mirror of
https://github.com/logseq/logseq.git
synced 2026-05-03 10:26:35 +00:00
Merge pull request #1072 from logseq/enhance/undo-redo
Enhance/undo redo
This commit is contained in:
@@ -178,3 +178,17 @@ export const triggerInputChange = (node, value = '', name = 'change') => {
|
||||
node.dispatchEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from https://github.com/google/diff-match-patch/issues/29#issuecomment-647627182
|
||||
export const reversePatch = patch => {
|
||||
return patch.map(patchObj => ({
|
||||
diffs: patchObj.diffs.map(([ op, val ]) => [
|
||||
op * -1, // The money maker
|
||||
val
|
||||
]),
|
||||
start1: patchObj.start2,
|
||||
start2: patchObj.start1,
|
||||
length1: patchObj.length2,
|
||||
length2: patchObj.length1
|
||||
}));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user