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

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.
@@ -10,7 +10,10 @@ export default class ErrorInfoBar {
10
10
  private _messageText;
11
11
  private _type;
12
12
  constructor(editor: OnesEditor);
13
- show(message: string, type: BarType): void;
13
+ show(message: string, options: {
14
+ type: BarType;
15
+ customMessage?: string;
16
+ }): void;
14
17
  hide(): void;
15
18
  visible(): boolean;
16
19
  destroy(): void;
@@ -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;
@@ -85521,7 +85523,7 @@ ${docStr}
85521
85523
  const clientId = editor.clientId;
85522
85524
  const popupClass = ["editor-popup-info-container", `editor-popup-info-container-${clientId}`];
85523
85525
  const errorInfoContainer = createElement("div", popupClass, drawioContainer);
85524
- errorInfoContainer.setAttribute("data-custom-error-message", i18n$1.t("drawio.error.network"));
85526
+ errorInfoContainer.setAttribute("data-custom-error-message", i18n$1.t("error.networkPopup"));
85525
85527
  drawioIframe = createElement("iframe", ["drawio-iframe-element"], drawioContainer);
85526
85528
  drawioIframe.setAttribute("frameborder", "0");
85527
85529
  addClass(drawioContainer, SHOW_FULL_SCREEN_IFRAME);
@@ -85580,11 +85582,6 @@ ${docStr}
85580
85582
  constructor() {
85581
85583
  __publicField(this, "loadingContainer");
85582
85584
  __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
85585
  });
85589
85586
  __publicField(this, "removeLoading", () => {
85590
85587
  const containers = document.querySelectorAll(".editor-drawio-iframe-container");
@@ -85654,28 +85651,27 @@ ${docStr}
85654
85651
  } catch (error2) {
85655
85652
  isDirty = true;
85656
85653
  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
- });
85654
+ if (!currentAlertDialog && exportFlag !== "auto") {
85655
+ const errorHandler = editor.findCustom("error-handler");
85656
+ if (errorHandler) {
85657
+ currentAlertDialog = errorHandler.showUploadResourceErrorDialog({
85658
+ id: ERROR_DIALOG_ID,
85659
+ allowRetry: true,
85660
+ onOk: () => {
85661
+ setTimeout(() => {
85662
+ drawioIframeWindow.postMessage(JSON.stringify({
85663
+ action: "export",
85664
+ format: "xmlsvg",
85665
+ spin: i18n$1.t("drawio.save"),
85666
+ autoSave: exportFlag
85667
+ }), "*");
85668
+ }, 1e3);
85669
+ },
85670
+ onClose: () => {
85671
+ currentAlertDialog = null;
85672
+ }
85673
+ });
85674
+ }
85679
85675
  }
85680
85676
  }
85681
85677
  loadingHandler.removeLoading();
@@ -85684,7 +85680,7 @@ ${docStr}
85684
85680
  case "exit":
85685
85681
  if (isDirty) {
85686
85682
  AlertDialog.showAlert({
85687
- id: "draw-io-error-alert",
85683
+ id: ERROR_DIALOG_ID,
85688
85684
  title: i18n$1.t("drawio.error.exitConfirm"),
85689
85685
  content: i18n$1.t("drawio.error.exitMessage"),
85690
85686
  okButtonTitle: i18n$1.t("drawio.exit"),
@@ -85973,9 +85969,6 @@ ${docStr}
85973
85969
  save: "Saving",
85974
85970
  exit: "\u9000\u51FA",
85975
85971
  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
85972
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
85980
85973
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
85981
85974
  }
@@ -85993,9 +85986,6 @@ ${docStr}
85993
85986
  save: "\u4FDD\u5B58\u4E2D",
85994
85987
  exit: "\u9000\u51FA",
85995
85988
  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
85989
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
86000
85990
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
86001
85991
  }
@@ -86013,9 +86003,6 @@ ${docStr}
86013
86003
  save: "\u4FDD\u5B58\u4E2D",
86014
86004
  exit: "\u9000\u51FA",
86015
86005
  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
86006
  exitConfirm: "\u9000\u51FA\u7F16\u8F91",
86020
86007
  exitMessage: "\u9000\u51FA\u7F16\u8F91\u540E\uFF0C\u6240\u6709\u66F4\u6539\u65E0\u6CD5\u4FDD\u5B58\u3002\u662F\u5426\u786E\u5B9A\u9000\u51FA\uFF1F"
86021
86008
  }
