@ones-editor/editor 2.9.8-beta.47 → 2.9.8-beta.49

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/dist/index.d.ts CHANGED
@@ -54,6 +54,7 @@ export declare function getDefaultOnesEditorOptions(options: CreateOnesEditorOpt
54
54
  enableComments: boolean | undefined;
55
55
  enableResolveComments: boolean | undefined;
56
56
  enableContextMenu: boolean | undefined;
57
+ dateTimeFormatter: ((v: Date, source?: string | undefined) => string) | undefined;
57
58
  components: {
58
59
  blocks: import("@ones-editor/core").Block[];
59
60
  embeds: import("@ones-editor/core").Embed[];
package/dist/index.js CHANGED
@@ -31977,7 +31977,7 @@ ${codeText}
31977
31977
  const logger$38 = getLogger("editor");
31978
31978
  class Editor extends tinyTypedEmitter.TypedEmitter {
31979
31979
  constructor(parent, doc2, optionalOptions) {
31980
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
31980
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
31981
31981
  super();
31982
31982
  __publicField(this, "parent");
31983
31983
  __publicField(this, "rootElement");
@@ -32026,12 +32026,13 @@ ${codeText}
32026
32026
  scrollContainer: optionalOptions == null ? void 0 : optionalOptions.scrollContainer,
32027
32027
  enableComments: (_d = optionalOptions == null ? void 0 : optionalOptions.enableComments) != null ? _d : true,
32028
32028
  enableResolveComments: (_e = optionalOptions == null ? void 0 : optionalOptions.enableResolveComments) != null ? _e : true,
32029
- enableContextMenu: (_f = optionalOptions == null ? void 0 : optionalOptions.enableContextMenu) != null ? _f : true
32029
+ enableContextMenu: (_f = optionalOptions == null ? void 0 : optionalOptions.enableContextMenu) != null ? _f : true,
32030
+ dateTimeFormatter: (_g = optionalOptions == null ? void 0 : optionalOptions.dateTimeFormatter) != null ? _g : (v) => v.toLocaleString()
32030
32031
  };
32031
- this.settingsProvider = (_g = optionalOptions == null ? void 0 : optionalOptions.settingsProvider) != null ? _g : new DefaultSettingsProvider(this);
32032
+ this.settingsProvider = (_h = optionalOptions == null ? void 0 : optionalOptions.settingsProvider) != null ? _h : new DefaultSettingsProvider(this);
32032
32033
  registerComponents(this, optionalOptions == null ? void 0 : optionalOptions.components);
32033
- this.blockHooks.push(...(_i = (_h = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _h.blockHooks) != null ? _i : []);
32034
- this.id = (_j = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _j : genId();
32034
+ this.blockHooks.push(...(_j = (_i = optionalOptions == null ? void 0 : optionalOptions.components) == null ? void 0 : _i.blockHooks) != null ? _j : []);
32035
+ this.id = (_k = optionalOptions == null ? void 0 : optionalOptions.id) != null ? _k : genId();
32035
32036
  this.clientId = genId();
32036
32037
  this.undoManager = new UndoManager(this);
32037
32038
  this.doc = new EditorDoc(this, doc2, this.undoManager);
@@ -41651,9 +41652,7 @@ ${codeText}
41651
41652
  const overflowBoundaryRect = overflowBoundary.getBoundingClientRect();
41652
41653
  const topCheck = popperRect.top < overflowBoundaryRect.top;
41653
41654
  const bottomCheck = popperRect.bottom > overflowBoundaryRect.bottom;
41654
- const leftCheck = popperRect.left < overflowBoundaryRect.left;
41655
- const rightCheck = popperRect.right > overflowBoundaryRect.right;
41656
- if (topCheck || bottomCheck || leftCheck || rightCheck) {
41655
+ if (topCheck || bottomCheck) {
41657
41656
  popper.setAttribute("data-tippy-hidden", "");
41658
41657
  } else {
41659
41658
  popper.removeAttribute("data-tippy-hidden");
@@ -42072,6 +42071,9 @@ ${codeText}
42072
42071
  if (parentEditor) {
42073
42072
  const input2 = parentEditor.querySelector(".editor-input");
42074
42073
  if (input2) {
42074
+ if (parentEditor.contains(document.activeElement)) {
42075
+ return;
42076
+ }
42075
42077
  input2.focus();
42076
42078
  }
42077
42079
  }
@@ -80783,7 +80785,7 @@ ${docStr}
80783
80785
  return UnknownFileIcon;
80784
80786
  }
80785
80787
  async function renderFileCard(editor, content, data2) {
80786
- var _a, _b;
80788
+ var _a, _b, _c, _d;
80787
80789
  const { fileName, fileType, fileSize, created, creator, src } = data2;
80788
80790
  const card = createElement("div", ["card-root"], content);
80789
80791
  const icon = createElement("div", ["file-icon"], card);
@@ -80810,14 +80812,14 @@ ${docStr}
80810
80812
  }
80811
80813
  nameElement.title = fileName;
80812
80814
  const infos = createElement("div", ["file-info"], detail);
80813
- const timeText = i18n$1.t("file.uploadedTime", { time: formatDate(new Date(created), "YYYY-MM-DD hh:mm") });
80815
+ const timeText = i18n$1.t("file.uploadedTime", { time: ((_c = (_b = editor.options) == null ? void 0 : _b.dateTimeFormatter) == null ? void 0 : _c.call(_b, new Date(created), "file-embed")) || formatDate(new Date(created), "YYYY-MM-DD hh:mm") });
80814
80816
  const sizeText = formatBytes(fileSize);
80815
80817
  const infoText = `${creator} ${timeText} ${sizeText}`;
80816
80818
  createElement("div", ["info"], infos, infoText);
80817
80819
  const actions2 = createElement("div", ["file-actions"], card);
80818
80820
  const options = editor.getComponentOptions("file");
80819
80821
  let copilotButton;
80820
- const checkCopilotMethod = (_b = editor.getComponentOptions("custom")) == null ? void 0 : _b.checkCopilotReadyItem;
80822
+ const checkCopilotMethod = (_d = editor.getComponentOptions("custom")) == null ? void 0 : _d.checkCopilotReadyItem;
80821
80823
  if (checkCopilotMethod) {
80822
80824
  const copilotEnabled = checkCopilotMethod(src);
80823
80825
  if (copilotEnabled) {
@@ -95420,6 +95422,7 @@ ${JSON.stringify(error2, null, 2)}`);
95420
95422
  enableComments: options == null ? void 0 : options.enableComments,
95421
95423
  enableResolveComments: options == null ? void 0 : options.enableResolveComments,
95422
95424
  enableContextMenu: options == null ? void 0 : options.enableContextMenu,
95425
+ dateTimeFormatter: options.dateTimeFormatter,
95423
95426
  components: {
95424
95427
  blocks: [...StandardBlocks, ...((_d = options == null ? void 0 : options.components) == null ? void 0 : _d.blocks) || []],
95425
95428
  embeds: [...StandardEmbeds, ...((_e = options.components) == null ? void 0 : _e.embeds) || []],
@@ -95652,7 +95655,7 @@ ${JSON.stringify(error2, null, 2)}`);
95652
95655
  }
95653
95656
  }
95654
95657
  });
95655
- editor.version = "2.9.8-beta.47";
95658
+ editor.version = "2.9.8-beta.49";
95656
95659
  return editor;
95657
95660
  }
95658
95661
  function isDoc(doc2) {
@@ -95676,6 +95679,7 @@ ${JSON.stringify(error2, null, 2)}`);
95676
95679
  scrollContainer: options == null ? void 0 : options.scrollContainer,
95677
95680
  enableResolveComments: options == null ? void 0 : options.enableResolveComments,
95678
95681
  enableComments,
95682
+ dateTimeFormatter: options.dateTimeFormatter,
95679
95683
  components: {
95680
95684
  blocks: [...StandardBlocks, ...(_f = (_e = options.components) == null ? void 0 : _e.blocks) != null ? _f : []],
95681
95685
  commandProviders: [new TableBlockCommandProvider()],
@@ -95784,7 +95788,7 @@ ${JSON.stringify(error2, null, 2)}`);
95784
95788
  OnesEditorDropTarget.register(editor);
95785
95789
  OnesEditorTocProvider.register(editor);
95786
95790
  OnesEditorExclusiveBlock.register(editor);
95787
- editor.version = "2.9.8-beta.47";
95791
+ editor.version = "2.9.8-beta.49";
95788
95792
  return editor;
95789
95793
  }
95790
95794
  async function showDocVersions(editor, options, serverUrl) {
package/dist/types.d.ts CHANGED
@@ -75,6 +75,7 @@ export interface CreateOnesEditorOptions {
75
75
  applyContentPlaceholder?: (editor: OnesEditor) => boolean;
76
76
  };
77
77
  onReauth?: (userId: string, docId: string, permission: OnesEditorUserPermission) => Promise<string>;
78
+ dateTimeFormatter?: (v: Date, source?: string) => string;
78
79
  user: {
79
80
  userId: string;
80
81
  displayName: string;
@@ -135,4 +136,5 @@ export interface CreateLocalEditorOptions {
135
136
  componentsOptions?: EditorComponentOptions;
136
137
  hideTitle?: boolean;
137
138
  autoNewLine?: boolean;
139
+ dateTimeFormatter?: (v: Date, source?: string) => string;
138
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.9.8-beta.47",
3
+ "version": "2.9.8-beta.49",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {