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

remove unused file

parent cb837dce
No related branches found
No related tags found
1 merge request!235Images
const findPlaceholder = (state, id, placeholderPlugin) => {
const decos = placeholderPlugin.getState(state);
const found = decos.find(null, null, spec => spec.id === id);
return found.length ? found[0].from : null;
};
export default (view, fileUpload, placeholderPlugin) => file => {
console.log('flffl', fileUpload);
const { state } = view;
// A fresh object to act as the ID for this upload
const id = {};
// Replace the selection with a placeholder
const { tr } = state;
if (!tr.selection.empty) tr.deleteSelection();
tr.setMeta(placeholderPlugin, {
add: { id, pos: tr.selection.from },
});
view.dispatch(tr);
const pos = findPlaceholder(view.state, id, placeholderPlugin);
// If the content around the placeholder has been deleted, drop
// the image
if (pos == null) {
return;
}
// Otherwise, insert it at the placeholder's position, and remove
// the placeholder
view.dispatch(
state.tr
.replaceWith(
pos,
pos,
view.state.schema.nodes.image.create({
src: url,
}),
)
.setMeta(placeholderPlugin, { remove: { id } }),
);
// fileUpload(file).then(
// url => {
// },
// () => {
// // On failure, just clean up the placeholder
// view.dispatch(tr.setMeta(placeholderPlugin, { remove: { id } }));
// }
// );
};
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