From be09b290b7754d949a0ff0ee5aceed99d0956b50 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 16 Aug 2018 22:51:51 -0700 Subject: [PATCH] RME upgrade, fix autoFocus logic --- app/scenes/Document/Document.js | 1 - app/scenes/Document/components/Editor.js | 10 ++++++++++ package.json | 2 +- yarn.lock | 6 +++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/scenes/Document/Document.js b/app/scenes/Document/Document.js index 1686205cb..a11f43121 100644 --- a/app/scenes/Document/Document.js +++ b/app/scenes/Document/Document.js @@ -347,7 +347,6 @@ class DocumentScene extends React.Component { onCancel={this.onDiscard} onShowToast={this.onShowToast} readOnly={!this.isEditing} - autoFocus={!document.text} toc /> diff --git a/app/scenes/Document/components/Editor.js b/app/scenes/Document/components/Editor.js index c45fc6040..cb11a2218 100644 --- a/app/scenes/Document/components/Editor.js +++ b/app/scenes/Document/components/Editor.js @@ -41,10 +41,20 @@ schema.document.normalize = ( class Editor extends React.Component { editor: *; + componentDidMount() { + if (!this.props.defaultValue) { + this.focusAtStart(); + } + } + setEditorRef = (ref: RichMarkdownEditor) => { this.editor = ref; }; + focusAtStart = () => { + if (this.editor) this.editor.focusAtStart(); + }; + focusAtEnd = () => { if (this.editor) this.editor.focusAtEnd(); }; diff --git a/package.json b/package.json index 3ea7caf86..3d47ccc10 100644 --- a/package.json +++ b/package.json @@ -158,7 +158,7 @@ "react-waypoint": "^7.3.1", "redis": "^2.6.2", "redis-lock": "^0.1.0", - "rich-markdown-editor": "4.0.0", + "rich-markdown-editor": "5.0.0", "safestart": "1.1.0", "sequelize": "4.28.6", "sequelize-cli": "^2.7.0", diff --git a/yarn.lock b/yarn.lock index f05eceae9..580eee2ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8858,9 +8858,9 @@ retry-axios@0.3.2, retry-axios@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/retry-axios/-/retry-axios-0.3.2.tgz#5757c80f585b4cc4c4986aa2ffd47a60c6d35e13" -rich-markdown-editor@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-4.0.0.tgz#483f2b24867553245b66a8c8f56ec3f8d70ae248" +rich-markdown-editor@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/rich-markdown-editor/-/rich-markdown-editor-5.0.0.tgz#7c581f5ec3a52f749bc7633ea46b9f3d5b113935" dependencies: "@tommoor/slate-drop-or-paste-images" "^0.8.1" babel-plugin-transform-async-to-generator "^6.24.1"