@ones-editor/editor 3.0.2-beta.3 → 3.0.2-beta.5

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
@@ -12484,6 +12484,7 @@ var __publicField = (obj, key, value) => {
12484
12484
  event.stopPropagation();
12485
12485
  return;
12486
12486
  }
12487
+ this.editor.selection.caret.update();
12487
12488
  if (target instanceof HTMLElement && target.draggable) {
12488
12489
  this.editor.selectionHandler.handleMouseDown(event);
12489
12490
  this.editor.selectionHandler.stopSelection();
@@ -26478,23 +26479,23 @@ var __publicField = (obj, key, value) => {
26478
26479
  }
26479
26480
  }
26480
26481
  function moveInputToScreenCenter(editor) {
26481
- const container = getScrollContainer$1(editor.rootContainer);
26482
+ let container = getScrollContainer$1(editor.rootContainer);
26483
+ if (!editor.rootElement.contains(container)) {
26484
+ container = editor.rootElement;
26485
+ }
26482
26486
  const rect = container.getBoundingClientRect();
26483
- const scale = getElementScale(container);
26484
- const windowWidth = window.innerWidth;
26485
- const windowHeight = window.innerHeight;
26486
- const x1 = rect.left < 0 ? 0 : rect.left;
26487
- const y1 = rect.top < 0 ? 0 : rect.top;
26488
- const x2 = rect.right > windowWidth ? windowWidth : rect.right;
26489
- const y2 = rect.bottom > windowHeight ? windowHeight : rect.bottom;
26487
+ const x1 = Math.max(rect.left, 0);
26488
+ const y1 = Math.max(rect.top, 0);
26489
+ const x2 = Math.min(rect.right, window.innerWidth);
26490
+ const y2 = Math.min(rect.bottom, window.innerHeight);
26490
26491
  const centerX = (x1 + x2) / 2;
26491
- const centerY = (y1 + y2) / 2;
26492
+ const centerY = y1 + (y2 - y1) / 4;
26492
26493
  const input2 = editor.input.inputElement;
26493
26494
  const inputHeight = input2.getBoundingClientRect().height;
26494
- const x = 0 - rect.left + centerX;
26495
- const y = 0 - rect.top + centerY + container.scrollTop - inputHeight / 2;
26496
- input2.style.left = `${x / scale}px`;
26497
- input2.style.top = `${y / scale}px`;
26495
+ const x = centerX - rect.left;
26496
+ const y = centerY - rect.top - inputHeight / 2;
26497
+ input2.style.left = `${x}px`;
26498
+ input2.style.top = `${y}px`;
26498
26499
  }
26499
26500
  const logger$3T = getLogger("editor-caret");
26500
26501
  function getFirefoxVersion() {
@@ -83447,20 +83448,33 @@ ${docStr}
83447
83448
  this.versionList = versionList2;
83448
83449
  }
83449
83450
  initViewVersion() {
83450
- var _a, _b;
83451
- const autoCompareWithLastVersion = (_a = this.versionOptions) == null ? void 0 : _a.autoCompareWithLastVersion;
83451
+ var _a, _b, _c;
83452
+ let compareWithVersion;
83453
+ if ((_a = this.versionOptions) == null ? void 0 : _a.compareWith) {
83454
+ compareWithVersion = this.versions.find((v) => {
83455
+ var _a2, _b2;
83456
+ if (v.version === ((_a2 = this.versionOptions) == null ? void 0 : _a2.compareWith)) {
83457
+ return true;
83458
+ }
83459
+ if (getVersionName(v) === ((_b2 = this.versionOptions) == null ? void 0 : _b2.compareWith)) {
83460
+ return true;
83461
+ }
83462
+ return false;
83463
+ });
83464
+ }
83465
+ const autoCompareWithLastVersion = (_b = this.versionOptions) == null ? void 0 : _b.autoCompareWithLastVersion;
83452
83466
  assert(logger$y, this.versionList, "no versionList");
83453
- if ((_b = this.versionOptions) == null ? void 0 : _b.initSelectedVersion) {
83467
+ if ((_c = this.versionOptions) == null ? void 0 : _c.initSelectedVersion) {
83454
83468
  const { initSelectedVersion: versionNumber } = this.versionOptions;
83455
83469
  const version2 = this.versionList.selectVersionByVersionNum(versionNumber);
83456
83470
  if (version2) {
83457
- this.viewVersion(version2, void 0, { autoCompareWithLastVersion });
83471
+ this.viewVersion(version2, compareWithVersion, { autoCompareWithLastVersion });
83458
83472
  return;
83459
83473
  }
83460
83474
  }
83461
83475
  const version = this.versionList.activeVersion;
83462
83476
  if (version) {
83463
- this.viewVersion(version, void 0, { autoCompareWithLastVersion });
83477
+ this.viewVersion(version, compareWithVersion, { autoCompareWithLastVersion });
83464
83478
  }
83465
83479
  }
83466
83480
  renderEditorLoading() {
@@ -96032,7 +96046,7 @@ ${JSON.stringify(error2, null, 2)}`);
96032
96046
  }
96033
96047
  }
96034
96048
  });
96035
- editor.version = "3.0.2-beta.3";
96049
+ editor.version = "3.0.2-beta.5";
96036
96050
  return editor;
96037
96051
  }
96038
96052
  function isDoc(doc2) {
@@ -96166,7 +96180,7 @@ ${JSON.stringify(error2, null, 2)}`);
96166
96180
  OnesEditorDropTarget.register(editor);
96167
96181
  OnesEditorTocProvider.register(editor);
96168
96182
  OnesEditorExclusiveBlock.register(editor);
96169
- editor.version = "3.0.2-beta.3";
96183
+ editor.version = "3.0.2-beta.5";
96170
96184
  return editor;
96171
96185
  }
96172
96186
  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.3",
3
+ "version": "3.0.2-beta.5",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {