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

Update start of lists when pasting from Word Online #2340

Merged
merged 7 commits into from
Jan 19, 2024

Conversation

BryanValverdeU
Copy link
Contributor

When pasting multiple lists from Word Online to Rooster, if there are multiple numbering lists, the list start is not updated.
This PR adds functionality to update the start override of the level when needed. By checking the start attribute of the list.

This is because Word Online List content is most of the time provided like:

<ol start=1><li></li><ol>
<ol start=2><li></li><ol>

Since each of the list items are wrapped inside of ol/ul the list format is lost, because the default list processors remove the levels after processing each of the list element, so we need a custom behavior,

To do so, add:

  1. Add a new property to keep the list level cached, and use it when creating the new list levels.
  2. Add a list thread property to catch the previous list number. This will help to check if the start property should be set in the list being processed

Source:
image

Before After
image image

@@ -21,8 +23,16 @@ import type {
const LIST_ELEMENT_TAGS = ['UL', 'OL', 'LI'];
const LIST_ELEMENT_SELECTOR = LIST_ELEMENT_TAGS.join(',');

const COMMENT_BG_COLOR_REST = 'rgba(209, 209, 209, 0.5)';
const COMMENTS_TEXT_HIGHLIGHT_CLICKED = 'rgba(197, 139, 204, 0.5)';
interface WacContext extends DomToModelContext {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of extend DomToModelContext, can we extend its member listFormat (type DomToModelListFormat)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated to extend DomToModelListFormat instead in the latest iteration.

@BryanValverdeU BryanValverdeU merged commit 47a271d into master Jan 19, 2024
7 checks passed
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.

2 participants