-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: link preview editor #3335
Merged
Merged
fix: link preview editor #3335
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
packages/editor/document-editor/src/ui/components/links/link-edit-view.tsx
Fixed
Show fixed
Hide fixed
1 task
sriramveeraghanta
approved these changes
Jan 10, 2024
henit-chobisa
force-pushed
the
fix/link-preview-editor
branch
from
January 10, 2024 11:34
75a3c35
to
0beca83
Compare
sriramveeraghanta
approved these changes
Jan 10, 2024
sriramveeraghanta
pushed a commit
that referenced
this pull request
Jan 22, 2024
* feat: added link preview plugin in document editor * fix: readonly editor page renderer css * fix: autolink issue with links * chore: added floating UI * feat: added link preview components * feat: added floating UI to page renderer for link previews * feat: added actionCompleteHandler to page renderer * chore: Lock file changes * fix: regex security error * chore: updated radix with lucid icons --------- Co-authored-by: pablohashescobar <[email protected]>
sriramveeraghanta
pushed a commit
that referenced
this pull request
Jan 22, 2024
* feat: added link preview plugin in document editor * fix: readonly editor page renderer css * fix: autolink issue with links * chore: added floating UI * feat: added link preview components * feat: added floating UI to page renderer for link previews * feat: added actionCompleteHandler to page renderer * chore: Lock file changes * fix: regex security error * chore: updated radix with lucid icons --------- Co-authored-by: pablohashescobar <[email protected]>
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.
Link Views for viewing, copying & editing links in Pages!
Description
The PR adds Link Previews inside Plane Pages, which enables customer to not only views the link but also can edit and remove the links on hover, which was not possible previously even to view the link. The Link Previews are added using floatingUI which can be beneficial for document-editor's upcoming features.
Features
Preview the Link when hovered
This is a basic feature for the Link Previews, the main challenge here was to handle the referenced element, which is variable, as the references element depends on the link embedded by the user. Hence, to determine the position of the floating element and the change it as the reference element changes.
Screen.Recording.2024-01-09.at.2.12.22.PM.mov
Copying Link to the Clipboard
Link can be copied to clipboard, so that can be used with other resources.
Screen.Recording.2024-01-09.at.2.40.46.PM.mov
Remove Link from Text
There are two ways of removing the link from the next, either the button in the
linkPreview
can be used orRemove Link
button from theLinkEditView
can be used.Screen.Recording.2024-01-09.at.2.41.30.PM.mov
Edit Links
Editing/Adding Correct Link Format
When added with the correct link format, the link from the text can be expected to updated.
Screen.Recording.2024-01-10.at.3.32.37.PM.mov
Preserves previous link in case of adding incorrect link format
When added an invalid link, the previous link should be preserved on dismissal of the
LinkView
Screen.Recording.2024-01-10.at.3.25.25.PM.mov
Preview Dismissal on Escape / Enter / Focus Change
There are a few ways to dismiss a link view
enter
on any input and an action will be taken to update the link or the text, followed by the dismissal of theLinkPreview
Screen.Recording.2024-01-10.at.3.29.44.PM.mov
Edit the Text along with the Link
You can edit text along with the link given in the link edit view. Here in the below video you can see that when the input is completely cleared it keeps one letter out of the last text that holds the link. The behaviour is intentional, as we don't want the user to loose the link, when the user clear the text input and add new text in the text input the last character would be removed and there would be completely new text on the place.
Screen.Recording.2024-01-10.at.3.33.32.PM.mov
Challenges
To get the challenges, it is significant to understand how floating UI handles the popovers. Floating UI has two modes, either a JavaScript or a react, where if you use a react mode, you have to determine the reference element and also the floating element. In that context, we can see that our floating element might be an element we know while the reference element is a variable, that we can only determine when the particular link is being hovered upon. Hence
Challenge 1 - To dynamically determine the position of the floating component based on the variable reference element.
Challenge 2 - Also it’s crucial to update the position of the popover when the reference element updates like change positions or scroll
Challenge 3 - We have to determine if we have to remake and destroy the popover every-time or we go along with the react way.
Challenge 4 - We have to destroy the popover all soon as we focus upon the editor.
Stages Further with Links! 🔗
LinkView
, theLinkInputView
which just takes in a link and apply it to the selected text.