From 4dfba17941eb1b2a2e55d32f8a599274606be8c3 Mon Sep 17 00:00:00 2001 From: void Date: Sat, 13 Feb 2021 01:14:36 +0000 Subject: [PATCH] editor: fixes y links --- app/javascript/editor/editor.ts | 114 +++++++++++++++----- app/javascript/editor/types.ts | 9 +- app/javascript/editor/types/blocks.ts | 2 +- app/javascript/editor/types/link.ts | 32 ++++++ app/javascript/editor/types/marks.ts | 6 +- app/javascript/editor/types/parentBlocks.ts | 2 +- app/javascript/editor/utils.ts | 9 +- app/views/posts/attributes/_content.haml | 20 ++-- 8 files changed, 148 insertions(+), 46 deletions(-) create mode 100644 app/javascript/editor/types/link.ts diff --git a/app/javascript/editor/editor.ts b/app/javascript/editor/editor.ts index 7d42e6e..ef3d315 100644 --- a/app/javascript/editor/editor.ts +++ b/app/javascript/editor/editor.ts @@ -1,17 +1,10 @@ import { storeContent, restoreContent } from 'editor/storage' -import { isDirectChild, moveChildren, safeGetSelection, safeGetRangeAt } 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' import { setupButtons as setupParentBlocksButtons } from 'editor/types/parentBlocks' - -export interface Editor { - editorEl: HTMLElement, - toolbarEl: HTMLElement, - contentEl: HTMLElement, - wordAlertEl: HTMLElement, - htmlEl: HTMLTextAreaElement, -} +import { setupAuxiliaryToolbar as setupLinkAuxiliaryToolbar } from 'editor/types/link' // Esta funcion corrije errores que pueden haber como: // * que un nodo que no tiene 'text' permitido no tenga children (se les @@ -50,7 +43,7 @@ function fixContent (editor: Editor, node: Element = editor.contentEl): void { if (getValidChildren(node, type).length == 0) { if (typeof type.handleEmpty !== 'string') { - const el = type.handleEmpty.create() + const el = type.handleEmpty.create(editor) // mover cosas que pueden haber // por ejemplo: cuando convertís a un