@windoc/react 0.2.11 → 0.3.1

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.js CHANGED
@@ -607,24 +607,29 @@ function ListTool() {
607
607
  const { editorRef, isApple, rangeStyle } = useEditor();
608
608
  const optionsRef = (0, import_react12.useRef)(null);
609
609
  const isActive = !!rangeStyle?.listType;
610
+ const close = () => optionsRef.current?.classList.remove("visible");
610
611
  const handleList = (type, style) => {
611
612
  editorRef.current?.command.executeList(type, style);
613
+ close();
612
614
  };
613
615
  const handlePreset = (type, preset) => {
614
616
  const style = type === "ol" ? "decimal" : "disc";
615
617
  editorRef.current?.command.executeListWithPreset(type, style, preset);
618
+ close();
616
619
  };
617
620
  const handleIndent = (e) => {
618
621
  e.stopPropagation();
619
622
  editorRef.current?.command.executeListIndent();
623
+ close();
620
624
  };
621
625
  const handleOutdent = (e) => {
622
626
  e.stopPropagation();
623
627
  editorRef.current?.command.executeListOutdent();
628
+ close();
624
629
  };
625
630
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: `menu-item__list ${isActive ? "active" : ""}`, title: `List(${isApple ? "\u2318" : "Ctrl"}+Shift+U)`, children: [
626
631
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react14.List, { size: 16, onClick: () => optionsRef.current?.classList.toggle("visible"), style: { cursor: "pointer" } }),
627
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: "8px", width: "320px" }, children: [
632
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "options", ref: optionsRef, style: { width: "320px" }, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { padding: "8px" }, children: [
628
633
  /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { style: { display: "flex", gap: "4px", marginBottom: "8px" }, children: [
629
634
  /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
630
635
  "button",
@@ -718,16 +723,18 @@ function SeparatorTool() {
718
723
  const optionsRef = (0, import_react13.useRef)(null);
719
724
  const [selectedWidth, setSelectedWidth] = (0, import_react13.useState)(1);
720
725
  const lineColor = "#344054";
721
- const handleSeparator = (dashArray) => {
726
+ const handleSeparator = (e, dashArray) => {
727
+ e.stopPropagation();
722
728
  editorRef.current?.command.executeSeparator(dashArray, { lineWidth: selectedWidth });
729
+ optionsRef.current?.classList.remove("visible");
723
730
  };
724
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "menu-item__separator", title: "Separator", children: [
725
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Minus, { size: 16, onClick: () => optionsRef.current?.classList.toggle("visible"), style: { cursor: "pointer" } }),
726
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: "8px 10px 10px", width: "200px" }, children: [
731
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "menu-item", title: "Separator", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "menu-item__separator", onClick: () => optionsRef.current?.classList.toggle("visible"), style: { display: "flex", alignItems: "center", justifyContent: "center", width: "28px", height: "28px", cursor: "pointer", margin: "0 2px", borderRadius: "8px", color: "#475467", transition: "all 0.2s", position: "relative" }, children: [
732
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react16.Minus, { size: 16 }),
733
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "options", ref: optionsRef, style: { width: "220px", height: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { style: { padding: "8px 10px 10px" }, children: [
727
734
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("ul", { style: { margin: 0, padding: 0, listStyle: "none" }, children: DASH_STYLES.map(({ label, dashArray }) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
728
735
  "li",
729
736
  {
730
- onClick: () => handleSeparator(dashArray),
737
+ onClick: (e) => handleSeparator(e, dashArray),
731
738
  style: { display: "flex", alignItems: "center", gap: "10px", padding: "5px 6px", cursor: "pointer", borderRadius: "4px" },
732
739
  children: [
733
740
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("svg", { style: { flex: 1, minWidth: 0, overflow: "hidden" }, height: "8", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
@@ -773,7 +780,7 @@ function SeparatorTool() {
773
780
  )) })
774
781
  ] })
775
782
  ] }) })
776
- ] });
783
+ ] }) });
777
784
  }
778
785
 
779
786
  // src/toolbar/WatermarkTool.tsx