@zero-library/common 2.3.4 → 2.3.6

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.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
- /** 是否显示收录列表,默认为true */
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 返回收录ID(如果有),返回Promise
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
- /** 是否显示收录列表,默认为true */
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 返回收录ID(如果有),返回Promise
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, Button, Alert, Skeleton, Result, Splitter, Empty, Image, Drawer, Tag, Avatar, notification, Modal, Form, Card as Card$1, List, Space, Popconfirm } from 'antd';
3
+ import { Spin, Input, Typography, message, Flex, Button, 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';
@@ -1340,14 +1340,17 @@ var styles_module_default2 = {
1340
1340
  var baseComponentMap = {
1341
1341
  // renderMarkdown: () => import('@/components/RenderMarkdown')
1342
1342
  };
1343
+ var lazyCache = /* @__PURE__ */ new Map();
1343
1344
  var LazyComponent_default = ({ type, customComponents, unknownContent, ...rest }) => {
1344
- const componentMap = useMemo(() => {
1345
- return { ...baseComponentMap, ...customComponents };
1346
- }, [customComponents]);
1345
+ const loader = customComponents?.[type] || baseComponentMap[type];
1347
1346
  const LazyComponent = useMemo(() => {
1348
- const loader = componentMap[type];
1349
- return loader ? lazy(loader) : null;
1350
- }, [type, componentMap]);
1347
+ if (!loader) return null;
1348
+ const cached = lazyCache.get(type);
1349
+ if (cached) return cached;
1350
+ const component = lazy(loader);
1351
+ lazyCache.set(type, component);
1352
+ return component;
1353
+ }, [loader]);
1351
1354
  if (!LazyComponent) return unknownContent || /* @__PURE__ */ jsx(Alert, { message: `\u672A\u77E5\u7C7B\u578B\uFF1A${type}`, type: "warning" });
1352
1355
  return /* @__PURE__ */ jsx(
1353
1356
  Suspense,
@@ -3284,7 +3287,7 @@ var isSelectionValid = (editor, selection, excludedNodeTypes = ["imageUpload", "
3284
3287
  const { state } = editor;
3285
3288
  const { doc } = state;
3286
3289
  const { empty, from, to } = selection;
3287
- const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(selection);
3290
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && !isTextSelection(selection);
3288
3291
  const isCodeBlock = selection.$from.parent.type.spec.code || isNodeSelection(selection) && selection.node.type.spec.code;
3289
3292
  const isExcludedNode = isNodeSelection(selection) && excludedNodeTypes.includes(selection.node.type.name);
3290
3293
  const isTableCell = selection instanceof CellSelection;
@@ -7455,7 +7458,7 @@ var createHtmlMark = (markName, ATTRS, classNames7) => {
7455
7458
  return Mark.create({
7456
7459
  name: markName,
7457
7460
  priority: 1e3,
7458
- // 高优先级确保收录不会被其他marks覆盖
7461
+ // 高优先级确保摘录不会被其他marks覆盖
7459
7462
  excludes: "",
7460
7463
  // 允许相同类型 mark 叠加
7461
7464
  inclusive: false,
@@ -7911,7 +7914,7 @@ var collectionSidebar_default = ({
7911
7914
  /* @__PURE__ */ jsxs(Space, { children: [
7912
7915
  /* @__PURE__ */ jsx(BookOutlined, {}),
7913
7916
  /* @__PURE__ */ jsxs("span", { children: [
7914
- "\u6536\u5F55",
7917
+ "\u6458\u5F55",
7915
7918
  collections.length > 0 && `\uFF08${collections.length}\uFF09`
7916
7919
  ] })
7917
7920
  ] }),
@@ -7957,9 +7960,9 @@ var collectionSidebar_default = ({
7957
7960
  title: "\u63D0\u793A",
7958
7961
  okText: "\u786E\u5B9A",
7959
7962
  cancelText: "\u53D6\u6D88",
7960
- description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6536\u5F55\u5417?",
7963
+ description: "\u786E\u8BA4\u5220\u9664\u5F53\u524D\u6458\u5F55\u5417?",
7961
7964
  onConfirm: () => onDeleteCollection(collection[COLLECTION_ATTRS[0]]),
7962
- children: /* @__PURE__ */ jsx(Button, { type: "text", size: "small", title: "\u5220\u9664\u6536\u5F55", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}) })
7965
+ children: /* @__PURE__ */ jsx(Button, { type: "text", size: "small", title: "\u5220\u9664\u6458\u5F55", icon: /* @__PURE__ */ jsx(DeleteOutlined, {}) })
7963
7966
  }
7964
7967
  ) })
7965
7968
  ] })
@@ -7968,7 +7971,7 @@ var collectionSidebar_default = ({
7968
7971
  );
7969
7972
  }
7970
7973
  }
7971
- ) : /* @__PURE__ */ jsx(Empty, { className: "m-t-24", description: "\u6682\u65E0\u6536\u5F55" })
7974
+ ) : /* @__PURE__ */ jsx(Empty, { className: "m-t-24", description: "\u6682\u65E0\u6458\u5F55" })
7972
7975
  }
