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

fix cursor movement on lists

parent 5c8e8a0b
No related branches found
No related tags found
1 merge request!107Tracked transaction
......@@ -48,12 +48,13 @@ const Editoria = () => (
placeholder="Type Something..."
fileUpload={file => renderImage(file)}
value={
'<p class="paragraph">this is <span class="deletion user-1234" data-id="" data-user="1234" data-username="demo" data-date="26486384" data-group="">some</span> content</p><ul> <li> <p> some li text</p></li><li> <p> some li second text</p></li><li> <p> some li third text</p></li></ul><p class="paragraph">second paragraph</p>'
'<p class="paragraph">this is</p><p class="paragraph">this is <span class="deletion user-1234" data-id="" data-user="1234" data-username="demo" data-date="26486384" data-group="">some</span> content</p><ul> <li> <p> some li text</p></li><li> <p> some li second text</p></li><li> <p> some li third text</p></li></ul><p class="paragraph">second paragraph</p>'
}
layout={EditoriaLayout}
TrackChange
// onChange={source => console.log(source)}
user={user}
debug
/>
</Fragment>
);
......
......@@ -28,6 +28,7 @@ const replaceStep = (state, tr, step, newTr, map, doc, user, date) => {
step.structure
)
: false;
// We didn't apply the original step in its original place. We adjust the map accordingly.
map.appendMap(step.invert(doc).getMap());
if (newStep) {
......
......@@ -45,12 +45,15 @@ const trackedTransaction = (tr, state, user) => {
switch (step.constructor) {
case ReplaceStep:
console.log("ReplaceStep");
replaceStep(state, tr, step, newTr, map, doc, user, date);
break;
case ReplaceAroundStep:
console.log("ReplaceAroundStep");
replaceAroundStep(state, tr, step, newTr, map, doc, user, date);
break;
case AddMarkStep:
console.log("AddMarkStep");
addMarkStep(state, tr, step, newTr, map, doc, user, date);
break;
case RemoveMarkStep:
......@@ -85,9 +88,19 @@ const trackedTransaction = (tr, state, user) => {
const caretPos = map.map(deletionMark.to + 1, 1);
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
} else {
console.log("not");
newTr.setSelection(tr.selection.map(newTr.doc, map));
}
} else {
if (
state.selection.from - tr.selection.from > 1 &&
tr.selection.$head.depth > 1
) {
const caretPos = map.map(tr.selection.from - 2, -1);
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
} else {
const caretPos = map.map(tr.selection.from, -1);
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
}
}
if (tr.storedMarksSet) {
newTr.setStoredMarks(tr.storedMarks);
......@@ -95,13 +108,6 @@ const trackedTransaction = (tr, state, user) => {
if (tr.scrolledIntoView) {
newTr.scrollIntoView();
}
if (
tr.selection instanceof TextSelection &&
tr.selection.from < state.selection.from
) {
const caretPos = map.map(tr.selection.from, -1);
newTr.setSelection(new TextSelection(newTr.doc.resolve(caretPos)));
}
return newTr;
};
......
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