@windoc/react 0.3.15 → 0.3.16

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
@@ -79,7 +79,7 @@ __export(index_exports, {
79
79
  module.exports = __toCommonJS(index_exports);
80
80
 
81
81
  // src/Editor.tsx
82
- var import_react23 = require("react");
82
+ var import_react24 = require("react");
83
83
 
84
84
  // src/EditorContext.tsx
85
85
  var import_react = require("react");
@@ -148,6 +148,9 @@ function useFooter() {
148
148
  return ctx;
149
149
  }
150
150
 
151
+ // src/EditorToolbar.tsx
152
+ var import_react18 = require("react");
153
+
151
154
  // src/toolbar/UndoTool.tsx
152
155
  var import_lucide_react = require("lucide-react");
153
156
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -498,7 +501,7 @@ function ColumnTool() {
498
501
  editorRef.current?.command.executeColumnGap(clampedValue);
499
502
  };
500
503
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "menu-item__select-group", children: [
501
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "menu-item__select-text", title: "Column Layout", onClick: toggle, children: currentColumns === 1 ? "1 Column" : `${currentColumns} Columns` }),
504
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "menu-item__select-text", title: "Column Layout", children: currentColumns === 1 ? "1 Column" : `${currentColumns} Columns` }),
502
505
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
503
506
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_lucide_react5.ChevronDown, { size: 10, strokeWidth: 2.5 }),
504
507
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "options", ref: optionsRef, style: { width: "130px" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { onClick: (e) => e.stopPropagation(), children: [
@@ -605,7 +608,7 @@ function TitleTool() {
605
608
  const toggle = () => optionsRef.current?.classList.toggle("visible");
606
609
  const close = () => optionsRef.current?.classList.remove("visible");
607
610
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "menu-item__select-group", children: [
608
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "menu-item__select-text", title: "Toggle Heading", onClick: toggle, children: activeLabel }),
611
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "menu-item__select-text", title: "Toggle Heading", children: activeLabel }),
609
612
  /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
610
613
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react7.ChevronDown, { size: 10, strokeWidth: 2.5 }),
611
614
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "options", ref: optionsRef, style: { width: "100px" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: LEVELS.map(({ level, label }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
@@ -648,7 +651,7 @@ function FontTool() {
648
651
  const toggle = () => optionsRef.current?.classList.toggle("visible");
649
652
  const close = () => optionsRef.current?.classList.remove("visible");
650
653
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "menu-item__select-group", children: [
651
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "menu-item__select-text", title: "Font", onClick: toggle, children: activeLabel }),
654
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "menu-item__select-text", title: "Font", children: activeLabel }),
652
655
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
653
656
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react8.ChevronDown, { size: 10, strokeWidth: 2.5 }),
654
657
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "options", ref: optionsRef, style: { width: "150px" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { children: FONTS.map(({ family, label }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -682,7 +685,7 @@ function FontSizeTool() {
682
685
  const toggle = () => optionsRef.current?.classList.toggle("visible");
683
686
  const close = () => optionsRef.current?.classList.remove("visible");
684
687
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "menu-item__select-group", children: [
685
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "menu-item__select-text", title: "Font Size", onClick: toggle, children: activeSize }),
688
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "menu-item__select-text", title: "Font Size", children: activeSize }),
686
689
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
687
690
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react9.ChevronDown, { size: 10, strokeWidth: 2.5 }),
688
691
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "options", ref: optionsRef, style: { width: "60px" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("ul", { children: SIZES.map((size) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -715,7 +718,7 @@ function LineHeightTool() {
715
718
  const toggle = () => optionsRef.current?.classList.toggle("visible");
716
719
  const close = () => optionsRef.current?.classList.remove("visible");
717
720
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "menu-item__select-group", children: [
718
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "menu-item__select-text", title: "Line Height", onClick: toggle, children: activeLabel }),
721
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "menu-item__select-text", title: "Line Height", children: activeLabel }),
719
722
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
720
723
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_lucide_react10.ChevronDown, { size: 10, strokeWidth: 2.5 }),
721
724
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "options", ref: optionsRef, style: { width: "60px" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { children: LINE_HEIGHTS.map((h) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -1615,7 +1618,32 @@ function PageBreakTool() {
1615
1618
  var import_jsx_runtime28 = require("react/jsx-runtime");
1616
1619
  function EditorToolbar() {
1617
1620
  const { isInTable } = useEditor();
1618
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "menu", "editor-component": "menu", children: [
1621
+ const menuRef = (0, import_react18.useRef)(null);
1622
+ (0, import_react18.useEffect)(() => {
1623
+ const menu = menuRef.current;
1624
+ if (!menu) return;
1625
+ const observer = new MutationObserver((mutations) => {
1626
+ mutations.forEach((mutation) => {
1627
+ const target = mutation.target;
1628
+ if (!target.classList.contains("options")) return;
1629
+ if (!target.classList.contains("visible")) {
1630
+ target.style.left = "";
1631
+ target.style.right = "";
1632
+ return;
1633
+ }
1634
+ target.style.left = "0";
1635
+ target.style.right = "";
1636
+ const rect = target.getBoundingClientRect();
1637
+ if (rect.right > window.innerWidth) {
1638
+ target.style.left = "auto";
1639
+ target.style.right = "0";
1640
+ }
1641
+ });
1642
+ });
1643
+ observer.observe(menu, { subtree: true, attributeFilter: ["class"] });
1644
+ return () => observer.disconnect();
1645
+ }, []);
1646
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "menu", "editor-component": "menu", ref: menuRef, children: [
1619
1647
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "menu-item", children: [
1620
1648
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(UndoTool, {}),
1621
1649
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RedoTool, {})
@@ -1683,11 +1711,11 @@ function CatalogToggleTool() {
1683
1711
  }
1684
1712
 
1685
1713
  // src/footer/PageModeTool.tsx
1686
- var import_react18 = require("react");
1714
+ var import_react19 = require("react");
1687
1715
  var import_jsx_runtime30 = require("react/jsx-runtime");
1688
1716
  function PageModeTool() {
1689
1717
  const { editorRef } = useEditor();
1690
- const [visible, setVisible] = (0, import_react18.useState)(false);
1718
+ const [visible, setVisible] = (0, import_react19.useState)(false);
1691
1719
  const handlePageMode = (mode) => {
1692
1720
  editorRef.current?.command.executePageMode(mode);
1693
1721
  setVisible(false);
@@ -1736,7 +1764,7 @@ function FooterStatus() {
1736
1764
  }
1737
1765
 
1738
1766
  // src/footer/EditorModeTool.tsx
1739
- var import_react19 = require("react");
1767
+ var import_react20 = require("react");
1740
1768
  var import_jsx_runtime32 = require("react/jsx-runtime");
1741
1769
  var MODE_LIST = [
1742
1770
  { mode: "edit", name: "Edit Mode" },
@@ -1749,8 +1777,8 @@ var MODE_LIST = [
1749
1777
  ];
1750
1778
  function EditorModeTool() {
1751
1779
  const { editorRef } = useEditor();
1752
- const [editorMode, setEditorMode] = (0, import_react19.useState)("Edit Mode");
1753
- const modeIndexRef = (0, import_react19.useRef)(0);
1780
+ const [editorMode, setEditorMode] = (0, import_react20.useState)("Edit Mode");
1781
+ const modeIndexRef = (0, import_react20.useRef)(0);
1754
1782
  const handleModeChange = () => {
1755
1783
  modeIndexRef.current = modeIndexRef.current === MODE_LIST.length - 1 ? 0 : modeIndexRef.current + 1;
1756
1784
  const { name, mode } = MODE_LIST[modeIndexRef.current];
@@ -1828,7 +1856,7 @@ function PageScaleAddTool() {
1828
1856
  }
1829
1857
 
1830
1858
  // src/footer/PaperSizeTool.tsx
1831
- var import_react20 = require("react");
1859
+ var import_react21 = require("react");
1832
1860
  var import_jsx_runtime36 = require("react/jsx-runtime");
1833
1861
  var SIZES2 = [
1834
1862
  { label: "A4", width: 794, height: 1123, active: true },
@@ -1838,7 +1866,7 @@ var SIZES2 = [
1838
1866
  ];
1839
1867
  function PaperSizeTool() {
1840
1868
  const { editorRef } = useEditor();
1841
- const [visible, setVisible] = (0, import_react20.useState)(false);
1869
+ const [visible, setVisible] = (0, import_react21.useState)(false);
1842
1870
  const handlePaperSize = (width, height) => {
1843
1871
  editorRef.current?.command.executePaperSize(width, height);
1844
1872
  setVisible(false);
@@ -1858,11 +1886,11 @@ function PaperSizeTool() {
1858
1886
  }
1859
1887
 
1860
1888
  // src/footer/PaperDirectionTool.tsx
1861
- var import_react21 = require("react");
1889
+ var import_react22 = require("react");
1862
1890
  var import_jsx_runtime37 = require("react/jsx-runtime");
1863
1891
  function PaperDirectionTool() {
1864
1892
  const { editorRef } = useEditor();
1865
- const [visible, setVisible] = (0, import_react21.useState)(false);
1893
+ const [visible, setVisible] = (0, import_react22.useState)(false);
1866
1894
  const handlePaperDirection = (direction) => {
1867
1895
  editorRef.current?.command.executePaperDirection(direction);
1868
1896
  setVisible(false);
@@ -2011,7 +2039,7 @@ function EditorOptionTool() {
2011
2039
  }
2012
2040
 
2013
2041
  // src/footer/WatermarkFooterTool.tsx
2014
- var import_react22 = require("react");
2042
+ var import_react23 = require("react");
2015
2043
  var import_jsx_runtime41 = require("react/jsx-runtime");
2016
2044
  var COLOR_PALETTE4 = [
2017
2045
  ["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc"],
@@ -2024,21 +2052,21 @@ var FONTS2 = [
2024
2052
  ];
2025
2053
  function WatermarkFooterTool() {
2026
2054
  const { editorRef } = useEditor();
2027
- const [visible, setVisible] = (0, import_react22.useState)(false);
2028
- const [tab, setTab] = (0, import_react22.useState)("text");
2029
- const containerRef = (0, import_react22.useRef)(null);
2030
- const panelRef = (0, import_react22.useRef)(null);
2031
- const fileInputRef = (0, import_react22.useRef)(null);
2032
- const [text, setText] = (0, import_react22.useState)("WATERMARK");
2033
- const [font, setFont] = (0, import_react22.useState)("Arial");
2034
- const [color, setColor] = (0, import_react22.useState)("#AEB5C0");
2035
- const [opacity, setOpacity] = (0, import_react22.useState)(30);
2036
- const [rotation, setRotation] = (0, import_react22.useState)(-45);
2037
- const [inFront, setInFront] = (0, import_react22.useState)(false);
2038
- const [imageData, setImageData] = (0, import_react22.useState)("");
2039
- const [imgWidth, setImgWidth] = (0, import_react22.useState)(200);
2040
- const [imgHeight, setImgHeight] = (0, import_react22.useState)(200);
2041
- (0, import_react22.useEffect)(() => {
2055
+ const [visible, setVisible] = (0, import_react23.useState)(false);
2056
+ const [tab, setTab] = (0, import_react23.useState)("text");
2057
+ const containerRef = (0, import_react23.useRef)(null);
2058
+ const panelRef = (0, import_react23.useRef)(null);
2059
+ const fileInputRef = (0, import_react23.useRef)(null);
2060
+ const [text, setText] = (0, import_react23.useState)("WATERMARK");
2061
+ const [font, setFont] = (0, import_react23.useState)("Arial");
2062
+ const [color, setColor] = (0, import_react23.useState)("#AEB5C0");
2063
+ const [opacity, setOpacity] = (0, import_react23.useState)(30);
2064
+ const [rotation, setRotation] = (0, import_react23.useState)(-45);
2065
+ const [inFront, setInFront] = (0, import_react23.useState)(false);
2066
+ const [imageData, setImageData] = (0, import_react23.useState)("");
2067
+ const [imgWidth, setImgWidth] = (0, import_react23.useState)(200);
2068
+ const [imgHeight, setImgHeight] = (0, import_react23.useState)(200);
2069
+ (0, import_react23.useEffect)(() => {
2042
2070
  if (!visible) return;
2043
2071
  const handler = (e) => {
2044
2072
  if (containerRef.current && !containerRef.current.contains(e.target)) {
@@ -2048,7 +2076,7 @@ function WatermarkFooterTool() {
2048
2076
  document.addEventListener("mousedown", handler);
2049
2077
  return () => document.removeEventListener("mousedown", handler);
2050
2078
  }, [visible]);
2051
- (0, import_react22.useEffect)(() => {
2079
+ (0, import_react23.useEffect)(() => {
2052
2080
  if (!visible || !panelRef.current) return;
2053
2081
  const el = panelRef.current;
2054
2082
  el.style.right = "";
@@ -2062,7 +2090,7 @@ function WatermarkFooterTool() {
2062
2090
  el.style.left = `${-rect.left + 4}px`;
2063
2091
  }
2064
2092
  }, [visible]);
2065
- const handleFileUpload = (0, import_react22.useCallback)(
2093
+ const handleFileUpload = (0, import_react23.useCallback)(
2066
2094
  (e) => {
2067
2095
  const file = e.target.files?.[0];
2068
2096
  if (!file) return;
@@ -2430,10 +2458,10 @@ function EditorInner({
2430
2458
  style,
2431
2459
  onDrop: userOnDrop
2432
2460
  }) {
2433
- const containerRef = (0, import_react23.useRef)(null);
2434
- const editorRef = (0, import_react23.useRef)(null);
2435
- const [rangeStyle, setRangeStyle] = (0, import_react23.useState)(null);
2436
- const [isInTable, setIsInTable] = (0, import_react23.useState)(false);
2461
+ const containerRef = (0, import_react24.useRef)(null);
2462
+ const editorRef = (0, import_react24.useRef)(null);
2463
+ const [rangeStyle, setRangeStyle] = (0, import_react24.useState)(null);
2464
+ const [isInTable, setIsInTable] = (0, import_react24.useState)(false);
2437
2465
  const {
2438
2466
  setPageNoList,
2439
2467
  setPageNo,
@@ -2443,7 +2471,7 @@ function EditorInner({
2443
2471
  setColNo,
2444
2472
  setPageScale
2445
2473
  } = useFooter();
2446
- (0, import_react23.useEffect)(() => {
2474
+ (0, import_react24.useEffect)(() => {
2447
2475
  let instance = null;
2448
2476
  let cancelled = false;
2449
2477
  let closeDropdowns = null;
@@ -2463,7 +2491,7 @@ function EditorInner({
2463
2491
  instance = new EditorClass(
2464
2492
  containerRef.current,
2465
2493
  data,
2466
- userOptions ?? {}
2494
+ { maskMargin: [24, 0, 24, 0], ...userOptions }
2467
2495
  );
2468
2496
  editorRef.current = instance;
2469
2497
  instance.listener.rangeStyleChange = (payload) => {