mirror of
https://gitee.com/mafgwo/stackedit
synced 2024-11-16 19:57:40 +08:00
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;
|
||||||
|
const hasMore = editorSvc.sectionDescList
|
||||||
|
.some((sectionDesc) => {
|
||||||
if (!sectionDesc.textToPreviewDiffs) {
|
if (!sectionDesc.textToPreviewDiffs) {
|
||||||
|
if (hasOne) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
sectionDesc.previewText = sectionDesc.previewElt.textContent;
|
sectionDesc.previewText = sectionDesc.previewElt.textContent;
|
||||||
sectionDesc.textToPreviewDiffs = diffMatchPatch.diff_main(
|
sectionDesc.textToPreviewDiffs = diffMatchPatch.diff_main(
|
||||||
sectionDesc.section.text, sectionDesc.previewText);
|
sectionDesc.section.text, sectionDesc.previewText);
|
||||||
|
hasOne = true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
if (hasMore) {
|
||||||
|
setTimeout(() => makeOne(), 10);
|
||||||
|
} else {
|
||||||
editorSvc.previewTextWithDiffsList = editorSvc.previewText;
|
editorSvc.previewTextWithDiffsList = editorSvc.previewText;
|
||||||
editorSvc.sectionDescWithDiffsList = editorSvc.sectionDescList;
|
editorSvc.sectionDescWithDiffsList = editorSvc.sectionDescList;
|
||||||
editorSvc.$emit('sectionDescWithDiffsList', editorSvc.sectionDescWithDiffsList);
|
editorSvc.$emit('sectionDescWithDiffsList', editorSvc.sectionDescWithDiffsList);
|
||||||
}
|
}
|
||||||
}, 50),
|
};
|
||||||
|
makeOne();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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