@tiptap/core 3.0.0-beta.6 → 3.0.0-beta.8

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 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
- try {
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: e,
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,