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 2: Decouple DomToModelContext and editor #1923

Merged
merged 13 commits into from
Jul 1, 2023

Conversation

JiuqingSong
Copy link
Collaborator

@JiuqingSong JiuqingSong commented Jun 29, 2023

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

The goal of this change is to decouple roosterjs-content-model-dom package from editor related logic, so that it can be used as a standalone library to do content transformation. To achieve this goal, I moved all editor related settings out to let editor pass in, includes:

  1. zoomScale
  2. root RTL
  3. selection

Then reorganize the parameter of createDomToModelContext and domToContentModel, now it can still work if nothing is passed in. In that case, content model will work with the following settings:

  • Light mode
  • Zoom scale = 1
  • Root direction is LTR
  • There is no selection in document

All these settings are suitable for the case of

  • Just read and rewrite content that is not inside an Editor
  • Process pasted content before insert them into editor

Then from roosterjs-content-model-editor package, it can gather all those information and pass it into Content Model.

Also to simplify the types, I removed customized selection types for Content Model, but just reuse SelectionRangeEx instead when do Dom to Model conversation.

@JiuqingSong JiuqingSong marked this pull request as ready for review June 30, 2023 03:08
@JiuqingSong JiuqingSong merged commit 55b2135 into master Jul 1, 2023
@JiuqingSong JiuqingSong deleted the u/jisong/improve2_0 branch July 1, 2023 05:16
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