@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.cjs +37 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/Editor.ts +13 -3
- package/src/Extendable.ts +28 -0
- package/src/ExtensionManager.ts +35 -1
- package/src/types.ts +28 -0
package/dist/index.cjs
CHANGED
|
@@ -3772,6 +3772,35 @@ var ExtensionManager = class {
|
|
|
3772
3772
|
})
|
|
3773
3773
|
);
|
|
3774
3774
|
}
|
|
3775
|
+
/**
|
|
3776
|
+
* Get the composed dispatchTransaction function from all extensions.
|
|
3777
|
+
* @param baseDispatch The base dispatch function (e.g. from the editor or user props)
|
|
3778
|
+
* @returns A composed dispatch function
|
|
3779
|
+
*/
|
|
3780
|
+
dispatchTransaction(baseDispatch) {
|
|
3781
|
+
const { editor } = this;
|
|
3782
|
+
const extensions = sortExtensions([...this.extensions].reverse());
|
|
3783
|
+
return extensions.reduceRight((next, extension) => {
|
|
3784
|
+
const context = {
|
|
3785
|
+
name: extension.name,
|
|
3786
|
+
options: extension.options,
|
|
3787
|
+
storage: this.editor.extensionStorage[extension.name],
|
|
3788
|
+
editor,
|
|
3789
|
+
type: getSchemaTypeByName(extension.name, this.schema)
|
|
3790
|
+
};
|
|
3791
|
+
const dispatchTransaction = getExtensionField(
|
|
3792
|
+
extension,
|
|
3793
|
+
"dispatchTransaction",
|
|
3794
|
+
context
|
|
3795
|
+
);
|
|
3796
|
+
if (!dispatchTransaction) {
|
|
3797
|
+
return next;
|
|
3798
|
+
}
|
|
3799
|
+
return (transaction) => {
|
|
3800
|
+
dispatchTransaction.call(context, { transaction, next });
|
|
3801
|
+
};
|
|
3802
|
+
}, baseDispatch);
|
|
3803
|
+
}
|
|
3775
3804
|
get markViews() {
|
|
3776
3805
|
const { editor } = this;
|
|
3777
3806
|
const { markExtensions } = splitExtensions(this.extensions);
|
|
@@ -4633,7 +4662,8 @@ var Editor = class extends EventEmitter {
|
|
|
4633
4662
|
},
|
|
4634
4663
|
onPaste: () => null,
|
|
4635
4664
|
onDrop: () => null,
|
|
4636
|
-
onDelete: () => null
|
|
4665
|
+
onDelete: () => null,
|
|
4666
|
+
enableExtensionDispatchTransaction: true
|
|
4637
4667
|
};
|
|
4638
4668
|
this.isCapturingTransaction = false;
|
|
4639
4669
|
this.capturedTransaction = null;
|
|
@@ -4958,15 +4988,17 @@ var Editor = class extends EventEmitter {
|
|
|
4958
4988
|
* Creates a ProseMirror view.
|
|
4959
4989
|
*/
|
|
4960
4990
|
createView(element) {
|
|
4961
|
-
|
|
4991
|
+
const { editorProps, enableExtensionDispatchTransaction } = this.options;
|
|
4992
|
+
const baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);
|
|
4993
|
+
const dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;
|
|
4962
4994
|
this.editorView = new import_view.EditorView(element, {
|
|
4963
|
-
...
|
|
4995
|
+
...editorProps,
|
|
4964
4996
|
attributes: {
|
|
4965
4997
|
// add `role="textbox"` to the editor element
|
|
4966
4998
|
role: "textbox",
|
|
4967
|
-
...
|
|
4999
|
+
...editorProps == null ? void 0 : editorProps.attributes
|
|
4968
5000
|
},
|
|
4969
|
-
dispatchTransaction:
|
|
5001
|
+
dispatchTransaction: dispatch,
|
|
4970
5002
|
state: this.editorState,
|
|
4971
5003
|
markViews: this.extensionManager.markViews,
|
|
4972
5004
|
nodeViews: this.extensionManager.nodeViews
|