@@ -88116,7 +88103,13 @@ ${data2.flowchartText}
88116
88103
  limitedEnvTips: "\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"
88117
88104
  },
88118
88105
  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"
88106
+ retry: "\u91CD\u8BD5",
88107
+ 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",
88108
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88109
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88110
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88111
+ 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",
88112
+ 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
88113
  }
88121
88114
  };
88122
88115
  const enUS$1 = {
@@ -88139,7 +88132,13 @@ ${data2.flowchartText}
88139
88132
  limitedEnvTips: "Press {shortCut} to paste due to browser restrictions"
88140
88133
  },
88141
88134
  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"
88135
+ retry: "Try again",
88136
+ 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",
88137
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88138
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88139
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88140
+ 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",
88141
+ 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
88142
  }
88144
88143
  };
88145
88144
  const jaJP$1 = {
@@ -88162,7 +88161,13 @@ ${data2.flowchartText}
88162
88161
  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
88162
  },
88164
88163
  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"
88164
+ retry: "\u518D\u8A66\u884C",
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",
88166
+ networkPopup: "\u670D\u52A1\u8FDE\u63A5\u5F02\u5E38\uFF0C\u6B63\u5728\u5C1D\u8BD5\u91CD\u8FDE...",
88167
+ uploadResourceError: "\u6570\u636E\u4FDD\u5B58\u5F02\u5E38",
88168
+ uploadResourceErrorMessage: "\u8D44\u6E90\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",
88169
+ 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",
88170
+ 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
88171
  }
88167
88172
  };
