mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Instead of setting value of CM, swap Docs
This allows for tracking changes on individual docs (i.e. files), instead of just changes to the editor. This is similar to how Ace works with sessions
This commit is contained in:
parent
eae8b5a592
commit
c85e9ba3b1
2 changed files with 10 additions and 3 deletions
|
@ -17,8 +17,9 @@ define [
|
|||
attachToCM(sharejsDoc)
|
||||
|
||||
attachToCM = (sharejsDoc) ->
|
||||
cm.setValue(sharejsDoc.getSnapshot())
|
||||
sharejsDoc.attachToCM(cm)
|
||||
setTimeout () ->
|
||||
Frontend.richText.openDoc(cm, sharejsDoc.getSnapshot())
|
||||
sharejsDoc.attachToCM(cm)
|
||||
|
||||
detachFromCM = (sharejsDoc) ->
|
||||
sharejsDoc.detachFromCM()
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
import CodeMirror from 'codemirror'
|
||||
import CodeMirror, { Doc } from 'codemirror'
|
||||
|
||||
export function init(rootEl) {
|
||||
return CodeMirror(rootEl)
|
||||
}
|
||||
|
||||
export function openDoc(cm, content) {
|
||||
const newDoc = Doc(content)
|
||||
cm.swapDoc(newDoc)
|
||||
return newDoc
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue