Skip to content

Comments

Support undeletable anchor Step 3: Support anchor#2972

Merged
JiuqingSong merged 6 commits intomasterfrom
u/jisong/anchor0328_3
Apr 3, 2025
Merged

Support undeletable anchor Step 3: Support anchor#2972
JiuqingSong merged 6 commits intomasterfrom
u/jisong/anchor0328_3

Conversation

@JiuqingSong
Copy link
Collaborator

This is the first step to support undeletable anchor.

The final goal is to allow adding anchor such as and specify what kind of anchor is not deletable, then all editing function will not delete it.

In this PR I'm adding support to anchor -- an <A> element with name but no href.

In order to support anchor, we need to let element parser recognize A element that has no href, also need to support empty anchor: A element without child. When that happens, add an empty text segment as the holder of anchor.

We also need to modify some utility functions such as normalizeParagraph and isSegmentEmpty to let them keep those empty text segment which has anchor link.

@JiuqingSong JiuqingSong changed the title Support undeletable anchor Step 2: Support anchor Support undeletable anchor Step 3: Support anchor Mar 28, 2025
@JiuqingSong JiuqingSong marked this pull request as ready for review April 1, 2025 18:56
@BryanValverdeU
Copy link
Contributor

Just curious, what happens if user with DevTools delete the element or with third party code the body of the editor is edited? Maybe just a corner case, but was curious what happens in that scenario

@JiuqingSong
Copy link
Collaborator Author

Just curious, what happens if user with DevTools delete the element or with third party code the body of the editor is edited? Maybe just a corner case, but was curious what happens in that scenario

Then we will lose those info.
But since user opens debugger, they can already copy everything :P

@JiuqingSong JiuqingSong merged commit ff7ca3b into master Apr 3, 2025
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/anchor0328_3 branch April 3, 2025 20:25
juliaroldi added a commit that referenced this pull request Apr 4, 2025
* Support undeletable anchor Step 1: Support hidden properties (#2970)

* Support undeletable anchor Step 1: Support hidden properties

* improve comments

* Support undeletable anchor Step 2: Add undeletable property to link (#2971)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3: Support anchor (#2972)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3

* Find previously marked paragraph (#2975)

* Support undeletable anchor Step 4: Prevent deleting undeletable anchor (#2973)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3

* Support undeletable anchor Step 4

* improve

* add test

* fix typo

* bump version

* fix version

---------

Co-authored-by: Jiuqing Song <jisong@microsoft.com>
juliaroldi added a commit that referenced this pull request Apr 7, 2025
* Support undeletable anchor Step 1: Support hidden properties (#2970)

* Support undeletable anchor Step 1: Support hidden properties

* improve comments

* Support undeletable anchor Step 2: Add undeletable property to link (#2971)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3: Support anchor (#2972)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3

* Find previously marked paragraph (#2975)

* Support undeletable anchor Step 4: Prevent deleting undeletable anchor (#2973)

* Support undeletable anchor Step 1: Support hidden properties

* Support undeletable anchor step 2

* improve comments

* Support undeletable anchor Step 3

* Support undeletable anchor Step 4

* improve

* add test

* fix typo

* Do not enable paragraph map by default (#2978)

* Check selection for empty anchor (#2979)

Co-authored-by: Julia Roldi <87443959+juliaroldi@users.noreply.github.com>

* fix test

---------

Co-authored-by: Jiuqing Song <jisong@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