88168
88173
  i18n$1.mergeLang({
@@ -88219,16 +88224,16 @@ ${data2.flowchartText}
88219
88224
  const message = createElement("div", ["message"], content);
88220
88225
  this.message = message;
88221
88226
  }
88222
- show(message, type) {
88227
+ show(message, options) {
88223
88228
  this._messageText = message;
88224
- this._type = type;
88229
+ this._type = options.type;
88225
88230
  const parent = this.findParent();
88226
88231
  if (this.root.parentElement !== parent) {
88227
88232
  parent.insertAdjacentElement("afterbegin", this.root);
88228
88233
  }
88229
- this.message.innerText = this.getErrorMessage(parent);
88234
+ this.message.innerText = options.customMessage || this.getErrorMessage(parent);
88230
88235
  removeClass(this.root, "hidden");
88231
- this.root.setAttribute("data-type", type);
88236
+ this.root.setAttribute("data-type", this._type);
88232
88237
  if (this._hideTimer) {
88233
88238
  clearTimeout(this._hideTimer);
88234
88239
  this._hideTimer = null;
@@ -88363,7 +88368,17 @@ ${data2.flowchartText}
88363
88368
  __publicField(this, "onUploadResourceError", (error2) => {
88364
88369
  assert(logger$6, this._editor, "no editor");
88365
88370
  logger$6.error(`Upload resource error${JSON.stringify(error2)}`);
88366
- this.handleError(error2);
88371
+ if (!this._connectionFlag) {
88372
+ if (this.hasPopup()) {
88373
+ this.handleError(error2, i18n$1.t("error.uploadResourcePopup"));
88374
+ } else {
88375
+ this.handleError(error2, i18n$1.t("error.uploadResourceNoPopup"));
88376
+ }
88377
+ }
88378
+ });
88379
+ __publicField(this, "onUploadResourceSuccess", () => {
88380
+ assert(logger$6, this._editor, "no editor");
88381
+ this.autoHide();
88367
88382
  });
88368
88383
  __publicField(this, "onReady", () => {
88369
88384
  var _a;
@@ -88382,15 +88397,22 @@ ${data2.flowchartText}
88382
88397
  setEditor(editor) {
88383
88398
  this._editor = editor;
88384
88399
  }
88385
- handleError(error2) {
88400
+ handleError(error2, customMessage) {
88386
88401
  if (this._editor) {
88387
88402
  this._editor.readonly = true;
88388
88403
  }
88389
- this.bar.show(this._errorMessage, "error");
88404
+ this.bar.show(this._errorMessage, {
88405
+ type: "error",
88406
+ customMessage
88407
+ });
88390
88408
  }
88391
88409
  autoHide() {
88410
+ var _a;
88392
88411
  if (!this._dirtyFlag && !this._connectionFlag) {
88393
88412
  this.bar.hide();
88413
+ if ((_a = this._editor) == null ? void 0 : _a.readonly) {
88414
+ this._editor.readonly = false;
88415
+ }
88394
88416
  }
88395
88417
  }
88396
88418
  get bar() {
@@ -88400,6 +88422,26 @@ ${data2.flowchartText}
88400
88422
  }
88401
88423
  return this._errorInfoBar;
88402
88424
  }
88425
+ showUploadResourceErrorDialog(options) {
88426
+ const buttons = (options == null ? void 0 : options.allowRetry) ? ["cancel", "ok"] : ["ok"];
88427
+ return AlertDialog.showAlert({
88428
+ id: (options == null ? void 0 : options.id) || "error-handler-upload-resource-alert",
88429
+ title: i18n$1.t("error.uploadResourceError"),
88430
+ content: i18n$1.t("error.uploadResourceErrorMessage"),
88431
+ buttons,
88432
+ okButtonTitle: i18n$1.t("error.retry"),
88433
+ onOk: (dialog) => {
88434
+ options == null ? void 0 : options.onOk(dialog);
88435
+ },
88436
+ onClose: () => {
88437
+ options == null ? void 0 : options.onClose();
88438
+ },
88439
+ type: "warning"
88440
+ });
88441
+ }
88442
+ hasPopup() {
88443
+ return !!document.querySelector(".editor-popup-info-container");
88444
+ }
88403
88445
  destroy() {
88404
88446
  var _a;
88405
88447
  (_a = this._errorInfoBar) == null ? void 0 : _a.destroy();
@@ -90602,6 +90644,7 @@ ${data2.flowchartText}
90602
90644
  onDisconnected: options.onDisconnected || errorHandler.onDisconnected,
90603
90645
  onUnknownError: options.onUnknownError || errorHandler.onUnknownError,
90604
90646
  onUploadResourceError: options.onUploadResourceError || errorHandler.onUploadResourceError,
90647
+ onUploadResourceSuccess: options.onUploadResourceSuccess || errorHandler.onUploadResourceSuccess,
90605
90648
  onReady: options.onReady || errorHandler.onReady
90606
90649
  };
90607
90650
  const doc2 = await ShareDBDoc.load(docOptions);
@@ -90733,7 +90776,7 @@ ${data2.flowchartText}
90733
90776
  }
90734
90777
  }
90735
90778
  });
90736
- editor.version = "2.3.0-beta.11";
90779
+ editor.version = "2.3.0-beta.12";
90737
90780
  return editor;
90738
90781
  }
90739
90782
  function isDoc(doc2) {
@@ -90840,7 +90883,7 @@ ${data2.flowchartText}
90840
90883
  }
90841
90884
  });
90842
90885
  OnesEditorToolbar.register(editor);
90843
- editor.version = "2.3.0-beta.11";
90886
+ editor.version = "2.3.0-beta.12";
90844
90887
  return editor;
90845
90888
  }
90846
90889
  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.12",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "dependencies": {