-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Tab characters are stripped in useEditor content prop #5486
Comments
Can you share what specifically you are testing, because from my understanding setContent should preserve tabs now: tiptap/demos/src/Commands/InsertContent/React/index.spec.js Lines 45 to 50 in 81d3b8a
|
Thanks for your reply @nperez0111. It seems this is a discrepancy in how I just tested, and
Tested with |
Ah yea so this was the compromise for preserving backwards compatibility. So for setContent you need to set a flag on preserveWhitespace for the whitespace to be respected. Looking at the source code it will be obvious what you will need to change if you set preserveWhiteSpace to "full" you'll get the same behavior as insertContentAt https://github.com/ueberdosis/tiptap/blob/develop/packages/core/src/commands/setContent.ts |
Ah that makes sense - thank you. I wonder though about about initially setting the editor content in I could sort of try to patch that myself by just calling |
I think that you should be able to tiptap/packages/core/src/Editor.ts Line 298 in e31673d
So it should look like this: const editor = useEditor({
parseOptions:{
preserveWhitespace: 'full',
},
content: 'content' |
Thank you so much for the tip @nperez0111 and apologies for overlooking it in the docs. It works great. |
Affected Packages
core
Version(s)
2.5.9
Bug Description
Related to #4862 - I noticed I had one test marked as
skip
with a TODO to re-enable once #4862 was resolved. Unfortunately this test continues to fail assetContent
strips\t
characters out unexpectedly.\t
is being preserved inside codeblocks, but it should be preserved everywhereBrowser Used
Chrome
Code Example URL
No response
Expected Behavior
\t
is preservedAdditional Context (Optional)
These are also lost when setting the initial content of the editor.
Our old editor had
\t
support everywhere and this makes it impossible for us to move users to the new editor because their content would be irreversibly modified.Dependency Updates
The text was updated successfully, but these errors were encountered: