@ones-editor/editor 5.0.6 → 5.0.7-beta.HBFB2296126.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -38695,6 +38695,57 @@ ${codeText}
|
|
|
38695
38695
|
};
|
|
38696
38696
|
var Connection = connection;
|
|
38697
38697
|
var types = types$3;
|
|
38698
|
+
function getContainers(doc2) {
|
|
38699
|
+
return Object.fromEntries(Object.entries(doc2).filter(([, value]) => Array.isArray(value) && value.every((block) => block && typeof block === "object" && block.id && block.type)));
|
|
38700
|
+
}
|
|
38701
|
+
function replaceDocOp(before, after) {
|
|
38702
|
+
const oldContainers = getContainers(before);
|
|
38703
|
+
const newContainers = getContainers(after);
|
|
38704
|
+
let result = null;
|
|
38705
|
+
for (const containerId of /* @__PURE__ */ new Set([...Object.keys(oldContainers), ...Object.keys(newContainers)])) {
|
|
38706
|
+
const oldBlocks = oldContainers[containerId];
|
|
38707
|
+
const newBlocks = newContainers[containerId] || [];
|
|
38708
|
+
if (!oldBlocks) {
|
|
38709
|
+
result = json1__namespace.type.compose(result, json1__namespace.insertOp([containerId], newBlocks));
|
|
38710
|
+
continue;
|
|
38711
|
+
}
|
|
38712
|
+
for (let index2 = oldBlocks.length - 1; index2 >= 0; index2--) {
|
|
38713
|
+
result = json1__namespace.type.compose(result, json1__namespace.removeOp([containerId, index2]));
|
|
38714
|
+
}
|
|
38715
|
+
for (let index2 = 0; index2 < newBlocks.length; index2++) {
|
|
38716
|
+
result = json1__namespace.type.compose(result, json1__namespace.insertOp([containerId, index2], newBlocks[index2]));
|
|
38717
|
+
}
|
|
38718
|
+
}
|
|
38719
|
+
return result || [];
|
|
38720
|
+
}
|
|
38721
|
+
function parseVersionOps(data2, ops, from) {
|
|
38722
|
+
var _a;
|
|
38723
|
+
const createdDocIndex = findLastIndex__default.default(ops, (op) => !!op.create);
|
|
38724
|
+
if (from === void 0 || from <= 0 || createdDocIndex === -1) {
|
|
38725
|
+
const createdDoc = (_a = ops[createdDocIndex]) == null ? void 0 : _a.create;
|
|
38726
|
+
const doc22 = createdDoc ? createdDoc.data : JSON.parse(data2);
|
|
38727
|
+
return { doc: { ...doc22, blocks: doc22.blocks || [] }, ops: ops.slice(createdDocIndex + 1) };
|
|
38728
|
+
}
|
|
38729
|
+
const baseline = JSON.parse(data2);
|
|
38730
|
+
const doc2 = { ...baseline, blocks: baseline.blocks || [] };
|
|
38731
|
+
let current = doc2;
|
|
38732
|
+
const historyOps = [];
|
|
38733
|
+
for (const item of ops) {
|
|
38734
|
+
if (item.create) {
|
|
38735
|
+
const op = replaceDocOp(current, item.create.data);
|
|
38736
|
+
if (op.length) {
|
|
38737
|
+
const historyOp = { ...item, op };
|
|
38738
|
+
delete historyOp.create;
|
|
38739
|
+
historyOps.push(historyOp);
|
|
38740
|
+
}
|
|
38741
|
+
current = item.create.data;
|
|
38742
|
+
} else if (item.op) {
|
|
38743
|
+
historyOps.push(item);
|
|
38744
|
+
current = json1__namespace.type.apply(current, item.op);
|
|
38745
|
+
}
|
|
38746
|
+
}
|
|
38747
|
+
return { doc: doc2, ops: historyOps };
|
|
38748
|
+
}
|
|
38698
38749
|
const AuthError = {
|
|
38699
38750
|
err: 1001,
|
|
38700
38751
|
msg: "user auth error",
|
|
@@ -39411,27 +39462,7 @@ ${codeText}
|
|
|
39411
39462
|
api += `&from=${from}`;
|
|
39412
39463
|
}
|
|
39413
39464
|
const ret = await this.request(api);
|
|
39414
|
-
|
|
39415
|
-
const createdDocIndex = findLastIndex__default.default(ops, (op) => !!op.create);
|
|
39416
|
-
let createdDoc = null;
|
|
39417
|
-
if (createdDocIndex !== -1) {
|
|
39418
|
-
createdDoc = ops[createdDocIndex];
|
|
39419
|
-
ops.splice(0, createdDocIndex + 1);
|
|
39420
|
-
}
|
|
39421
|
-
let doc2;
|
|
39422
|
-
if (createdDoc) {
|
|
39423
|
-
assert(logger$30, createdDoc.create, "no createDoc.create");
|
|
39424
|
-
doc2 = createdDoc.create.data;
|
|
39425
|
-
} else {
|
|
39426
|
-
doc2 = JSON.parse(ret.data.data);
|
|
39427
|
-
}
|
|
39428
|
-
if (!doc2.blocks) {
|
|
39429
|
-
doc2.blocks = [];
|
|
39430
|
-
}
|
|
39431
|
-
return {
|
|
39432
|
-
doc: doc2,
|
|
39433
|
-
ops: ret.data.ops
|
|
39434
|
-
};
|
|
39465
|
+
return parseVersionOps(ret.data.data, ret.data.ops, from);
|
|
39435
39466
|
}
|
|
39436
39467
|
async updateVersionExtra(version, tagId, extra) {
|
|
39437
39468
|
const server = this.apiServer();
|
|
@@ -41299,27 +41330,7 @@ ${codeText}
|
|
|
41299
41330
|
api += `&from=${from}`;
|
|
41300
41331
|
}
|
|
41301
41332
|
const ret = await this.request(api);
|
|
41302
|
-
|
|
41303
|
-
const createdDocIndex = findLastIndex__default.default(ops, (op) => !!op.create);
|
|
41304
|
-
let createdDoc = null;
|
|
41305
|
-
if (createdDocIndex !== -1) {
|
|
41306
|
-
createdDoc = ops[createdDocIndex];
|
|
41307
|
-
ops.splice(0, createdDocIndex + 1);
|
|
41308
|
-
}
|
|
41309
|
-
let doc2;
|
|
41310
|
-
if (createdDoc) {
|
|
41311
|
-
assert(logger$2S, createdDoc.create, "no createDoc.create");
|
|
41312
|
-
doc2 = createdDoc.create.data;
|
|
41313
|
-
} else {
|
|
41314
|
-
doc2 = JSON.parse(ret.data.data);
|
|
41315
|
-
}
|
|
41316
|
-
if (!doc2.blocks) {
|
|
41317
|
-
doc2.blocks = [];
|
|
41318
|
-
}
|
|
41319
|
-
return {
|
|
41320
|
-
doc: doc2,
|
|
41321
|
-
ops: ret.data.ops
|
|
41322
|
-
};
|
|
41333
|
+
return parseVersionOps(ret.data.data, ret.data.ops, from);
|
|
41323
41334
|
}
|
|
41324
41335
|
async updateVersionExtra(version, tagId, extra) {
|
|
41325
41336
|
const server = this.apiServer();
|
|
@@ -98055,7 +98066,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98055
98066
|
}
|
|
98056
98067
|
}
|
|
98057
98068
|
});
|
|
98058
|
-
editor.version = "5.0.
|
|
98069
|
+
editor.version = "5.0.7-beta.HBFB2296126.1";
|
|
98059
98070
|
return editor;
|
|
98060
98071
|
}
|
|
98061
98072
|
function isDoc(doc2) {
|
|
@@ -98191,7 +98202,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98191
98202
|
OnesEditorDropTarget.register(editor);
|
|
98192
98203
|
OnesEditorTocProvider.register(editor);
|
|
98193
98204
|
OnesEditorExclusiveBlock.register(editor);
|
|
98194
|
-
editor.version = "5.0.
|
|
98205
|
+
editor.version = "5.0.7-beta.HBFB2296126.1";
|
|
98195
98206
|
return editor;
|
|
98196
98207
|
} catch (error2) {
|
|
98197
98208
|
try {
|
|
@@ -98334,7 +98345,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98334
98345
|
}
|
|
98335
98346
|
}
|
|
98336
98347
|
});
|
|
98337
|
-
editor.version = "5.0.
|
|
98348
|
+
editor.version = "5.0.7-beta.HBFB2296126.1";
|
|
98338
98349
|
return editor;
|
|
98339
98350
|
}
|
|
98340
98351
|
const emojis$1 = {
|