(Firefox) Fix certain chunks not updating when editing

I don't know why Firefox is so weird but we need to do this or else
some chunks don't update properly when you edit multiple chunks at the
same time.

One example of when this happened is when you have a story with at least
one chunk other than the prompt. Then, if you select the entire story
except for the first few characters of the prompt and then delete the
selected characters, and then defocus the story to save your changes,
the last chunk in the story will not register as having been deleted,
which you can verify if you refresh the page.

Another example. If your story has a chunk with no trailing newlines
followed by a chunk with exactly two leading newlines, if you delete
the first newline from the latter chunk and then defocus to save your
edits, the newline will be there again when you refresh the page.
This commit is contained in:
Gnome Ann 2021-09-27 23:10:34 -04:00
parent 3297c27fcd
commit e8cefcc2c6
1 changed files with 2 additions and 5 deletions

View File

@ -950,11 +950,8 @@ function chunkOnDOMMutate(mutations, observer) {
var nodes = [];
for(var i = 0; i < mutations.length; i++) {
var mutation = mutations[i];
if(mutation.type === "childList") {
nodes = nodes.concat(Array.from(mutation.addedNodes), Array.from(mutation.removedNodes));
} else {
nodes.push(mutation.target);
}
nodes = nodes.concat(Array.from(mutation.addedNodes), Array.from(mutation.removedNodes));
nodes.push(mutation.target);
}
applyChunkDeltas(nodes);
}