From 2af7c82933edb682957628ce965ff8fa22782e9f Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Wed, 15 Feb 2017 18:06:13 +0200 Subject: [PATCH] you can write in editor once again --- .../SimpleEditor/ContainerEditor.js | 34 +++++++++---------- app/components/SimpleEditor/Editor.js | 4 +-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/components/SimpleEditor/ContainerEditor.js b/app/components/SimpleEditor/ContainerEditor.js index a848bab..7dc30b3 100644 --- a/app/components/SimpleEditor/ContainerEditor.js +++ b/app/components/SimpleEditor/ContainerEditor.js @@ -4,14 +4,12 @@ import { // deleteCharacter, // deleteSelection, keys as keyboardKeys, - Surface, uuid } from 'substance' class ContainerEditor extends SubstanceContainerEditor { render ($$) { - // TODO -- call with super - var el = Surface.prototype.render.call(this, $$) + let el = super.render($$) var doc = this.getDocument() var containerId = this.getContainerId() @@ -29,9 +27,9 @@ class ContainerEditor extends SubstanceContainerEditor { // if it IS empty, handle in didMount if (!this.isEmpty()) { - containerNode.getNodes().forEach(function (node) { - el.append(this._renderNode($$, node).ref(node.id)) - }.bind(this)) + // containerNode.getNodes().forEach(function (node) { + // el.append(this._renderNode($$, node).ref(node.id)) + // }.bind(this)) } // open for editing @@ -44,21 +42,21 @@ class ContainerEditor extends SubstanceContainerEditor { return el } - + // didMount () { super.didMount() if (this.isEmpty()) this.createText() - this.focus() - - if (this.isReadOnlyMode()) { - const documentSession = this.getDocumentSession() - documentSession.on('didUpdate', this.disableToolbar, this) - - this.addTargetToLinks() - } + this.focus() // TODO notworking + + // if (this.isReadOnlyMode()) { + // const documentSession = this.getDocumentSession() + // documentSession.on('didUpdate', this.disableToolbar, this) + // + // this.addTargetToLinks() + // } } - + // onTextInput (event) { if (!this.props.trackChanges) return super.onTextInput(event) @@ -159,7 +157,7 @@ class ContainerEditor extends SubstanceContainerEditor { createText () { var newSel - this.transaction(function (tx) { + this.editorSession.transaction(function (tx) { var container = tx.get(this.props.containerId) var textType = tx.getSchema().getDefaultTextType() @@ -180,7 +178,7 @@ class ContainerEditor extends SubstanceContainerEditor { }.bind(this)) this.rerender() - this.setSelection(newSel) + this.editorSession.setSelection(newSel) } // only runs if editor is in read-only mode diff --git a/app/components/SimpleEditor/Editor.js b/app/components/SimpleEditor/Editor.js index 96b8e05..a44b839 100644 --- a/app/components/SimpleEditor/Editor.js +++ b/app/components/SimpleEditor/Editor.js @@ -41,8 +41,8 @@ class Editor extends ProseEditor { willUpdateState () {} didMount () { - this.documentSession.on('didUpdate', this.documentSessionUpdated, this) - this.documentSession.on('fileUploadTrigger', this.handleUpload, this) + // this.documentSession.on('didUpdate', this.documentSessionUpdated, this) + // this.documentSession.on('fileUploadTrigger', this.handleUpload, this) this.extendState({ editorReady: true }) } -- GitLab