@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.cjs.js CHANGED
@@ -8076,11 +8076,14 @@ var useCollections = (collectionConfig) => {
8076
8076
  }
8077
8077
  const content = getSelectedText(editor.current);
8078
8078
  const pageIndex = editor.current.commands?.getPageNo?.();
8079
- const remoteId = await collectionConfig.onBeforeCreate({
8080
- content,
8081
- pageNo: pageIndex
8082
- });
8083
- if (!remoteId) return;
8079
+ let remoteId = genNonDuplicateID();
8080
+ if (collectionConfig?.onBeforeCreate) {
8081
+ remoteId = await collectionConfig?.onBeforeCreate({
8082
+ content,
8083
+ pageNo: pageIndex
8084
+ });
8085
+ if (!remoteId) return;
8086
+ }
8084
8087
  editor.current.chain().focus().setMark(COLLECTION_KEY, {
8085
8088
  "collection-id": remoteId,
8086
8089
  "user-name": collectionConfig?.user?.name || "\u672A\u77E5",
@@ -8395,7 +8398,6 @@ var MainToolbarContent = ({
8395
8398
  }) => {
8396
8399
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8397
8400
  /* @__PURE__ */ jsxRuntime.jsx(Spacer, {}),
8398
- onQuote && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteIcon, { className: "tiptap-button-icon" }), tooltip: "\u5F15\u7528\u9009\u4E2D\u6587\u672C", onClick: onQuote }) }),
8399
8401
  !isBubble && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8400
8402
  /* @__PURE__ */ jsxRuntime.jsxs(ToolbarGroup, { children: [
8401
8403
  /* @__PURE__ */ jsxRuntime.jsx(UndoRedoButton, { action: "undo" }),
@@ -8403,6 +8405,7 @@ var MainToolbarContent = ({
8403
8405
  ] }),
8404
8406
  /* @__PURE__ */ jsxRuntime.jsx(ToolbarSeparator, {})
8405
8407
  ] }),
8408
+ onQuote && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(QuoteIcon, { className: "tiptap-button-icon" }), tooltip: "\u5F15\u7528\u9009\u4E2D\u6587\u672C", onClick: onQuote }) }),
8406
8409
  onCreateAnnotation && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icon.MessageOutlined, {}), tooltip: "\u6279\u6CE8", onClick: onCreateAnnotation }) }),
8407
8410
  onCreateCollection && /* @__PURE__ */ jsxRuntime.jsx(ToolbarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectButton, { icon: /* @__PURE__ */ jsxRuntime.jsx(Icon.BookOutlined, {}), tooltip: "\u6536\u5F55\u7B14\u8BB0", onClick: onCreateCollection }) }),
8408
8411
  /* @__PURE__ */ jsxRuntime.jsxs(ToolbarGroup, { children: [
@@ -8586,7 +8589,6 @@ var MarkdownEditor_default = ({
8586
8589
  content: value,
8587
8590
  contentType: "markdown",
8588
8591
  onUpdate: () => {
8589
- console.log("update \u6587\u672C\u6539\u53D8");
8590
8592
  const markdownOutput = getMarkdown();
8591
8593
  if (markdownOutput === lastContentRef.current) return;
8592
8594
  lastContentRef.current = markdownOutput;
@@ -8730,7 +8732,7 @@ var styles_module_default7 = {
8730
8732
  rect: "styles_module_rect",
8731
8733
  score: "styles_module_score"
8732
8734
  };
8733
- var MarkDrawing_default = ({ children, detections, originalSize }) => {
8735
+ var MarkDrawing_default = ({ children, detections, originalSize, scopeRender }) => {
8734
8736
  const containerRef = React.useRef(null);
8735
8737
  const [containerSize, setContainerSize] = React.useState({
8736
8738
  width: originalSize.width,
@@ -8751,7 +8753,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8751
8753
  const scaleY = containerSize.height / originalSize.height;
8752
8754
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: styles_module_default7.container, children: [
8753
8755
  children,
8754
- detections.map((det, idx) => {
8756
+ detections?.map((det, idx) => {
8755
8757
  const [x1, y1, x2, y2] = det.bbox;
8756
8758
  const left = x1 * scaleX;
8757
8759
  const top = y1 * scaleY;
@@ -8778,7 +8780,7 @@ var MarkDrawing_default = ({ children, detections, originalSize }) => {
8778
8780
  left,
8779
8781
  top: Math.max(top - 20, 0)
8780
8782
  },
8781
- children: det.score.toFixed(3)
8783
+ children: scopeRender ? scopeRender(det.score) : det.score
8782
8784
  }
8783
8785
  )
8784
8786
  ] }, idx);