-
Notifications
You must be signed in to change notification settings - Fork 183
New getContentForCopy API #3182
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
Conversation
| tempDiv: HTMLDivElement | ||
| ): Range | null { | ||
| pruneUnselectedModel(pasteModel); | ||
| const doc = editor.getDocument(); |
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.
since you only need document from editor, pass in document instead
| pruneUnselectedModel(pasteModel); | ||
| const doc = editor.getDocument(); | ||
|
|
||
| if (selection.type === 'table') { |
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.
you only need selection type here, so no need to pass in the whole selection object.
And actually, can we get selection type from model? As a public api, we need to make sure all combination of parameters are valid. If user passes in a selection that does not match the selection in the model, what will happen? So better get selection from model instead.
| * @param tempDiv A temporary DIV element used for cut/copy content | ||
| * @returns | ||
| */ | ||
| export function createCopyRange( |
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.
And as a public API, better put it under a public place, but not corePlugin. You can put it under command folder
| editor: IEditor, | ||
| pasteModel: ContentModelDocument, | ||
| selection: DOMSelection, | ||
| tempDiv: HTMLDivElement |
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.
Better also hide the code of creating tempDiv into this function, so caller does not need to know how to pass it in.
We need to make sure each parameter of a public API is easy to understand
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.
BTW,where is the code to trigger beforeCutCopy event? Do you want to trigger it manually from your code?
|
Actually, with the new customCutCopy feature graduated, I don't think we still need a temp DIV inserted in DOM tree. It was used for let browser handle the copy event, now we set clipboard by our code, we just need to create a DIV in order to get innerHTML, but no need to really put it into DOM tree. It can be something like: const div = doc.createElement('div');
contentModelToDom(...);
...
const html = div.innerHTML;
// no need to clean up at allAnd, I feel we don't need to |
|
As a public API, it is ok to only take editor as parameter, no need to know other things, because you can get everything from editor. Then it only needs to return HTML and plain text, then let the caller decide how to use it. For example, in the plugin it will put them into clipboard, and in your scenario you will save them as quick part. |
…om/microsoft/roosterjs into u/juliaroldi/create-copy-selection
|
|
||
| cleanUpAndRestoreSelection(tempDiv); | ||
| this.editor.setDOMSelection(selection); | ||
| this.editor.focus(); |
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.
@JiuqingSong can we remove this?
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 guess we can. Please test.
|
Please make sure that Copy and Cut buttons in OWA Ribbon and Context menu keep working with this change. |
| /** | ||
| * The model adjusted by beforeCutCopy event | ||
| */ | ||
| pasteModel?: ContentModelDocument; |
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.
Is this necessary?
I was thinking of adding this in event. But I finally didn't. This is because in the event we already have clonedRoot which contains the DOM elements, and plugin can modify it to change the content to copy. However, when add a model here, plugin developer can be confused that which one I should modify, and why modifying a model won't work.
If we just want to provide a model for plugin to know what is being cut/copy, please add comment that this is not expected to be modified, and change its type to be ReadonlyContentModelDocument.
| const pasteModel = this.editor.getContentModelCopy('disconnected'); | ||
|
|
||
| pruneUnselectedModel(pasteModel); | ||
| const beforeCutCopyEvent = triggerBeforeCutCopyEvent( |
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 prefer to let this function return html and plain text only, but no the event object. Since you actually only need them
| } else if (range) { | ||
| const doc = this.editor.getDocument(); | ||
| addRangeToSelection(doc, range); |
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.
we now do not change focus, so no need to set selection back. If event is not clipboard event (actually t his should never happen), just do nothing
| adjustSelectionForCopyCut(pasteModel); | ||
| if (isClipboardEvent(event)) { | ||
| event.preventDefault(); | ||
| const text = pasteModel ? contentModelToText(pasteModel) : ''; |
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.
this can be done inside the your new function, and return the text only
packages/roosterjs-content-model-core/lib/command/cutCopy/preprocessTable.ts
Show resolved
Hide resolved
| /** | ||
| * @internal | ||
| */ | ||
| export function adjustSelectionForCopyCut(pasteModel: ContentModelDocument) { |
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.
same here
| export function triggerBeforeCutCopyEvent( | ||
| editor: IEditor, | ||
| isCut: boolean = false, | ||
| event?: ClipboardEvent |
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 rethink about this, I feel we should make this event parameter required. So the code to create this object should be outside of this function.
| */ | ||
| export function triggerBeforeCutCopyEvent( | ||
| editor: IEditor, | ||
| isCut: boolean = false, |
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.
Make it required as well
| * @param event an optional parameter for when the clipboard event needs to be trigger | ||
| * @returns | ||
| */ | ||
| export function triggerBeforeCutCopyEvent( |
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.
Since this function is mainly used for getting the copy/cut content, triggering event is just a step of it, let name it getContentForCopy.
Since cutting the content is not done in this function, so no need to mention "Cut" in the function name.
| /** | ||
| * The html and text content for the copy action | ||
| */ | ||
| export interface CopyContent { |
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.
- Move this type to
roosterjs-content-model-typespackage - Have a better name. For example, ContentForCopy, or TextAndHtmlContent. The name should be like a noun, but not a verb
- Add comment to each member
| const pasteModel = this.editor.getContentModelCopy('disconnected'); | ||
|
|
||
| pruneUnselectedModel(pasteModel); | ||
| const beforeCutCopyEvent = getContentForCopy(this.editor, isCut, event as ClipboardEvent); |
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.
Now it does not return an event, so rename this variable
| }); | ||
| } else if (selection.type === 'range') { | ||
| adjustSelectionForCopyCut(pasteModel); | ||
| if (isClipboardEvent(event)) { |
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.
We are already using event as a ClipboardEvent, so let's move this check before line 93, to make it safer.
Then no type cast is needed at line 93
| /** | ||
| * The model adjusted by beforeCutCopy event | ||
| */ | ||
| pasteModel?: ContentModelDocument; |
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 don't think you still need this
* support RTL (#3177) * Update ContextMenuProvider to accept event parameter and adjust related tests (#3175) * refactor: remove deprecated features and clean up related code in CachePlugin and CopyPastePlugin (#3178) * Add `test:fast` for faster unit test runs (#3179) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * refactor: update test commands to use fast karma configuration * Add support for retaining formats when splitting paragraphs on Enter/Delete/Backspace keypress (#3180) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * Add support for retaining formats when splitting paragraphs on Enter key press - Introduced `formatsToKeep` option in `EditOptions` to specify which formats to retain. - Updated `keyboardEnter`, `handleEnterOnParagraph`, and `splitParagraph` functions to handle the new formats. - Enhanced tests to verify the correct behavior of format retention during paragraph splits. * Remove unused import for handleEnterOnParagraph in keyboardEnterTest * Remove stray backtick from splitParagraph function * refactor: update test commands to use fast karma configuration * feat: implement class format handling and preserve formatting on paragraph split * feat: rename formatsToKeep to formatsToPreserveOnMerge and update related functionality * test: update spies in keyboardDelete tests and fix format property in preserveParagraphFormat tests * Support rowSpan equal to 0 (#3181) * fix: handle zero colSpan and rowSpan in tableProcessor to ensure proper cell creation * fix: correct colSpan condition in tableProcessor for accurate cell processing * feat: add spanUntilNextSection support in table cell processing and handling * refactor: remove spanUntilNextSection from table cell handling and related tests * refactor: simplify rowSpan handling and improve tableProcessor tests for edge cases * Remove unneeded changes * Remove * fix: update source map configuration for improved debugging accuracy (#3186) * Support passing event to getContextMenuItems when plugin is a MixedPlugin (#3188) * feat: enhance context menu handling to support V9 providers with event parameter * fix: enhance isV9ContextMenuProvider to check for mixed plugins * refactor: simplify spyOn usage for DarkColorHandler in BridgePlugin tests * fix: enhance isV9ContextMenuProvider to validate V9 provider signature * fix: update context menu provider check to use isMixedPluginProvider * New getContentForCopy API (#3182) New getContentForCopy API * feat: add announce options for bold, italic, and underline formatting (#3194) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Add Find and Replace API and plugin (#3190) * Add Find and Replace API and plugin * Fix a comment * improve * feat: add announcements for table selection and unselection in the editor (#3195) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * feat: add announcements for text selection and unselection in the editor * refactor: simplify table selection logic by using TableSelection type in getIsSelectingOrUnselecting function * Update packages/roosterjs-content-model-core/lib/corePlugin/selection/tableSelectionUtils.ts Co-authored-by: Copilot <[email protected]> * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Move functionality to a new plugin * Fix * Fix * Fix comment --------- Co-authored-by: Copilot <[email protected]> * Fix #396891 (#3199) * Fix #396891 * improve * improve * first colunm (#3202) * Fix 400434 (#3200) * Add format when insert table (#3203) Add the format parameter in the insertTable API, then it will be possible to insert a table with a predefined format. It can be used to add margin bottom to the table, then when a table is inserted under another their border does not overlay. * Move graduated feature to a separate type (#3205) * Move graduated feature to a separate type * improve * fix build * Translate lineHeight normal to 120% when pasting from Word Desktop and move parsers to their own file (#3209) * Translate lineHeight normal to 120% and move parsers to their own file * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix text to bullet issue (#3210) * Fix text to bullet issue * fix test * Update version * Update version on react pkgs --------- Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> Co-authored-by: Copilot <[email protected]>
* support RTL (#3177) * Update ContextMenuProvider to accept event parameter and adjust related tests (#3175) * refactor: remove deprecated features and clean up related code in CachePlugin and CopyPastePlugin (#3178) * Add `test:fast` for faster unit test runs (#3179) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * refactor: update test commands to use fast karma configuration * Add support for retaining formats when splitting paragraphs on Enter/Delete/Backspace keypress (#3180) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * Add support for retaining formats when splitting paragraphs on Enter key press - Introduced `formatsToKeep` option in `EditOptions` to specify which formats to retain. - Updated `keyboardEnter`, `handleEnterOnParagraph`, and `splitParagraph` functions to handle the new formats. - Enhanced tests to verify the correct behavior of format retention during paragraph splits. * Remove unused import for handleEnterOnParagraph in keyboardEnterTest * Remove stray backtick from splitParagraph function * refactor: update test commands to use fast karma configuration * feat: implement class format handling and preserve formatting on paragraph split * feat: rename formatsToKeep to formatsToPreserveOnMerge and update related functionality * test: update spies in keyboardDelete tests and fix format property in preserveParagraphFormat tests * Support rowSpan equal to 0 (#3181) * fix: handle zero colSpan and rowSpan in tableProcessor to ensure proper cell creation * fix: correct colSpan condition in tableProcessor for accurate cell processing * feat: add spanUntilNextSection support in table cell processing and handling * refactor: remove spanUntilNextSection from table cell handling and related tests * refactor: simplify rowSpan handling and improve tableProcessor tests for edge cases * Remove unneeded changes * Remove * fix: update source map configuration for improved debugging accuracy (#3186) * Support passing event to getContextMenuItems when plugin is a MixedPlugin (#3188) * feat: enhance context menu handling to support V9 providers with event parameter * fix: enhance isV9ContextMenuProvider to check for mixed plugins * refactor: simplify spyOn usage for DarkColorHandler in BridgePlugin tests * fix: enhance isV9ContextMenuProvider to validate V9 provider signature * fix: update context menu provider check to use isMixedPluginProvider * New getContentForCopy API (#3182) New getContentForCopy API * feat: add announce options for bold, italic, and underline formatting (#3194) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Add Find and Replace API and plugin (#3190) * Add Find and Replace API and plugin * Fix a comment * improve * feat: add announcements for table selection and unselection in the editor (#3195) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * feat: add announcements for text selection and unselection in the editor * refactor: simplify table selection logic by using TableSelection type in getIsSelectingOrUnselecting function * Update packages/roosterjs-content-model-core/lib/corePlugin/selection/tableSelectionUtils.ts Co-authored-by: Copilot <[email protected]> * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Move functionality to a new plugin * Fix * Fix * Fix comment --------- Co-authored-by: Copilot <[email protected]> * Fix #396891 (#3199) * Fix #396891 * improve * improve * first colunm (#3202) * Fix 400434 (#3200) * Add format when insert table (#3203) Add the format parameter in the insertTable API, then it will be possible to insert a table with a predefined format. It can be used to add margin bottom to the table, then when a table is inserted under another their border does not overlay. * Move graduated feature to a separate type (#3205) * Move graduated feature to a separate type * improve * fix build * Translate lineHeight normal to 120% when pasting from Word Desktop and move parsers to their own file (#3209) * Translate lineHeight normal to 120% and move parsers to their own file * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix text to bullet issue (#3210) * Fix text to bullet issue * fix test * Refactor paste source validation to use getDocumentSource (#3208) * Refactor paste source validation to use getDocumentSource - Updated shouldConvertToSingleImage to utilize htmlFirstLevelChildTags instead of clipboardData. - Replaced instances of getPasteSource with getDocumentSource across various tests and implementations. - Introduced getDocumentSource function to centralize document source determination logic. - Added retrieveDocumentMetadata utility to extract metadata from documents. - Ensured all related tests are updated to reflect changes in function calls and parameters. * Refactor paste handling and add tests for negative text indent parser * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix #3171 #3184 (#3211) * Fix #3171 #3184 * Update packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Use getPromoteLink to verify if a link can be promoted (#3213) Add getPromoteLink function to verify if a link can be promoted. * [fix] Keep format on the selection marker when reconcile Text (#3220) * [fix] Keep format on the selection marker when reconcile Text * update ut * update test * [Image Edit] Fix 394371 (#3219) Check if the selectedImage property exists when the content changed event is triggered, * Update the Entity's format when applying format on the content inside the Entity (#3196) * Update the Entity's format when applying format on the content inside the Entity * fix test * Fix Align Attribute being removed on paste for containers (#3217) * Add wordContainerParser to handle negative margin-left values and update processPastedContentFromWordDesktop to use it * asd * Refactor wordContainerParser to remove unused parameters * remove * update * Support cache for list (#3204) * Support cache for list * fix build * improve * add tests * add test * add test * Update packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleBlockGroupChildren.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Try generate url data (#3222) wrap the draw image function in a try statement, if successful the image will be drawn in the canvas, if not return the data URL of the previous image --------- Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Haowen Chen <[email protected]>
* support RTL (#3177) * Update ContextMenuProvider to accept event parameter and adjust related tests (#3175) * refactor: remove deprecated features and clean up related code in CachePlugin and CopyPastePlugin (#3178) * Add `test:fast` for faster unit test runs (#3179) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * refactor: update test commands to use fast karma configuration * Add support for retaining formats when splitting paragraphs on Enter/Delete/Backspace keypress (#3180) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * Add support for retaining formats when splitting paragraphs on Enter key press - Introduced `formatsToKeep` option in `EditOptions` to specify which formats to retain. - Updated `keyboardEnter`, `handleEnterOnParagraph`, and `splitParagraph` functions to handle the new formats. - Enhanced tests to verify the correct behavior of format retention during paragraph splits. * Remove unused import for handleEnterOnParagraph in keyboardEnterTest * Remove stray backtick from splitParagraph function * refactor: update test commands to use fast karma configuration * feat: implement class format handling and preserve formatting on paragraph split * feat: rename formatsToKeep to formatsToPreserveOnMerge and update related functionality * test: update spies in keyboardDelete tests and fix format property in preserveParagraphFormat tests * Support rowSpan equal to 0 (#3181) * fix: handle zero colSpan and rowSpan in tableProcessor to ensure proper cell creation * fix: correct colSpan condition in tableProcessor for accurate cell processing * feat: add spanUntilNextSection support in table cell processing and handling * refactor: remove spanUntilNextSection from table cell handling and related tests * refactor: simplify rowSpan handling and improve tableProcessor tests for edge cases * Remove unneeded changes * Remove * fix: update source map configuration for improved debugging accuracy (#3186) * Support passing event to getContextMenuItems when plugin is a MixedPlugin (#3188) * feat: enhance context menu handling to support V9 providers with event parameter * fix: enhance isV9ContextMenuProvider to check for mixed plugins * refactor: simplify spyOn usage for DarkColorHandler in BridgePlugin tests * fix: enhance isV9ContextMenuProvider to validate V9 provider signature * fix: update context menu provider check to use isMixedPluginProvider * New getContentForCopy API (#3182) New getContentForCopy API * feat: add announce options for bold, italic, and underline formatting (#3194) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Add Find and Replace API and plugin (#3190) * Add Find and Replace API and plugin * Fix a comment * improve * feat: add announcements for table selection and unselection in the editor (#3195) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * feat: add announcements for text selection and unselection in the editor * refactor: simplify table selection logic by using TableSelection type in getIsSelectingOrUnselecting function * Update packages/roosterjs-content-model-core/lib/corePlugin/selection/tableSelectionUtils.ts Co-authored-by: Copilot <[email protected]> * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Move functionality to a new plugin * Fix * Fix * Fix comment --------- Co-authored-by: Copilot <[email protected]> * Fix #396891 (#3199) * Fix #396891 * improve * improve * first colunm (#3202) * Fix 400434 (#3200) * Add format when insert table (#3203) Add the format parameter in the insertTable API, then it will be possible to insert a table with a predefined format. It can be used to add margin bottom to the table, then when a table is inserted under another their border does not overlay. * Move graduated feature to a separate type (#3205) * Move graduated feature to a separate type * improve * fix build * Translate lineHeight normal to 120% when pasting from Word Desktop and move parsers to their own file (#3209) * Translate lineHeight normal to 120% and move parsers to their own file * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix text to bullet issue (#3210) * Fix text to bullet issue * fix test * Refactor paste source validation to use getDocumentSource (#3208) * Refactor paste source validation to use getDocumentSource - Updated shouldConvertToSingleImage to utilize htmlFirstLevelChildTags instead of clipboardData. - Replaced instances of getPasteSource with getDocumentSource across various tests and implementations. - Introduced getDocumentSource function to centralize document source determination logic. - Added retrieveDocumentMetadata utility to extract metadata from documents. - Ensured all related tests are updated to reflect changes in function calls and parameters. * Refactor paste handling and add tests for negative text indent parser * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix #3171 #3184 (#3211) * Fix #3171 #3184 * Update packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Use getPromoteLink to verify if a link can be promoted (#3213) Add getPromoteLink function to verify if a link can be promoted. * [fix] Keep format on the selection marker when reconcile Text (#3220) * [fix] Keep format on the selection marker when reconcile Text * update ut * update test * [Image Edit] Fix 394371 (#3219) Check if the selectedImage property exists when the content changed event is triggered, * Update the Entity's format when applying format on the content inside the Entity (#3196) * Update the Entity's format when applying format on the content inside the Entity * fix test * Fix Align Attribute being removed on paste for containers (#3217) * Add wordContainerParser to handle negative margin-left values and update processPastedContentFromWordDesktop to use it * asd * Refactor wordContainerParser to remove unused parameters * remove * update * Support cache for list (#3204) * Support cache for list * fix build * improve * add tests * add test * add test * Update packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleBlockGroupChildren.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Try generate url data (#3222) wrap the draw image function in a try statement, if successful the image will be drawn in the canvas, if not return the data URL of the previous image * Support Trusted publishing for npmjs (#3227) * Support Trusted publishing for npmjs * improve * improve * Fix 230556 (#3223) * Fix 230556 * improve * fix build and improve * Fix: make the isSafari env include both iOS and macOS (#3215) Co-authored-by: Liang Meng <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> * Revert "Fix: make the isSafari env include both iOS and macOS (#3215)" (#3229) This reverts commit a5b653f. * Fix table selection logic to handle reversed coordinates and add corresponding tests (#3228) * Update "isSafari" detection to work across Apple platforms (#3232) * Update Safari detection logic in createEditorCore * Update isSafari detection in corresponding tests * Fix #2841 (#3230) * Fix #2841 * fix build * fix build * fix comment * Fix 298633 (#3233) * Fix #3231 (#3234) * Fix #3231 * fix comment * fix comments * Table Row/Column Selector (#3221) Add to new Table Editor features, TableRowSelector and TableColumnSelector to select table rows or columns. * Support color transformation in table borders (#3216) Introduce a new TransformTableBorderColor that enable border color transformation when the editor switch from light to dark mode. * Fix ordinal superscript for numbers ending in 0 (20th, 30th, etc.) (#3241) - Changed falsy check to explicit !== null for numericValue - Fixes issue where 0 was treated as falsy, preventing superscript - Affects both separate segments (linked numbers) and combined (20th) formats - Added unit tests for 20th, 30th, and 40th to prevent regression * Disable using global window and document (#3240) * Add minWidth cell to insertTable (#3239) Add a new parameter, customCellFormat, to the insertTable function to allow custom styles for tables. * Export formatContainerProcessor for public API use (#3238) Export formatContainerProcessor from roosterjs-content-model-dom public API to enable users to use it in processorOverride for custom DOM-to-Model processing. This allows customization of format container elements (e.g., blockquote) processing without relying on internal module paths. Co-authored-by: Jiuqing Song <[email protected]> * version 9.45 * bump react version --------- Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Haowen Chen <[email protected]> Co-authored-by: Liang <[email protected]> Co-authored-by: Liang Meng <[email protected]> Co-authored-by: gabesl <[email protected]> Co-authored-by: Dennis Chen <[email protected]>
* support RTL (#3177) * Update ContextMenuProvider to accept event parameter and adjust related tests (#3175) * refactor: remove deprecated features and clean up related code in CachePlugin and CopyPastePlugin (#3178) * Add `test:fast` for faster unit test runs (#3179) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * refactor: update test commands to use fast karma configuration * Add support for retaining formats when splitting paragraphs on Enter/Delete/Backspace keypress (#3180) * refactor: optimize karma configuration for improved performance * feat: add fast karma configuration and update package.json for debugging * refactor: streamline karma plugin declaration and update test scripts for clarity * Add support for retaining formats when splitting paragraphs on Enter key press - Introduced `formatsToKeep` option in `EditOptions` to specify which formats to retain. - Updated `keyboardEnter`, `handleEnterOnParagraph`, and `splitParagraph` functions to handle the new formats. - Enhanced tests to verify the correct behavior of format retention during paragraph splits. * Remove unused import for handleEnterOnParagraph in keyboardEnterTest * Remove stray backtick from splitParagraph function * refactor: update test commands to use fast karma configuration * feat: implement class format handling and preserve formatting on paragraph split * feat: rename formatsToKeep to formatsToPreserveOnMerge and update related functionality * test: update spies in keyboardDelete tests and fix format property in preserveParagraphFormat tests * Support rowSpan equal to 0 (#3181) * fix: handle zero colSpan and rowSpan in tableProcessor to ensure proper cell creation * fix: correct colSpan condition in tableProcessor for accurate cell processing * feat: add spanUntilNextSection support in table cell processing and handling * refactor: remove spanUntilNextSection from table cell handling and related tests * refactor: simplify rowSpan handling and improve tableProcessor tests for edge cases * Remove unneeded changes * Remove * fix: update source map configuration for improved debugging accuracy (#3186) * Support passing event to getContextMenuItems when plugin is a MixedPlugin (#3188) * feat: enhance context menu handling to support V9 providers with event parameter * fix: enhance isV9ContextMenuProvider to check for mixed plugins * refactor: simplify spyOn usage for DarkColorHandler in BridgePlugin tests * fix: enhance isV9ContextMenuProvider to validate V9 provider signature * fix: update context menu provider check to use isMixedPluginProvider * New getContentForCopy API (#3182) New getContentForCopy API * feat: add announce options for bold, italic, and underline formatting (#3194) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Add Find and Replace API and plugin (#3190) * Add Find and Replace API and plugin * Fix a comment * improve * feat: add announcements for table selection and unselection in the editor (#3195) * feat: add announce options for bold, italic, and underline formatting; update shortcuts and tests * refactor: update context initialization in toggleBold, toggleItalic, and toggleUnderline tests for type safety * feat: add announcements for text selection and unselection in the editor * refactor: simplify table selection logic by using TableSelection type in getIsSelectingOrUnselecting function * Update packages/roosterjs-content-model-core/lib/corePlugin/selection/tableSelectionUtils.ts Co-authored-by: Copilot <[email protected]> * Address comments from review * test: add unit tests for bold, italic, and underline shortcuts with announceFormatChange * Move functionality to a new plugin * Fix * Fix * Fix comment --------- Co-authored-by: Copilot <[email protected]> * Fix #396891 (#3199) * Fix #396891 * improve * improve * first colunm (#3202) * Fix 400434 (#3200) * Add format when insert table (#3203) Add the format parameter in the insertTable API, then it will be possible to insert a table with a predefined format. It can be used to add margin bottom to the table, then when a table is inserted under another their border does not overlay. * Move graduated feature to a separate type (#3205) * Move graduated feature to a separate type * improve * fix build * Translate lineHeight normal to 120% when pasting from Word Desktop and move parsers to their own file (#3209) * Translate lineHeight normal to 120% and move parsers to their own file * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix text to bullet issue (#3210) * Fix text to bullet issue * fix test * Refactor paste source validation to use getDocumentSource (#3208) * Refactor paste source validation to use getDocumentSource - Updated shouldConvertToSingleImage to utilize htmlFirstLevelChildTags instead of clipboardData. - Replaced instances of getPasteSource with getDocumentSource across various tests and implementations. - Introduced getDocumentSource function to centralize document source determination logic. - Added retrieveDocumentMetadata utility to extract metadata from documents. - Ensured all related tests are updated to reflect changes in function calls and parameters. * Refactor paste handling and add tests for negative text indent parser * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Fix #3171 #3184 (#3211) * Fix #3171 #3184 * Update packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts Co-authored-by: Copilot <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Use getPromoteLink to verify if a link can be promoted (#3213) Add getPromoteLink function to verify if a link can be promoted. * [fix] Keep format on the selection marker when reconcile Text (#3220) * [fix] Keep format on the selection marker when reconcile Text * update ut * update test * [Image Edit] Fix 394371 (#3219) Check if the selectedImage property exists when the content changed event is triggered, * Update the Entity's format when applying format on the content inside the Entity (#3196) * Update the Entity's format when applying format on the content inside the Entity * fix test * Fix Align Attribute being removed on paste for containers (#3217) * Add wordContainerParser to handle negative margin-left values and update processPastedContentFromWordDesktop to use it * asd * Refactor wordContainerParser to remove unused parameters * remove * update * Support cache for list (#3204) * Support cache for list * fix build * improve * add tests * add test * add test * Update packages/roosterjs-content-model-dom/lib/modelToDom/handlers/handleBlockGroupChildren.ts Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Try generate url data (#3222) wrap the draw image function in a try statement, if successful the image will be drawn in the canvas, if not return the data URL of the previous image * Support Trusted publishing for npmjs (#3227) * Support Trusted publishing for npmjs * improve * improve * Fix 230556 (#3223) * Fix 230556 * improve * fix build and improve * Fix: make the isSafari env include both iOS and macOS (#3215) Co-authored-by: Liang Meng <[email protected]> Co-authored-by: Jiuqing Song <[email protected]> * Revert "Fix: make the isSafari env include both iOS and macOS (#3215)" (#3229) This reverts commit a5b653f. * Fix table selection logic to handle reversed coordinates and add corresponding tests (#3228) * Update "isSafari" detection to work across Apple platforms (#3232) * Update Safari detection logic in createEditorCore * Update isSafari detection in corresponding tests * Fix #2841 (#3230) * Fix #2841 * fix build * fix build * fix comment * Fix 298633 (#3233) * Fix #3231 (#3234) * Fix #3231 * fix comment * fix comments * Table Row/Column Selector (#3221) Add to new Table Editor features, TableRowSelector and TableColumnSelector to select table rows or columns. * Support color transformation in table borders (#3216) Introduce a new TransformTableBorderColor that enable border color transformation when the editor switch from light to dark mode. * Fix ordinal superscript for numbers ending in 0 (20th, 30th, etc.) (#3241) - Changed falsy check to explicit !== null for numericValue - Fixes issue where 0 was treated as falsy, preventing superscript - Affects both separate segments (linked numbers) and combined (20th) formats - Added unit tests for 20th, 30th, and 40th to prevent regression * Disable using global window and document (#3240) * Add minWidth cell to insertTable (#3239) Add a new parameter, customCellFormat, to the insertTable function to allow custom styles for tables. * Export formatContainerProcessor for public API use (#3238) Export formatContainerProcessor from roosterjs-content-model-dom public API to enable users to use it in processorOverride for custom DOM-to-Model processing. This allows customization of format container elements (e.g., blockquote) processing without relying on internal module paths. Co-authored-by: Jiuqing Song <[email protected]> * Fix Table Cell alignment for RTL (#3246) When the cell has the text direction in RTL, invert the table cell alignment direction, so it can match the direction. * Fix publish issue (#3253) --------- Co-authored-by: Julia Roldi <[email protected]> Co-authored-by: Bryan Valverde U <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Haowen Chen <[email protected]> Co-authored-by: Liang <[email protected]> Co-authored-by: Liang Meng <[email protected]> Co-authored-by: gabesl <[email protected]> Co-authored-by: Dennis Chen <[email protected]>
Extract the logic to create the BeforeCutCopyEvent into a new public API called triggerBeforeCutCopyEvent. It adds a new property in BeforeCutCopyEvent called pasteModel, that has the selection adjusted.