@windoc/react 0.3.17 → 0.3.18

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
@@ -38,6 +38,9 @@ function FooterProvider({
38
38
  const [rowNo, setRowNo] = useState2(0);
39
39
  const [colNo, setColNo] = useState2(0);
40
40
  const [pageScale, setPageScale] = useState2(100);
41
+ const [paperDirection, setPaperDirection] = useState2("vertical");
42
+ const [paperWidth, setPaperWidth] = useState2(794);
43
+ const [paperHeight, setPaperHeight] = useState2(1123);
41
44
  return /* @__PURE__ */ jsx2(
42
45
  FooterContext.Provider,
43
46
  {
@@ -49,6 +52,9 @@ function FooterProvider({
49
52
  rowNo,
50
53
  colNo,
51
54
  pageScale,
55
+ paperDirection,
56
+ paperWidth,
57
+ paperHeight,
52
58
  setPageNoList,
53
59
  setPageNo,
54
60
  setPageSize,
@@ -56,6 +62,9 @@ function FooterProvider({
56
62
  setRowNo,
57
63
  setColNo,
58
64
  setPageScale,
65
+ setPaperDirection,
66
+ setPaperWidth,
67
+ setPaperHeight,
59
68
  handleToggleCatalogAction
60
69
  },
61
70
  children
@@ -1779,25 +1788,28 @@ function PageScaleAddTool() {
1779
1788
  import { useState as useState10 } from "react";
1780
1789
  import { jsx as jsx35, jsxs as jsxs21 } from "react/jsx-runtime";
1781
1790
  var SIZES2 = [
1782
- { label: "A4", width: 794, height: 1123, active: true },
1791
+ { label: "A4", width: 794, height: 1123 },
1783
1792
  { label: "A2", width: 1593, height: 2251 },
1784
1793
  { label: "A3", width: 1125, height: 1593 },
1785
1794
  { label: "A5", width: 565, height: 796 }
1786
1795
  ];
1787
1796
  function PaperSizeTool() {
1788
1797
  const { editorRef } = useEditor();
1798
+ const { paperWidth, paperHeight, setPaperWidth, setPaperHeight } = useFooter();
1789
1799
  const [visible, setVisible] = useState10(false);
1790
1800
  const handlePaperSize = (width, height) => {
1791
1801
  editorRef.current?.command.executePaperSize(width, height);
1802
+ setPaperWidth(width);
1803
+ setPaperHeight(height);
1792
1804
  setVisible(false);
1793
1805
  };
1794
1806
  return /* @__PURE__ */ jsxs21("div", { className: "paper-size", onClick: () => setVisible(!visible), children: [
1795
1807
  /* @__PURE__ */ jsx35("i", { title: "Paper Type" }),
1796
- /* @__PURE__ */ jsx35("div", { className: `options ${visible ? "visible" : ""}`, children: /* @__PURE__ */ jsx35("ul", { children: SIZES2.map(({ label, width, height, active }) => /* @__PURE__ */ jsx35(
1808
+ /* @__PURE__ */ jsx35("div", { className: `options ${visible ? "visible" : ""}`, children: /* @__PURE__ */ jsx35("ul", { children: SIZES2.map(({ label, width, height }) => /* @__PURE__ */ jsx35(
1797
1809
  "li",
1798
1810
  {
1799
1811
  onClick: () => handlePaperSize(width, height),
1800
- className: active ? "active" : "",
1812
+ className: paperWidth === width && paperHeight === height ? "active" : "",
1801
1813
  children: label
1802
1814
  },
1803
1815
  label
@@ -1810,9 +1822,11 @@ import { useState as useState11 } from "react";
1810
1822
  import { jsx as jsx36, jsxs as jsxs22 } from "react/jsx-runtime";
1811
1823
  function PaperDirectionTool() {
1812
1824
  const { editorRef } = useEditor();
1825
+ const { paperDirection, setPaperDirection } = useFooter();
1813
1826
  const [visible, setVisible] = useState11(false);
1814
1827
  const handlePaperDirection = (direction) => {
1815
1828
  editorRef.current?.command.executePaperDirection(direction);
1829
+ setPaperDirection(direction);
1816
1830
  setVisible(false);
1817
1831
  };
1818
1832
  return /* @__PURE__ */ jsxs22("div", { className: "paper-direction", onClick: () => setVisible(!visible), children: [
@@ -1822,11 +1836,18 @@ function PaperDirectionTool() {
1822
1836
  "li",
1823
1837
  {
1824
1838
  onClick: () => handlePaperDirection("vertical"),
1825
- className: "active",
1839
+ className: paperDirection === "vertical" ? "active" : "",
1826
1840
  children: "Portrait"
1827
1841
  }
1828
1842
  ),
1829
- /* @__PURE__ */ jsx36("li", { onClick: () => handlePaperDirection("horizontal"), children: "Landscape" })
1843
+ /* @__PURE__ */ jsx36(
1844
+ "li",
1845
+ {
1846
+ onClick: () => handlePaperDirection("horizontal"),
1847
+ className: paperDirection === "horizontal" ? "active" : "",
1848
+ children: "Landscape"
1849
+ }
1850
+ )
1830
1851
  ] }) })
1831
1852
  ] });
1832
1853
  }
@@ -2389,7 +2410,10 @@ function EditorInner({
2389
2410
  setWordCount,
2390
2411
  setRowNo,
2391
2412
  setColNo,
2392
- setPageScale
2413
+ setPageScale,
2414
+ setPaperDirection,
2415
+ setPaperWidth,
2416
+ setPaperHeight
2393
2417
  } = useFooter();
2394
2418
  useEffect5(() => {
2395
2419
  let instance = null;
@@ -2414,8 +2438,11 @@ function EditorInner({
2414
2438
  { maskMargin: [24, 0, 24, 0], ...userOptions }
2415
2439
  );
2416
2440
  editorRef.current = instance;
2417
- const initialScale = userOptions?.scale ?? 1;
2418
- setPageScale(Math.round(initialScale * 100));
2441
+ const opts = instance.command.getOptions();
2442
+ setPageScale(Math.round(opts.scale * 100));
2443
+ setPaperDirection(opts.paperDirection);
2444
+ setPaperWidth(opts.width);
2445
+ setPaperHeight(opts.height);
2419
2446
  instance.listener.rangeStyleChange = (payload) => {
2420
2447
  setRangeStyle(payload);
2421
2448
  onRangeStyleChange?.(payload);