@tiptap/core 3.0.0-beta.1 → 3.0.0-beta.11
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 +30 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +30 -14
- package/dist/index.js.map +1 -1
- 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/package.json +5 -4
- package/src/Editor.ts +4 -3
- package/src/commands/insertContentAt.ts +29 -10
- package/src/types.ts +9 -0
package/dist/index.cjs
CHANGED
|
@@ -2835,18 +2835,10 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2835
2835
|
};
|
|
2836
2836
|
let content;
|
|
2837
2837
|
const { selection } = editor.state;
|
|
2838
|
-
|
|
2839
|
-
content = createNodeFromContent(value, editor.schema, {
|
|
2840
|
-
parseOptions: {
|
|
2841
|
-
preserveWhitespace: "full",
|
|
2842
|
-
...options.parseOptions
|
|
2843
|
-
},
|
|
2844
|
-
errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
|
|
2845
|
-
});
|
|
2846
|
-
} catch (e) {
|
|
2838
|
+
const emitContentError = (error) => {
|
|
2847
2839
|
editor.emit("contentError", {
|
|
2848
2840
|
editor,
|
|
2849
|
-
error
|
|
2841
|
+
error,
|
|
2850
2842
|
disableCollaboration: () => {
|
|
2851
2843
|
if ("collaboration" in editor.storage && typeof editor.storage.collaboration === "object" && editor.storage.collaboration) {
|
|
2852
2844
|
;
|
|
@@ -2854,6 +2846,28 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2854
2846
|
}
|
|
2855
2847
|
}
|
|
2856
2848
|
});
|
|
2849
|
+
};
|
|
2850
|
+
const parseOptions = {
|
|
2851
|
+
preserveWhitespace: "full",
|
|
2852
|
+
...options.parseOptions
|
|
2853
|
+
};
|
|
2854
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
2855
|
+
try {
|
|
2856
|
+
createNodeFromContent(value, editor.schema, {
|
|
2857
|
+
parseOptions,
|
|
2858
|
+
errorOnInvalidContent: true
|
|
2859
|
+
});
|
|
2860
|
+
} catch (e) {
|
|
2861
|
+
emitContentError(e);
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
try {
|
|
2865
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
2866
|
+
parseOptions,
|
|
2867
|
+
errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
|
|
2868
|
+
});
|
|
2869
|
+
} catch (e) {
|
|
2870
|
+
emitContentError(e);
|
|
2857
2871
|
return false;
|
|
2858
2872
|
}
|
|
2859
2873
|
let { from, to } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
@@ -4383,6 +4397,7 @@ var Editor = class extends EventEmitter {
|
|
|
4383
4397
|
enablePasteRules: true,
|
|
4384
4398
|
enableCoreExtensions: true,
|
|
4385
4399
|
enableContentCheck: false,
|
|
4400
|
+
emitContentError: false,
|
|
4386
4401
|
onBeforeCreate: () => null,
|
|
4387
4402
|
onCreate: () => null,
|
|
4388
4403
|
onUpdate: () => null,
|
|
@@ -4548,7 +4563,8 @@ var Editor = class extends EventEmitter {
|
|
|
4548
4563
|
// Stub some commonly accessed properties to prevent errors
|
|
4549
4564
|
composing: false,
|
|
4550
4565
|
dragging: null,
|
|
4551
|
-
editable: true
|
|
4566
|
+
editable: true,
|
|
4567
|
+
isDestroyed: false
|
|
4552
4568
|
},
|
|
4553
4569
|
{
|
|
4554
4570
|
get: (obj, key) => {
|
|
@@ -4601,7 +4617,7 @@ var Editor = class extends EventEmitter {
|
|
|
4601
4617
|
let plugins = prevPlugins;
|
|
4602
4618
|
[].concat(nameOrPluginKeyToRemove).forEach((nameOrPluginKey) => {
|
|
4603
4619
|
const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
|
|
4604
|
-
plugins =
|
|
4620
|
+
plugins = plugins.filter((plugin) => !plugin.key.startsWith(name));
|
|
4605
4621
|
});
|
|
4606
4622
|
if (prevPlugins.length === plugins.length) {
|
|
4607
4623
|
return void 0;
|
|
@@ -4862,8 +4878,8 @@ var Editor = class extends EventEmitter {
|
|
|
4862
4878
|
* Check if the editor is already destroyed.
|
|
4863
4879
|
*/
|
|
4864
4880
|
get isDestroyed() {
|
|
4865
|
-
var _a;
|
|
4866
|
-
return
|
|
4881
|
+
var _a, _b;
|
|
4882
|
+
return (_b = (_a = this.editorView) == null ? void 0 : _a.isDestroyed) != null ? _b : true;
|
|
4867
4883
|
}
|
|
4868
4884
|
$node(selector, attributes) {
|
|
4869
4885
|
var _a;
|