@tiptap/core 3.14.0 → 3.15.1

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.d.cts CHANGED
@@ -889,6 +889,27 @@ interface ExtendableConfig<Options = any, Storage = any, Config extends Extensio
889
889
  type: PMType;
890
890
  parent: ParentConfig<Config>['onDestroy'];
891
891
  }, event: EditorEvents['destroy']) => void) | null;
892
+ /**
893
+ * This hook allows you to intercept and modify transactions before they are dispatched.
894
+ *
895
+ * Example
896
+ * ```ts
897
+ * dispatchTransaction({ transaction, next }) {
898
+ * console.log('Dispatching transaction:', transaction)
899
+ * next(transaction)
900
+ * }
901
+ * ```
902
+ *
903
+ * @param props - The dispatch transaction props
904
+ */
905
+ dispatchTransaction?: ((this: {
906
+ name: string;
907
+ options: Options;
908
+ storage: Storage;
909
+ editor: Editor;
910
+ type: PMType;
911
+ parent: ParentConfig<Config>['dispatchTransaction'];
912
+ }, props: DispatchTransactionProps) => void) | null;
892
913
  }
893
914
  declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>> {
894
915
  type: string;
@@ -1128,6 +1149,22 @@ interface EditorEvents {
1128
1149
  mark: Mark$1;
1129
1150
  });
1130
1151
  }
1152
+ /**
1153
+ * Props passed to the `dispatchTransaction` hook in extensions.
1154
+ */
1155
+ type DispatchTransactionProps = {
1156
+ /**
1157
+ * The transaction that is about to be dispatched.
1158
+ */
1159
+ transaction: Transaction;
1160
+ /**
1161
+ * A function that should be called to pass the transaction down to the next extension
1162
+ * (or eventually to the editor).
1163
+ *
1164
+ * @param transaction The transaction to dispatch
1165
+ */
1166
+ next: (transaction: Transaction) => void;
1167
+ };
1131
1168
  type EnableRules = (AnyExtension | string)[] | boolean;
1132
1169
  interface EditorOptions {
1133
1170
  /**
@@ -1299,6 +1336,17 @@ interface EditorOptions {
1299
1336
  * Called when content is deleted from the editor.
1300
1337
  */
1301
1338
  onDelete: (props: EditorEvents['delete']) => void;
1339
+ /**
1340
+ * Whether to enable extension-level dispatching of transactions.
1341
+ * If `false`, extensions cannot define their own `dispatchTransaction` hook.
1342
+ *
1343
+ * @default true
1344
+ * @example
1345
+ * new Editor({
1346
+ * enableExtensionDispatchTransaction: false,
1347
+ * })
1348
+ */
1349
+ enableExtensionDispatchTransaction?: boolean;
1302
1350
  }
1303
1351
  /**
1304
1352
  * The editor's content as HTML
@@ -2266,6 +2314,12 @@ declare class ExtensionManager {
2266
2314
  * @returns An object with all node views where the key is the node name and the value is the node view function
2267
2315
  */
2268
2316
  get nodeViews(): Record<string, NodeViewConstructor>;
2317
+ /**
2318
+ * Get the composed dispatchTransaction function from all extensions.
2319
+ * @param baseDispatch The base dispatch function (e.g. from the editor or user props)
2320
+ * @returns A composed dispatch function
2321
+ */
2322
+ dispatchTransaction(baseDispatch: (tr: Transaction) => void): (tr: Transaction) => void;
2269
2323
  get markViews(): Record<string, MarkViewConstructor>;
2270
2324
  /**
2271
2325
  * Go through all extensions, create extension storages & setup marks
@@ -4810,4 +4864,4 @@ interface Commands<ReturnType = any> {
4810
4864
  interface Storage {
4811
4865
  }
4812
4866
 
4813
- export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
4867
+ export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
package/dist/index.d.ts CHANGED
@@ -889,6 +889,27 @@ interface ExtendableConfig<Options = any, Storage = any, Config extends Extensio
889
889
  type: PMType;
890
890
  parent: ParentConfig<Config>['onDestroy'];
891
891
  }, event: EditorEvents['destroy']) => void) | null;
892
+ /**
893
+ * This hook allows you to intercept and modify transactions before they are dispatched.
894
+ *
895
+ * Example
896
+ * ```ts
897
+ * dispatchTransaction({ transaction, next }) {
898
+ * console.log('Dispatching transaction:', transaction)
899
+ * next(transaction)
900
+ * }
901
+ * ```
902
+ *
903
+ * @param props - The dispatch transaction props
904
+ */
905
+ dispatchTransaction?: ((this: {
906
+ name: string;
907
+ options: Options;
908
+ storage: Storage;
909
+ editor: Editor;
910
+ type: PMType;
911
+ parent: ParentConfig<Config>['dispatchTransaction'];
912
+ }, props: DispatchTransactionProps) => void) | null;
892
913
  }
893
914
  declare class Extendable<Options = any, Storage = any, Config = ExtensionConfig<Options, Storage> | NodeConfig<Options, Storage> | MarkConfig<Options, Storage>> {
894
915
  type: string;
@@ -1128,6 +1149,22 @@ interface EditorEvents {
1128
1149
  mark: Mark$1;
1129
1150
  });
1130
1151
  }
1152
+ /**
1153
+ * Props passed to the `dispatchTransaction` hook in extensions.
1154
+ */
1155
+ type DispatchTransactionProps = {
1156
+ /**
1157
+ * The transaction that is about to be dispatched.
1158
+ */
1159
+ transaction: Transaction;
1160
+ /**
1161
+ * A function that should be called to pass the transaction down to the next extension
1162
+ * (or eventually to the editor).
1163
+ *
1164
+ * @param transaction The transaction to dispatch
1165
+ */
1166
+ next: (transaction: Transaction) => void;
1167
+ };
1131
1168
  type EnableRules = (AnyExtension | string)[] | boolean;
1132
1169
  interface EditorOptions {
1133
1170
  /**
@@ -1299,6 +1336,17 @@ interface EditorOptions {
1299
1336
  * Called when content is deleted from the editor.
1300
1337
  */
1301
1338
  onDelete: (props: EditorEvents['delete']) => void;
1339
+ /**
1340
+ * Whether to enable extension-level dispatching of transactions.
1341
+ * If `false`, extensions cannot define their own `dispatchTransaction` hook.
1342
+ *
1343
+ * @default true
1344
+ * @example
1345
+ * new Editor({
1346
+ * enableExtensionDispatchTransaction: false,
1347
+ * })
1348
+ */
1349
+ enableExtensionDispatchTransaction?: boolean;
1302
1350
  }
1303
1351
  /**
1304
1352
  * The editor's content as HTML
@@ -2266,6 +2314,12 @@ declare class ExtensionManager {
2266
2314
  * @returns An object with all node views where the key is the node name and the value is the node view function
2267
2315
  */
2268
2316
  get nodeViews(): Record<string, NodeViewConstructor>;
2317
+ /**
2318
+ * Get the composed dispatchTransaction function from all extensions.
2319
+ * @param baseDispatch The base dispatch function (e.g. from the editor or user props)
2320
+ * @returns A composed dispatch function
2321
+ */
2322
+ dispatchTransaction(baseDispatch: (tr: Transaction) => void): (tr: Transaction) => void;
2269
2323
  get markViews(): Record<string, MarkViewConstructor>;
