@ones-editor/editor 1.1.10-beta.14 → 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(() => {
@@ -49908,21 +49879,18 @@ $$${mathData.mathjaxText}$$
49908
49879
  if (parentBlock !== block) {
49909
49880
  selectCodeBlock(editor, block, { focusToEditor: true });
49910
49881
  }
49911
- editorCopyBlock(editor, block).then(() => {
49912
- const { onCodeCopyComplete } = editor.getComponentOptions("code") || {};
49913
- if (onCodeCopyComplete) {
49914
- onCodeCopyComplete();
49915
- 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
49916
49893
  }
49917
- const rect = button2.getBoundingClientRect();
49918
- showToast(i18n$1.t("code.copySuccess"), {
49919
- position: {
49920
- x: rect.x + rect.width / 2,
49921
- y: rect.bottom + 30
49922
- }
49923
- });
49924
- }).catch((err) => {
49925
- logger$1b.error(err.message);
49926
49894
  });
49927
49895
  return;
49928
49896
  }
@@ -54895,16 +54863,15 @@ ${codeText}
54895
54863
  }
54896
54864
  const [imageClipboardData, imageClipboardOriginData] = clipboardData;
54897
54865
  if (imageClipboardData) {
54898
- const items = Object.entries(imageClipboardData).map(([key, value]) => ({ type: key, data: value }));
54899
- setClipboardData(items).then((ret) => {
54900
- if (!ret && event) {
54901
- const clipboardData2 = event.clipboardData;
54902
- if (clipboardData2) {
54903
- clipboardData2.setData("text/plain", imageClipboardOriginData["text/plain"]);
54904
- clipboardData2.setData("text/html", imageClipboardOriginData["text/html"]);
54905
- }
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"]);
54906
54873
  }
54907
- });
54874
+ }
54908
54875
  return true;
54909
54876
  }
54910
54877
  return void 0;
@@ -75717,7 +75684,7 @@ ${data.flowchartText}
75717
75684
  }
75718
75685
  }
75719
75686
  });
75720
- editor.version = "1.1.10-beta.14";
75687
+ editor.version = "1.1.10-beta.17";
75721
75688
  return editor;
75722
75689
  }
75723
75690
  function isDoc(doc2) {
@@ -75790,7 +75757,7 @@ ${data.flowchartText}
75790
75757
  });
75791
75758
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
75792
75759
  OnesEditorToolbar.register(editor);
75793
- editor.version = "1.1.10-beta.14";
75760
+ editor.version = "1.1.10-beta.17";
75794
75761
  return editor;
75795
75762
  }
75796
75763
  async function showDocVersions(editor, options, serverUrl) {
@@ -75940,6 +75907,7 @@ ${data.flowchartText}
75940
75907
  exports2.converterIntercept = converterIntercept;
75941
75908
  exports2.copyBlockAttributes = copyBlockAttributes;
75942
75909
  exports2.copyResourcesFromDoc = copyResourcesFromDoc;
75910
+ exports2.copyTextToClipboard = copyTextToClipboard;
75943
75911
  exports2.createBlockAnchor = createBlockAnchor;
75944
75912
  exports2.createBlockCaretAnchor = createBlockCaretAnchor;
75945
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.14",
3
+ "version": "1.1.10-beta.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",