From 1811c81c0d10ae2585a7cf245a1a01ae96de4b69 Mon Sep 17 00:00:00 2001 From: void Date: Wed, 18 Nov 2020 22:37:06 -0300 Subject: [PATCH 1/4] convertir a strong y a em --- app/assets/javascripts/02-editor.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/02-editor.js b/app/assets/javascripts/02-editor.js index e01132ef..87d47758 100644 --- a/app/assets/javascripts/02-editor.js +++ b/app/assets/javascripts/02-editor.js @@ -336,8 +336,17 @@ function cleanNode (node, contentEl) { child.parentElement.removeChild(child) return } else if (child.tagName === "STYLE") { + return child.parentElement.removeChild(child) + } else if (child.tagName === "B") { + const el = document.createElement("STRONG") + moveChildren(child, el) + child.parentElement.insertBefore(el, child) + child.parentElement.removeChild(child) + } else if (child.tagName === "I") { + const el = document.createElement("EM") + moveChildren(child, el) + child.parentElement.insertBefore(el, child) child.parentElement.removeChild(child) - return } for (const style of Object.values(child.style)) { From f03479fad56085ab81d7a3e9613fece26e93759c Mon Sep 17 00:00:00 2001 From: void Date: Wed, 18 Nov 2020 22:51:15 -0300 Subject: [PATCH 2/4] aviso cuando pegas de word (#130) --- app/assets/javascripts/02-editor.js | 3 +++ app/assets/stylesheets/editor.scss | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/app/assets/javascripts/02-editor.js b/app/assets/javascripts/02-editor.js index ec4cf34b..a11362d2 100644 --- a/app/assets/javascripts/02-editor.js +++ b/app/assets/javascripts/02-editor.js @@ -416,6 +416,9 @@ function setupEditor (editorEl) { range.collapse() } }) + contentEl.addEventListener("paste", event => { + contentEl.querySelector("editor-aviso-word").style.display = "block" + }) document.addEventListener("selectionchange", event => { cleanContent(contentEl) }) diff --git a/app/assets/stylesheets/editor.scss b/app/assets/stylesheets/editor.scss index 4b89cf1a..95c7a07a 100644 --- a/app/assets/stylesheets/editor.scss +++ b/app/assets/stylesheets/editor.scss @@ -35,6 +35,11 @@ background: white; } + .editor-aviso-word { + color: red; + display: none; + } + .editor-primary-toolbar, .editor-auxiliary-toolbar { display: block; overflow-x: auto; From cf93710b339ec4e6b6957fe4d3cdf301a52b47ee Mon Sep 17 00:00:00 2001 From: void Date: Wed, 18 Nov 2020 22:55:13 -0300 Subject: [PATCH 3/4] =?UTF-8?q?me=20olvid=C3=A9=20de=20esta=20parte=20del?= =?UTF-8?q?=20commit=20anterior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/attributes/_content.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/posts/attributes/_content.haml b/app/views/posts/attributes/_content.haml index b4d1ad2a..d4ba76a7 100644 --- a/app/views/posts/attributes/_content.haml +++ b/app/views/posts/attributes/_content.haml @@ -68,6 +68,9 @@ .form-group{ data: { editor: { auxiliary: 'link' } } } %label{ for: 'link-href' }= t('editor.url') %input.form-control{ type: 'url', data: { prop: 'link-href' } }/ + + .editor-aviso-word + %p ¡Alto ahí! ¿Estás pegando de word? ... .editor-content.form-control.h-auto.mt-1{ contenteditable: 'true' } = metadata.value.html_safe From 89ad4515240bfbac51e4f0b72412111a3f178b9d Mon Sep 17 00:00:00 2001 From: void Date: Wed, 18 Nov 2020 22:55:33 -0300 Subject: [PATCH 4/4] sup y sub; falta strings --- app/assets/javascripts/01-types.js | 8 ++++++++ app/views/posts/attributes/_content.haml | 2 ++ 2 files changed, 10 insertions(+) diff --git a/app/assets/javascripts/01-types.js b/app/assets/javascripts/01-types.js index 9b0abd79..38b32d96 100644 --- a/app/assets/javascripts/01-types.js +++ b/app/assets/javascripts/01-types.js @@ -27,6 +27,14 @@ const marks = { selector: "u", createFn: () => document.createElement("U"), }, + sub: { + selector: "sub", + createFn: () => document.createElement("SUB"), + }, + sup: { + selector: "sup", + createFn: () => document.createElement("SUP"), + }, mark: { selector: "mark", createFn: () => document.createElement("MARK"), diff --git a/app/views/posts/attributes/_content.haml b/app/views/posts/attributes/_content.haml index d4ba76a7..b928bc49 100644 --- a/app/views/posts/attributes/_content.haml +++ b/app/views/posts/attributes/_content.haml @@ -14,6 +14,8 @@ %button.btn{ data: { button: 'italic' } }= t('editor.italic') %button.btn{ data: { button: 'deleted' } }= t('editor.deleted') %button.btn{ data: { button: 'underline' } }= t('editor.underline') + %button.btn{ data: { button: 'sup' } }= t('editor.sup') + %button.btn{ data: { button: 'sub' } }= t('editor.sub') %button.btn{ data: { button: 'mark' } }= t('editor.mark') %button.btn{ data: { button: 'h1' } }= t('editor.h1') %button.btn{ data: { button: 'h2' } }= t('editor.h2')