Fixed text to preview diffs
This commit is contained in:
parent
0dd787a4e6
commit
fdfafc9519
@ -31,7 +31,6 @@ export default class PreviewClassApplier {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
editorSvc.$on('previewHtml', this.restoreClass);
|
|
||||||
editorSvc.$on('sectionDescWithDiffsList', this.restoreClass);
|
editorSvc.$on('sectionDescWithDiffsList', this.restoreClass);
|
||||||
nextTick(() => this.applyClass());
|
nextTick(() => this.applyClass());
|
||||||
}
|
}
|
||||||
|
@ -233,23 +233,36 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils,
|
|||||||
/**
|
/**
|
||||||
* Make the diff between editor's markdown and preview's html.
|
* Make the diff between editor's markdown and preview's html.
|
||||||
*/
|
*/
|
||||||
makeTextToPreviewDiffs: allowDebounce(() => {
|
makeTextToPreviewDiffs() {
|
||||||
if (editorSvc.sectionDescList &&
|
if (editorSvc.sectionDescList &&
|
||||||
editorSvc.sectionDescList !== editorSvc.sectionDescWithDiffsList
|
editorSvc.sectionDescList !== editorSvc.sectionDescWithDiffsList
|
||||||
) {
|
) {
|
||||||
editorSvc.sectionDescList
|
const makeOne = () => {
|
||||||
.forEach((sectionDesc) => {
|
let hasOne = false;
|
||||||
if (!sectionDesc.textToPreviewDiffs) {
|
const hasMore = editorSvc.sectionDescList
|
||||||
sectionDesc.previewText = sectionDesc.previewElt.textContent;
|
.some((sectionDesc) => {
|
||||||
sectionDesc.textToPreviewDiffs = diffMatchPatch.diff_main(
|
if (!sectionDesc.textToPreviewDiffs) {
|
||||||
sectionDesc.section.text, sectionDesc.previewText);
|
if (hasOne) {
|
||||||
}
|
return true;
|
||||||
});
|
}
|
||||||
editorSvc.previewTextWithDiffsList = editorSvc.previewText;
|
sectionDesc.previewText = sectionDesc.previewElt.textContent;
|
||||||
editorSvc.sectionDescWithDiffsList = editorSvc.sectionDescList;
|
sectionDesc.textToPreviewDiffs = diffMatchPatch.diff_main(
|
||||||
editorSvc.$emit('sectionDescWithDiffsList', editorSvc.sectionDescWithDiffsList);
|
sectionDesc.section.text, sectionDesc.previewText);
|
||||||
|
hasOne = true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (hasMore) {
|
||||||
|
setTimeout(() => makeOne(), 10);
|
||||||
|
} else {
|
||||||
|
editorSvc.previewTextWithDiffsList = editorSvc.previewText;
|
||||||
|
editorSvc.sectionDescWithDiffsList = editorSvc.sectionDescList;
|
||||||
|
editorSvc.$emit('sectionDescWithDiffsList', editorSvc.sectionDescWithDiffsList);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
makeOne();
|
||||||
}
|
}
|
||||||
}, 50),
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save editor selection/scroll state into the current file content.
|
* Save editor selection/scroll state into the current file content.
|
||||||
|
Loading…
Reference in New Issue
Block a user