Merge branch 'rails' of 0xacab.org:sutty/sutty into rails
This commit is contained in:
commit
56b4884b32
1 changed files with 27 additions and 0 deletions
|
@ -38,6 +38,33 @@ function fixContent (editor: Editor, node: Element = editor.contentEl): void {
|
|||
node = el
|
||||
}
|
||||
|
||||
if (node instanceof HTMLImageElement) {
|
||||
node.dataset.multimediaInner = ''
|
||||
const figureEl = types.multimedia.create(editor)
|
||||
|
||||
let targetEl = node.parentElement
|
||||
if (!targetEl) throw new Error('No encontré lx objetivo')
|
||||
while (true) {
|
||||
const type = getType(targetEl)
|
||||
if (!type) throw new Error('lx objetivo tiene tipo')
|
||||
if (type.type.allowedChildren.includes('multimedia')) break
|
||||
if (!targetEl.parentElement) throw new Error('No encontré lx objetivo')
|
||||
targetEl = targetEl.parentElement
|
||||
}
|
||||
|
||||
let parentEl = [...targetEl.childNodes].find(
|
||||
el => el.contains(node)
|
||||
)
|
||||
if (!parentEl) throw new Error('no encontré lx pariente')
|
||||
targetEl.insertBefore(figureEl, parentEl)
|
||||
|
||||
const innerEl = figureEl.querySelector('[data-multimedia-inner]')
|
||||
if (!innerEl) throw new Error('Raro.')
|
||||
figureEl.replaceChild(node, innerEl)
|
||||
|
||||
node = figureEl
|
||||
}
|
||||
|
||||
const _type = getType(node)
|
||||
if (!_type) return
|
||||
|
||||
|
|
Loading…
Reference in a new issue