Fixed discussion offset restore on undo
This commit is contained in:
parent
505df59204
commit
920f34d454
@ -64,12 +64,6 @@ function stripDiscussionOffsets(objectMap) {
|
||||
}
|
||||
|
||||
function restoreDiscussionOffsets(content, markerKeys) {
|
||||
// Init offsets (just in case)
|
||||
Object.keys(content.discussions).forEach((discussionId) => {
|
||||
const discussion = content.discussions[discussionId];
|
||||
discussion.start = 0;
|
||||
discussion.end = 0;
|
||||
});
|
||||
// Go through markers
|
||||
let count = 0;
|
||||
const maxIdx = markerKeys.length;
|
||||
@ -86,6 +80,15 @@ function restoreDiscussionOffsets(content, markerKeys) {
|
||||
count += 1;
|
||||
return '';
|
||||
});
|
||||
Object.keys(content.discussions).forEach((discussionId) => {
|
||||
const discussion = content.discussions[discussionId];
|
||||
if (discussion.start === undefined) {
|
||||
discussion.start = discussion.end || 0;
|
||||
}
|
||||
if (discussion.end === undefined) {
|
||||
discussion.end = discussion.start;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function mergeText(serverText, clientText, lastMergedText) {
|
||||
|
@ -129,6 +129,7 @@ export default {
|
||||
currentPatchableText = diffUtils.makePatchableText(newContent, markerKeys, markerIdxMap);
|
||||
} else {
|
||||
// Take a chance to restore discussion offsets on undo/redo
|
||||
newContent.text = currentPatchableText;
|
||||
diffUtils.restoreDiscussionOffsets(newContent, markerKeys);
|
||||
syncDiscussionMarkers(newContent, false);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import editorSvc from '../editorSvc';
|
||||
|
||||
let editorScrollerElt;
|
||||
let previewScrollerElt;
|
||||
let previewElt;
|
||||
let editorFinishTimeoutId;
|
||||
let previewFinishTimeoutId;
|
||||
let skipAnimation;
|
||||
@ -122,7 +121,6 @@ store.watch(() => store.getters['data/localSettings'].scrollSync, forceScrollSyn
|
||||
editorSvc.$on('inited', () => {
|
||||
editorScrollerElt = editorSvc.editorElt.parentNode;
|
||||
previewScrollerElt = editorSvc.previewElt.parentNode;
|
||||
previewElt = editorSvc.previewElt;
|
||||
|
||||
editorScrollerElt.addEventListener('scroll', () => {
|
||||
if (isEditorMoving) {
|
||||
@ -149,14 +147,7 @@ editorSvc.$on('sectionList', () => {
|
||||
sectionDescList = undefined;
|
||||
});
|
||||
|
||||
editorSvc.$on('conversionCtx', () => {
|
||||
// Set the preview height to prevent scrollbar from jumping
|
||||
previewElt.style.height = `${previewElt.offsetHeight}px`;
|
||||
});
|
||||
|
||||
editorSvc.$on('previewText', () => {
|
||||
// Remove height property once the preview as been refreshed
|
||||
previewElt.style.removeProperty('height');
|
||||
// Assume the user is writing in the editor
|
||||
isScrollEditor = store.getters['layout/styles'].showEditor;
|
||||
// A preview scrolling event can occur if height is smaller
|
||||
|
Loading…
Reference in New Issue
Block a user