@windoc/react 0.2.6 → 0.2.7
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 +36 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/Editor.tsx
|
|
2
|
-
import { useEffect as useEffect4, useRef as
|
|
2
|
+
import { useEffect as useEffect4, useRef as useRef16, useState as useState11 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/EditorContext.tsx
|
|
5
5
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
@@ -100,11 +100,11 @@ function RedoTool() {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// src/toolbar/ColumnTool.tsx
|
|
103
|
-
import { useState as useState3 } from "react";
|
|
103
|
+
import { useRef, useState as useState3 } from "react";
|
|
104
104
|
import { Fragment, jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
105
105
|
function ColumnTool() {
|
|
106
106
|
const { editorRef } = useEditor();
|
|
107
|
-
const
|
|
107
|
+
const optionsRef = useRef(null);
|
|
108
108
|
const [currentColumns, setCurrentColumns] = useState3(1);
|
|
109
109
|
const [gap, setGap] = useState3(20);
|
|
110
110
|
const handleColumn = (col) => {
|
|
@@ -116,9 +116,9 @@ function ColumnTool() {
|
|
|
116
116
|
setGap(clampedValue);
|
|
117
117
|
editorRef.current?.command.executeColumnGap(clampedValue);
|
|
118
118
|
};
|
|
119
|
-
return /* @__PURE__ */ jsxs("div", { className: "menu-item__column", onClick: () =>
|
|
119
|
+
return /* @__PURE__ */ jsxs("div", { className: "menu-item__column", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
120
120
|
/* @__PURE__ */ jsx5("span", { className: "select", title: "Column Layout", children: currentColumns === 1 ? "1 Column" : `${currentColumns} Columns` }),
|
|
121
|
-
/* @__PURE__ */ jsx5("div", { className: "options"
|
|
121
|
+
/* @__PURE__ */ jsx5("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsxs("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
122
122
|
/* @__PURE__ */ jsxs("ul", { children: [
|
|
123
123
|
/* @__PURE__ */ jsx5("li", { onClick: () => handleColumn(1), children: "1 Column" }),
|
|
124
124
|
/* @__PURE__ */ jsx5("li", { onClick: () => handleColumn(2), children: "2 Columns" })
|
|
@@ -145,7 +145,7 @@ function ColumnTool() {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// src/toolbar/TableTool.tsx
|
|
148
|
-
import { useState as useState4, useEffect as useEffect2, useRef } from "react";
|
|
148
|
+
import { useState as useState4, useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
149
149
|
import { Table } from "lucide-react";
|
|
150
150
|
import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
151
151
|
function TableTool() {
|
|
@@ -153,7 +153,7 @@ function TableTool() {
|
|
|
153
153
|
const [visible, setVisible] = useState4(false);
|
|
154
154
|
const [hoverRow, setHoverRow] = useState4(0);
|
|
155
155
|
const [hoverCol, setHoverCol] = useState4(0);
|
|
156
|
-
const containerRef =
|
|
156
|
+
const containerRef = useRef2(null);
|
|
157
157
|
useEffect2(() => {
|
|
158
158
|
if (!visible) return;
|
|
159
159
|
const handleClickOutside = (e) => {
|
|
@@ -194,7 +194,7 @@ function TableTool() {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
// src/toolbar/TitleTool.tsx
|
|
197
|
-
import {
|
|
197
|
+
import { useRef as useRef3 } from "react";
|
|
198
198
|
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
199
199
|
var LEVELS = [
|
|
200
200
|
{ level: null, label: "Body" },
|
|
@@ -207,15 +207,15 @@ var LEVELS = [
|
|
|
207
207
|
];
|
|
208
208
|
function TitleTool() {
|
|
209
209
|
const { editorRef, rangeStyle } = useEditor();
|
|
210
|
-
const
|
|
210
|
+
const optionsRef = useRef3(null);
|
|
211
211
|
const activeLevel = rangeStyle?.level || null;
|
|
212
212
|
const activeLabel = LEVELS.find((l) => l.level === activeLevel)?.label || "Body";
|
|
213
213
|
const handleTitle = (level) => {
|
|
214
214
|
editorRef.current?.command.executeTitle(level);
|
|
215
215
|
};
|
|
216
|
-
return /* @__PURE__ */ jsxs3("div", { className: "menu-item__title", onClick: () =>
|
|
216
|
+
return /* @__PURE__ */ jsxs3("div", { className: "menu-item__title", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
217
217
|
/* @__PURE__ */ jsx7("span", { className: "select", title: "Toggle Heading", children: activeLabel }),
|
|
218
|
-
/* @__PURE__ */ jsx7("div", { className: "options"
|
|
218
|
+
/* @__PURE__ */ jsx7("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx7("ul", { children: LEVELS.map(({ level, label }) => /* @__PURE__ */ jsx7(
|
|
219
219
|
"li",
|
|
220
220
|
{
|
|
221
221
|
className: activeLevel === level ? "active" : "",
|
|
@@ -229,7 +229,7 @@ function TitleTool() {
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
// src/toolbar/FontTool.tsx
|
|
232
|
-
import {
|
|
232
|
+
import { useRef as useRef4 } from "react";
|
|
233
233
|
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
234
234
|
var FONTS = [
|
|
235
235
|
{ family: "Arial", label: "Sans Serif" },
|
|
@@ -237,15 +237,15 @@ var FONTS = [
|
|
|
237
237
|
];
|
|
238
238
|
function FontTool() {
|
|
239
239
|
const { editorRef, rangeStyle } = useEditor();
|
|
240
|
-
const
|
|
240
|
+
const optionsRef = useRef4(null);
|
|
241
241
|
const activeFont = rangeStyle?.font || "Arial";
|
|
242
242
|
const activeLabel = FONTS.find((f) => f.family === activeFont)?.label || activeFont;
|
|
243
243
|
const handleFont = (family) => {
|
|
244
244
|
editorRef.current?.command.executeFont(family);
|
|
245
245
|
};
|
|
246
|
-
return /* @__PURE__ */ jsxs4("div", { className: "menu-item__font", onClick: () =>
|
|
246
|
+
return /* @__PURE__ */ jsxs4("div", { className: "menu-item__font", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
247
247
|
/* @__PURE__ */ jsx8("span", { className: "select", title: "Font", children: activeLabel }),
|
|
248
|
-
/* @__PURE__ */ jsx8("div", { className: "options"
|
|
248
|
+
/* @__PURE__ */ jsx8("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx8("ul", { children: FONTS.map(({ family, label }) => /* @__PURE__ */ jsx8(
|
|
249
249
|
"li",
|
|
250
250
|
{
|
|
251
251
|
"data-family": family,
|
|
@@ -260,19 +260,19 @@ function FontTool() {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
// src/toolbar/FontSizeTool.tsx
|
|
263
|
-
import {
|
|
263
|
+
import { useRef as useRef5 } from "react";
|
|
264
264
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
265
265
|
var SIZES = [56, 48, 34, 32, 29, 24, 21, 20, 18, 16, 14, 12, 10, 8];
|
|
266
266
|
function FontSizeTool() {
|
|
267
267
|
const { editorRef, rangeStyle } = useEditor();
|
|
268
|
-
const
|
|
268
|
+
const optionsRef = useRef5(null);
|
|
269
269
|
const activeSize = rangeStyle?.size ?? 16;
|
|
270
270
|
const handleSize = (size) => {
|
|
271
271
|
editorRef.current?.command.executeSize(size);
|
|
272
272
|
};
|
|
273
|
-
return /* @__PURE__ */ jsxs5("div", { className: "menu-item__size", onClick: () =>
|
|
273
|
+
return /* @__PURE__ */ jsxs5("div", { className: "menu-item__size", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
274
274
|
/* @__PURE__ */ jsx9("span", { className: "select", title: "Font Size", children: activeSize }),
|
|
275
|
-
/* @__PURE__ */ jsx9("div", { className: "options"
|
|
275
|
+
/* @__PURE__ */ jsx9("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx9("ul", { children: SIZES.map((size) => /* @__PURE__ */ jsx9(
|
|
276
276
|
"li",
|
|
277
277
|
{
|
|
278
278
|
className: activeSize === size ? "active" : "",
|
|
@@ -285,20 +285,20 @@ function FontSizeTool() {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
// src/toolbar/LineHeightTool.tsx
|
|
288
|
-
import {
|
|
288
|
+
import { useRef as useRef6 } from "react";
|
|
289
289
|
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
290
290
|
var LINE_HEIGHTS = ["1.0", "1.15", "1.5", "2.0", "2.5"];
|
|
291
291
|
function LineHeightTool() {
|
|
292
292
|
const { editorRef, rangeStyle } = useEditor();
|
|
293
|
-
const
|
|
293
|
+
const optionsRef = useRef6(null);
|
|
294
294
|
const activeMargin = rangeStyle?.rowMargin ?? 1;
|
|
295
295
|
const activeLabel = Number.isInteger(activeMargin) ? `${activeMargin}.0` : String(activeMargin);
|
|
296
296
|
const handleLineHeight = (value) => {
|
|
297
297
|
editorRef.current?.command.executeRowMargin(Number(value));
|
|
298
298
|
};
|
|
299
|
-
return /* @__PURE__ */ jsxs6("div", { className: "menu-item__line-height", onClick: () =>
|
|
299
|
+
return /* @__PURE__ */ jsxs6("div", { className: "menu-item__line-height", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
300
300
|
/* @__PURE__ */ jsx10("span", { className: "select", title: "Line Height", children: activeLabel }),
|
|
301
|
-
/* @__PURE__ */ jsx10("div", { className: "options"
|
|
301
|
+
/* @__PURE__ */ jsx10("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx10("ul", { children: LINE_HEIGHTS.map((h) => /* @__PURE__ */ jsx10(
|
|
302
302
|
"li",
|
|
303
303
|
{
|
|
304
304
|
className: String(activeMargin) === h || activeLabel === h ? "active" : "",
|
|
@@ -311,7 +311,7 @@ function LineHeightTool() {
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
// src/toolbar/ColorTool.tsx
|
|
314
|
-
import {
|
|
314
|
+
import { useRef as useRef7 } from "react";
|
|
315
315
|
import { Baseline, RotateCcw } from "lucide-react";
|
|
316
316
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
317
317
|
var COLOR_PALETTE = [
|
|
@@ -326,7 +326,7 @@ var COLOR_PALETTE = [
|
|
|
326
326
|
];
|
|
327
327
|
function ColorTool() {
|
|
328
328
|
const { editorRef, rangeStyle } = useEditor();
|
|
329
|
-
const
|
|
329
|
+
const dropdownRef = useRef7(null);
|
|
330
330
|
const activeColor = rangeStyle?.color || "#000000";
|
|
331
331
|
const handleColor = (color) => {
|
|
332
332
|
editorRef.current?.command.executeColor(color);
|
|
@@ -334,11 +334,11 @@ function ColorTool() {
|
|
|
334
334
|
const handleReset = () => {
|
|
335
335
|
editorRef.current?.command.executeColor(null);
|
|
336
336
|
};
|
|
337
|
-
return /* @__PURE__ */ jsxs7("div", { className: "menu-item__color", title: "Font Color", onClick: () =>
|
|
337
|
+
return /* @__PURE__ */ jsxs7("div", { className: "menu-item__color", title: "Font Color", onClick: () => dropdownRef.current?.classList.toggle("visible"), children: [
|
|
338
338
|
/* @__PURE__ */ jsx11(Baseline, { size: 16 }),
|
|
339
339
|
/* @__PURE__ */ jsx11("span", { style: { backgroundColor: activeColor } }),
|
|
340
340
|
/* @__PURE__ */ jsx11("input", { id: "color", type: "color", readOnly: true, tabIndex: -1 }),
|
|
341
|
-
/* @__PURE__ */ jsx11("div", { className: "color-palette-dropdown"
|
|
341
|
+
/* @__PURE__ */ jsx11("div", { className: "color-palette-dropdown", ref: dropdownRef, children: /* @__PURE__ */ jsxs7("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
342
342
|
/* @__PURE__ */ jsxs7("button", { className: "color-palette-reset", onClick: handleReset, children: [
|
|
343
343
|
/* @__PURE__ */ jsx11(RotateCcw, { size: 12 }),
|
|
344
344
|
"Reset"
|
|
@@ -358,7 +358,7 @@ function ColorTool() {
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
// src/toolbar/HighlightTool.tsx
|
|
361
|
-
import {
|
|
361
|
+
import { useRef as useRef8 } from "react";
|
|
362
362
|
import { Highlighter, RotateCcw as RotateCcw2 } from "lucide-react";
|
|
363
363
|
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
364
364
|
var HIGHLIGHT_PALETTE = [
|
|
@@ -373,7 +373,7 @@ var HIGHLIGHT_PALETTE = [
|
|
|
373
373
|
];
|
|
374
374
|
function HighlightTool() {
|
|
375
375
|
const { editorRef, rangeStyle } = useEditor();
|
|
376
|
-
const
|
|
376
|
+
const dropdownRef = useRef8(null);
|
|
377
377
|
const activeColor = rangeStyle?.highlight || "";
|
|
378
378
|
const handleColor = (color) => {
|
|
379
379
|
editorRef.current?.command.executeHighlight(color);
|
|
@@ -381,11 +381,11 @@ function HighlightTool() {
|
|
|
381
381
|
const handleReset = () => {
|
|
382
382
|
editorRef.current?.command.executeHighlight(null);
|
|
383
383
|
};
|
|
384
|
-
return /* @__PURE__ */ jsxs8("div", { className: "menu-item__highlight", title: "Highlight", onClick: () =>
|
|
384
|
+
return /* @__PURE__ */ jsxs8("div", { className: "menu-item__highlight", title: "Highlight", onClick: () => dropdownRef.current?.classList.toggle("visible"), children: [
|
|
385
385
|
/* @__PURE__ */ jsx12(Highlighter, { size: 16 }),
|
|
386
386
|
/* @__PURE__ */ jsx12("span", { style: { backgroundColor: activeColor || "#ffff00" } }),
|
|
387
387
|
/* @__PURE__ */ jsx12("input", { id: "highlight", type: "color", readOnly: true, tabIndex: -1 }),
|
|
388
|
-
/* @__PURE__ */ jsx12("div", { className: "color-palette-dropdown"
|
|
388
|
+
/* @__PURE__ */ jsx12("div", { className: "color-palette-dropdown", ref: dropdownRef, children: /* @__PURE__ */ jsxs8("div", { onClick: (e) => e.stopPropagation(), children: [
|
|
389
389
|
/* @__PURE__ */ jsxs8("button", { className: "color-palette-reset", onClick: handleReset, children: [
|
|
390
390
|
/* @__PURE__ */ jsx12(RotateCcw2, { size: 12 }),
|
|
391
391
|
"None"
|
|
@@ -423,18 +423,18 @@ function ItalicTool() {
|
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
// src/toolbar/UnderlineTool.tsx
|
|
426
|
-
import {
|
|
426
|
+
import { useRef as useRef9 } from "react";
|
|
427
427
|
import { Underline as UnderlineIcon } from "lucide-react";
|
|
428
428
|
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
429
429
|
var STYLES = ["solid", "double", "dashed", "dotted", "wavy"];
|
|
430
430
|
function UnderlineTool() {
|
|
431
431
|
const { editorRef, isApple, rangeStyle } = useEditor();
|
|
432
|
-
const
|
|
432
|
+
const optionsRef = useRef9(null);
|
|
433
433
|
const isActive = rangeStyle?.underline === true;
|
|
434
434
|
return /* @__PURE__ */ jsxs9("div", { className: `menu-item__underline ${isActive ? "active" : ""}`, title: `Underline(${isApple ? "\u2318" : "Ctrl"}+U)`, children: [
|
|
435
435
|
/* @__PURE__ */ jsx15(UnderlineIcon, { size: 16, onClick: () => editorRef.current?.command.executeUnderline(), style: { cursor: "pointer" } }),
|
|
436
|
-
/* @__PURE__ */ jsx15("span", { className: "select", onClick: () =>
|
|
437
|
-
/* @__PURE__ */ jsx15("div", { className: "options"
|
|
436
|
+
/* @__PURE__ */ jsx15("span", { className: "select", onClick: () => optionsRef.current?.classList.toggle("visible") }),
|
|
437
|
+
/* @__PURE__ */ jsx15("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx15("ul", { children: STYLES.map((style) => /* @__PURE__ */ jsx15("li", { "data-decoration-style": style, onClick: () => {
|
|
438
438
|
editorRef.current?.command.executeUnderline({ style });
|
|
439
439
|
}, children: /* @__PURE__ */ jsx15("i", {}) }, style)) }) })
|
|
440
440
|
] });
|
|
@@ -486,7 +486,7 @@ function JustifyTool() {
|
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
// src/toolbar/ListTool.tsx
|
|
489
|
-
import {
|
|
489
|
+
import { useRef as useRef10 } from "react";
|
|
490
490
|
import { List, ListOrdered, Indent, Outdent } from "lucide-react";
|
|
491
491
|
import { jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
492
492
|
var OL_PRESETS = [
|
|
@@ -521,7 +521,7 @@ function PresetCell({ option, onClick }) {
|
|
|
521
521
|
}
|
|
522
522
|
function ListTool() {
|
|
523
523
|
const { editorRef, isApple, rangeStyle } = useEditor();
|
|
524
|
-
const
|
|
524
|
+
const optionsRef = useRef10(null);
|
|
525
525
|
const isActive = !!rangeStyle?.listType;
|
|
526
526
|
const handleList = (type, style) => {
|
|
527
527
|
editorRef.current?.command.executeList(type, style);
|
|
@@ -539,8 +539,8 @@ function ListTool() {
|
|
|
539
539
|
editorRef.current?.command.executeListOutdent();
|
|
540
540
|
};
|
|
541
541
|
return /* @__PURE__ */ jsxs10("div", { className: `menu-item__list ${isActive ? "active" : ""}`, title: `List(${isApple ? "\u2318" : "Ctrl"}+Shift+U)`, children: [
|
|
542
|
-
/* @__PURE__ */ jsx21(List, { size: 16, onClick: () =>
|
|
543
|
-
/* @__PURE__ */ jsx21("div", { className: "options"
|
|
542
|
+
/* @__PURE__ */ jsx21(List, { size: 16, onClick: () => optionsRef.current?.classList.toggle("visible"), style: { cursor: "pointer" } }),
|
|
543
|
+
/* @__PURE__ */ jsx21("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsxs10("div", { style: { padding: "8px", width: "320px" }, children: [
|
|
544
544
|
/* @__PURE__ */ jsxs10("div", { style: { display: "flex", gap: "4px", marginBottom: "8px" }, children: [
|
|
545
545
|
/* @__PURE__ */ jsx21(
|
|
546
546
|
"button",
|
|
@@ -615,7 +615,7 @@ function ImageTool() {
|
|
|
615
615
|
}
|
|
616
616
|
|
|
617
617
|
// src/toolbar/SeparatorTool.tsx
|
|
618
|
-
import { useState as
|
|
618
|
+
import { useRef as useRef11, useState as useState5 } from "react";
|
|
619
619
|
import { Minus } from "lucide-react";
|
|
620
620
|
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
621
621
|
var DASH_STYLES = [
|
|
@@ -631,15 +631,15 @@ var LINE_WIDTHS = [
|
|
|
631
631
|
];
|
|
632
632
|
function SeparatorTool() {
|
|
633
633
|
const { editorRef } = useEditor();
|
|
634
|
-
const
|
|
635
|
-
const [selectedWidth, setSelectedWidth] =
|
|
634
|
+
const optionsRef = useRef11(null);
|
|
635
|
+
const [selectedWidth, setSelectedWidth] = useState5(1);
|
|
636
636
|
const lineColor = "#344054";
|
|
637
637
|
const handleSeparator = (dashArray) => {
|
|
638
638
|
editorRef.current?.command.executeSeparator(dashArray, { lineWidth: selectedWidth });
|
|
639
639
|
};
|
|
640
640
|
return /* @__PURE__ */ jsxs12("div", { className: "menu-item__separator", title: "Separator", children: [
|
|
641
|
-
/* @__PURE__ */ jsx23(Minus, { size: 16, onClick: () =>
|
|
642
|
-
/* @__PURE__ */ jsx23("div", { className: "options"
|
|
641
|
+
/* @__PURE__ */ jsx23(Minus, { size: 16, onClick: () => optionsRef.current?.classList.toggle("visible"), style: { cursor: "pointer" } }),
|
|
642
|
+
/* @__PURE__ */ jsx23("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsxs12("div", { style: { padding: "8px 10px 10px", width: "200px" }, children: [
|
|
643
643
|
/* @__PURE__ */ jsx23("ul", { style: { margin: 0, padding: 0, listStyle: "none" }, children: DASH_STYLES.map(({ label, dashArray }) => /* @__PURE__ */ jsxs12(
|
|
644
644
|
"li",
|
|
645
645
|
{
|
|
@@ -693,11 +693,11 @@ function SeparatorTool() {
|
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
// src/toolbar/WatermarkTool.tsx
|
|
696
|
-
import {
|
|
696
|
+
import { useRef as useRef12 } from "react";
|
|
697
697
|
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
698
698
|
function InsertElementTool() {
|
|
699
699
|
const { editorRef } = useEditor();
|
|
700
|
-
const
|
|
700
|
+
const optionsRef = useRef12(null);
|
|
701
701
|
const handleHeader = () => {
|
|
702
702
|
if (!editorRef.current) return;
|
|
703
703
|
const options = editorRef.current.command.getOptions();
|
|
@@ -707,18 +707,18 @@ function InsertElementTool() {
|
|
|
707
707
|
}
|
|
708
708
|
editorRef.current.command.executeSetZone("header");
|
|
709
709
|
};
|
|
710
|
-
return /* @__PURE__ */ jsxs13("div", { className: "menu-item__insert-element", onClick: () =>
|
|
710
|
+
return /* @__PURE__ */ jsxs13("div", { className: "menu-item__insert-element", onClick: () => optionsRef.current?.classList.toggle("visible"), children: [
|
|
711
711
|
/* @__PURE__ */ jsx24("i", { title: "Insert Element" }),
|
|
712
|
-
/* @__PURE__ */ jsx24("div", { className: "options"
|
|
712
|
+
/* @__PURE__ */ jsx24("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsx24("ul", { children: /* @__PURE__ */ jsx24("li", { onClick: handleHeader, children: "Add Header" }) }) })
|
|
713
713
|
] });
|
|
714
714
|
}
|
|
715
715
|
|
|
716
716
|
// src/toolbar/PageBreakTool.tsx
|
|
717
|
-
import {
|
|
717
|
+
import { useRef as useRef13 } from "react";
|
|
718
718
|
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
719
719
|
function PageBreakTool() {
|
|
720
720
|
const { editorRef } = useEditor();
|
|
721
|
-
const
|
|
721
|
+
const optionsRef = useRef13(null);
|
|
722
722
|
const handlePageBreak = () => {
|
|
723
723
|
editorRef.current?.command.executePageBreak();
|
|
724
724
|
};
|
|
@@ -729,10 +729,10 @@ function PageBreakTool() {
|
|
|
729
729
|
"div",
|
|
730
730
|
{
|
|
731
731
|
className: "menu-item__page-break",
|
|
732
|
-
onClick: () =>
|
|
732
|
+
onClick: () => optionsRef.current?.classList.toggle("visible"),
|
|
733
733
|
children: [
|
|
734
734
|
/* @__PURE__ */ jsx25("i", { title: "Break" }),
|
|
735
|
-
/* @__PURE__ */ jsx25("div", { className: "options"
|
|
735
|
+
/* @__PURE__ */ jsx25("div", { className: "options", ref: optionsRef, children: /* @__PURE__ */ jsxs14("ul", { children: [
|
|
736
736
|
/* @__PURE__ */ jsx25("li", { onClick: handlePageBreak, children: "Page Break" }),
|
|
737
737
|
/* @__PURE__ */ jsx25("li", { onClick: handleColumnBreak, children: "Column Break" })
|
|
738
738
|
] }) })
|
|
@@ -797,11 +797,11 @@ function CatalogToggleTool() {
|
|
|
797
797
|
}
|
|
798
798
|
|
|
799
799
|
// src/footer/PageModeTool.tsx
|
|
800
|
-
import { useState as
|
|
800
|
+
import { useState as useState6 } from "react";
|
|
801
801
|
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
802
802
|
function PageModeTool() {
|
|
803
803
|
const { editorRef } = useEditor();
|
|
804
|
-
const [visible, setVisible] =
|
|
804
|
+
const [visible, setVisible] = useState6(false);
|
|
805
805
|
const handlePageMode = (mode) => {
|
|
806
806
|
editorRef.current?.command.executePageMode(mode);
|
|
807
807
|
setVisible(false);
|
|
@@ -850,7 +850,7 @@ function FooterStatus() {
|
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
// src/footer/EditorModeTool.tsx
|
|
853
|
-
import { useState as
|
|
853
|
+
import { useState as useState7, useRef as useRef14 } from "react";
|
|
854
854
|
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
855
855
|
var MODE_LIST = [
|
|
856
856
|
{ mode: "edit", name: "Edit Mode" },
|
|
@@ -863,8 +863,8 @@ var MODE_LIST = [
|
|
|
863
863
|
];
|
|
864
864
|
function EditorModeTool() {
|
|
865
865
|
const { editorRef } = useEditor();
|
|
866
|
-
const [editorMode, setEditorMode] =
|
|
867
|
-
const modeIndexRef =
|
|
866
|
+
const [editorMode, setEditorMode] = useState7("Edit Mode");
|
|
867
|
+
const modeIndexRef = useRef14(0);
|
|
868
868
|
const handleModeChange = () => {
|
|
869
869
|
modeIndexRef.current = modeIndexRef.current === MODE_LIST.length - 1 ? 0 : modeIndexRef.current + 1;
|
|
870
870
|
const { name, mode } = MODE_LIST[modeIndexRef.current];
|
|
@@ -910,7 +910,7 @@ function PageScaleAddTool() {
|
|
|
910
910
|
}
|
|
911
911
|
|
|
912
912
|
// src/footer/PaperSizeTool.tsx
|
|
913
|
-
import { useState as
|
|
913
|
+
import { useState as useState8 } from "react";
|
|
914
914
|
import { jsx as jsx33, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
915
915
|
var SIZES2 = [
|
|
916
916
|
{ label: "A4", width: 794, height: 1123, active: true },
|
|
@@ -920,7 +920,7 @@ var SIZES2 = [
|
|
|
920
920
|
];
|
|
921
921
|
function PaperSizeTool() {
|
|
922
922
|
const { editorRef } = useEditor();
|
|
923
|
-
const [visible, setVisible] =
|
|
923
|
+
const [visible, setVisible] = useState8(false);
|
|
924
924
|
const handlePaperSize = (width, height) => {
|
|
925
925
|
editorRef.current?.command.executePaperSize(width, height);
|
|
926
926
|
setVisible(false);
|
|
@@ -932,11 +932,11 @@ function PaperSizeTool() {
|
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
// src/footer/PaperDirectionTool.tsx
|
|
935
|
-
import { useState as
|
|
935
|
+
import { useState as useState9 } from "react";
|
|
936
936
|
import { jsx as jsx34, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
937
937
|
function PaperDirectionTool() {
|
|
938
938
|
const { editorRef } = useEditor();
|
|
939
|
-
const [visible, setVisible] =
|
|
939
|
+
const [visible, setVisible] = useState9(false);
|
|
940
940
|
const handlePaperDirection = (direction) => {
|
|
941
941
|
editorRef.current?.command.executePaperDirection(direction);
|
|
942
942
|
setVisible(false);
|
|
@@ -1033,7 +1033,7 @@ function EditorOptionTool() {
|
|
|
1033
1033
|
}
|
|
1034
1034
|
|
|
1035
1035
|
// src/footer/WatermarkFooterTool.tsx
|
|
1036
|
-
import { useState as
|
|
1036
|
+
import { useState as useState10, useRef as useRef15, useEffect as useEffect3, useCallback } from "react";
|
|
1037
1037
|
import { Fragment as Fragment3, jsx as jsx38, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1038
1038
|
var COLOR_PALETTE2 = [
|
|
1039
1039
|
["#000000", "#434343", "#666666", "#999999", "#b7b7b7", "#cccccc"],
|
|
@@ -1046,20 +1046,20 @@ var FONTS2 = [
|
|
|
1046
1046
|
];
|
|
1047
1047
|
function WatermarkFooterTool() {
|
|
1048
1048
|
const { editorRef } = useEditor();
|
|
1049
|
-
const [visible, setVisible] =
|
|
1050
|
-
const [tab, setTab] =
|
|
1051
|
-
const containerRef =
|
|
1052
|
-
const panelRef =
|
|
1053
|
-
const fileInputRef =
|
|
1054
|
-
const [text, setText] =
|
|
1055
|
-
const [font, setFont] =
|
|
1056
|
-
const [color, setColor] =
|
|
1057
|
-
const [opacity, setOpacity] =
|
|
1058
|
-
const [rotation, setRotation] =
|
|
1059
|
-
const [inFront, setInFront] =
|
|
1060
|
-
const [imageData, setImageData] =
|
|
1061
|
-
const [imgWidth, setImgWidth] =
|
|
1062
|
-
const [imgHeight, setImgHeight] =
|
|
1049
|
+
const [visible, setVisible] = useState10(false);
|
|
1050
|
+
const [tab, setTab] = useState10("text");
|
|
1051
|
+
const containerRef = useRef15(null);
|
|
1052
|
+
const panelRef = useRef15(null);
|
|
1053
|
+
const fileInputRef = useRef15(null);
|
|
1054
|
+
const [text, setText] = useState10("WATERMARK");
|
|
1055
|
+
const [font, setFont] = useState10("Arial");
|
|
1056
|
+
const [color, setColor] = useState10("#AEB5C0");
|
|
1057
|
+
const [opacity, setOpacity] = useState10(30);
|
|
1058
|
+
const [rotation, setRotation] = useState10(-45);
|
|
1059
|
+
const [inFront, setInFront] = useState10(false);
|
|
1060
|
+
const [imageData, setImageData] = useState10("");
|
|
1061
|
+
const [imgWidth, setImgWidth] = useState10(200);
|
|
1062
|
+
const [imgHeight, setImgHeight] = useState10(200);
|
|
1063
1063
|
useEffect3(() => {
|
|
1064
1064
|
if (!visible) return;
|
|
1065
1065
|
const handler = (e) => {
|
|
@@ -1298,9 +1298,9 @@ function EditorInner({
|
|
|
1298
1298
|
style,
|
|
1299
1299
|
onDrop: userOnDrop
|
|
1300
1300
|
}) {
|
|
1301
|
-
const containerRef =
|
|
1302
|
-
const editorRef =
|
|
1303
|
-
const [rangeStyle, setRangeStyle] =
|
|
1301
|
+
const containerRef = useRef16(null);
|
|
1302
|
+
const editorRef = useRef16(null);
|
|
1303
|
+
const [rangeStyle, setRangeStyle] = useState11(null);
|
|
1304
1304
|
const {
|
|
1305
1305
|
setPageNoList,
|
|
1306
1306
|
setPageNo,
|