@tiptap/core 2.12.0 → 2.14.0
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/Editor.d.ts.map +1 -1
- package/dist/commands/insertContentAt.d.ts.map +1 -1
- package/dist/index.cjs +29 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -11
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +29 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Editor.ts +1 -0
- package/src/commands/insertContentAt.ts +29 -10
- package/src/types.ts +9 -0
package/dist/index.js
CHANGED
|
@@ -2069,25 +2069,42 @@ const insertContentAt = (position, value, options) => ({ tr, dispatch, editor })
|
|
|
2069
2069
|
...options,
|
|
2070
2070
|
};
|
|
2071
2071
|
let content;
|
|
2072
|
-
|
|
2073
|
-
content = createNodeFromContent(value, editor.schema, {
|
|
2074
|
-
parseOptions: {
|
|
2075
|
-
preserveWhitespace: 'full',
|
|
2076
|
-
...options.parseOptions,
|
|
2077
|
-
},
|
|
2078
|
-
errorOnInvalidContent: (_a = options.errorOnInvalidContent) !== null && _a !== void 0 ? _a : editor.options.enableContentCheck,
|
|
2079
|
-
});
|
|
2080
|
-
}
|
|
2081
|
-
catch (e) {
|
|
2072
|
+
const emitContentError = (error) => {
|
|
2082
2073
|
editor.emit('contentError', {
|
|
2083
2074
|
editor,
|
|
2084
|
-
error
|
|
2075
|
+
error,
|
|
2085
2076
|
disableCollaboration: () => {
|
|
2086
2077
|
if (editor.storage.collaboration) {
|
|
2087
2078
|
editor.storage.collaboration.isDisabled = true;
|
|
2088
2079
|
}
|
|
2089
2080
|
},
|
|
2090
2081
|
});
|
|
2082
|
+
};
|
|
2083
|
+
const parseOptions = {
|
|
2084
|
+
preserveWhitespace: 'full',
|
|
2085
|
+
...options.parseOptions,
|
|
2086
|
+
};
|
|
2087
|
+
// If `emitContentError` is enabled, we want to check the content for errors
|
|
2088
|
+
// but ignore them (do not remove the invalid content from the document)
|
|
2089
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
2090
|
+
try {
|
|
2091
|
+
createNodeFromContent(value, editor.schema, {
|
|
2092
|
+
parseOptions,
|
|
2093
|
+
errorOnInvalidContent: true,
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2096
|
+
catch (e) {
|
|
2097
|
+
emitContentError(e);
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
try {
|
|
2101
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
2102
|
+
parseOptions,
|
|
2103
|
+
errorOnInvalidContent: (_a = options.errorOnInvalidContent) !== null && _a !== void 0 ? _a : editor.options.enableContentCheck,
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
catch (e) {
|
|
2107
|
+
emitContentError(e);
|
|
2091
2108
|
return false;
|
|
2092
2109
|
}
|
|
2093
2110
|
let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to };
|
|
@@ -4394,6 +4411,7 @@ class Editor extends EventEmitter {
|
|
|
4394
4411
|
enablePasteRules: true,
|
|
4395
4412
|
enableCoreExtensions: true,
|
|
4396
4413
|
enableContentCheck: false,
|
|
4414
|
+
emitContentError: false,
|
|
4397
4415
|
onBeforeCreate: () => null,
|
|
4398
4416
|
onCreate: () => null,
|
|
4399
4417
|
onUpdate: () => null,
|