@zero-library/common 2.3.5 → 2.3.7
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 +31 -44
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +41 -8
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.esm.js +32 -45
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -293,7 +293,7 @@ type CollectionType = {
|
|
|
293
293
|
[key in (typeof COLLECTION_ATTRS)[number]]: string;
|
|
294
294
|
};
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
296
|
+
* 摘录功能配置
|
|
297
297
|
*/
|
|
298
298
|
interface CollectionsProps {
|
|
299
299
|
/** 是否启用批注功能,默认为false */
|
|
@@ -303,23 +303,23 @@ interface CollectionsProps {
|
|
|
303
303
|
id: string;
|
|
304
304
|
name: string;
|
|
305
305
|
};
|
|
306
|
-
/**
|
|
306
|
+
/** 是否显示摘录列表,默认为true */
|
|
307
307
|
showList?: boolean;
|
|
308
308
|
/** 受控属性:批注列表是否可见 */
|
|
309
309
|
visible?: boolean;
|
|
310
310
|
/** 受控属性:批注列表可见性改变回调 */
|
|
311
311
|
onVisibleChange?: (visible: boolean) => void;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
314
|
-
* @param data
|
|
315
|
-
* @returns
|
|
313
|
+
* 创建摘录的回调
|
|
314
|
+
* @param data 摘录数据
|
|
315
|
+
* @returns 返回摘录ID(如果有),返回Promise
|
|
316
316
|
*/
|
|
317
317
|
onBeforeCreate?: (data: {
|
|
318
318
|
content: string;
|
|
319
319
|
pageNo?: number;
|
|
320
320
|
}) => Promise<string>;
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
322
|
+
* 自定义渲染摘录列表项
|
|
323
323
|
* @param props 列表项数据及操作
|
|
324
324
|
* @returns React节点
|
|
325
325
|
*/
|
|
@@ -331,7 +331,7 @@ interface CollectionsProps {
|
|
|
331
331
|
}) => React.ReactNode;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* 摘录功能配置接口
|
|
335
335
|
*/
|
|
336
336
|
interface CollectionConfig extends CollectionsProps {
|
|
337
337
|
getContainer?: () => HTMLElement | null;
|
|
@@ -359,7 +359,7 @@ interface MarkdownEditorProps {
|
|
|
359
359
|
onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
|
|
360
360
|
/** 批注功能配置对象 */
|
|
361
361
|
annotationConfig?: AnnotationConfig;
|
|
362
|
-
/**
|
|
362
|
+
/** 摘录功能专属配置,不与批注混淆 */
|
|
363
363
|
collectionConfig?: CollectionConfig;
|
|
364
364
|
pageNoConfig?: {
|
|
365
365
|
/** 是否启用分页功能,默认为false */
|
package/dist/index.d.ts
CHANGED
|
@@ -293,7 +293,7 @@ type CollectionType = {
|
|
|
293
293
|
[key in (typeof COLLECTION_ATTRS)[number]]: string;
|
|
294
294
|
};
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
296
|
+
* 摘录功能配置
|
|
297
297
|
*/
|
|
298
298
|
interface CollectionsProps {
|
|
299
299
|
/** 是否启用批注功能,默认为false */
|
|
@@ -303,23 +303,23 @@ interface CollectionsProps {
|
|
|
303
303
|
id: string;
|
|
304
304
|
name: string;
|
|
305
305
|
};
|
|
306
|
-
/**
|
|
306
|
+
/** 是否显示摘录列表,默认为true */
|
|
307
307
|
showList?: boolean;
|
|
308
308
|
/** 受控属性:批注列表是否可见 */
|
|
309
309
|
visible?: boolean;
|
|
310
310
|
/** 受控属性:批注列表可见性改变回调 */
|
|
311
311
|
onVisibleChange?: (visible: boolean) => void;
|
|
312
312
|
/**
|
|
313
|
-
*
|
|
314
|
-
* @param data
|
|
315
|
-
* @returns
|
|
313
|
+
* 创建摘录的回调
|
|
314
|
+
* @param data 摘录数据
|
|
315
|
+
* @returns 返回摘录ID(如果有),返回Promise
|
|
316
316
|
*/
|
|
317
317
|
onBeforeCreate?: (data: {
|
|
318
318
|
content: string;
|
|
319
319
|
pageNo?: number;
|
|
320
320
|
}) => Promise<string>;
|
|
321
321
|
/**
|
|
322
|
-
*
|
|
322
|
+
* 自定义渲染摘录列表项
|
|
323
323
|
* @param props 列表项数据及操作
|
|
324
324
|
* @returns React节点
|
|
325
325
|
*/
|
|
@@ -331,7 +331,7 @@ interface CollectionsProps {
|
|
|
331
331
|
}) => React.ReactNode;
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
|
-
*
|
|
334
|
+
* 摘录功能配置接口
|
|
335
335
|
*/
|
|
336
336
|
interface CollectionConfig extends CollectionsProps {
|
|
337
337
|
getContainer?: () => HTMLElement | null;
|
|
@@ -359,7 +359,7 @@ interface MarkdownEditorProps {
|
|
|
359
359
|
onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
|
|
360
360
|
/** 批注功能配置对象 */
|
|
361
361
|
annotationConfig?: AnnotationConfig;
|
|
362
|
-
/**
|
|
362
|
+
/** 摘录功能专属配置,不与批注混淆 */
|
|
363
363
|
collectionConfig?: CollectionConfig;
|
|
364
364
|
pageNoConfig?: {
|
|
365
365
|
/** 是否启用分页功能,默认为false */
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import Icon, { MinusCircleOutlined, PlusCircleOutlined, RedoOutlined, FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined, MessageOutlined, BookOutlined, AudioMutedOutlined, AudioOutlined, EditOutlined, DeleteOutlined, CloseOutlined } from '@ant-design/icons';
|
|
3
|
-
import { Spin, Input, Typography, message, Flex,
|
|
3
|
+
import { Spin, Input, Typography, Tooltip as Tooltip$1, Button, message, Flex, Alert, Skeleton, Result, Splitter, Empty, Image, Drawer, Avatar, notification, Modal, Form, Card as Card$1, List, Space, Popconfirm } from 'antd';
|
|
4
4
|
import classNames2 from 'classnames';
|
|
5
5
|
import { renderAsync } from 'docx-preview';
|
|
6
6
|
import * as React from 'react';
|
|
@@ -2054,7 +2054,7 @@ var PdfImagePreview_default = ({ fileUrl, pageNo, scale = 1, isHasThumbnails = t
|
|
|
2054
2054
|
return index;
|
|
2055
2055
|
}
|
|
2056
2056
|
}
|
|
2057
|
-
return 0;
|
|
2057
|
+
return getCurrentIndex() ?? 0;
|
|
2058
2058
|
};
|
|
2059
2059
|
useEffect(() => {
|
|
2060
2060
|
const index = getIndex(pageNo);
|
|
@@ -3287,7 +3287,7 @@ var isSelectionValid = (editor, selection, excludedNodeTypes = ["imageUpload", "
|
|
|
3287
3287
|
const { state } = editor;
|
|
3288
3288
|
const { doc } = state;
|
|
3289
3289
|
const { empty, from, to } = selection;
|
|
3290
|
-
const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(selection);
|
|
3290
|
+
const isEmptyTextBlock = !doc.textBetween(from, to).length && !isTextSelection(selection);
|
|
3291
3291
|
const isCodeBlock = selection.$from.parent.type.spec.code || isNodeSelection(selection) && selection.node.type.spec.code;
|
|
3292
3292
|
const isExcludedNode = isNodeSelection(selection) && excludedNodeTypes.includes(selection.node.type.name);
|
|
3293
3293
|
const isTableCell = selection instanceof CellSelection;
|
|
@@ -7458,7 +7458,7 @@ var createHtmlMark = (markName, ATTRS, classNames7) => {
|
|
|
7458
7458
|
return Mark.create({
|
|
7459
7459
|
name: markName,
|
|
7460
7460
|
priority: 1e3,
|
|
7461
|
-
//
|
|
7461
|
+
// 高优先级确保摘录不会被其他marks覆盖
|
|
7462
7462
|
excludes: "",
|
|
7463
7463
|
// 允许相同类型 mark 叠加
|
|
7464
7464
|
inclusive: false,
|
|
@@ -7914,7 +7914,7 @@ var collectionSidebar_default = ({
|
|
|
7914
7914
|
/* @__PURE__ */ jsxs(Space, { children: [
|
|
7915
7915
|
/* @__PURE__ */ jsx(BookOutlined, {}),
|
|
7916
7916
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
7917
|
-
"\
|
|
7917
|
+
"\u6458\u5F55",
|
|
7918
7918
|
collections.length > 0 && `\uFF08${collections.length}\uFF09`
|
|
7919
7919
|
] })
|
|
7920
7920
|
] }),
|
|
@@ -7960,9 +7960,9 @@ var collectionSidebar_default = ({
|
|
|
7960
7960
|
title: "\u63D0\u793A",
|
|
7961
7961
|
okText: "\u786E\u5B9A",
|
|
7962
7962
|
cancelText: "\u53D6\u6D88",
|
|
7963
|
-
description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\
|
|
7963
|
+
description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6458\u5F55\u5417?",
|
|
7964
7964
|
onConfirm: () => onDeleteCollection(collection[COLLECTION_ATTRS[0]]),
|
|
7965
|
-
children: /* @__PURE__ */ jsx(Button, { type: "text", size: "small", title: "\u5220\u9664\
|
|
7965
|
+
children: /* @__PURE__ */ jsx(Button, { type: "text", size: "small", title: "\u5220\u9664\u6458\u5F55", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}) })
|
|
7966
7966
|
}
|
|
7967
7967
|
) })
|
|
7968
7968
|
] })
|
|
@@ -7971,7 +7971,7 @@ var collectionSidebar_default = ({
|
|
|
7971
7971
|
);
|
|
7972
7972
|
}
|
|
7973
7973
|
}
|
|
7974
|
-
) : /* @__PURE__ */ jsx(Empty, { className: "m-t-24", description: "\u6682\u65E0\
|
|
7974
|
+
) : /* @__PURE__ */ jsx(Empty, { className: "m-t-24", description: "\u6682\u65E0\u6458\u5F55" })
|
|
7975
7975
|
}
|
|
7976
7976
|
);
|
|
7977
7977
|
const container = collectionConfig?.getContainer?.();
|
|
@@ -8108,7 +8108,7 @@ function useSelect(editor, disabled = false, hideWhenUnavailable = false) {
|
|
|
8108
8108
|
};
|
|
8109
8109
|
}
|
|
8110
8110
|
var SelectButton = React__default.forwardRef(
|
|
8111
|
-
({ editor: providedEditor,
|
|
8111
|
+
({ editor: providedEditor, disabled = false, hideWhenUnavailable = false, onClick, children, icon, tooltip, ...buttonProps }, ref) => {
|
|
8112
8112
|
const { editor } = useTiptapEditor(providedEditor);
|
|
8113
8113
|
const { isDisabled, shouldShow, getText, getMarkdown } = useSelect(editor, disabled, hideWhenUnavailable);
|
|
8114
8114
|
const handleClick = React__default.useCallback(
|
|
@@ -8121,23 +8121,7 @@ var SelectButton = React__default.forwardRef(
|
|
|
8121
8121
|
[onClick, editor, isDisabled, getText, getMarkdown]
|
|
8122
8122
|
);
|
|
8123
8123
|
if (!shouldShow || !editor || !editor.isEditable) return null;
|
|
8124
|
-
return /* @__PURE__ */ jsx(
|
|
8125
|
-
Button4,
|
|
8126
|
-
{
|
|
8127
|
-
type: "button",
|
|
8128
|
-
className: className.trim(),
|
|
8129
|
-
disabled: isDisabled,
|
|
8130
|
-
"data-style": "ghost",
|
|
8131
|
-
"data-disabled": isDisabled,
|
|
8132
|
-
onClick: handleClick,
|
|
8133
|
-
...buttonProps,
|
|
8134
|
-
ref,
|
|
8135
|
-
children: children || /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8136
|
-
icon,
|
|
8137
|
-
text && /* @__PURE__ */ jsx("span", { className: "tiptap-button-text", children: text })
|
|
8138
|
-
] })
|
|
8139
|
-
}
|
|
8140
|
-
);
|
|
8124
|
+
return /* @__PURE__ */ jsx(Tooltip$1, { placement: "bottom", title: tooltip, arrow: false, children: /* @__PURE__ */ jsx(Button, { color: "orange", variant: "text", size: "small", icon, onClick: handleClick, disabled: isDisabled, ...buttonProps, ref, children }) });
|
|
8141
8125
|
}
|
|
8142
8126
|
);
|
|
8143
8127
|
SelectButton.displayName = "SelectButton";
|
|
@@ -8344,14 +8328,14 @@ var SearchAndReplace = Extension.create({
|
|
|
8344
8328
|
}
|
|
8345
8329
|
});
|
|
8346
8330
|
var searchAndReplace_default = SearchAndReplace;
|
|
8347
|
-
var QuoteIcon = React.memo(({
|
|
8348
|
-
return /* @__PURE__ */ jsx("svg", { width: "
|
|
8331
|
+
var QuoteIcon = React.memo(({ ...props }) => {
|
|
8332
|
+
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(
|
|
8349
8333
|
"path",
|
|
8350
8334
|
{
|
|
8351
8335
|
d: "M130.16 789.92V500.25q-1.85-62.51 18-117.41T204 286.23a308 308 0 0 1 86.13-69.1A304.32 304.32 0 0 1 386.26 184 11 11 0 0 1 399 194.86v104.52a11 11 0 0 1-7.21 10.29q-66.13 24.5-91.25 70.31-24.41 44.36-26.32 107a11 11 0 0 0 11 11.3h102.84a11 11 0 0 1 11 11V779a11 11 0 0 1-11 11h-257.9z m403.3 0V500.25q-2-62.51 17.95-117.41t55.85-96.61q35.94-41.6 86.13-69.1A304.7 304.7 0 0 1 789.56 184a11 11 0 0 1 12.76 10.82v104.56a11 11 0 0 1-7.21 10.29Q729 334.18 703.86 380q-24.41 44.36-26.32 107a11 11 0 0 0 11 11.3h102.82a11 11 0 0 1 11 11V779a11 11 0 0 1-11 11H533.45z m0 0",
|
|
8352
8336
|
fill: "currentColor"
|
|
8353
8337
|
}
|
|
8354
|
-
) });
|
|
8338
|
+
) }) });
|
|
8355
8339
|
});
|
|
8356
8340
|
QuoteIcon.displayName = "QuoteIcon";
|
|
8357
8341
|
var MainToolbarContent = ({
|
|
@@ -8372,9 +8356,9 @@ var MainToolbarContent = ({
|
|
|
8372
8356
|
] }),
|
|
8373
8357
|
/* @__PURE__ */ jsx(ToolbarSeparator, {})
|
|
8374
8358
|
] }),
|
|
8375
|
-
onQuote && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(QuoteIcon, {
|
|
8359
|
+
onQuote && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(QuoteIcon, {}), tooltip: "\u5F15\u7528\u9009\u4E2D\u6587\u672C", onClick: onQuote }) }),
|
|
8376
8360
|
onCreateAnnotation && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(MessageOutlined, {}), tooltip: "\u6279\u6CE8", onClick: onCreateAnnotation }) }),
|
|
8377
|
-
onCreateCollection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(BookOutlined, {}), tooltip: "\
|
|
8361
|
+
onCreateCollection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(BookOutlined, {}), tooltip: "\u6458\u5F55\u7B14\u8BB0", onClick: onCreateCollection }) }),
|
|
8378
8362
|
/* @__PURE__ */ jsxs(ToolbarGroup, { children: [
|
|
8379
8363
|
/* @__PURE__ */ jsx(HeadingDropdownMenu, { levels: [1, 2, 3, 4], portal: isMobile }),
|
|
8380
8364
|
/* @__PURE__ */ jsx(ListDropdownMenu, { types: ["bulletList", "orderedList", "taskList"], portal: isMobile }),
|
|
@@ -8542,7 +8526,7 @@ var MarkdownEditor_default = ({
|
|
|
8542
8526
|
}
|
|
8543
8527
|
})
|
|
8544
8528
|
] : [],
|
|
8545
|
-
//
|
|
8529
|
+
// 摘录功能扩展
|
|
8546
8530
|
...collectionConfig?.enabled ? [
|
|
8547
8531
|
CollectionMark,
|
|
8548
8532
|
CollectionPlugin.configure({
|
|
@@ -8564,6 +8548,7 @@ var MarkdownEditor_default = ({
|
|
|
8564
8548
|
});
|
|
8565
8549
|
const getMarkdown = () => {
|
|
8566
8550
|
if (!editor) return "";
|
|
8551
|
+
if (editor.isEmpty) return "";
|
|
8567
8552
|
return editor.getMarkdown();
|
|
8568
8553
|
};
|
|
8569
8554
|
useEffect(() => {
|
|
@@ -8626,28 +8611,30 @@ var MarkdownEditor_default = ({
|
|
|
8626
8611
|
NsToolBar({ isBubble: false }),
|
|
8627
8612
|
/* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", className: classNames2(styles_module_default4.extraToolbar), children: [
|
|
8628
8613
|
annotationConfig?.enabled && annotationConfig?.showList !== false && /* @__PURE__ */ jsx(
|
|
8629
|
-
|
|
8614
|
+
Button,
|
|
8630
8615
|
{
|
|
8616
|
+
size: "small",
|
|
8631
8617
|
title: "\u6279\u6CE8\u5217\u8868",
|
|
8632
|
-
|
|
8633
|
-
color: "
|
|
8634
|
-
|
|
8635
|
-
onClick: () => setShowAnnotation(!showAnnotation)
|
|
8636
|
-
children: /* @__PURE__ */ jsx(MessageOutlined, {})
|
|
8618
|
+
icon: /* @__PURE__ */ jsx(MessageOutlined, {}),
|
|
8619
|
+
color: "primary",
|
|
8620
|
+
variant: "text",
|
|
8621
|
+
onClick: () => setShowAnnotation(!showAnnotation)
|
|
8637
8622
|
}
|
|
8638
8623
|
),
|
|
8639
8624
|
collectionConfig?.enabled && collectionConfig?.showList !== false && /* @__PURE__ */ jsx(
|
|
8640
|
-
|
|
8625
|
+
Button,
|
|
8641
8626
|
{
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8627
|
+
style: { gap: "2px" },
|
|
8628
|
+
size: "small",
|
|
8629
|
+
title: "\u6458\u5F55\u5217\u8868",
|
|
8630
|
+
icon: /* @__PURE__ */ jsx(BookOutlined, {}),
|
|
8631
|
+
color: "primary",
|
|
8632
|
+
variant: "text",
|
|
8646
8633
|
onClick: () => setShowCollection(!showCollection),
|
|
8647
|
-
children:
|
|
8634
|
+
children: "\u6458\u5F55"
|
|
8648
8635
|
}
|
|
8649
8636
|
),
|
|
8650
|
-
onDownloadFile && /* @__PURE__ */ jsx(
|
|
8637
|
+
onDownloadFile && /* @__PURE__ */ jsx(Button, { size: "small", color: "primary", variant: "text", onClick: downloadFile2, children: "\u4E0B\u8F7D" }),
|
|
8651
8638
|
extraNav
|
|
8652
8639
|
] })
|
|
8653
8640
|
] }),
|