From 50581ffff5c90d696f11b7bb3e153f437b371108 Mon Sep 17 00:00:00 2001 From: aayush anand Date: Sat, 24 Feb 2018 12:21:01 +0530 Subject: [PATCH 1/2] added support for font-size, undo,redo and font-family --- src/RichTextEditor.js | 16 ++++++++++++++++ src/WebviewMessageHandler.js | 12 ++++++++++++ src/const.js | 6 +++++- src/editor.html | 5 +++++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/RichTextEditor.js b/src/RichTextEditor.js index 51e212ef..56992111 100644 --- a/src/RichTextEditor.js +++ b/src/RichTextEditor.js @@ -388,6 +388,22 @@ export default class RichTextEditor extends Component { this._sendAction(actions.blurContentEditor); } + undo(){ + this._sendAction(actions.undo) + } + + redo(){ + this._sendAction(actions.redo) + } + + fontSize(size){ + this._sendAction(actions.fontSize,size) + } + + font(font) { + this._sendAction(actions.font, font) + } + setBold() { this._sendAction(actions.setBold); } diff --git a/src/WebviewMessageHandler.js b/src/WebviewMessageHandler.js index 05a66ea6..60fc292c 100644 --- a/src/WebviewMessageHandler.js +++ b/src/WebviewMessageHandler.js @@ -170,6 +170,18 @@ export const InjectedMessageHandler = ` case '${actions.setPlatform}': zss_editor.setPlatform(action.data); break; + case '${actions.undo}': + zss_editor.undo(action.data); + break; + case '${actions.redo}': + zss_editor.redo(action.data); + break; + case '${actions.fontSize}': + zss_editor.setFontSize(action.data); + break; + case '${actions.font}': + zss_editor.setFontFamily(action.data); + break; } }; } diff --git a/src/const.js b/src/const.js index 653b43f8..7c94b5fb 100644 --- a/src/const.js +++ b/src/const.js @@ -52,7 +52,11 @@ export const actions = { init: 'ZSSS_INIT', setEditorHeight: 'SET_EDITOR_HEIGHT', setFooterHeight: 'SET_FOOTER_HEIGHT', - setPlatform: 'SET_PLATFORM' + setPlatform: 'SET_PLATFORM', + undo: 'undo', + redo: 'redo', + fontSize: 'font-size', + font: 'font', }; diff --git a/src/editor.html b/src/editor.html index 1b30f937..6e7e545e 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1225,6 +1225,11 @@ } + zss_editor.setFontSize = function (em) { + document.execCommand('fontsize', true, em); + zss_editor.enabledEditingItems(); + } + zss_editor.setTextColor = function(color) { if(zss_editor.currentSelection) { From e3a5c9ad667a0a5c5fb3f415e23d8f2e00bf7911 Mon Sep 17 00:00:00 2001 From: aayush anand Date: Wed, 7 Mar 2018 12:50:31 +0530 Subject: [PATCH 2/2] making fontfamily to work --- src/editor.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/editor.html b/src/editor.html index 6e7e545e..82fec3ad 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1217,7 +1217,9 @@ zss_editor.setFontFamily = function(fontFamily) { - zss_editor.restorerange(); + if (zss_editor.currentSelection) { + zss_editor.restorerange(); + } document.execCommand("styleWithCSS", null, true); document.execCommand("fontName", false, fontFamily); document.execCommand("styleWithCSS", null, false);