MCPcopy Create free account
hub / github.com/docusealco/docuseal / handleLinkTooltip

Method handleLinkTooltip

app/javascript/elements/markdown_editor.js:320–346  ·  view source on GitHub ↗
(editor)

Source from the content-addressed store, hash-verified

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')) {

Callers 1

connectedCallbackMethod · 0.45

Calls 4

isVisibleMethod · 0.80
hideMethod · 0.80
startMethod · 0.80
showMethod · 0.45

Tested by

no test coverage detected