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

Support toggling of partial, nested, and intersecting tags #487

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

robinbisping
Copy link

@robinbisping robinbisping commented May 24, 2024

Relations:

A prototype attempting to tackle a range of formatting issues.

Key Ideas

Toggle

  • Check if there exists a node in the range that is not wrapped in the element -> Wrap
  • Otherwise -> Unwrap

Wrap

Iteratate through the DOM tree:

  • The element is encountered -> Skip subtree
  • A leaf node is reached
    • The leaf node is fully contained in the range: Wrap
    • The leaf node is partially contained in the range: Split and wrap

Normalize the DOM tree.

Unwrap

Iteratate through the DOM tree:

  • The element is encountered
    • The element is fully contained in the range: Unwrap
    • The element is partially contained in the range: Split and unwrap

Normalize the DOM tree.

Normalize

Normalize the DOM tree to avoid fragmentation:

  1. Sort the tree.
  2. Merge neighboring identical nodes.

Remaining Challenges and Tasks

  • Handle spell checking and comment nodes
    • Proposal: Normalize after spell checking and comment nodes have been removed
  • Decide on whitespace removal
    • Proposal: Drop support for whitespace removal
  • Preserve ranges without obstructing normalization
    • Proposal: Do not rely on restoreRange as it obstructs normalization
  • Sort tags by popularity not lexical order
  • Testing

@robinbisping robinbisping changed the title Support toggling of partial, nested, and intersecting tags (Prototype) Support toggling of partial, nested, and intersecting tags May 24, 2024
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.

1 participant