1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Fixed revision issue for old revisions

This commit is contained in:
Laurent Cozic
2021-06-20 13:59:58 +01:00
parent d13b1f96ba
commit 9323caf2f1

View File

@@ -45,7 +45,10 @@ export default class Revision extends BaseItem {
if (this.isLegacyPatch(patch)) { if (this.isLegacyPatch(patch)) {
return this.applyTextPatchLegacy(text, patch); return this.applyTextPatchLegacy(text, patch);
} else { } else {
const result = dmp.patch_apply(JSON.parse(patch), text); // An empty patch should be '[]', but legacy data may be just "".
// However an empty string would make JSON.parse fail so we set it
// to '[]'.
const result = dmp.patch_apply(JSON.parse(patch ? patch : '[]'), text);
if (!result || !result.length) throw new Error('Could not apply patch'); if (!result || !result.length) throw new Error('Could not apply patch');
return result[0]; return result[0];
} }