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

Method connectedCallback

app/javascript/elements/html_editor.js:440–524  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

438 ]
439
440 async connectedCallback () {
441 if (!this.textarea || !this.editorElement) return
442
443 this.textarea.style.display = 'none'
444 this.adjustShortcutsForPlatform()
445
446 const tiptap = await loadTiptap()
447
448 const { Editor, Extension, Document, Text, HardBreak, UndoRedo, Gapcursor, Dropcursor } = tiptap
449
450 this.emailDocument = new DOMParser().parseFromString(this.textarea.value, 'text/html')
451
452 const shadow = this.editorElement.attachShadow({ mode: 'open' })
453
454 shadow.adoptedStyleSheets = [editorStylesheet]
455
456 this.emailDocument.head.querySelectorAll('style').forEach((style) => {
457 shadow.appendChild(style.cloneNode(true))
458 })
459
460 const container = document.createElement('div')
461 const bodyStyle = this.emailDocument.body.getAttribute('style')
462
463 if (bodyStyle) container.setAttribute('style', bodyStyle)
464
465 shadow.appendChild(container)
466
467 const LinkShortcut = Extension.create({
468 name: 'linkShortcut',
469 addKeyboardShortcuts: () => ({
470 'Mod-k': () => {
471 this.toggleLink()
472
473 return true
474 }
475 })
476 })
477
478 this.editor = new Editor({
479 element: container,
480 extensions: [
481 Document,
482 Text,
483 HardBreak,
484 UndoRedo,
485 Gapcursor,
486 Dropcursor,
487 ...buildExtensions(tiptap),
488 LinkShortcut
489 ],
490 content: this.emailDocument.body.innerHTML,
491 injectCSS: false,
492 editorProps: {
493 attributes: {
494 dir: 'auto'
495 },
496 handleDOMEvents: {
497 click: (_, event) => {

Callers

nothing calls this directly

Calls 9

buildExtensionsFunction · 0.85
containsMethod · 0.80
hideMethod · 0.80
loadTiptapFunction · 0.70
createMethod · 0.45
toggleLinkMethod · 0.45
updateToolbarStateMethod · 0.45
handleLinkTooltipMethod · 0.45

Tested by

no test coverage detected