ueberdosis / tiptap

The headless rich text editor framework for web artisans.
https://tiptap.dev
MIT License
26.85k stars 2.24k forks source link

[Bug]: EnableContentCheck is invalid(Check whether this node and its descendants conform to the schema, and raise an exception when they do not.) #5682

Closed jinbiaode closed 2 hours ago

jinbiaode commented 3 hours ago

Affected Packages

@tiptap/core

Version(s)

2.7.4

Bug Description

When I was using @ tiptap/core 2.7.4 and set enableContentCheck: false on the new Editor, I still found that I was checking the content. Source code{ key: "checkContent", value: function checkContent(content) { if (! this.validContent(content)) throw new RangeError("Invalid content for node ".concat(this.name, ": ").concat(content.toString().slice(0, 50))); }

I need to perform an empty label check on this content, but I don't need this check() Check whether this node and its descendants conform to the schema, and raise an exception when they do not.

Because my content is HTML content and there are empty tags in the tags, I am unable to add content. How can I close this check? EnableContentCheck is not valid for this.

<section style="margin: 10px; text-align: center;"><section style="display:inline-block;"><section style="margin-top:-10px;width: 100%;padding-top: 10px;padding-bottom: 10px;box-sizing: border-box;"><section style="display: flex;justify-content: flex-start;"><section style="width:1em;height: 1em;border-top: 1px solid #749191;border-left: 1px solid #749191;box-sizing: border-box;"></section></section><section style="margin-top:-10px;margin-left:-5px;width: 1em;height: 1em;border-top: 1px solid #749191;border-left: 1px solid #749191;box-sizing: border-box;"></section><section style="margin: -0.8em 1em -0.8em 1em;"><section style="font-size: 14px;letter-spacing: 1.5px;line-height: 1.75em;color: #3f3e3f;"><p><span style="font-size: 17px; color: #2b7a7c;">清明时节雨纷纷</span></p></section></section><section style="float:right;"><section style="margin-left:-0.2em;width: 1em;height: 1em;border-bottom: 1px solid #749191;border-right:1px solid #749191;box-sizing: border-box;"></section><section style="margin-top:-10px;width: 1em;height: 1em;border-bottom:1px solid #749191;border-right:1px solid #749191;box-sizing: border-box;"></section></section></section></section></section>

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

I hope enableContentCheck can be applied to check() Check whether this node and its descent conform to the schema, and raise an exception when they do not. Skip ignore

Additional Context (Optional)

No response

Dependency Updates

nperez0111 commented 3 hours ago

I'm sorry, but this is not clear.

checkContent does not appear anywhere in this repo, so I don't even know where you are getting that from.

Inserting arbitrary HTML is not supported, Tiptap will only preserve content that is actually valid to your schema, there is not a way to make it support adding arbitrary HTML content, so injecting HTML can be lossy.

Are you saying that content checking is happening when it should not be?

Or are you saying that you want to check the content?

Can you provide links to the source code in this repo that you think are wrong?

jinbiaode commented 3 hours ago

I don't need this check, because what I'm inserting contains the content of the html, the content of the top code block. When I set the content, I found that some errors were reported. The source code was traced to this check (). Is there any way to turn off this check? I tried, but it didn't work.

发自我的iPhone

------------------ Original ------------------ From: Nick Perez @.> Date: Mon,Sep 30,2024 5:19 PM To: ueberdosis/tiptap @.> Cc: Jin Biao @.>, Author @.> Subject: Re: [ueberdosis/tiptap] [Bug]: EnableContentCheck is invalid(Check whether this node and its descendants conform to the schema, and raise an exception when they do not.) (Issue #5682)

nperez0111 commented 2 hours ago

contentCheck throws a Tiptap error, the code you traced it down to is Prosemirror source code for checking whether content is valid. This is necessary, there is not a way to disable it. Prosemirror needs control of the schema to allow editing it. If you still have issues then you can go to the Prosemirror repo, not here.