@tiptap/core
Advanced tools
Comparing version 2.0.0-beta.34 to 2.0.0-beta.35
@@ -6,2 +6,14 @@ # Change Log | ||
# [2.0.0-beta.35](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.34...@tiptap/core@2.0.0-beta.35) (2021-04-21) | ||
### Features | ||
* add editor prop to KeyboardShortcutCommand ([e0c2460](https://github.com/ueberdosis/tiptap-next/commit/e0c2460a960c739ac4b543f0f185653cb41599e3)) | ||
* add name to extension context ([12f60ab](https://github.com/ueberdosis/tiptap-next/commit/12f60abb731edd080cb9a70e8e34ae721e37f80e)) | ||
# [2.0.0-beta.34](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.33...@tiptap/core@2.0.0-beta.34) (2021-04-20) | ||
@@ -8,0 +20,0 @@ |
import { NodeType } from 'prosemirror-model'; | ||
import { Command, RawCommands, AnyObject } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
insertNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
insertNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { Command, RawCommands, AnyObject } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
lift: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { Command, RawCommands, AnyObject } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
replace: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { Command, RawCommands, Range, AnyObject } from '../types'; | ||
import { Command, RawCommands, Range } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AnyObject, Command, RawCommands, Content } from '../types'; | ||
import { Command, RawCommands, Content } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -8,3 +8,3 @@ interface Commands { | ||
*/ | ||
setContent: (content: Content, emitUpdate?: Boolean, parseOptions?: AnyObject) => Command; | ||
setContent: (content: Content, emitUpdate?: Boolean, parseOptions?: Record<string, any>) => Command; | ||
}; | ||
@@ -11,0 +11,0 @@ } |
import { MarkType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
setMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command; | ||
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
setNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { MarkType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
toggleMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command; | ||
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
toggleWrap: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType, MarkType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: AnyObject) => Command; | ||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: AnyObject) => Command; | ||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
wrapIn: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject, Command, RawCommands } from '../types'; | ||
import { Command, RawCommands } from '../types'; | ||
declare module '@tiptap/core' { | ||
@@ -9,3 +9,3 @@ interface Commands { | ||
*/ | ||
wrapInList: (typeOrName: string | NodeType, attributes?: AnyObject) => Command; | ||
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command; | ||
}; | ||
@@ -12,0 +12,0 @@ } |
@@ -6,3 +6,3 @@ import { EditorState, Plugin, PluginKey, Transaction } from 'prosemirror-state'; | ||
import EventEmitter from './EventEmitter'; | ||
import { EditorOptions, CanCommands, ChainedCommands, SingleCommands, AnyObject } from './types'; | ||
import { EditorOptions, CanCommands, ChainedCommands, SingleCommands } from './types'; | ||
import * as extensions from './extensions'; | ||
@@ -103,3 +103,3 @@ export { extensions }; | ||
*/ | ||
getNodeAttributes(name: string): AnyObject; | ||
getNodeAttributes(name: string): Record<string, any>; | ||
/** | ||
@@ -110,3 +110,3 @@ * Get attributes of the currently selected mark. | ||
*/ | ||
getMarkAttributes(name: string): AnyObject; | ||
getMarkAttributes(name: string): Record<string, any>; | ||
/** | ||
@@ -123,3 +123,3 @@ * Returns if the currently selected node or mark is active. | ||
*/ | ||
getJSON(): AnyObject; | ||
getJSON(): Record<string, any>; | ||
/** | ||
@@ -126,0 +126,0 @@ * Get the document as HTML. |
import { Plugin, Transaction } from 'prosemirror-state'; | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
@@ -7,3 +6,3 @@ import { Editor } from './Editor'; | ||
import { Mark } from './Mark'; | ||
import { GlobalAttributes, RawCommands, ParentConfig } from './types'; | ||
import { GlobalAttributes, RawCommands, ParentConfig, KeyboardShortcutCommand } from './types'; | ||
import { ExtensionConfig } from '.'; | ||
@@ -29,2 +28,3 @@ declare module '@tiptap/core' { | ||
addGlobalAttributes?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -37,2 +37,3 @@ parent: ParentConfig<ExtensionConfig<Options>>['addGlobalAttributes']; | ||
addCommands?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -46,2 +47,3 @@ editor: Editor; | ||
addKeyboardShortcuts?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -51,3 +53,3 @@ editor: Editor; | ||
}) => { | ||
[key: string]: ProseMirrorCommand; | ||
[key: string]: KeyboardShortcutCommand; | ||
}; | ||
@@ -58,2 +60,3 @@ /** | ||
addInputRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -67,2 +70,3 @@ editor: Editor; | ||
addPasteRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -76,2 +80,3 @@ editor: Editor; | ||
addProseMirrorPlugins?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -85,7 +90,6 @@ editor: Editor; | ||
extendNodeSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<ExtensionConfig<Options>>['extendNodeSchema']; | ||
}, extension: Node) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Node) => Record<string, any>) | null; | ||
/** | ||
@@ -95,7 +99,6 @@ * Extend Mark Schema | ||
extendMarkSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<ExtensionConfig<Options>>['extendMarkSchema']; | ||
}, extension: Mark) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Mark) => Record<string, any>) | null; | ||
/** | ||
@@ -105,2 +108,3 @@ * The editor is not ready yet. | ||
onBeforeCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -114,2 +118,3 @@ editor: Editor; | ||
onCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -123,2 +128,3 @@ editor: Editor; | ||
onUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -132,2 +138,3 @@ editor: Editor; | ||
onSelectionUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -141,2 +148,3 @@ editor: Editor; | ||
onTransaction?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -152,2 +160,3 @@ editor: Editor; | ||
onFocus?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -163,2 +172,3 @@ editor: Editor; | ||
onBlur?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -174,2 +184,3 @@ editor: Editor; | ||
onDestroy?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -176,0 +187,0 @@ editor: Editor; |
import { Schema, Node as ProseMirrorNode } from 'prosemirror-model'; | ||
import { AnyObject, Content } from '../types'; | ||
export default function createDocument(content: Content, schema: Schema, parseOptions?: AnyObject): ProseMirrorNode; | ||
import { Content } from '../types'; | ||
export default function createDocument(content: Content, schema: Schema, parseOptions?: Record<string, any>): ProseMirrorNode; |
import { Schema, Node as ProseMirrorNode, Fragment } from 'prosemirror-model'; | ||
import { AnyObject, Content } from '../types'; | ||
import { Content } from '../types'; | ||
export declare type CreateNodeFromContentOptions = { | ||
slice?: boolean; | ||
parseOptions?: AnyObject; | ||
parseOptions?: Record<string, any>; | ||
}; | ||
export default function createNodeFromContent(content: Content, schema: Schema, options?: CreateNodeFromContentOptions): string | ProseMirrorNode | Fragment; |
@@ -1,2 +0,2 @@ | ||
import { AnyExtension, AnyObject, RemoveThis } from '../types'; | ||
export default function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: AnyObject): RemoveThis<T>; | ||
import { AnyExtension, RemoveThis } from '../types'; | ||
export default function getExtensionField<T = any>(extension: AnyExtension, field: string, context?: Record<string, any>): RemoveThis<T>; |
import { EditorState } from 'prosemirror-state'; | ||
import { MarkType } from 'prosemirror-model'; | ||
import { AnyObject } from '../types'; | ||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): AnyObject; | ||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any>; |
import { EditorState } from 'prosemirror-state'; | ||
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject } from '../types'; | ||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): AnyObject; | ||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any>; |
import { Node, Mark } from 'prosemirror-model'; | ||
import { ExtensionAttribute, AnyObject } from '../types'; | ||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): AnyObject; | ||
import { ExtensionAttribute } from '../types'; | ||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record<string, any>; |
@@ -1,2 +0,2 @@ | ||
import { AnyObject, ExtensionAttribute } from '../types'; | ||
export default function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: AnyObject): AnyObject; | ||
import { ExtensionAttribute } from '../types'; | ||
export default function getSplittedAttributes(extensionAttributes: ExtensionAttribute[], typeName: string, attributes: Record<string, any>): Record<string, any>; |
import { EditorState } from 'prosemirror-state'; | ||
import { AnyObject } from '../types'; | ||
export default function isActive(state: EditorState, name: string | null, attributes?: AnyObject): boolean; | ||
export default function isActive(state: EditorState, name: string | null, attributes?: Record<string, any>): boolean; |
import { EditorState } from 'prosemirror-state'; | ||
import { MarkType } from 'prosemirror-model'; | ||
import { AnyObject } from '../types'; | ||
export default function isMarkActive(state: EditorState, typeOrName: MarkType | string | null, attributes?: AnyObject): boolean; | ||
export default function isMarkActive(state: EditorState, typeOrName: MarkType | string | null, attributes?: Record<string, any>): boolean; |
import { EditorState } from 'prosemirror-state'; | ||
import { NodeType } from 'prosemirror-model'; | ||
import { AnyObject } from '../types'; | ||
export default function isNodeActive(state: EditorState, typeOrName: NodeType | string | null, attributes?: AnyObject): boolean; | ||
export default function isNodeActive(state: EditorState, typeOrName: NodeType | string | null, attributes?: Record<string, any>): boolean; |
import { DOMOutputSpec, MarkSpec, Mark as ProseMirrorMark, MarkType } from 'prosemirror-model'; | ||
import { Plugin, Transaction } from 'prosemirror-state'; | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
import { Attributes, RawCommands, GlobalAttributes, ParentConfig } from './types'; | ||
import { Attributes, RawCommands, GlobalAttributes, ParentConfig, KeyboardShortcutCommand } from './types'; | ||
import { Node } from './Node'; | ||
@@ -28,2 +27,3 @@ import { MarkConfig } from '.'; | ||
addGlobalAttributes?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -36,2 +36,3 @@ parent: ParentConfig<MarkConfig<Options>>['addGlobalAttributes']; | ||
addCommands?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -46,2 +47,3 @@ editor: Editor; | ||
addKeyboardShortcuts?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -52,3 +54,3 @@ editor: Editor; | ||
}) => { | ||
[key: string]: ProseMirrorCommand; | ||
[key: string]: KeyboardShortcutCommand; | ||
}; | ||
@@ -59,2 +61,3 @@ /** | ||
addInputRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -69,2 +72,3 @@ editor: Editor; | ||
addPasteRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -79,2 +83,3 @@ editor: Editor; | ||
addProseMirrorPlugins?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -89,7 +94,6 @@ editor: Editor; | ||
extendNodeSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<MarkConfig<Options>>['extendNodeSchema']; | ||
}, extension: Node) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Node) => Record<string, any>) | null; | ||
/** | ||
@@ -99,7 +103,6 @@ * Extend Mark Schema | ||
extendMarkSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<MarkConfig<Options>>['extendMarkSchema']; | ||
}, extension: Mark) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Mark) => Record<string, any>) | null; | ||
/** | ||
@@ -109,2 +112,3 @@ * The editor is not ready yet. | ||
onBeforeCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -119,2 +123,3 @@ editor: Editor; | ||
onCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -129,2 +134,3 @@ editor: Editor; | ||
onUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -139,2 +145,3 @@ editor: Editor; | ||
onSelectionUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -149,2 +156,3 @@ editor: Editor; | ||
onTransaction?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -161,2 +169,3 @@ editor: Editor; | ||
onFocus?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -173,2 +182,3 @@ editor: Editor; | ||
onBlur?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -185,2 +195,3 @@ editor: Editor; | ||
onDestroy?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -199,2 +210,3 @@ editor: Editor; | ||
inclusive?: MarkSpec['inclusive'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -207,2 +219,3 @@ parent: ParentConfig<MarkConfig<Options>>['inclusive']; | ||
excludes?: MarkSpec['excludes'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -215,2 +228,3 @@ parent: ParentConfig<MarkConfig<Options>>['excludes']; | ||
group?: MarkSpec['group'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -223,2 +237,3 @@ parent: ParentConfig<MarkConfig<Options>>['group']; | ||
spanning?: MarkSpec['spanning'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -231,2 +246,3 @@ parent: ParentConfig<MarkConfig<Options>>['spanning']; | ||
parseHTML?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -239,2 +255,3 @@ parent: ParentConfig<MarkConfig<Options>>['parseHTML']; | ||
renderHTML?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -244,5 +261,3 @@ parent: ParentConfig<MarkConfig<Options>>['renderHTML']; | ||
mark: ProseMirrorMark; | ||
HTMLAttributes: { | ||
[key: string]: any; | ||
}; | ||
HTMLAttributes: Record<string, any>; | ||
}) => DOMOutputSpec) | null; | ||
@@ -253,2 +268,3 @@ /** | ||
addAttributes?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -255,0 +271,0 @@ parent: ParentConfig<MarkConfig<Options>>['addAttributes']; |
import { DOMOutputSpec, NodeSpec, Node as ProseMirrorNode, NodeType } from 'prosemirror-model'; | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands'; | ||
import { Plugin, Transaction } from 'prosemirror-state'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
import { Attributes, NodeViewRenderer, GlobalAttributes, RawCommands, ParentConfig } from './types'; | ||
import { Attributes, NodeViewRenderer, GlobalAttributes, RawCommands, ParentConfig, KeyboardShortcutCommand } from './types'; | ||
import { NodeConfig } from '.'; | ||
@@ -27,2 +26,3 @@ import { Editor } from './Editor'; | ||
addGlobalAttributes?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -35,2 +35,3 @@ parent: ParentConfig<NodeConfig<Options>>['addGlobalAttributes']; | ||
addCommands?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -45,2 +46,3 @@ editor: Editor; | ||
addKeyboardShortcuts?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -51,3 +53,3 @@ editor: Editor; | ||
}) => { | ||
[key: string]: ProseMirrorCommand; | ||
[key: string]: KeyboardShortcutCommand; | ||
}; | ||
@@ -58,2 +60,3 @@ /** | ||
addInputRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -68,2 +71,3 @@ editor: Editor; | ||
addPasteRules?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -78,2 +82,3 @@ editor: Editor; | ||
addProseMirrorPlugins?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -88,7 +93,6 @@ editor: Editor; | ||
extendNodeSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<NodeConfig<Options>>['extendNodeSchema']; | ||
}, extension: Node) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Node) => Record<string, any>) | null; | ||
/** | ||
@@ -98,7 +102,6 @@ * Extend Mark Schema | ||
extendMarkSchema?: ((this: { | ||
name: string; | ||
options: Options; | ||
parent: ParentConfig<NodeConfig<Options>>['extendMarkSchema']; | ||
}, extension: Node) => { | ||
[key: string]: any; | ||
}) | null; | ||
}, extension: Node) => Record<string, any>) | null; | ||
/** | ||
@@ -108,2 +111,3 @@ * The editor is not ready yet. | ||
onBeforeCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -118,2 +122,3 @@ editor: Editor; | ||
onCreate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -128,2 +133,3 @@ editor: Editor; | ||
onUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -138,2 +144,3 @@ editor: Editor; | ||
onSelectionUpdate?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -148,2 +155,3 @@ editor: Editor; | ||
onTransaction?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -160,2 +168,3 @@ editor: Editor; | ||
onFocus?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -172,2 +181,3 @@ editor: Editor; | ||
onBlur?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -184,2 +194,3 @@ editor: Editor; | ||
onDestroy?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -194,2 +205,3 @@ editor: Editor; | ||
addNodeView?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -208,2 +220,3 @@ editor: Editor; | ||
content?: NodeSpec['content'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -216,2 +229,3 @@ parent: ParentConfig<NodeConfig<Options>>['content']; | ||
marks?: NodeSpec['marks'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -224,2 +238,3 @@ parent: ParentConfig<NodeConfig<Options>>['marks']; | ||
group?: NodeSpec['group'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -232,2 +247,3 @@ parent: ParentConfig<NodeConfig<Options>>['group']; | ||
inline?: NodeSpec['inline'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -240,2 +256,3 @@ parent: ParentConfig<NodeConfig<Options>>['inline']; | ||
atom?: NodeSpec['atom'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -248,2 +265,3 @@ parent: ParentConfig<NodeConfig<Options>>['atom']; | ||
selectable?: NodeSpec['selectable'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -256,2 +274,3 @@ parent: ParentConfig<NodeConfig<Options>>['selectable']; | ||
draggable?: NodeSpec['draggable'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -264,2 +283,3 @@ parent: ParentConfig<NodeConfig<Options>>['draggable']; | ||
code?: NodeSpec['code'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -272,2 +292,3 @@ parent: ParentConfig<NodeConfig<Options>>['code']; | ||
defining?: NodeSpec['defining'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -280,2 +301,3 @@ parent: ParentConfig<NodeConfig<Options>>['defining']; | ||
isolating?: NodeSpec['isolating'] | ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -288,2 +310,3 @@ parent: ParentConfig<NodeConfig<Options>>['isolating']; | ||
parseHTML?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -296,2 +319,3 @@ parent: ParentConfig<NodeConfig<Options>>['parseHTML']; | ||
renderHTML?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -301,5 +325,3 @@ parent: ParentConfig<NodeConfig<Options>>['renderHTML']; | ||
node: ProseMirrorNode; | ||
HTMLAttributes: { | ||
[key: string]: any; | ||
}; | ||
HTMLAttributes: Record<string, any>; | ||
}) => DOMOutputSpec) | null; | ||
@@ -310,2 +332,3 @@ /** | ||
renderText?: ((this: { | ||
name: string; | ||
options: Options; | ||
@@ -322,2 +345,3 @@ editor: Editor; | ||
addAttributes?: (this: { | ||
name: string; | ||
options: Options; | ||
@@ -324,0 +348,0 @@ parent: ParentConfig<NodeConfig<Options>>['addAttributes']; |
@@ -54,3 +54,3 @@ import { Node as ProseMirrorNode, Mark as ProseMirrorMark, ParseOptions } from 'prosemirror-model'; | ||
} | ||
export declare type Content = string | AnyObject | null; | ||
export declare type Content = string | Record<string, any> | null; | ||
export declare type CommandProps = { | ||
@@ -68,13 +68,10 @@ editor: Editor; | ||
export declare type CommandSpec = (...args: any[]) => Command; | ||
export declare type KeyboardShortcutCommand = (props: { | ||
editor: Editor; | ||
}) => boolean; | ||
export declare type Attribute = { | ||
default: any; | ||
rendered?: boolean; | ||
renderHTML?: ((attributes: { | ||
[key: string]: any; | ||
}) => { | ||
[key: string]: any; | ||
} | null) | null; | ||
parseHTML?: ((element: HTMLElement) => { | ||
[key: string]: any; | ||
} | null) | null; | ||
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null; | ||
parseHTML?: ((element: HTMLElement) => Record<string, any> | null) | null; | ||
keepOnSplit: boolean; | ||
@@ -106,5 +103,2 @@ }; | ||
export declare type Overwrite<T, U> = Pick<T, Diff<keyof T, keyof U>> & U; | ||
export declare type AnyObject = { | ||
[key: string]: any; | ||
}; | ||
export declare type ValuesOf<T> = T[keyof T]; | ||
@@ -121,3 +115,3 @@ export declare type KeysWithTypeOf<T, Type> = ({ | ||
getPos: () => number; | ||
updateAttributes: (attributes: AnyObject) => void; | ||
updateAttributes: (attributes: Record<string, any>) => void; | ||
}; | ||
@@ -128,5 +122,3 @@ export declare type NodeViewRendererProps = { | ||
getPos: (() => number) | boolean; | ||
HTMLAttributes: { | ||
[key: string]: any; | ||
}; | ||
HTMLAttributes: Record<string, any>; | ||
decorations: Decoration[]; | ||
@@ -133,0 +125,0 @@ extension: Node; |
@@ -1,2 +0,1 @@ | ||
import { AnyObject } from '../types'; | ||
/** | ||
@@ -7,2 +6,2 @@ * Remove a property or an array of properties from an object | ||
*/ | ||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]): AnyObject; | ||
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any>; |
@@ -1,2 +0,1 @@ | ||
import { AnyObject } from '../types'; | ||
export default function mergeAttributes(...objects: AnyObject[]): AnyObject; | ||
export default function mergeAttributes(...objects: Record<string, any>[]): Record<string, any>; |
@@ -1,2 +0,1 @@ | ||
import { AnyObject } from '../types'; | ||
export default function mergeDeep(target: AnyObject, source: AnyObject): AnyObject; | ||
export default function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any>; |
@@ -1,2 +0,1 @@ | ||
import { AnyObject } from '../types'; | ||
/** | ||
@@ -7,2 +6,2 @@ * Check if object1 includes object2 | ||
*/ | ||
export default function objectIncludes(object1: AnyObject, object2: AnyObject): boolean; | ||
export default function objectIncludes(object1: Record<string, any>, object2: Record<string, any>): boolean; |
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.0.0-beta.34", | ||
"version": "2.0.0-beta.35", | ||
"homepage": "https://tiptap.dev", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "8bb30776bc062c85d6478d56eac8817568fc9e1c" | ||
"gitHead": "8fd618a788f288a9005e8e049d2f8f8df5523b6d" | ||
} |
import { NodeType } from 'prosemirror-model' | ||
import getNodeType from '../helpers/getNodeType' | ||
import { Command, RawCommands, AnyObject } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
@@ -11,3 +11,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
insertNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
insertNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -14,0 +14,0 @@ } |
import { lift as originalLift } from 'prosemirror-commands' | ||
import { NodeType } from 'prosemirror-model' | ||
import { Command, RawCommands, AnyObject } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import isNodeActive from '../helpers/isNodeActive' | ||
@@ -13,3 +13,3 @@ import getNodeType from '../helpers/getNodeType' | ||
*/ | ||
lift: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -16,0 +16,0 @@ } |
import { NodeType } from 'prosemirror-model' | ||
import { Command, RawCommands, AnyObject } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
@@ -10,3 +10,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
replace: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
replace: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -13,0 +13,0 @@ } |
import { NodeType } from 'prosemirror-model' | ||
import getNodeType from '../helpers/getNodeType' | ||
import { | ||
Command, | ||
RawCommands, | ||
Range, | ||
AnyObject, | ||
} from '../types' | ||
import { Command, RawCommands, Range } from '../types' | ||
@@ -16,3 +11,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
replaceRange: (range: Range, typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -19,0 +14,0 @@ } |
import { TextSelection } from 'prosemirror-state' | ||
import createDocument from '../helpers/createDocument' | ||
import { | ||
AnyObject, | ||
Command, | ||
RawCommands, | ||
Content, | ||
} from '../types' | ||
import { Command, RawCommands, Content } from '../types' | ||
@@ -19,3 +14,3 @@ declare module '@tiptap/core' { | ||
emitUpdate?: Boolean, | ||
parseOptions?: AnyObject, | ||
parseOptions?: Record<string, any>, | ||
) => Command, | ||
@@ -22,0 +17,0 @@ } |
import { MarkType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import getMarkType from '../helpers/getMarkType' | ||
@@ -12,3 +12,3 @@ import getMarkAttributes from '../helpers/getMarkAttributes' | ||
*/ | ||
setMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command, | ||
setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -15,0 +15,0 @@ } |
import { NodeType } from 'prosemirror-model' | ||
import { setBlockType } from 'prosemirror-commands' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import getNodeType from '../helpers/getNodeType' | ||
@@ -12,3 +12,3 @@ | ||
*/ | ||
setNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -15,0 +15,0 @@ } |
import { MarkType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import getMarkType from '../helpers/getMarkType' | ||
@@ -12,3 +12,3 @@ import isMarkActive from '../helpers/isMarkActive' | ||
*/ | ||
toggleMark: (typeOrName: string | MarkType, attributes?: AnyObject) => Command, | ||
toggleMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -15,0 +15,0 @@ } |
import { NodeType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import isNodeActive from '../helpers/isNodeActive' | ||
@@ -12,3 +12,3 @@ import getNodeType from '../helpers/getNodeType' | ||
*/ | ||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
toggleNode: (typeOrName: string | NodeType, toggleTypeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -15,0 +15,0 @@ } |
import { wrapIn, lift } from 'prosemirror-commands' | ||
import { NodeType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import isNodeActive from '../helpers/isNodeActive' | ||
@@ -13,3 +13,3 @@ import getNodeType from '../helpers/getNodeType' | ||
*/ | ||
toggleWrap: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -16,0 +16,0 @@ } |
@@ -5,3 +5,3 @@ import { NodeType, MarkType } from 'prosemirror-model' | ||
import getSchemaTypeNameByName from '../helpers/getSchemaTypeNameByName' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
@@ -14,3 +14,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: AnyObject) => Command, | ||
updateAttributes: (typeOrName: string | NodeType | MarkType, attributes: Record<string, any>) => Command, | ||
} | ||
@@ -17,0 +17,0 @@ } |
import { NodeType } from 'prosemirror-model' | ||
import getNodeType from '../helpers/getNodeType' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
@@ -11,3 +11,3 @@ declare module '@tiptap/core' { | ||
*/ | ||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: AnyObject) => Command, | ||
updateNodeAttributes: (typeOrName: string | NodeType, attributes: Record<string, any>) => Command, | ||
} | ||
@@ -14,0 +14,0 @@ } |
import { wrapIn as originalWrapIn } from 'prosemirror-commands' | ||
import { NodeType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import isNodeActive from '../helpers/isNodeActive' | ||
@@ -13,3 +13,3 @@ import getNodeType from '../helpers/getNodeType' | ||
*/ | ||
wrapIn: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -16,0 +16,0 @@ } |
import { wrapInList as originalWrapInList } from 'prosemirror-schema-list' | ||
import { NodeType } from 'prosemirror-model' | ||
import { AnyObject, Command, RawCommands } from '../types' | ||
import { Command, RawCommands } from '../types' | ||
import getNodeType from '../helpers/getNodeType' | ||
@@ -12,3 +12,3 @@ | ||
*/ | ||
wrapInList: (typeOrName: string | NodeType, attributes?: AnyObject) => Command, | ||
wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => Command, | ||
} | ||
@@ -15,0 +15,0 @@ } |
@@ -22,3 +22,2 @@ import { | ||
SingleCommands, | ||
AnyObject, | ||
} from './types' | ||
@@ -345,3 +344,3 @@ import * as extensions from './extensions' | ||
*/ | ||
public getNodeAttributes(name: string): AnyObject { | ||
public getNodeAttributes(name: string): Record<string, any> { | ||
return getNodeAttributes(this.state, name) | ||
@@ -355,3 +354,3 @@ } | ||
*/ | ||
public getMarkAttributes(name: string): AnyObject { | ||
public getMarkAttributes(name: string): Record<string, any> { | ||
return getMarkAttributes(this.state, name) | ||
@@ -383,3 +382,3 @@ } | ||
*/ | ||
public getJSON(): AnyObject { | ||
public getJSON(): Record<string, any> { | ||
return this.state.doc.toJSON() | ||
@@ -386,0 +385,0 @@ } |
import { Plugin, Transaction } from 'prosemirror-state' | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands' | ||
import { InputRule } from 'prosemirror-inputrules' | ||
@@ -8,3 +7,8 @@ import { Editor } from './Editor' | ||
import mergeDeep from './utilities/mergeDeep' | ||
import { GlobalAttributes, RawCommands, ParentConfig } from './types' | ||
import { | ||
GlobalAttributes, | ||
RawCommands, | ||
ParentConfig, | ||
KeyboardShortcutCommand, | ||
} from './types' | ||
import { ExtensionConfig } from '.' | ||
@@ -35,2 +39,3 @@ | ||
addGlobalAttributes?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -44,2 +49,3 @@ parent: ParentConfig<ExtensionConfig<Options>>['addGlobalAttributes'], | ||
addCommands?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -54,2 +60,3 @@ editor: Editor, | ||
addKeyboardShortcuts?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -59,3 +66,3 @@ editor: Editor, | ||
}) => { | ||
[key: string]: ProseMirrorCommand, | ||
[key: string]: KeyboardShortcutCommand, | ||
}, | ||
@@ -67,2 +74,3 @@ | ||
addInputRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -77,2 +85,3 @@ editor: Editor, | ||
addPasteRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -87,2 +96,3 @@ editor: Editor, | ||
addProseMirrorPlugins?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -98,2 +108,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -103,5 +114,3 @@ parent: ParentConfig<ExtensionConfig<Options>>['extendNodeSchema'], | ||
extension: Node, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -113,2 +122,3 @@ /** | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -118,5 +128,3 @@ parent: ParentConfig<ExtensionConfig<Options>>['extendMarkSchema'], | ||
extension: Mark, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -126,3 +134,4 @@ /** | ||
*/ | ||
onBeforeCreate?: ((this: { | ||
onBeforeCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -137,2 +146,3 @@ editor: Editor, | ||
onCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -147,2 +157,3 @@ editor: Editor, | ||
onUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -157,2 +168,3 @@ editor: Editor, | ||
onSelectionUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -168,2 +180,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -183,2 +196,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -198,2 +212,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -212,2 +227,3 @@ editor: Editor, | ||
onDestroy?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -214,0 +230,0 @@ editor: Editor, |
@@ -35,2 +35,3 @@ import { keymap } from 'prosemirror-keymap' | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -153,2 +154,3 @@ editor: this.editor, | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -181,2 +183,3 @@ editor: this.editor, | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -196,4 +199,12 @@ editor: this.editor, | ||
if (addKeyboardShortcuts) { | ||
const keyMapPlugin = keymap(addKeyboardShortcuts()) | ||
const bindings = Object.fromEntries( | ||
Object | ||
.entries(addKeyboardShortcuts()) | ||
.map(([shortcut, method]) => { | ||
return [shortcut, () => method({ editor: this.editor })] | ||
}), | ||
) | ||
const keyMapPlugin = keymap(bindings) | ||
plugins.push(keyMapPlugin) | ||
@@ -259,2 +270,3 @@ } | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -304,2 +316,3 @@ editor, | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -306,0 +319,0 @@ editor, |
import { Schema, Node as ProseMirrorNode } from 'prosemirror-model' | ||
import { AnyObject, Content } from '../types' | ||
import { Content } from '../types' | ||
import createNodeFromContent from './createNodeFromContent' | ||
@@ -8,5 +8,5 @@ | ||
schema: Schema, | ||
parseOptions: AnyObject = {}, | ||
parseOptions: Record<string, any> = {}, | ||
): ProseMirrorNode { | ||
return createNodeFromContent(content, schema, { slice: false, parseOptions }) as ProseMirrorNode | ||
} |
@@ -8,7 +8,7 @@ import { | ||
import elementFromString from '../utilities/elementFromString' | ||
import { AnyObject, Content } from '../types' | ||
import { Content } from '../types' | ||
export type CreateNodeFromContentOptions = { | ||
slice?: boolean, | ||
parseOptions?: AnyObject, | ||
parseOptions?: Record<string, any>, | ||
} | ||
@@ -15,0 +15,0 @@ |
@@ -31,2 +31,3 @@ import splitExtensions from './splitExtensions' | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -68,2 +69,3 @@ } | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -70,0 +72,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AnyExtension, AnyObject, RemoveThis } from '../types' | ||
import { AnyExtension, RemoveThis } from '../types' | ||
@@ -6,3 +6,3 @@ export default function getExtensionField<T = any>( | ||
field: string, | ||
context: AnyObject = {}, | ||
context: Record<string, any> = {}, | ||
): RemoveThis<T> { | ||
@@ -9,0 +9,0 @@ |
import { EditorState } from 'prosemirror-state' | ||
import { Mark, MarkType } from 'prosemirror-model' | ||
import getMarkType from './getMarkType' | ||
import { AnyObject } from '../types' | ||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): AnyObject { | ||
export default function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> { | ||
const type = getMarkType(typeOrName, state.schema) | ||
@@ -8,0 +7,0 @@ const { from, to, empty } = state.selection |
import { EditorState } from 'prosemirror-state' | ||
import { Node, NodeType } from 'prosemirror-model' | ||
import getNodeType from './getNodeType' | ||
import { AnyObject } from '../types' | ||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): AnyObject { | ||
export default function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> { | ||
const type = getNodeType(typeOrName, state.schema) | ||
@@ -8,0 +7,0 @@ const { from, to } = state.selection |
import { Node, Mark } from 'prosemirror-model' | ||
import { ExtensionAttribute, AnyObject } from '../types' | ||
import { ExtensionAttribute } from '../types' | ||
import mergeAttributes from '../utilities/mergeAttributes' | ||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): AnyObject { | ||
export default function getRenderedAttributes(nodeOrMark: Node | Mark, extensionAttributes: ExtensionAttribute[]): Record<string, any> { | ||
return extensionAttributes | ||
@@ -7,0 +7,0 @@ .filter(item => item.attribute.rendered) |
@@ -30,2 +30,3 @@ import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model' | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -86,2 +87,3 @@ } | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
@@ -88,0 +90,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { AnyObject, ExtensionAttribute } from '../types' | ||
import { ExtensionAttribute } from '../types' | ||
@@ -6,4 +6,4 @@ export default function getSplittedAttributes( | ||
typeName: string, | ||
attributes: AnyObject, | ||
): AnyObject { | ||
attributes: Record<string, any>, | ||
): Record<string, any> { | ||
return Object.fromEntries(Object | ||
@@ -10,0 +10,0 @@ .entries(attributes) |
@@ -5,5 +5,4 @@ import { EditorState } from 'prosemirror-state' | ||
import getSchemaTypeNameByName from './getSchemaTypeNameByName' | ||
import { AnyObject } from '../types' | ||
export default function isActive(state: EditorState, name: string | null, attributes: AnyObject = {}): boolean { | ||
export default function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean { | ||
if (!name) { | ||
@@ -10,0 +9,0 @@ return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes) |
@@ -15,3 +15,6 @@ import { Extensions } from '../types' | ||
const context = { options: extension.options } | ||
const context = { | ||
name: extension.name, | ||
options: extension.options, | ||
} | ||
const group = callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context)) | ||
@@ -18,0 +21,0 @@ |
@@ -5,3 +5,3 @@ import { EditorState } from 'prosemirror-state' | ||
import getMarkType from './getMarkType' | ||
import { AnyObject, MarkRange } from '../types' | ||
import { MarkRange } from '../types' | ||
@@ -11,3 +11,3 @@ export default function isMarkActive( | ||
typeOrName: MarkType | string | null, | ||
attributes: AnyObject = {}, | ||
attributes: Record<string, any> = {}, | ||
): boolean { | ||
@@ -14,0 +14,0 @@ const { from, to, empty } = state.selection |
@@ -5,3 +5,3 @@ import { EditorState } from 'prosemirror-state' | ||
import getNodeType from './getNodeType' | ||
import { AnyObject, NodeRange } from '../types' | ||
import { NodeRange } from '../types' | ||
@@ -11,3 +11,3 @@ export default function isNodeActive( | ||
typeOrName: NodeType | string | null, | ||
attributes: AnyObject = {}, | ||
attributes: Record<string, any> = {}, | ||
): boolean { | ||
@@ -14,0 +14,0 @@ const { from, to, empty } = state.selection |
@@ -8,3 +8,2 @@ import { | ||
import { Plugin, Transaction } from 'prosemirror-state' | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands' | ||
import { InputRule } from 'prosemirror-inputrules' | ||
@@ -17,2 +16,3 @@ import mergeDeep from './utilities/mergeDeep' | ||
ParentConfig, | ||
KeyboardShortcutCommand, | ||
} from './types' | ||
@@ -46,2 +46,3 @@ import { Node } from './Node' | ||
addGlobalAttributes?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -55,2 +56,3 @@ parent: ParentConfig<MarkConfig<Options>>['addGlobalAttributes'], | ||
addCommands?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -66,2 +68,3 @@ editor: Editor, | ||
addKeyboardShortcuts?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -72,3 +75,3 @@ editor: Editor, | ||
}) => { | ||
[key: string]: ProseMirrorCommand, | ||
[key: string]: KeyboardShortcutCommand, | ||
}, | ||
@@ -80,2 +83,3 @@ | ||
addInputRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -91,2 +95,3 @@ editor: Editor, | ||
addPasteRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -102,2 +107,3 @@ editor: Editor, | ||
addProseMirrorPlugins?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -114,2 +120,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -119,5 +126,3 @@ parent: ParentConfig<MarkConfig<Options>>['extendNodeSchema'], | ||
extension: Node, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -129,2 +134,3 @@ /** | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -134,5 +140,3 @@ parent: ParentConfig<MarkConfig<Options>>['extendMarkSchema'], | ||
extension: Mark, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -143,2 +147,3 @@ /** | ||
onBeforeCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -154,2 +159,3 @@ editor: Editor, | ||
onCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -165,2 +171,3 @@ editor: Editor, | ||
onUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -176,2 +183,3 @@ editor: Editor, | ||
onSelectionUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -188,2 +196,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -204,2 +213,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -220,2 +230,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -235,2 +246,3 @@ editor: Editor, | ||
onDestroy?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -251,2 +263,3 @@ editor: Editor, | ||
inclusive?: MarkSpec['inclusive'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -260,2 +273,3 @@ parent: ParentConfig<MarkConfig<Options>>['inclusive'], | ||
excludes?: MarkSpec['excludes'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -269,2 +283,3 @@ parent: ParentConfig<MarkConfig<Options>>['excludes'], | ||
group?: MarkSpec['group'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -278,2 +293,3 @@ parent: ParentConfig<MarkConfig<Options>>['group'], | ||
spanning?: MarkSpec['spanning'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -288,2 +304,3 @@ parent: ParentConfig<MarkConfig<Options>>['spanning'], | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -299,2 +316,3 @@ parent: ParentConfig<MarkConfig<Options>>['parseHTML'], | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -305,3 +323,3 @@ parent: ParentConfig<MarkConfig<Options>>['renderHTML'], | ||
mark: ProseMirrorMark, | ||
HTMLAttributes: { [key: string]: any }, | ||
HTMLAttributes: Record<string, any>, | ||
}, | ||
@@ -315,2 +333,3 @@ ) => DOMOutputSpec) | null, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -317,0 +336,0 @@ parent: ParentConfig<MarkConfig<Options>>['addAttributes'], |
@@ -7,3 +7,2 @@ import { | ||
} from 'prosemirror-model' | ||
import { Command as ProseMirrorCommand } from 'prosemirror-commands' | ||
import { Plugin, Transaction } from 'prosemirror-state' | ||
@@ -18,2 +17,3 @@ import { InputRule } from 'prosemirror-inputrules' | ||
ParentConfig, | ||
KeyboardShortcutCommand, | ||
} from './types' | ||
@@ -46,2 +46,3 @@ import { NodeConfig } from '.' | ||
addGlobalAttributes?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -55,2 +56,3 @@ parent: ParentConfig<NodeConfig<Options>>['addGlobalAttributes'], | ||
addCommands?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -66,2 +68,3 @@ editor: Editor, | ||
addKeyboardShortcuts?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -72,3 +75,3 @@ editor: Editor, | ||
}) => { | ||
[key: string]: ProseMirrorCommand, | ||
[key: string]: KeyboardShortcutCommand, | ||
}, | ||
@@ -80,2 +83,3 @@ | ||
addInputRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -91,2 +95,3 @@ editor: Editor, | ||
addPasteRules?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -102,2 +107,3 @@ editor: Editor, | ||
addProseMirrorPlugins?: (this: { | ||
name: string, | ||
options: Options, | ||
@@ -114,2 +120,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -119,5 +126,3 @@ parent: ParentConfig<NodeConfig<Options>>['extendNodeSchema'], | ||
extension: Node, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -129,2 +134,3 @@ /** | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -134,5 +140,3 @@ parent: ParentConfig<NodeConfig<Options>>['extendMarkSchema'], | ||
extension: Node, | ||
) => { | ||
[key: string]: any, | ||
}) | null, | ||
) => Record<string, any>) | null, | ||
@@ -142,3 +146,4 @@ /** | ||
*/ | ||
onBeforeCreate?: ((this: { | ||
onBeforeCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -154,2 +159,3 @@ editor: Editor, | ||
onCreate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -165,2 +171,3 @@ editor: Editor, | ||
onUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -176,2 +183,3 @@ editor: Editor, | ||
onSelectionUpdate?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -188,2 +196,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -204,2 +213,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -220,2 +230,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -235,2 +246,3 @@ editor: Editor, | ||
onDestroy?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -246,2 +258,3 @@ editor: Editor, | ||
addNodeView?: ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -262,2 +275,3 @@ editor: Editor, | ||
content?: NodeSpec['content'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -271,2 +285,3 @@ parent: ParentConfig<NodeConfig<Options>>['content'], | ||
marks?: NodeSpec['marks'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -280,2 +295,3 @@ parent: ParentConfig<NodeConfig<Options>>['marks'], | ||
group?: NodeSpec['group'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -289,2 +305,3 @@ parent: ParentConfig<NodeConfig<Options>>['group'], | ||
inline?: NodeSpec['inline'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -298,2 +315,3 @@ parent: ParentConfig<NodeConfig<Options>>['inline'], | ||
atom?: NodeSpec['atom'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -307,2 +325,3 @@ parent: ParentConfig<NodeConfig<Options>>['atom'], | ||
selectable?: NodeSpec['selectable'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -316,2 +335,3 @@ parent: ParentConfig<NodeConfig<Options>>['selectable'], | ||
draggable?: NodeSpec['draggable'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -325,2 +345,3 @@ parent: ParentConfig<NodeConfig<Options>>['draggable'], | ||
code?: NodeSpec['code'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -334,2 +355,3 @@ parent: ParentConfig<NodeConfig<Options>>['code'], | ||
defining?: NodeSpec['defining'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -343,2 +365,3 @@ parent: ParentConfig<NodeConfig<Options>>['defining'], | ||
isolating?: NodeSpec['isolating'] | ((this: { | ||
name: string, | ||
options: Options, | ||
@@ -353,2 +376,3 @@ parent: ParentConfig<NodeConfig<Options>>['isolating'], | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -364,2 +388,3 @@ parent: ParentConfig<NodeConfig<Options>>['parseHTML'], | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -370,3 +395,3 @@ parent: ParentConfig<NodeConfig<Options>>['renderHTML'], | ||
node: ProseMirrorNode, | ||
HTMLAttributes: { [key: string]: any }, | ||
HTMLAttributes: Record<string, any>, | ||
} | ||
@@ -380,2 +405,3 @@ ) => DOMOutputSpec) | null, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -396,2 +422,3 @@ editor: Editor, | ||
this: { | ||
name: string, | ||
options: Options, | ||
@@ -398,0 +425,0 @@ parent: ParentConfig<NodeConfig<Options>>['addAttributes'], |
@@ -63,3 +63,3 @@ import { | ||
export type Content = string | AnyObject | null | ||
export type Content = string | Record<string, any> | null | ||
@@ -81,7 +81,9 @@ export type CommandProps = { | ||
export type KeyboardShortcutCommand = (props: { editor: Editor }) => boolean | ||
export type Attribute = { | ||
default: any, | ||
rendered?: boolean, | ||
renderHTML?: ((attributes: { [key: string]: any }) => { [key: string]: any } | null) | null, | ||
parseHTML?: ((element: HTMLElement) => { [key: string]: any } | null) | null, | ||
renderHTML?: ((attributes: Record<string, any>) => Record<string, any> | null) | null, | ||
parseHTML?: ((element: HTMLElement) => Record<string, any> | null) | null, | ||
keepOnSplit: boolean, | ||
@@ -118,6 +120,2 @@ } | ||
export type AnyObject = { | ||
[key: string]: any | ||
} | ||
export type ValuesOf<T> = T[keyof T]; | ||
@@ -134,3 +132,3 @@ | ||
getPos: () => number, | ||
updateAttributes: (attributes: AnyObject) => void, | ||
updateAttributes: (attributes: Record<string, any>) => void, | ||
} | ||
@@ -142,3 +140,3 @@ | ||
getPos: (() => number) | boolean, | ||
HTMLAttributes: { [key: string]: any }, | ||
HTMLAttributes: Record<string, any>, | ||
decorations: Decoration[], | ||
@@ -145,0 +143,0 @@ extension: Node, |
@@ -1,3 +0,1 @@ | ||
import { AnyObject } from '../types' | ||
/** | ||
@@ -8,3 +6,3 @@ * Remove a property or an array of properties from an object | ||
*/ | ||
export default function deleteProps(obj: AnyObject, propOrProps: string | string[]): AnyObject { | ||
export default function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> { | ||
const props = typeof propOrProps === 'string' | ||
@@ -16,3 +14,3 @@ ? [propOrProps] | ||
.keys(obj) | ||
.reduce((newObj: AnyObject, prop) => { | ||
.reduce((newObj: Record<string, any>, prop) => { | ||
if (!props.includes(prop)) { | ||
@@ -19,0 +17,0 @@ newObj[prop] = obj[prop] |
@@ -1,4 +0,2 @@ | ||
import { AnyObject } from '../types' | ||
export default function mergeAttributes(...objects: AnyObject[]): AnyObject { | ||
export default function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> { | ||
return objects | ||
@@ -5,0 +3,0 @@ .filter(item => !!item) |
@@ -1,5 +0,4 @@ | ||
import { AnyObject } from '../types' | ||
import isPlainObject from './isPlainObject' | ||
export default function mergeDeep(target: AnyObject, source: AnyObject): AnyObject { | ||
export default function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> { | ||
const output = { ...target } | ||
@@ -6,0 +5,0 @@ |
@@ -1,3 +0,1 @@ | ||
import { AnyObject } from '../types' | ||
/** | ||
@@ -8,3 +6,3 @@ * Check if object1 includes object2 | ||
*/ | ||
export default function objectIncludes(object1: AnyObject, object2: AnyObject): boolean { | ||
export default function objectIncludes(object1: Record<string, any>, object2: Record<string, any>): boolean { | ||
const keys = Object.keys(object2) | ||
@@ -11,0 +9,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2496636
16838