From fb7ad9ae1ae496e387bf3f2ef3f9d89131087418 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 26 Feb 2021 11:23:11 -0300 Subject: [PATCH] =?UTF-8?q?Revert=20"editor:=20mover=20imagenes=20a=20un?= =?UTF-8?q?=20figure=20aparte=20si=20no=20lo=20est=C3=A1n"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dfc9d6a2a40131492dbb5ec8d048dce5a146020a. --- app/javascript/editor/editor.ts | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/app/javascript/editor/editor.ts b/app/javascript/editor/editor.ts index a3919c85..3e340a45 100644 --- a/app/javascript/editor/editor.ts +++ b/app/javascript/editor/editor.ts @@ -1,5 +1,5 @@ import { storeContent, restoreContent, forgetContent } from 'editor/storage' -import { isDirectChild, moveChildren, safeGetSelection, safeGetRangeAt, setAuxiliaryToolbar, parentBlockNames } from 'editor/utils' +import { isDirectChild, moveChildren, safeGetSelection, safeGetRangeAt, setAuxiliaryToolbar } from 'editor/utils' import { types, getValidChildren, getType } from 'editor/types' import { setupButtons as setupMarksButtons } from 'editor/types/marks' import { setupButtons as setupBlocksButtons } from 'editor/types/blocks' @@ -14,7 +14,7 @@ import { setupAuxiliaryToolbar as setupMarkAuxiliaryToolbar } from 'editor/types // Esta funcion corrije errores que pueden haber como: // * que un nodo que no tiene 'text' permitido no tenga children (se les // inserta un allowedChildren[0]) -// * que haya una imágen sin
o que no esté como bloque (se ponen +// * TODO: que haya una imágen sin
o que no esté como bloque (se ponen // después del bloque en el que están como bloque de por si) // * convierte y en y // Lo hace para que siga la estructura del documento y que no se borren por @@ -38,33 +38,6 @@ 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') - - const innerEl = figureEl.querySelector('[data-multimedia-inner]') - if (!innerEl) throw new Error('Raro.') - figureEl.replaceChild(node, innerEl) - - targetEl.insertBefore(figureEl, parentEl) - node = figureEl - } - const _type = getType(node) if (!_type) return