@tiptap/core
Advanced tools
Comparing version 2.0.0-beta.27 to 2.0.0-beta.28
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.0.0-beta.28](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.27...@tiptap/core@2.0.0-beta.28) (2021-04-12) | ||
### Features | ||
* add parentConfig to extension context for more extendable extensions, fix [#259](https://github.com/ueberdosis/tiptap-next/issues/259) ([5e1ec5d](https://github.com/ueberdosis/tiptap-next/commit/5e1ec5d2a66be164f505d631f97861ab9344ba96)) | ||
# [2.0.0-beta.27](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.26...@tiptap/core@2.0.0-beta.27) (2021-04-09) | ||
@@ -8,0 +19,0 @@ |
@@ -6,3 +6,3 @@ import { Plugin, Transaction } from 'prosemirror-state'; | ||
import { Node } from './Node'; | ||
import { GlobalAttributes, RawCommands } from './types'; | ||
import { GlobalAttributes, RawCommands, ParentConfig } from './types'; | ||
import { ExtensionConfig } from '.'; | ||
@@ -29,2 +29,3 @@ declare module '@tiptap/core' { | ||
options: Options; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => GlobalAttributes | {}; | ||
@@ -37,2 +38,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => Partial<RawCommands>; | ||
@@ -45,2 +47,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => { | ||
@@ -55,2 +58,3 @@ [key: string]: ProseMirrorCommand; | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => InputRule[]; | ||
@@ -63,2 +67,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -71,2 +76,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -78,2 +84,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -87,2 +94,3 @@ [key: string]: any; | ||
options: Options; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -97,2 +105,3 @@ [key: string]: any; | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => void) | null; | ||
@@ -105,2 +114,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => void) | null; | ||
@@ -113,2 +123,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => void) | null; | ||
@@ -121,2 +132,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => void) | null; | ||
@@ -129,2 +141,3 @@ /** | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}, props: { | ||
@@ -139,2 +152,3 @@ transaction: Transaction; | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}, props: { | ||
@@ -149,2 +163,3 @@ event: FocusEvent; | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}, props: { | ||
@@ -159,2 +174,3 @@ event: FocusEvent; | ||
editor: Editor; | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>; | ||
}) => void) | null; | ||
@@ -167,2 +183,3 @@ } | ||
config: ExtensionConfig; | ||
parentConfig: Partial<ExtensionConfig>; | ||
options: Options; | ||
@@ -169,0 +186,0 @@ constructor(config: ExtensionConfig<Options>); |
@@ -12,2 +12,3 @@ export * from './Editor'; | ||
export { default as mergeAttributes } from './utilities/mergeAttributes'; | ||
export { default as createExtensionContext } from './helpers/createExtensionContext'; | ||
export { default as findChildren } from './helpers/findChildren'; | ||
@@ -14,0 +15,0 @@ export { default as findParentNode } from './helpers/findParentNode'; |
@@ -5,3 +5,3 @@ import { DOMOutputSpec, MarkSpec, Mark as ProseMirrorMark, MarkType } from 'prosemirror-model'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
import { Attributes, RawCommands, GlobalAttributes } from './types'; | ||
import { Attributes, RawCommands, GlobalAttributes, ParentConfig } from './types'; | ||
import { MarkConfig } from '.'; | ||
@@ -29,2 +29,3 @@ import { Editor } from './Editor'; | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => GlobalAttributes | {}; | ||
@@ -38,2 +39,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => Partial<RawCommands>; | ||
@@ -47,2 +49,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => { | ||
@@ -58,2 +61,3 @@ [key: string]: ProseMirrorCommand; | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => InputRule[]; | ||
@@ -67,2 +71,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -76,2 +81,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -83,2 +89,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -92,2 +99,3 @@ [key: string]: any; | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -103,2 +111,3 @@ [key: string]: any; | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => void) | null; | ||
@@ -112,2 +121,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => void) | null; | ||
@@ -121,2 +131,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => void) | null; | ||
@@ -130,2 +141,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => void) | null; | ||
@@ -139,2 +151,3 @@ /** | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, props: { | ||
@@ -150,2 +163,3 @@ transaction: Transaction; | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, props: { | ||
@@ -161,2 +175,3 @@ event: FocusEvent; | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, props: { | ||
@@ -172,2 +187,3 @@ event: FocusEvent; | ||
type: MarkType; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => void) | null; | ||
@@ -183,2 +199,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => MarkSpec['inclusive']); | ||
@@ -190,2 +207,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => MarkSpec['excludes']); | ||
@@ -197,2 +215,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => MarkSpec['group']); | ||
@@ -204,2 +223,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => MarkSpec['spanning']); | ||
@@ -211,2 +231,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => MarkSpec['parseDOM']; | ||
@@ -218,2 +239,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}, props: { | ||
@@ -230,2 +252,3 @@ mark: ProseMirrorMark; | ||
options: Options; | ||
parentConfig: ParentConfig<MarkConfig<Options>>; | ||
}) => Attributes | {}; | ||
@@ -238,2 +261,3 @@ } | ||
config: MarkConfig; | ||
parentConfig: Partial<MarkConfig>; | ||
options: Options; | ||
@@ -240,0 +264,0 @@ constructor(config: MarkConfig<Options>); |
@@ -5,3 +5,3 @@ import { DOMOutputSpec, NodeSpec, Node as ProseMirrorNode, NodeType } from 'prosemirror-model'; | ||
import { InputRule } from 'prosemirror-inputrules'; | ||
import { Attributes, NodeViewRenderer, GlobalAttributes, RawCommands } from './types'; | ||
import { Attributes, NodeViewRenderer, GlobalAttributes, RawCommands, ParentConfig } from './types'; | ||
import { NodeConfig } from '.'; | ||
@@ -29,2 +29,3 @@ import { Editor } from './Editor'; | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => GlobalAttributes | {}; | ||
@@ -38,2 +39,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => Partial<RawCommands>; | ||
@@ -47,2 +49,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => { | ||
@@ -58,2 +61,3 @@ [key: string]: ProseMirrorCommand; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => InputRule[]; | ||
@@ -67,2 +71,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -76,2 +81,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => Plugin[]; | ||
@@ -83,2 +89,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -92,2 +99,3 @@ [key: string]: any; | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, extension: Node) => { | ||
@@ -103,2 +111,3 @@ [key: string]: any; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => void) | null; | ||
@@ -112,2 +121,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => void) | null; | ||
@@ -121,2 +131,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => void) | null; | ||
@@ -130,2 +141,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => void) | null; | ||
@@ -139,2 +151,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, props: { | ||
@@ -150,2 +163,3 @@ transaction: Transaction; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, props: { | ||
@@ -161,2 +175,3 @@ event: FocusEvent; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, props: { | ||
@@ -172,2 +187,3 @@ event: FocusEvent; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => void) | null; | ||
@@ -181,2 +197,3 @@ /** | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeViewRenderer) | null; | ||
@@ -192,2 +209,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['content']); | ||
@@ -199,2 +217,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['marks']); | ||
@@ -206,2 +225,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['group']); | ||
@@ -213,2 +233,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['inline']); | ||
@@ -220,2 +241,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['atom']); | ||
@@ -227,2 +249,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['selectable']); | ||
@@ -234,2 +257,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['draggable']); | ||
@@ -241,2 +265,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['code']); | ||
@@ -248,2 +273,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['defining']); | ||
@@ -255,2 +281,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['isolating']); | ||
@@ -262,2 +289,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => NodeSpec['parseDOM']; | ||
@@ -269,2 +297,3 @@ /** | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, props: { | ||
@@ -283,2 +312,3 @@ node: ProseMirrorNode; | ||
type: NodeType; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}, props: { | ||
@@ -292,2 +322,3 @@ node: ProseMirrorNode; | ||
options: Options; | ||
parentConfig: ParentConfig<NodeConfig<Options>>; | ||
}) => Attributes | {}; | ||
@@ -300,2 +331,3 @@ } | ||
config: NodeConfig; | ||
parentConfig: Partial<NodeConfig>; | ||
options: Options; | ||
@@ -302,0 +334,0 @@ constructor(config: NodeConfig<Options>); |
@@ -9,3 +9,7 @@ import { Node as ProseMirrorNode, Mark as ProseMirrorMark, ParseOptions } from 'prosemirror-model'; | ||
import { Commands } from '.'; | ||
export declare type Extensions = (Extension | Node | Mark)[]; | ||
export declare type AnyExtension = Extension | Node | Mark; | ||
export declare type Extensions = AnyExtension[]; | ||
export declare type ParentConfig<T> = Partial<{ | ||
[P in keyof T]: Required<T>[P] extends () => any ? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> : T[P]; | ||
}>; | ||
export interface EditorOptions { | ||
@@ -12,0 +16,0 @@ element: Element; |
{ | ||
"name": "@tiptap/core", | ||
"description": "headless rich text editor", | ||
"version": "2.0.0-beta.27", | ||
"version": "2.0.0-beta.28", | ||
"homepage": "https://tiptap.dev", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "9fbde0f8da0af342f08645c077dce78a77c363e0" | ||
"gitHead": "28d30a10341cb5cd10626b1b8c884c20787b5d72" | ||
} |
@@ -7,3 +7,3 @@ import { Plugin, Transaction } from 'prosemirror-state' | ||
import mergeDeep from './utilities/mergeDeep' | ||
import { GlobalAttributes, RawCommands } from './types' | ||
import { GlobalAttributes, RawCommands, ParentConfig } from './types' | ||
import { ExtensionConfig } from '.' | ||
@@ -35,2 +35,3 @@ | ||
options: Options, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => GlobalAttributes | {}, | ||
@@ -44,2 +45,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => Partial<RawCommands>, | ||
@@ -53,2 +55,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => { | ||
@@ -64,2 +67,3 @@ [key: string]: ProseMirrorCommand, | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => InputRule[], | ||
@@ -73,2 +77,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -82,2 +87,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -91,2 +97,3 @@ | ||
options: Options, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}, | ||
@@ -104,2 +111,3 @@ extension: Node, | ||
options: Options, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}, | ||
@@ -117,2 +125,3 @@ extension: Node, | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => void) | null, | ||
@@ -126,2 +135,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => void) | null, | ||
@@ -135,2 +145,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => void) | null, | ||
@@ -144,2 +155,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => void) | null, | ||
@@ -154,2 +166,3 @@ | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}, | ||
@@ -168,2 +181,3 @@ props: { | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}, | ||
@@ -182,2 +196,3 @@ props: { | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}, | ||
@@ -195,2 +210,3 @@ props: { | ||
editor: Editor, | ||
parentConfig: ParentConfig<ExtensionConfig<Options>>, | ||
}) => void) | null, | ||
@@ -209,2 +225,4 @@ } | ||
parentConfig: Partial<ExtensionConfig> = {} | ||
options!: Options | ||
@@ -238,7 +256,11 @@ | ||
extend<ExtendedOptions = Options>(extendedConfig: Partial<ExtensionConfig<ExtendedOptions>>) { | ||
return new Extension<ExtendedOptions>({ | ||
const extension = new Extension<ExtendedOptions>({ | ||
...this.config, | ||
...extendedConfig, | ||
} as ExtensionConfig<ExtendedOptions>) | ||
extension.parentConfig = this.config | ||
return extension | ||
} | ||
} |
@@ -8,2 +8,3 @@ import { keymap } from 'prosemirror-keymap' | ||
import { Extensions, NodeViewRenderer, RawCommands } from './types' | ||
import createExtensionContext from './helpers/createExtensionContext' | ||
import getSchema from './helpers/getSchema' | ||
@@ -33,7 +34,7 @@ import getSchemaTypeByName from './helpers/getSchemaTypeByName' | ||
this.extensions.forEach(extension => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
editor: this.editor, | ||
type: getSchemaTypeByName(extension.config.name, this.schema), | ||
} | ||
}) | ||
@@ -100,7 +101,7 @@ if (extension.type === 'mark') { | ||
return this.extensions.reduce((commands, extension) => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
editor: this.editor, | ||
type: getSchemaTypeByName(extension.config.name, this.schema), | ||
} | ||
}) | ||
@@ -122,7 +123,7 @@ if (!extension.config.addCommands) { | ||
.map(extension => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
editor: this.editor, | ||
type: getSchemaTypeByName(extension.config.name, this.schema), | ||
} | ||
}) | ||
@@ -175,7 +176,7 @@ const plugins: Plugin[] = [] | ||
const extensionAttributes = this.attributes.filter(attribute => attribute.type === extension.config.name) | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
editor, | ||
type: getNodeType(extension.config.name, this.schema), | ||
} | ||
}) | ||
const renderer = extension.config.addNodeView?.call(context) as NodeViewRenderer | ||
@@ -212,7 +213,7 @@ | ||
.map(extension => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
editor, | ||
type: getNodeType(extension.config.name, this.schema), | ||
} | ||
}) | ||
@@ -219,0 +220,0 @@ const textSerializer = (props: { node: ProsemirrorNode }) => extension.config.renderText?.call(context, props) |
@@ -0,1 +1,2 @@ | ||
import createExtensionContext from './createExtensionContext' | ||
import splitExtensions from './splitExtensions' | ||
@@ -27,5 +28,5 @@ import { | ||
extensions.forEach(extension => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
} | ||
}) | ||
@@ -57,5 +58,5 @@ if (!extension.config.addGlobalAttributes) { | ||
nodeAndMarkExtensions.forEach(extension => { | ||
const context = { | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
} | ||
}) | ||
@@ -62,0 +63,0 @@ if (!extension.config.addAttributes) { |
import { NodeSpec, MarkSpec, Schema } from 'prosemirror-model' | ||
import { Extensions } from '../types' | ||
import { ExtensionConfig, NodeConfig, MarkConfig } from '..' | ||
import createExtensionContext from './createExtensionContext' | ||
import splitExtensions from './splitExtensions' | ||
@@ -48,3 +49,5 @@ import getAttributesFromExtensions from './getAttributesFromExtensions' | ||
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.config.name) | ||
const context = { options: extension.options } | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
}) | ||
@@ -95,3 +98,5 @@ const extraNodeFields = nodeSchemaExtenders.reduce((fields, nodeSchemaExtender) => { | ||
const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.config.name) | ||
const context = { options: extension.options } | ||
const context = createExtensionContext(extension, { | ||
options: extension.options, | ||
}) | ||
@@ -98,0 +103,0 @@ const extraMarkFields = markSchemaExtenders.reduce((fields, markSchemaExtender) => { |
@@ -15,2 +15,3 @@ export * from './Editor' | ||
export { default as createExtensionContext } from './helpers/createExtensionContext' | ||
export { default as findChildren } from './helpers/findChildren' | ||
@@ -17,0 +18,0 @@ export { default as findParentNode } from './helpers/findParentNode' |
@@ -11,3 +11,8 @@ import { | ||
import mergeDeep from './utilities/mergeDeep' | ||
import { Attributes, RawCommands, GlobalAttributes } from './types' | ||
import { | ||
Attributes, | ||
RawCommands, | ||
GlobalAttributes, | ||
ParentConfig, | ||
} from './types' | ||
import { MarkConfig } from '.' | ||
@@ -40,2 +45,3 @@ import { Editor } from './Editor' | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => GlobalAttributes | {}, | ||
@@ -50,2 +56,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => Partial<RawCommands>, | ||
@@ -60,2 +67,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => { | ||
@@ -72,2 +80,3 @@ [key: string]: ProseMirrorCommand, | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => InputRule[], | ||
@@ -82,2 +91,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -92,2 +102,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -101,2 +112,3 @@ | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -114,2 +126,3 @@ extension: Node, | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -128,2 +141,3 @@ extension: Node, | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => void) | null, | ||
@@ -138,2 +152,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => void) | null, | ||
@@ -148,2 +163,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => void) | null, | ||
@@ -158,2 +174,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => void) | null, | ||
@@ -169,2 +186,3 @@ | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -184,2 +202,3 @@ props: { | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -199,2 +218,3 @@ props: { | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -213,2 +233,3 @@ props: { | ||
type: MarkType, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => void) | null, | ||
@@ -224,3 +245,6 @@ | ||
*/ | ||
inclusive?: MarkSpec['inclusive'] | ((this: { options: Options }) => MarkSpec['inclusive']), | ||
inclusive?: MarkSpec['inclusive'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => MarkSpec['inclusive']), | ||
@@ -230,3 +254,6 @@ /** | ||
*/ | ||
excludes?: MarkSpec['excludes'] | ((this: { options: Options }) => MarkSpec['excludes']), | ||
excludes?: MarkSpec['excludes'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => MarkSpec['excludes']), | ||
@@ -236,3 +263,6 @@ /** | ||
*/ | ||
group?: MarkSpec['group'] | ((this: { options: Options }) => MarkSpec['group']), | ||
group?: MarkSpec['group'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => MarkSpec['group']), | ||
@@ -242,3 +272,6 @@ /** | ||
*/ | ||
spanning?: MarkSpec['spanning'] | ((this: { options: Options }) => MarkSpec['spanning']), | ||
spanning?: MarkSpec['spanning'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}) => MarkSpec['spanning']), | ||
@@ -251,2 +284,3 @@ /** | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -261,2 +295,3 @@ ) => MarkSpec['parseDOM'], | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -275,2 +310,3 @@ props: { | ||
options: Options, | ||
parentConfig: ParentConfig<MarkConfig<Options>>, | ||
}, | ||
@@ -290,2 +326,4 @@ ) => Attributes | {}, | ||
parentConfig: Partial<MarkConfig> = {} | ||
options!: Options | ||
@@ -319,7 +357,11 @@ | ||
extend<ExtendedOptions = Options>(extendedConfig: Partial<MarkConfig<ExtendedOptions>>) { | ||
return new Mark<ExtendedOptions>({ | ||
const extension = new Mark<ExtendedOptions>({ | ||
...this.config, | ||
...extendedConfig, | ||
} as MarkConfig<ExtendedOptions>) | ||
extension.parentConfig = this.config | ||
return extension | ||
} | ||
} |
@@ -16,2 +16,3 @@ import { | ||
RawCommands, | ||
ParentConfig, | ||
} from './types' | ||
@@ -45,2 +46,3 @@ import { NodeConfig } from '.' | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => GlobalAttributes | {}, | ||
@@ -55,2 +57,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => Partial<RawCommands>, | ||
@@ -65,2 +68,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => { | ||
@@ -77,2 +81,3 @@ [key: string]: ProseMirrorCommand, | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => InputRule[], | ||
@@ -87,2 +92,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -97,2 +103,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => Plugin[], | ||
@@ -106,2 +113,3 @@ | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -119,2 +127,3 @@ extension: Node, | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -133,2 +142,3 @@ extension: Node, | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => void) | null, | ||
@@ -143,2 +153,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => void) | null, | ||
@@ -153,2 +164,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => void) | null, | ||
@@ -163,2 +175,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => void) | null, | ||
@@ -174,2 +187,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -189,2 +203,3 @@ props: { | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -204,2 +219,3 @@ props: { | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -218,2 +234,3 @@ props: { | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => void) | null, | ||
@@ -228,2 +245,3 @@ | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeViewRenderer) | null, | ||
@@ -239,3 +257,6 @@ | ||
*/ | ||
content?: NodeSpec['content'] | ((this: { options: Options }) => NodeSpec['content']), | ||
content?: NodeSpec['content'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['content']), | ||
@@ -245,3 +266,6 @@ /** | ||
*/ | ||
marks?: NodeSpec['marks'] | ((this: { options: Options }) => NodeSpec['marks']), | ||
marks?: NodeSpec['marks'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['marks']), | ||
@@ -251,3 +275,6 @@ /** | ||
*/ | ||
group?: NodeSpec['group'] | ((this: { options: Options }) => NodeSpec['group']), | ||
group?: NodeSpec['group'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['group']), | ||
@@ -257,3 +284,6 @@ /** | ||
*/ | ||
inline?: NodeSpec['inline'] | ((this: { options: Options }) => NodeSpec['inline']), | ||
inline?: NodeSpec['inline'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['inline']), | ||
@@ -263,3 +293,6 @@ /** | ||
*/ | ||
atom?: NodeSpec['atom'] | ((this: { options: Options }) => NodeSpec['atom']), | ||
atom?: NodeSpec['atom'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['atom']), | ||
@@ -269,3 +302,6 @@ /** | ||
*/ | ||
selectable?: NodeSpec['selectable'] | ((this: { options: Options }) => NodeSpec['selectable']), | ||
selectable?: NodeSpec['selectable'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['selectable']), | ||
@@ -275,3 +311,6 @@ /** | ||
*/ | ||
draggable?: NodeSpec['draggable'] | ((this: { options: Options }) => NodeSpec['draggable']), | ||
draggable?: NodeSpec['draggable'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['draggable']), | ||
@@ -281,3 +320,6 @@ /** | ||
*/ | ||
code?: NodeSpec['code'] | ((this: { options: Options }) => NodeSpec['code']), | ||
code?: NodeSpec['code'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['code']), | ||
@@ -287,3 +329,6 @@ /** | ||
*/ | ||
defining?: NodeSpec['defining'] | ((this: { options: Options }) => NodeSpec['defining']), | ||
defining?: NodeSpec['defining'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['defining']), | ||
@@ -293,3 +338,6 @@ /** | ||
*/ | ||
isolating?: NodeSpec['isolating'] | ((this: { options: Options }) => NodeSpec['isolating']), | ||
isolating?: NodeSpec['isolating'] | ((this: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}) => NodeSpec['isolating']), | ||
@@ -302,2 +350,3 @@ /** | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -312,2 +361,3 @@ ) => NodeSpec['parseDOM'], | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -328,2 +378,3 @@ props: { | ||
type: NodeType, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -341,2 +392,3 @@ props: { | ||
options: Options, | ||
parentConfig: ParentConfig<NodeConfig<Options>>, | ||
}, | ||
@@ -356,2 +408,4 @@ ) => Attributes | {}, | ||
parentConfig: Partial<NodeConfig> = {} | ||
options!: Options | ||
@@ -385,7 +439,11 @@ | ||
extend<ExtendedOptions = Options>(extendedConfig: Partial<NodeConfig<ExtendedOptions>>) { | ||
return new Node<ExtendedOptions>({ | ||
const extension = new Node<ExtendedOptions>({ | ||
...this.config, | ||
...extendedConfig, | ||
} as NodeConfig<ExtendedOptions>) | ||
extension.parentConfig = this.config | ||
return extension | ||
} | ||
} |
@@ -19,4 +19,11 @@ import { | ||
export type Extensions = (Extension | Node | Mark)[] | ||
export type AnyExtension = Extension | Node | Mark | ||
export type Extensions = AnyExtension[] | ||
export type ParentConfig<T> = Partial<{ | ||
[P in keyof T]: Required<T>[P] extends () => any | ||
? (...args: Parameters<Required<T>[P]>) => ReturnType<Required<T>[P]> | ||
: T[P] | ||
}> | ||
export interface EditorOptions { | ||
@@ -23,0 +30,0 @@ element: Element, |
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
2483449
238
16236