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

remove only image and don't crash on lists

parent d8df3f22
No related branches found
No related tags found
1 merge request!147Fixes
import markDeletion from './markDeletion'; import markDeletion from './markDeletion';
import markInsertion from './markInsertion'; import markInsertion from './markInsertion';
import markWrapping from './markWrapping'; import markWrapping from './markWrapping';
import { liftListItem } from 'prosemirror-schema-list';
const replaceAroundStep = ( const replaceAroundStep = (
state, state,
...@@ -45,8 +46,8 @@ const replaceAroundStep = ( ...@@ -45,8 +46,8 @@ const replaceAroundStep = (
); );
} }
} else { } else {
console.log('to fix'); console.log('to fix lift list item');
newTr.step(step); // newTr.step(step);
const ranges = [ const ranges = [
{ {
from: step.getMap().map(step.from, -1), from: step.getMap().map(step.from, -1),
...@@ -57,12 +58,18 @@ const replaceAroundStep = ( ...@@ -57,12 +58,18 @@ const replaceAroundStep = (
to: step.getMap().map(step.to), to: step.getMap().map(step.to),
}, },
]; ];
ranges.forEach(range => ranges.forEach(range =>
doc.nodesBetween(range.from, range.to, (node, pos) => { doc.nodesBetween(range.from, range.to, (node, pos) => {
if (pos < range.from) { if (pos < range.from) {
return true; return true;
} }
markInsertion(newTr, range.from, range.to, user, date); liftListItem(node.type)(state, newTr => {
newTr.steps.forEach(step => {
tr.step(step);
map.appendMap(step.getMap());
});
});
}), }),
); );
} }
......
...@@ -27,7 +27,11 @@ const trackedTransaction = (tr, state, user) => { ...@@ -27,7 +27,11 @@ const trackedTransaction = (tr, state, user) => {
// images // images
if (tr.meta.inputType === 'backwardsDelete' && !tr.steps.lenght) { if (tr.meta.inputType === 'backwardsDelete' && !tr.steps.lenght) {
const $pos = state.selection.$anchor; const $pos = state.selection.$anchor;
if ($pos.depth === 1) return tr; let node;
if ($pos.depth === 1) {
node = $pos.node($pos.depth);
if (node.content.content[0].type.name === 'image') return tr;
}
} }
if ( if (
......
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