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