Skip to content

Commit

Permalink
fix(preview): set selection inside the node
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Mar 6, 2024
1 parent dde4901 commit 80ed416
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions cypress/e2e/nodes/Preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/ParagraphView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
console.info(...args)
this.$editor.chain()
.focus()
.setTextSelection(this.getPos())
.setTextSelection(this.getPos() + 1)
.setPreview()
.run()
},
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/Preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default {
console.info(...args)
this.$editor.chain()
.focus()
.setTextSelection(this.getPos())
.setTextSelection(this.getPos() + 1)
.unsetPreview()
.run()
},
Expand Down

0 comments on commit 80ed416

Please sign in to comment.