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

replace paragraph with image if paragraph is already empty

parent 14cd20a8
No related branches found
No related tags found
1 merge request!519Move tool groups
......@@ -30,7 +30,7 @@ export default (view, fileUpload, placeholderPlugin, context) => file => {
extraData = fileData.extraData;
}
const pos = findPlaceholder(view.state, id, placeholderPlugin);
let pos = findPlaceholder(view.state, id, placeholderPlugin);
// If the content around the placeholder has been deleted, drop
// the image
if (pos == null) {
......@@ -38,6 +38,12 @@ export default (view, fileUpload, placeholderPlugin, context) => file => {
}
// Otherwise, insert it at the placeholder's position, and remove
// the placeholder
// if paragraph is empty don't break into new line
if (context.pmViews.main.state.doc.resolve(pos).parent.nodeSize === 2) {
pos -= 1;
}
context.setOption({ uploading: false });
context.pmViews.main.dispatch(
context.pmViews.main.state.tr
......
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