Skip to content
Snippets Groups Projects
Commit ee92a19a authored by chris's avatar chris
Browse files

image fix

parent 88171efc
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ const renderImage = file => {
reader.onload = () => accept(reader.result);
reader.onerror = () => fail(reader.error);
// Some extra delay to make the asynchronicity visible
setTimeout(() => reader.readAsDataURL(file), 150);
setTimeout(() => reader.readAsDataURL(file), 4150);
});
};
......
/* eslint-disable no-underscore-dangle */
import React from 'react';
import React, { useContext } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { isEmpty } from 'lodash';
import { injectable } from 'inversify';
import { ImageUpload } from 'wax-prosemirror-components';
import { Commands, Tools } from 'wax-prosemirror-core';
import { WaxContext, Commands, Tools } from 'wax-prosemirror-core';
import fileUpload from './fileUpload';
@injectable()
......@@ -35,10 +35,12 @@ export default class Image extends Tools {
renderTool(view) {
if (isEmpty(view)) return null;
const context = useContext(WaxContext);
const upload = fileUpload(
view,
this.config.get('fileUpload'),
this.pmplugins.get('imagePlaceHolder'),
context,
);
return this._isDisplayed ? (
<ImageUpload
......
......@@ -6,7 +6,7 @@ const findPlaceholder = (state, id, placeholderPlugin) => {
return found.length ? found[0].from : null;
};
export default (view, fileUpload, placeholderPlugin) => file => {
export default (view, fileUpload, placeholderPlugin, context) => file => {
const { state } = view;
// A fresh object to act as the ID for this upload
const id = {};
......@@ -38,12 +38,12 @@ export default (view, fileUpload, placeholderPlugin) => file => {
}
// Otherwise, insert it at the placeholder's position, and remove
// the placeholder
view.dispatch(
state.tr
context.pmViews.main.dispatch(
context.pmViews.main.state.tr
.replaceWith(
pos,
pos,
view.state.schema.nodes.image.create({
context.pmViews.main.state.schema.nodes.image.create({
src: url,
id: uuidv4(),
extraData,
......
......@@ -20,9 +20,9 @@ export default key =>
});
set = set.add(tr.doc, [deco]);
} else if (action && action.remove) {
// set = set.remove(
// set.find(null, null, spec => spec.id === action.remove.id),
// );
set = set.remove(
set.find(null, null, spec => spec.id === action.remove.id),
);
}
return set;
},
......
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