From 544bfb6dacb7d312e6e821e4fb626896fff8ea23 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 6 Mar 2024 18:50:57 +0100 Subject: [PATCH] fix(preview): set selection inside the node Signed-off-by: Max --- cypress/e2e/nodes/Preview.spec.js | 6 ++++++ src/nodes/ParagraphView.vue | 2 +- src/nodes/Preview.vue | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/nodes/Preview.spec.js b/cypress/e2e/nodes/Preview.spec.js index c701f635c4..02135a66cd 100644 --- a/cypress/e2e/nodes/Preview.spec.js +++ b/cypress/e2e/nodes/Preview.spec.js @@ -75,6 +75,12 @@ describe.only('Preview extension', { retries: 0 }, () => { expect(editor.can().setPreview()).to.be.true }) + it('can run the second a paragraph with a link', () => { + prepareEditor('hello\n\n[link text](https://nextcloud.com)\n') + editor.commands.setTextSelection(10) + expect(editor.can().setPreview()).to.be.true + }) + it('results in a preview node with the href and text with link mark', () => { prepareEditor('[link text](https://nextcloud.com)\n') editor.commands.setPreview() diff --git a/src/nodes/ParagraphView.vue b/src/nodes/ParagraphView.vue index 653d5c0b49..6db8c6482b 100644 --- a/src/nodes/ParagraphView.vue +++ b/src/nodes/ParagraphView.vue @@ -79,7 +79,7 @@ export default { console.info(...args) this.$editor.chain() .focus() - .setTextSelection(this.getPos()) + .setTextSelection(this.getPos() + 1) .setPreview() .run() }, diff --git a/src/nodes/Preview.vue b/src/nodes/Preview.vue index efc3df6be6..b3abed0ef7 100644 --- a/src/nodes/Preview.vue +++ b/src/nodes/Preview.vue @@ -59,7 +59,7 @@ export default { console.info(...args) this.$editor.chain() .focus() - .setTextSelection(this.getPos()) + .setTextSelection(this.getPos() + 1) .unsetPreview() .run() },