@windoc/react 0.3.14 → 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 +68 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/styles/editor.css +5 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Editor.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect5, useRef as useRef19, useState as useState13 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/EditorContext.tsx
|
|
5
5
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
@@ -68,6 +68,9 @@ function useFooter() {
|
|
|
68
68
|
return ctx;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
// src/EditorToolbar.tsx
|
|
72
|
+
import { useEffect as useEffect3, useRef as useRef16 } from "react";
|
|
73
|
+
|
|
71
74
|
// src/toolbar/UndoTool.tsx
|
|
72
75
|
import { Undo } from "lucide-react";
|
|
73
76
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
@@ -418,7 +421,7 @@ function ColumnTool() {
|
|
|
418
421
|
editorRef.current?.command.executeColumnGap(clampedValue);
|
|
419
422
|
};
|
|
420
423
|
return /* @__PURE__ */ jsxs3("div", { className: "menu-item__select-group", children: [
|
|
421
|
-
/* @__PURE__ */ jsx7("div", { className: "menu-item__select-text", title: "Column Layout",
|
|
424
|
+
/* @__PURE__ */ jsx7("div", { className: "menu-item__select-text", title: "Column Layout", children: currentColumns === 1 ? "1 Column" : `${currentColumns} Columns` }),
|
|
422
425
|
/* @__PURE__ */ jsxs3("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
|
|
423
426
|
/* @__PURE__ */ jsx7(ChevronDown, { size: 10, strokeWidth: 2.5 }),
|
|
424
427
|
/* @__PURE__ */ jsx7("div", { className: "options", ref: optionsRef, style: { width: "130px" }, children: /* @__PURE__ */ jsxs3("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
@@ -525,7 +528,7 @@ function TitleTool() {
|
|
|
525
528
|
const toggle = () => optionsRef.current?.classList.toggle("visible");
|
|
526
529
|
const close = () => optionsRef.current?.classList.remove("visible");
|
|
527
530
|
return /* @__PURE__ */ jsxs5("div", { className: "menu-item__select-group", children: [
|
|
528
|
-
/* @__PURE__ */ jsx9("div", { className: "menu-item__select-text", title: "Toggle Heading",
|
|
531
|
+
/* @__PURE__ */ jsx9("div", { className: "menu-item__select-text", title: "Toggle Heading", children: activeLabel }),
|
|
529
532
|
/* @__PURE__ */ jsxs5("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
|
|
530
533
|
/* @__PURE__ */ jsx9(ChevronDown2, { size: 10, strokeWidth: 2.5 }),
|
|
531
534
|
/* @__PURE__ */ jsx9("div", { className: "options", ref: optionsRef, style: { width: "100px" }, children: /* @__PURE__ */ jsx9("ul", { children: LEVELS.map(({ level, label }) => /* @__PURE__ */ jsx9(
|
|
@@ -568,7 +571,7 @@ function FontTool() {
|
|
|
568
571
|
const toggle = () => optionsRef.current?.classList.toggle("visible");
|
|
569
572
|
const close = () => optionsRef.current?.classList.remove("visible");
|
|
570
573
|
return /* @__PURE__ */ jsxs6("div", { className: "menu-item__select-group", children: [
|
|
571
|
-
/* @__PURE__ */ jsx10("div", { className: "menu-item__select-text", title: "Font",
|
|
574
|
+
/* @__PURE__ */ jsx10("div", { className: "menu-item__select-text", title: "Font", children: activeLabel }),
|
|
572
575
|
/* @__PURE__ */ jsxs6("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
|
|
573
576
|
/* @__PURE__ */ jsx10(ChevronDown3, { size: 10, strokeWidth: 2.5 }),
|
|
574
577
|
/* @__PURE__ */ jsx10("div", { className: "options", ref: optionsRef, style: { width: "150px" }, children: /* @__PURE__ */ jsx10("ul", { children: FONTS.map(({ family, label }) => /* @__PURE__ */ jsx10(
|
|
@@ -602,7 +605,7 @@ function FontSizeTool() {
|
|
|
602
605
|
const toggle = () => optionsRef.current?.classList.toggle("visible");
|
|
603
606
|
const close = () => optionsRef.current?.classList.remove("visible");
|
|
604
607
|
return /* @__PURE__ */ jsxs7("div", { className: "menu-item__select-group", children: [
|
|
605
|
-
/* @__PURE__ */ jsx11("div", { className: "menu-item__select-text", title: "Font Size",
|
|
608
|
+
/* @__PURE__ */ jsx11("div", { className: "menu-item__select-text", title: "Font Size", children: activeSize }),
|
|
606
609
|
/* @__PURE__ */ jsxs7("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
|
|
607
610
|
/* @__PURE__ */ jsx11(ChevronDown4, { size: 10, strokeWidth: 2.5 }),
|
|
608
611
|
/* @__PURE__ */ jsx11("div", { className: "options", ref: optionsRef, style: { width: "60px" }, children: /* @__PURE__ */ jsx11("ul", { children: SIZES.map((size) => /* @__PURE__ */ jsx11(
|
|
@@ -635,7 +638,7 @@ function LineHeightTool() {
|
|
|
635
638
|
const toggle = () => optionsRef.current?.classList.toggle("visible");
|
|
636
639
|
const close = () => optionsRef.current?.classList.remove("visible");
|
|
637
640
|
return /* @__PURE__ */ jsxs8("div", { className: "menu-item__select-group", children: [
|
|
638
|
-
/* @__PURE__ */ jsx12("div", { className: "menu-item__select-text", title: "Line Height",
|
|
641
|
+
/* @__PURE__ */ jsx12("div", { className: "menu-item__select-text", title: "Line Height", children: activeLabel }),
|
|
639
642
|
/* @__PURE__ */ jsxs8("div", { className: "menu-item__select-arrow", onClick: toggle, children: [
|
|
640
643
|
/* @__PURE__ */ jsx12(ChevronDown5, { size: 10, strokeWidth: 2.5 }),
|
|
641
644
|
/* @__PURE__ */ jsx12("div", { className: "options", ref: optionsRef, style: { width: "60px" }, children: /* @__PURE__ */ jsx12("ul", { children: LINE_HEIGHTS.map((h) => /* @__PURE__ */ jsx12(
|
|
@@ -1535,7 +1538,32 @@ function PageBreakTool() {
|
|
|
1535
1538
|
import { Fragment as Fragment2, jsx as jsx28, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1536
1539
|
function EditorToolbar() {
|
|
1537
1540
|
const { isInTable } = useEditor();
|
|
1538
|
-
|
|
1541
|
+
const menuRef = useRef16(null);
|
|
1542
|
+
useEffect3(() => {
|
|
1543
|
+
const menu = menuRef.current;
|
|
1544
|
+
if (!menu) return;
|
|
1545
|
+
const observer = new MutationObserver((mutations) => {
|
|
1546
|
+
mutations.forEach((mutation) => {
|
|
1547
|
+
const target = mutation.target;
|
|
1548
|
+
if (!target.classList.contains("options")) return;
|
|
1549
|
+
if (!target.classList.contains("visible")) {
|
|
1550
|
+
target.style.left = "";
|
|
1551
|
+
target.style.right = "";
|
|
1552
|
+
return;
|
|
1553
|
+
}
|
|
1554
|
+
target.style.left = "0";
|
|
1555
|
+
target.style.right = "";
|
|
1556
|
+
const rect = target.getBoundingClientRect();
|
|
1557
|
+
if (rect.right > window.innerWidth) {
|
|
1558
|
+
target.style.left = "auto";
|
|
1559
|
+
target.style.right = "0";
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
});
|
|
1563
|
+
observer.observe(menu, { subtree: true, attributeFilter: ["class"] });
|
|
1564
|
+
return () => observer.disconnect();
|
|
1565
|
+
}, []);
|
|
1566
|
+
return /* @__PURE__ */ jsxs17("div", { className: "menu", "editor-component": "menu", ref: menuRef, children: [
|
|
1539
1567
|
/* @__PURE__ */ jsxs17("div", { className: "menu-item", children: [
|
|
1540
1568
|
/* @__PURE__ */ jsx28(UndoTool, {}),
|
|
1541
1569
|
/* @__PURE__ */ jsx28(RedoTool, {})
|
|
@@ -1656,7 +1684,7 @@ function FooterStatus() {
|
|
|
1656
1684
|
}
|
|
1657
1685
|
|
|
1658
1686
|
// src/footer/EditorModeTool.tsx
|
|
1659
|
-
import { useState as useState9, useRef as
|
|
1687
|
+
import { useState as useState9, useRef as useRef17 } from "react";
|
|
1660
1688
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
1661
1689
|
var MODE_LIST = [
|
|
1662
1690
|
{ mode: "edit", name: "Edit Mode" },
|
|
@@ -1670,7 +1698,7 @@ var MODE_LIST = [
|
|
|
1670
1698
|
function EditorModeTool() {
|
|
1671
1699
|
const { editorRef } = useEditor();
|
|
1672
1700
|
const [editorMode, setEditorMode] = useState9("Edit Mode");
|
|
1673
|
-
const modeIndexRef =
|
|
1701
|
+
const modeIndexRef = useRef17(0);
|
|
1674
1702
|
const handleModeChange = () => {
|
|
1675
1703
|
modeIndexRef.current = modeIndexRef.current === MODE_LIST.length - 1 ? 0 : modeIndexRef.current + 1;
|
|
1676
1704
|
const { name, mode } = MODE_LIST[modeIndexRef.current];
|
|
@@ -1931,7 +1959,7 @@ function EditorOptionTool() {
|
|
|
1931
1959
|
}
|
|
1932
1960
|
|
|
1933
1961
|
// src/footer/WatermarkFooterTool.tsx
|
|
1934
|
-
import { useState as useState12, useRef as
|
|
1962
|
+
import { useState as useState12, useRef as useRef18, useEffect as useEffect4, useCallback } from "react";
|
|
1935
1963
|
import { Fragment as Fragment4, jsx as jsx40, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1936
1964
|
var COLOR_PALETTE4 = [
|
|
1937
1965
|
["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc"],
|
|
@@ -1946,9 +1974,9 @@ function WatermarkFooterTool() {
|
|
|
1946
1974
|
const { editorRef } = useEditor();
|
|
1947
1975
|
const [visible, setVisible] = useState12(false);
|
|
1948
1976
|
const [tab, setTab] = useState12("text");
|
|
1949
|
-
const containerRef =
|
|
1950
|
-
const panelRef =
|
|
1951
|
-
const fileInputRef =
|
|
1977
|
+
const containerRef = useRef18(null);
|
|
1978
|
+
const panelRef = useRef18(null);
|
|
1979
|
+
const fileInputRef = useRef18(null);
|
|
1952
1980
|
const [text, setText] = useState12("WATERMARK");
|
|
1953
1981
|
const [font, setFont] = useState12("Arial");
|
|
1954
1982
|
const [color, setColor] = useState12("#AEB5C0");
|
|
@@ -1958,7 +1986,7 @@ function WatermarkFooterTool() {
|
|
|
1958
1986
|
const [imageData, setImageData] = useState12("");
|
|
1959
1987
|
const [imgWidth, setImgWidth] = useState12(200);
|
|
1960
1988
|
const [imgHeight, setImgHeight] = useState12(200);
|
|
1961
|
-
|
|
1989
|
+
useEffect4(() => {
|
|
1962
1990
|
if (!visible) return;
|
|
1963
1991
|
const handler = (e) => {
|
|
1964
1992
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -1968,7 +1996,7 @@ function WatermarkFooterTool() {
|
|
|
1968
1996
|
document.addEventListener("mousedown", handler);
|
|
1969
1997
|
return () => document.removeEventListener("mousedown", handler);
|
|
1970
1998
|
}, [visible]);
|
|
1971
|
-
|
|
1999
|
+
useEffect4(() => {
|
|
1972
2000
|
if (!visible || !panelRef.current) return;
|
|
1973
2001
|
const el = panelRef.current;
|
|
1974
2002
|
el.style.right = "";
|
|
@@ -2350,8 +2378,8 @@ function EditorInner({
|
|
|
2350
2378
|
style,
|
|
2351
2379
|
onDrop: userOnDrop
|
|
2352
2380
|
}) {
|
|
2353
|
-
const containerRef =
|
|
2354
|
-
const editorRef =
|
|
2381
|
+
const containerRef = useRef19(null);
|
|
2382
|
+
const editorRef = useRef19(null);
|
|
2355
2383
|
const [rangeStyle, setRangeStyle] = useState13(null);
|
|
2356
2384
|
const [isInTable, setIsInTable] = useState13(false);
|
|
2357
2385
|
const {
|
|
@@ -2363,7 +2391,7 @@ function EditorInner({
|
|
|
2363
2391
|
setColNo,
|
|
2364
2392
|
setPageScale
|
|
2365
2393
|
} = useFooter();
|
|
2366
|
-
|
|
2394
|
+
useEffect5(() => {
|
|
2367
2395
|
let instance = null;
|
|
2368
2396
|
let cancelled = false;
|
|
2369
2397
|
let closeDropdowns = null;
|
|
@@ -2383,7 +2411,7 @@ function EditorInner({
|
|
|
2383
2411
|
instance = new EditorClass(
|
|
2384
2412
|
containerRef.current,
|
|
2385
2413
|
data,
|
|
2386
|
-
userOptions
|
|
2414
|
+
{ maskMargin: [24, 0, 24, 0], ...userOptions }
|
|
2387
2415
|
);
|
|
2388
2416
|
editorRef.current = instance;
|
|
2389
2417
|
instance.listener.rangeStyleChange = (payload) => {
|