Merge pull request #281 from jorilallo/image-paste

Fix Image paste
This commit is contained in:
Tom Moor
2017-09-29 01:06:29 -04:00
committed by GitHub
3 changed files with 13 additions and 8 deletions

View File

@@ -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,

View File

@@ -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);

View File

@@ -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`;
}