From edc81bb380d8b7348d998eb9ad5762f3cd91e87b Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 26 Feb 2021 16:17:05 -0500 Subject: [PATCH] Editor Driver Abstraction (#2594) This will allow drop-in replacements of the editor with a more advanced WYSIWYG solution such as ProseMirror --- framework/core/js/package-lock.json | 5 + framework/core/js/package.json | 1 + framework/core/js/src/common/compat.js | 2 - .../core/js/src/common/utils/SuperTextarea.js | 109 --------------- framework/core/js/src/forum/compat.js | 3 + .../core/js/src/forum/components/Composer.js | 6 +- .../js/src/forum/components/TextEditor.js | 58 +++++--- .../core/js/src/forum/states/ComposerState.js | 9 +- .../js/src/forum/utils/BasicEditorDriver.ts | 124 ++++++++++++++++++ .../src/forum/utils/EditorDriverInterface.ts | 105 +++++++++++++++ framework/core/less/forum/Composer.less | 4 +- 11 files changed, 287 insertions(+), 139 deletions(-) delete mode 100644 framework/core/js/src/common/utils/SuperTextarea.js create mode 100644 framework/core/js/src/forum/utils/BasicEditorDriver.ts create mode 100644 framework/core/js/src/forum/utils/EditorDriverInterface.ts diff --git a/framework/core/js/package-lock.json b/framework/core/js/package-lock.json index 609e9e2fa..8a053610c 100644 --- a/framework/core/js/package-lock.json +++ b/framework/core/js/package-lock.json @@ -4474,6 +4474,11 @@ } } }, + "textarea-caret": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/textarea-caret/-/textarea-caret-3.1.0.tgz", + "integrity": "sha512-cXAvzO9pP5CGa6NKx0WYHl+8CHKZs8byMkt3PCJBCmq2a34YA9pO1NrQET5pzeqnBjBdToF5No4rrmkDUgQC2Q==" + }, "through2": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", diff --git a/framework/core/js/package.json b/framework/core/js/package.json index c6c8aa9b1..770f13ec4 100644 --- a/framework/core/js/package.json +++ b/framework/core/js/package.json @@ -16,6 +16,7 @@ "mithril": "^2.0.4", "punycode": "^2.1.1", "spin.js": "^3.1.0", + "textarea-caret": "^3.1.0", "webpack": "^4.43.0", "webpack-cli": "^3.3.11", "webpack-merge": "^4.1.4" diff --git a/framework/core/js/src/common/compat.js b/framework/core/js/src/common/compat.js index 5df365423..6811fa07d 100644 --- a/framework/core/js/src/common/compat.js +++ b/framework/core/js/src/common/compat.js @@ -19,7 +19,6 @@ import extract from './utils/extract'; import ScrollListener from './utils/ScrollListener'; import stringToColor from './utils/stringToColor'; import subclassOf from './utils/subclassOf'; -import SuperTextarea from './utils/SuperTextarea'; import patchMithril from './utils/patchMithril'; import proxifyCompat from './utils/proxifyCompat'; import classList from './utils/classList'; @@ -92,7 +91,6 @@ export default { 'utils/stringToColor': stringToColor, 'utils/Stream': Stream, 'utils/subclassOf': subclassOf, - 'utils/SuperTextarea': SuperTextarea, 'utils/setRouteWithForcedRefresh': setRouteWithForcedRefresh, 'utils/patchMithril': patchMithril, 'utils/proxifyCompat': proxifyCompat, diff --git a/framework/core/js/src/common/utils/SuperTextarea.js b/framework/core/js/src/common/utils/SuperTextarea.js deleted file mode 100644 index eebb4c487..000000000 --- a/framework/core/js/src/common/utils/SuperTextarea.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - * A textarea wrapper with powerful helpers for text manipulation. - * - * This wraps a