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