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 Cache improvement - Step 8: Finally enable readonly types in all format API #2651

Merged
merged 87 commits into from
Jun 3, 2024

Conversation

JiuqingSong
Copy link
Contributor

@JiuqingSong JiuqingSong commented May 20, 2024

Now all format API are using readonly types, we can finally enable the readonly type from root level.
This includes:

  1. In formatContentModel, we provide a ShallowMutableContentModelDocument to callback instead of original ContentModelDocument. Then if we need to do any modification to blocks under this model object, we need to use mutateBlock to convert it to a mutable block. This is a breaking change. Ideally after this change we should bump the major version. However, given that we just bump to version 9 recently, I'll prefer keep current major version and later we can provide a document on how to fix the build failures when integrate the new version.
  2. Provide a new editor option experimentalFeatures to allow pass in feature names.
  3. Provide a new feature name PersistCache. When this feature name is passed into EditorOptions.experimentalFeatures, we will keep cached element in content model as long as we can
  4. In iterateSelection, do not delete cached element for selected blocks when PersistCache is enabled
  5. In domIndexer, do not delete cached element for current block when PersistCache is enabled. I also need to convert it to a class so that it can hold private members
  6. In demo site, add the UI to allow turn on/off experimental features.

In order to let iterateSelections know if PersistCache is enabled, I did a workaround here to store this information in Content Model as a private member. So that we don't need to change the caller code everywhere. Once this feature is fully graduated, we can remove this private member.

@JiuqingSong JiuqingSong merged commit db8e2da into master Jun 3, 2024
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/readonlytypes_step_8 branch June 3, 2024 18: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