@ones-editor/editor 3.0.14 → 3.0.16-beta.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.
|
@@ -18,6 +18,7 @@ export interface VersionDialogOptions {
|
|
|
18
18
|
onVersionsLoaded?: (sender: unknown, versions: DocVersion[]) => void;
|
|
19
19
|
decorateItem?: (item: HTMLElement, ver: DocVersion) => void;
|
|
20
20
|
onCopyVersionLink?: (ver: DocVersion) => void;
|
|
21
|
+
forceRequestVersionAsLatest?: boolean;
|
|
21
22
|
}
|
|
22
23
|
export type VersionNum = number | string;
|
|
23
24
|
export interface PlayOptions {
|
|
@@ -18,6 +18,7 @@ export declare class OnesEditorVersionsDialog implements OnesEditorCustom {
|
|
|
18
18
|
private handleSelectVersion;
|
|
19
19
|
private handleCompareWithVersion;
|
|
20
20
|
private handleHelp;
|
|
21
|
+
private createVersionFromNum;
|
|
21
22
|
private viewVersion;
|
|
22
23
|
private onMemoChanged;
|
|
23
24
|
private renderContent;
|
package/dist/index.js
CHANGED
|
@@ -6481,6 +6481,10 @@ div.editor-root div.editor-content div[data-type=editor-container] div.embed-blo
|
|
|
6481
6481
|
.version-dialog.loading .version-viewer .version-info-container {
|
|
6482
6482
|
display: none;
|
|
6483
6483
|
}
|
|
6484
|
+
.version-dialog.force-latest-compare .version-viewer .version-info-container,
|
|
6485
|
+
.version-dialog.force-latest-compare .version-list-root {
|
|
6486
|
+
display: none !important;
|
|
6487
|
+
}
|
|
6484
6488
|
.version-dialog .version-loading {
|
|
6485
6489
|
display: flex;
|
|
6486
6490
|
height: 100%;
|
|
@@ -83455,7 +83459,8 @@ ${docStr}
|
|
|
83455
83459
|
this.dropdown.setLabels([]);
|
|
83456
83460
|
if (compareWithVersion) {
|
|
83457
83461
|
this.dropdown.setText(getVersionName(compareWithVersion));
|
|
83458
|
-
|
|
83462
|
+
const latestVersion = this.versions[0];
|
|
83463
|
+
if (compareWithVersion.version === -1 || latestVersion && compareWithVersion.created === latestVersion.created) {
|
|
83459
83464
|
this.dropdown.setLabels([i18n$1.t("version.latest")]);
|
|
83460
83465
|
}
|
|
83461
83466
|
}
|
|
@@ -83861,6 +83866,7 @@ ${docStr}
|
|
|
83861
83866
|
}
|
|
83862
83867
|
}
|
|
83863
83868
|
const logger$y = getLogger("version-dialog");
|
|
83869
|
+
const ForceLatestCompareClass = "force-latest-compare";
|
|
83864
83870
|
class OnesEditorVersionsDialog {
|
|
83865
83871
|
constructor(server, provider, editorOptions) {
|
|
83866
83872
|
__publicField(this, "dialog", null);
|
|
@@ -83904,8 +83910,8 @@ ${docStr}
|
|
|
83904
83910
|
(_b = (_a = this.versionOptions) == null ? void 0 : _a.onHelp) == null ? void 0 : _b.call(_a);
|
|
83905
83911
|
});
|
|
83906
83912
|
__publicField(this, "viewVersion", async (version, compareWithVersion, options) => {
|
|
83907
|
-
var _a, _b, _c, _d, _e;
|
|
83908
|
-
const isLatest = this.versions[0].created === version.created;
|
|
83913
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
83914
|
+
const isLatest = !!this.versions[0] && this.versions[0].created === version.created;
|
|
83909
83915
|
this.components.infoHeader.setVersion(version, compareWithVersion, isLatest);
|
|
83910
83916
|
if (!compareWithVersion && (options == null ? void 0 : options.autoCompareWithLastVersion)) {
|
|
83911
83917
|
compareWithVersion = (_a = this.components.infoHeader.dropdown.getLastVersion()) != null ? _a : void 0;
|
|
@@ -83917,20 +83923,21 @@ ${docStr}
|
|
|
83917
83923
|
this.oldViewer.destroy();
|
|
83918
83924
|
this.oldViewer = null;
|
|
83919
83925
|
}
|
|
83920
|
-
if (!this.versionList) {
|
|
83926
|
+
if (!this.versionList && !((_b = this.versionOptions) == null ? void 0 : _b.forceRequestVersionAsLatest)) {
|
|
83921
83927
|
return;
|
|
83922
83928
|
}
|
|
83923
|
-
if (((
|
|
83929
|
+
if (((_c = this.versionOptions) == null ? void 0 : _c.onWillChangeVersion) && !await this.versionOptions.onWillChangeVersion(this, version)) {
|
|
83924
83930
|
return;
|
|
83925
83931
|
}
|
|
83926
83932
|
this.renderEditorLoading();
|
|
83927
83933
|
const from = compareWithVersion == null ? void 0 : compareWithVersion.version;
|
|
83934
|
+
const forceRequestVersionAsLatest = !!((_d = this.versionOptions) == null ? void 0 : _d.forceRequestVersionAsLatest);
|
|
83928
83935
|
let docObject;
|
|
83929
83936
|
let historyData;
|
|
83930
83937
|
if (from) {
|
|
83931
|
-
const
|
|
83932
|
-
const
|
|
83933
|
-
const ret = await this.versionHelper.getHistoryData(
|
|
83938
|
+
const requestVersion = forceRequestVersionAsLatest ? -1 : Math.max(version.version, from);
|
|
83939
|
+
const requestFrom = forceRequestVersionAsLatest ? from : Math.min(version.version, from);
|
|
83940
|
+
const ret = await this.versionHelper.getHistoryData(requestVersion, requestFrom);
|
|
83934
83941
|
docObject = ret.doc;
|
|
83935
83942
|
historyData = ret.historyData;
|
|
83936
83943
|
} else {
|
|
@@ -83943,7 +83950,7 @@ ${docStr}
|
|
|
83943
83950
|
const viewer = this.provider.createHistoryEditor(editorElement, historyDoc);
|
|
83944
83951
|
viewer.editorBlockRenders.registerRender(new OnesEditorHistoryRender());
|
|
83945
83952
|
viewer.editorBoxes.registerBoxClass(HistoryDeletedTextBox);
|
|
83946
|
-
(
|
|
83953
|
+
(_f = (_e = this.versionOptions) == null ? void 0 : _e.textRenders) == null ? void 0 : _f.forEach((render) => viewer.editorBlockRenders.registerRender(render));
|
|
83947
83954
|
OnesEditorHistoryTooltip.register(viewer);
|
|
83948
83955
|
addClass(viewer.rootElement, HistoryClass.HISTORY);
|
|
83949
83956
|
try {
|
|
@@ -83951,7 +83958,7 @@ ${docStr}
|
|
|
83951
83958
|
} finally {
|
|
83952
83959
|
this.oldViewer = viewer;
|
|
83953
83960
|
}
|
|
83954
|
-
if ((
|
|
83961
|
+
if ((_g = this.versionOptions) == null ? void 0 : _g.onVersionChanged) {
|
|
83955
83962
|
this.versionOptions.onVersionChanged(this, viewer, version);
|
|
83956
83963
|
}
|
|
83957
83964
|
});
|
|
@@ -83989,6 +83996,21 @@ ${docStr}
|
|
|
83989
83996
|
get editor() {
|
|
83990
83997
|
return this.oldViewer;
|
|
83991
83998
|
}
|
|
83999
|
+
createVersionFromNum(versionNum) {
|
|
84000
|
+
if (versionNum === void 0 || versionNum === null) {
|
|
84001
|
+
return void 0;
|
|
84002
|
+
}
|
|
84003
|
+
const parsed = Number(versionNum);
|
|
84004
|
+
if (Number.isNaN(parsed)) {
|
|
84005
|
+
return void 0;
|
|
84006
|
+
}
|
|
84007
|
+
return {
|
|
84008
|
+
version: parsed,
|
|
84009
|
+
created: parsed,
|
|
84010
|
+
versionIndex: 0,
|
|
84011
|
+
tagId: ""
|
|
84012
|
+
};
|
|
84013
|
+
}
|
|
83992
84014
|
renderContent(versions) {
|
|
83993
84015
|
var _a, _b, _c, _d, _e, _f;
|
|
83994
84016
|
const { listContainer: versionsListContainer } = this.components;
|
|
@@ -84017,9 +84039,17 @@ ${docStr}
|
|
|
84017
84039
|
this.versionList = versionList2;
|
|
84018
84040
|
}
|
|
84019
84041
|
initViewVersion() {
|
|
84020
|
-
var _a, _b, _c;
|
|
84042
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84043
|
+
if ((_a = this.versionOptions) == null ? void 0 : _a.forceRequestVersionAsLatest) {
|
|
84044
|
+
const initVersion = this.createVersionFromNum((_b = this.versionOptions) == null ? void 0 : _b.initSelectedVersion);
|
|
84045
|
+
if (initVersion) {
|
|
84046
|
+
const compareWithVersion2 = this.createVersionFromNum((_c = this.versionOptions) == null ? void 0 : _c.compareWith);
|
|
84047
|
+
this.viewVersion(initVersion, compareWithVersion2);
|
|
84048
|
+
}
|
|
84049
|
+
return;
|
|
84050
|
+
}
|
|
84021
84051
|
let compareWithVersion;
|
|
84022
|
-
if ((
|
|
84052
|
+
if ((_d = this.versionOptions) == null ? void 0 : _d.compareWith) {
|
|
84023
84053
|
compareWithVersion = this.versions.find((v) => {
|
|
84024
84054
|
var _a2, _b2;
|
|
84025
84055
|
if (v.version === ((_a2 = this.versionOptions) == null ? void 0 : _a2.compareWith)) {
|
|
@@ -84031,9 +84061,9 @@ ${docStr}
|
|
|
84031
84061
|
return false;
|
|
84032
84062
|
});
|
|
84033
84063
|
}
|
|
84034
|
-
const autoCompareWithLastVersion = (
|
|
84064
|
+
const autoCompareWithLastVersion = (_e = this.versionOptions) == null ? void 0 : _e.autoCompareWithLastVersion;
|
|
84035
84065
|
assert(logger$y, this.versionList, "no versionList");
|
|
84036
|
-
if ((
|
|
84066
|
+
if ((_f = this.versionOptions) == null ? void 0 : _f.initSelectedVersion) {
|
|
84037
84067
|
const { initSelectedVersion: versionNumber } = this.versionOptions;
|
|
84038
84068
|
const version2 = this.versionList.selectVersionByVersionNum(versionNumber);
|
|
84039
84069
|
if (version2) {
|
|
@@ -84068,11 +84098,17 @@ ${docStr}
|
|
|
84068
84098
|
versionsListContainer.append(versionsListHeader, listLoading);
|
|
84069
84099
|
}
|
|
84070
84100
|
async show(options) {
|
|
84101
|
+
var _a, _b, _c, _d;
|
|
84071
84102
|
this.versionOptions = {
|
|
84072
84103
|
...this.versionOptions,
|
|
84073
84104
|
...options
|
|
84074
84105
|
};
|
|
84075
84106
|
const { root: root2 } = this.components;
|
|
84107
|
+
if ((_a = this.versionOptions) == null ? void 0 : _a.forceRequestVersionAsLatest) {
|
|
84108
|
+
addClass(root2, ForceLatestCompareClass);
|
|
84109
|
+
} else {
|
|
84110
|
+
removeClass(root2, ForceLatestCompareClass);
|
|
84111
|
+
}
|
|
84076
84112
|
addClass(root2, "loading");
|
|
84077
84113
|
this.renderListLoading();
|
|
84078
84114
|
this.renderEditorLoading();
|
|
@@ -84080,6 +84116,16 @@ ${docStr}
|
|
|
84080
84116
|
this.dialog = new Dialog$1(root2);
|
|
84081
84117
|
}
|
|
84082
84118
|
this.dialog.show(options.container);
|
|
84119
|
+
const skipVersionsFetch = !!((_b = this.versionOptions) == null ? void 0 : _b.forceRequestVersionAsLatest) && ((_c = this.versionOptions) == null ? void 0 : _c.initSelectedVersion) !== void 0 && ((_d = this.versionOptions) == null ? void 0 : _d.compareWith) !== void 0;
|
|
84120
|
+
if (skipVersionsFetch) {
|
|
84121
|
+
this.versions = [];
|
|
84122
|
+
this.versionList = null;
|
|
84123
|
+
this.components.listContainer.innerHTML = "";
|
|
84124
|
+
this.components.infoHeader.dropdown.setVersions([]);
|
|
84125
|
+
removeClass(this.components.root, "loading");
|
|
84126
|
+
this.initViewVersion();
|
|
84127
|
+
return;
|
|
84128
|
+
}
|
|
84083
84129
|
this.versions = await this.versionHelper.getVersions(options.showPublishedVersions);
|
|
84084
84130
|
removeClass(this.components.root, "loading");
|
|
84085
84131
|
if (this.versionOptions.onVersionsLoaded) {
|
|
@@ -96857,7 +96903,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96857
96903
|
}
|
|
96858
96904
|
}
|
|
96859
96905
|
});
|
|
96860
|
-
editor.version = "3.0.
|
|
96906
|
+
editor.version = "3.0.16-beta.1";
|
|
96861
96907
|
return editor;
|
|
96862
96908
|
}
|
|
96863
96909
|
function isDoc(doc2) {
|
|
@@ -96991,7 +97037,7 @@ ${JSON.stringify(error2, null, 2)}`);
|
|
|
96991
97037
|
OnesEditorDropTarget.register(editor);
|
|
96992
97038
|
OnesEditorTocProvider.register(editor);
|
|
96993
97039
|
OnesEditorExclusiveBlock.register(editor);
|
|
96994
|
-
editor.version = "3.0.
|
|
97040
|
+
editor.version = "3.0.16-beta.1";
|
|
96995
97041
|
return editor;
|
|
96996
97042
|
}
|
|
96997
97043
|
async function showDocVersions(editor, options, serverUrl) {
|