@zero-library/common 3.0.1 → 3.0.3
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 +913 -356
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +52 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +50 -7
- package/dist/index.d.ts +50 -7
- package/dist/index.esm.js +616 -65
- package/dist/index.esm.js.map +1 -1
- package/dist/pdf.worker.min.mjs +28 -0
- package/package.json +5 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { jsx,
|
|
2
|
-
import { MessageOutlined, BookOutlined, EditOutlined, DeleteOutlined, CloseOutlined, MinusCircleOutlined, PlusCircleOutlined, RedoOutlined, FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined, ColumnWidthOutlined } from '@ant-design/icons';
|
|
3
|
-
import { Spin, Input,
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { MessageOutlined, BookOutlined, EditOutlined, DeleteOutlined, CloseOutlined, MinusCircleOutlined, PlusCircleOutlined, RedoOutlined, FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined, ColumnWidthOutlined, LeftOutlined, RightOutlined, MinusOutlined, PlusOutlined } from '@ant-design/icons';
|
|
3
|
+
import { Typography, Spin, Input, Tooltip as Tooltip$1, Button, Flex, Form, Card, List, Space, Popconfirm, Empty, Modal, message, Alert, Skeleton, Result, Splitter, Image as Image$1, Drawer, Avatar, notification } from 'antd';
|
|
4
4
|
import classNames2 from 'classnames';
|
|
5
5
|
import { renderAsync } from 'docx-preview';
|
|
6
|
-
import * as
|
|
7
|
-
import
|
|
6
|
+
import * as React3 from 'react';
|
|
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
8
|
import AES from 'crypto-js/aes';
|
|
9
9
|
import encUtf8 from 'crypto-js/enc-utf8';
|
|
10
10
|
import { convert } from 'html-to-text';
|
|
11
|
+
import { jsonrepair } from 'jsonrepair';
|
|
11
12
|
import MarkdownIt from 'markdown-it';
|
|
12
13
|
import markdownItDefList from 'markdown-it-deflist';
|
|
13
14
|
import { full } from 'markdown-it-emoji';
|
|
@@ -20,7 +21,6 @@ import relativeTime from 'dayjs/plugin/relativeTime';
|
|
|
20
21
|
import axios from 'axios';
|
|
21
22
|
import markdownItKatex from '@traptitech/markdown-it-katex';
|
|
22
23
|
import parse from 'html-react-parser';
|
|
23
|
-
import { jsonrepair } from 'jsonrepair';
|
|
24
24
|
import 'katex/dist/katex.min.css';
|
|
25
25
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
26
26
|
import { Worker, Viewer, PasswordStatus } from '@react-pdf-viewer/core';
|
|
@@ -32,6 +32,9 @@ import zh_CN from '@react-pdf-viewer/locales/lib/zh_CN.json';
|
|
|
32
32
|
import '@react-pdf-viewer/page-navigation/lib/styles/index.css';
|
|
33
33
|
import '@react-pdf-viewer/thumbnail/lib/styles/index.css';
|
|
34
34
|
import '@react-pdf-viewer/zoom/lib/styles/index.css';
|
|
35
|
+
import Editor, { loader } from '@monaco-editor/react';
|
|
36
|
+
import * as monaco from 'monaco-editor';
|
|
37
|
+
import * as pdfjsLib from 'pdfjs-dist-v5/legacy/build/pdf.mjs';
|
|
35
38
|
import microApp from '@micro-zoe/micro-app';
|
|
36
39
|
import jsxCustomEvent from '@micro-zoe/micro-app/polyfill/jsx-custom-event';
|
|
37
40
|
import { mergeAttributes, useEditor, EditorContext, EditorContent, isNodeSelection, posToDOMRect, useCurrentEditor, useEditorState, isTextSelection } from '@tiptap/react';
|
|
@@ -82,7 +85,14 @@ var styles_module_default = {
|
|
|
82
85
|
nsPreviewAudio: "styles_module_nsPreviewAudio",
|
|
83
86
|
nsPreviewDocx: "styles_module_nsPreviewDocx",
|
|
84
87
|
docxToolbar: "styles_module_docxToolbar",
|
|
85
|
-
docxContent: "styles_module_docxContent"
|
|
88
|
+
docxContent: "styles_module_docxContent",
|
|
89
|
+
stateBody: "styles_module_stateBody",
|
|
90
|
+
pdfContainer: "styles_module_pdfContainer",
|
|
91
|
+
floatingToolbar: "styles_module_floatingToolbar",
|
|
92
|
+
divider: "styles_module_divider",
|
|
93
|
+
pdfBody: "styles_module_pdfBody",
|
|
94
|
+
pdfDocument: "styles_module_pdfDocument",
|
|
95
|
+
pdfPage: "styles_module_pdfPage"
|
|
86
96
|
};
|
|
87
97
|
var AudioPlayer_default = ({ fileUrl }) => {
|
|
88
98
|
return /* @__PURE__ */ jsxs("audio", { controls: true, className: styles_module_default.nsPreviewAudio, children: [
|
|
@@ -870,6 +880,21 @@ var findTreeNodesByIds = (tree, ids, formatFn, options = {}) => {
|
|
|
870
880
|
dfs(tree);
|
|
871
881
|
return result;
|
|
872
882
|
};
|
|
883
|
+
function safeParseJson(raw, options = {}) {
|
|
884
|
+
const shouldRepair = options.repair ?? false;
|
|
885
|
+
const fallbackMode = options.fallback ?? "raw";
|
|
886
|
+
const getFallbackValue = () => fallbackMode === "raw" ? raw : null;
|
|
887
|
+
try {
|
|
888
|
+
return JSON.parse(raw);
|
|
889
|
+
} catch {
|
|
890
|
+
if (!shouldRepair) return getFallbackValue();
|
|
891
|
+
}
|
|
892
|
+
try {
|
|
893
|
+
return JSON.parse(jsonrepair(raw));
|
|
894
|
+
} catch {
|
|
895
|
+
return getFallbackValue();
|
|
896
|
+
}
|
|
897
|
+
}
|
|
873
898
|
dayjs.extend(relativeTime);
|
|
874
899
|
var DEFAULT_DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
875
900
|
var DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
@@ -1289,6 +1314,13 @@ var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
|
1289
1314
|
const Icon = useMemo(() => {
|
|
1290
1315
|
switch (suffix?.toUpperCase()) {
|
|
1291
1316
|
case "TXT":
|
|
1317
|
+
case "LOG":
|
|
1318
|
+
case "JSON":
|
|
1319
|
+
case "XML":
|
|
1320
|
+
case "YML":
|
|
1321
|
+
case "YAML":
|
|
1322
|
+
case "INI":
|
|
1323
|
+
case "CONF":
|
|
1292
1324
|
return /* @__PURE__ */ jsx(FileTextOutlined, {});
|
|
1293
1325
|
case "PDF":
|
|
1294
1326
|
return /* @__PURE__ */ jsx(FilePdfOutlined, {});
|
|
@@ -1297,8 +1329,10 @@ var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
|
1297
1329
|
return /* @__PURE__ */ jsx(FileWordOutlined, {});
|
|
1298
1330
|
case "XLS":
|
|
1299
1331
|
case "XLSX":
|
|
1332
|
+
case "CSV":
|
|
1300
1333
|
return /* @__PURE__ */ jsx(FileExcelOutlined, {});
|
|
1301
1334
|
case "PPT":
|
|
1335
|
+
case "PPTX":
|
|
1302
1336
|
return /* @__PURE__ */ jsx(FilePptOutlined, {});
|
|
1303
1337
|
case "MP4":
|
|
1304
1338
|
case "MOV":
|
|
@@ -1316,6 +1350,7 @@ var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
|
1316
1350
|
case "JPEG":
|
|
1317
1351
|
return /* @__PURE__ */ jsx(FileJpgOutlined, {});
|
|
1318
1352
|
case "PNG":
|
|
1353
|
+
case "WEBP":
|
|
1319
1354
|
return /* @__PURE__ */ jsx(FileImageOutlined, {});
|
|
1320
1355
|
case "GIF":
|
|
1321
1356
|
return /* @__PURE__ */ jsx(FileGifOutlined, {});
|
|
@@ -1325,6 +1360,8 @@ var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
|
1325
1360
|
case "ZIP":
|
|
1326
1361
|
case "RAR":
|
|
1327
1362
|
case "7Z":
|
|
1363
|
+
case "TAR":
|
|
1364
|
+
case "GZ":
|
|
1328
1365
|
return /* @__PURE__ */ jsx(FileZipOutlined, {});
|
|
1329
1366
|
case "CATALOG":
|
|
1330
1367
|
return /* @__PURE__ */ jsx("i", { style: styles, className: "iconfont icon-wenjianjia" });
|
|
@@ -1351,15 +1388,15 @@ var baseComponentMap = {
|
|
|
1351
1388
|
};
|
|
1352
1389
|
var lazyCache = /* @__PURE__ */ new Map();
|
|
1353
1390
|
var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
|
|
1354
|
-
const
|
|
1391
|
+
const loader2 = customComponents?.[type] || baseComponentMap[type];
|
|
1355
1392
|
const LazyComponent = useMemo(() => {
|
|
1356
|
-
if (!
|
|
1393
|
+
if (!loader2) return null;
|
|
1357
1394
|
const cached = lazyCache.get(type);
|
|
1358
1395
|
if (cached) return cached;
|
|
1359
|
-
const component = lazy(
|
|
1396
|
+
const component = lazy(loader2);
|
|
1360
1397
|
lazyCache.set(type, component);
|
|
1361
1398
|
return component;
|
|
1362
|
-
}, [
|
|
1399
|
+
}, [loader2]);
|
|
1363
1400
|
if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsx(Alert, { title: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
|
|
1364
1401
|
return /* @__PURE__ */ jsx(
|
|
1365
1402
|
Suspense,
|
|
@@ -1375,19 +1412,6 @@ md.renderer.rules.link_open = function(tokens, idx, options, env, self) {
|
|
|
1375
1412
|
token.attrPush(["target", "_blank"]);
|
|
1376
1413
|
return self.renderToken(tokens, idx, options);
|
|
1377
1414
|
};
|
|
1378
|
-
function parseData(raw) {
|
|
1379
|
-
let obj = {};
|
|
1380
|
-
try {
|
|
1381
|
-
obj = JSON.parse(raw);
|
|
1382
|
-
} catch {
|
|
1383
|
-
try {
|
|
1384
|
-
obj = JSON.parse(jsonrepair(raw));
|
|
1385
|
-
} catch {
|
|
1386
|
-
obj = { _raw: raw };
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
return obj;
|
|
1390
|
-
}
|
|
1391
1415
|
function highlightKeywords(html, keywords) {
|
|
1392
1416
|
const escaped = keywords.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
1393
1417
|
const regex = new RegExp(`(${escaped.join("|")})`, "gi");
|
|
@@ -1479,7 +1503,7 @@ var RenderMarkdown_default = ({ content = "", searchValue, customComponents, ...
|
|
|
1479
1503
|
let data = {};
|
|
1480
1504
|
if (/^__ALERT_DATA_\d+__$/.test(dataAttr)) {
|
|
1481
1505
|
const raw = placeholders.get(dataAttr) ?? "";
|
|
1482
|
-
data =
|
|
1506
|
+
data = safeParseJson(raw, { repair: true, fallback: "null" }) ?? { _raw: raw };
|
|
1483
1507
|
}
|
|
1484
1508
|
return /* @__PURE__ */ jsx(LazyComponent_default, { customComponents, type, data, loading, ...rest }, `${type}${lazyIndex}`);
|
|
1485
1509
|
}
|
|
@@ -2620,6 +2644,533 @@ var FilePreview_default = ({ suffix, fileUrl, pdfParams, password, searchValue,
|
|
|
2620
2644
|
}, [suffix, fileUrl, pdfParams]);
|
|
2621
2645
|
return /* @__PURE__ */ jsx(Flex, { justify: "center", align: "center", className: "height-full", children: Preview });
|
|
2622
2646
|
};
|
|
2647
|
+
loader.config({ monaco });
|
|
2648
|
+
var getLanguage = (suffix) => {
|
|
2649
|
+
switch (suffix.toLowerCase()) {
|
|
2650
|
+
case "ts":
|
|
2651
|
+
case "tsx":
|
|
2652
|
+
return "typescript";
|
|
2653
|
+
case "js":
|
|
2654
|
+
case "jsx":
|
|
2655
|
+
return "javascript";
|
|
2656
|
+
case "json":
|
|
2657
|
+
return "json";
|
|
2658
|
+
case "css":
|
|
2659
|
+
return "css";
|
|
2660
|
+
case "less":
|
|
2661
|
+
return "less";
|
|
2662
|
+
case "scss":
|
|
2663
|
+
return "scss";
|
|
2664
|
+
case "html":
|
|
2665
|
+
case "htm":
|
|
2666
|
+
return "html";
|
|
2667
|
+
case "xml":
|
|
2668
|
+
return "xml";
|
|
2669
|
+
case "py":
|
|
2670
|
+
return "python";
|
|
2671
|
+
case "java":
|
|
2672
|
+
return "java";
|
|
2673
|
+
case "go":
|
|
2674
|
+
return "go";
|
|
2675
|
+
case "yaml":
|
|
2676
|
+
case "yml":
|
|
2677
|
+
return "yaml";
|
|
2678
|
+
case "md":
|
|
2679
|
+
case "markdown":
|
|
2680
|
+
return "markdown";
|
|
2681
|
+
default:
|
|
2682
|
+
return "plaintext";
|
|
2683
|
+
}
|
|
2684
|
+
};
|
|
2685
|
+
var CodePreview = ({ fileUrl, suffix }) => {
|
|
2686
|
+
const [content, setContent] = useState("");
|
|
2687
|
+
const [error, setError] = useState("");
|
|
2688
|
+
const [loading, setLoading] = useState(false);
|
|
2689
|
+
const fetchContent = async (signal) => {
|
|
2690
|
+
const headers = {
|
|
2691
|
+
"Content-Type": "application/json"
|
|
2692
|
+
};
|
|
2693
|
+
const res = await fetch(fileUrl, { headers, signal });
|
|
2694
|
+
if (res.status !== 200) {
|
|
2695
|
+
throw new Error(`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${res.status}`);
|
|
2696
|
+
}
|
|
2697
|
+
const buffer = await res.arrayBuffer();
|
|
2698
|
+
let text = "";
|
|
2699
|
+
try {
|
|
2700
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
2701
|
+
text = decoder.decode(buffer);
|
|
2702
|
+
} catch (e) {
|
|
2703
|
+
const gbkDecoder = new TextDecoder("gbk");
|
|
2704
|
+
text = gbkDecoder.decode(buffer);
|
|
2705
|
+
}
|
|
2706
|
+
setContent(text);
|
|
2707
|
+
};
|
|
2708
|
+
useEffect(() => {
|
|
2709
|
+
const controller = new AbortController();
|
|
2710
|
+
const init = async () => {
|
|
2711
|
+
setContent("");
|
|
2712
|
+
setError("");
|
|
2713
|
+
if (fileUrl) {
|
|
2714
|
+
try {
|
|
2715
|
+
setLoading(true);
|
|
2716
|
+
await fetchContent(controller.signal);
|
|
2717
|
+
} catch (error2) {
|
|
2718
|
+
if (!controller.signal.aborted) {
|
|
2719
|
+
setError("\u52A0\u8F7D\u6587\u4EF6\u5931\u8D25");
|
|
2720
|
+
}
|
|
2721
|
+
} finally {
|
|
2722
|
+
if (!controller.signal.aborted) {
|
|
2723
|
+
setLoading(false);
|
|
2724
|
+
}
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
};
|
|
2728
|
+
init();
|
|
2729
|
+
return () => {
|
|
2730
|
+
controller.abort();
|
|
2731
|
+
};
|
|
2732
|
+
}, [fileUrl]);
|
|
2733
|
+
if (error) {
|
|
2734
|
+
return /* @__PURE__ */ jsx(Result, { status: "error", title: error });
|
|
2735
|
+
}
|
|
2736
|
+
return /* @__PURE__ */ jsx("div", { style: { height: "100%", width: "100%", position: "relative" }, children: loading ? /* @__PURE__ */ jsx("div", { style: { position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }, children: /* @__PURE__ */ jsx(Spin, {}) }) : /* @__PURE__ */ jsx(
|
|
2737
|
+
Editor,
|
|
2738
|
+
{
|
|
2739
|
+
height: "100%",
|
|
2740
|
+
defaultLanguage: getLanguage(suffix || ""),
|
|
2741
|
+
value: content,
|
|
2742
|
+
options: {
|
|
2743
|
+
readOnly: true,
|
|
2744
|
+
minimap: { enabled: false },
|
|
2745
|
+
lineNumbers: "on",
|
|
2746
|
+
wordWrap: "on",
|
|
2747
|
+
fontSize: 14,
|
|
2748
|
+
unicodeHighlight: {
|
|
2749
|
+
invisibleCharacters: false,
|
|
2750
|
+
ambiguousCharacters: false
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
) });
|
|
2755
|
+
};
|
|
2756
|
+
var CodePreview_default = CodePreview;
|
|
2757
|
+
var { Text } = Typography;
|
|
2758
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = new URL("./pdf.worker.min.mjs", import.meta.url).toString();
|
|
2759
|
+
var MIN_SCALE = 0.6;
|
|
2760
|
+
var MAX_SCALE = 1.5;
|
|
2761
|
+
var SCALE_STEP = 0.1;
|
|
2762
|
+
var PdfPage = React3__default.memo(({ pdf, pageNumber, scale, scrollContainerRef, defaultSize }) => {
|
|
2763
|
+
const canvasRef = useRef(null);
|
|
2764
|
+
const containerRef = useRef(null);
|
|
2765
|
+
const [loading, setLoading] = useState(false);
|
|
2766
|
+
const renderTaskRef = useRef(null);
|
|
2767
|
+
const [dimensions, setDimensions] = useState(null);
|
|
2768
|
+
const [shouldRender2, setShouldRender] = useState(false);
|
|
2769
|
+
useEffect(() => {
|
|
2770
|
+
const el = containerRef.current;
|
|
2771
|
+
if (!el) return;
|
|
2772
|
+
const renderObserver = new IntersectionObserver(
|
|
2773
|
+
([entry]) => {
|
|
2774
|
+
setShouldRender(entry.isIntersecting);
|
|
2775
|
+
},
|
|
2776
|
+
{
|
|
2777
|
+
root: scrollContainerRef.current,
|
|
2778
|
+
rootMargin: "100% 0px"
|
|
2779
|
+
}
|
|
2780
|
+
);
|
|
2781
|
+
renderObserver.observe(el);
|
|
2782
|
+
return () => {
|
|
2783
|
+
renderObserver.disconnect();
|
|
2784
|
+
};
|
|
2785
|
+
}, [scrollContainerRef]);
|
|
2786
|
+
useEffect(() => {
|
|
2787
|
+
setDimensions(null);
|
|
2788
|
+
}, [scale]);
|
|
2789
|
+
useEffect(() => {
|
|
2790
|
+
if (!shouldRender2 || !pdf || !canvasRef.current) return;
|
|
2791
|
+
const render = async () => {
|
|
2792
|
+
if (renderTaskRef.current) {
|
|
2793
|
+
renderTaskRef.current.cancel();
|
|
2794
|
+
}
|
|
2795
|
+
try {
|
|
2796
|
+
setLoading(true);
|
|
2797
|
+
const page = await pdf.getPage(pageNumber);
|
|
2798
|
+
const dpr = window.devicePixelRatio || 1;
|
|
2799
|
+
const viewport = page.getViewport({ scale });
|
|
2800
|
+
const nextDimensions = { width: viewport.width, height: viewport.height };
|
|
2801
|
+
setDimensions(nextDimensions);
|
|
2802
|
+
const canvas = canvasRef.current;
|
|
2803
|
+
if (!canvas) return;
|
|
2804
|
+
const ctx = canvas.getContext("2d");
|
|
2805
|
+
if (!ctx) return;
|
|
2806
|
+
canvas.width = Math.floor(viewport.width * dpr);
|
|
2807
|
+
canvas.height = Math.floor(viewport.height * dpr);
|
|
2808
|
+
canvas.style.width = `${viewport.width}px`;
|
|
2809
|
+
canvas.style.height = `${viewport.height}px`;
|
|
2810
|
+
const renderTask = page.render({
|
|
2811
|
+
canvasContext: ctx,
|
|
2812
|
+
viewport,
|
|
2813
|
+
transform: [dpr, 0, 0, dpr, 0, 0]
|
|
2814
|
+
});
|
|
2815
|
+
renderTaskRef.current = renderTask;
|
|
2816
|
+
await renderTask.promise;
|
|
2817
|
+
setLoading(false);
|
|
2818
|
+
} catch (error) {
|
|
2819
|
+
if (error.name !== "RenderingCancelledException") {
|
|
2820
|
+
console.error(`Error rendering page ${pageNumber}:`, error);
|
|
2821
|
+
}
|
|
2822
|
+
setLoading(false);
|
|
2823
|
+
}
|
|
2824
|
+
};
|
|
2825
|
+
render();
|
|
2826
|
+
return () => {
|
|
2827
|
+
if (renderTaskRef.current) {
|
|
2828
|
+
renderTaskRef.current.cancel();
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
}, [shouldRender2, pdf, pageNumber, scale]);
|
|
2832
|
+
const width = dimensions?.width || defaultSize?.width || "100%";
|
|
2833
|
+
const height = dimensions?.height || defaultSize?.height || 800;
|
|
2834
|
+
return /* @__PURE__ */ jsx(
|
|
2835
|
+
"div",
|
|
2836
|
+
{
|
|
2837
|
+
ref: containerRef,
|
|
2838
|
+
className: styles_module_default.pdfPage,
|
|
2839
|
+
id: `pdf-page-${pageNumber}`,
|
|
2840
|
+
style: {
|
|
2841
|
+
width,
|
|
2842
|
+
height,
|
|
2843
|
+
position: "relative"
|
|
2844
|
+
},
|
|
2845
|
+
children: shouldRender2 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2846
|
+
/* @__PURE__ */ jsx("canvas", { ref: canvasRef, style: { display: "block" } }),
|
|
2847
|
+
loading && /* @__PURE__ */ jsx(
|
|
2848
|
+
"div",
|
|
2849
|
+
{
|
|
2850
|
+
style: {
|
|
2851
|
+
position: "absolute",
|
|
2852
|
+
top: 0,
|
|
2853
|
+
left: 0,
|
|
2854
|
+
right: 0,
|
|
2855
|
+
bottom: 0,
|
|
2856
|
+
display: "flex",
|
|
2857
|
+
alignItems: "center",
|
|
2858
|
+
justifyContent: "center",
|
|
2859
|
+
background: "rgba(255,255,255,0.8)"
|
|
2860
|
+
},
|
|
2861
|
+
children: /* @__PURE__ */ jsx(Spin, {})
|
|
2862
|
+
}
|
|
2863
|
+
)
|
|
2864
|
+
] })
|
|
2865
|
+
}
|
|
2866
|
+
);
|
|
2867
|
+
});
|
|
2868
|
+
var DocumentPreview = ({ fileUrl, previewEnabled = true }) => {
|
|
2869
|
+
const [loading, setLoading] = useState(false);
|
|
2870
|
+
const [pdf, setPdf] = useState(null);
|
|
2871
|
+
const [numPages, setNumPages] = useState(0);
|
|
2872
|
+
const [pageNumber, setPageNumber] = useState(1);
|
|
2873
|
+
const [scale, setScale] = useState(1);
|
|
2874
|
+
const [error, setError] = useState(null);
|
|
2875
|
+
const containerRef = useRef(null);
|
|
2876
|
+
const pdfLoadingTaskRef = useRef(null);
|
|
2877
|
+
const [defaultSize, setDefaultSize] = useState(void 0);
|
|
2878
|
+
useEffect(() => {
|
|
2879
|
+
let aborted = false;
|
|
2880
|
+
const load = async () => {
|
|
2881
|
+
if (pdfLoadingTaskRef.current) {
|
|
2882
|
+
try {
|
|
2883
|
+
pdfLoadingTaskRef.current.destroy();
|
|
2884
|
+
} catch (e) {
|
|
2885
|
+
}
|
|
2886
|
+
pdfLoadingTaskRef.current = null;
|
|
2887
|
+
}
|
|
2888
|
+
setError(null);
|
|
2889
|
+
setPdf(null);
|
|
2890
|
+
setNumPages(0);
|
|
2891
|
+
setPageNumber(1);
|
|
2892
|
+
setDefaultSize(void 0);
|
|
2893
|
+
if (!previewEnabled || !fileUrl) {
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
2896
|
+
setLoading(true);
|
|
2897
|
+
try {
|
|
2898
|
+
const loadingTask = pdfjsLib.getDocument({
|
|
2899
|
+
url: fileUrl,
|
|
2900
|
+
disableFontFace: true,
|
|
2901
|
+
// 强制将所有字体转换为路径绘制,解决浏览器字体加载拦截/失败导致的文字空白问题
|
|
2902
|
+
disableAutoFetch: true,
|
|
2903
|
+
disableStream: true,
|
|
2904
|
+
rangeChunkSize: 1024 * 512
|
|
2905
|
+
});
|
|
2906
|
+
pdfLoadingTaskRef.current = loadingTask;
|
|
2907
|
+
const doc = await loadingTask.promise;
|
|
2908
|
+
if (aborted) return;
|
|
2909
|
+
setPdf(doc);
|
|
2910
|
+
setNumPages(doc.numPages);
|
|
2911
|
+
setPageNumber(1);
|
|
2912
|
+
if (containerRef.current) {
|
|
2913
|
+
containerRef.current.scrollTop = 0;
|
|
2914
|
+
}
|
|
2915
|
+
try {
|
|
2916
|
+
const page1 = await doc.getPage(1);
|
|
2917
|
+
const viewport = page1.getViewport({ scale: 1 });
|
|
2918
|
+
if (!aborted) {
|
|
2919
|
+
setDefaultSize({ width: viewport.width, height: viewport.height });
|
|
2920
|
+
}
|
|
2921
|
+
} catch (e) {
|
|
2922
|
+
console.warn("Failed to get page 1 size", e);
|
|
2923
|
+
}
|
|
2924
|
+
} catch (e) {
|
|
2925
|
+
if (aborted) return;
|
|
2926
|
+
const message3 = e?.message;
|
|
2927
|
+
if (typeof message3 === "string" && message3.includes("cancelled")) ; else if (typeof message3 === "string" && message3.includes("(903)")) {
|
|
2928
|
+
setError("\u9884\u89C8\u6587\u4EF6\u6B63\u5728\u751F\u6210\u4E2D...");
|
|
2929
|
+
} else {
|
|
2930
|
+
setError(message3 || "PDF \u52A0\u8F7D\u5931\u8D25");
|
|
2931
|
+
}
|
|
2932
|
+
} finally {
|
|
2933
|
+
if (!aborted) {
|
|
2934
|
+
setLoading(false);
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
2938
|
+
load();
|
|
2939
|
+
return () => {
|
|
2940
|
+
aborted = true;
|
|
2941
|
+
if (pdfLoadingTaskRef.current) {
|
|
2942
|
+
try {
|
|
2943
|
+
pdfLoadingTaskRef.current.destroy();
|
|
2944
|
+
} catch (e) {
|
|
2945
|
+
}
|
|
2946
|
+
pdfLoadingTaskRef.current = null;
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2949
|
+
}, [fileUrl, previewEnabled]);
|
|
2950
|
+
useEffect(() => {
|
|
2951
|
+
const container = containerRef.current;
|
|
2952
|
+
if (!container || numPages === 0) return;
|
|
2953
|
+
let rafId = 0;
|
|
2954
|
+
const onScroll = () => {
|
|
2955
|
+
if (rafId) return;
|
|
2956
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2957
|
+
rafId = 0;
|
|
2958
|
+
const { scrollTop, clientHeight, scrollHeight } = container;
|
|
2959
|
+
if (scrollTop <= 10) {
|
|
2960
|
+
setPageNumber(1);
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
if (scrollTop + clientHeight >= scrollHeight - 10) {
|
|
2964
|
+
setPageNumber(numPages);
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
const containerRect = container.getBoundingClientRect();
|
|
2968
|
+
const centerY = containerRect.top + clientHeight / 2;
|
|
2969
|
+
let closestPage = 1;
|
|
2970
|
+
let closestDistance = Number.POSITIVE_INFINITY;
|
|
2971
|
+
for (let i = 1; i <= numPages; i++) {
|
|
2972
|
+
const el = window.document.getElementById(`pdf-page-${i}`);
|
|
2973
|
+
if (!el) continue;
|
|
2974
|
+
const rect = el.getBoundingClientRect();
|
|
2975
|
+
const pageCenter = rect.top + rect.height / 2;
|
|
2976
|
+
const distance = Math.abs(pageCenter - centerY);
|
|
2977
|
+
if (distance < closestDistance) {
|
|
2978
|
+
closestDistance = distance;
|
|
2979
|
+
closestPage = i;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
setPageNumber(closestPage);
|
|
2983
|
+
});
|
|
2984
|
+
};
|
|
2985
|
+
container.addEventListener("scroll", onScroll, { passive: true });
|
|
2986
|
+
return () => {
|
|
2987
|
+
if (rafId) window.cancelAnimationFrame(rafId);
|
|
2988
|
+
container.removeEventListener("scroll", onScroll);
|
|
2989
|
+
};
|
|
2990
|
+
}, [numPages]);
|
|
2991
|
+
const scrollToPage = (pageNum) => {
|
|
2992
|
+
const container = containerRef.current;
|
|
2993
|
+
const el = window.document.getElementById(`pdf-page-${pageNum}`);
|
|
2994
|
+
if (container && el) {
|
|
2995
|
+
el.scrollIntoView({ behavior: "smooth" });
|
|
2996
|
+
setPageNumber(pageNum);
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2999
|
+
const onPrev = () => {
|
|
3000
|
+
scrollToPage(Math.max(1, pageNumber - 1));
|
|
3001
|
+
};
|
|
3002
|
+
const onNext = () => {
|
|
3003
|
+
scrollToPage(Math.min(numPages, pageNumber + 1));
|
|
3004
|
+
};
|
|
3005
|
+
const onZoomOut = () => {
|
|
3006
|
+
setScale((s) => Math.max(MIN_SCALE, parseFloat((s - SCALE_STEP).toFixed(2))));
|
|
3007
|
+
};
|
|
3008
|
+
const onZoomIn = () => {
|
|
3009
|
+
setScale((s) => Math.min(MAX_SCALE, parseFloat((s + SCALE_STEP).toFixed(2))));
|
|
3010
|
+
};
|
|
3011
|
+
const currentDefaultSize = useMemo(() => {
|
|
3012
|
+
if (!defaultSize) return void 0;
|
|
3013
|
+
return {
|
|
3014
|
+
width: defaultSize.width * scale,
|
|
3015
|
+
height: defaultSize.height * scale
|
|
3016
|
+
};
|
|
3017
|
+
}, [defaultSize, scale]);
|
|
3018
|
+
const toolbar = /* @__PURE__ */ jsxs("div", { className: styles_module_default.floatingToolbar, children: [
|
|
3019
|
+
/* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(LeftOutlined, {}), size: "small", onClick: onPrev, disabled: pageNumber <= 1 }),
|
|
3020
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3021
|
+
Math.min(pageNumber, numPages),
|
|
3022
|
+
" / ",
|
|
3023
|
+
numPages || 0
|
|
3024
|
+
] }),
|
|
3025
|
+
/* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(RightOutlined, {}), size: "small", onClick: onNext, disabled: pageNumber >= numPages || numPages === 0 }),
|
|
3026
|
+
/* @__PURE__ */ jsx("div", { className: styles_module_default.divider }),
|
|
3027
|
+
/* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(MinusOutlined, {}), size: "small", onClick: onZoomOut, disabled: scale <= MIN_SCALE }),
|
|
3028
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
3029
|
+
Math.round(scale * 100),
|
|
3030
|
+
"%"
|
|
3031
|
+
] }),
|
|
3032
|
+
/* @__PURE__ */ jsx(Button, { type: "text", icon: /* @__PURE__ */ jsx(PlusOutlined, {}), size: "small", onClick: onZoomIn, disabled: scale >= MAX_SCALE })
|
|
3033
|
+
] });
|
|
3034
|
+
if (!previewEnabled) {
|
|
3035
|
+
return /* @__PURE__ */ jsx(Flex, { className: styles_module_default.stateBody, children: "\u5173\u95ED\u9884\u89C8" });
|
|
3036
|
+
}
|
|
3037
|
+
return /* @__PURE__ */ jsxs("div", { className: styles_module_default.pdfContainer, children: [
|
|
3038
|
+
toolbar,
|
|
3039
|
+
/* @__PURE__ */ jsx("div", { className: styles_module_default.pdfBody, ref: containerRef, children: /* @__PURE__ */ jsx("div", { className: classNames2(styles_module_default.pdfDocument, "width-full"), children: loading && !pdf ? /* @__PURE__ */ jsx(Spin, { spinning: true }) : error ? /* @__PURE__ */ jsx(Flex, { className: styles_module_default.stateBody, children: error }) : Array.from({ length: numPages }, (_, i) => /* @__PURE__ */ jsx(PdfPage, { pdf, pageNumber: i + 1, scale, scrollContainerRef: containerRef, defaultSize: currentDefaultSize }, i + 1)) }) })
|
|
3040
|
+
] });
|
|
3041
|
+
};
|
|
3042
|
+
var DocumentPreview_default = DocumentPreview;
|
|
3043
|
+
var HtmlPreview = ({ fileUrl }) => {
|
|
3044
|
+
const [content, setContent] = useState("");
|
|
3045
|
+
const [error, setError] = useState("");
|
|
3046
|
+
const [loading, setLoading] = useState(false);
|
|
3047
|
+
const fetchHtml = async (signal) => {
|
|
3048
|
+
const headers = {
|
|
3049
|
+
"Content-Type": "application/json"
|
|
3050
|
+
};
|
|
3051
|
+
const res = await fetch(fileUrl, {
|
|
3052
|
+
headers,
|
|
3053
|
+
signal
|
|
3054
|
+
});
|
|
3055
|
+
if (res.status !== 200) {
|
|
3056
|
+
throw new Error(`\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${res.status}`);
|
|
3057
|
+
}
|
|
3058
|
+
const buffer = await res.arrayBuffer();
|
|
3059
|
+
let htmlText = "";
|
|
3060
|
+
try {
|
|
3061
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
3062
|
+
htmlText = decoder.decode(buffer);
|
|
3063
|
+
} catch (e) {
|
|
3064
|
+
const gbkDecoder = new TextDecoder("gbk");
|
|
3065
|
+
htmlText = gbkDecoder.decode(buffer);
|
|
3066
|
+
}
|
|
3067
|
+
if (!htmlText) {
|
|
3068
|
+
throw new Error("\u8FD4\u56DE\u5185\u5BB9\u4E3A\u7A7A");
|
|
3069
|
+
}
|
|
3070
|
+
setContent(htmlText);
|
|
3071
|
+
};
|
|
3072
|
+
useEffect(() => {
|
|
3073
|
+
const controller = new AbortController();
|
|
3074
|
+
const init = async () => {
|
|
3075
|
+
setContent("");
|
|
3076
|
+
setError("");
|
|
3077
|
+
if (fileUrl) {
|
|
3078
|
+
try {
|
|
3079
|
+
setLoading(true);
|
|
3080
|
+
await fetchHtml(controller.signal);
|
|
3081
|
+
} catch (error2) {
|
|
3082
|
+
if (!controller.signal.aborted) {
|
|
3083
|
+
setError("\u52A0\u8F7D\u6216\u89E3\u6790 HTML \u5931\u8D25");
|
|
3084
|
+
}
|
|
3085
|
+
} finally {
|
|
3086
|
+
if (!controller.signal.aborted) {
|
|
3087
|
+
setLoading(false);
|
|
3088
|
+
}
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
};
|
|
3092
|
+
init();
|
|
3093
|
+
return () => {
|
|
3094
|
+
controller.abort();
|
|
3095
|
+
};
|
|
3096
|
+
}, [fileUrl]);
|
|
3097
|
+
return error ? /* @__PURE__ */ jsx(Result, { status: "error", title: error }) : /* @__PURE__ */ jsx("div", { style: { height: "100%", width: "100%", position: "relative" }, children: loading ? /* @__PURE__ */ jsx("div", { style: { position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }, children: /* @__PURE__ */ jsx(Spin, {}) }) : content ? /* @__PURE__ */ jsx(
|
|
3098
|
+
"iframe",
|
|
3099
|
+
{
|
|
3100
|
+
srcDoc: content,
|
|
3101
|
+
style: { width: "100%", height: "100%", border: "none" },
|
|
3102
|
+
sandbox: "allow-scripts allow-same-origin allow-popups allow-forms",
|
|
3103
|
+
title: "HTML Preview"
|
|
3104
|
+
}
|
|
3105
|
+
) : null });
|
|
3106
|
+
};
|
|
3107
|
+
var HtmlPreview_default = HtmlPreview;
|
|
3108
|
+
var luyaFilePreview_default = ({ suffix, fileUrl, emptyProps, fileName }) => {
|
|
3109
|
+
const extension = suffix ? suffix : getFileSuffixName(fileName || "");
|
|
3110
|
+
const Preview = useMemo(() => {
|
|
3111
|
+
if (!fileUrl) {
|
|
3112
|
+
return /* @__PURE__ */ jsx(Empty, { ...emptyProps });
|
|
3113
|
+
}
|
|
3114
|
+
switch (extension?.toUpperCase()) {
|
|
3115
|
+
case "PNG":
|
|
3116
|
+
case "JPG":
|
|
3117
|
+
case "JPEG":
|
|
3118
|
+
case "GIF":
|
|
3119
|
+
case "BMP":
|
|
3120
|
+
case "WEBP":
|
|
3121
|
+
case "SVG":
|
|
3122
|
+
case "ICO":
|
|
3123
|
+
case "TIFF":
|
|
3124
|
+
return /* @__PURE__ */ jsx(Image$1, { classNames: { root: styles_module_default.nsPreviewImage }, src: fileUrl, alt: "\u9884\u89C8\u56FE\u7247" });
|
|
3125
|
+
case "DOC":
|
|
3126
|
+
case "DOCX":
|
|
3127
|
+
case "PDF":
|
|
3128
|
+
case "XLS":
|
|
3129
|
+
case "XLSX":
|
|
3130
|
+
case "PPT":
|
|
3131
|
+
case "PPTX":
|
|
3132
|
+
case "CSV":
|
|
3133
|
+
return /* @__PURE__ */ jsx(DocumentPreview_default, { fileUrl });
|
|
3134
|
+
case "MP4":
|
|
3135
|
+
return /* @__PURE__ */ jsx(VideoPlayer_default, { fileUrl });
|
|
3136
|
+
case "MP3":
|
|
3137
|
+
case "WAV":
|
|
3138
|
+
case "M4A":
|
|
3139
|
+
case "AAC":
|
|
3140
|
+
case "ACC":
|
|
3141
|
+
return /* @__PURE__ */ jsx(AudioPlayer_default, { fileUrl });
|
|
3142
|
+
case "HTML":
|
|
3143
|
+
case "HTM":
|
|
3144
|
+
return /* @__PURE__ */ jsx(HtmlPreview_default, { fileUrl });
|
|
3145
|
+
case "MD":
|
|
3146
|
+
case "MARKDOWN":
|
|
3147
|
+
return /* @__PURE__ */ jsx(MarkdownPreview_default, { fileUrl });
|
|
3148
|
+
case "TS":
|
|
3149
|
+
case "TSX":
|
|
3150
|
+
case "JS":
|
|
3151
|
+
case "JSX":
|
|
3152
|
+
case "JSON":
|
|
3153
|
+
case "CSS":
|
|
3154
|
+
case "LESS":
|
|
3155
|
+
case "SCSS":
|
|
3156
|
+
case "XML":
|
|
3157
|
+
case "PY":
|
|
3158
|
+
case "JAVA":
|
|
3159
|
+
case "GO":
|
|
3160
|
+
case "YAML":
|
|
3161
|
+
case "YML":
|
|
3162
|
+
case "ENV":
|
|
3163
|
+
case "CONF":
|
|
3164
|
+
case "CONFIG":
|
|
3165
|
+
return /* @__PURE__ */ jsx(CodePreview_default, { fileUrl, suffix: extension });
|
|
3166
|
+
case "TXT":
|
|
3167
|
+
return /* @__PURE__ */ jsx(MarkdownPreview_default, { fileUrl, asPlainText: true });
|
|
3168
|
+
default:
|
|
3169
|
+
return /* @__PURE__ */ jsx(Result, { subTitle: `\u6682\u4E0D\u652F\u6301 ${suffix || ""} \u6587\u4EF6\u7684\u9884\u89C8` });
|
|
3170
|
+
}
|
|
3171
|
+
}, [suffix, fileUrl, fileName]);
|
|
3172
|
+
return /* @__PURE__ */ jsx(Flex, { justify: "center", align: "center", className: "height-full", children: Preview });
|
|
3173
|
+
};
|
|
2623
3174
|
var FilePreviewDrawer_default = ({ open, title = "\u6587\u4EF6\u9884\u89C8", onClose, ...props }) => {
|
|
2624
3175
|
return /* @__PURE__ */ jsx(
|
|
2625
3176
|
Drawer,
|
|
@@ -3467,7 +4018,7 @@ var styles_module_default6 = {
|
|
|
3467
4018
|
annotationItemSelected: "styles_module_annotationItemSelected"
|
|
3468
4019
|
};
|
|
3469
4020
|
var { TextArea: TextArea2 } = Input;
|
|
3470
|
-
var { Text } = Typography;
|
|
4021
|
+
var { Text: Text2 } = Typography;
|
|
3471
4022
|
var AnnotationSidebar_default = ({
|
|
3472
4023
|
disabled,
|
|
3473
4024
|
annotations,
|
|
@@ -3540,8 +4091,8 @@ var AnnotationSidebar_default = ({
|
|
|
3540
4091
|
},
|
|
3541
4092
|
children: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, flex: 1, children: [
|
|
3542
4093
|
/* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "space-between", className: styles_module_default6.annotationMeta, children: [
|
|
3543
|
-
/* @__PURE__ */ jsx(
|
|
3544
|
-
/* @__PURE__ */ jsx(
|
|
4094
|
+
/* @__PURE__ */ jsx(Text2, { strong: true, type: "secondary", children: annotation["user-name"] }),
|
|
4095
|
+
/* @__PURE__ */ jsx(Text2, { type: "secondary", children: formatDate(annotation["update-time"]) })
|
|
3545
4096
|
] }),
|
|
3546
4097
|
!disabled && (editingId === annotation[ANNOTATION_ATTRS[0]] ? /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
|
|
3547
4098
|
/* @__PURE__ */ jsx(Form, { form, children: /* @__PURE__ */ jsx(
|
|
@@ -3560,7 +4111,7 @@ var AnnotationSidebar_default = ({
|
|
|
3560
4111
|
/* @__PURE__ */ jsx(Button, { size: "small", onClick: handleCancelEdit, children: "\u53D6\u6D88" })
|
|
3561
4112
|
] })
|
|
3562
4113
|
] }) : /* @__PURE__ */ jsxs(Flex, { gap: 8, vertical: true, children: [
|
|
3563
|
-
/* @__PURE__ */ jsx(
|
|
4114
|
+
/* @__PURE__ */ jsx(Text2, { children: annotation.content }),
|
|
3564
4115
|
selectedAnnotationId === annotation[ANNOTATION_ATTRS[0]] && /* @__PURE__ */ jsxs(Space, { children: [
|
|
3565
4116
|
/* @__PURE__ */ jsx(
|
|
3566
4117
|
Button,
|
|
@@ -3600,7 +4151,7 @@ var AnnotationSidebar_default = ({
|
|
|
3600
4151
|
}
|
|
3601
4152
|
return createPortal(sidebarContent, container);
|
|
3602
4153
|
};
|
|
3603
|
-
var createHtmlMark = (markName, ATTRS,
|
|
4154
|
+
var createHtmlMark = (markName, ATTRS, classNames9) => {
|
|
3604
4155
|
return Mark.create({
|
|
3605
4156
|
name: markName,
|
|
3606
4157
|
priority: 1e3,
|
|
@@ -3629,7 +4180,7 @@ var createHtmlMark = (markName, ATTRS, classNames8) => {
|
|
|
3629
4180
|
return [
|
|
3630
4181
|
"div",
|
|
3631
4182
|
mergeAttributes$1(attrs, {
|
|
3632
|
-
class:
|
|
4183
|
+
class: classNames9
|
|
3633
4184
|
}),
|
|
3634
4185
|
0
|
|
3635
4186
|
];
|
|
@@ -4148,7 +4699,7 @@ var styles_module_default7 = {
|
|
|
4148
4699
|
collectionItem: "styles_module_collectionItem",
|
|
4149
4700
|
collectionItemSelected: "styles_module_collectionItemSelected"
|
|
4150
4701
|
};
|
|
4151
|
-
var { Text:
|
|
4702
|
+
var { Text: Text3 } = Typography;
|
|
4152
4703
|
var collectionSidebar_default = ({
|
|
4153
4704
|
disabled,
|
|
4154
4705
|
collections,
|
|
@@ -4214,11 +4765,11 @@ var collectionSidebar_default = ({
|
|
|
4214
4765
|
},
|
|
4215
4766
|
children: /* @__PURE__ */ jsxs(Flex, { vertical: true, gap: 8, flex: 1, children: [
|
|
4216
4767
|
/* @__PURE__ */ jsxs(Flex, { gap: 8, justify: "space-between", className: styles_module_default7.collectionMeta, children: [
|
|
4217
|
-
/* @__PURE__ */ jsx(
|
|
4218
|
-
/* @__PURE__ */ jsx(
|
|
4768
|
+
/* @__PURE__ */ jsx(Text3, { strong: true, type: "secondary", children: collection["user-name"] }),
|
|
4769
|
+
/* @__PURE__ */ jsx(Text3, { type: "secondary", children: formatDate(collection["update-time"]) })
|
|
4219
4770
|
] }),
|
|
4220
4771
|
/* @__PURE__ */ jsxs(Flex, { gap: 8, vertical: true, children: [
|
|
4221
|
-
/* @__PURE__ */ jsx(
|
|
4772
|
+
/* @__PURE__ */ jsx(Text3, { children: collection.text }),
|
|
4222
4773
|
!disabled && selectedCollectionId === collection[COLLECTION_ATTRS[0]] && /* @__PURE__ */ jsx(Space, { children: /* @__PURE__ */ jsx(
|
|
4223
4774
|
Popconfirm,
|
|
4224
4775
|
{
|
|
@@ -4458,7 +5009,7 @@ var ShortcutDisplay = ({
|
|
|
4458
5009
|
/* @__PURE__ */ jsx("kbd", { children: key })
|
|
4459
5010
|
] }, index)) });
|
|
4460
5011
|
};
|
|
4461
|
-
var
|
|
5012
|
+
var Button7 = forwardRef(
|
|
4462
5013
|
({
|
|
4463
5014
|
className,
|
|
4464
5015
|
children,
|
|
@@ -4502,7 +5053,7 @@ var Button6 = forwardRef(
|
|
|
4502
5053
|
] });
|
|
4503
5054
|
}
|
|
4504
5055
|
);
|
|
4505
|
-
|
|
5056
|
+
Button7.displayName = "Button";
|
|
4506
5057
|
var ButtonGroup = forwardRef(({ className, children, orientation = "vertical", ...props }, ref) => {
|
|
4507
5058
|
return /* @__PURE__ */ jsx(
|
|
4508
5059
|
"div",
|
|
@@ -4838,7 +5389,7 @@ var BlockquoteButton = forwardRef(
|
|
|
4838
5389
|
return null;
|
|
4839
5390
|
}
|
|
4840
5391
|
return /* @__PURE__ */ jsx(
|
|
4841
|
-
|
|
5392
|
+
Button7,
|
|
4842
5393
|
{
|
|
4843
5394
|
type: "button",
|
|
4844
5395
|
"data-style": "ghost",
|
|
@@ -5064,7 +5615,7 @@ var CodeBlockButton = forwardRef(
|
|
|
5064
5615
|
return null;
|
|
5065
5616
|
}
|
|
5066
5617
|
return /* @__PURE__ */ jsx(
|
|
5067
|
-
|
|
5618
|
+
Button7,
|
|
5068
5619
|
{
|
|
5069
5620
|
type: "button",
|
|
5070
5621
|
"data-style": "ghost",
|
|
@@ -5430,7 +5981,7 @@ var ColorHighlightButton = forwardRef(
|
|
|
5430
5981
|
return null;
|
|
5431
5982
|
}
|
|
5432
5983
|
return /* @__PURE__ */ jsx(
|
|
5433
|
-
|
|
5984
|
+
Button7,
|
|
5434
5985
|
{
|
|
5435
5986
|
type: "button",
|
|
5436
5987
|
"data-style": "ghost",
|
|
@@ -5665,7 +6216,7 @@ function useColorHighlight(config) {
|
|
|
5665
6216
|
};
|
|
5666
6217
|
}
|
|
5667
6218
|
var ColorHighlightPopoverButton = forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
5668
|
-
|
|
6219
|
+
Button7,
|
|
5669
6220
|
{
|
|
5670
6221
|
type: "button",
|
|
5671
6222
|
className,
|
|
@@ -5734,7 +6285,7 @@ function ColorHighlightPopoverContent({
|
|
|
5734
6285
|
)) }),
|
|
5735
6286
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
5736
6287
|
/* @__PURE__ */ jsx(ButtonGroup, { orientation: "horizontal", children: /* @__PURE__ */ jsx(
|
|
5737
|
-
|
|
6288
|
+
Button7,
|
|
5738
6289
|
{
|
|
5739
6290
|
onClick: handleRemoveHighlight,
|
|
5740
6291
|
"aria-label": "\u79FB\u9664\u80CC\u666F",
|
|
@@ -5858,7 +6409,7 @@ var HeadingButton = forwardRef(
|
|
|
5858
6409
|
return null;
|
|
5859
6410
|
}
|
|
5860
6411
|
return /* @__PURE__ */ jsx(
|
|
5861
|
-
|
|
6412
|
+
Button7,
|
|
5862
6413
|
{
|
|
5863
6414
|
type: "button",
|
|
5864
6415
|
"data-style": "ghost",
|
|
@@ -6287,7 +6838,7 @@ var HeadingDropdownMenu = forwardRef(
|
|
|
6287
6838
|
}
|
|
6288
6839
|
return /* @__PURE__ */ jsxs(DropdownMenu, { modal: true, open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
6289
6840
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
6290
|
-
|
|
6841
|
+
Button7,
|
|
6291
6842
|
{
|
|
6292
6843
|
type: "button",
|
|
6293
6844
|
"data-style": "ghost",
|
|
@@ -6505,7 +7056,7 @@ function InputGroup({
|
|
|
6505
7056
|
var LinkButton = forwardRef(
|
|
6506
7057
|
({ className, children, ...props }, ref) => {
|
|
6507
7058
|
return /* @__PURE__ */ jsx(
|
|
6508
|
-
|
|
7059
|
+
Button7,
|
|
6509
7060
|
{
|
|
6510
7061
|
type: "button",
|
|
6511
7062
|
className,
|
|
@@ -6565,7 +7116,7 @@ var LinkMain = ({
|
|
|
6565
7116
|
}
|
|
6566
7117
|
) }),
|
|
6567
7118
|
/* @__PURE__ */ jsx(ButtonGroup, { orientation: "horizontal", children: /* @__PURE__ */ jsx(
|
|
6568
|
-
|
|
7119
|
+
Button7,
|
|
6569
7120
|
{
|
|
6570
7121
|
type: "button",
|
|
6571
7122
|
onClick: setLink,
|
|
@@ -6578,7 +7129,7 @@ var LinkMain = ({
|
|
|
6578
7129
|
/* @__PURE__ */ jsx(Separator, {}),
|
|
6579
7130
|
/* @__PURE__ */ jsxs(ButtonGroup, { orientation: "horizontal", children: [
|
|
6580
7131
|
/* @__PURE__ */ jsx(
|
|
6581
|
-
|
|
7132
|
+
Button7,
|
|
6582
7133
|
{
|
|
6583
7134
|
type: "button",
|
|
6584
7135
|
onClick: openLink,
|
|
@@ -6589,7 +7140,7 @@ var LinkMain = ({
|
|
|
6589
7140
|
}
|
|
6590
7141
|
),
|
|
6591
7142
|
/* @__PURE__ */ jsx(
|
|
6592
|
-
|
|
7143
|
+
Button7,
|
|
6593
7144
|
{
|
|
6594
7145
|
type: "button",
|
|
6595
7146
|
onClick: removeLink,
|
|
@@ -6871,7 +7422,7 @@ var ListButton = forwardRef(
|
|
|
6871
7422
|
return null;
|
|
6872
7423
|
}
|
|
6873
7424
|
return /* @__PURE__ */ jsx(
|
|
6874
|
-
|
|
7425
|
+
Button7,
|
|
6875
7426
|
{
|
|
6876
7427
|
type: "button",
|
|
6877
7428
|
"data-style": "ghost",
|
|
@@ -7376,7 +7927,7 @@ function ListDropdownMenu({
|
|
|
7376
7927
|
}
|
|
7377
7928
|
return /* @__PURE__ */ jsxs(DropdownMenu, { open: isOpen, onOpenChange: handleOnOpenChange, children: [
|
|
7378
7929
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
7379
|
-
|
|
7930
|
+
Button7,
|
|
7380
7931
|
{
|
|
7381
7932
|
type: "button",
|
|
7382
7933
|
"data-style": "ghost",
|
|
@@ -7450,7 +8001,7 @@ var MarkButton = forwardRef(
|
|
|
7450
8001
|
return null;
|
|
7451
8002
|
}
|
|
7452
8003
|
return /* @__PURE__ */ jsx(
|
|
7453
|
-
|
|
8004
|
+
Button7,
|
|
7454
8005
|
{
|
|
7455
8006
|
type: "button",
|
|
7456
8007
|
disabled: !canToggle3,
|
|
@@ -7845,7 +8396,7 @@ var TextAlignButton = forwardRef(
|
|
|
7845
8396
|
}
|
|
7846
8397
|
const RenderIcon = CustomIcon ?? Icon;
|
|
7847
8398
|
return /* @__PURE__ */ jsx(
|
|
7848
|
-
|
|
8399
|
+
Button7,
|
|
7849
8400
|
{
|
|
7850
8401
|
type: "button",
|
|
7851
8402
|
disabled: !canAlign,
|
|
@@ -8180,7 +8731,7 @@ var UndoRedoButton = forwardRef(
|
|
|
8180
8731
|
return null;
|
|
8181
8732
|
}
|
|
8182
8733
|
return /* @__PURE__ */ jsx(
|
|
8183
|
-
|
|
8734
|
+
Button7,
|
|
8184
8735
|
{
|
|
8185
8736
|
type: "button",
|
|
8186
8737
|
disabled: !canExecute,
|
|
@@ -8351,17 +8902,17 @@ var ArrowLeftIcon = memo(({ className, ...props }) => {
|
|
|
8351
8902
|
});
|
|
8352
8903
|
ArrowLeftIcon.displayName = "ArrowLeftIcon";
|
|
8353
8904
|
function useSelect(editor, disabled = false, hideWhenUnavailable = false) {
|
|
8354
|
-
const selectionAvailable =
|
|
8355
|
-
const blockMathSelected =
|
|
8356
|
-
const isDisabled =
|
|
8357
|
-
const shouldShow =
|
|
8905
|
+
const selectionAvailable = React3__default.useMemo(() => hasSelection(editor), [editor?.state.selection]);
|
|
8906
|
+
const blockMathSelected = React3__default.useMemo(() => selectionHasBlockMath(editor), [editor?.state.selection]);
|
|
8907
|
+
const isDisabled = React3__default.useMemo(() => !selectionAvailable || disabled, [selectionAvailable, disabled]);
|
|
8908
|
+
const shouldShow = React3__default.useMemo(() => {
|
|
8358
8909
|
if (!editor?.isEditable) return false;
|
|
8359
8910
|
if (hideWhenUnavailable && !selectionAvailable) return false;
|
|
8360
8911
|
if (blockMathSelected) return false;
|
|
8361
8912
|
return true;
|
|
8362
8913
|
}, [editor, hideWhenUnavailable, selectionAvailable, blockMathSelected]);
|
|
8363
|
-
const getText =
|
|
8364
|
-
const getMarkdown =
|
|
8914
|
+
const getText = React3__default.useCallback(() => getSelectedText(editor), [editor]);
|
|
8915
|
+
const getMarkdown = React3__default.useCallback(() => getSelectedMarkdown(editor), [editor]);
|
|
8365
8916
|
return {
|
|
8366
8917
|
isDisabled,
|
|
8367
8918
|
shouldShow,
|
|
@@ -8369,11 +8920,11 @@ function useSelect(editor, disabled = false, hideWhenUnavailable = false) {
|
|
|
8369
8920
|
getMarkdown
|
|
8370
8921
|
};
|
|
8371
8922
|
}
|
|
8372
|
-
var SelectButton =
|
|
8923
|
+
var SelectButton = React3__default.forwardRef(
|
|
8373
8924
|
({ editor: providedEditor, disabled = false, hideWhenUnavailable = false, onClick, children, icon, tooltip, ...buttonProps }, ref) => {
|
|
8374
8925
|
const { editor } = useTiptapEditor(providedEditor);
|
|
8375
8926
|
const { isDisabled, shouldShow, getText, getMarkdown } = useSelect(editor, disabled, hideWhenUnavailable);
|
|
8376
|
-
const handleClick =
|
|
8927
|
+
const handleClick = React3__default.useCallback(
|
|
8377
8928
|
(e) => {
|
|
8378
8929
|
if (e.defaultPrevented || isDisabled || !editor) return;
|
|
8379
8930
|
const selectedText = getText();
|
|
@@ -8565,7 +9116,7 @@ function useCursorVisibility({ editor, overlayHeight = 0 }) {
|
|
|
8565
9116
|
}, [editor, overlayHeight, windowHeight, rect.height]);
|
|
8566
9117
|
return rect;
|
|
8567
9118
|
}
|
|
8568
|
-
var QuoteIcon =
|
|
9119
|
+
var QuoteIcon = React3.memo(({ ...props }) => {
|
|
8569
9120
|
return /* @__PURE__ */ jsx("span", { className: "anticon", children: /* @__PURE__ */ jsx("svg", { width: "1em", height: "1em", viewBox: "0 0 1024 1024", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ jsx(
|
|
8570
9121
|
"path",
|
|
8571
9122
|
{
|
|
@@ -8638,7 +9189,7 @@ var MainToolbarContent = ({
|
|
|
8638
9189
|
] });
|
|
8639
9190
|
};
|
|
8640
9191
|
var MobileToolbarContent = ({ type, onBack }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8641
|
-
/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxs(
|
|
9192
|
+
/* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxs(Button7, { "data-style": "ghost", onClick: onBack, children: [
|
|
8642
9193
|
/* @__PURE__ */ jsx(ArrowLeftIcon, { className: "tiptap-button-icon" }),
|
|
8643
9194
|
type === "highlighter" ? /* @__PURE__ */ jsx(HighlighterIcon, { className: "tiptap-button-icon" }) : /* @__PURE__ */ jsx(LinkIcon, { className: "tiptap-button-icon" })
|
|
8644
9195
|
] }) }),
|
|
@@ -9247,7 +9798,7 @@ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender })
|
|
|
9247
9798
|
const top = y1 * scaleY;
|
|
9248
9799
|
const width = (x2 - x1) * scaleX;
|
|
9249
9800
|
const height = (y2 - y1) * scaleY;
|
|
9250
|
-
return /* @__PURE__ */ jsxs(
|
|
9801
|
+
return /* @__PURE__ */ jsxs(React3__default.Fragment, { children: [
|
|
9251
9802
|
/* @__PURE__ */ jsx(
|
|
9252
9803
|
"div",
|
|
9253
9804
|
{
|
|
@@ -9315,6 +9866,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
|
9315
9866
|
return avatarSrc ? /* @__PURE__ */ jsx(Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsx(Avatar, { size, className: "cursor-pointer", style: { backgroundColor: "var(--ant-color-primary)" }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
9316
9867
|
};
|
|
9317
9868
|
|
|
9318
|
-
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, MarkDrawing_default as MarkDrawing, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MicroApp_default as MicroApp, Drawer_default as MicroAppDrawer, Window_default as MicroAppWindow, MultiEmailValidator, PdfImagePreview_default as PdfImagePreview, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, htmlToMarkdown, htmlToText, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAsyncQueue_default as useAsyncQueue, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
9869
|
+
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, luyaFilePreview_default as LuyaFilePreview, MarkDrawing_default as MarkDrawing, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MicroApp_default as MicroApp, Drawer_default as MicroAppDrawer, Window_default as MicroAppWindow, MultiEmailValidator, PdfImagePreview_default as PdfImagePreview, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, htmlToMarkdown, htmlToText, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, safeParseJson, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAsyncQueue_default as useAsyncQueue, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
9319
9870
|
//# sourceMappingURL=index.esm.js.map
|
|
9320
9871
|
//# sourceMappingURL=index.esm.js.map
|