diff --git a/cypress/e2e/Links.spec.js b/cypress/e2e/Links.spec.js index 8be684aa611..bb27ec2808b 100644 --- a/cypress/e2e/Links.spec.js +++ b/cypress/e2e/Links.spec.js @@ -43,7 +43,7 @@ describe('test link marks', function () { cy.get('.link-view-bubble .widget-default', { timeout: 10000 }) .find('.widget-default--name') .contains('Nextcloud') - .click({ force: true }) + .click() }) it('shows a link preview in the bubble after browsing to link', () => { @@ -58,6 +58,16 @@ describe('test link marks', function () { .contains('Nextcloud') }) + it('open button opens a new tab', () => { + const link = 'https://nextcloud.com/' + cy.insertLine(link) + clickLink(link) + + cy.get('.link-view-bubble button[title="Open link"]').click() + + cy.get('@winOpen').should('have.been.calledOnce') + }) + it('closes the link bubble when clicking elsewhere', () => { const link = 'https://nextcloud.com/' cy.insertLine(link) diff --git a/cypress/e2e/nodes/PreviewOptions.spec.js b/cypress/e2e/nodes/PreviewOptions.spec.js index b3fbd83a427..bc216156aa6 100644 --- a/cypress/e2e/nodes/PreviewOptions.spec.js +++ b/cypress/e2e/nodes/PreviewOptions.spec.js @@ -25,6 +25,9 @@ describe('Preview Options', function () { }) it('should render previewOptions correctly', function () { + cy.get('.action-button__text') + .contains('Open in new tab') + .should('be.visible') cy.get('.action-button__text').contains('Remove link').should('be.visible') cy.get('.action-radio__label').each((el) => { cy.wrap(el) diff --git a/src/components/Editor.provider.ts b/src/components/Editor.provider.ts index fa49465dfd6..9e866078fa1 100644 --- a/src/components/Editor.provider.ts +++ b/src/components/Editor.provider.ts @@ -3,6 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ +import { openLink } from '../helpers/links.js' import { logger } from '../helpers/logger.js' export const FILE = Symbol('editor:file') @@ -11,6 +12,7 @@ export const IS_MOBILE = Symbol('editor:is-mobile') export const EDITOR_UPLOAD = Symbol('editor:upload') export const HOOK_MENTION_SEARCH = Symbol('hook:mention-search') export const HOOK_MENTION_INSERT = Symbol('hook:mention-insert') +export const OPEN_LINK_HANDLER = Symbol('editor:open-link-handler') export const useIsMobileMixin = { inject: { @@ -66,3 +68,13 @@ export const useMentionHook = { }, }, } +export const useOpenLinkHandler = { + inject: { + $openLinkHandler: { + from: OPEN_LINK_HANDLER, + default: { + openLink, + }, + }, + }, +} diff --git a/src/components/Link/LinkBubbleView.vue b/src/components/Link/LinkBubbleView.vue index 97ac00dd61b..5ed97243907 100644 --- a/src/components/Link/LinkBubbleView.vue +++ b/src/components/Link/LinkBubbleView.vue @@ -10,6 +10,16 @@