Skip to content
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

Parse white space according to the HTML spec #2729

Merged
merged 15 commits into from
Nov 8, 2023
Merged

Conversation

12joan
Copy link
Collaborator

@12joan 12joan commented Nov 6, 2023

Description

Fixes #2713

Copy link

changeset-bot bot commented Nov 6, 2023

🦋 Changeset detected

Latest commit: 1a8762e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 50 packages
Name Type
@udecode/plate-core Patch
@udecode/plate-serializer-docx Patch
@udecode/plate-common Patch
@udecode/plate-utils Patch
@udecode/plate Patch
@udecode/plate-alignment Patch
@udecode/plate-autoformat Patch
@udecode/plate-basic-elements Patch
@udecode/plate-basic-marks Patch
@udecode/plate-block-quote Patch
@udecode/plate-break Patch
@udecode/plate-caption Patch
@udecode/plate-cloud Patch
@udecode/plate-code-block Patch
@udecode/plate-combobox Patch
@udecode/plate-comments Patch
@udecode/plate-cursor Patch
@udecode/plate-dnd Patch
@udecode/plate-emoji Patch
@udecode/plate-excalidraw Patch
@udecode/plate-find-replace Patch
@udecode/plate-floating Patch
@udecode/plate-font Patch
@udecode/plate-heading Patch
@udecode/plate-highlight Patch
@udecode/plate-horizontal-rule Patch
@udecode/plate-indent-list Patch
@udecode/plate-indent Patch
@udecode/plate-juice Patch
@udecode/plate-kbd Patch
@udecode/plate-line-height Patch
@udecode/plate-link Patch
@udecode/plate-list Patch
@udecode/plate-media Patch
@udecode/plate-mention Patch
@udecode/plate-node-id Patch
@udecode/plate-normalizers Patch
@udecode/plate-paragraph Patch
@udecode/plate-reset-node Patch
@udecode/plate-resizable Patch
@udecode/plate-select Patch
@udecode/plate-selection Patch
@udecode/plate-serializer-csv Patch
@udecode/plate-serializer-html Patch
@udecode/plate-serializer-md Patch
@udecode/plate-suggestion Patch
@udecode/plate-tabbable Patch
@udecode/plate-table Patch
@udecode/plate-trailing-block Patch
@udecode/plate-yjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Nov 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plate ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2023 9:58am

@reviewpad reviewpad bot added the large Pull request is large label Nov 6, 2023
@12joan 12joan marked this pull request as ready for review November 6, 2023 21:38
@12joan 12joan requested a review from zbeyens November 6, 2023 21:46
@12joan 12joan changed the title Parse whitespace according to the HTML spec Parse white space according to the HTML spec Nov 6, 2023
@jkcs
Copy link

jkcs commented Nov 8, 2023

<div>
  normal:
  <div style='white-space: normal'>hello one two
    three
    four
  </div>
  <br/>
  nowrap:
  <div style='white-space: nowrap'>hello one two
    three
    four
  </div>
  <br/>
</div>

When I paste this HTML, there is no line break between 'normal:' and the following element. Is this the expected behavior?

  • Browser:
    image
  • Plate:
    image

@12joan
Copy link
Collaborator Author

12joan commented Nov 8, 2023

@jkcs Nicely spotted! Technically, this isn't a fault in the white space parsing, but due to the fact that Plate's HTML deserializer ignores block elements that it doesn't understand (in this case, the <div>).

Still, it might be worth addressing in a separate PR. The rule might be something like: If you encounter a block HTML element that doesn't map to a Slate node at the end of an inline formatting context, insert a newline at the end of the preceeding inline formatting context. Since this logic depends on the plugin system, it would need to be placed somewhere in the old deserializeHtml tree of recursive functions, rather than in collapseWhiteSpace.

Copy link
Member

@zbeyens zbeyens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified the changeset to patch, next step is to modify v25 changelog to include this major change.

@12joan
Copy link
Collaborator Author

12joan commented Nov 8, 2023

@zbeyens Assuming that needs to happen after merge and the release of 25.0.1, I think we're ready to merge this.

@zbeyens zbeyens merged commit 282f86a into main Nov 8, 2023
6 checks passed
@zbeyens zbeyens deleted the fix/html-whitespace-parsing branch November 8, 2023 10:13
@zbeyens zbeyens mentioned this pull request Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
large Pull request is large
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace in pasted HTML is not handled according to the HTML spec
3 participants