@zero-library/common 2.3.1 → 2.3.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.d.mts CHANGED
@@ -289,7 +289,6 @@ type CollectionType = {
289
289
  text: string;
290
290
  from: number;
291
291
  to: number;
292
- pageNo?: string;
293
292
  } & {
294
293
  [key in (typeof COLLECTION_ATTRS)[number]]: string;
295
294
  };
@@ -387,8 +386,9 @@ interface SizeType {
387
386
  }
388
387
  interface MarkDrawingProps {
389
388
  children: ReactNode;
390
- detections: Detection[];
389
+ detections?: Detection[];
391
390
  originalSize: SizeType;
391
+ scopeRender?: (score: number) => ReactNode;
392
392
  }
393
393
  /**
394
394
  * MarkDrawing组件
@@ -397,8 +397,9 @@ interface MarkDrawingProps {
397
397
  * @param children - 待绘制标注的内容
398
398
  * @param detections - 检测结果数组
399
399
  * @param originalSize - 原始尺寸信息
400
+ * @param scopeRender - 可选的作用域渲染函数
400
401
  */
401
- declare const _default$f: ({ children, detections, originalSize }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
+ declare const _default$f: ({ children, detections, originalSize, scopeRender }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
403
 
403
404
  /**
404
405
  * Markdown渲染组件属性接口
package/dist/index.d.ts CHANGED
@@ -289,7 +289,6 @@ type CollectionType = {
289
289
  text: string;
290
290
  from: number;
291
291
  to: number;
292
- pageNo?: string;
293
292
  } & {
294
293
  [key in (typeof COLLECTION_ATTRS)[number]]: string;
295
294
  };
@@ -387,8 +386,9 @@ interface SizeType {
387
386
  }
388
387
  interface MarkDrawingProps {
389
388
  children: ReactNode;
390
- detections: Detection[];
389
+ detections?: Detection[];
391
390
  originalSize: SizeType;
391
+ scopeRender?: (score: number) => ReactNode;
392
392
  }
393
393
  /**
394
394
  * MarkDrawing组件
@@ -397,8 +397,9 @@ interface MarkDrawingProps {
397
397
  * @param children - 待绘制标注的内容
398
398
  * @param detections - 检测结果数组
399
399
  * @param originalSize - 原始尺寸信息
400
+ * @param scopeRender - 可选的作用域渲染函数
400
401
  */
401
- declare const _default$f: ({ children, detections, originalSize }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
+ declare const _default$f: ({ children, detections, originalSize, scopeRender }: MarkDrawingProps) => react_jsx_runtime.JSX.Element;
402
403
 
403
404
  /**
404
405
  * Markdown渲染组件属性接口
package/dist/index.esm.js CHANGED
@@ -8033,11 +8033,14 @@ var useCollections = (collectionConfig) => {
8033
8033
  }
8034
8034
  const content = getSelectedText(editor.current);
8035
8035
  const pageIndex = editor.current.commands?.getPageNo?.();
8036
- const remoteId = await collectionConfig.onBeforeCreate({
8037
- content,
8038
- pageNo: pageIndex
8039
- });
8040
- if (!remoteId) return;
8036
+ let remoteId = genNonDuplicateID();
8037
+ if (collectionConfig?.onBeforeCreate) {
8038
+ remoteId = await collectionConfig?.onBeforeCreate({
8039
+ content,
8040
+ pageNo: pageIndex
8041
+ });
8042
+ if (!remoteId) return;
8043
+ }
8041
8044
  editor.current.chain().focus().setMark(COLLECTION_KEY, {
8042
8045
  "collection-id": remoteId,
8043
8046
  "user-name": collectionConfig?.user?.name || "\u672A\u77E5",
@@ -8352,7 +8355,6 @@ var MainToolbarContent = ({
8352
8355
  }) => {
8353
8356
  return /* @__PURE__ */ jsxs(Fragment, { children: [
8354
8357
  /* @__PURE__ */ jsx(Spacer, {}),
8355
- 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 }) }),
8356
8358
  !isBubble && /* @__PURE__ */ jsxs(Fragment, { children: [
8357
8359
  /* @__PURE__ */ jsxs(ToolbarGroup, { children: [
8358
8360
  /* @__PURE__ */ jsx(UndoRedoButton, { action: "undo" }),
@@ -8360,6 +8362,7 @@ var MainToolbarContent = ({
8360
8362
  ] }),
8361
8363
  /* @__PURE__ */ jsx(ToolbarSeparator, {})
8362
8364
  ] }),
8365
+ 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 }) }),
8363
8366
  onCreateAnnotation && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(MessageOutlined, {}), tooltip: "\u6279\u6CE8", onClick: onCreateAnnotation }) }),
8364
8367
  onCreateCollection && /* @__PURE__ */ jsx(ToolbarGroup, { children: /* @__PURE__ */ jsx(SelectButton, { icon: /* @__PURE__ */ jsx(BookOutlined, {}), tooltip: "\u6536\u5F55\u7B14\u8BB0", onClick: onCreateCollection }) }),
8365
8368
  /* @__PURE__ */ jsxs(ToolbarGroup, { children: [
@@ -8543,7 +8546,6 @@ var MarkdownEditor_default = ({
8543
8546
  content: value,
8544
8547
  contentType: "markdown",
8545
8548
  onUpdate: () => {
8546
- console.log("update \u6587\u672C\u6539\u53D8");
8547
8549
  const markdownOutput = getMarkdown();
8548
8550
  if (markdownOutput === lastContentRef.current) return;
8549
8551
  lastContentRef.current = markdownOutput;
@@ -8687,7 +8689,7 @@ var styles_module_default7 = {
8687
8689
  rect: "styles_module_rect",
8688
8690
  score: "styles_module_score"
8689
8691
  };
8690
- var MarkDrawing_default = ({ children, detections, originalSize }) => {
8692
+ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender }) => {
8691
8693
  const containerRef = useRef(null);
8692
8694
  const [containerSize, setContainerSize] = useState({
8693
8695
  width: originalSize.width,
@@ -8708,7 +8710,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8708
8710
  const scaleY = containerSize.height / originalSize.height;
8709
8711
  return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: styles_module_default7.container, children: [
8710
8712
  children,
8711
- detections.map((det, idx) => {
8713
+ detections?.map((det, idx) => {
8712
8714
  const [x1, y1, x2, y2] = det.bbox;
8713
8715
  const left = x1 * scaleX;
8714
8716
  const top = y1 * scaleY;
@@ -8735,7 +8737,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8735
8737
  left,
8736
8738
  top: Math.max(top - 20, 0)
8737
8739
  },
8738
- children: det.score.toFixed(3)
8740
+ children: scopeRender ? scopeRender(det.score) : det.score
8739
8741
  }
8740
8742
  )
8741
8743
  ] }, idx);