mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 05:41:33 +02:00
Create cmEditor directive to connect to ShareJS
This commit is contained in:
@@ -428,6 +428,9 @@ define [
|
||||
if rendererData?
|
||||
rendererData.lineHeight = editor.renderer.lineHeight
|
||||
|
||||
scope.$on '$destroy', () ->
|
||||
detachFromAce(scope.sharejsDoc)
|
||||
|
||||
template: """
|
||||
<div class="ace-editor-wrapper">
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
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) ->
|
||||
cm.setValue(sharejsDoc.getSnapshot())
|
||||
sharejsDoc.attachToCM(cm)
|
||||
|
||||
detachFromCM = (sharejsDoc) ->
|
||||
sharejsDoc.detachFromCM()
|
||||
|
||||
scope.$on 'destroy', () ->
|
||||
detachFromCM(scope.sharejsDoc)
|
||||
|
||||
template: """
|
||||
<div class="cm-editor-wrapper"></div>
|
||||
"""
|
||||
}
|
||||
@@ -75,8 +75,9 @@
|
||||
top: 40px;
|
||||
}
|
||||
|
||||
#editor {
|
||||
#editor, #editor-rich-text {
|
||||
.full-size;
|
||||
top: 40px; // TODO: replace with toolbar height var
|
||||
}
|
||||
|
||||
.loading-screen {
|
||||
@@ -190,6 +191,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
.cm-editor-wrapper {
|
||||
height: 100%;
|
||||
|
||||
.CodeMirror {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
// The internal components of the aceEditor directive
|
||||
.ace-editor-wrapper {
|
||||
.full-size;
|
||||
|
||||
Reference in New Issue
Block a user