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

Add isReverted to DOM Selection #2368

Merged
merged 12 commits into from
Jan 30, 2024
Merged

Conversation

BryanValverdeU
Copy link
Contributor

  1. This PR adds a new Util to get the focused position using a DOMSelection as parameter.
    1.1. To accomplish this, also adds a new property to DOMSelection isReverted to determine if the selection in the DOM was in Document order (From right to left/Top to bottom) or in reverse Document order (Left to right/Bottom to top). By Checking the Focus node of the selection and the start container of the range of the selection.
  2. Add the support to maintain the selection order when formating and when restoring an undo snapshot if the selection was in reverse of the document.

@BryanValverdeU BryanValverdeU changed the title Add getFocusedPosition util Add isReverted to DOM Selection Jan 29, 2024
@@ -27,6 +27,7 @@ export function contentModelToDom(
onNodeCreated?: OnNodeCreated
): DOMSelection | null {
context.onNodeCreated = onNodeCreated;
context.regularSelection.isReverted = isSelectionReverted(doc.getSelection());
Copy link
Collaborator

Choose a reason for hiding this comment

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

selection in content model may not be the same with current selection, so here we can't use doc.getSelection().

Actually when create Content Model, I think the isReverted info is lost, because we only have "isSelected" in Content Model but we don't store if it is reverted.

Do we need this info when write back from Content Model? If not, we can always set to false and leave a TODO here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, lets remove it.
The only problem here is that if the selection was reverse of the document, after model to dom, the reverse order could be lost. But it is probably a small issue.

@BryanValverdeU BryanValverdeU merged commit 1ad815d into master Jan 30, 2024
7 checks passed
@BryanValverdeU BryanValverdeU deleted the u/bvalverde/addFocusedPosition branch January 30, 2024 18:23
Andres-CT98 added a commit that referenced this pull request Feb 2, 2024
* wip

* wip

* refactor

* fix dependecies

* fix dependecies

* fix dependecies

* WIP

* add test

* add tests

* types

* add comment

* add comment

* add comment

* add comment

* add comment

* comments

* fix build

* fixes

* fixes

* refactor

* fixes

* Add shortcut support Ctrl+K for insertLink  (#2333)

* Add shortcut support Ctrl+K for insertLink

* Add metakey and alt key checks

* Add insertButton check and disable param

* add options to ribbon and decouple onButtonClick

* update

* update fix

* add break statement

* remove duplicate imports

---------

Co-authored-by: Ghanem10 <107857762+Ghanem10@users.noreply.github.com>
Co-authored-by: Jiuqing Song <jisong@microsoft.com>

* Content Model: Add back ContentModelBeforePasteEvent (#2347)

* Use margin-top and bottom for list margin (#2346)

* Standalone Editor: Improve cache (3rd try) (#2344)

Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com>

* fixes

* fix test

* Fix safari selection issue (#2332)

* try fix safari selection issue

* fix content model editor, add test

* fix focus bug

* Standalone Editor: Remove dependency to old code from api and plugins package (#2349)

* Content Model: Decouple test code from old code (#2351)

* Fix demo site (#2353)

* Content Model: Fix table text color (#2359)

* Fix pending format (#2354)

* Fix pending format

* improve

* Standalone Editor: Provide a DOMHelper to allow access DOM tree (#2363)

* Fix shadow edit (#2355)

* Fix 2 shadow edit issue (#2356)

* Support unit "inch" when parse value (#2357)

* Content Model: Support inch when parse unit value

* add comment

* Code clean up: small refactor to paste code (#2365)

* Refactor paste

* add test

* Code clean up: Remove IStandaloneEditor.setContentModel (#2364)

* Add support to cursor around Block entities. (#2350)

* rotator space

* Port ContextMenu plugin (#2366)

* Port ContextMenu plugin

* add test

* Content Model: Fix 252436 (#2367)

* Content Model: Fix 252436

* add test

---------

Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com>

* Code cleanup: Remove parameter onNodeCreated (#2374)

* Code cleanup: Remove isContentModelEditor (#2371)

* Code cleanup: Remove isContentModelEditor

* add buttons

* Add `isReverted` to DOM Selection (#2368)

* add Changes

* add Tests

* fix dependencies

* address comments

* address comment

* fix after merge

* fix test

---------

Co-authored-by: Jiuqing Song <jisong@microsoft.com>

* Code cleanup: Remove NormalizeTablePlugin (#2376)

* add normalize content model

* fix build

* Code cleanup: Replace createContentModel with getContentModelCopy (#2372)

* Code cleanup: Remove isContentModelEditor

* add buttons

* Code cleanup: Replace createContentModel with getContentModelCopy

* Code cleanup: Remove get/setZoomScale (#2378)

* Code cleanup: Remove get/setZoomScale

* Add calculateZoomScale function

* improve

* Code cleanup: Move isNodeInEditor into DOMHelper (#2379)

* Code cleanup: Remove TODO (#2384)

* Add write permission to deploy action (#2383)

* Revert "Add support to cursor around Block entities. (#2350)" (#2390)

This reverts commit 7998d03.

* Content Model: Fix #2202 (#2389)

Co-authored-by: Bryan Valverde U <bvalverde@microsoft.com>

* bump

---------

Co-authored-by: Júlia Roldi <juliaroldi@microsoft.com>
Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com>
Co-authored-by: Gani <107857762+gm-al@users.noreply.github.com>
Co-authored-by: Ghanem10 <107857762+Ghanem10@users.noreply.github.com>
Co-authored-by: Jiuqing Song <jisong@microsoft.com>
Co-authored-by: Bryan Valverde U <bvalverde@microsoft.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