2270
2324
  /**
2271
2325
  * Go through all extensions, create extension storages & setup marks
@@ -4810,4 +4864,4 @@ interface Commands<ReturnType = any> {
4810
4864
  interface Storage {
4811
4865
  }
4812
4866
 
4813
- export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
4867
+ export { type AllowedAttribute, type AnyCommands, type AnyConfig, type AnyExtension, type AtomBlockMarkdownSpecOptions, type Attribute, type Attributes$1 as Attributes, type BlockMarkdownSpecOptions, type BlockParserConfig, 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 DispatchTransactionProps, type DocumentType, Editor, type EditorEvents, type EditorOptions, type EnableRules, Extendable, type ExtendableConfig, type ExtendedRegExpMatchArray, Extension, type ExtensionAttribute, type ExtensionConfig, type Extensions, type FocusPosition, Fragment, type FullMarkdownHelpers, type GetUpdatedPositionResult, type GlobalAttributes, type HTMLContent, type InlineMarkdownSpecOptions, InputRule, type InputRuleFinder, type InputRuleMatch, type InsertContentAtOptions, type InsertContentOptions, type JSONContent, type KeyboardShortcutCommand, type KeysWithTypeOf, MappablePosition, Mark, type MarkConfig, type MarkRange, type MarkType, MarkView, type MarkViewProps, type MarkViewRenderer, type MarkViewRendererOptions, type MarkViewRendererProps, type MarkdownExtensionSpec, type MarkdownHelpers, type MarkdownLexerConfiguration, type MarkdownParseHelpers, type MarkdownParseResult, type MarkdownRendererHelpers, type MarkdownToken, type MarkdownTokenizer, 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, type ParsedBlock, PasteRule, type PasteRuleFinder, type PasteRuleMatch, type PickValue, type Predicate, type Primitive, type Range, type RawCommands, type RemoveThis, type RenderContext, type ResizableNodeDimensions, ResizableNodeView, type ResizableNodeViewDirection, type ResizableNodeViewOptions, ResizableNodeview, type SetContentOptions, type SingleCommands, type Storage, type TextSerializer, type TextType, type TiptapEditorHTMLElement, Tracker, type TrackerResult, type UnionCommands, type UnionToIntersection, type Utils, type ValuesOf, blur, callOrReturn, canInsertNode, clearContent, clearNodes, combineTransactionSteps, command, index$2 as commands, createAtomBlockMarkdownSpec, createBlockMarkdownSpec, createChainableState, createDocument, h as createElement, createInlineMarkdownSpec, createMappablePosition, createNodeFromContent, createParagraphNear, createStyleTag, cut, defaultBlockAt, deleteCurrentNode, deleteNode, deleteProps, deleteRange, deleteSelection, elementFromString, enter, escapeForRegEx, exitCode, extendMarkRange, index$1 as extensions, findChildren, findChildrenInRange, findDuplicates, findParentNode, findParentNodeClosestToPos, first, flattenExtensions, focus, forEach, 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, getUpdatedPosition, h, injectExtensionAttributesToParseRule, inputRulesPlugin, insertContent, insertContentAt, isActive, isAndroid, isAtEndOfNode, isAtStartOfNode, isEmptyObject, isExtensionRulesEnabled, isFunction, isList, isMacOS, isMarkActive, isNodeActive, isNodeEmpty, isNodeSelection, isNumber, isPlainObject, isRegExp, isString, isTextSelection, isiOS, joinBackward, joinDown, joinForward, joinItemBackward, joinItemForward, joinTextblockBackward, joinTextblockForward, joinUp, keyboardShortcut, lift, liftEmptyBlock, liftListItem, markInputRule, markPasteRule, index as markdown, mergeAttributes, mergeDeep, minMax, newlineInCode, nodeInputRule, nodePasteRule, objectIncludes, parseAttributes, parseIndentedBlocks, pasteRulesPlugin, posToDOMRect, removeDuplicates, renderNestedMarkdownContent, resetAttributes, resolveExtensions, resolveFocusPosition, rewriteUnknownContent, scrollIntoView, selectAll, selectNodeBackward, selectNodeForward, selectParentNode, selectTextblockEnd, selectTextblockStart, selectionToInsertionEnd, serializeAttributes, setContent, setMark, setMeta, setNode, setNodeSelection, setTextDirection, setTextSelection, sinkListItem, sortExtensions, splitBlock, splitExtensions, splitListItem, textInputRule, textPasteRule, textblockTypeInputRule, toggleList, toggleMark, toggleNode, toggleWrap, undoInputRule, unsetAllMarks, unsetMark, unsetTextDirection, updateAttributes, updateMarkViewAttributes, wrapIn, wrapInList, wrappingInputRule };
package/dist/index.js CHANGED
@@ -3641,6 +3641,35 @@ var ExtensionManager = class {
3641
3641
  })
3642
3642
  );
3643
3643
  }
3644
+ /**
3645
+ * Get the composed dispatchTransaction function from all extensions.
3646
+ * @param baseDispatch The base dispatch function (e.g. from the editor or user props)
3647
+ * @returns A composed dispatch function
3648
+ */
3649
+ dispatchTransaction(baseDispatch) {
3650
+ const { editor } = this;
3651
+ const extensions = sortExtensions([...this.extensions].reverse());
3652
+ return extensions.reduceRight((next, extension) => {
3653
+ const context = {
3654
+ name: extension.name,
3655
+ options: extension.options,
3656
+ storage: this.editor.extensionStorage[extension.name],
3657
+ editor,
3658
+ type: getSchemaTypeByName(extension.name, this.schema)
3659
+ };
3660
+ const dispatchTransaction = getExtensionField(
3661
+ extension,
3662
+ "dispatchTransaction",
3663
+ context
3664
+ );
3665
+ if (!dispatchTransaction) {
3666
+ return next;
3667
+ }
3668
+ return (transaction) => {
3669
+ dispatchTransaction.call(context, { transaction, next });
3670
+ };
3671
+ }, baseDispatch);
3672
+ }
3644
3673
  get markViews() {
3645
3674
  const { editor } = this;
3646
3675
  const { markExtensions } = splitExtensions(this.extensions);
@@ -4502,7 +4531,8 @@ var Editor = class extends EventEmitter {
4502
4531
  },
4503
4532
  onPaste: () => null,
4504
4533
  onDrop: () => null,
4505
- onDelete: () => null
4534
+ onDelete: () => null,
4535
+ enableExtensionDispatchTransaction: true
4506
4536
  };
4507
4537
  this.isCapturingTransaction = false;
4508
4538
  this.capturedTransaction = null;
@@ -4827,15 +4857,17 @@ var Editor = class extends EventEmitter {
4827
4857
  * Creates a ProseMirror view.
4828
4858
  */
4829
4859
  createView(element) {
4830
- var _a;
4860
+ const { editorProps, enableExtensionDispatchTransaction } = this.options;
4861
+ const baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);
4862
+ const dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;
4831
4863
  this.editorView = new EditorView(element, {
4832
- ...this.options.editorProps,
4864
+ ...editorProps,
4833
4865
  attributes: {
4834
4866
  // add `role="textbox"` to the editor element
4835
4867
  role: "textbox",
4836
- ...(_a = this.options.editorProps) == null ? void 0 : _a.attributes
4868
+ ...editorProps == null ? void 0 : editorProps.attributes
4837
4869
  },
4838
- dispatchTransaction: this.dispatchTransaction.bind(this),
4870
+ dispatchTransaction: dispatch,
4839
4871
  state: this.editorState,
4840
4872
  markViews: this.extensionManager.markViews,
4841
4873
  nodeViews: this.extensionManager.nodeViews