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

Commits on Jul 6, 2022

  1. backport of feature: emit clickLink from ReadOnlyEditor

    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>
    max-nextcloud authored and mejo- committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    52587b6 View commit details
    Browse the repository at this point in the history
  2. fix: find link href based on prosemirror node

    * 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>
    max-nextcloud authored and mejo- committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    099e3fc View commit details
    Browse the repository at this point in the history
  3. Move click conditions from default openClick handler to link plugin

    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>
    mejo- committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    6b15a37 View commit details
    Browse the repository at this point in the history
  4. Compile JS assets

    Signed-off-by: Jonas <jonas@freesources.org>
    mejo- committed Jul 6, 2022
    Configuration menu
    Copy the full SHA
    0a5c403 View commit details
    Browse the repository at this point in the history