Skip to content

Content Model Shadow Edit Step 4: Finally support shadow edit with Content Model#1696

Merged
JiuqingSong merged 9 commits into
masterfrom
u/jisong/shadowedit4
Apr 4, 2023
Merged

Content Model Shadow Edit Step 4: Finally support shadow edit with Content Model#1696
JiuqingSong merged 9 commits into
masterfrom
u/jisong/shadowedit4

Conversation

@JiuqingSong

@JiuqingSong JiuqingSong commented Apr 3, 2023

Copy link
Copy Markdown
Collaborator

In order to support shadow edit with Content Model, we need to override the original core API switchShadowEdit and allow call other functions like create content model. So in this change I split some functions out of ContentModelEditor to be new core API:

  • createContentModel
  • createEditorContext
  • setContentModel
  • switchShadowEdit: This function will make sure there is a cached content model before entering shadow edit state, and use it to restore content after shadow edit is done. When format with content model during shadow edit, we will now clone a model from the cached one and do format change on it. If format using original API that is not based on Content Model, it will still use the cached fragment so that everything keeps no change.

Then we create a new function createContentModelEditorCore that will invoke original createEditorCore function and build editor core for ContentModelEditor, including appending these new core APIs, override shadow edit API when reuse model is allowed.

We also disable changing cached model during shadow edit to make sure the cached model is always the same one for the content before shadow edit.

Related test cases added.

@JiuqingSong

Copy link
Copy Markdown
Collaborator Author

#1691

@JiuqingSong
JiuqingSong marked this pull request as ready for review April 3, 2023 22:31
@JiuqingSong
JiuqingSong merged commit f204ecc into master Apr 4, 2023
@JiuqingSong
JiuqingSong deleted the u/jisong/shadowedit4 branch April 4, 2023 00:37
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