@tiptap/core 3.0.0-beta.2 → 3.0.0-beta.22
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/chunk-GRT2MR5L.js +59 -0
- package/dist/chunk-GRT2MR5L.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/chunk-TH7LERQR.js +34 -0
- package/dist/chunk-TH7LERQR.js.map +1 -0
- package/dist/chunk-UNIMJOD2.js +1010 -0
- package/dist/chunk-UNIMJOD2.js.map +1 -0
- package/dist/esm-7BF7U2WM.js +47055 -0
- package/dist/esm-7BF7U2WM.js.map +1 -0
- package/dist/index.cjs +54109 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -7
- package/dist/index.d.ts +61 -7
- package/dist/index.js +127 -31
- package/dist/index.js.map +1 -1
- package/dist/json-diff-main-ASELUCBE.js +4742 -0
- package/dist/json-diff-main-ASELUCBE.js.map +1 -0
- package/dist/json-diff-worker-ET432FKY.js +398 -0
- package/dist/json-diff-worker-ET432FKY.js.map +1 -0
- package/jsx-dev-runtime/index.cjs +1 -0
- package/jsx-dev-runtime/index.d.cts +1 -0
- package/jsx-dev-runtime/index.d.ts +1 -0
- package/jsx-dev-runtime/index.js +1 -0
- package/jsx-runtime/index.cjs +1 -1
- package/package.json +7 -4
- package/src/Editor.ts +47 -3
- package/src/Extension.ts +14 -4
- package/src/Mark.ts +12 -4
- package/src/Node.ts +12 -4
- package/src/NodePos.ts +6 -0
- package/src/PasteRule.ts +1 -1
- package/src/commands/cut.ts +1 -1
- package/src/commands/insertContentAt.ts +31 -11
- package/src/types.ts +21 -0
- 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 = {
|
|
@@ -1155,6 +1163,27 @@ interface EditorOptions {
|
|
|
1155
1163
|
* @default false
|
|
1156
1164
|
*/
|
|
1157
1165
|
enableContentCheck: boolean;
|
|
1166
|
+
/**
|
|
1167
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1168
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1169
|
+
* invalid editor content while still showing a warning or error message to
|
|
1170
|
+
* the user.
|
|
1171
|
+
*
|
|
1172
|
+
* @default false
|
|
1173
|
+
*/
|
|
1174
|
+
emitContentError: boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* Enable a lazy-loaded Prosemirror DevTools integration.
|
|
1177
|
+
*
|
|
1178
|
+
* Requires having the `prosemirror-dev-tools` npm package installed.
|
|
1179
|
+
* @type boolean
|
|
1180
|
+
* @default false
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```js
|
|
1183
|
+
* enableDevTools: true
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
enableDevTools: boolean;
|
|
1158
1187
|
/**
|
|
1159
1188
|
* Called before the editor is constructed.
|
|
1160
1189
|
*/
|
|
@@ -1622,9 +1651,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
|
|
|
1622
1651
|
*/
|
|
1623
1652
|
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1624
1653
|
type: string;
|
|
1625
|
-
|
|
1654
|
+
/**
|
|
1655
|
+
* Create a new Extension instance
|
|
1656
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1657
|
+
*/
|
|
1658
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1626
1659
|
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1627
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1660
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1628
1661
|
}
|
|
1629
1662
|
|
|
1630
1663
|
/**
|
|
@@ -2891,6 +2924,25 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2891
2924
|
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2892
2925
|
*/
|
|
2893
2926
|
unmount(): void;
|
|
2927
|
+
/**
|
|
2928
|
+
*
|
|
2929
|
+
* @returns
|
|
2930
|
+
*/
|
|
2931
|
+
/**
|
|
2932
|
+
* Applies ProseMirror dev tools to the editor instance if enabled and running in a browser environment.
|
|
2933
|
+
*
|
|
2934
|
+
* This method dynamically imports the `prosemirror-dev-tools` package and applies it to the current
|
|
2935
|
+
* editor view. If the dev tools are not installed, a warning is logged to the console.
|
|
2936
|
+
*
|
|
2937
|
+
* @private
|
|
2938
|
+
* @remarks
|
|
2939
|
+
* - Dev tools are only applied if `this.options.enableDevTools` is `true` and the code is running in a browser.
|
|
2940
|
+
* - If the editor view is not available, the dev tools are not applied.
|
|
2941
|
+
* - If the `prosemirror-dev-tools` package is missing, a warning is shown in the console.
|
|
2942
|
+
*
|
|
2943
|
+
* @returns {void}
|
|
2944
|
+
*/
|
|
2945
|
+
private applyDevTools;
|
|
2894
2946
|
/**
|
|
2895
2947
|
* Returns the editor storage.
|
|
2896
2948
|
*/
|
|
@@ -3256,6 +3308,8 @@ declare class Tracker {
|
|
|
3256
3308
|
*/
|
|
3257
3309
|
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3258
3310
|
|
|
3311
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3312
|
+
|
|
3259
3313
|
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3260
3314
|
|
|
3261
3315
|
/**
|
|
@@ -3323,4 +3377,4 @@ interface Commands<ReturnType = any> {
|
|
|
3323
3377
|
interface Storage {
|
|
3324
3378
|
}
|
|
3325
3379
|
|
|
3326
|
-
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 };
|
|
3380
|
+
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 = {
|
|
@@ -1155,6 +1163,27 @@ interface EditorOptions {
|
|
|
1155
1163
|
* @default false
|
|
1156
1164
|
*/
|
|
1157
1165
|
enableContentCheck: boolean;
|
|
1166
|
+
/**
|
|
1167
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1168
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1169
|
+
* invalid editor content while still showing a warning or error message to
|
|
1170
|
+
* the user.
|
|
1171
|
+
*
|
|
1172
|
+
* @default false
|
|
1173
|
+
*/
|
|
1174
|
+
emitContentError: boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* Enable a lazy-loaded Prosemirror DevTools integration.
|
|
1177
|
+
*
|
|
1178
|
+
* Requires having the `prosemirror-dev-tools` npm package installed.
|
|
1179
|
+
* @type boolean
|
|
1180
|
+
* @default false
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```js
|
|
1183
|
+
* enableDevTools: true
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
enableDevTools: boolean;
|
|
1158
1187
|
/**
|
|
1159
1188
|
* Called before the editor is constructed.
|
|
1160
1189
|
*/
|
|
@@ -1622,9 +1651,13 @@ interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig
|
|
|
1622
1651
|
*/
|
|
1623
1652
|
declare class Extension<Options = any, Storage = any> extends Extendable<Options, Storage, ExtensionConfig<Options, Storage>> {
|
|
1624
1653
|
type: string;
|
|
1625
|
-
|
|
1654
|
+
/**
|
|
1655
|
+
* Create a new Extension instance
|
|
1656
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
1657
|
+
*/
|
|
1658
|
+
static create<O = any, S = any>(config?: Partial<ExtensionConfig<O, S>> | (() => Partial<ExtensionConfig<O, S>>)): Extension<O, S>;
|
|
1626
1659
|
configure(options?: Partial<Options>): Extension<Options, Storage>;
|
|
1627
|
-
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig>): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1660
|
+
extend<ExtendedOptions = Options, ExtendedStorage = Storage, ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>>(extendedConfig?: Partial<ExtendedConfig> | (() => Partial<ExtendedConfig>)): Extension<ExtendedOptions, ExtendedStorage>;
|
|
1628
1661
|
}
|
|
1629
1662
|
|
|
1630
1663
|
/**
|
|
@@ -2891,6 +2924,25 @@ declare class Editor extends EventEmitter<EditorEvents> {
|
|
|
2891
2924
|
* Remove the editor from the DOM, but still allow remounting at a different point in time
|
|
2892
2925
|
*/
|
|
2893
2926
|
unmount(): void;
|
|
2927
|
+
/**
|
|
2928
|
+
*
|
|
2929
|
+
* @returns
|
|
2930
|
+
*/
|
|
2931
|
+
/**
|
|
2932
|
+
* Applies ProseMirror dev tools to the editor instance if enabled and running in a browser environment.
|
|
2933
|
+
*
|
|
2934
|
+
* This method dynamically imports the `prosemirror-dev-tools` package and applies it to the current
|
|
2935
|
+
* editor view. If the dev tools are not installed, a warning is logged to the console.
|
|
2936
|
+
*
|
|
2937
|
+
* @private
|
|
2938
|
+
* @remarks
|
|
2939
|
+
* - Dev tools are only applied if `this.options.enableDevTools` is `true` and the code is running in a browser.
|
|
2940
|
+
* - If the editor view is not available, the dev tools are not applied.
|
|
2941
|
+
* - If the `prosemirror-dev-tools` package is missing, a warning is shown in the console.
|
|
2942
|
+
*
|
|
2943
|
+
* @returns {void}
|
|
2944
|
+
*/
|
|
2945
|
+
private applyDevTools;
|
|
2894
2946
|
/**
|
|
2895
2947
|
* Returns the editor storage.
|
|
2896
2948
|
*/
|
|
@@ -3256,6 +3308,8 @@ declare class Tracker {
|
|
|
3256
3308
|
*/
|
|
3257
3309
|
declare function callOrReturn<T>(value: T, context?: any, ...props: any[]): MaybeReturnType<T>;
|
|
3258
3310
|
|
|
3311
|
+
declare function canInsertNode(state: EditorState, nodeType: NodeType$1): boolean;
|
|
3312
|
+
|
|
3259
3313
|
declare function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement;
|
|
3260
3314
|
|
|
3261
3315
|
/**
|
|
@@ -3323,4 +3377,4 @@ interface Commands<ReturnType = any> {
|
|
|
3323
3377
|
interface Storage {
|
|
3324
3378
|
}
|
|
3325
3379
|
|
|
3326
|
-
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 };
|
|
3380
|
+
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
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
__export
|
|
3
|
+
} from "./chunk-PR4QN5HX.js";
|
|
6
4
|
|
|
7
5
|
// src/helpers/createChainableState.ts
|
|
8
6
|
function createChainableState(config) {
|
|
@@ -1831,8 +1829,13 @@ var Mark = class _Mark extends Extendable {
|
|
|
1831
1829
|
super(...arguments);
|
|
1832
1830
|
this.type = "mark";
|
|
1833
1831
|
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Create a new Mark instance
|
|
1834
|
+
* @param config - Mark configuration object or a function that returns a configuration object
|
|
1835
|
+
*/
|
|
1834
1836
|
static create(config = {}) {
|
|
1835
|
-
|
|
1837
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
1838
|
+
return new _Mark(resolvedConfig);
|
|
1836
1839
|
}
|
|
1837
1840
|
static handleExit({ editor, mark }) {
|
|
1838
1841
|
const { tr } = editor.state;
|
|
@@ -1858,7 +1861,8 @@ var Mark = class _Mark extends Extendable {
|
|
|
1858
1861
|
return super.configure(options);
|
|
1859
1862
|
}
|
|
1860
1863
|
extend(extendedConfig) {
|
|
1861
|
-
|
|
1864
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
1865
|
+
return super.extend(resolvedConfig);
|
|
1862
1866
|
}
|
|
1863
1867
|
};
|
|
1864
1868
|
|
|
@@ -2026,7 +2030,7 @@ function pasteRulesPlugin(props) {
|
|
|
2026
2030
|
dropEvent = event;
|
|
2027
2031
|
if (!isDroppedFromProseMirror) {
|
|
2028
2032
|
const dragFromOtherEditor = tiptapDragFromOtherEditor;
|
|
2029
|
-
if (dragFromOtherEditor) {
|
|
2033
|
+
if (dragFromOtherEditor == null ? void 0 : dragFromOtherEditor.isEditable) {
|
|
2030
2034
|
setTimeout(() => {
|
|
2031
2035
|
const selection = dragFromOtherEditor.state.selection;
|
|
2032
2036
|
if (selection) {
|
|
@@ -2363,14 +2367,20 @@ var Extension = class _Extension extends Extendable {
|
|
|
2363
2367
|
super(...arguments);
|
|
2364
2368
|
this.type = "extension";
|
|
2365
2369
|
}
|
|
2370
|
+
/**
|
|
2371
|
+
* Create a new Extension instance
|
|
2372
|
+
* @param config - Extension configuration object or a function that returns a configuration object
|
|
2373
|
+
*/
|
|
2366
2374
|
static create(config = {}) {
|
|
2367
|
-
|
|
2375
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
2376
|
+
return new _Extension(resolvedConfig);
|
|
2368
2377
|
}
|
|
2369
2378
|
configure(options) {
|
|
2370
2379
|
return super.configure(options);
|
|
2371
2380
|
}
|
|
2372
2381
|
extend(extendedConfig) {
|
|
2373
|
-
|
|
2382
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
2383
|
+
return super.extend(resolvedConfig);
|
|
2374
2384
|
}
|
|
2375
2385
|
};
|
|
2376
2386
|
|
|
@@ -2540,7 +2550,7 @@ var cut = (originRange, targetPos) => ({ editor, tr }) => {
|
|
|
2540
2550
|
tr.deleteRange(originRange.from, originRange.to);
|
|
2541
2551
|
const newPos = tr.mapping.map(targetPos);
|
|
2542
2552
|
tr.insert(newPos, contentSlice.content);
|
|
2543
|
-
tr.setSelection(new TextSelection3(tr.doc.resolve(newPos - 1)));
|
|
2553
|
+
tr.setSelection(new TextSelection3(tr.doc.resolve(Math.max(newPos - 1, 0))));
|
|
2544
2554
|
return true;
|
|
2545
2555
|
};
|
|
2546
2556
|
|
|
@@ -2716,18 +2726,10 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2716
2726
|
};
|
|
2717
2727
|
let content;
|
|
2718
2728
|
const { selection } = editor.state;
|
|
2719
|
-
|
|
2720
|
-
content = createNodeFromContent(value, editor.schema, {
|
|
2721
|
-
parseOptions: {
|
|
2722
|
-
preserveWhitespace: "full",
|
|
2723
|
-
...options.parseOptions
|
|
2724
|
-
},
|
|
2725
|
-
errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
|
|
2726
|
-
});
|
|
2727
|
-
} catch (e) {
|
|
2729
|
+
const emitContentError = (error) => {
|
|
2728
2730
|
editor.emit("contentError", {
|
|
2729
2731
|
editor,
|
|
2730
|
-
error
|
|
2732
|
+
error,
|
|
2731
2733
|
disableCollaboration: () => {
|
|
2732
2734
|
if ("collaboration" in editor.storage && typeof editor.storage.collaboration === "object" && editor.storage.collaboration) {
|
|
2733
2735
|
;
|
|
@@ -2735,6 +2737,28 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2735
2737
|
}
|
|
2736
2738
|
}
|
|
2737
2739
|
});
|
|
2740
|
+
};
|
|
2741
|
+
const parseOptions = {
|
|
2742
|
+
preserveWhitespace: "full",
|
|
2743
|
+
...options.parseOptions
|
|
2744
|
+
};
|
|
2745
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
2746
|
+
try {
|
|
2747
|
+
createNodeFromContent(value, editor.schema, {
|
|
2748
|
+
parseOptions,
|
|
2749
|
+
errorOnInvalidContent: true
|
|
2750
|
+
});
|
|
2751
|
+
} catch (e) {
|
|
2752
|
+
emitContentError(e);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
try {
|
|
2756
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
2757
|
+
parseOptions,
|
|
2758
|
+
errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
|
|
2759
|
+
});
|
|
2760
|
+
} catch (e) {
|
|
2761
|
+
emitContentError(e);
|
|
2738
2762
|
return false;
|
|
2739
2763
|
}
|
|
2740
2764
|
let { from, to } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
@@ -2776,7 +2800,8 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2776
2800
|
newContent = content;
|
|
2777
2801
|
const fromSelectionAtStart = selection.$from.parentOffset === 0;
|
|
2778
2802
|
const isTextSelection2 = selection.$from.node().isText || selection.$from.node().isTextblock;
|
|
2779
|
-
|
|
2803
|
+
const hasContent = selection.$from.node().content.size > 0;
|
|
2804
|
+
if (fromSelectionAtStart && isTextSelection2 && hasContent) {
|
|
2780
2805
|
from = Math.max(0, from - 1);
|
|
2781
2806
|
}
|
|
2782
2807
|
tr.replaceWith(from, to, newContent);
|
|
@@ -4072,6 +4097,9 @@ var NodePos = class _NodePos {
|
|
|
4072
4097
|
const isBlock = node.isBlock && !node.isTextblock;
|
|
4073
4098
|
const isNonTextAtom = node.isAtom && !node.isText;
|
|
4074
4099
|
const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
|
|
4100
|
+
if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
|
|
4101
|
+
return;
|
|
4102
|
+
}
|
|
4075
4103
|
const $pos = this.resolvedPos.doc.resolve(targetPos);
|
|
4076
4104
|
if (!isBlock && $pos.depth <= this.depth) {
|
|
4077
4105
|
return;
|
|
@@ -4269,6 +4297,8 @@ var Editor = class extends EventEmitter {
|
|
|
4269
4297
|
enablePasteRules: true,
|
|
4270
4298
|
enableCoreExtensions: true,
|
|
4271
4299
|
enableContentCheck: false,
|
|
4300
|
+
enableDevTools: false,
|
|
4301
|
+
emitContentError: false,
|
|
4272
4302
|
onBeforeCreate: () => null,
|
|
4273
4303
|
onCreate: () => null,
|
|
4274
4304
|
onUpdate: () => null,
|
|
@@ -4350,6 +4380,38 @@ var Editor = class extends EventEmitter {
|
|
|
4350
4380
|
(_a = this.css) == null ? void 0 : _a.remove();
|
|
4351
4381
|
this.css = null;
|
|
4352
4382
|
}
|
|
4383
|
+
/**
|
|
4384
|
+
*
|
|
4385
|
+
* @returns
|
|
4386
|
+
*/
|
|
4387
|
+
/**
|
|
4388
|
+
* Applies ProseMirror dev tools to the editor instance if enabled and running in a browser environment.
|
|
4389
|
+
*
|
|
4390
|
+
* This method dynamically imports the `prosemirror-dev-tools` package and applies it to the current
|
|
4391
|
+
* editor view. If the dev tools are not installed, a warning is logged to the console.
|
|
4392
|
+
*
|
|
4393
|
+
* @private
|
|
4394
|
+
* @remarks
|
|
4395
|
+
* - Dev tools are only applied if `this.options.enableDevTools` is `true` and the code is running in a browser.
|
|
4396
|
+
* - If the editor view is not available, the dev tools are not applied.
|
|
4397
|
+
* - If the `prosemirror-dev-tools` package is missing, a warning is shown in the console.
|
|
4398
|
+
*
|
|
4399
|
+
* @returns {void}
|
|
4400
|
+
*/
|
|
4401
|
+
applyDevTools() {
|
|
4402
|
+
if (typeof window === "undefined" || !this.options.enableDevTools) {
|
|
4403
|
+
return;
|
|
4404
|
+
}
|
|
4405
|
+
import("./esm-7BF7U2WM.js").then(({ default: apply }) => {
|
|
4406
|
+
if (!this.editorView) {
|
|
4407
|
+
return;
|
|
4408
|
+
}
|
|
4409
|
+
apply(this.editorView);
|
|
4410
|
+
}).catch(() => {
|
|
4411
|
+
console.warn("[Tiptap warning]: Devtools are enabled but `prosemirror-dev-tools` is not installed.");
|
|
4412
|
+
console.warn("Install 'prosemirror-dev-tools' as a dev dependency to use the dev tools.");
|
|
4413
|
+
});
|
|
4414
|
+
}
|
|
4353
4415
|
/**
|
|
4354
4416
|
* Returns the editor storage.
|
|
4355
4417
|
*/
|
|
@@ -4434,7 +4496,8 @@ var Editor = class extends EventEmitter {
|
|
|
4434
4496
|
// Stub some commonly accessed properties to prevent errors
|
|
4435
4497
|
composing: false,
|
|
4436
4498
|
dragging: null,
|
|
4437
|
-
editable: true
|
|
4499
|
+
editable: true,
|
|
4500
|
+
isDestroyed: false
|
|
4438
4501
|
},
|
|
4439
4502
|
{
|
|
4440
4503
|
get: (obj, key) => {
|
|
@@ -4487,7 +4550,7 @@ var Editor = class extends EventEmitter {
|
|
|
4487
4550
|
let plugins = prevPlugins;
|
|
4488
4551
|
[].concat(nameOrPluginKeyToRemove).forEach((nameOrPluginKey) => {
|
|
4489
4552
|
const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
|
|
4490
|
-
plugins =
|
|
4553
|
+
plugins = plugins.filter((plugin) => !plugin.key.startsWith(name));
|
|
4491
4554
|
});
|
|
4492
4555
|
if (prevPlugins.length === plugins.length) {
|
|
4493
4556
|
return void 0;
|
|
@@ -4586,6 +4649,9 @@ var Editor = class extends EventEmitter {
|
|
|
4586
4649
|
dispatchTransaction: this.dispatchTransaction.bind(this),
|
|
4587
4650
|
state: this.editorState
|
|
4588
4651
|
});
|
|
4652
|
+
if (this.options.enableDevTools) {
|
|
4653
|
+
this.applyDevTools();
|
|
4654
|
+
}
|
|
4589
4655
|
const newState = this.state.reconfigure({
|
|
4590
4656
|
plugins: this.extensionManager.plugins
|
|
4591
4657
|
});
|
|
@@ -4748,8 +4814,8 @@ var Editor = class extends EventEmitter {
|
|
|
4748
4814
|
* Check if the editor is already destroyed.
|
|
4749
4815
|
*/
|
|
4750
4816
|
get isDestroyed() {
|
|
4751
|
-
var _a;
|
|
4752
|
-
return
|
|
4817
|
+
var _a, _b;
|
|
4818
|
+
return (_b = (_a = this.editorView) == null ? void 0 : _a.isDestroyed) != null ? _b : true;
|
|
4753
4819
|
}
|
|
4754
4820
|
$node(selector, attributes) {
|
|
4755
4821
|
var _a;
|
|
@@ -4927,6 +4993,29 @@ var h = (tag, attributes) => {
|
|
|
4927
4993
|
return [tag, rest, children];
|
|
4928
4994
|
};
|
|
4929
4995
|
|
|
4996
|
+
// src/utilities/canInsertNode.ts
|
|
4997
|
+
import { NodeSelection as NodeSelection4 } from "@tiptap/pm/state";
|
|
4998
|
+
function canInsertNode(state, nodeType) {
|
|
4999
|
+
const { selection } = state;
|
|
5000
|
+
const { $from } = selection;
|
|
5001
|
+
if (selection instanceof NodeSelection4) {
|
|
5002
|
+
const index = $from.index();
|
|
5003
|
+
const parent = $from.parent;
|
|
5004
|
+
return parent.canReplaceWith(index, index + 1, nodeType);
|
|
5005
|
+
}
|
|
5006
|
+
let depth = $from.depth;
|
|
5007
|
+
while (depth >= 0) {
|
|
5008
|
+
const index = $from.index(depth);
|
|
5009
|
+
const parent = $from.node(depth);
|
|
5010
|
+
const match = parent.contentMatchAt(index);
|
|
5011
|
+
if (match.matchType(nodeType)) {
|
|
5012
|
+
return true;
|
|
5013
|
+
}
|
|
5014
|
+
depth -= 1;
|
|
5015
|
+
}
|
|
5016
|
+
return false;
|
|
5017
|
+
}
|
|
5018
|
+
|
|
4930
5019
|
// src/utilities/escapeForRegEx.ts
|
|
4931
5020
|
function escapeForRegEx(string) {
|
|
4932
5021
|
return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
@@ -4984,19 +5073,25 @@ var Node3 = class _Node extends Extendable {
|
|
|
4984
5073
|
super(...arguments);
|
|
4985
5074
|
this.type = "node";
|
|
4986
5075
|
}
|
|
5076
|
+
/**
|
|
5077
|
+
* Create a new Node instance
|
|
5078
|
+
* @param config - Node configuration object or a function that returns a configuration object
|
|
5079
|
+
*/
|
|
4987
5080
|
static create(config = {}) {
|
|
4988
|
-
|
|
5081
|
+
const resolvedConfig = typeof config === "function" ? config() : config;
|
|
5082
|
+
return new _Node(resolvedConfig);
|
|
4989
5083
|
}
|
|
4990
5084
|
configure(options) {
|
|
4991
5085
|
return super.configure(options);
|
|
4992
5086
|
}
|
|
4993
5087
|
extend(extendedConfig) {
|
|
4994
|
-
|
|
5088
|
+
const resolvedConfig = typeof extendedConfig === "function" ? extendedConfig() : extendedConfig;
|
|
5089
|
+
return super.extend(resolvedConfig);
|
|
4995
5090
|
}
|
|
4996
5091
|
};
|
|
4997
5092
|
|
|
4998
5093
|
// src/NodeView.ts
|
|
4999
|
-
import { NodeSelection as
|
|
5094
|
+
import { NodeSelection as NodeSelection5 } from "@tiptap/pm/state";
|
|
5000
5095
|
var NodeView = class {
|
|
5001
5096
|
constructor(component, props, options) {
|
|
5002
5097
|
this.isDragging = false;
|
|
@@ -5049,7 +5144,7 @@ var NodeView = class {
|
|
|
5049
5144
|
if (typeof pos !== "number") {
|
|
5050
5145
|
return;
|
|
5051
5146
|
}
|
|
5052
|
-
const selection =
|
|
5147
|
+
const selection = NodeSelection5.create(view.state.doc, pos);
|
|
5053
5148
|
const transaction = view.state.tr.setSelection(selection);
|
|
5054
5149
|
view.dispatch(transaction);
|
|
5055
5150
|
}
|
|
@@ -5075,7 +5170,7 @@ var NodeView = class {
|
|
|
5075
5170
|
const { isEditable } = this.editor;
|
|
5076
5171
|
const { isDragging } = this;
|
|
5077
5172
|
const isDraggable = !!this.node.type.spec.draggable;
|
|
5078
|
-
const isSelectable =
|
|
5173
|
+
const isSelectable = NodeSelection5.isSelectable(this.node);
|
|
5079
5174
|
const isCopyEvent = event.type === "copy";
|
|
5080
5175
|
const isPasteEvent = event.type === "paste";
|
|
5081
5176
|
const isCutEvent = event.type === "cut";
|
|
@@ -5298,6 +5393,7 @@ export {
|
|
|
5298
5393
|
PasteRule,
|
|
5299
5394
|
Tracker,
|
|
5300
5395
|
callOrReturn,
|
|
5396
|
+
canInsertNode,
|
|
5301
5397
|
combineTransactionSteps,
|
|
5302
5398
|
createChainableState,
|
|
5303
5399
|
createDocument,
|