@zero-library/common 2.3.11 → 2.4.0
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/README.md +43 -0
- package/dist/index.cjs.js +261 -308
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +0 -92
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +61 -56
- package/dist/index.d.ts +61 -56
- package/dist/index.esm.js +233 -278
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var icons = require('@ant-design/icons');
|
|
5
5
|
var antd = require('antd');
|
|
6
6
|
var classNames2 = require('classnames');
|
|
7
7
|
var docxPreview = require('docx-preview');
|
|
@@ -78,7 +78,6 @@ function _interopNamespace(e) {
|
|
|
78
78
|
return Object.freeze(n);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
var Icon__default = /*#__PURE__*/_interopDefault(Icon);
|
|
82
81
|
var classNames2__default = /*#__PURE__*/_interopDefault(classNames2);
|
|
83
82
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
84
83
|
var AES__default = /*#__PURE__*/_interopDefault(AES);
|
|
@@ -1302,9 +1301,9 @@ var DocxPreview_default = ({ fileUrl, scale = 1 }) => {
|
|
|
1302
1301
|
};
|
|
1303
1302
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames2__default.default(styles_module_default.nsPreviewDocx, "height-full", "width-full"), children: [
|
|
1304
1303
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 6, align: "center", className: styles_module_default.docxToolbar, children: [
|
|
1305
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1306
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1307
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: resetZoom, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1304
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}), title: "\u7F29\u5C0F" }),
|
|
1305
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusCircleOutlined, {}), title: "\u653E\u5927" }),
|
|
1306
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: resetZoom, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.RedoOutlined, {}), title: "\u8FD8\u539F" })
|
|
1308
1307
|
] }),
|
|
1309
1308
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default(styles_module_default.docxContent, "height-full", "scroll-fade-in"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1310
1309
|
"div",
|
|
@@ -1320,54 +1319,54 @@ var DocxPreview_default = ({ fileUrl, scale = 1 }) => {
|
|
|
1320
1319
|
};
|
|
1321
1320
|
var FileIcon_default = ({ suffix, fontSize = 22 }) => {
|
|
1322
1321
|
const styles = { fontSize, color: "var(--ant-color-primary)" };
|
|
1323
|
-
const
|
|
1322
|
+
const Icon = React.useMemo(() => {
|
|
1324
1323
|
switch (suffix?.toUpperCase()) {
|
|
1325
1324
|
case "TXT":
|
|
1326
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1325
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileTextOutlined, {});
|
|
1327
1326
|
case "PDF":
|
|
1328
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1327
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FilePdfOutlined, {});
|
|
1329
1328
|
case "DOC":
|
|
1330
1329
|
case "DOCX":
|
|
1331
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1330
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileWordOutlined, {});
|
|
1332
1331
|
case "XLS":
|
|
1333
1332
|
case "XLSX":
|
|
1334
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1333
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileExcelOutlined, {});
|
|
1335
1334
|
case "PPT":
|
|
1336
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1335
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FilePptOutlined, {});
|
|
1337
1336
|
case "MP4":
|
|
1338
1337
|
case "MOV":
|
|
1339
1338
|
case "MKV":
|
|
1340
1339
|
case "AVI":
|
|
1341
1340
|
case "FLV":
|
|
1342
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1341
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.VideoCameraOutlined, {});
|
|
1343
1342
|
case "MP3":
|
|
1344
1343
|
case "WAV":
|
|
1345
1344
|
case "M4A":
|
|
1346
1345
|
case "ACC":
|
|
1347
1346
|
case "WMA":
|
|
1348
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1347
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.NotificationOutlined, {});
|
|
1349
1348
|
case "JPG":
|
|
1350
1349
|
case "JPEG":
|
|
1351
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1350
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileJpgOutlined, {});
|
|
1352
1351
|
case "PNG":
|
|
1353
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1352
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileImageOutlined, {});
|
|
1354
1353
|
case "GIF":
|
|
1355
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1354
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileGifOutlined, {});
|
|
1356
1355
|
case "MD":
|
|
1357
1356
|
case "MARKDOWN":
|
|
1358
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1357
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileMarkdownOutlined, {});
|
|
1359
1358
|
case "ZIP":
|
|
1360
1359
|
case "RAR":
|
|
1361
1360
|
case "7Z":
|
|
1362
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1361
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileZipOutlined, {});
|
|
1363
1362
|
case "CATALOG":
|
|
1364
1363
|
return /* @__PURE__ */ jsxRuntime.jsx("i", { style: styles, className: "iconfont icon-wenjianjia" });
|
|
1365
1364
|
// 文件夹图标
|
|
1366
1365
|
default:
|
|
1367
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1366
|
+
return /* @__PURE__ */ jsxRuntime.jsx(icons.FileUnknownOutlined, {});
|
|
1368
1367
|
}
|
|
1369
1368
|
}, [suffix]);
|
|
1370
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles, children:
|
|
1369
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { style: styles, children: Icon });
|
|
1371
1370
|
};
|
|
1372
1371
|
var VideoPlayer_default = ({ fileUrl }) => {
|
|
1373
1372
|
return /* @__PURE__ */ jsxRuntime.jsxs("video", { controls: true, className: styles_module_default.nsPreviewVideo, children: [
|
|
@@ -1604,6 +1603,55 @@ var useIframeRelayBridge_default = (allowedOrigins = ["*"]) => {
|
|
|
1604
1603
|
}
|
|
1605
1604
|
return { on, off };
|
|
1606
1605
|
};
|
|
1606
|
+
var useRefState_default = (init) => {
|
|
1607
|
+
const [state, setState] = React.useState(init);
|
|
1608
|
+
const stateRef = React.useRef(init);
|
|
1609
|
+
const setProxy = (newVal) => {
|
|
1610
|
+
stateRef.current = newVal;
|
|
1611
|
+
setState(newVal);
|
|
1612
|
+
};
|
|
1613
|
+
const getState = () => stateRef.current;
|
|
1614
|
+
return [state, setProxy, getState];
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
// src/hooks/useAsyncQueue.ts
|
|
1618
|
+
var useAsyncQueue_default = () => {
|
|
1619
|
+
const [queue, setQueue] = React.useState([]);
|
|
1620
|
+
const [enabled, setEnabled] = React.useState(true);
|
|
1621
|
+
const [running, setRunning, getRunning] = useRefState_default(false);
|
|
1622
|
+
const addToQueue = React.useCallback((func, ...args) => {
|
|
1623
|
+
setQueue((prevQueue) => [...prevQueue, { func, args }]);
|
|
1624
|
+
}, []);
|
|
1625
|
+
const executeQueue = React.useCallback((nextEnabled) => {
|
|
1626
|
+
setEnabled(nextEnabled);
|
|
1627
|
+
}, []);
|
|
1628
|
+
const clearQueue = React.useCallback(() => {
|
|
1629
|
+
setQueue([]);
|
|
1630
|
+
}, []);
|
|
1631
|
+
React.useEffect(() => {
|
|
1632
|
+
if (!enabled) return;
|
|
1633
|
+
if (getRunning()) return;
|
|
1634
|
+
if (queue.length === 0) return;
|
|
1635
|
+
const task = queue[0];
|
|
1636
|
+
setRunning(true);
|
|
1637
|
+
(async () => {
|
|
1638
|
+
try {
|
|
1639
|
+
await task.func(...task.args);
|
|
1640
|
+
} finally {
|
|
1641
|
+
setQueue((prevQueue) => prevQueue.slice(1));
|
|
1642
|
+
setRunning(false);
|
|
1643
|
+
}
|
|
1644
|
+
})();
|
|
1645
|
+
}, [queue, enabled]);
|
|
1646
|
+
return {
|
|
1647
|
+
addToQueue,
|
|
1648
|
+
executeQueue,
|
|
1649
|
+
clearQueue,
|
|
1650
|
+
queueSize: queue.length,
|
|
1651
|
+
enabled,
|
|
1652
|
+
running
|
|
1653
|
+
};
|
|
1654
|
+
};
|
|
1607
1655
|
var useAutoRefresh_default = (listenValue, shouldRefresh, callback, delay = 1e4) => {
|
|
1608
1656
|
const timerRef = React.useRef(null);
|
|
1609
1657
|
const shouldRefreshRef = React.useRef(shouldRefresh);
|
|
@@ -1721,100 +1769,6 @@ var useDeepEffect_default = (effect, deps) => {
|
|
|
1721
1769
|
}
|
|
1722
1770
|
}, [depsChanged, effect, ...deps]);
|
|
1723
1771
|
};
|
|
1724
|
-
var useRefState_default = (init) => {
|
|
1725
|
-
const [state, setState] = React.useState(init);
|
|
1726
|
-
const stateRef = React.useRef(init);
|
|
1727
|
-
const setProxy = (newVal) => {
|
|
1728
|
-
stateRef.current = newVal;
|
|
1729
|
-
setState(newVal);
|
|
1730
|
-
};
|
|
1731
|
-
const getState = () => stateRef.current;
|
|
1732
|
-
return [state, setProxy, getState];
|
|
1733
|
-
};
|
|
1734
|
-
var useSpeech_default = ({ onResult, lang = "zh-CN" }) => {
|
|
1735
|
-
const [permission, setPermission] = React.useState("prompt");
|
|
1736
|
-
const [isRecording, setIsRecording] = React.useState(false);
|
|
1737
|
-
const recognitionRef = React.useRef(null);
|
|
1738
|
-
React.useEffect(() => {
|
|
1739
|
-
const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
1740
|
-
if (!SpeechRecognition) {
|
|
1741
|
-
setPermission("unsupported");
|
|
1742
|
-
return;
|
|
1743
|
-
}
|
|
1744
|
-
const recognition = new SpeechRecognition();
|
|
1745
|
-
recognition.continuous = true;
|
|
1746
|
-
recognition.interimResults = false;
|
|
1747
|
-
recognition.lang = lang;
|
|
1748
|
-
recognition.onresult = (event) => {
|
|
1749
|
-
let transcript = "";
|
|
1750
|
-
for (let i = event.resultIndex; i < event.results.length; i++) {
|
|
1751
|
-
transcript += event.results[i][0].transcript;
|
|
1752
|
-
}
|
|
1753
|
-
onResult?.(transcript.trim());
|
|
1754
|
-
};
|
|
1755
|
-
recognition.onend = () => {
|
|
1756
|
-
setIsRecording(false);
|
|
1757
|
-
};
|
|
1758
|
-
recognition.onerror = (error) => {
|
|
1759
|
-
setIsRecording(false);
|
|
1760
|
-
console.error("Speech recognition error:", error);
|
|
1761
|
-
};
|
|
1762
|
-
recognitionRef.current = recognition;
|
|
1763
|
-
return () => {
|
|
1764
|
-
recognition.stop?.();
|
|
1765
|
-
recognition.onresult = null;
|
|
1766
|
-
recognition.onend = null;
|
|
1767
|
-
recognition.onerror = null;
|
|
1768
|
-
};
|
|
1769
|
-
}, [lang, onResult]);
|
|
1770
|
-
React.useEffect(() => {
|
|
1771
|
-
if (!navigator.permissions) return;
|
|
1772
|
-
navigator.permissions.query({ name: "microphone" }).then((status) => {
|
|
1773
|
-
setPermission(status.state);
|
|
1774
|
-
status.onchange = () => setPermission(status.state);
|
|
1775
|
-
});
|
|
1776
|
-
}, []);
|
|
1777
|
-
const requestPermission = React.useCallback(async () => {
|
|
1778
|
-
try {
|
|
1779
|
-
await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
1780
|
-
setPermission("granted");
|
|
1781
|
-
} catch {
|
|
1782
|
-
setPermission("denied");
|
|
1783
|
-
}
|
|
1784
|
-
}, []);
|
|
1785
|
-
const start = React.useCallback(() => {
|
|
1786
|
-
if (permission === "prompt") {
|
|
1787
|
-
requestPermission();
|
|
1788
|
-
return;
|
|
1789
|
-
}
|
|
1790
|
-
if (permission !== "granted") return;
|
|
1791
|
-
if (!isRecording) {
|
|
1792
|
-
recognitionRef.current?.start();
|
|
1793
|
-
setIsRecording(true);
|
|
1794
|
-
}
|
|
1795
|
-
}, [permission, isRecording, requestPermission]);
|
|
1796
|
-
const stop = React.useCallback(() => {
|
|
1797
|
-
try {
|
|
1798
|
-
recognitionRef.current?.stop();
|
|
1799
|
-
} finally {
|
|
1800
|
-
setIsRecording(false);
|
|
1801
|
-
}
|
|
1802
|
-
}, []);
|
|
1803
|
-
return {
|
|
1804
|
-
/**
|
|
1805
|
-
* 权限状态
|
|
1806
|
-
*/
|
|
1807
|
-
permission,
|
|
1808
|
-
/**
|
|
1809
|
-
* 录音状态
|
|
1810
|
-
*/
|
|
1811
|
-
isRecording,
|
|
1812
|
-
/** 开始语音识别 */
|
|
1813
|
-
start,
|
|
1814
|
-
/** 停止语音识别 */
|
|
1815
|
-
stop
|
|
1816
|
-
};
|
|
1817
|
-
};
|
|
1818
1772
|
var useSyncInput_default = (storeValue, setStoreValue) => {
|
|
1819
1773
|
const [inputValue, setInputValue] = React.useState(storeValue);
|
|
1820
1774
|
React.useEffect(() => {
|
|
@@ -2132,72 +2086,88 @@ var PdfImagePreview_default = ({ fileUrl, pageNo, scale = 1, isHasThumbnails = t
|
|
|
2132
2086
|
}
|
|
2133
2087
|
}, [zoom, virtualizer]);
|
|
2134
2088
|
return error ? /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "error", title: error }) : /* @__PURE__ */ jsxRuntime.jsxs(antd.Splitter, { className: classNames2__default.default(styles_module_default.nsPreviewPdfImage), children: [
|
|
2135
|
-
isHasThumbnails && /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { resizable: false, min: 400, max: 400, collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: thumbsParentRef, className: classNames2__default.default(styles_module_default.pdfImageNav, "height-full", "scroll-fade-in"), children:
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
{
|
|
2139
|
-
|
|
2140
|
-
align: "center",
|
|
2141
|
-
className: classNames2__default.default(styles_module_default.pdfImageNavItem),
|
|
2142
|
-
style: {
|
|
2143
|
-
top: item.start,
|
|
2144
|
-
height: `${THUMB_IMG_HEIGHT}px`
|
|
2145
|
-
},
|
|
2146
|
-
onClick: () => {
|
|
2147
|
-
virtualizer.scrollToIndex(item.index);
|
|
2148
|
-
},
|
|
2149
|
-
children: [
|
|
2150
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2151
|
-
"div",
|
|
2152
|
-
{
|
|
2153
|
-
className: classNames2__default.default(styles_module_default.pdfImageNavItemImgWrapper, "flex-1", {
|
|
2154
|
-
[styles_module_default.pdfImageNavItemActive]: item.index === currentIndex
|
|
2155
|
-
}),
|
|
2156
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles_module_default.pdfImageNavItemImg, src: images[item.index].thumbnail || images[item.index].imageUrl })
|
|
2157
|
-
}
|
|
2158
|
-
),
|
|
2159
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default.pdfImageNavItemTip, children: item.index + 1 })
|
|
2160
|
-
]
|
|
2089
|
+
isHasThumbnails && /* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { resizable: false, min: 400, max: 400, collapsible: true, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: thumbsParentRef, className: classNames2__default.default(styles_module_default.pdfImageNav, "height-full", "scroll-fade-in"), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2090
|
+
"div",
|
|
2091
|
+
{
|
|
2092
|
+
style: {
|
|
2093
|
+
height: `${thumbsVirtualizer.getTotalSize()}px`
|
|
2161
2094
|
},
|
|
2162
|
-
item
|
|
2163
|
-
|
|
2164
|
-
|
|
2095
|
+
children: thumbsVirtualizer.getVirtualItems().map((item) => {
|
|
2096
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2097
|
+
antd.Flex,
|
|
2098
|
+
{
|
|
2099
|
+
vertical: true,
|
|
2100
|
+
align: "center",
|
|
2101
|
+
className: classNames2__default.default(styles_module_default.pdfImageNavItem),
|
|
2102
|
+
style: {
|
|
2103
|
+
top: item.start,
|
|
2104
|
+
height: `${THUMB_IMG_HEIGHT}px`
|
|
2105
|
+
},
|
|
2106
|
+
onClick: () => {
|
|
2107
|
+
virtualizer.scrollToIndex(item.index);
|
|
2108
|
+
},
|
|
2109
|
+
children: [
|
|
2110
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2111
|
+
"div",
|
|
2112
|
+
{
|
|
2113
|
+
className: classNames2__default.default(styles_module_default.pdfImageNavItemImgWrapper, "flex-1", {
|
|
2114
|
+
[styles_module_default.pdfImageNavItemActive]: item.index === currentIndex
|
|
2115
|
+
}),
|
|
2116
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("img", { className: styles_module_default.pdfImageNavItemImg, src: images[item.index].thumbnail || images[item.index].imageUrl })
|
|
2117
|
+
}
|
|
2118
|
+
),
|
|
2119
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_module_default.pdfImageNavItemTip, children: item.index + 1 })
|
|
2120
|
+
]
|
|
2121
|
+
},
|
|
2122
|
+
item.index
|
|
2123
|
+
);
|
|
2124
|
+
})
|
|
2125
|
+
}
|
|
2126
|
+
) }) }),
|
|
2165
2127
|
/* @__PURE__ */ jsxRuntime.jsx(antd.Splitter.Panel, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames2__default.default("height-full", styles_module_default.pdfImageBody), children: [
|
|
2166
2128
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 6, align: "center", className: styles_module_default.pdfImageBodyToolbar, children: [
|
|
2167
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2168
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2169
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomFitWidth, icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2129
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusCircleOutlined, {}), title: "\u7F29\u5C0F" }),
|
|
2130
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.PlusCircleOutlined, {}), title: "\u653E\u5927" }),
|
|
2131
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { onClick: zoomFitWidth, icon: /* @__PURE__ */ jsxRuntime.jsx(icons.ColumnWidthOutlined, {}), title: "\u9002\u5E94\u5BBD\u5EA6" })
|
|
2170
2132
|
] }),
|
|
2171
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "height-full scroll-fade-in", children:
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
{
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2133
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "height-full scroll-fade-in", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2134
|
+
"div",
|
|
2135
|
+
{
|
|
2136
|
+
style: {
|
|
2137
|
+
height: `${virtualizer.getTotalSize()}px`
|
|
2138
|
+
},
|
|
2139
|
+
children: virtualizer.getVirtualItems().map((item) => {
|
|
2140
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2180
2141
|
"div",
|
|
2181
2142
|
{
|
|
2182
|
-
className:
|
|
2143
|
+
className: styles_module_default.pdfImageBodyItem,
|
|
2183
2144
|
style: {
|
|
2184
|
-
|
|
2185
|
-
height: `${MAIN_IMG_HEIGHT * zoom}px`
|
|
2145
|
+
top: item.start
|
|
2186
2146
|
},
|
|
2187
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2188
|
-
"
|
|
2147
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2148
|
+
"div",
|
|
2189
2149
|
{
|
|
2190
|
-
className: classNames2__default.default(styles_module_default.
|
|
2191
|
-
|
|
2192
|
-
|
|
2150
|
+
className: classNames2__default.default(styles_module_default.pdfImageBodyItemInnerWrapper, "p-8"),
|
|
2151
|
+
style: {
|
|
2152
|
+
width: `${MAIN_IMG_WIDTH * zoom}px`,
|
|
2153
|
+
height: `${MAIN_IMG_HEIGHT * zoom}px`
|
|
2154
|
+
},
|
|
2155
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames2__default.default(styles_module_default.pdfImageBodyItemInner, { [styles_module_default.pdfImageBodyItemActive]: item.index === currentIndex }), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2156
|
+
"img",
|
|
2157
|
+
{
|
|
2158
|
+
className: classNames2__default.default(styles_module_default.pdfImageBodyItemImg),
|
|
2159
|
+
src: images[item.index].imageUrl,
|
|
2160
|
+
loading: item.index === currentIndex ? "eager" : "lazy"
|
|
2161
|
+
}
|
|
2162
|
+
) })
|
|
2193
2163
|
}
|
|
2194
|
-
)
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2164
|
+
)
|
|
2165
|
+
},
|
|
2166
|
+
`${item.index}-${images[item.index].pageNum}`
|
|
2167
|
+
);
|
|
2168
|
+
})
|
|
2169
|
+
}
|
|
2170
|
+
) })
|
|
2201
2171
|
] }) })
|
|
2202
2172
|
] });
|
|
2203
2173
|
};
|
|
@@ -3211,13 +3181,13 @@ var AnnotationSidebar_default = ({
|
|
|
3211
3181
|
className: "full-card no-padding-card extra-sidebar",
|
|
3212
3182
|
title: annotationConfig?.showListHeader === false ? false : /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", children: [
|
|
3213
3183
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { children: [
|
|
3214
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3184
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.MessageOutlined, {}),
|
|
3215
3185
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3216
3186
|
"\u6279\u6CE8",
|
|
3217
3187
|
annotations.length > 0 && `\uFF08${annotations.length}\uFF09`
|
|
3218
3188
|
] })
|
|
3219
3189
|
] }),
|
|
3220
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3190
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, {}), onClick: onClose })
|
|
3221
3191
|
] }),
|
|
3222
3192
|
variant: "borderless",
|
|
3223
3193
|
children: annotations.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3267,7 +3237,7 @@ var AnnotationSidebar_default = ({
|
|
|
3267
3237
|
type: "text",
|
|
3268
3238
|
size: "small",
|
|
3269
3239
|
title: "\u7F16\u8F91\u6279\u6CE8",
|
|
3270
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3240
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.EditOutlined, {}),
|
|
3271
3241
|
onClick: (e) => {
|
|
3272
3242
|
handleEdit(annotation);
|
|
3273
3243
|
}
|
|
@@ -3281,7 +3251,7 @@ var AnnotationSidebar_default = ({
|
|
|
3281
3251
|
cancelText: "\u53D6\u6D88",
|
|
3282
3252
|
description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6279\u6CE8\u5417?",
|
|
3283
3253
|
onConfirm: () => onDeleteAnnotation(annotation[ANNOTATION_ATTRS[0]]),
|
|
3284
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", title: "\u5220\u9664\u6279\u6CE8", icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3254
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", title: "\u5220\u9664\u6279\u6CE8", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}) })
|
|
3285
3255
|
}
|
|
3286
3256
|
)
|
|
3287
3257
|
] })
|
|
@@ -3628,6 +3598,90 @@ var COLLECTION_ATTRS = ["collection-id", "user-name", "user-id", "update-time",
|
|
|
3628
3598
|
|
|
3629
3599
|
// src/components/MarkdownEditor/collection/CollectionMark.ts
|
|
3630
3600
|
var CollectionMark = createHtmlMark(COLLECTION_KEY, COLLECTION_ATTRS, "editor-collection");
|
|
3601
|
+
|
|
3602
|
+
// src/components/MarkdownEditor/common/utils.ts
|
|
3603
|
+
function selectionHasBlockMath(editor) {
|
|
3604
|
+
if (!editor) return false;
|
|
3605
|
+
const { state } = editor;
|
|
3606
|
+
const { from, to } = state.selection;
|
|
3607
|
+
let hasBlockMath = false;
|
|
3608
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
3609
|
+
if (node.type.name === "blockMath") {
|
|
3610
|
+
hasBlockMath = true;
|
|
3611
|
+
return false;
|
|
3612
|
+
}
|
|
3613
|
+
});
|
|
3614
|
+
return hasBlockMath;
|
|
3615
|
+
}
|
|
3616
|
+
function hasSelection(editor) {
|
|
3617
|
+
if (!editor) return false;
|
|
3618
|
+
const { from, to } = editor.state.selection;
|
|
3619
|
+
return from < to;
|
|
3620
|
+
}
|
|
3621
|
+
function getSelectedText(editor) {
|
|
3622
|
+
if (!editor) return "";
|
|
3623
|
+
const { from, to } = editor.state.selection;
|
|
3624
|
+
if (from === to) return "";
|
|
3625
|
+
return editor.state.doc.textBetween(from, to, " ");
|
|
3626
|
+
}
|
|
3627
|
+
function getSelectedMarkdown(editor) {
|
|
3628
|
+
if (!editor) return "";
|
|
3629
|
+
if (!editor.markdown) {
|
|
3630
|
+
console.warn("Markdown extension \u672A\u542F\u7528");
|
|
3631
|
+
return "";
|
|
3632
|
+
}
|
|
3633
|
+
const { from, to } = editor.state.selection;
|
|
3634
|
+
const slice = editor.state.doc.cut(from, to);
|
|
3635
|
+
return editor.markdown.serialize({
|
|
3636
|
+
type: "doc",
|
|
3637
|
+
content: slice.content.toJSON()
|
|
3638
|
+
});
|
|
3639
|
+
}
|
|
3640
|
+
function getScrollParent(el) {
|
|
3641
|
+
if (typeof window === "undefined") return null;
|
|
3642
|
+
let current = el?.parentElement ?? null;
|
|
3643
|
+
while (current) {
|
|
3644
|
+
const style = window.getComputedStyle(current);
|
|
3645
|
+
const overflowY = style.overflowY;
|
|
3646
|
+
const overflow = style.overflow;
|
|
3647
|
+
const canScroll = /(auto|scroll|overlay)/.test(overflowY) || /(auto|scroll|overlay)/.test(overflow);
|
|
3648
|
+
if (canScroll) {
|
|
3649
|
+
return current;
|
|
3650
|
+
}
|
|
3651
|
+
current = current.parentElement;
|
|
3652
|
+
}
|
|
3653
|
+
return document.scrollingElement;
|
|
3654
|
+
}
|
|
3655
|
+
function scrollEditorViewToPosInNextFrame(view, pos, options) {
|
|
3656
|
+
const { align = "start", behavior = "auto", offset: offset3 = 0 } = options || {};
|
|
3657
|
+
requestAnimationFrame(() => {
|
|
3658
|
+
try {
|
|
3659
|
+
const result = view.domAtPos(pos);
|
|
3660
|
+
if (!result) return;
|
|
3661
|
+
const el = result.node.nodeType === Node.TEXT_NODE ? result.node.parentElement : result.node;
|
|
3662
|
+
if (!el) return;
|
|
3663
|
+
const scrollParent = getScrollParent(view.dom);
|
|
3664
|
+
const parentRect = scrollParent.getBoundingClientRect();
|
|
3665
|
+
const targetRect = el.getBoundingClientRect();
|
|
3666
|
+
let delta = 0;
|
|
3667
|
+
if (align === "start") {
|
|
3668
|
+
delta = targetRect.top - parentRect.top;
|
|
3669
|
+
} else if (align === "center") {
|
|
3670
|
+
delta = targetRect.top - parentRect.top - parentRect.height / 2 + targetRect.height / 2;
|
|
3671
|
+
} else if (align === "end") {
|
|
3672
|
+
delta = targetRect.bottom - parentRect.bottom;
|
|
3673
|
+
}
|
|
3674
|
+
scrollParent.scrollTo({
|
|
3675
|
+
top: scrollParent.scrollTop + delta - offset3,
|
|
3676
|
+
behavior
|
|
3677
|
+
});
|
|
3678
|
+
} catch (e) {
|
|
3679
|
+
console.warn("scroll error:", e);
|
|
3680
|
+
}
|
|
3681
|
+
});
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
// src/components/MarkdownEditor/collection/CollectionPlugin.ts
|
|
3631
3685
|
var collectionPluginKey = new state.PluginKey("collectionPlugin");
|
|
3632
3686
|
var CollectionPlugin = core.Extension.create({
|
|
3633
3687
|
name: "collectionPlugin",
|
|
@@ -3650,10 +3704,11 @@ var CollectionPlugin = core.Extension.create({
|
|
|
3650
3704
|
},
|
|
3651
3705
|
moveCursorToCollection: (id) => ({ state: state$1, commands, view }) => {
|
|
3652
3706
|
const foundFrom = findMarkPosition(state$1.doc, COLLECTION_KEY, COLLECTION_ATTRS[0], id);
|
|
3653
|
-
if (foundFrom) {
|
|
3707
|
+
if (isNumber(foundFrom)) {
|
|
3654
3708
|
const tr = state$1.tr.setSelection(state.TextSelection.create(state$1.doc, foundFrom));
|
|
3655
3709
|
view.dispatch(tr);
|
|
3656
3710
|
commands.focus();
|
|
3711
|
+
scrollEditorViewToPosInNextFrame(view, foundFrom, { align: "start" });
|
|
3657
3712
|
}
|
|
3658
3713
|
}
|
|
3659
3714
|
};
|
|
@@ -3757,13 +3812,13 @@ var collectionSidebar_default = ({
|
|
|
3757
3812
|
className: "full-card no-padding-card extra-sidebar",
|
|
3758
3813
|
title: collectionConfig?.showListHeader === false ? false : /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { justify: "space-between", align: "center", children: [
|
|
3759
3814
|
/* @__PURE__ */ jsxRuntime.jsxs(antd.Space, { children: [
|
|
3760
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3815
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.BookOutlined, {}),
|
|
3761
3816
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
3762
3817
|
"\u6458\u5F55",
|
|
3763
3818
|
collections.length > 0 && `\uFF08${collections.length}\uFF09`
|
|
3764
3819
|
] })
|
|
3765
3820
|
] }),
|
|
3766
|
-
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3821
|
+
/* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CloseOutlined, {}), onClick: onClose })
|
|
3767
3822
|
] }),
|
|
3768
3823
|
variant: "borderless",
|
|
3769
3824
|
children: collections.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -3807,7 +3862,7 @@ var collectionSidebar_default = ({
|
|
|
3807
3862
|
cancelText: "\u53D6\u6D88",
|
|
3808
3863
|
description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6458\u5F55\u5417?",
|
|
3809
3864
|
onConfirm: () => onDeleteCollection(collection[COLLECTION_ATTRS[0]]),
|
|
3810
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", title: "\u5220\u9664\u6458\u5F55", icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3865
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { type: "text", size: "small", title: "\u5220\u9664\u6458\u5F55", icon: /* @__PURE__ */ jsxRuntime.jsx(icons.DeleteOutlined, {}) })
|
|
3811
3866
|
}
|
|
3812
3867
|
) })
|
|
3813
3868
|
] })
|
|
@@ -3825,47 +3880,6 @@ var collectionSidebar_default = ({
|
|
|
3825
3880
|
}
|
|
3826
3881
|
return reactDom.createPortal(sidebarContent, container);
|
|
3827
3882
|
};
|
|
3828
|
-
|
|
3829
|
-
// src/components/MarkdownEditor/common/utils.ts
|
|
3830
|
-
function selectionHasBlockMath(editor) {
|
|
3831
|
-
if (!editor) return false;
|
|
3832
|
-
const { state } = editor;
|
|
3833
|
-
const { from, to } = state.selection;
|
|
3834
|
-
let hasBlockMath = false;
|
|
3835
|
-
state.doc.nodesBetween(from, to, (node) => {
|
|
3836
|
-
if (node.type.name === "blockMath") {
|
|
3837
|
-
hasBlockMath = true;
|
|
3838
|
-
return false;
|
|
3839
|
-
}
|
|
3840
|
-
});
|
|
3841
|
-
return hasBlockMath;
|
|
3842
|
-
}
|
|
3843
|
-
function hasSelection(editor) {
|
|
3844
|
-
if (!editor) return false;
|
|
3845
|
-
const { from, to } = editor.state.selection;
|
|
3846
|
-
return from < to;
|
|
3847
|
-
}
|
|
3848
|
-
function getSelectedText(editor) {
|
|
3849
|
-
if (!editor) return "";
|
|
3850
|
-
const { from, to } = editor.state.selection;
|
|
3851
|
-
if (from === to) return "";
|
|
3852
|
-
return editor.state.doc.textBetween(from, to, " ");
|
|
3853
|
-
}
|
|
3854
|
-
function getSelectedMarkdown(editor) {
|
|
3855
|
-
if (!editor) return "";
|
|
3856
|
-
if (!editor.markdown) {
|
|
3857
|
-
console.warn("Markdown extension \u672A\u542F\u7528");
|
|
3858
|
-
return "";
|
|
3859
|
-
}
|
|
3860
|
-
const { from, to } = editor.state.selection;
|
|
3861
|
-
const slice = editor.state.doc.cut(from, to);
|
|
3862
|
-
return editor.markdown.serialize({
|
|
3863
|
-
type: "doc",
|
|
3864
|
-
content: slice.content.toJSON()
|
|
3865
|
-
});
|
|
3866
|
-
}
|
|
3867
|
-
|
|
3868
|
-
// src/components/MarkdownEditor/collection/use-collections.ts
|
|
3869
3883
|
var useCollections = (collectionConfig) => {
|
|
3870
3884
|
const [collections, setCollections] = React.useState([]);
|
|
3871
3885
|
const [selectedCollectionId, setSelectedCollectionId] = React.useState(null);
|
|
@@ -3904,7 +3918,7 @@ var useCollections = (collectionConfig) => {
|
|
|
3904
3918
|
"page-no": pageIndex
|
|
3905
3919
|
}).run();
|
|
3906
3920
|
setShowCollection(true);
|
|
3907
|
-
handleSelectCollection(remoteId
|
|
3921
|
+
handleSelectCollection(remoteId);
|
|
3908
3922
|
};
|
|
3909
3923
|
const handleDeleteCollection = (id) => {
|
|
3910
3924
|
if (!editor.current) {
|
|
@@ -4441,7 +4455,7 @@ var BlockquoteButton = React.forwardRef(
|
|
|
4441
4455
|
handleToggle,
|
|
4442
4456
|
label,
|
|
4443
4457
|
shortcutKeys,
|
|
4444
|
-
Icon
|
|
4458
|
+
Icon
|
|
4445
4459
|
} = useBlockquote({
|
|
4446
4460
|
editor,
|
|
4447
4461
|
hideWhenUnavailable,
|
|
@@ -4475,7 +4489,7 @@ var BlockquoteButton = React.forwardRef(
|
|
|
4475
4489
|
...buttonProps,
|
|
4476
4490
|
ref,
|
|
4477
4491
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4478
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4492
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
4479
4493
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
4480
4494
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(BlockquoteShortcutBadge, { shortcutKeys })
|
|
4481
4495
|
] })
|
|
@@ -4667,7 +4681,7 @@ var CodeBlockButton = React.forwardRef(
|
|
|
4667
4681
|
handleToggle,
|
|
4668
4682
|
label,
|
|
4669
4683
|
shortcutKeys,
|
|
4670
|
-
Icon
|
|
4684
|
+
Icon
|
|
4671
4685
|
} = useCodeBlock({
|
|
4672
4686
|
editor,
|
|
4673
4687
|
hideWhenUnavailable,
|
|
@@ -4701,7 +4715,7 @@ var CodeBlockButton = React.forwardRef(
|
|
|
4701
4715
|
...buttonProps,
|
|
4702
4716
|
ref,
|
|
4703
4717
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4704
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4718
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
4705
4719
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
4706
4720
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(CodeBlockShortcutBadge, { shortcutKeys })
|
|
4707
4721
|
] })
|
|
@@ -5387,7 +5401,7 @@ function ColorHighlightPopover({
|
|
|
5387
5401
|
}) {
|
|
5388
5402
|
const { editor } = useTiptapEditor(providedEditor);
|
|
5389
5403
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
5390
|
-
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label, Icon
|
|
5404
|
+
const { isVisible, canColorHighlight: canColorHighlight2, isActive, label, Icon } = useColorHighlight({
|
|
5391
5405
|
editor,
|
|
5392
5406
|
hideWhenUnavailable,
|
|
5393
5407
|
onApplied
|
|
@@ -5404,7 +5418,7 @@ function ColorHighlightPopover({
|
|
|
5404
5418
|
"aria-label": label,
|
|
5405
5419
|
tooltip: label,
|
|
5406
5420
|
...props,
|
|
5407
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5421
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" })
|
|
5408
5422
|
}
|
|
5409
5423
|
) }),
|
|
5410
5424
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { "aria-label": "\u80CC\u666F\u8272", children: /* @__PURE__ */ jsxRuntime.jsx(ColorHighlightPopoverContent, { editor, colors }) })
|
|
@@ -5459,7 +5473,7 @@ var HeadingButton = React.forwardRef(
|
|
|
5459
5473
|
isActive,
|
|
5460
5474
|
handleToggle,
|
|
5461
5475
|
label,
|
|
5462
|
-
Icon
|
|
5476
|
+
Icon,
|
|
5463
5477
|
shortcutKeys
|
|
5464
5478
|
} = useHeading({
|
|
5465
5479
|
editor,
|
|
@@ -5495,7 +5509,7 @@ var HeadingButton = React.forwardRef(
|
|
|
5495
5509
|
...buttonProps,
|
|
5496
5510
|
ref,
|
|
5497
5511
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5498
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5512
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
5499
5513
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
5500
5514
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(HeadingShortcutBadge, { level, shortcutKeys })
|
|
5501
5515
|
] })
|
|
@@ -5890,7 +5904,7 @@ var HeadingDropdownMenu = React.forwardRef(
|
|
|
5890
5904
|
}, ref) => {
|
|
5891
5905
|
const { editor } = useTiptapEditor(providedEditor);
|
|
5892
5906
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
5893
|
-
const { isVisible, isActive, canToggle: canToggle3, Icon
|
|
5907
|
+
const { isVisible, isActive, canToggle: canToggle3, Icon } = useHeadingDropdownMenu({
|
|
5894
5908
|
editor,
|
|
5895
5909
|
levels,
|
|
5896
5910
|
hideWhenUnavailable
|
|
@@ -5923,7 +5937,7 @@ var HeadingDropdownMenu = React.forwardRef(
|
|
|
5923
5937
|
...buttonProps,
|
|
5924
5938
|
ref,
|
|
5925
5939
|
children: [
|
|
5926
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5940
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
5927
5941
|
/* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, { className: "tiptap-button-dropdown-small" })
|
|
5928
5942
|
]
|
|
5929
5943
|
}
|
|
@@ -6256,7 +6270,7 @@ var LinkPopover = React.forwardRef(
|
|
|
6256
6270
|
removeLink,
|
|
6257
6271
|
openLink,
|
|
6258
6272
|
label,
|
|
6259
|
-
Icon
|
|
6273
|
+
Icon
|
|
6260
6274
|
} = useLinkPopover({
|
|
6261
6275
|
editor,
|
|
6262
6276
|
hideWhenUnavailable,
|
|
@@ -6301,7 +6315,7 @@ var LinkPopover = React.forwardRef(
|
|
|
6301
6315
|
onClick: handleClick,
|
|
6302
6316
|
...buttonProps,
|
|
6303
6317
|
ref,
|
|
6304
|
-
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6318
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" })
|
|
6305
6319
|
}
|
|
6306
6320
|
) }),
|
|
6307
6321
|
/* @__PURE__ */ jsxRuntime.jsx(PopoverContent, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -6473,7 +6487,7 @@ var ListButton = React.forwardRef(
|
|
|
6473
6487
|
handleToggle,
|
|
6474
6488
|
label,
|
|
6475
6489
|
shortcutKeys,
|
|
6476
|
-
Icon
|
|
6490
|
+
Icon
|
|
6477
6491
|
} = useList({
|
|
6478
6492
|
editor,
|
|
6479
6493
|
type,
|
|
@@ -6508,7 +6522,7 @@ var ListButton = React.forwardRef(
|
|
|
6508
6522
|
...buttonProps,
|
|
6509
6523
|
ref,
|
|
6510
6524
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6511
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6525
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
6512
6526
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
6513
6527
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(ListShortcutBadge, { type, shortcutKeys })
|
|
6514
6528
|
] })
|
|
@@ -6980,7 +6994,7 @@ function ListDropdownMenu({
|
|
|
6980
6994
|
}) {
|
|
6981
6995
|
const { editor } = useTiptapEditor(providedEditor);
|
|
6982
6996
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
6983
|
-
const { filteredLists, canToggle: canToggle3, isActive, isVisible, Icon
|
|
6997
|
+
const { filteredLists, canToggle: canToggle3, isActive, isVisible, Icon } = useListDropdownMenu({
|
|
6984
6998
|
editor,
|
|
6985
6999
|
types,
|
|
6986
7000
|
hideWhenUnavailable
|
|
@@ -7010,7 +7024,7 @@ function ListDropdownMenu({
|
|
|
7010
7024
|
tooltip: "\u5217\u8868",
|
|
7011
7025
|
...props,
|
|
7012
7026
|
children: [
|
|
7013
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7027
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
7014
7028
|
/* @__PURE__ */ jsxRuntime.jsx(ChevronDownIcon, { className: "tiptap-button-dropdown-small" })
|
|
7015
7029
|
]
|
|
7016
7030
|
}
|
|
@@ -7051,7 +7065,7 @@ var MarkButton = React.forwardRef(
|
|
|
7051
7065
|
label,
|
|
7052
7066
|
canToggle: canToggle3,
|
|
7053
7067
|
isActive,
|
|
7054
|
-
Icon
|
|
7068
|
+
Icon,
|
|
7055
7069
|
shortcutKeys
|
|
7056
7070
|
} = useMark({
|
|
7057
7071
|
editor,
|
|
@@ -7087,7 +7101,7 @@ var MarkButton = React.forwardRef(
|
|
|
7087
7101
|
...buttonProps,
|
|
7088
7102
|
ref,
|
|
7089
7103
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7090
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7104
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
7091
7105
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
7092
7106
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(MarkShortcutBadge, { type, shortcutKeys })
|
|
7093
7107
|
] })
|
|
@@ -7445,7 +7459,7 @@ var TextAlignButton = React.forwardRef(
|
|
|
7445
7459
|
label,
|
|
7446
7460
|
canAlign,
|
|
7447
7461
|
isActive,
|
|
7448
|
-
Icon
|
|
7462
|
+
Icon,
|
|
7449
7463
|
shortcutKeys
|
|
7450
7464
|
} = useTextAlign({
|
|
7451
7465
|
editor,
|
|
@@ -7464,7 +7478,7 @@ var TextAlignButton = React.forwardRef(
|
|
|
7464
7478
|
if (!isVisible) {
|
|
7465
7479
|
return null;
|
|
7466
7480
|
}
|
|
7467
|
-
const RenderIcon = CustomIcon ??
|
|
7481
|
+
const RenderIcon = CustomIcon ?? Icon;
|
|
7468
7482
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7469
7483
|
Button6,
|
|
7470
7484
|
{
|
|
@@ -7783,7 +7797,7 @@ var UndoRedoButton = React.forwardRef(
|
|
|
7783
7797
|
...buttonProps
|
|
7784
7798
|
}, ref) => {
|
|
7785
7799
|
const { editor } = useTiptapEditor(providedEditor);
|
|
7786
|
-
const { isVisible, handleAction, label, canExecute, Icon
|
|
7800
|
+
const { isVisible, handleAction, label, canExecute, Icon, shortcutKeys } = useUndoRedo({
|
|
7787
7801
|
editor,
|
|
7788
7802
|
action,
|
|
7789
7803
|
hideWhenUnavailable,
|
|
@@ -7815,7 +7829,7 @@ var UndoRedoButton = React.forwardRef(
|
|
|
7815
7829
|
...buttonProps,
|
|
7816
7830
|
ref,
|
|
7817
7831
|
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
7818
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7832
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "tiptap-button-icon" }),
|
|
7819
7833
|
text && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tiptap-button-text", children: text }),
|
|
7820
7834
|
showShortcut && /* @__PURE__ */ jsxRuntime.jsx(
|
|
7821
7835
|
HistoryShortcutBadge,
|
|
@@ -8217,8 +8231,8 @@ var MainToolbarContent = ({
|
|
|
8217
8231
|
/* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {})
|
|
8218
8232
|
] }),
|
|
8219
8233
|
onQuote && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteIcon, {}), tooltip: "\u5F15\u7528\u9009\u4E2D\u6587\u672C", onClick: onQuote, children: "\u5F15\u7528" }) }),
|
|
8220
|
-
onCreateAnnotation && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8221
|
-
onCreateCollection && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8234
|
+
onCreateAnnotation && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MessageOutlined, {}), tooltip: "\u6279\u6CE8", onClick: onCreateAnnotation, children: "\u6279\u6CE8" }) }),
|
|
8235
|
+
onCreateCollection && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(icons.BookOutlined, {}), tooltip: "\u6458\u5F55\u7B14\u8BB0", onClick: onCreateCollection, children: "\u6458\u5F55" }) }),
|
|
8222
8236
|
(tools.includes("heading") || tools.includes("list") || tools.includes("block")) && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
8223
8237
|
/* @__PURE__ */ jsxRuntime.jsxs(ToolbarGroup, { children: [
|
|
8224
8238
|
tools.includes("heading") && /* @__PURE__ */ jsxRuntime.jsx(HeadingDropdownMenu, { levels: [1, 2, 3, 4], portal: isMobile }),
|
|
@@ -8691,7 +8705,7 @@ var MarkdownEditor_default = ({
|
|
|
8691
8705
|
{
|
|
8692
8706
|
size: "small",
|
|
8693
8707
|
title: "\u6279\u6CE8\u5217\u8868",
|
|
8694
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8708
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MessageOutlined, {}),
|
|
8695
8709
|
color: "primary",
|
|
8696
8710
|
variant: "text",
|
|
8697
8711
|
onClick: () => setShowAnnotation(!showAnnotation)
|
|
@@ -8703,7 +8717,7 @@ var MarkdownEditor_default = ({
|
|
|
8703
8717
|
style: { gap: "2px" },
|
|
8704
8718
|
size: "small",
|
|
8705
8719
|
title: "\u6458\u5F55\u5217\u8868",
|
|
8706
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(
|
|
8720
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.BookOutlined, {}),
|
|
8707
8721
|
color: "primary",
|
|
8708
8722
|
variant: "text",
|
|
8709
8723
|
onClick: () => setShowCollection(!showCollection),
|
|
@@ -8862,66 +8876,6 @@ function propsMerge(control, props) {
|
|
|
8862
8876
|
}
|
|
8863
8877
|
return null;
|
|
8864
8878
|
}
|
|
8865
|
-
var SpeechLoading_default = () => /* @__PURE__ */ jsxRuntime.jsxs("svg", { color: "currentColor", viewBox: "0 0 1000 1000", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
8866
|
-
/* @__PURE__ */ jsxRuntime.jsxs("rect", { fill: "currentColor", rx: "70", ry: "70", height: "250", width: "140", x: "0", y: "375", children: [
|
|
8867
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "height", values: "250; 500; 250", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0s", repeatCount: "indefinite" }),
|
|
8868
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "y", values: "375; 250; 375", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0s", repeatCount: "indefinite" })
|
|
8869
|
-
] }),
|
|
8870
|
-
/* @__PURE__ */ jsxRuntime.jsxs("rect", { fill: "currentColor", rx: "70", ry: "70", height: "250", width: "140", x: "286.66666666666663", y: "375", children: [
|
|
8871
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "height", values: "250; 500; 250", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0.2s", repeatCount: "indefinite" }),
|
|
8872
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "y", values: "375; 250; 375", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0.2s", repeatCount: "indefinite" })
|
|
8873
|
-
] }),
|
|
8874
|
-
/* @__PURE__ */ jsxRuntime.jsxs("rect", { fill: "currentColor", rx: "70", ry: "70", height: "250", width: "140", x: "573.3333333333333", y: "375", children: [
|
|
8875
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "height", values: "250; 500; 250", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0.4s", repeatCount: "indefinite" }),
|
|
8876
|
-
/* @__PURE__ */ jsxRuntime.jsx("animate", { attributeName: "y", values: "375; 250; 375", keyTimes: "0; 0.5; 1", dur: "0.8s", begin: "0.4s", repeatCount: "indefinite" })
|
|
8877
|
-
] }),
|
|
8878
|
-
/* @__PURE__ */ jsxRuntime.jsxs("rect", { fill: "currentColor", rx: "70", ry: "70", height: "250", width: "140", x: "859.9999999999999", y: "375", children: [
|
|
8879
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8880
|
-
"animate",
|
|
8881
|
-
{
|
|
8882
|
-
attributeName: "height",
|
|
8883
|
-
values: "250; 500; 250",
|
|
8884
|
-
keyTimes: "0; 0.5; 1",
|
|
8885
|
-
dur: "0.8s",
|
|
8886
|
-
begin: "0.6000000000000001s",
|
|
8887
|
-
repeatCount: "indefinite"
|
|
8888
|
-
}
|
|
8889
|
-
),
|
|
8890
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8891
|
-
"animate",
|
|
8892
|
-
{
|
|
8893
|
-
attributeName: "y",
|
|
8894
|
-
values: "375; 250; 375",
|
|
8895
|
-
keyTimes: "0; 0.5; 1",
|
|
8896
|
-
dur: "0.8s",
|
|
8897
|
-
begin: "0.6000000000000001s",
|
|
8898
|
-
repeatCount: "indefinite"
|
|
8899
|
-
}
|
|
8900
|
-
)
|
|
8901
|
-
] })
|
|
8902
|
-
] });
|
|
8903
|
-
var SpeechButton_default = (props) => {
|
|
8904
|
-
const { permission, isRecording, start, stop } = useSpeech_default(props);
|
|
8905
|
-
const disabled = permission === "denied" || permission === "unsupported";
|
|
8906
|
-
const handleClick = () => {
|
|
8907
|
-
if (isRecording) {
|
|
8908
|
-
stop();
|
|
8909
|
-
} else {
|
|
8910
|
-
start();
|
|
8911
|
-
}
|
|
8912
|
-
};
|
|
8913
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8914
|
-
antd.Button,
|
|
8915
|
-
{
|
|
8916
|
-
title: permission === "unsupported" ? "\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u8BED\u97F3\u8BC6\u522B" : permission === "denied" ? "\u9EA6\u514B\u98CE\u6743\u9650\u5DF2\u62D2\u7EDD" : isRecording ? "\u505C\u6B62\u5F55\u97F3" : "\u70B9\u51FB\u5F00\u59CB\u5F55\u97F3",
|
|
8917
|
-
disabled,
|
|
8918
|
-
color: "primary",
|
|
8919
|
-
variant: "text",
|
|
8920
|
-
icon: isRecording ? /* @__PURE__ */ jsxRuntime.jsx(Icon__default.default, { style: { width: 16 }, component: SpeechLoading_default }) : disabled ? /* @__PURE__ */ jsxRuntime.jsx(Icon.AudioMutedOutlined, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icon.AudioOutlined, {}),
|
|
8921
|
-
onClick: handleClick
|
|
8922
|
-
}
|
|
8923
|
-
);
|
|
8924
|
-
};
|
|
8925
8879
|
var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
8926
8880
|
return avatarSrc ? /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsxRuntime.jsx(antd.Avatar, { size, className: "cursor-pointer", style: { backgroundColor: "var(--ant-color-primary)" }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
8927
8881
|
};
|
|
@@ -8959,7 +8913,6 @@ exports.RegTaxNo = RegTaxNo;
|
|
|
8959
8913
|
exports.RegTelePhone = RegTelePhone;
|
|
8960
8914
|
exports.RenderMarkdown = RenderMarkdown_default;
|
|
8961
8915
|
exports.RenderWrapper = RenderWrapper_default;
|
|
8962
|
-
exports.SpeechButton = SpeechButton_default;
|
|
8963
8916
|
exports.ThanNumLengthValidator = ThanNumLengthValidator;
|
|
8964
8917
|
exports.ThanNumValidator = ThanNumValidator;
|
|
8965
8918
|
exports.UserAvatar = UserAvatar_default;
|
|
@@ -9050,6 +9003,7 @@ exports.times = times;
|
|
|
9050
9003
|
exports.toFixed = toFixed;
|
|
9051
9004
|
exports.transform = transform;
|
|
9052
9005
|
exports.transforms = transforms;
|
|
9006
|
+
exports.useAsyncQueue = useAsyncQueue_default;
|
|
9053
9007
|
exports.useAutoRefresh = useAutoRefresh_default;
|
|
9054
9008
|
exports.useCountDown = useCountDown_default;
|
|
9055
9009
|
exports.useCreateValtioContext = useCreateValtioContext_default;
|
|
@@ -9057,7 +9011,6 @@ exports.useDebounce = useDebounce_default;
|
|
|
9057
9011
|
exports.useDeepEffect = useDeepEffect_default;
|
|
9058
9012
|
exports.useIframeRelayBridge = useIframeRelayBridge_default;
|
|
9059
9013
|
exports.useRefState = useRefState_default;
|
|
9060
|
-
exports.useSpeech = useSpeech_default;
|
|
9061
9014
|
exports.useSyncInput = useSyncInput_default;
|
|
9062
9015
|
exports.useThrottle = useThrottle_default;
|
|
9063
9016
|
exports.useWebSocket = useWebSocket_default;
|