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

Allow skipping marking hasNewContent in formatContentModel #2933

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

JiuqingSong
Copy link
Collaborator

We have a parameter skipUndoSnapshot in formatContentModel context object to allow skipping adding undo snapshot. When it is set to true, formatContentModel will not add undo snapshot but it will mark hasNewContent to be true so next time undo is performed, we will first add an undo snapshot then undo.

But in some scenario we don't even want to mark hasNewContent as well, so in this PR I modified this parameter to let it allow 3 different values in addition to existing true | false value:

  • When set to 'DoNotSkip', it will add undo snapshot (default behavior)
  • When set to 'MarkNewContent', it will skip adding undo snapshot but mark "hasNewContent" so that next undo snapshot will be added
  • When set to 'SkipAll', it will skip adding undo snapshot and not mark "hasNewContent", as if no change is made

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/roosterjs-content-model-core/lib/coreApi/formatContentModel/formatContentModel.ts:51

  • [nitpick] The variable name 'minMaxImageSize' in the 'handleImages' function is ambiguous. It should be renamed to 'minImageSize'.
const shouldAddSnapshot = (!skipUndoSnapshot || skipUndoSnapshot == 'DoNotSkip') && !isNested;

*/
skipUndoSnapshot?: boolean;
skipUndoSnapshot?: boolean | 'DoNotSkip' | 'MarkNewContent' | 'SkipAll';
Copy link
Preview

Copilot AI Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment for the skipUndoSnapshot parameter is unclear. It should be clarified that true is equivalent to 'MarkNewContent'.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@JiuqingSong JiuqingSong merged commit 5f67c49 into master Jan 31, 2025
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/skipnewcontnet branch January 31, 2025 18:25
JiuqingSong added a commit that referenced this pull request Feb 7, 2025
* remove margins on Autoformat plugin

* fixes

* fix

* remove data-istrue

* use content change

* refactor

* Allow skipping marking hasNewContent in `formatContentModel` (#2933)

* Fix bridge plugin to be able to handle new event (#2935)

* Fix bridge plugin to be able to handle new event

* add test

* clean LegacySelectionPlugin

* Send anchor event in Auto Link (#2934)

After a text is automatically transformed into a link by typing and pressing space, send the anchor element when the ContentChanged event is triggered. Also add more unit tests.

* Respect font weight in TH element (#2939)

* Respect font weight in TH element

* add test

* improve

* fix build

* Fix resize table with width (#2940)

* Fix resize table with width

* fix test

* version bump

---------

Co-authored-by: Julia Roldi (from Dev Box) <juliaroldi@microsoft.com>
Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com>
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