From 9cb3c084eedffd93ddd68de2473305de2797e5ad Mon Sep 17 00:00:00 2001 From: f Date: Fri, 26 Feb 2021 10:21:53 -0300 Subject: [PATCH] =?UTF-8?q?olvidar=20el=20art=C3=ADculo=20al=20guardar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/editor/editor.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/javascript/editor/editor.ts b/app/javascript/editor/editor.ts index 0990c59..a3919c8 100644 --- a/app/javascript/editor/editor.ts +++ b/app/javascript/editor/editor.ts @@ -1,4 +1,4 @@ -import { storeContent, restoreContent } from 'editor/storage' +import { storeContent, restoreContent, forgetContent } from 'editor/storage' import { isDirectChild, moveChildren, safeGetSelection, safeGetRangeAt, setAuxiliaryToolbar, parentBlockNames } from 'editor/utils' import { types, getValidChildren, getType } from 'editor/types' import { setupButtons as setupMarksButtons } from 'editor/types/marks' @@ -279,11 +279,24 @@ function setupEditor (editorEl: HTMLElement): void { } document.addEventListener("turbolinks:load", () => { + const flash = document.querySelector('.js-flash') + + if (flash) { + const keys = JSON.parse(flash.dataset.keys || '') + + switch (flash.dataset.target) { + case 'editor': + switch (flash.dataset.action) { + case 'forget-content': + keys.forEach(forgetContent) + } + } + } + for (const editorEl of document.querySelectorAll('.editor[data-editor]')) { try { setupEditor(editorEl) } catch (error) { - //alert(`No pude iniciar el editor: ${error}`) // TODO: mostrar error console.error('no se pudo iniciar el editor, error completo', error) }