@ones-editor/editor 5.0.7-beta.hotfix-release-7-77-0.1 → 5.0.7
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/@ones-editor/core/package.json +3 -0
- package/@ones-editor/server-tools/package.json +2 -1
- package/@ones-editor/server-tools/src/to-markdown/embeds/markdown.d.ts +3 -0
- package/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/@ones-editor/versions/src/types.d.ts +0 -2
- package/@ones-editor/versions/src/version-dialog/version-list.d.ts +0 -1
- package/dist/index.js +82 -107
- package/package.json +1 -1
- package/@ones-editor/sharedb-doc/src/versions/version-ops.d.ts +0 -5
|
@@ -8,8 +8,6 @@ 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;
|
|
13
11
|
getDisabledTip?: () => string | undefined;
|
|
14
12
|
onMemoChanged?: (version: DocVersion) => void;
|
|
15
13
|
onBeforeEditMemo?: () => Promise<boolean>;
|
|
@@ -17,7 +17,6 @@ interface VersionListOptions {
|
|
|
17
17
|
onMemoChanged?: (version: DocVersion) => void;
|
|
18
18
|
onBeforeEditMemo: () => PromiseLike<boolean>;
|
|
19
19
|
useCreatedBy?: boolean;
|
|
20
|
-
formatUserName?: (displayName: string) => string;
|
|
21
20
|
enableEdit: boolean;
|
|
22
21
|
getDisabledTip?: () => string | undefined;
|
|
23
22
|
decorateItem?: (item: HTMLElement, ver: DocVersion) => void;
|
package/dist/index.js
CHANGED
|
@@ -29965,7 +29965,7 @@ var __publicField = (obj, key, value) => {
|
|
|
29965
29965
|
});
|
|
29966
29966
|
return true;
|
|
29967
29967
|
}
|
|
29968
|
-
function defaultGetResourceFromBlock(editor,
|
|
29968
|
+
function defaultGetResourceFromBlock(editor, block, resources) {
|
|
29969
29969
|
if (block.type === "embed") {
|
|
29970
29970
|
const embedData = block.embedData;
|
|
29971
29971
|
if (block.embedType === WIKI_MACRO_TYPE) {
|
|
@@ -30006,43 +30006,23 @@ var __publicField = (obj, key, value) => {
|
|
|
30006
30006
|
}
|
|
30007
30007
|
});
|
|
30008
30008
|
}
|
|
30009
|
-
|
|
30010
|
-
|
|
30011
|
-
|
|
30012
|
-
|
|
30013
|
-
|
|
30014
|
-
|
|
30015
|
-
|
|
30016
|
-
|
|
30009
|
+
}
|
|
30010
|
+
function getResourcesFromBlock(editor, doc2, block, resources) {
|
|
30011
|
+
var _a, _b;
|
|
30012
|
+
const blockClass = editor.editorBlocks.getBlockClass(block.type);
|
|
30013
|
+
const declaredResources = (_a = blockClass.getResources) == null ? void 0 : _a.call(blockClass, editor, block);
|
|
30014
|
+
if (declaredResources) {
|
|
30015
|
+
declaredResources.forEach((resource) => resources.add(resource));
|
|
30016
|
+
} else {
|
|
30017
|
+
defaultGetResourceFromBlock(editor, block, resources);
|
|
30017
30018
|
}
|
|
30019
|
+
(_b = block.children) == null ? void 0 : _b.forEach((containerId) => {
|
|
30020
|
+
doc2.blocks[containerId].forEach((child) => getResourcesFromBlock(editor, doc2, child, resources));
|
|
30021
|
+
});
|
|
30018
30022
|
}
|
|
30019
30023
|
function getAllResourcesFromDoc(editor, doc2) {
|
|
30020
30024
|
const resources = /* @__PURE__ */ new Set();
|
|
30021
|
-
|
|
30022
|
-
blocks.forEach((block) => {
|
|
30023
|
-
const blockClass = editor.editorBlocks.getBlockClass(block.type);
|
|
30024
|
-
if (blockClass.getResources) {
|
|
30025
|
-
const ret = blockClass.getResources(editor, block);
|
|
30026
|
-
if (ret) {
|
|
30027
|
-
ret.forEach((resource) => {
|
|
30028
|
-
resources.add(resource);
|
|
30029
|
-
});
|
|
30030
|
-
const children = block.children;
|
|
30031
|
-
if (children) {
|
|
30032
|
-
children.forEach((childContainerId) => {
|
|
30033
|
-
const blocks2 = doc2.blocks[childContainerId];
|
|
30034
|
-
blocks2.forEach((b) => {
|
|
30035
|
-
defaultGetResourceFromBlock(editor, doc2, b, resources);
|
|
30036
|
-
});
|
|
30037
|
-
});
|
|
30038
|
-
}
|
|
30039
|
-
} else {
|
|
30040
|
-
defaultGetResourceFromBlock(editor, doc2, block, resources);
|
|
30041
|
-
}
|
|
30042
|
-
} else {
|
|
30043
|
-
defaultGetResourceFromBlock(editor, doc2, block, resources);
|
|
30044
|
-
}
|
|
30045
|
-
});
|
|
30025
|
+
doc2.blocks.root.forEach((block) => getResourcesFromBlock(editor, doc2, block, resources));
|
|
30046
30026
|
return Array.from(resources);
|
|
30047
30027
|
}
|
|
30048
30028
|
function injectDocToHtmlFragment(htmlFragment, doc2) {
|
|
@@ -30355,8 +30335,14 @@ ${codeText}
|
|
|
30355
30335
|
}
|
|
30356
30336
|
return true;
|
|
30357
30337
|
}
|
|
30358
|
-
function defaultReplaceBlockResources(doc2, block, resources) {
|
|
30338
|
+
function defaultReplaceBlockResources(editor, doc2, block, resources) {
|
|
30339
|
+
var _a;
|
|
30359
30340
|
if (block.type === "embed") {
|
|
30341
|
+
const blockClass = editor.editorBlocks.getBlockClass(block.type);
|
|
30342
|
+
const declaredResources = (_a = blockClass.getResources) == null ? void 0 : _a.call(blockClass, editor, block);
|
|
30343
|
+
if (declaredResources && declaredResources.length === 0) {
|
|
30344
|
+
return;
|
|
30345
|
+
}
|
|
30360
30346
|
const embedData = block.embedData;
|
|
30361
30347
|
if (block.embedType === WIKI_MACRO_TYPE) {
|
|
30362
30348
|
replaceWikiMacroResources(embedData, resources);
|
|
@@ -30401,23 +30387,26 @@ ${codeText}
|
|
|
30401
30387
|
children.forEach((childContainerId) => {
|
|
30402
30388
|
const blocks = doc2.blocks[childContainerId];
|
|
30403
30389
|
blocks.forEach((b) => {
|
|
30404
|
-
|
|
30390
|
+
replaceBlockResources(editor, doc2, b, resources);
|
|
30405
30391
|
});
|
|
30406
30392
|
});
|
|
30407
30393
|
}
|
|
30408
30394
|
}
|
|
30395
|
+
function replaceBlockResources(editor, doc2, block, resources) {
|
|
30396
|
+
const blockClass = editor.editorBlocks.getBlockClass(block.type);
|
|
30397
|
+
if (blockClass.replaceResources) {
|
|
30398
|
+
blockClass.replaceResources(block, resources);
|
|
30399
|
+
} else {
|
|
30400
|
+
defaultReplaceBlockResources(editor, doc2, block, resources);
|
|
30401
|
+
}
|
|
30402
|
+
}
|
|
30409
30403
|
function replaceDocResources(editor, doc2, resources) {
|
|
30410
30404
|
if (resources.size === 0) {
|
|
30411
30405
|
return;
|
|
30412
30406
|
}
|
|
30413
30407
|
const blocks = doc2.blocks.root;
|
|
30414
30408
|
blocks.forEach((block) => {
|
|
30415
|
-
|
|
30416
|
-
if (blockClass.replaceResources) {
|
|
30417
|
-
blockClass.replaceResources(block, resources);
|
|
30418
|
-
} else {
|
|
30419
|
-
defaultReplaceBlockResources(doc2, block, resources);
|
|
30420
|
-
}
|
|
30409
|
+
replaceBlockResources(editor, doc2, block, resources);
|
|
30421
30410
|
});
|
|
30422
30411
|
}
|
|
30423
30412
|
async function addLocalResourcesToDoc(editor, resources) {
|
|
@@ -38695,57 +38684,6 @@ ${codeText}
|
|
|
38695
38684
|
};
|
|
38696
38685
|
var Connection = connection;
|
|
38697
38686
|
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
|
-
}
|
|
38749
38687
|
const AuthError = {
|
|
38750
38688
|
err: 1001,
|
|
38751
38689
|
msg: "user auth error",
|
|
@@ -39462,7 +39400,27 @@ ${codeText}
|
|
|
39462
39400
|
api += `&from=${from}`;
|
|
39463
39401
|
}
|
|
39464
39402
|
const ret = await this.request(api);
|
|
39465
|
-
|
|
39403
|
+
const ops = ret.data.ops;
|
|
39404
|
+
const createdDocIndex = findLastIndex__default.default(ops, (op) => !!op.create);
|
|
39405
|
+
let createdDoc = null;
|
|
39406
|
+
if (createdDocIndex !== -1) {
|
|
39407
|
+
createdDoc = ops[createdDocIndex];
|
|
39408
|
+
ops.splice(0, createdDocIndex + 1);
|
|
39409
|
+
}
|
|
39410
|
+
let doc2;
|
|
39411
|
+
if (createdDoc) {
|
|
39412
|
+
assert(logger$30, createdDoc.create, "no createDoc.create");
|
|
39413
|
+
doc2 = createdDoc.create.data;
|
|
39414
|
+
} else {
|
|
39415
|
+
doc2 = JSON.parse(ret.data.data);
|
|
39416
|
+
}
|
|
39417
|
+
if (!doc2.blocks) {
|
|
39418
|
+
doc2.blocks = [];
|
|
39419
|
+
}
|
|
39420
|
+
return {
|
|
39421
|
+
doc: doc2,
|
|
39422
|
+
ops: ret.data.ops
|
|
39423
|
+
};
|
|
39466
39424
|
}
|
|
39467
39425
|
async updateVersionExtra(version, tagId, extra) {
|
|
39468
39426
|
const server = this.apiServer();
|
|
@@ -41330,7 +41288,27 @@ ${codeText}
|
|
|
41330
41288
|
api += `&from=${from}`;
|
|
41331
41289
|
}
|
|
41332
41290
|
const ret = await this.request(api);
|
|
41333
|
-
|
|
41291
|
+
const ops = ret.data.ops;
|
|
41292
|
+
const createdDocIndex = findLastIndex__default.default(ops, (op) => !!op.create);
|
|
41293
|
+
let createdDoc = null;
|
|
41294
|
+
if (createdDocIndex !== -1) {
|
|
41295
|
+
createdDoc = ops[createdDocIndex];
|
|
41296
|
+
ops.splice(0, createdDocIndex + 1);
|
|
41297
|
+
}
|
|
41298
|
+
let doc2;
|
|
41299
|
+
if (createdDoc) {
|
|
41300
|
+
assert(logger$2S, createdDoc.create, "no createDoc.create");
|
|
41301
|
+
doc2 = createdDoc.create.data;
|
|
41302
|
+
} else {
|
|
41303
|
+
doc2 = JSON.parse(ret.data.data);
|
|
41304
|
+
}
|
|
41305
|
+
if (!doc2.blocks) {
|
|
41306
|
+
doc2.blocks = [];
|
|
41307
|
+
}
|
|
41308
|
+
return {
|
|
41309
|
+
doc: doc2,
|
|
41310
|
+
ops: ret.data.ops
|
|
41311
|
+
};
|
|
41334
41312
|
}
|
|
41335
41313
|
async updateVersionExtra(version, tagId, extra) {
|
|
41336
41314
|
const server = this.apiServer();
|
|
@@ -83228,15 +83206,13 @@ ${docStr}
|
|
|
83228
83206
|
createElement("li", ["version-item-time"], info, formatDate(new Date(ver.version), "YYYY-MM-DD hh:mm"));
|
|
83229
83207
|
const authors = createElement("ul", ["version-item-authors"], info);
|
|
83230
83208
|
const addUser = (user) => {
|
|
83231
|
-
var _a2, _b2, _c2;
|
|
83232
83209
|
const author = createElement("li", ["version-item-author"], authors);
|
|
83233
83210
|
const markAuthor = createElement("span", ["version-item-author-mark"], author);
|
|
83234
83211
|
markAuthor.style.background = this.options.getMarkColor(user);
|
|
83235
|
-
const
|
|
83236
|
-
const authorName = createElement("span", ["version-item-author-name"], author, displayName);
|
|
83212
|
+
const authorName = createElement("span", ["version-item-author-name"], author, user.displayName);
|
|
83237
83213
|
authorName.setAttribute(
|
|
83238
83214
|
"data-editor-tooltip-common",
|
|
83239
|
-
i18n$1.t("version.tooltip.user", { name: displayName })
|
|
83215
|
+
i18n$1.t("version.tooltip.user", { name: user.displayName })
|
|
83240
83216
|
);
|
|
83241
83217
|
};
|
|
83242
83218
|
if (this.options.useCreatedBy) {
|
|
@@ -84766,7 +84742,7 @@ ${docStr}
|
|
|
84766
84742
|
};
|
|
84767
84743
|
}
|
|
84768
84744
|
renderContent(versions) {
|
|
84769
|
-
var _a, _b, _c, _d, _e, _f
|
|
84745
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84770
84746
|
const { listContainer: versionsListContainer } = this.components;
|
|
84771
84747
|
versionsListContainer.innerHTML = "";
|
|
84772
84748
|
const versionList2 = new VersionList({
|
|
@@ -84778,13 +84754,12 @@ ${docStr}
|
|
|
84778
84754
|
})),
|
|
84779
84755
|
versionHelper: this.versionHelper,
|
|
84780
84756
|
useCreatedBy: (_c = this.versionOptions) == null ? void 0 : _c.useCreatedBy,
|
|
84781
|
-
formatUserName: (_d = this.versionOptions) == null ? void 0 : _d.formatUserName,
|
|
84782
84757
|
onSelectVersion: this.handleSelectVersion,
|
|
84783
84758
|
onRevert: this.handleRevert,
|
|
84784
|
-
onCopyLink: ((
|
|
84759
|
+
onCopyLink: ((_d = this.versionOptions) == null ? void 0 : _d.onCopyVersionLink) ? this.handleCopyLink : void 0,
|
|
84785
84760
|
onMemoChanged: this.onMemoChanged,
|
|
84786
|
-
decorateItem: (
|
|
84787
|
-
onBeforeEditMemo: ((
|
|
84761
|
+
decorateItem: (_e = this.versionOptions) == null ? void 0 : _e.decorateItem,
|
|
84762
|
+
onBeforeEditMemo: ((_f = this.versionOptions) == null ? void 0 : _f.onBeforeEditMemo) || (async () => true),
|
|
84788
84763
|
getMarkColor: (user) => {
|
|
84789
84764
|
const { flag } = getUserColors(this.server.getRemoteUsers(), user);
|
|
84790
84765
|
return flag;
|
|
@@ -98069,7 +98044,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98069
98044
|
}
|
|
98070
98045
|
}
|
|
98071
98046
|
});
|
|
98072
|
-
editor.version = "5.0.7
|
|
98047
|
+
editor.version = "5.0.7";
|
|
98073
98048
|
return editor;
|
|
98074
98049
|
}
|
|
98075
98050
|
function isDoc(doc2) {
|
|
@@ -98205,7 +98180,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98205
98180
|
OnesEditorDropTarget.register(editor);
|
|
98206
98181
|
OnesEditorTocProvider.register(editor);
|
|
98207
98182
|
OnesEditorExclusiveBlock.register(editor);
|
|
98208
|
-
editor.version = "5.0.7
|
|
98183
|
+
editor.version = "5.0.7";
|
|
98209
98184
|
return editor;
|
|
98210
98185
|
} catch (error2) {
|
|
98211
98186
|
try {
|
|
@@ -98348,7 +98323,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
98348
98323
|
}
|
|
98349
98324
|
}
|
|
98350
98325
|
});
|
|
98351
|
-
editor.version = "5.0.7
|
|
98326
|
+
editor.version = "5.0.7";
|
|
98352
98327
|
return editor;
|
|
98353
98328
|
}
|
|
98354
98329
|
const emojis$1 = {
|
package/package.json
CHANGED