From 0a7bd1053223ae96795656866ac6c3bbcf7172df Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 18 May 2026 14:44:59 +0200 Subject: [PATCH] fix(ActionInsertLink): allow to get title from link picker Requires nextcloud-libraries/nextcloud-vue#8532 to have an effect. Signed-off-by: Jonas --- src/components/Menu/ActionInsertLink.vue | 12 +++++++----- src/nodes/Preview.js | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/Menu/ActionInsertLink.vue b/src/components/Menu/ActionInsertLink.vue index 39e6227f376..855b4b26637 100644 --- a/src/components/Menu/ActionInsertLink.vue +++ b/src/components/Menu/ActionInsertLink.vue @@ -235,20 +235,22 @@ export default { linkCustomAction() { this.menubarLinkCustomAction .action() - .then((link) => { - this.insertLink(link) + .then((result) => { + this.insertLink(result) }) .catch((error) => { console.error('Custom link action promise rejected', error) }) }, - insertLink(link) { - if (!link) { + insertLink(result) { + if (!result) { return } + const { link, title = '' } = + typeof result === 'string' ? { link: result } : result const chain = this.editor?.chain() if (this.editor?.view.state?.selection.empty) { - chain.focus().insertPreview(link).run() + chain.focus().insertPreview(link, title).run() } else { chain.setLink({ href: link }).focus().run() } diff --git a/src/nodes/Preview.js b/src/nodes/Preview.js index 98224aef08d..e9912de1a40 100644 --- a/src/nodes/Preview.js +++ b/src/nodes/Preview.js @@ -144,10 +144,12 @@ export default Node.create({ * Insert a preview for given link. * * @param {string} link - the link URL + * @param {string|null} title - the link title (optional) */ insertPreview: - (link) => + (link, title = '') => ({ state, chain }) => { + title = title.trim() ?? link return chain() .insertContent({ type: 'preview', @@ -161,7 +163,7 @@ export default Node.create({ attrs: { href: link }, }, ], - text: link, + text: title, }, ], })