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

Bugfix: add support to auto link #2316

Merged
merged 4 commits into from
Apr 20, 2022

Conversation

vinicius73
Copy link
Member

Summary

Auto-link is included in the original tiptap extension-link.

We should keep the original behavior as much as possible.

Vinicius Reis added 2 commits April 19, 2022 18:57
auto link is included in original tiptap extension-link.

We should keep the original behavior as much as possible.

Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
Comment on lines +9 to +15
const linkElement = event.target.parentElement instanceof HTMLAnchorElement
? event.target.parentElement
: event.target

const isLink = linkElement && linkElement instanceof HTMLAnchorElement

const htmlHref = linkElement?.href
Copy link
Member Author

Choose a reason for hiding this comment

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

I've changed this part of the original code to make it possible to run tests inside Cypress.

Originally we used editor.getAttributes('link') but it not works in cypress

When we interact natively/manually with the editor, the original events "bubble" from the span tag, but in cypress tests, the event comes from a tag, and this tag doesn't have attributes in the editor.
It makes the automated test impossible to work, because of this I've changed the code to use the native properties of the link.

@vinicius73
Copy link
Member Author

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
Copy link
Member

@julien-nc julien-nc left a comment

Choose a reason for hiding this comment

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

Works like a charm!


cy.get('@winOpen')
.should('have.been.calledOnce')
.should('have.been.calledWith', `/index.php/f/${id}`)
Copy link
Member

Choose a reason for hiding this comment

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

This fails if NC is accessible with a sub path as the call will be like /sub/path/index.php/f/${id}. Not a big deal but this test may fail in the future if we change how NC is deployed in the CI job.

We could either check that the target of @winOpen ends with /index.php/f/${id} or get the sub path and include it in the expected value.

@juliushaertl
Copy link
Member

/backport to stable24

@juliushaertl juliushaertl merged commit fddfacb into master Apr 20, 2022
@delete-merged-branch delete-merged-branch bot deleted the bugfix/2097/add-support-to-auto-link branch April 20, 2022 16:22
@backportbot-nextcloud
Copy link

The backport to stable24 failed. Please do this backport manually.

@juliushaertl
Copy link
Member

@vinicius73 Mind to take care of the manual backport then? :)

vinicius73 pushed a commit that referenced this pull request Apr 20, 2022
manually applied from #2316 and #2318

Signed-off-by: Vinicius Reis <vinicius.reis@nextcloud.com>
@max-nextcloud max-nextcloud added the backported successfully backported label Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review backported successfully backported bug: regression enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for autolink (tiptap v2)
5 participants