@ones-editor/editor 5.0.6 → 5.0.7-beta.hotfix-release-7-77-0.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.
|
@@ -8,6 +8,8 @@ export interface VersionDialogOptions {
|
|
|
8
8
|
textRenders?: OnesEditorBlockRenderer[];
|
|
9
9
|
autoCompareWithLastVersion?: boolean;
|
|
10
10
|
compareWith?: VersionNum;
|
|
11
|
+
/** Formats author names for display without changing stored version metadata. */
|
|
12
|
+
formatUserName?: (displayName: string) => string;
|
|
11
13
|
getDisabledTip?: () => string | undefined;
|
|
12
14
|
onMemoChanged?: (version: DocVersion) => void;
|
|
13
15
|
onBeforeEditMemo?: () => Promise<boolean>;
|
|
@@ -17,6 +17,7 @@ interface VersionListOptions {
|
|
|
17
17
|
onMemoChanged?: (version: DocVersion) => void;
|
|
18
18
|
onBeforeEditMemo: () => PromiseLike<boolean>;
|
|
19
19
|
useCreatedBy?: boolean;
|
|
20
|
+
formatUserName?: (displayName: string) => string;
|
|
20
21
|
enableEdit: boolean;
|
|
21
22
|
getDisabledTip?: () => string | undefined;
|
|
22
23
|
decorateItem?: (item: HTMLElement, ver: DocVersion) => void;
|
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();
|
|
@@ -83217,13 +83228,15 @@ ${docStr}
|
|
|
83217
83228
|
createElement("li", ["version-item-time"], info, formatDate(new Date(ver.version), "YYYY-MM-DD hh:mm"));
|
|
83218
83229
|
const authors = createElement("ul", ["version-item-authors"], info);
|
|
83219
83230
|
const addUser = (user) => {
|
|
83231
|
+
var _a2, _b2, _c2;
|
|
83220
83232
|
const author = createElement("li", ["version-item-author"], authors);
|
|
83221
83233
|
const markAuthor = createElement("span", ["version-item-author-mark"], author);
|
|
83222
83234
|
markAuthor.style.background = this.options.getMarkColor(user);
|
|
83223
|
-
const
|
|
83235
|
+
const displayName = (_c2 = (_b2 = (_a2 = this.options).formatUserName) == null ? void 0 : _b2.call(_a2, user.displayName)) != null ? _c2 : user.displayName;
|
|
83236
|
+
const authorName = createElement("span", ["version-item-author-name"], author, displayName);
|
|
83224
83237
|
authorName.setAttribute(
|
|
83225
83238
|
"data-editor-tooltip-common",
|
|
83226
|
-
i18n$1.t("version.tooltip.user", { name:
|
|
83239
|
+
i18n$1.t("version.tooltip.user", { name: displayName })
|
|
83227
83240
|
);
|
|
83228
83241
|
};
|
|
83229
83242
|
if (this.options.useCreatedBy) {
|
|
@@ -84753,7 +84766,7 @@ ${docStr}
|
|
|
84753
84766
|
};
|
|
84754
84767
|
}
|
|
84755
84768
|
renderContent(versions) {
|
|
84756
|
-
var _a, _b, _c, _d, _e, _f;
|
|
84769
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
84757
84770
|
const { listContainer: versionsListContainer } = this.components;
|
|
84758
84771
|
versionsListContainer.innerHTML = "";
|
|
84759
84772
|
const versionList2 = new VersionList({
|
|
@@ -84765,12 +84778,13 @@ ${docStr}
|
|
|
84765
84778
|
})),
|
|
84766
84779
|
versionHelper: this.versionHelper,
|
|
84767
84780
|
useCreatedBy: (_c = this.versionOptions) == null ? void 0 : _c.useCreatedBy,
|
|
84781
|
+
formatUserName: (_d = this.versionOptions) == null ? void 0 : _d.formatUserName,
|
|
84768
84782
|
onSelectVersion: this.handleSelectVersion,
|
|
84769
84783
|
onRevert: this.handleRevert,
|
|
84770
|
-
onCopyLink: ((
|
|
84784
|
+
onCopyLink: ((_e = this.versionOptions) == null ? void 0 : _e.onCopyVersionLink) ? this.handleCopyLink : void 0,
|
|
84771
84785
|
onMemoChanged: this.onMemoChanged,
|
|
84772
|
-
decorateItem: (
|
|
84773
|
-
onBeforeEditMemo: ((
|
|
84786
|
+
decorateItem: (_f = this.versionOptions) == null ? void 0 : _f.decorateItem,
|
|
84787
|
+
onBeforeEditMemo: ((_g = this.versionOptions) == null ? void 0 : _g.onBeforeEditMemo) || (async () => true),
|
|
84774
84788
|
getMarkColor: (user) => {
|
|
84775
84789
|
const { flag } = getUserColors(this.server.getRemoteUsers(), user);
|
|
84776
84790
|
return flag;
|
|
@@ -98055,7 +98069,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98055
98069
|
}
|
|
98056
98070
|
}
|
|
98057
98071
|
});
|
|
98058
|
-
editor.version = "5.0.
|
|
98072
|
+
editor.version = "5.0.7-beta.hotfix-release-7-77-0.1";
|
|
98059
98073
|
return editor;
|
|
98060
98074
|
}
|
|
98061
98075
|
function isDoc(doc2) {
|
|
@@ -98191,7 +98205,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98191
98205
|
OnesEditorDropTarget.register(editor);
|
|
98192
98206
|
OnesEditorTocProvider.register(editor);
|
|
98193
98207
|
OnesEditorExclusiveBlock.register(editor);
|
|
98194
|
-
editor.version = "5.0.
|
|
98208
|
+
editor.version = "5.0.7-beta.hotfix-release-7-77-0.1";
|
|
98195
98209
|
return editor;
|
|
98196
98210
|
} catch (error2) {
|
|
98197
98211
|
try {
|
|
@@ -98334,7 +98348,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98334
98348
|
}
|
|
98335
98349
|
}
|
|
98336
98350
|
});
|
|
98337
|
-
editor.version = "5.0.
|
|
98351
|
+
editor.version = "5.0.7-beta.hotfix-release-7-77-0.1";
|
|
98338
98352
|
return editor;
|
|
98339
98353
|
}
|
|
98340
98354
|
const emojis$1 = {
|