mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-11 18:24:43 +02:00
Fixed revision issue for old revisions
This commit is contained in:
parent
d13b1f96ba
commit
9323caf2f1
@ -45,7 +45,10 @@ export default class Revision extends BaseItem {
|
||||
if (this.isLegacyPatch(patch)) {
|
||||
return this.applyTextPatchLegacy(text, patch);
|
||||
} 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');
|
||||
return result[0];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user