@zero-library/common 3.1.3 → 3.1.5
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.cjs.js +15 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +14 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -5,6 +5,7 @@ import classNames2 from 'classnames';
|
|
|
5
5
|
import { renderAsync } from 'docx-preview';
|
|
6
6
|
import * as React3 from 'react';
|
|
7
7
|
import React3__default, { useRef, useState, useEffect, forwardRef, useMemo, useCallback, createContext, isValidElement, version, cloneElement, memo, useImperativeHandle, useContext, Fragment as Fragment$1, lazy, Suspense } from 'react';
|
|
8
|
+
import copyToClipboard from 'copy-to-clipboard';
|
|
8
9
|
import AES from 'crypto-js/aes';
|
|
9
10
|
import encUtf8 from 'crypto-js/enc-utf8';
|
|
10
11
|
import { convert } from 'html-to-text';
|
|
@@ -468,23 +469,8 @@ var genNonDuplicateID = () => {
|
|
|
468
469
|
});
|
|
469
470
|
};
|
|
470
471
|
var copyText = async (text, prompt = "\u590D\u5236\u6210\u529F") => {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
if (prompt) message.success(prompt);
|
|
474
|
-
} catch (e) {
|
|
475
|
-
const textArea = document.createElement("textarea");
|
|
476
|
-
textArea.value = text;
|
|
477
|
-
textArea.style.position = "absolute";
|
|
478
|
-
textArea.style.opacity = "0";
|
|
479
|
-
textArea.style.left = "-999999px";
|
|
480
|
-
textArea.style.top = "-999999px";
|
|
481
|
-
document.body.appendChild(textArea);
|
|
482
|
-
textArea.focus();
|
|
483
|
-
textArea.select();
|
|
484
|
-
const ok = document.execCommand("copy");
|
|
485
|
-
if (ok && prompt) message.success(prompt);
|
|
486
|
-
textArea.remove();
|
|
487
|
-
}
|
|
472
|
+
await copyToClipboard(text);
|
|
473
|
+
if (prompt) message.success(prompt);
|
|
488
474
|
};
|
|
489
475
|
function formatNumberWithCommas(number) {
|
|
490
476
|
const numericValue = parseFloat(number);
|
|
@@ -1527,11 +1513,19 @@ var MarkdownPreview_default = ({ fileUrl, searchValue, asPlainText }) => {
|
|
|
1527
1513
|
if (res.status !== 200) {
|
|
1528
1514
|
throw new Error(`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${res.status}`);
|
|
1529
1515
|
}
|
|
1530
|
-
const
|
|
1531
|
-
|
|
1516
|
+
const buffer = await res.arrayBuffer();
|
|
1517
|
+
let markdownText = "";
|
|
1518
|
+
try {
|
|
1519
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
1520
|
+
markdownText = decoder.decode(buffer);
|
|
1521
|
+
} catch (e) {
|
|
1522
|
+
const gbkDecoder = new TextDecoder("gbk");
|
|
1523
|
+
markdownText = gbkDecoder.decode(buffer);
|
|
1524
|
+
}
|
|
1525
|
+
if (!markdownText) {
|
|
1532
1526
|
throw new Error("\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A");
|
|
1533
1527
|
}
|
|
1534
|
-
return
|
|
1528
|
+
return markdownText;
|
|
1535
1529
|
};
|
|
1536
1530
|
const init = async () => {
|
|
1537
1531
|
setContent("");
|