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

Standalone editor: Refactor list format handler 2 #2137

Merged
merged 6 commits into from
Oct 16, 2023

Conversation

JiuqingSong
Copy link
Collaborator

Today list format handlers needs to decode/encode metadata when do DOM and Content Model conversion. This now happens in roosterjs-content-model-dom package. However we want to make this package only contains the core conversion code, but put the complex editing part to roosterjs-content-model-editor package. So I need to split out the metadata related code. Then the remaining code only read/write existing format styles but no need to do reformat (such as reapply list item number style)

This is the second step, including:

  1. Create a MetadataApplier type to help apply metadata. Here "apply" means we apply the settings in metadata to Content Model format, but not to DOM directly. Then we still need to call applyFormat to apply this format change into DOM tree.
  2. Refactor exiting list handler code, call applyMetadata to apply its value.
  3. Add listStyleType property in ListStyleFormat
  4. Add list metadata appliers, apply list styles into either OL/UL element or LI element, depends on the list style type value
  5. Remove listItemMetadataFormatHandler and listLevelMetadataFormatHandler since they are now replaced by the metadata appliers
  6. Add the new metadata appliers into Content Model editor core
  7. Fix test cases

After this change, if we just do DOM to model to DOM conversion without the metadata appliers (using roosterjs-content-model-dom package only), it will always respect the existing listStyleType if any, metadata will still be preserved but its value will be ignored. Then inside editor, metadata appliers are always added, so all format API will trigger list style type to be regenerated.

And we can now put all metadata appliers and its related definition code into roosterjs-content-model-editor package. For roosterjs-content-model-dom package, it will only contain common code such as applyMetadata function itself, and the metadata validation common code.

@JiuqingSong JiuqingSong marked this pull request as ready for review October 12, 2023 16:43
@JiuqingSong JiuqingSong merged commit 8be2f66 into master Oct 16, 2023
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/listrefactor2 branch October 16, 2023 16:52
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