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

🐛 Fixed kg-html-to-lexical creating unwanted text alignment and invalid nesting #1002

Merged
merged 11 commits into from
Oct 19, 2023

Conversation

kevinansfield
Copy link
Contributor

@kevinansfield kevinansfield commented Oct 17, 2023

refs TryGhost/Ghost#18448

  • extracted our aligment stripping, de-nesting, and list-merging transforms to a new kg-default-transforms package
    • generalised the de-nesting transform further to handle invalid nesting inside lists (allowed removal of image-specific denest transform)
    • updated koenig-lexical to use the new package in place of the extracted transform code
  • updated kg-html-to-lexical so it adds the transforms to the headless editor ensuring the output matches what we'd get if the same content was pasted directly into the editor

TODO:

  • add tests to kg-html-to-lexical to ensure input is modified as expected
  • add tests to kg-default-transforms

@kevinansfield kevinansfield force-pushed the kg-default-transforms branch 2 times, most recently from 13f9bdd to 3d503cf Compare October 18, 2023 13:32
9larsons added a commit that referenced this pull request Oct 18, 2023
closes TryGhost/Product#4035
- added support for images wrapped in an anchor tag
- previously only supported this if additionally wrapped in a figure
- note: requires the package created in #1002 to provide valid lexical strings
…alid nesting

refs TryGhost/Ghost#18448

- extracted our aligment stripping and denesting transforms to a new `kg-default-transforms` package
- updated `kg-html-to-lexical` so it adds the transforms to the headless editor ensuring the output matches what we'd get if the same content was pasted directly into the editor
- with module build type we ran into issues when imported into commonjs package builds
- with commonjs build type we need to explicitly import in koenig-lexical vite config
- extracted editor creation to test utils ready for re-use in individual transform tests
- transforms are not run when using `setEditorState()` so we need to register them after that as they _are_ run when registering
- we can't use `getEditorState()` immediately after registering transforms because they are still being run async, we can get around that by running an empty discrete update first
@kevinansfield kevinansfield marked this pull request as ready for review October 19, 2023 17:20
@kevinansfield kevinansfield merged commit 4932a52 into TryGhost:main Oct 19, 2023
2 checks passed
@kevinansfield kevinansfield deleted the kg-default-transforms branch October 19, 2023 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant