From 3f8eda2223bb057df80f22e9f6f779be3cfeb391 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Wed, 21 Mar 2018 13:24:38 +0000 Subject: [PATCH] Extract rich text code to module --- .../coffee/ide/editor/EditorManager.coffee | 2 -- .../EditorToolbarController.coffee | 7 ---- .../ide/editor/directives/cmEditor.coffee | 33 ------------------- services/web/public/es/rich-text.js | 16 --------- 4 files changed, 58 deletions(-) delete mode 100644 services/web/public/coffee/ide/editor/controllers/EditorToolbarController.coffee delete mode 100644 services/web/public/coffee/ide/editor/directives/cmEditor.coffee delete mode 100644 services/web/public/es/rich-text.js diff --git a/services/web/public/coffee/ide/editor/EditorManager.coffee b/services/web/public/coffee/ide/editor/EditorManager.coffee index 9c4d74e76f..b2b954eaf9 100644 --- a/services/web/public/coffee/ide/editor/EditorManager.coffee +++ b/services/web/public/coffee/ide/editor/EditorManager.coffee @@ -1,9 +1,7 @@ define [ "ide/editor/Document" "ide/editor/directives/aceEditor" - "ide/editor/directives/cmEditor" "ide/editor/controllers/SavingNotificationController" - "ide/editor/controllers/EditorToolbarController" ], (Document) -> class EditorManager constructor: (@ide, @$scope) -> diff --git a/services/web/public/coffee/ide/editor/controllers/EditorToolbarController.coffee b/services/web/public/coffee/ide/editor/controllers/EditorToolbarController.coffee deleted file mode 100644 index 9649899ba8..0000000000 --- a/services/web/public/coffee/ide/editor/controllers/EditorToolbarController.coffee +++ /dev/null @@ -1,7 +0,0 @@ -define [ - "base" - "ide/editor/Document" -], (App, Document) -> - App.controller "EditorToolbarController", ($scope, ide) -> - $scope.toggleRichText = () -> - ide.editorManager.toggleRichText() diff --git a/services/web/public/coffee/ide/editor/directives/cmEditor.coffee b/services/web/public/coffee/ide/editor/directives/cmEditor.coffee deleted file mode 100644 index 37a7724d85..0000000000 --- a/services/web/public/coffee/ide/editor/directives/cmEditor.coffee +++ /dev/null @@ -1,33 +0,0 @@ -define [ - "base" -], (App) -> - App.directive "cmEditor", () -> - return { - scope: { - sharejsDoc: "=" - } - - link: (scope, element, attrs) -> - cm = Frontend.richText.init(element.find('.cm-editor-wrapper')[0]) - - scope.$watch "sharejsDoc", (sharejsDoc, oldSharejsDoc) -> - if oldSharejsDoc? - detachFromCM(oldSharejsDoc) - if sharejsDoc? - attachToCM(sharejsDoc) - - attachToCM = (sharejsDoc) -> - scope.$applyAsync () -> - Frontend.richText.openDoc(cm, sharejsDoc.getSnapshot()) - sharejsDoc.attachToCM(cm) - - detachFromCM = (sharejsDoc) -> - sharejsDoc.detachFromCM() - - scope.$on 'destroy', () -> - detachFromCM(scope.sharejsDoc) - - template: """ -
- """ - } \ No newline at end of file diff --git a/services/web/public/es/rich-text.js b/services/web/public/es/rich-text.js deleted file mode 100644 index 3adac7680c..0000000000 --- a/services/web/public/es/rich-text.js +++ /dev/null @@ -1,16 +0,0 @@ -import CodeMirror, { Doc } from 'codemirror' - -export function init (rootEl) { - CodeMirror.defineMIME('application/x-tex', 'latex') - CodeMirror.defineMIME('application/x-latex', 'latex') - - return CodeMirror(rootEl, { - mode: 'latex' - }) -} - -export function openDoc (cm, content) { - const newDoc = Doc(content, 'latex') - cm.swapDoc(newDoc) - return newDoc -}