(editor)
| 318 | } |
| 319 | |
| 320 | handleLinkTooltip (editor) { |
| 321 | const { from } = editor.state.selection |
| 322 | const mark = editor.state.doc.resolve(from).marks().find(m => m.type.name === 'link') |
| 323 | |
| 324 | if (!mark) { |
| 325 | if (this.linkTooltip.isVisible()) this.linkTooltip.hide() |
| 326 | |
| 327 | return |
| 328 | } |
| 329 | |
| 330 | if (this.linkTooltip.isVisible() && this.linkTooltip.currentMark === mark) return |
| 331 | |
| 332 | let linkStart = from |
| 333 | const start = editor.state.doc.resolve(from).start() |
| 334 | |
| 335 | for (let i = from - 1; i >= start; i--) { |
| 336 | if (editor.state.doc.resolve(i).marks().some(m => m.eq(mark))) { |
| 337 | linkStart = i |
| 338 | } else { |
| 339 | break |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | this.linkTooltip.hide() |
| 344 | this.linkTooltip.show(mark.attrs.href, linkStart > start ? linkStart - 1 : linkStart) |
| 345 | this.linkTooltip.currentMark = mark |
| 346 | } |
| 347 | |
| 348 | toggleLink () { |
| 349 | if (this.editor.isActive('link')) { |
no test coverage detected