@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.d.cts
CHANGED
|
@@ -1155,6 +1155,15 @@ interface EditorOptions {
|
|
|
1155
1155
|
* @default false
|
|
1156
1156
|
*/
|
|
1157
1157
|
enableContentCheck: boolean;
|
|
1158
|
+
/**
|
|
1159
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1160
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1161
|
+
* invalid editor content while still showing a warning or error message to
|
|
1162
|
+
* the user.
|
|
1163
|
+
*
|
|
1164
|
+
* @default false
|
|
1165
|
+
*/
|
|
1166
|
+
emitContentError: boolean;
|
|
1158
1167
|
/**
|
|
1159
1168
|
* Called before the editor is constructed.
|
|
1160
1169
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1155,6 +1155,15 @@ interface EditorOptions {
|
|
|
1155
1155
|
* @default false
|
|
1156
1156
|
*/
|
|
1157
1157
|
enableContentCheck: boolean;
|
|
1158
|
+
/**
|
|
1159
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
1160
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
1161
|
+
* invalid editor content while still showing a warning or error message to
|
|
1162
|
+
* the user.
|
|
1163
|
+
*
|
|
1164
|
+
* @default false
|
|
1165
|
+
*/
|
|
1166
|
+
emitContentError: boolean;
|
|
1158
1167
|
/**
|
|
1159
1168
|
* Called before the editor is constructed.
|
|
1160
1169
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2716,18 +2716,10 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2716
2716
|
};
|
|
2717
2717
|
let content;
|
|
2718
2718
|
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) {
|
|
2719
|
+
const emitContentError = (error) => {
|
|
2728
2720
|
editor.emit("contentError", {
|
|
2729
2721
|
editor,
|
|
2730
|
-
error
|
|
2722
|
+
error,
|
|
2731
2723
|
disableCollaboration: () => {
|
|
2732
2724
|
if ("collaboration" in editor.storage && typeof editor.storage.collaboration === "object" && editor.storage.collaboration) {
|
|
2733
2725
|
;
|
|
@@ -2735,6 +2727,28 @@ var insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) =
|
|
|
2735
2727
|
}
|
|
2736
2728
|
}
|
|
2737
2729
|
});
|
|
2730
|
+
};
|
|
2731
|
+
const parseOptions = {
|
|
2732
|
+
preserveWhitespace: "full",
|
|
2733
|
+
...options.parseOptions
|
|
2734
|
+
};
|
|
2735
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
2736
|
+
try {
|
|
2737
|
+
createNodeFromContent(value, editor.schema, {
|
|
2738
|
+
parseOptions,
|
|
2739
|
+
errorOnInvalidContent: true
|
|
2740
|
+
});
|
|
2741
|
+
} catch (e) {
|
|
2742
|
+
emitContentError(e);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
try {
|
|
2746
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
2747
|
+
parseOptions,
|
|
2748
|
+
errorOnInvalidContent: (_a = options.errorOnInvalidContent) != null ? _a : editor.options.enableContentCheck
|
|
2749
|
+
});
|
|
2750
|
+
} catch (e) {
|
|
2751
|
+
emitContentError(e);
|
|
2738
2752
|
return false;
|
|
2739
2753
|
}
|
|
2740
2754
|
let { from, to } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
@@ -4269,6 +4283,7 @@ var Editor = class extends EventEmitter {
|
|
|
4269
4283
|
enablePasteRules: true,
|
|
4270
4284
|
enableCoreExtensions: true,
|
|
4271
4285
|
enableContentCheck: false,
|
|
4286
|
+
emitContentError: false,
|
|
4272
4287
|
onBeforeCreate: () => null,
|
|
4273
4288
|
onCreate: () => null,
|
|
4274
4289
|
onUpdate: () => null,
|
|
@@ -4434,7 +4449,8 @@ var Editor = class extends EventEmitter {
|
|
|
4434
4449
|
// Stub some commonly accessed properties to prevent errors
|
|
4435
4450
|
composing: false,
|
|
4436
4451
|
dragging: null,
|
|
4437
|
-
editable: true
|
|
4452
|
+
editable: true,
|
|
4453
|
+
isDestroyed: false
|
|
4438
4454
|
},
|
|
4439
4455
|
{
|
|
4440
4456
|
get: (obj, key) => {
|
|
@@ -4487,7 +4503,7 @@ var Editor = class extends EventEmitter {
|
|
|
4487
4503
|
let plugins = prevPlugins;
|
|
4488
4504
|
[].concat(nameOrPluginKeyToRemove).forEach((nameOrPluginKey) => {
|
|
4489
4505
|
const name = typeof nameOrPluginKey === "string" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;
|
|
4490
|
-
plugins =
|
|
4506
|
+
plugins = plugins.filter((plugin) => !plugin.key.startsWith(name));
|
|
4491
4507
|
});
|
|
4492
4508
|
if (prevPlugins.length === plugins.length) {
|
|
4493
4509
|
return void 0;
|
|
@@ -4748,8 +4764,8 @@ var Editor = class extends EventEmitter {
|
|
|
4748
4764
|
* Check if the editor is already destroyed.
|
|
4749
4765
|
*/
|
|
4750
4766
|
get isDestroyed() {
|
|
4751
|
-
var _a;
|
|
4752
|
-
return
|
|
4767
|
+
var _a, _b;
|
|
4768
|
+
return (_b = (_a = this.editorView) == null ? void 0 : _a.isDestroyed) != null ? _b : true;
|
|
4753
4769
|
}
|
|
4754
4770
|
$node(selector, attributes) {
|
|
4755
4771
|
var _a;
|