Skip to content
Snippets Groups Projects
Commit 2af7c829 authored by chris's avatar chris Committed by Yannis Barlas
Browse files

you can write in editor once again

parent 938074e7
No related branches found
No related tags found
No related merge requests found
...@@ -4,14 +4,12 @@ import { ...@@ -4,14 +4,12 @@ import {
// deleteCharacter, // deleteCharacter,
// deleteSelection, // deleteSelection,
keys as keyboardKeys, keys as keyboardKeys,
Surface,
uuid uuid
} from 'substance' } from 'substance'
class ContainerEditor extends SubstanceContainerEditor { class ContainerEditor extends SubstanceContainerEditor {
render ($$) { render ($$) {
// TODO -- call with super let el = super.render($$)
var el = Surface.prototype.render.call(this, $$)
var doc = this.getDocument() var doc = this.getDocument()
var containerId = this.getContainerId() var containerId = this.getContainerId()
...@@ -29,9 +27,9 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -29,9 +27,9 @@ class ContainerEditor extends SubstanceContainerEditor {
// if it IS empty, handle in didMount // if it IS empty, handle in didMount
if (!this.isEmpty()) { if (!this.isEmpty()) {
containerNode.getNodes().forEach(function (node) { // containerNode.getNodes().forEach(function (node) {
el.append(this._renderNode($$, node).ref(node.id)) // el.append(this._renderNode($$, node).ref(node.id))
}.bind(this)) // }.bind(this))
} }
// open for editing // open for editing
...@@ -44,21 +42,21 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -44,21 +42,21 @@ class ContainerEditor extends SubstanceContainerEditor {
return el return el
} }
//
didMount () { didMount () {
super.didMount() super.didMount()
if (this.isEmpty()) this.createText() if (this.isEmpty()) this.createText()
this.focus() this.focus() // TODO notworking
if (this.isReadOnlyMode()) { // if (this.isReadOnlyMode()) {
const documentSession = this.getDocumentSession() // const documentSession = this.getDocumentSession()
documentSession.on('didUpdate', this.disableToolbar, this) // documentSession.on('didUpdate', this.disableToolbar, this)
//
this.addTargetToLinks() // this.addTargetToLinks()
} // }
} }
//
onTextInput (event) { onTextInput (event) {
if (!this.props.trackChanges) return super.onTextInput(event) if (!this.props.trackChanges) return super.onTextInput(event)
...@@ -159,7 +157,7 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -159,7 +157,7 @@ class ContainerEditor extends SubstanceContainerEditor {
createText () { createText () {
var newSel var newSel
this.transaction(function (tx) { this.editorSession.transaction(function (tx) {
var container = tx.get(this.props.containerId) var container = tx.get(this.props.containerId)
var textType = tx.getSchema().getDefaultTextType() var textType = tx.getSchema().getDefaultTextType()
...@@ -180,7 +178,7 @@ class ContainerEditor extends SubstanceContainerEditor { ...@@ -180,7 +178,7 @@ class ContainerEditor extends SubstanceContainerEditor {
}.bind(this)) }.bind(this))
this.rerender() this.rerender()
this.setSelection(newSel) this.editorSession.setSelection(newSel)
} }
// only runs if editor is in read-only mode // only runs if editor is in read-only mode
......
...@@ -41,8 +41,8 @@ class Editor extends ProseEditor { ...@@ -41,8 +41,8 @@ class Editor extends ProseEditor {
willUpdateState () {} willUpdateState () {}
didMount () { didMount () {
this.documentSession.on('didUpdate', this.documentSessionUpdated, this) // this.documentSession.on('didUpdate', this.documentSessionUpdated, this)
this.documentSession.on('fileUploadTrigger', this.handleUpload, this) // this.documentSession.on('fileUploadTrigger', this.handleUpload, this)
this.extendState({ editorReady: true }) this.extendState({ editorReady: true })
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment