mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-23 00:46:16 -04:00
Changeset: Migrate from smartOpAssembler()
to canonicalizeOps()
This commit is contained in:
parent
23e7809b4a
commit
d3d2090ca5
8 changed files with 162 additions and 164 deletions
|
@ -494,21 +494,20 @@ Pad.prototype.copyPadWithoutHistory = async function (destinationID, force) {
|
|||
|
||||
const oldAText = this.atext;
|
||||
|
||||
// based on Changeset.makeSplice
|
||||
const assem = Changeset.smartOpAssembler();
|
||||
for (const op of Changeset.opsFromAText(oldAText)) assem.append(op);
|
||||
assem.endDocument();
|
||||
let newLength;
|
||||
const serializedOps = Changeset.serializeOps((function* () {
|
||||
newLength = yield* Changeset.canonicalizeOps(Changeset.opsFromAText(oldAText), true);
|
||||
})());
|
||||
|
||||
// although we have instantiated the newPad with '\n', an additional '\n' is
|
||||
// added internally, so the pad text on the revision 0 is "\n\n"
|
||||
const oldLength = 2;
|
||||
|
||||
const newLength = assem.getLengthChange();
|
||||
const newText = oldAText.text;
|
||||
|
||||
// create a changeset that removes the previous text and add the newText with
|
||||
// all atributes present on the source pad
|
||||
const changeset = Changeset.pack(oldLength, newLength, assem.toString(), newText);
|
||||
const changeset = Changeset.pack(oldLength, newLength, serializedOps, newText);
|
||||
newPad.appendRevision(changeset);
|
||||
|
||||
await hooks.aCallAll('padCopy', {originalPad: this, destinationID});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue