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

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,7 +7973,47 @@ var __publicField = (obj, key, value) => {
7973
7973
  }
7974
7974
  return false;
7975
7975
  }
7976
- const copyTextToClipboard = (text2) => {
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;
7991
+ if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
7992
+ const textarea2 = document.createElement("textarea");
7993
+ 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 = "hello \u5F02\u6B65";
7999
+ textarea2.style.position = "fixed";
8000
+ textarea2.style.opacity = "0";
8001
+ document.body.appendChild(textarea2);
8002
+ textarea2.select();
8003
+ document.execCommand("copy");
8004
+ document.body.removeChild(textarea2);
8005
+ return true;
8006
+ } catch (ex) {
8007
+ alert("\u590D\u5236\u5931\u8D25");
8008
+ logger$49.error(ex);
8009
+ document.body.removeChild(textarea2);
8010
+ return false;
8011
+ }
8012
+ }
8013
+ return false;
8014
+ }
8015
+ const copyTextToClipboard = async (text2) => {
8016
+ await new Promise((resolve) => setTimeout(resolve, 100));
7977
8017
  if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
7978
8018
  const textarea2 = document.createElement("textarea");
7979
8019
  textarea2.textContent = text2;
@@ -7995,7 +8035,7 @@ var __publicField = (obj, key, value) => {
7995
8035
  function setClipboardData(items) {
7996
8036
  if (window.indexTs % 2) {
7997
8037
  setTimeout(() => {
7998
- copyTextToClipboard("hello world 10 miao");
8038
+ execCommandCopy(items);
7999
8039
  }, 10);
8000
8040
  } else {
8001
8041
  copyTextToClipboard("hello world");
@@ -54863,8 +54903,8 @@ ${codeText}
54863
54903
  }
54864
54904
  const [imageClipboardData, imageClipboardOriginData] = clipboardData;
54865
54905
  if (imageClipboardData) {
54866
- Object.entries(imageClipboardData).map(([key, value]) => ({ type: key, data: value }));
54867
- setClipboardData();
54906
+ const items = Object.entries(imageClipboardData).map(([key, value]) => ({ type: key, data: value }));
54907
+ setClipboardData(items);
54868
54908
  if (event) {
54869
54909
  const clipboardData2 = event.clipboardData;
54870
54910
  if (clipboardData2) {
@@ -75684,7 +75724,7 @@ ${data.flowchartText}
75684
75724
  }
75685
75725
  }
75686
75726
  });
75687
- editor.version = "1.1.10-beta.17";
75727
+ editor.version = "1.1.10-beta.18";
75688
75728
  return editor;
75689
75729
  }
75690
75730
  function isDoc(doc2) {
@@ -75757,7 +75797,7 @@ ${data.flowchartText}
75757
75797
  });
75758
75798
  editor.addCustom(DOC_RE_AUTH_KEYS, (editor2) => new DocReAuthCallbacks(editor2));
75759
75799
  OnesEditorToolbar.register(editor);
75760
- editor.version = "1.1.10-beta.17";
75800
+ editor.version = "1.1.10-beta.18";
75761
75801
  return editor;
75762
75802
  }
75763
75803
  async function showDocVersions(editor, options, serverUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ones-editor/editor",
3
- "version": "1.1.10-beta.17",
3
+ "version": "1.1.10-beta.18",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",