-
Notifications
You must be signed in to change notification settings - Fork 57
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
ZUIEditor link and button extensions #2477
Merged
richardolsson
merged 16 commits into
undocumented/ZUI-text-editor
from
undocumented/ZUI-editor-tools
Jan 18, 2025
Merged
ZUIEditor link and button extensions #2477
richardolsson
merged 16 commits into
undocumented/ZUI-text-editor
from
undocumented/ZUI-editor-tools
Jan 18, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
richardolsson
changed the title
ZUIEditor link extension (WIP)
ZUIEditor link and button extensions
Jan 17, 2025
I'm going to merge this into the editor branch to avoid more conflicts, but I still think you should have a look when you get a chance @ziggabyte. |
richardolsson
commented
Jan 20, 2025
const mark = this.type.create(); | ||
const node = this.type.schema.text(String.fromCharCode(160), [mark]); | ||
const pos = state.selection.$head.pos; | ||
tr = tr.insert(pos, node); |
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.
Someone should check if tr == tr.insert(pos, node)
, i.e. if the tr
object changes or is immutable and gets copied.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR finishes link and button extensions for the new
ZUIEditor
, initially implemented by @ziggabyte and then finished by me.They use a common
TextAndHrefOverlay
component for their UI.Screenshots
Button
Link
Changes
LinkExtensionUI
andButtonExtensionUI
components that both render aTextAndHrefOverlay
Notes to reviewer
Note especially how I solved the two new commands in the
ButtonExtension
, which rely heavily onresolve()
to find the relevant positions. Theresolve()
function could also be useful in situations where we need to find the relevant nodes, since it returns adepth
andnode()
function to retrieve the node and it's ancestors at the current position.For the new "Create link" feature, that inserts a link without converting an existing text range, I chose to insert a link node consisting of a single non-breaking space (
String.fromCharCode(160)
) and select it. For some reason, a regular space (' '
) did not work reliably.Related issues
Undocumented