@zero-library/common 2.3.1 → 2.3.2

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: [