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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
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.

1 participant