-
Notifications
You must be signed in to change notification settings - Fork 157
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 2: Prepare utility functions #2641
Merged
Merged
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
7cc5a1b
Readonly types (3rd try
JiuqingSong 3ff0779
Improve
JiuqingSong 950a4ae
fix build
JiuqingSong 2574fe2
Improve
JiuqingSong 0180d29
Merge branch 'master' into u/jisong/readonlytype0513
JiuqingSong 47b21f3
improve
JiuqingSong bd6b0cb
Improve
JiuqingSong cf3ea78
Add shallow mutable type
JiuqingSong e14e506
improve
JiuqingSong 9a2d449
Improve
JiuqingSong 719f5ed
improve
JiuqingSong caf7ef1
improve
JiuqingSong 29495db
Merge branch 'master' into u/jisong/readonlytype0513
JiuqingSong 0230a26
add test
JiuqingSong 46fbe45
Readonly types step 2
JiuqingSong 2afcf38
add test
JiuqingSong adb26a0
Improve
JiuqingSong e91e1a8
Merge branch 'master' into u/jisong/readonlytype0513
JiuqingSong 6dbd78b
improve
JiuqingSong d0ee665
Merge branch 'u/jisong/readonlytype0513' into u/jisong/readonlytypes_…
JiuqingSong f659ca9
Merge branch 'master' into u/jisong/readonlytypes_step_2
JiuqingSong acceb1d
improve
JiuqingSong a69738f
Merge branch 'master' into u/jisong/readonlytype0513
JiuqingSong b4ab134
improve
JiuqingSong dea9f7f
Merge branch 'u/jisong/readonlytype0513' into u/jisong/readonlytypes_…
JiuqingSong f745036
Merge branch 'master' into u/jisong/readonlytypes_step_2
JiuqingSong 806a1d3
Improve
JiuqingSong 7a6b43f
fix test
JiuqingSong 5e72761
improve
JiuqingSong e590215
Merge branch 'master' into u/jisong/readonlytypes_step_2
JiuqingSong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 8 additions & 2 deletions
10
demo/scripts/controlsV2/sidePane/contentModel/components/format/MetadataView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
packages/roosterjs-content-model-dom/lib/modelApi/common/addBlock.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import type { ContentModelBlock, ContentModelBlockGroup } from 'roosterjs-content-model-types'; | ||
import type { | ||
ContentModelBlock, | ||
ShallowMutableContentModelBlockGroup, | ||
} from 'roosterjs-content-model-types'; | ||
|
||
/** | ||
* Add a given block to block group | ||
* @param group The block group to add block into | ||
* @param block The block to add | ||
*/ | ||
export function addBlock(group: ContentModelBlockGroup, block: ContentModelBlock) { | ||
export function addBlock(group: ShallowMutableContentModelBlockGroup, block: ContentModelBlock) { | ||
group.blocks.push(block); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood the shallow type is something between the mutable and readonly, but I do not understand how to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, your understanding is right.
formatContentModel
, we pass the model to callback function as Readonly (later I will useShallowMutableContentModelDocument
instead, but for now you can treat it as readonly)mutateBlock
, it only clear cached element for this block itself (as well as cached Element for table rows if block is table, or list levels if block is list litem), but it will not clear cached element for child blocks (e.g. table cell under table row, or paragraph under table cell)mutateBlock
to child blocksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can read
mutateBlock.ts
(already checked in) for better understanding.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that means that for shallow type are mutable, but their children are readonly. In case we need the children to be mutable, we call mutateBlock. Is my understanding correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is right.