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

Backport link fixes to stable24 #2672

Merged
merged 4 commits into from
Jul 6, 2022
Merged

Conversation

mejo-
Copy link
Member

@mejo- mejo- commented Jul 5, 2022

Backports several fixes for issues with link handling in editor (especially in Collectives).

@mejo- mejo- added bug Something isn't working 4. to release labels Jul 5, 2022
@mejo- mejo- added this to the Nextcloud 24.0.3 milestone Jul 5, 2022
@mejo- mejo- force-pushed the fix/stable24/link_handling branch from ff3e0a0 to f488874 Compare July 5, 2022 09:45
@mejo-
Copy link
Member Author

mejo- commented Jul 5, 2022

/compile amend

@skjnldsv skjnldsv mentioned this pull request Jul 5, 2022
18 tasks
@mejo- mejo- force-pushed the fix/stable24/link_handling branch 2 times, most recently from e369f69 to db2741c Compare July 6, 2022 10:23
max-nextcloud and others added 4 commits July 6, 2022 11:32
The Prosemirror plugin with the `handleClick` handler
only customizes the prosemirror handling of the click event.
In read only mode we are not in a content-editable section.
So clicking a link will cause the browser to open the url with a page reload.

Allow overwriting this behavior by handling all link clicks via prosemirror.
Set `onClick` option on the `Link` mark to customize the behavior.

Emit a `click-link` event from `ReadOnlyEditor` with info about the event
and the attributes of the link mark.

Find the link that was clicked based on the clicked marks
rather than the element in the event.
This way we can get access to the attributes of the mark
without relying on the selection or even changing it.

Also add plugin key to link click handler

Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Jonas <jonas@nextcloud.com>
* Resolve the position given to the `handleClick` function.
* Get the `link` mark from the resolved position.
* Use the attrs of this mark.

`editor.getAttributes` gets the attributes at the current selection.
In Firefox the selection will not move to the clicked position in read only mode.
So instead of relying on the selection we now use the `pos` of the click.

Signed-off-by: Max <max@nextcloud.com>
We only want our custom link handlers (either the default from Text app
or a further customized one, e.g. from Collectives app) to happen if the
first mouse button is used, Ctrl key is not pressed and the link points
to a local link.

Signed-off-by: Jonas <jonas@freesources.org>
Signed-off-by: Jonas <jonas@freesources.org>
@mejo- mejo- force-pushed the fix/stable24/link_handling branch from db2741c to 0a5c403 Compare July 6, 2022 10:33
Copy link
Collaborator

@max-nextcloud max-nextcloud left a comment

Choose a reason for hiding this comment

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

looks good to me. Thanks for taking care of this!

@max-nextcloud max-nextcloud merged commit 0ca9864 into stable24 Jul 6, 2022
@delete-merged-branch delete-merged-branch bot deleted the fix/stable24/link_handling branch July 6, 2022 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants