From 546128f13f5f74eaca814e4ec502ac28fcd37fa7 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Oct 2018 20:26:13 +0300 Subject: [PATCH 1/3] formatting to 'p' because removeFormat cannot deal with headers (h1, h2, ...) --- RichEditorView/Assets/editor/rich_editor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RichEditorView/Assets/editor/rich_editor.js b/RichEditorView/Assets/editor/rich_editor.js index 6fc55d4e..0472f53e 100644 --- a/RichEditorView/Assets/editor/rich_editor.js +++ b/RichEditorView/Assets/editor/rich_editor.js @@ -130,6 +130,9 @@ RE.updatePlaceholder = function() { }; RE.removeFormat = function() { + // https://stackoverflow.com/a/52137754/4514671 + // formatting to 'p' because removeFormat cannot deal with headers (h1, h2, ...) + document.execCommand('formatBlock', false, 'p'); document.execCommand('removeFormat', false, null); }; From e0b57789023dd79ca125e91beb31ff7e1ab87c2f Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Oct 2018 20:36:48 +0300 Subject: [PATCH 2/3] Added another reference link --- RichEditorView/Assets/editor/rich_editor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/RichEditorView/Assets/editor/rich_editor.js b/RichEditorView/Assets/editor/rich_editor.js index 0472f53e..ccd21918 100644 --- a/RichEditorView/Assets/editor/rich_editor.js +++ b/RichEditorView/Assets/editor/rich_editor.js @@ -131,6 +131,7 @@ RE.updatePlaceholder = function() { RE.removeFormat = function() { // https://stackoverflow.com/a/52137754/4514671 + // https://stackoverflow.com/questions/14028773/javascript-execcommandremoveformat-doesnt-strip-h2-tag // formatting to 'p' because removeFormat cannot deal with headers (h1, h2, ...) document.execCommand('formatBlock', false, 'p'); document.execCommand('removeFormat', false, null); From 12d3c4d2ef76cf5f3d47da3fe6c6f54876f59645 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 9 Oct 2018 15:18:00 +0300 Subject: [PATCH 3/3] Fix for Body button not removing Header tags; formatting to 'p' because removeFormat cannot deal with headers (h1, h2, ...) --- RichEditorView/Assets/editor/rich_editor.js | 1 + 1 file changed, 1 insertion(+) diff --git a/RichEditorView/Assets/editor/rich_editor.js b/RichEditorView/Assets/editor/rich_editor.js index ccd21918..75bf51f1 100644 --- a/RichEditorView/Assets/editor/rich_editor.js +++ b/RichEditorView/Assets/editor/rich_editor.js @@ -132,6 +132,7 @@ RE.updatePlaceholder = function() { RE.removeFormat = function() { // https://stackoverflow.com/a/52137754/4514671 // https://stackoverflow.com/questions/14028773/javascript-execcommandremoveformat-doesnt-strip-h2-tag + // fix for body button not formatting headers // formatting to 'p' because removeFormat cannot deal with headers (h1, h2, ...) document.execCommand('formatBlock', false, 'p'); document.execCommand('removeFormat', false, null);