From 26a3f2c7e362bb9da1f18a97fbdc48069ca943d2 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 28 Sep 2017 20:36:29 -0700 Subject: [PATCH 1/2] Refactor to routeHelpers --- frontend/scenes/Document/Document.js | 11 ++++------- frontend/utils/routeHelpers.js | 8 ++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index 7bdb80236..3db9f3b07 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -12,6 +12,8 @@ import { collectionUrl, updateDocumentUrl, documentMoveUrl, + documentEditUrl, + documentNewUrl, matchDocumentEdit, matchDocumentMove, } from 'utils/routeHelpers'; @@ -57,7 +59,6 @@ type Props = { @observable isSaving = false; @observable showAsSaved = false; @observable notFound = false; - @observable moveModalOpen: boolean = false; componentWillMount() { @@ -144,16 +145,12 @@ type Props = { onClickEdit = () => { if (!this.document) return; - const url = `${this.document.url}/edit`; - this.props.history.push(url); + this.props.history.push(documentEditUrl(this.document)); }; onClickNew = () => { if (!this.document) return; - let newUrl = `${this.document.collection.url}/new`; - if (this.document.parentDocumentId) - newUrl = `${newUrl}?parentDocument=${this.document.parentDocumentId}`; - this.props.history.push(newUrl); + this.props.history.push(documentNewUrl(this.document)); }; handleCloseMoveModal = () => (this.moveModalOpen = false); diff --git a/frontend/utils/routeHelpers.js b/frontend/utils/routeHelpers.js index 707e4a82c..4db4200f7 100644 --- a/frontend/utils/routeHelpers.js +++ b/frontend/utils/routeHelpers.js @@ -22,6 +22,14 @@ export function documentUrl(doc: Document): string { return doc.url; } +export function documentNewUrl(doc: Document): string { + const newUrl = `${doc.collection.url}/new`; + if (doc.parentDocumentId) { + return `${newUrl}?parentDocument=${doc.parentDocumentId}`; + } + return newUrl; +} + export function documentEditUrl(doc: Document): string { return `${doc.url}/edit`; } From 6ae3e51ae106c9ada2e82d837c21813cefdf6b3e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 28 Sep 2017 21:32:26 -0700 Subject: [PATCH 2/2] Fixes #280 - Image pasting --- frontend/components/Editor/plugins.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/components/Editor/plugins.js b/frontend/components/Editor/plugins.js index e5b026aef..c487df2a6 100644 --- a/frontend/components/Editor/plugins.js +++ b/frontend/components/Editor/plugins.js @@ -25,7 +25,7 @@ const createPlugins = ({ onImageUploadStart, onImageUploadStop }: Options) => { }), DropOrPasteImages({ extensions: ['png', 'jpg', 'gif'], - applyTransform: (transform, editor, file) => { + applyTransform: (transform, file, editor) => { return insertImage( transform, file,