@ones-editor/editor 1.1.10-beta.15 → 1.1.10-beta.17

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.js CHANGED
@@ -7973,57 +7973,34 @@ var __publicField = (obj, key, value) => {
7973
7973
  }
7974
7974
  return false;
7975
7975
  }
7976
- function readBlob(blob) {
7977
- if (typeof blob.text === "function") {
7978
- return blob.text();
7979
- }
7980
- return new Promise((resolve, reject) => {
7981
- const reader = new FileReader();
7982
- reader.onload = () => {
7983
- resolve(reader.result);
7984
- };
7985
- reader.onerror = reject;
7986
- reader.readAsText(blob);
7987
- });
7988
- }
7989
- async function execCommandCopy(items) {
7990
- var _a;
7976
+ const copyTextToClipboard = (text2) => {
7991
7977
  if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
7992
7978
  const textarea2 = document.createElement("textarea");
7979
+ textarea2.textContent = text2;
7980
+ textarea2.style.position = "fixed";
7981
+ document.body.appendChild(textarea2);
7982
+ textarea2.select();
7993
7983
  try {
7994
- let text2 = (_a = items.find((item) => item.type === "text/plain")) == null ? void 0 : _a.data;
7995
- if (text2 instanceof Blob) {
7996
- text2 = await readBlob(text2);
7997
- }
7998
- textarea2.textContent = text2 != null ? text2 : "";
7999
- textarea2.style.position = "fixed";
8000
- textarea2.style.opacity = "0";
8001
- document.body.appendChild(textarea2);
8002
- textarea2.select();
8003
7984
  document.execCommand("copy");
8004
- document.body.removeChild(textarea2);
8005
- return true;
8006
7985
  } catch (ex) {
8007
- logger$49.error(ex);
8008
- document.body.removeChild(textarea2);
7986
+ logger$49.error("Cannot copy text to clipboard");
8009
7987
  return false;
7988
+ } finally {
7989
+ document.body.removeChild(textarea2);
8010
7990
  }
8011
7991
  }
8012
- return false;
8013
- }
8014
- async function setClipboardData(items) {
8015
- try {
8016
- const clipboardData = {};
8017
- items.forEach((item) => {
8018
- clipboardData[item.type] = item.data;
8019
- });
8020
- const clipboardItems = new ClipboardItem(clipboardData);
8021
- await navigator.clipboard.write([clipboardItems]);
8022
- return true;
8023
- } catch (err) {
8024
- logger$49.error(err);
8025
- return await execCommandCopy(items);
7992
+ return true;
7993
+ };
7994
+ window.indexTs = 0;
7995
+ function setClipboardData(items) {
7996
+ if (window.indexTs % 2) {
7997
+ setTimeout(() => {
7998
+ copyTextToClipboard("hello world 10 miao");
7999
+ }, 10);
8000
+ } else {
8001
+ copyTextToClipboard("hello world");
8026
8002
  }
8003
+ window.indexTs += 1;
8027
8004
  }
8028
8005
  function selectFile(accept, options) {
8029
8006
  return new Promise((resolve, reject) => {
@@ -26166,7 +26143,7 @@ var __publicField = (obj, key, value) => {
26166
26143
  }
26167
26144
  editorCopyDoc(editor, doc2);
26168
26145
  }
26169
- async function editorCopyBlock(editor, block) {
26146
+ function editorCopyBlock(editor, block) {
26170
26147
  if (!window.isSecureContext) {
26171
26148
  throw new Error("Can't copy block in insecure context.");
26172
26149
  }
@@ -34300,9 +34277,6 @@ ${codeText}
34300
34277
  __publicField(this, "reAuth", async () => {
34301
34278
  if (this.connection && this.reauthFunc) {
34302
34279
  const newAuth = await this.reauthFunc();
34303
- if (window.isReauthError) {
34304
- throw new Error("reauth error");
34305
- }
34306
34280
  await this.auth(newAuth);
34307
34281
  const pingOptions = this.pingOptions;
34308
34282
  this.connection._initializeHandshake = function handshake() {
@@ -34372,9 +34346,6 @@ ${codeText}
34372
34346
  const thatWs = this.ws;
34373
34347
  const pingOptions = this.pingOptions;
34374
34348
  this.connection._initializeHandshake = function handshake() {
34375
- if (window.isTokenExpired) {
34376
- auth.token = "aaabbbccc";
34377
- }
34378
34349
  this.send({ a: "hs", id: this.id, auth, options: { ping: pingOptions } });
34379
34350
  if (this._ping == null) {
34380
34351
  this._ping = window.setInterval(() => {
@@ -35573,13 +35544,7 @@ ${codeText}
35573
35544
  __publicField(this, "disableLogout");
35574
35545
  __publicField(this, "destroyed", false);
35575
35546
  __publicField(this, "handleNothingPending", () => {
35576
- if (window.setDelay) {
35577
- setTimeout(() => {
35578
- this.setStatus("clean");
35579
- }, 30 * 1e3);
35580
- } else {
35581
- this.setStatus("clean");
35582
- }
35547
+ this.setStatus("clean");
35583
35548
  });
35584
35549
  __publicField(this, "handleCreate", () => {
35585
35550
  this.handleReload("doc created");
@@ -49914,21 +49879,18 @@ $$${mathData.mathjaxText}$$
49914
49879
  if (parentBlock !== block) {
49915
49880
  selectCodeBlock(editor, block, { focusToEditor: true });
49916
49881
  }
49917
- editorCopyBlock(editor, block).then(() => {
49918
- const { onCodeCopyComplete } = editor.getComponentOptions("code") || {};
49919
- if (onCodeCopyComplete) {
49920
- onCodeCopyComplete();
49921
- return;
49882
+ editorCopyBlock(editor, block);
49883
+ const { onCodeCopyComplete } = editor.getComponentOptions("code") || {};
49884
+ if (onCodeCopyComplete) {
49885
+ onCodeCopyComplete();
49886
+ return;
49887
+ }
49888
+ const rect = button2.getBoundingClientRect();
49889
+ showToast(i18n$1.t("code.copySuccess"), {
49890
+ position: {
49891
+ x: rect.x + rect.width / 2,
49892
+ y: rect.bottom + 30
49922
49893
  }
49923
- const rect = button2.getBoundingClientRect();
49924
- showToast(i18n$1.t("code.copySuccess"), {
49925
- position: {
49926
- x: rect.x + rect.width / 2,
49927
- y: rect.bottom + 30
49928
- }
49929
- });
49930
- }).catch((err) => {
49931
- logger$1b.error(err.message);
49932
49894
  });
49933
49895
  return;
49934
49896
  }
@@ -54901,16 +54863,15 @@ ${codeText}
54901
54863
  }
54902
54864
  const [imageClipboardData, imageClipboardOriginData] = clipboardData;
54903
54865
  if (imageClipboardData) {
54904
- const items = Object.entries(imageClipboardData).map(([key, value]) => ({ type: key, data: value }));
54905
- setClipboardData(items).then((ret) => {
54906
- if (!ret && event) {
54907
- const clipboardData2 = event.clipboardData;
54908
- if (clipboardData2) {
54909
- clipboardData2.setData("text/plain", imageClipboardOriginData["text/plain"]);
54910
- clipboardData2.setData("text/html", imageClipboardOriginData["text/html"]);
54911
- }
54866
+ Object.entries(imageClipboardData).map(([key, value]) => ({ type: key, data: value }));
54867
+ setClipboardData();
54868
+ if (event) {
54869
+ const clipboardData2 = event.clipboardData;
54870
+ if (clipboardData2) {
54871
+ clipboardData2.setData("text/plain", imageClipboardOriginData["text/plain"]);
54872
+ clipboardData2.setData("text/html", imageClipboardOriginData["text/html"]);
54912
54873
  }
54913
- });
54874
+ }
54914
54875
  return true;
54915
54876
  }
54916
54877
  return void 0;
@@ -75723,7 +75684,7 @@ ${data.flowchartText}
75723
75684
  }
75724
75685
  }
75725
75686
  });
75726
- editor.version = "1.1.10-beta.15";
75687
+ editor.version = "1.1.10-beta.17";
75727
75688
  return editor;
75728
75689
  }
75729
75690
  function isDoc(doc2) {
@@ -75796,7 +75757,7 @@ ${data.flowchartText}
75796
75757
  });
75797
75758
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
75798
75759
  OnesEditorToolbar.register(editor);
75799
- editor.version = "1.1.10-beta.15";
75760
+ editor.version = "1.1.10-beta.17";
75800
75761
  return editor;
75801
75762
  }
75802
75763
  async function showDocVersions(editor, options, serverUrl) {
@@ -75946,6 +75907,7 @@ ${data.flowchartText}
75946
75907
  exports2.converterIntercept = converterIntercept;
75947
75908
  exports2.copyBlockAttributes = copyBlockAttributes;
75948
75909
  exports2.copyResourcesFromDoc = copyResourcesFromDoc;
75910
+ exports2.copyTextToClipboard = copyTextToClipboard;
75949
75911
  exports2.createBlockAnchor = createBlockAnchor;
75950
75912
  exports2.createBlockCaretAnchor = createBlockCaretAnchor;
75951
75913
  exports2.createBlockContentElement = createBlockContentElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "1.1.10-beta.15",
3
+ "version": "1.1.10-beta.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",