7973
7976
  );
7974
7977
  const container = collectionConfig?.getContainer?.();
@@ -8371,7 +8374,7 @@ var MainToolbarContent = ({
8371
8374
  ] }),
8372
8375
  onQuote && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(QuoteIcon, { className: "tiptap-button-icon" }), tooltip: "\u5F15\u7528\u9009\u4E2D\u6587\u672C", onClick: onQuote }) }),
8373
8376
  onCreateAnnotation && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(MessageOutlined, {}), tooltip: "\u6279\u6CE8", onClick: onCreateAnnotation }) }),
8374
- onCreateCollection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(BookOutlined, {}), tooltip: "\u6536\u5F55\u7B14\u8BB0", onClick: onCreateCollection }) }),
8377
+ onCreateCollection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(BookOutlined, {}), tooltip: "\u6458\u5F55\u7B14\u8BB0", onClick: onCreateCollection }) }),
8375
8378
  /* @__PURE__ */ jsxs(ToolbarGroup, { children: [
8376
8379
  /* @__PURE__ */ jsx(HeadingDropdownMenu, { levels: [1, 2, 3, 4], portal: isMobile }),
8377
8380
  /* @__PURE__ */ jsx(ListDropdownMenu, { types: ["bulletList", "orderedList", "taskList"], portal: isMobile }),
@@ -8539,7 +8542,7 @@ var MarkdownEditor_default = ({
8539
8542
  }
8540
8543
  })
8541
8544
  ] : [],
8542
- // 收录功能扩展
8545
+ // 摘录功能扩展
8543
8546
  ...collectionConfig?.enabled ? [
8544
8547
  CollectionMark,
8545
8548
  CollectionPlugin.configure({
@@ -8561,6 +8564,7 @@ var MarkdownEditor_default = ({
8561
8564
  });
8562
8565
  const getMarkdown = () => {
8563
8566
  if (!editor) return "";
8567
+ if (editor.isEmpty) return "";
8564
8568
  return editor.getMarkdown();
8565
8569
  };
8566
8570
  useEffect(() => {
@@ -8623,28 +8627,30 @@ var MarkdownEditor_default = ({
8623
8627
  NsToolBar({ isBubble: false }),
8624
8628
  /* @__PURE__ */ jsxs(Flex, { gap: 8, align: "center", className: classNames2(styles_module_default4.extraToolbar), children: [
8625
8629
  annotationConfig?.enabled && annotationConfig?.showList !== false && /* @__PURE__ */ jsx(
8626
- Tag,
8630
+ Button,
8627
8631
  {
8632
+ size: "small",
8628
8633
  title: "\u6279\u6CE8\u5217\u8868",
8629
- bordered: false,
8630
- color: "default",
8631
- className: "cursor-pointer",
8632
- onClick: () => setShowAnnotation(!showAnnotation),
8633
- children: /* @__PURE__ */ jsx(MessageOutlined, {})
8634
+ icon: /* @__PURE__ */ jsx(MessageOutlined, {}),
8635
+ color: "primary",
8636
+ variant: "text",
8637
+ onClick: () => setShowAnnotation(!showAnnotation)
8634
8638
  }
8635
8639
  ),
8636
8640
  collectionConfig?.enabled && collectionConfig?.showList !== false && /* @__PURE__ */ jsx(
8637
- Tag,
8641
+ Button,
8638
8642
  {
8639
- title: "\u6536\u5F55\u5217\u8868",
8640
- bordered: false,
8641
- color: "default",
8642
- className: "cursor-pointer",
8643
+ style: { gap: "2px" },
8644
+ size: "small",
8645
+ title: "\u6458\u5F55\u5217\u8868",
8646
+ icon: /* @__PURE__ */ jsx(BookOutlined, {}),
8647
+ color: "primary",
8648
+ variant: "text",
8643
8649
  onClick: () => setShowCollection(!showCollection),
8644
- children: /* @__PURE__ */ jsx(BookOutlined, {})
8650
+ children: "\u6458\u5F55"
8645
8651
  }
8646
8652
  ),
8647
- onDownloadFile && /* @__PURE__ */ jsx(Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: downloadFile2, children: "\u4E0B\u8F7D" }),
8653
+ onDownloadFile && /* @__PURE__ */ jsx(Button, { size: "small", color: "primary", variant: "text", onClick: downloadFile2, children: "\u4E0B\u8F7D" }),
8648
8654
  extraNav
8649
8655
  ] })
8650
8656
  ] }),