@tiptap/core 3.0.0-beta.14 → 3.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +54 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -7
- package/dist/index.d.ts +21 -7
- package/dist/index.js +53 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Extension.ts +14 -4
- package/src/Mark.ts +12 -4
- package/src/Node.ts +12 -4
- package/src/commands/insertContentAt.ts +2 -1
- package/src/utilities/canInsertNode.ts +30 -0
- package/src/utilities/index.ts +1 -0
package/dist/index.d.cts
CHANGED
|
@@ -183,13 +183,17 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
183
183
|
*/
|
|
184
184
|
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
185
185
|
type: string;
|
|
186
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Create a new Mark instance
|
|
188
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
189
|
+
*/
|
|
190
|
+
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
|
|
187
191
|
static handleExit({ editor, mark }: {
|
|
188
192
|
editor: Editor;
|
|
189
193
|
mark: Mark;
|
|
190
194
|
}): boolean;
|
|
191
195
|
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
192
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
|
|
196
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Mark<ExtendedOptions, ExtendedStorage>;
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
@@ -470,9 +474,13 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
470
474
|
*/
|
|
471
475
|
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
472
476
|
type: string;
|
|
473
|
-
|
|
477
|
+
/**
|
|
478
|
+
* Create a new Node instance
|
|
479
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
480
|
+
*/
|
|
481
|
+
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
|
|
474
482
|
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
475
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
|
|
483
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Node<ExtendedOptions, ExtendedStorage>;
|
|
476
484
|
}
|
|
477
485
|
|
|
478
486
|
type PasteRuleMatch = {
|
|
@@ -1631,9 +1639,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
|
|
|
1631
1639
|
*/
|
|
1632
1640
|
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1633
1641
|
type: string;
|
|
1634
|
-
|
|
1642
|
+
/**
|
|
1643
|
+
* Create a new Extension instance
|
|
1644
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1645
|
+
*/
|
|
1646
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1635
1647
|
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1636
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1648
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1637
1649
|
}
|
|
1638
1650
|
|
|
1639
1651
|
/**
|
|
@@ -3265,6 +3277,8 @@ declare class Tracker {
|
|
|
3265
3277
|
*/
|
|
3266
3278
|
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3267
3279
|
|
|
3280
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3281
|
+
|
|
3268
3282
|
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3269
3283
|
|
|
3270
3284
|
/**
|
|
@@ -3332,4 +3346,4 @@ interface Commands<ReturnType = any> {
|
|
|
3332
3346
|
interface Storage {
|
|
3333
3347
|
}
|
|
3334
3348
|
|
|
3335
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
3349
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
package/dist/index.d.ts
CHANGED
|
@@ -183,13 +183,17 @@ interface MarkConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
183
183
|
*/
|
|
184
184
|
declare class Mark<Options = any, Storage = any> extends Extendable<Options, Storage, MarkConfig<Options, Storage>> {
|
|
185
185
|
type: string;
|
|
186
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Create a new Mark instance
|
|
188
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
189
|
+
*/
|
|
190
|
+
static create<O = any, S = any>(config?: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>)): Mark<O, S>;
|
|
187
191
|
static handleExit({ editor, mark }: {
|
|
188
192
|
editor: Editor;
|
|
189
193
|
mark: Mark;
|
|
190
194
|
}): boolean;
|
|
191
195
|
configure(options?: Partial<Options>): Mark<Options, Storage>;
|
|
192
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Mark<ExtendedOptions, ExtendedStorage>;
|
|
196
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Mark<ExtendedOptions, ExtendedStorage>;
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Options, Storage, NodeConfig<Options, Storage>, NodeType$1> {
|
|
@@ -470,9 +474,13 @@ interface NodeConfig<Options = any, Storage = any> extends ExtendableConfig<Opti
|
|
|
470
474
|
*/
|
|
471
475
|
declare class Node<Options = any, Storage = any> extends Extendable<Options, Storage, NodeConfig<Options, Storage>> {
|
|
472
476
|
type: string;
|
|
473
|
-
|
|
477
|
+
/**
|
|
478
|
+
* Create a new Node instance
|
|
479
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
480
|
+
*/
|
|
481
|
+
static create<O = any, S = any>(config?: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>)): Node<O, S>;
|
|
474
482
|
configure(options?: Partial<Options>): Node<Options, Storage>;
|
|
475
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Node<ExtendedOptions, ExtendedStorage>;
|
|
483
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Node<ExtendedOptions, ExtendedStorage>;
|
|
476
484
|
}
|
|
477
485
|
|
|
478
486
|
type PasteRuleMatch = {
|
|
@@ -1631,9 +1639,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
|
|
|
1631
1639
|
*/
|
|
1632
1640
|
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1633
1641
|
type: string;
|
|
1634
|
-
|
|
1642
|
+
/**
|
|
1643
|
+
* Create a new Extension instance
|
|
1644
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1645
|
+
*/
|
|
1646
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1635
1647
|
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1636
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1648
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1637
1649
|
}
|
|
1638
1650
|
|
|
1639
1651
|
/**
|
|
@@ -3265,6 +3277,8 @@ declare class Tracker {
|
|
|
3265
3277
|
*/
|
|
3266
3278
|
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3267
3279
|
|
|
3280
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3281
|
+
|
|
3268
3282
|
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3269
3283
|
|
|
3270
3284
|
/**
|
|
@@ -3332,4 +3346,4 @@ interface Commands<ReturnType = any> {
|
|
|
3332
3346
|
interface Storage {
|
|
3333
3347
|
}
|
|
3334
3348
|
|
|
3335
|
-
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
|
3349
|
+
export { type AnyCommands, type AnyConfig, type AnyExtension, type Attribute, type Attributes$1 as Attributes, type CanCommands, type ChainedCommands, type ChangedRange, type Command, CommandManager, type CommandProps, type CommandSpec, type Commands, type Content, type CreateNodeFromContentOptions, type DOMNode, type DOMOutputSpecArray$1 as DOMOutputSpecArray, type DecorationType, type DecorationWithType, type Diff, type Dispatch, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type GlobalAttributes, type HTMLContent, InputRule, type InputRuleFinder, type InputRuleMatch, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MaybeReturnType, type MaybeThisParameterType, Node, type NodeConfig, NodePos, type NodeRange, type NodeType, NodeView, type NodeViewProps, type NodeViewRenderer, type NodeViewRendererOptions, type NodeViewRendererProps, type NodeWithPos, type Overwrite, type ParentConfig, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type ValuesOf, callOrReturn, canInsertNode, combineTransactionSteps, createChainableState, createDocument, h as createElement, createNodeFromContent, createStyleTag, defaultBlockAt, deleteProps, elementFromString, escapeForRegEx, index as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, flattenExtensions, fromString, generateHTML, generateJSON, generateText, getAttributes, getAttributesFromExtensions, getChangedRanges, getDebugJSON, getExtensionField, getHTMLFromFragment, getMarkAttributes, getMarkRange, getMarkType, getMarksBetween, getNodeAtPosition, getNodeAttributes, getNodeType, getRenderedAttributes, getSchema, getSchemaByResolvedExtensions, getSchemaTypeByName, getSchemaTypeNameByName, getSplittedAttributes, getText, getTextBetween, getTextContentFromNodes, getTextSerializersFromSchema, h, injectExtensionAttributesToParseRule, inputRulesPlugin, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, markInputRule, markPasteRule, mergeAttributes, mergeDeep, minMax, nodeInputRule, nodePasteRule, objectIncludes, pasteRulesPlugin, posToDOMRect, removeDuplicates, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, selectionToInsertionEnd, sortExtensions, splitExtensions, textInputRule, textPasteRule, textblockTypeInputRule, wrappingInputRule };
|
package/dist/index.js
CHANGED
|
@@ -1831,8 +1831,13 @@ var Mark = class _Mark extends Extendable {
|
|
|
1831
1831
|
super(...arguments);
|
|
1832
1832
|
this.type = "mark";
|
|
1833
1833
|
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Create a new Mark instance
|
|
1836
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
1837
|
+
*/
|
|
1834
1838
|
static create(config = {}) {
|
|
1835
|
-
|
|
1839
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
1840
|
+
return new _Mark(resolvedConfig);
|
|
1836
1841
|
}
|
|
1837
1842
|
static handleExit({ editor, mark }) {
|
|
1838
1843
|
const { tr } = editor.state;
|
|
@@ -1858,7 +1863,8 @@ var Mark = class _Mark extends Extendable {
|
|
|
1858
1863
|
return super.configure(options);
|
|
1859
1864
|
}
|
|
1860
1865
|
extend(extendedConfig) {
|
|
1861
|
-
|
|
1866
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
1867
|
+
return super.extend(resolvedConfig);
|
|
1862
1868
|
}
|
|
1863
1869
|
};
|
|
1864
1870
|
|
|
@@ -2363,14 +2369,20 @@ var Extension = class _Extension extends Extendable {
|
|
|
2363
2369
|
super(...arguments);
|
|
2364
2370
|
this.type = "extension";
|
|
2365
2371
|
}
|
|
2372
|
+
/**
|
|
2373
|
+
* Create a new Extension instance
|
|
2374
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
2375
|
+
*/
|
|
2366
2376
|
static create(config = {}) {
|
|
2367
|
-
|
|
2377
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
2378
|
+
return new _Extension(resolvedConfig);
|
|
2368
2379
|
}
|
|
2369
2380
|
configure(options) {
|
|
2370
2381
|
return super.configure(options);
|
|
2371
2382
|
}
|
|
2372
2383
|
extend(extendedConfig) {
|
|
2373
|
-
|
|
2384
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
2385
|
+
return super.extend(resolvedConfig);
|
|
2374
2386
|
}
|
|
2375
2387
|
};
|
|
2376
2388
|
|
|
@@ -2790,7 +2802,8 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2790
2802
|
newContent = content;
|
|
2791
2803
|
const fromSelectionAtStart = selection.$from.parentOffset === 0;
|
|
2792
2804
|
const isTextSelection2 = selection.$from.node().isText || selection.$from.node().isTextblock;
|
|
2793
|
-
|
|
2805
|
+
const hasContent = selection.$from.node().content.size > 0;
|
|
2806
|
+
if (fromSelectionAtStart && isTextSelection2 && hasContent) {
|
|
2794
2807
|
from = Math.max(0, from - 1);
|
|
2795
2808
|
}
|
|
2796
2809
|
tr.replaceWith(from, to, newContent);
|
|
@@ -4946,6 +4959,29 @@ var h = (tag, attributes) => {
|
|
|
4946
4959
|
return [tag, rest, children];
|
|
4947
4960
|
};
|
|
4948
4961
|
|
|
4962
|
+
// src/utilities/canInsertNode.ts
|
|
4963
|
+
import { NodeSelection as NodeSelection4 } from "@tiptap/pm/state";
|
|
4964
|
+
function canInsertNode(state, nodeType) {
|
|
4965
|
+
const { selection } = state;
|
|
4966
|
+
const { $from } = selection;
|
|
4967
|
+
if (selection instanceof NodeSelection4) {
|
|
4968
|
+
const index = $from.index();
|
|
4969
|
+
const parent = $from.parent;
|
|
4970
|
+
return parent.canReplaceWith(index, index + 1, nodeType);
|
|
4971
|
+
}
|
|
4972
|
+
let depth = $from.depth;
|
|
4973
|
+
while (depth >= 0) {
|
|
4974
|
+
const index = $from.index(depth);
|
|
4975
|
+
const parent = $from.node(depth);
|
|
4976
|
+
const match = parent.contentMatchAt(index);
|
|
4977
|
+
if (match.matchType(nodeType)) {
|
|
4978
|
+
return true;
|
|
4979
|
+
}
|
|
4980
|
+
depth -= 1;
|
|
4981
|
+
}
|
|
4982
|
+
return false;
|
|
4983
|
+
}
|
|
4984
|
+
|
|
4949
4985
|
// src/utilities/escapeForRegEx.ts
|
|
4950
4986
|
function escapeForRegEx(string) {
|
|
4951
4987
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
@@ -5003,19 +5039,25 @@ var Node3 = class _Node extends Extendable {
|
|
|
5003
5039
|
super(...arguments);
|
|
5004
5040
|
this.type = "node";
|
|
5005
5041
|
}
|
|
5042
|
+
/**
|
|
5043
|
+
* Create a new Node instance
|
|
5044
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
5045
|
+
*/
|
|
5006
5046
|
static create(config = {}) {
|
|
5007
|
-
|
|
5047
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
5048
|
+
return new _Node(resolvedConfig);
|
|
5008
5049
|
}
|
|
5009
5050
|
configure(options) {
|
|
5010
5051
|
return super.configure(options);
|
|
5011
5052
|
}
|
|
5012
5053
|
extend(extendedConfig) {
|
|
5013
|
-
|
|
5054
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
5055
|
+
return super.extend(resolvedConfig);
|
|
5014
5056
|
}
|
|
5015
5057
|
};
|
|
5016
5058
|
|
|
5017
5059
|
// src/NodeView.ts
|
|
5018
|
-
import { NodeSelection as
|
|
5060
|
+
import { NodeSelection as NodeSelection5 } from "@tiptap/pm/state";
|
|
5019
5061
|
var NodeView = class {
|
|
5020
5062
|
constructor(component, props, options) {
|
|
5021
5063
|
this.isDragging = false;
|
|
@@ -5068,7 +5110,7 @@ var NodeView = class {
|
|
|
5068
5110
|
if (typeof pos !== "number") {
|
|
5069
5111
|
return;
|
|
5070
5112
|
}
|
|
5071
|
-
const selection =
|
|
5113
|
+
const selection = NodeSelection5.create(view.state.doc, pos);
|
|
5072
5114
|
const transaction = view.state.tr.setSelection(selection);
|
|
5073
5115
|
view.dispatch(transaction);
|
|
5074
5116
|
}
|
|
@@ -5094,7 +5136,7 @@ var NodeView = class {
|
|
|
5094
5136
|
const { isEditable } = this.editor;
|
|
5095
5137
|
const { isDragging } = this;
|
|
5096
5138
|
const isDraggable = !!this.node.type.spec.draggable;
|
|
5097
|
-
const isSelectable =
|
|
5139
|
+
const isSelectable = NodeSelection5.isSelectable(this.node);
|
|
5098
5140
|
const isCopyEvent = event.type === "copy";
|
|
5099
5141
|
const isPasteEvent = event.type === "paste";
|
|
5100
5142
|
const isCutEvent = event.type === "cut";
|
|
@@ -5317,6 +5359,7 @@ export {
|
|
|
5317
5359
|
PasteRule,
|
|
5318
5360
|
Tracker,
|
|
5319
5361
|
callOrReturn,
|
|
5362
|
+
canInsertNode,
|
|
5320
5363
|
combineTransactionSteps,
|
|
5321
5364
|
createChainableState,
|
|
5322
5365
|
createDocument,
|