mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-26 18:21:09 +00:00
Extract rich text code to module
This commit is contained in:
parent
1a0154c9ea
commit
3f8eda2223
4 changed files with 0 additions and 58 deletions
|
@ -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) ->
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
define [
|
||||
"base"
|
||||
"ide/editor/Document"
|
||||
], (App, Document) ->
|
||||
App.controller "EditorToolbarController", ($scope, ide) ->
|
||||
$scope.toggleRichText = () ->
|
||||
ide.editorManager.toggleRichText()
|
|
@ -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: """
|
||||
<div class="cm-editor-wrapper"></div>
|
||||
"""
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue