@windoc/react 0.2.2 → 0.2.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.mjs CHANGED
@@ -139,10 +139,10 @@ function useDropdown() {
139
139
  // src/utils/DropdownPortal.tsx
140
140
  import { createPortal } from "react-dom";
141
141
  import { jsx as jsx5 } from "react/jsx-runtime";
142
- function DropdownPortal({ isOpen, style, className, children }) {
142
+ function DropdownPortal({ isOpen, style, className, wrapperClassName, children }) {
143
143
  if (!isOpen) return null;
144
144
  return createPortal(
145
- /* @__PURE__ */ jsx5("div", { className: "menu-item", style, children: /* @__PURE__ */ jsx5("div", { className, children }) }),
145
+ /* @__PURE__ */ jsx5("div", { className: `menu-item menu-item-portal${wrapperClassName ? ` ${wrapperClassName}` : ""}`, style, children: /* @__PURE__ */ jsx5("div", { className, children }) }),
146
146
  document.body
147
147
  );
148
148
  }
@@ -165,7 +165,7 @@ function ColumnTool() {
165
165
  };
166
166
  return /* @__PURE__ */ jsxs("div", { className: "menu-item__column", ref: triggerRef, onClick: toggle, children: [
167
167
  /* @__PURE__ */ jsx6("span", { className: "select", title: "Column Layout", children: currentColumns === 1 ? "1 Column" : `${currentColumns} Columns` }),
168
- /* @__PURE__ */ jsx6(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsxs("div", { onClick: (e) => e.stopPropagation(), children: [
168
+ /* @__PURE__ */ jsx6(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__column", children: /* @__PURE__ */ jsxs("div", { onClick: (e) => e.stopPropagation(), children: [
169
169
  /* @__PURE__ */ jsxs("ul", { children: [
170
170
  /* @__PURE__ */ jsx6("li", { onClick: () => handleColumn(1), children: "1 Column" }),
171
171
  /* @__PURE__ */ jsx6("li", { onClick: () => handleColumn(2), children: "2 Columns" })
@@ -261,7 +261,7 @@ function TitleTool() {
261
261
  };
262
262
  return /* @__PURE__ */ jsxs3("div", { className: "menu-item__title", ref: triggerRef, onClick: toggle, children: [
263
263
  /* @__PURE__ */ jsx8("span", { className: "select", title: "Toggle Heading", children: activeLabel }),
264
- /* @__PURE__ */ jsx8(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx8("ul", { children: LEVELS.map(({ level, label }) => /* @__PURE__ */ jsx8(
264
+ /* @__PURE__ */ jsx8(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__title", children: /* @__PURE__ */ jsx8("ul", { children: LEVELS.map(({ level, label }) => /* @__PURE__ */ jsx8(
265
265
  "li",
266
266
  {
267
267
  className: activeLevel === level ? "active" : "",
@@ -290,7 +290,7 @@ function FontTool() {
290
290
  };
291
291
  return /* @__PURE__ */ jsxs4("div", { className: "menu-item__font", ref: triggerRef, onClick: toggle, children: [
292
292
  /* @__PURE__ */ jsx9("span", { className: "select", title: "Font", children: activeLabel }),
293
- /* @__PURE__ */ jsx9(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx9("ul", { children: FONTS.map(({ family, label }) => /* @__PURE__ */ jsx9(
293
+ /* @__PURE__ */ jsx9(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__font", children: /* @__PURE__ */ jsx9("ul", { children: FONTS.map(({ family, label }) => /* @__PURE__ */ jsx9(
294
294
  "li",
295
295
  {
296
296
  "data-family": family,
@@ -316,7 +316,7 @@ function FontSizeTool() {
316
316
  };
317
317
  return /* @__PURE__ */ jsxs5("div", { className: "menu-item__size", ref: triggerRef, onClick: toggle, children: [
318
318
  /* @__PURE__ */ jsx10("span", { className: "select", title: "Font Size", children: activeSize }),
319
- /* @__PURE__ */ jsx10(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx10("ul", { children: SIZES.map((size) => /* @__PURE__ */ jsx10(
319
+ /* @__PURE__ */ jsx10(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__size", children: /* @__PURE__ */ jsx10("ul", { children: SIZES.map((size) => /* @__PURE__ */ jsx10(
320
320
  "li",
321
321
  {
322
322
  className: activeSize === size ? "active" : "",
@@ -341,7 +341,7 @@ function LineHeightTool() {
341
341
  };
342
342
  return /* @__PURE__ */ jsxs6("div", { className: "menu-item__line-height", ref: triggerRef, onClick: toggle, children: [
343
343
  /* @__PURE__ */ jsx11("span", { className: "select", title: "Line Height", children: activeLabel }),
344
- /* @__PURE__ */ jsx11(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx11("ul", { children: LINE_HEIGHTS.map((h) => /* @__PURE__ */ jsx11(
344
+ /* @__PURE__ */ jsx11(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__line-height", children: /* @__PURE__ */ jsx11("ul", { children: LINE_HEIGHTS.map((h) => /* @__PURE__ */ jsx11(
345
345
  "li",
346
346
  {
347
347
  className: String(activeMargin) === h || activeLabel === h ? "active" : "",
@@ -380,7 +380,7 @@ function ColorTool() {
380
380
  /* @__PURE__ */ jsx12(Baseline, { size: 16 }),
381
381
  /* @__PURE__ */ jsx12("span", { style: { backgroundColor: activeColor } }),
382
382
  /* @__PURE__ */ jsx12("input", { id: "color", type: "color", readOnly: true, tabIndex: -1 }),
383
- /* @__PURE__ */ jsx12(DropdownPortal, { isOpen: visible, style: portalStyle, className: "color-palette-dropdown", children: /* @__PURE__ */ jsxs7("div", { onClick: (e) => e.stopPropagation(), children: [
383
+ /* @__PURE__ */ jsx12(DropdownPortal, { isOpen: visible, style: portalStyle, className: "color-palette-dropdown", wrapperClassName: "menu-item__color", children: /* @__PURE__ */ jsxs7("div", { onClick: (e) => e.stopPropagation(), children: [
384
384
  /* @__PURE__ */ jsxs7("button", { className: "color-palette-reset", onClick: handleReset, children: [
385
385
  /* @__PURE__ */ jsx12(RotateCcw, { size: 12 }),
386
386
  "Reset"
@@ -426,7 +426,7 @@ function HighlightTool() {
426
426
  /* @__PURE__ */ jsx13(Highlighter, { size: 16 }),
427
427
  /* @__PURE__ */ jsx13("span", { style: { backgroundColor: activeColor || "#ffff00" } }),
428
428
  /* @__PURE__ */ jsx13("input", { id: "highlight", type: "color", readOnly: true, tabIndex: -1 }),
429
- /* @__PURE__ */ jsx13(DropdownPortal, { isOpen: visible, style: portalStyle, className: "color-palette-dropdown", children: /* @__PURE__ */ jsxs8("div", { onClick: (e) => e.stopPropagation(), children: [
429
+ /* @__PURE__ */ jsx13(DropdownPortal, { isOpen: visible, style: portalStyle, className: "color-palette-dropdown", wrapperClassName: "menu-item__highlight", children: /* @__PURE__ */ jsxs8("div", { onClick: (e) => e.stopPropagation(), children: [
430
430
  /* @__PURE__ */ jsxs8("button", { className: "color-palette-reset", onClick: handleReset, children: [
431
431
  /* @__PURE__ */ jsx13(RotateCcw2, { size: 12 }),
432
432
  "None"
@@ -474,7 +474,7 @@ function UnderlineTool() {
474
474
  return /* @__PURE__ */ jsxs9("div", { className: `menu-item__underline ${isActive ? "active" : ""}`, ref: triggerRef, title: `Underline(${isApple ? "\u2318" : "Ctrl"}+U)`, children: [
475
475
  /* @__PURE__ */ jsx16(UnderlineIcon, { size: 16, onClick: () => editorRef.current?.command.executeUnderline(), style: { cursor: "pointer" } }),
476
476
  /* @__PURE__ */ jsx16("span", { className: "select", onClick: toggle }),
477
- /* @__PURE__ */ jsx16(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx16("ul", { children: STYLES.map((style) => /* @__PURE__ */ jsx16("li", { "data-decoration-style": style, onClick: () => {
477
+ /* @__PURE__ */ jsx16(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__underline", children: /* @__PURE__ */ jsx16("ul", { children: STYLES.map((style) => /* @__PURE__ */ jsx16("li", { "data-decoration-style": style, onClick: () => {
478
478
  editorRef.current?.command.executeUnderline({ style });
479
479
  }, children: /* @__PURE__ */ jsx16("i", {}) }, style)) }) })
480
480
  ] });
@@ -579,7 +579,7 @@ function ListTool() {
579
579
  };
580
580
  return /* @__PURE__ */ jsxs10("div", { ref: triggerRef, className: `menu-item__list ${isActive ? "active" : ""}`, title: `List(${isApple ? "\u2318" : "Ctrl"}+Shift+U)`, children: [
581
581
  /* @__PURE__ */ jsx22(List, { size: 16, onClick: toggle, style: { cursor: "pointer" } }),
582
- /* @__PURE__ */ jsx22(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsxs10("div", { style: { padding: "8px", width: "320px" }, children: [
582
+ /* @__PURE__ */ jsx22(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__list", children: /* @__PURE__ */ jsxs10("div", { style: { padding: "8px", width: "320px" }, children: [
583
583
  /* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: "4px", marginBottom: "8px" }, children: [
584
584
  /* @__PURE__ */ jsx22(
585
585
  "button",
@@ -678,7 +678,7 @@ function SeparatorTool() {
678
678
  };
679
679
  return /* @__PURE__ */ jsxs12("div", { className: "menu-item__separator", ref: triggerRef, title: "Separator", children: [
680
680
  /* @__PURE__ */ jsx24(Minus, { size: 16, onClick: toggle, style: { cursor: "pointer" } }),
681
- /* @__PURE__ */ jsx24(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsxs12("div", { style: { padding: "8px 10px 10px", width: "200px" }, children: [
681
+ /* @__PURE__ */ jsx24(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__separator", children: /* @__PURE__ */ jsxs12("div", { style: { padding: "8px 10px 10px", width: "200px" }, children: [
682
682
  /* @__PURE__ */ jsx24("ul", { style: { margin: 0, padding: 0, listStyle: "none" }, children: DASH_STYLES.map(({ label, dashArray }) => /* @__PURE__ */ jsxs12(
683
683
  "li",
684
684
  {
@@ -747,7 +747,7 @@ function InsertElementTool() {
747
747
  };
748
748
  return /* @__PURE__ */ jsxs13("div", { className: "menu-item__insert-element", ref: triggerRef, onClick: toggle, children: [
749
749
  /* @__PURE__ */ jsx25("i", { title: "Insert Element" }),
750
- /* @__PURE__ */ jsx25(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsx25("ul", { children: /* @__PURE__ */ jsx25("li", { onClick: handleHeader, children: "Add Header" }) }) })
750
+ /* @__PURE__ */ jsx25(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__insert-element", children: /* @__PURE__ */ jsx25("ul", { children: /* @__PURE__ */ jsx25("li", { onClick: handleHeader, children: "Add Header" }) }) })
751
751
  ] });
752
752
  }
753
753
 
@@ -770,7 +770,7 @@ function PageBreakTool() {
770
770
  onClick: toggle,
771
771
  children: [
772
772
  /* @__PURE__ */ jsx26("i", { title: "Break" }),
773
- /* @__PURE__ */ jsx26(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", children: /* @__PURE__ */ jsxs14("ul", { children: [
773
+ /* @__PURE__ */ jsx26(DropdownPortal, { isOpen, style: portalStyle, className: "options visible", wrapperClassName: "menu-item__page-break", children: /* @__PURE__ */ jsxs14("ul", { children: [
774
774
  /* @__PURE__ */ jsx26("li", { onClick: handlePageBreak, children: "Page Break" }),
775
775
  /* @__PURE__ */ jsx26("li", { onClick: handleColumnBreak, children: "Column Break" })
776
776
  ] }) })