@ones-editor/editor 3.0.2-beta.2 → 3.0.2-beta.4

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.
@@ -7,6 +7,7 @@ export interface VersionDialogOptions {
7
7
  enableEdit?: boolean;
8
8
  textRenders?: OnesEditorBlockRenderer[];
9
9
  autoCompareWithLastVersion?: boolean;
10
+ compareWith?: VersionNum;
10
11
  getDisabledTip?: () => string | undefined;
11
12
  onMemoChanged?: (version: DocVersion) => void;
12
13
  onBeforeEditMemo?: () => Promise<boolean>;
package/dist/index.js CHANGED
@@ -40832,15 +40832,8 @@ ${codeText}
40832
40832
  super();
40833
40833
  __publicField(this, "remoteUsers", new RemoteUsers());
40834
40834
  __publicField(this, "client");
40835
- __publicField(this, "copyLink");
40836
40835
  this.options = options;
40837
40836
  this.client = new ShareDBSimpleClient(options.auth, options.serverUrl);
40838
- if (options.onCopyVersionLink) {
40839
- this.copyLink = (v) => {
40840
- var _a;
40841
- (_a = options.onCopyVersionLink) == null ? void 0 : _a.call(options, v);
40842
- };
40843
- }
40844
40837
  }
40845
40838
  destroy() {
40846
40839
  }
@@ -83324,7 +83317,7 @@ ${docStr}
83324
83317
  if (!version) {
83325
83318
  return;
83326
83319
  }
83327
- (_c = (_b = this.versionHelper).copyLink) == null ? void 0 : _c.call(_b, version);
83320
+ (_c = (_b = this.versionOptions) == null ? void 0 : _b.onCopyVersionLink) == null ? void 0 : _c.call(_b, version);
83328
83321
  });
83329
83322
  __publicField(this, "handleSelectVersion", (version) => {
83330
83323
  assert(logger$y, version, `The version: ${version} is invalid`);
@@ -83427,7 +83420,7 @@ ${docStr}
83427
83420
  return this.oldViewer;
83428
83421
  }
83429
83422
  renderContent(versions) {
83430
- var _a, _b, _c, _d, _e;
83423
+ var _a, _b, _c, _d, _e, _f;
83431
83424
  const { listContainer: versionsListContainer } = this.components;
83432
83425
  versionsListContainer.innerHTML = "";
83433
83426
  const versionList2 = new VersionList({
@@ -83441,10 +83434,10 @@ ${docStr}
83441
83434
  useCreatedBy: (_c = this.versionOptions) == null ? void 0 : _c.useCreatedBy,
83442
83435
  onSelectVersion: this.handleSelectVersion,
83443
83436
  onRevert: this.handleRevert,
83444
- onCopyLink: this.versionHelper.copyLink ? this.handleCopyLink : void 0,
83437
+ onCopyLink: ((_d = this.versionOptions) == null ? void 0 : _d.onCopyVersionLink) ? this.handleCopyLink : void 0,
83445
83438
  onMemoChanged: this.onMemoChanged,
83446
- decorateItem: (_d = this.versionOptions) == null ? void 0 : _d.decorateItem,
83447
- onBeforeEditMemo: ((_e = this.versionOptions) == null ? void 0 : _e.onBeforeEditMemo) || (async () => true),
83439
+ decorateItem: (_e = this.versionOptions) == null ? void 0 : _e.decorateItem,
83440
+ onBeforeEditMemo: ((_f = this.versionOptions) == null ? void 0 : _f.onBeforeEditMemo) || (async () => true),
83448
83441
  getMarkColor: (user) => {
83449
83442
  const { flag } = getUserColors(this.server.getRemoteUsers(), user);
83450
83443
  return flag;
@@ -83454,20 +83447,33 @@ ${docStr}
83454
83447
  this.versionList = versionList2;
83455
83448
  }
83456
83449
  initViewVersion() {
83457
- var _a, _b;
83458
- const autoCompareWithLastVersion = (_a = this.versionOptions) == null ? void 0 : _a.autoCompareWithLastVersion;
83450
+ var _a, _b, _c;
83451
+ let compareWithVersion;
83452
+ if ((_a = this.versionOptions) == null ? void 0 : _a.compareWith) {
83453
+ compareWithVersion = this.versions.find((v) => {
83454
+ var _a2, _b2;
83455
+ if (v.version === ((_a2 = this.versionOptions) == null ? void 0 : _a2.compareWith)) {
83456
+ return true;
83457
+ }
83458
+ if (getVersionName(v) === ((_b2 = this.versionOptions) == null ? void 0 : _b2.compareWith)) {
83459
+ return true;
83460
+ }
83461
+ return false;
83462
+ });
83463
+ }
83464
+ const autoCompareWithLastVersion = (_b = this.versionOptions) == null ? void 0 : _b.autoCompareWithLastVersion;
83459
83465
  assert(logger$y, this.versionList, "no versionList");
83460
- if ((_b = this.versionOptions) == null ? void 0 : _b.initSelectedVersion) {
83466
+ if ((_c = this.versionOptions) == null ? void 0 : _c.initSelectedVersion) {
83461
83467
  const { initSelectedVersion: versionNumber } = this.versionOptions;
83462
83468
  const version2 = this.versionList.selectVersionByVersionNum(versionNumber);
83463
83469
  if (version2) {
83464
- this.viewVersion(version2, void 0, { autoCompareWithLastVersion });
83470
+ this.viewVersion(version2, compareWithVersion, { autoCompareWithLastVersion });
83465
83471
  return;
83466
83472
  }
83467
83473
  }
83468
83474
  const version = this.versionList.activeVersion;
83469
83475
  if (version) {
83470
- this.viewVersion(version, void 0, { autoCompareWithLastVersion });
83476
+ this.viewVersion(version, compareWithVersion, { autoCompareWithLastVersion });
83471
83477
  }
83472
83478
  }
83473
83479
  renderEditorLoading() {
@@ -96039,7 +96045,7 @@ ${JSON.stringify(error2, null, 2)}`);
96039
96045
  }
96040
96046
  }
96041
96047
  });
96042
- editor.version = "3.0.2-beta.2";
96048
+ editor.version = "3.0.2-beta.4";
96043
96049
  return editor;
96044
96050
  }
96045
96051
  function isDoc(doc2) {
@@ -96173,7 +96179,7 @@ ${JSON.stringify(error2, null, 2)}`);
96173
96179
  OnesEditorDropTarget.register(editor);
96174
96180
  OnesEditorTocProvider.register(editor);
96175
96181
  OnesEditorExclusiveBlock.register(editor);
96176
- editor.version = "3.0.2-beta.2";
96182
+ editor.version = "3.0.2-beta.4";
96177
96183
  return editor;
96178
96184
  }
96179
96185
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "3.0.2-beta.2",
3
+ "version": "3.0.2-beta.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {