@ones-editor/editor 2.3.0-beta.11 → 2.3.0-beta.13

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,7 +7,6 @@ export default class ErrorInfoBar {
7
7
  private message;
8
8
  private _hideTimer;
9
9
  private _adjustParentInterval;
10
- private _messageText;
11
10
  private _type;
12
11
  constructor(editor: OnesEditor);
13
12
  show(message: string, type: BarType): void;
@@ -16,5 +15,4 @@ export default class ErrorInfoBar {
16
15
  destroy(): void;
17
16
  private findParent;
18
17
  private autoAdjustParent;
19
- private getErrorMessage;
20
18
  }
@@ -1,7 +1,8 @@
1
- import { OnesEditor } from '../../@ones-editor/core';
1
+ import { ErrorHandler, OnesEditor, UploadResourceErrorDialogOptions } from '../../@ones-editor/core';
2
2
  import { AuthMessage } from '../../@ones-editor/sharedb-doc';
3
+ import { AlertDialog } from '../../@ones-editor/ui-base';
3
4
  import ErrorInfoBar from './error-info-bar';
4
- export default class DefaultErrorHandler {
5
+ export default class DefaultErrorHandler implements ErrorHandler {
5
6
  private _editor;
6
7
  private _errorInfoBar;
7
8
  private _dirtyFlag;
@@ -20,10 +21,13 @@ export default class DefaultErrorHandler {
20
21
  onConnectionError: (error: Error) => void;
21
22
  onDisconnected: (reason: string) => void;
22
23
  onUploadResourceError: (error: Error) => void;
24
+ onUploadResourceSuccess: () => void;
23
25
  onReady: () => void;
24
26
  setEditor(editor: OnesEditor): void;
25
27
  private handleError;
26
28
  private autoHide;
27
29
  get bar(): ErrorInfoBar;
30
+ showUploadResourceErrorDialog(options?: UploadResourceErrorDialogOptions): AlertDialog | null;
31
+ private hasPopup;
28
32
  destroy(): void;
29
33
  }
package/dist/index.js CHANGED
@@ -39136,7 +39136,7 @@ ${codeText}
39136
39136
  return ret;
39137
39137
  }
39138
39138
  async uploadResource(file2, options) {
39139
- var _a, _b, _c, _d;
39139
+ var _a, _b, _c, _d, _e, _f;
39140
39140
  try {
39141
39141
  if ((_a = this.options) == null ? void 0 : _a.uploadResource) {
39142
39142
  try {
@@ -39147,11 +39147,12 @@ ${codeText}
39147
39147
  }
39148
39148
  const ret = await this.client.uploadResource(file2, (_b = options == null ? void 0 : options.onProgress) != null ? _b : () => {
39149
39149
  });
39150
+ (_d = (_c = this.options) == null ? void 0 : _c.onUploadResourceSuccess) == null ? void 0 : _d.call(_c);
39150
39151
  return {
39151
39152
  resourceId: ret
39152
39153
  };
39153
39154
  } catch (err) {
39154
- (_d = (_c = this.options) == null ? void 0 : _c.onUploadResourceError) == null ? void 0 : _d.call(_c, err);
39155
+ (_f = (_e = this.options) == null ? void 0 : _e.onUploadResourceError) == null ? void 0 : _f.call(_e, err);
39155
39156
  throw err;
39156
39157
  }
39157
39158
  }
@@ -40083,7 +40084,7 @@ ${codeText}
40083
40084
  const AlignCenterIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 1.5H14" stroke="currentColor" stroke-linejoin="round"/>\n<path d="M2 9.5H8.5H14" stroke="currentColor" stroke-linejoin="round"/>\n<path d="M4 5.5H12" stroke="currentColor" stroke-linejoin="round"/>\n<path d="M4 13.5H12" stroke="currentColor" stroke-linejoin="round"/>\n</svg> \n';
40084
40085
  const ImageIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<g clip-path="url(#clip0_1214_10264)">\n<path d="M2 14L9.5 7L15 12" stroke="currentColor"/>\n<path d="M5 6C5 6.27614 4.77614 6.5 4.5 6.5C4.22386 6.5 4 6.27614 4 6C4 5.72386 4.22386 5.5 4.5 5.5C4.77614 5.5 5 5.72386 5 6Z" fill="#606060" stroke="currentColor"/>\n<path d="M1 13V3C1 2.44772 1.44772 2 2 2H14C14.5523 2 15 2.44772 15 3V13C15 13.5523 14.5523 14 14 14H2C1.44772 14 1 13.5523 1 13Z" stroke="currentColor"/>\n</g>\n<defs>\n<clipPath id="clip0_1214_10264">\n<rect width="16" height="16" fill="white"/>\n</clipPath>\n</defs>\n</svg>';
40085
40086
  const ImageMenuIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 14L9.5 7L15 12" stroke="currentColor"/>\n<path d="M5 6C5 6.27614 4.77614 6.5 4.5 6.5C4.22386 6.5 4 6.27614 4 6C4 5.72386 4.22386 5.5 4.5 5.5C4.77614 5.5 5 5.72386 5 6Z" fill="currentColor" stroke="currentColor"/>\n<path d="M1 13V3C1 2.44772 1.44772 2 2 2H14C14.5523 2 15 2.44772 15 3V13C15 13.5523 14.5523 14 14 14H2C1.44772 14 1 13.5523 1 13Z" stroke="currentColor"/>\n</svg>\n';
40086
- const WarningIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.49902C4.41023 1.49902 1.5 4.40925 1.5 7.99902C1.5 11.5888 4.41023 14.499 8 14.499C11.5898 14.499 14.5 11.5888 14.5 7.99902C14.5 4.40925 11.5898 1.49902 8 1.49902ZM0.5 7.99902C0.5 3.85696 3.85794 0.499023 8 0.499023C12.1421 0.499023 15.5 3.85696 15.5 7.99902C15.5 12.1411 12.1421 15.499 8 15.499C3.85794 15.499 0.5 12.1411 0.5 7.99902ZM8.5 6.99902V11.999H7.5V6.99902H8.5ZM8.5 5.99902V3.99902H7.5V5.99902H8.5Z" fill="currentColor"/>\n</svg>\n';
40087
+ const WarningIcon = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4.98464L3.24099 20H20.7589L17.8862 15.0753L12 4.98464ZM11.0066 2.71825C11.4504 1.95752 12.5495 1.95753 12.9933 2.71825L19.6137 14.0676L23.2321 20.2706C23.6794 21.0372 23.1263 22 22.2388 22H1.76111C0.873539 22 0.320549 21.0372 0.767761 20.2706L11.0066 2.71825ZM13 9.00001V15H11V9.00001H13ZM13 19.5V16.5H11V19.5H13Z" fill="currentColor"/>\n</svg>\n';
40087
40088
  const PasteSpecialIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.5 6.5C7.5 5.94772 7.94772 5.5 8.5 5.5H13.5C14.0523 5.5 14.5 5.94772 14.5 6.5V11.2273V13.5C14.5 14.0523 14.0523 14.5 13.5 14.5H8.5C7.94772 14.5 7.5 14.0523 7.5 13.5V6.5Z" stroke="currentColor"/>\n<path d="M11.5 6V3C11.5 2.44772 11.0523 2 10.5 2H8.5M4.27778 2L2.5 2C1.94772 2 1.5 2.44772 1.5 3V11.5C1.5 12.0523 1.94772 12.5 2.5 12.5H7.05556" stroke="currentColor"/>\n<rect x="4.5" y="1" width="4" height="2" stroke="currentColor"/>\n</svg>\n';
40088
40089
  const ImageErrorIcon = '<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6 42L28.5 21L33.32 25.3818" stroke="currentColor" stroke-width="3"/>\n<path d="M15 18C15 18.8284 14.3284 19.5 13.5 19.5C12.6716 19.5 12 18.8284 12 18C12 17.1716 12.6716 16.5 13.5 16.5C14.3284 16.5 15 17.1716 15 18Z" fill="currentColor" stroke="currentColor" stroke-width="3"/>\n<path d="M45 27V9C45 7.34315 43.6569 6 42 6H6C4.34315 6 3 7.34315 3 9V39C3 40.6569 4.34315 42 6 42H27" stroke="currentColor" stroke-width="3"/>\n<path d="M44.916 44.915L33.0007 32.9997" stroke="currentColor" stroke-width="3"/>\n<path d="M33 44.915L44.9153 32.9997" stroke="currentColor" stroke-width="3"/>\n</svg>\n';
40089
40090
  const ImageEmptyIcon = '<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M6 42L28.5 21L45 36" stroke="currentColor" stroke-width="6"/>\n<path d="M15 18C15 18.8284 14.3284 19.5 13.5 19.5C12.6716 19.5 12 18.8284 12 18C12 17.1716 12.6716 16.5 13.5 16.5C14.3284 16.5 15 17.1716 15 18Z" fill="currentColor" stroke="currentColor" stroke-width="6"/>\n<path d="M3 39V9C3 7.34315 4.34315 6 6 6H42C43.6569 6 45 7.34315 45 9V39C45 40.6569 43.6569 42 42 42H6C4.34315 42 3 40.6569 3 39Z" stroke="currentColor" stroke-width="6"/>\n</svg>\n';
@@ -85460,6 +85461,7 @@ ${docStr}
85460
85461
  const SAVE_DELAY_TIME = 30 * 1e3;
85461
85462
  const DRAWIO_EMPTY_CLASS = "editor-empty-drawio";
85462
85463
  const SHOW_FULL_SCREEN_IFRAME = "show-full-screen-iframe";
85464
+ const ERROR_DIALOG_ID = "draw-io-error-alert";
85463
85465
  const logger$f = getLogger("embed-block-drawio");
85464
85466
  let currentAlertDialog = null;
85465
85467
  let isDirty = false;
@@ -85520,8 +85522,7 @@ ${docStr}
85520
85522
  drawioContainer.setAttribute("data-placeholder", i18n$1.t("drawio.loading"));
85521
85523
  const clientId = editor.clientId;
85522
85524
  const popupClass = ["editor-popup-info-container", `editor-popup-info-container-${clientId}`];
85523
- const errorInfoContainer = createElement("div", popupClass, drawioContainer);
85524
- errorInfoContainer.setAttribute("data-custom-error-message", i18n$1.t("drawio.error.network"));
85525
+ createElement("div", popupClass, drawioContainer);
85525
85526
  drawioIframe = createElement("iframe", ["drawio-iframe-element"], drawioContainer);
85526
85527
  drawioIframe.setAttribute("frameborder", "0");
85527
85528
  addClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
@@ -85580,11 +85581,6 @@ ${docStr}
85580
85581
  constructor() {
85581
85582
  __publicField(this, "loadingContainer");
85582
85583
  __publicField(this, "setLoading", (iframe, placeholder2 = i18n$1.t("drawio.save")) => {
85583
- const parent = iframe.parentElement;
85584
- if (parent) {
85585
- addClass(parent, "loading");
85586
- parent.setAttribute("data-placeholder", placeholder2);
85587
- }
85588
85584
  });
85589
85585
  __publicField(this, "removeLoading", () => {
85590
85586
  const containers = document.querySelectorAll(".editor-drawio-iframe-container");
@@ -85654,28 +85650,27 @@ ${docStr}
85654
85650
  } catch (error2) {
85655
85651
  isDirty = true;
85656
85652
  const drawioIframeWindow = iframe.contentWindow;
85657
- if (!currentAlertDialog) {
85658
- currentAlertDialog = AlertDialog.showAlert({
85659
- id: "draw-io-error-alert",
85660
- title: i18n$1.t("drawio.error.networkDisconnected"),
85661
- content: i18n$1.t("drawio.error.networkDisconnectedMessage"),
85662
- buttons: ["cancel", "ok"],
85663
- okButtonTitle: i18n$1.t("drawio.retry"),
85664
- onOk: () => {
85665
- setTimeout(() => {
85666
- drawioIframeWindow.postMessage(JSON.stringify({
85667
- action: "export",
85668
- format: "xmlsvg",
85669
- spin: i18n$1.t("drawio.save"),
85670
- autoSave: exportFlag
85671
- }), "*");
85672
- }, 1e3);
85673
- },
85674
- onClose: () => {
85675
- currentAlertDialog = null;
85676
- },
85677
- type: "warning"
85678
- });
85653
+ if (!currentAlertDialog && exportFlag !== "auto") {
85654
+ const errorHandler = editor.findCustom("error-handler");
85655
+ if (errorHandler) {
85656
+ currentAlertDialog = errorHandler.showUploadResourceErrorDialog({
85657
+ id: ERROR_DIALOG_ID,
85658
+ allowRetry: true,
85659
+ onOk: () => {
85660
+ setTimeout(() => {
85661
+ drawioIframeWindow.postMessage(JSON.stringify({
85662
+ action: "export",
85663
+ format: "xmlsvg",
85664
+ spin: i18n$1.t("drawio.save"),
85665
+ autoSave: exportFlag
85666
+ }), "*");
85667
+ }, 1e3);
85668
+ },
85669
+ onClose: () => {
85670
+ currentAlertDialog = null;
85671
+ }
85672
+ });
85673
+ }
85679
85674
  }
85680
85675
  }
85681
85676
  loadingHandler.removeLoading();
@@ -85684,7 +85679,7 @@ ${docStr}
85684
85679
  case "exit":
85685
85680
  if (isDirty) {
85686
85681
  AlertDialog.showAlert({
85687
- id: "draw-io-error-alert",
85682
+ id: ERROR_DIALOG_ID,
85688
85683
  title: i18n$1.t("drawio.error.exitConfirm"),
85689
85684
  content: i18n$1.t("drawio.error.exitMessage"),
85690
85685
  okButtonTitle: i18n$1.t("drawio.exit"),
@@ -85973,9 +85968,6 @@ ${docStr}
85973
85968
  save: "Saving",
85974
85969
  exit: "\u9000\u51FA",
85975
85970
  error: {
85976
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
85977
- networkDisconnected: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00",
85978
- networkDisconnectedMessage: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u8BF7\u5728\u8FDE\u63A5\u6210\u529F\u540E\u5C1D\u8BD5\u4FDD\u5B58\u3002",
85979
85971
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
85980
85972
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
85981
85973
  }
@@ -85993,9 +85985,6 @@ ${docStr}
85993
85985
  save: "\u4FDD\u5B58\u4E2D",
85994
85986
  exit: "\u9000\u51FA",
85995
85987
  error: {
85996
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
85997
- networkDisconnected: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00",
85998
- networkDisconnectedMessage: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u8BF7\u5728\u8FDE\u63A5\u6210\u529F\u540E\u5C1D\u8BD5\u4FDD\u5B58\u3002",
85999
85988
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
86000
85989
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
86001
85990
  }
@@ -86013,9 +86002,6 @@ ${docStr}
86013
86002
  save: "\u4FDD\u5B58\u4E2D",
86014
86003
  exit: "\u9000\u51FA",
86015
86004
  error: {
86016
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
86017
- networkDisconnected: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00",
86018
- networkDisconnectedMessage: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u8BF7\u5728\u8FDE\u63A5\u6210\u529F\u540E\u5C1D\u8BD5\u4FDD\u5B58\u3002",
86019
86005
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
86020
86006
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
86021
86007
  }
@@ -88116,7 +88102,13 @@ ${data2.flowchartText}
88116
88102
  limitedEnvTips: "\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"
88117
88103
  },
88118
88104
  error: {
88119
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002"
88105
+ retry: "\u91CD\u8BD5",
88106
+ network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002",
88107
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88108
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88109
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88110
+ uploadResourcePopup: "\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u6570\u636E\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002",
88111
+ uploadResourceNoPopup: "\u6587\u4EF6\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u4E3A\u907F\u514D\u6570\u636E\u4E22\u5931\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002"
88120
88112
  }
88121
88113
  };
88122
88114
  const enUS$1 = {
@@ -88139,7 +88131,13 @@ ${data2.flowchartText}
88139
88131
  limitedEnvTips: "Press {shortCut} to paste due to browser restrictions"
88140
88132
  },
88141
88133
  error: {
88142
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002"
88134
+ retry: "Try again",
88135
+ network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002",
88136
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88137
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88138
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88139
+ uploadResourcePopup: "\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u6570\u636E\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002",
88140
+ uploadResourceNoPopup: "\u6587\u4EF6\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u4E3A\u907F\u514D\u6570\u636E\u4E22\u5931\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002"
88143
88141
  }
88144
88142
  };
88145
88143
  const jaJP$1 = {
@@ -88162,7 +88160,13 @@ ${data2.flowchartText}
88162
88160
  limitedEnvTips: "\u30D6\u30E9\u30A6\u30B6\u30FC\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u300C{shortCut}\u300D\u3092\u4F7F\u7528\u3057\u3066\u8CBC\u308A\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044"
88163
88161
  },
88164
88162
  error: {
88165
- network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002"
88163
+ retry: "\u518D\u8A66\u884C",
88164
+ network: "\u7F51\u7EDC\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE\u3002\u4E3A\u907F\u514D\u5185\u5BB9\u65E0\u6CD5\u540C\u6B65\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u5728\u7F51\u7EDC\u91CD\u8FDE\u6210\u529F\u540E\u7EE7\u7EED\u3002",
88165
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88166
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88167
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88168
+ uploadResourcePopup: "\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u6570\u636E\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002",
88169
+ uploadResourceNoPopup: "\u6587\u4EF6\u8D44\u6E90\u4E0A\u4F20\u5F02\u5E38\uFF0C\u4E3A\u907F\u514D\u6570\u636E\u4E22\u5931\uFF0C\u5DF2\u6682\u65F6\u7981\u7528\u7F16\u8F91\u3002\u8BF7\u590D\u5236\u8FD8\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u5237\u65B0\u9875\u9762\u540E\u91CD\u8BD5\u3002"
88166
88170
  }
88167
88171
  };
88168
88172
  i18n$1.mergeLang({
@@ -88210,7 +88214,6 @@ ${data2.flowchartText}
88210
88214
  __publicField(this, "message");
88211
88215
  __publicField(this, "_hideTimer", null);
88212
88216
  __publicField(this, "_adjustParentInterval", null);
88213
- __publicField(this, "_messageText", "");
88214
88217
  __publicField(this, "_type", "error");
88215
88218
  this.editor = editor;
88216
88219
  const root2 = createElement("div", ["error-info-bar"], null);
@@ -88220,15 +88223,14 @@ ${data2.flowchartText}
88220
88223
  this.message = message;
88221
88224
  }
88222
88225
  show(message, type) {
88223
- this._messageText = message;
88224
88226
  this._type = type;
88225
88227
  const parent = this.findParent();
88226
88228
  if (this.root.parentElement !== parent) {
88227
88229
  parent.insertAdjacentElement("afterbegin", this.root);
88228
88230
  }
88229
- this.message.innerText = this.getErrorMessage(parent);
88231
+ this.message.innerText = message;
88230
88232
  removeClass(this.root, "hidden");
88231
- this.root.setAttribute("data-type", type);
88233
+ this.root.setAttribute("data-type", this._type);
88232
88234
  if (this._hideTimer) {
88233
88235
  clearTimeout(this._hideTimer);
88234
88236
  this._hideTimer = null;
@@ -88294,13 +88296,6 @@ ${data2.flowchartText}
88294
88296
  currentParent.insertAdjacentElement("afterbegin", this.root);
88295
88297
  }, 1e3);
88296
88298
  }
88297
- getErrorMessage(parent) {
88298
- const customErrorMessage = parent.getAttribute("data-custom-error-message");
88299
- if (customErrorMessage && this._type === "error") {
88300
- return customErrorMessage;
88301
- }
88302
- return this._messageText;
88303
- }
88304
88299
  }
88305
88300
  const logger$6 = getLogger("error-handler");
88306
88301
  class DefaultErrorHandler {
@@ -88363,7 +88358,17 @@ ${data2.flowchartText}
88363
88358
  __publicField(this, "onUploadResourceError", (error2) => {
88364
88359
  assert(logger$6, this._editor, "no editor");
88365
88360
  logger$6.error(`Upload resource error${JSON.stringify(error2)}`);
88366
- this.handleError(error2);
88361
+ if (!this._connectionFlag) {
88362
+ if (this.hasPopup()) {
88363
+ this.handleError(error2, i18n$1.t("error.uploadResourcePopup"));
88364
+ } else {
88365
+ this.handleError(error2, i18n$1.t("error.uploadResourceNoPopup"));
88366
+ }
88367
+ }
88368
+ });
88369
+ __publicField(this, "onUploadResourceSuccess", () => {
88370
+ assert(logger$6, this._editor, "no editor");
88371
+ this.autoHide();
88367
88372
  });
88368
88373
  __publicField(this, "onReady", () => {
88369
88374
  var _a;
@@ -88382,15 +88387,21 @@ ${data2.flowchartText}
88382
88387
  setEditor(editor) {
88383
88388
  this._editor = editor;
88384
88389
  }
88385
- handleError(error2) {
88390
+ handleError(error2, customMessage) {
88386
88391
  if (this._editor) {
88387
88392
  this._editor.readonly = true;
88388
88393
  }
88389
- this.bar.show(this._errorMessage, "error");
88394
+ const defaultMessage = this.hasPopup() ? i18n$1.t("error.networkPopup") : i18n$1.t("error.network");
88395
+ const errorMessage = customMessage || defaultMessage;
88396
+ this.bar.show(errorMessage, "error");
88390
88397
  }
88391
88398
  autoHide() {
88399
+ var _a;
88392
88400
  if (!this._dirtyFlag && !this._connectionFlag) {
88393
88401
  this.bar.hide();
88402
+ if ((_a = this._editor) == null ? void 0 : _a.readonly) {
88403
+ this._editor.readonly = false;
88404
+ }
88394
88405
  }
88395
88406
  }
88396
88407
  get bar() {
@@ -88400,6 +88411,26 @@ ${data2.flowchartText}
88400
88411
  }
88401
88412
  return this._errorInfoBar;
88402
88413
  }
88414
+ showUploadResourceErrorDialog(options) {
88415
+ const buttons = (options == null ? void 0 : options.allowRetry) ? ["cancel", "ok"] : ["ok"];
88416
+ return AlertDialog.showAlert({
88417
+ id: (options == null ? void 0 : options.id) || "error-handler-upload-resource-alert",
88418
+ title: i18n$1.t("error.uploadResourceError"),
88419
+ content: i18n$1.t("error.uploadResourceErrorMessage"),
88420
+ buttons,
88421
+ okButtonTitle: i18n$1.t("error.retry"),
88422
+ onOk: (dialog) => {
88423
+ options == null ? void 0 : options.onOk(dialog);
88424
+ },
88425
+ onClose: () => {
88426
+ options == null ? void 0 : options.onClose();
88427
+ },
88428
+ type: "warning"
88429
+ });
88430
+ }
88431
+ hasPopup() {
88432
+ return !!document.querySelector(".editor-popup-info-container");
88433
+ }
88403
88434
  destroy() {
88404
88435
  var _a;
88405
88436
  (_a = this._errorInfoBar) == null ? void 0 : _a.destroy();
@@ -90602,6 +90633,7 @@ ${data2.flowchartText}
90602
90633
  onDisconnected: options.onDisconnected || errorHandler.onDisconnected,
90603
90634
  onUnknownError: options.onUnknownError || errorHandler.onUnknownError,
90604
90635
  onUploadResourceError: options.onUploadResourceError || errorHandler.onUploadResourceError,
90636
+ onUploadResourceSuccess: options.onUploadResourceSuccess || errorHandler.onUploadResourceSuccess,
90605
90637
  onReady: options.onReady || errorHandler.onReady
90606
90638
  };
90607
90639
  const doc2 = await ShareDBDoc.load(docOptions);
@@ -90733,7 +90765,7 @@ ${data2.flowchartText}
90733
90765
  }
90734
90766
  }
90735
90767
  });
90736
- editor.version = "2.3.0-beta.11";
90768
+ editor.version = "2.3.0-beta.13";
90737
90769
  return editor;
90738
90770
  }
90739
90771
  function isDoc(doc2) {
@@ -90840,7 +90872,7 @@ ${data2.flowchartText}
90840
90872
  }
90841
90873
  });
90842
90874
  OnesEditorToolbar.register(editor);
90843
- editor.version = "2.3.0-beta.11";
90875
+ editor.version = "2.3.0-beta.13";
90844
90876
  return editor;
90845
90877
  }
90846
90878
  async function showDocVersions(editor, options, serverUrl) {
@@ -18,7 +18,13 @@ declare const _default: {
18
18
  limitedEnvTips: string;
19
19
  };
20
20
  error: {
21
+ retry: string;
21
22
  network: string;
23
+ networkPopup: string;
24
+ uploadResourceError: string;
25
+ uploadResourceErrorMessage: string;
26
+ uploadResourcePopup: string;
27
+ uploadResourceNoPopup: string;
22
28
  };
23
29
  };
24
30
  export default _default;
@@ -18,7 +18,13 @@ declare const _default: {
18
18
  limitedEnvTips: string;
19
19
  };
20
20
  error: {
21
+ retry: string;
21
22
  network: string;
23
+ networkPopup: string;
24
+ uploadResourceError: string;
25
+ uploadResourceErrorMessage: string;
26
+ uploadResourcePopup: string;
27
+ uploadResourceNoPopup: string;
22
28
  };
23
29
  };
24
30
  export default _default;
@@ -18,7 +18,13 @@ declare const _default: {
18
18
  limitedEnvTips: string;
19
19
  };
20
20
  error: {
21
+ retry: string;
21
22
  network: string;
23
+ networkPopup: string;
24
+ uploadResourceError: string;
25
+ uploadResourceErrorMessage: string;
26
+ uploadResourcePopup: string;
27
+ uploadResourceNoPopup: string;
22
28
  };
23
29
  };
24
30
  export default _default;
package/dist/types.d.ts CHANGED
@@ -104,6 +104,7 @@ export interface CreateOnesEditorOptions {
104
104
  onDisconnected?: (reason: string) => void;
105
105
  onUnknownError?: (error: Error) => void;
106
106
  onUploadResourceError?: (error: Error) => void;
107
+ onUploadResourceSuccess?: () => void;
107
108
  onReady?: () => void;
108
109
  }
109
110
  export interface CreateLocalEditorOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "2.3.0-beta.11",
3
+ "version": "2.3.0-beta.13",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {