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

Content Model code improvement 3: Refactor List #1936

Merged
merged 27 commits into from
Jul 21, 2023
Merged

Conversation

JiuqingSong
Copy link
Collaborator

@JiuqingSong JiuqingSong commented Jul 1, 2023

I'll have a bunch of PR to improve Content Model code, and do some clean up.

Currently a list item is represented like this:

{
  blockType: 'BlockGroup',
  blockGroupType: 'ListItem',
  format: { ... },
  blocks: [ ... ],
  levels: [{
     listType: 'OL',
     orderedStyleType: 1,
     ...
  }]
}

In the levels section, we mixed list type, list format and list metadata together. In this change. I split the list level into 3 parts:

  • list type
  • format
  • metadata
{
  lisType: 'OL',
  format: { ... },
  metadata: {
     editingInfo: '...'
  }
}

So that we can leverage existing parser and applier to operate on them.

Here is the motivation of this change. With earlier changes, we have split content model dom conversion code and format API/editor code. For most metadata API they are moved into roosterjs-content-model-editor package, only exception is list metadata API. It is still used when we parse and apply list format. But as a DOM conversion code, it should just do simple things -- read whatever list style and then write it back as it is. Other complex work like aggregate list item into list thread, or change list item style, they should be part of the format API code. In order to be able to move those code out, as a prestep we need to refactor the data structure of list item level first.

@JiuqingSong JiuqingSong changed the title Content Model code improvement 3-1: Refactor List Content Model code improvement 3: Refactor List Jul 20, 2023
@JiuqingSong JiuqingSong marked this pull request as ready for review July 20, 2023 22:08
@JiuqingSong JiuqingSong merged commit e0913b2 into master Jul 21, 2023
@JiuqingSong JiuqingSong deleted the u/jisong/improve3a branch July 21, 2023 16:50
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