@canvas-components/print-design-plugin 0.1.7 → 0.1.9
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/README.md +51 -5
- package/dist/index.cjs +1144 -131
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1145 -132
- package/dist/list-table-print.cjs +1687 -302
- package/dist/list-table-print.css +505 -6
- package/dist/list-table-print.d.cts +2 -2
- package/dist/list-table-print.d.ts +2 -2
- package/dist/list-table-print.js +1690 -305
- package/dist/{model-BwhSanYM.d.cts → model-DIvOoRX8.d.cts} +47 -1
- package/dist/{model-BwhSanYM.d.ts → model-DIvOoRX8.d.ts} +47 -1
- package/dist/native.cjs +1144 -131
- package/dist/native.d.cts +2 -2
- package/dist/native.d.ts +2 -2
- package/dist/native.js +1145 -132
- package/dist/react.cjs +4408 -354
- package/dist/react.css +505 -6
- package/dist/react.d.cts +176 -3
- package/dist/react.d.ts +176 -3
- package/dist/react.js +4411 -359
- package/package.json +11 -10
package/dist/list-table-print.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { LINE_STYLE_OPTIONS, FONT_FAMILY_OPTIONS, PrintDesignScopedPropertyRegistry, LayerAlignmentControls, ElementLayerControls, GroupControls, GuidePositionField, PreprintModeHelp, PropertyToggleButton, PaperSizeField, isBuiltinPaperSize, NumberField, PrintDesignComponentFactoryRegistry, PrintDesignToolRegistry, readPrintDesignTemplates, getPropertyFieldPatch, builtinPrintDesignComponentFactories, findSelectedGroup, DebuggerToolButton, TemplatePropertiesPanel, TemplatesTool, ComponentsTool, SavedGroupsTool, MultiSelectionPropertiesPanel, LayersTool, GuidePropertiesPanel, GuidesTool, PagePropertiesPanel, PagesTool, SettingsPropertiesPanel, SettingsTool, editorThemes, withEditorTheme, PluginMarketTool, JsonField, isPrintDesignDocumentCompatible, isPrintDesignTemplateInvalid, getPrintDesignTemplateInvalidLocations, ReactPrintDesign, DataModeButtons, DataPathPicker, useEditorPreferences } from '@canvas-components/react-print-design';
|
|
2
|
-
import { definePrintDesignPluginRenderer, renderPrintDesignHtmlFrame, rotatePoint, resolvePrintDesignElementData, PrintDesignComponentRegistry, resolvePrintDesignBinding, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, resolveDesignText, cssFont,
|
|
2
|
+
import { definePrintDesignPluginRenderer, renderPrintDesignHtmlFrame, rotatePoint, resolvePrintDesignElementData, PrintDesignComponentRegistry, resolvePrintDesignBinding, resolvePrintDesignElementVisible, resolvePrintDesignPageVisible, resolveDesignText, cssFont, isPrintDesignColorValue, cssNumber, escapeHtml, cssColor, PRINT_DESIGN_DEFAULT_FONT_FAMILY, resolvePrintDesignDataPath, getPrintDesignElementDataConfig, elementTransformHomography, projectTransformPoint, hitTestPrintDesignPage, transformRect, elementTransformCss, pixelsToMillimeters, PRINT_DESIGN_CSS_DPI, isPrintDesignRecordCollection, clonePrintDesignDocument, getSelectionRect, fromDisplayUnit, toDisplayUnit, resolvePrintDesignFontFamily, inverseTransformPoint, stringifyPrintDesignBinding, createPrintDesignId, transformPrintDesignToHtmlBatches, createPrintDesignDocument, createPrintDesignPage } from '@canvas-components/print-design';
|
|
3
3
|
import { encodeBarcodePattern, drawBarcodeToCanvas, exportBarcodeToSvg } from '@canvas-components/barcode';
|
|
4
4
|
import { drawQrCodeToCanvas, encodeQrCodeMatrix, exportQrCodeToSvg, buildQrCodeContent, getQrCodeMatrix } from '@canvas-components/qrcode';
|
|
5
5
|
import { drawCanvasChartToCanvas, exportCanvasChartToSvg } from '@canvas-components/chart';
|
|
6
6
|
import { getIconDefinition } from '@canvas-components/icons';
|
|
7
7
|
import { roundPreciseNumber, mapInBatches } from '@canvas-components/utils';
|
|
8
|
-
import { createElement, useState, useEffect, useMemo, useCallback
|
|
9
|
-
import { ReactFontSizeOutlined, ReactAlignLeftOutlined, ReactAlignCenterOutlined, ReactAlignRightOutlined, ReactMenuOutlined, ReactColumnWidthOutlined, ReactVerticalAlignTopOutlined, ReactVerticalAlignMiddleOutlined, ReactVerticalAlignBottomOutlined, ReactCalendarOutlined, ReactDollarOutlined, ReactNumberOutlined, ReactHighlightOutlined, ReactLineOutlined, ReactTableOutlined, ReactFileImageOutlined, ReactBarcodeOutlined, ReactQrcodeOutlined, ReactBarChartOutlined, ReactInputNumber, ReactButton, ReactColorPicker, ReactPlusOutlined, ReactInput, ReactModal, ReactCollapsePanel, ReactSelect, ReactReloadOutlined, ReactBoldOutlined, ReactItalicOutlined, ReactEyeOutlined, ReactEyeInvisibleOutlined, ReactDeleteOutlined, ReactPopup, ReactBorderLeftOutlined, ReactBorderBottomOutlined, ReactBorderRightOutlined, ReactBorderTopOutlined, ReactBorderInnerOutlined, ReactProgress } from '@canvas-components/react-components';
|
|
8
|
+
import { createElement, useState, useEffect, useRef, useMemo, useCallback } from 'react';
|
|
9
|
+
import { ReactFontSizeOutlined, ReactAlignLeftOutlined, ReactAlignCenterOutlined, ReactAlignRightOutlined, ReactMenuOutlined, ReactColumnWidthOutlined, ReactVerticalAlignTopOutlined, ReactVerticalAlignMiddleOutlined, ReactVerticalAlignBottomOutlined, ReactCalendarOutlined, ReactDollarOutlined, ReactNumberOutlined, ReactHighlightOutlined, ReactLineOutlined, ReactTableOutlined, ReactFileImageOutlined, ReactBarcodeOutlined, ReactQrcodeOutlined, ReactBarChartOutlined, ReactInputNumber, ReactButton, ReactColorPicker, ReactPlusOutlined, ReactInput, ReactModal, ReactRichText, ReactCollapsePanel, ReactSelect, ReactReloadOutlined, ReactBoldOutlined, ReactItalicOutlined, ReactEyeOutlined, ReactEyeInvisibleOutlined, ReactDeleteOutlined, ReactPopup, ReactBorderLeftOutlined, ReactBorderBottomOutlined, ReactBorderRightOutlined, ReactBorderTopOutlined, ReactBorderInnerOutlined, ReactProgress } from '@canvas-components/react-components';
|
|
10
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import { BROWSER_PRINT_PAPER_SIZES } from '@canvas-components/print';
|
|
12
12
|
import { createRoot } from 'react-dom/client';
|
|
@@ -53,7 +53,9 @@ function assertNativePluginDependencies(plugins) {
|
|
|
53
53
|
function validateTextElement(value) {
|
|
54
54
|
if (!value || typeof value !== "object") return false;
|
|
55
55
|
const element = value;
|
|
56
|
-
return element.type === "text" && typeof element.text === "string" && (element.colorMode === void 0 || ["static", "binding"].includes(element.colorMode)) && (element.fontSizeMode === void 0 || ["static", "binding"].includes(element.fontSizeMode)) && (element.colorPath === void 0 || typeof element.colorPath === "string") && (element.fontSizePath === void 0 || typeof element.fontSizePath === "string") && (element.fontSizeBindingUnit === void 0 || ["mm", "cm", "in", "pt", "px"].includes(element.fontSizeBindingUnit)) && (element.heightOverflow === void 0 || ["clip", "flow", "ellipsis"].includes(element.heightOverflow)) && (element.
|
|
56
|
+
return element.type === "text" && typeof element.text === "string" && (element.fontStyle === void 0 || ["normal", "italic"].includes(element.fontStyle)) && (element.colorMode === void 0 || ["static", "binding"].includes(element.colorMode)) && (element.fontSizeMode === void 0 || ["static", "binding"].includes(element.fontSizeMode)) && (element.colorPath === void 0 || typeof element.colorPath === "string") && (element.fontSizePath === void 0 || typeof element.fontSizePath === "string") && (element.fontSizeBindingUnit === void 0 || ["mm", "cm", "in", "pt", "px"].includes(element.fontSizeBindingUnit)) && (element.heightOverflow === void 0 || ["clip", "flow", "ellipsis"].includes(element.heightOverflow)) && (element.indentMode === void 0 || ["none", "firstLine", "hanging"].includes(element.indentMode)) && (element.indentValue === void 0 || Number.isFinite(element.indentValue) && element.indentValue >= 0) && (element.indentUnit === void 0 || ["char", "mm", "cm", "in", "pt", "px"].includes(element.indentUnit)) && (element.prewrappedIndents === void 0 || Array.isArray(element.prewrappedIndents) && element.prewrappedIndents.every(
|
|
57
|
+
(value2) => Number.isFinite(value2) && value2 >= 0
|
|
58
|
+
)) && (element.underlineStyle === void 0 || ["solid", "dashed", "dotted", "wavy"].includes(element.underlineStyle)) && (element.underlineCount === void 0 || Number.isInteger(element.underlineCount) && element.underlineCount >= 0 && element.underlineCount <= 5) && (element.fontSource === void 0 || typeof element.fontSource === "string") && (element.borderWidth === void 0 || Number.isFinite(element.borderWidth) && element.borderWidth >= 0) && (element.borderColor === void 0 || typeof element.borderColor === "string") && (element.fontSizeRules === void 0 || Array.isArray(element.fontSizeRules) && element.fontSizeRules.every(
|
|
57
59
|
(rule) => rule && Number.isInteger(rule.maxChars) && rule.maxChars >= 1 && Number.isFinite(rule.fontSize) && rule.fontSize > 0
|
|
58
60
|
));
|
|
59
61
|
}
|
|
@@ -69,23 +71,36 @@ function graphemes(text) {
|
|
|
69
71
|
function drawVerticalText(ctx, text, box, options) {
|
|
70
72
|
if (box.width <= 0 || box.height <= 0) return;
|
|
71
73
|
const step = Math.max(1, options.fontSize * options.lineHeight);
|
|
72
|
-
const capacity = Math.max(1, Math.floor(box.height / step));
|
|
73
74
|
const paragraphs = text.split(/\r?\n/).map(graphemes);
|
|
74
75
|
const columns = paragraphs.flatMap((chars) => {
|
|
75
|
-
if (!options.wrap || chars.length <= capacity) return [chars];
|
|
76
76
|
const chunks = [];
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let offset = 0;
|
|
78
|
+
do {
|
|
79
|
+
const indent = options.indentMode === "firstLine" ? chunks.length === 0 ? options.indent ?? 0 : 0 : options.indentMode === "hanging" && chunks.length > 0 ? options.indent ?? 0 : 0;
|
|
80
|
+
const capacity = Math.max(1, Math.floor((box.height - indent) / step));
|
|
81
|
+
chunks.push({
|
|
82
|
+
chars: options.wrap === false ? chars.slice(offset) : chars.slice(offset, offset + capacity),
|
|
83
|
+
indent
|
|
84
|
+
});
|
|
85
|
+
offset += capacity;
|
|
86
|
+
} while (options.wrap !== false && offset < chars.length);
|
|
79
87
|
return chunks;
|
|
80
88
|
});
|
|
81
89
|
const visibleCount = Math.max(1, Math.floor(box.width / step));
|
|
82
90
|
const visible = columns.slice(0, visibleCount);
|
|
83
|
-
const overflowed = columns.length > visibleCount || !options.wrap && visible.some(
|
|
91
|
+
const overflowed = columns.length > visibleCount || !options.wrap && visible.some(
|
|
92
|
+
({ chars, indent }) => chars.length > Math.max(1, Math.floor((box.height - indent) / step))
|
|
93
|
+
);
|
|
84
94
|
if (options.ellipsis && overflowed && visible.length) {
|
|
85
|
-
const
|
|
95
|
+
const previous = visible[visible.length - 1];
|
|
96
|
+
const capacity = Math.max(
|
|
97
|
+
1,
|
|
98
|
+
Math.floor((box.height - previous.indent) / step)
|
|
99
|
+
);
|
|
100
|
+
const last = [...previous.chars];
|
|
86
101
|
last.length = Math.min(last.length, capacity);
|
|
87
102
|
last[Math.max(0, Math.min(last.length, capacity) - 1)] = "\u2026";
|
|
88
|
-
visible[visible.length - 1] = last;
|
|
103
|
+
visible[visible.length - 1] = { ...previous, chars: last };
|
|
89
104
|
}
|
|
90
105
|
const blockWidth = visible.length * step;
|
|
91
106
|
const left = options.align === "left" ? box.x : options.align === "center" ? box.x + (box.width - blockWidth) / 2 : box.x + box.width - blockWidth;
|
|
@@ -95,12 +110,17 @@ function drawVerticalText(ctx, text, box, options) {
|
|
|
95
110
|
ctx.clip();
|
|
96
111
|
ctx.textAlign = "center";
|
|
97
112
|
ctx.textBaseline = "middle";
|
|
98
|
-
visible.forEach((chars, column) => {
|
|
113
|
+
visible.forEach(({ chars, indent }, column) => {
|
|
99
114
|
const textHeight = chars.length * step;
|
|
100
|
-
const
|
|
115
|
+
const availableHeight = Math.max(0, box.height - indent);
|
|
116
|
+
const offset = options.verticalAlign === "bottom" ? Math.max(0, availableHeight - textHeight) : options.verticalAlign === "middle" ? Math.max(0, (availableHeight - textHeight) / 2) : 0;
|
|
101
117
|
const centerX = left + blockWidth - (column + 0.5) * step;
|
|
102
118
|
chars.forEach(
|
|
103
|
-
(char, index) => ctx.fillText(
|
|
119
|
+
(char, index) => ctx.fillText(
|
|
120
|
+
char,
|
|
121
|
+
centerX,
|
|
122
|
+
box.y + indent + offset + (index + 0.5) * step
|
|
123
|
+
)
|
|
104
124
|
);
|
|
105
125
|
});
|
|
106
126
|
ctx.restore();
|
|
@@ -141,15 +161,16 @@ function getTextLayoutCache(ctx) {
|
|
|
141
161
|
}
|
|
142
162
|
return entry;
|
|
143
163
|
}
|
|
144
|
-
function layoutSpacedText(ctx, text, width, prewrapped = false) {
|
|
164
|
+
function layoutSpacedText(ctx, text, width, prewrapped = false, indent) {
|
|
145
165
|
const cache = getTextLayoutCache(ctx);
|
|
146
|
-
const key = `${prewrapped}:${width}\0${text}`;
|
|
166
|
+
const key = `${prewrapped}:${width}:${indent?.mode ?? "none"}:${indent?.value ?? 0}\0${text}`;
|
|
147
167
|
let lines = cache.lines.get(key);
|
|
148
168
|
if (!lines) {
|
|
149
169
|
lines = prewrapped ? text.split("\n").map((text2) => ({ text: text2, last: true })) : layoutAlignedText(
|
|
150
170
|
text,
|
|
151
171
|
width,
|
|
152
|
-
(value) => measureSpacedText(ctx, value)
|
|
172
|
+
(value) => measureSpacedText(ctx, value),
|
|
173
|
+
indent
|
|
153
174
|
);
|
|
154
175
|
if (cache.lines.size >= 128) cache.lines.clear();
|
|
155
176
|
cache.lines.set(key, lines);
|
|
@@ -203,28 +224,30 @@ function drawSpacedText(ctx, text, x, y) {
|
|
|
203
224
|
});
|
|
204
225
|
ctx.textAlign = align;
|
|
205
226
|
}
|
|
206
|
-
function layoutAlignedText(text, width, measure) {
|
|
227
|
+
function layoutAlignedText(text, width, measure, indent) {
|
|
207
228
|
return text.split("\n").flatMap((paragraph) => {
|
|
208
229
|
const lines = [];
|
|
209
230
|
let line = "";
|
|
231
|
+
const indentation = (index) => indent?.mode === "firstLine" ? index === 0 ? indent.value : 0 : indent?.mode === "hanging" && index > 0 ? indent.value : 0;
|
|
210
232
|
const tokens = paragraph.match(
|
|
211
233
|
/[¥¥$€£]?\p{N}+(?:[.,:/-]\p{N}+)*(?:[%%])?|[\p{Script=Latin}\p{N}]+|\s+|[^\p{Script=Latin}\p{N}\s]+/gu
|
|
212
234
|
) ?? [];
|
|
213
235
|
const pieces = tokens.flatMap(
|
|
214
236
|
(token) => /^(?:[¥¥$€£]?\p{N}+(?:[.,:/-]\p{N}+)*(?:[%%])?|[\p{Script=Latin}\p{N}\s]+)$/u.test(
|
|
215
237
|
token
|
|
216
|
-
) && measure(token) <= width ? [token] : graphemes(token)
|
|
238
|
+
) && measure(token) <= Math.max(1, width - Math.max(0, indent?.value ?? 0)) ? [token] : graphemes(token)
|
|
217
239
|
);
|
|
218
240
|
for (const piece of pieces) {
|
|
219
|
-
if (line && measure(line + piece) > width) {
|
|
220
|
-
lines.push(line.trimEnd());
|
|
241
|
+
if (line && measure(line + piece) > Math.max(1, width - indentation(lines.length))) {
|
|
242
|
+
lines.push({ text: line.trimEnd(), indent: indentation(lines.length) });
|
|
221
243
|
line = "";
|
|
222
244
|
}
|
|
223
245
|
if (line || piece.trim()) line += piece;
|
|
224
246
|
}
|
|
225
|
-
lines.push(line.trimEnd());
|
|
247
|
+
lines.push({ text: line.trimEnd(), indent: indentation(lines.length) });
|
|
226
248
|
return lines.map((value, index) => ({
|
|
227
|
-
text: value,
|
|
249
|
+
text: value.text,
|
|
250
|
+
...indent && indent.mode !== "none" && indent.value > 0 ? { indent: value.indent } : {},
|
|
228
251
|
last: index === lines.length - 1
|
|
229
252
|
}));
|
|
230
253
|
});
|
|
@@ -250,13 +273,7 @@ function drawAlignedTextLine(ctx, text, x, y, width, distributed) {
|
|
|
250
273
|
});
|
|
251
274
|
}
|
|
252
275
|
function resolveTextFontFamily(family) {
|
|
253
|
-
|
|
254
|
-
if (!selected) return PRINT_DESIGN_DEFAULT_FONT_FAMILY;
|
|
255
|
-
if (/\bPrintDesignNotoSansSC\b/i.test(selected)) return selected;
|
|
256
|
-
if (!/(?:^|,)\s*['"]?Times New Roman['"]?(?:,|$)/i.test(selected) && !/(?:^|,)\s*serif\s*$/i.test(selected))
|
|
257
|
-
return selected;
|
|
258
|
-
const generic = /,\s*(sans-serif|serif|monospace|cursive|fantasy|system-ui)\s*$/i;
|
|
259
|
-
return generic.test(selected) ? selected.replace(generic, ", PrintDesignNotoSansSC, $1") : `${selected}, PrintDesignNotoSansSC`;
|
|
276
|
+
return resolvePrintDesignFontFamily(family);
|
|
260
277
|
}
|
|
261
278
|
|
|
262
279
|
// src/plugins/text/layout/measure.ts
|
|
@@ -274,7 +291,7 @@ function createHtmlTextMeasure(element, fontSize, fallback) {
|
|
|
274
291
|
widths = /* @__PURE__ */ new Map();
|
|
275
292
|
widthCaches.set(ownerDocument, widths);
|
|
276
293
|
}
|
|
277
|
-
const font = `${element.fontWeight ?? "400"} ${fontSize}pt ${resolveTextFontFamily(element.fontFamily)}`;
|
|
294
|
+
const font = `${element.fontStyle ?? "normal"} ${element.fontWeight ?? "400"} ${fontSize}pt ${resolveTextFontFamily(element.fontFamily)}`;
|
|
278
295
|
let span;
|
|
279
296
|
return {
|
|
280
297
|
measure: (value) => {
|
|
@@ -305,6 +322,12 @@ function createHtmlTextMeasure(element, fontSize, fallback) {
|
|
|
305
322
|
dispose: () => span?.remove()
|
|
306
323
|
};
|
|
307
324
|
}
|
|
325
|
+
function resolveTextIndentMm(element, fontSizePt) {
|
|
326
|
+
if (!element.indentMode || element.indentMode === "none") return 0;
|
|
327
|
+
const value = Math.max(0, element.indentValue ?? 0);
|
|
328
|
+
if (!Number.isFinite(value)) return 0;
|
|
329
|
+
return element.indentUnit === "char" || !element.indentUnit ? value * fontSizePt * 25.4 / 72 : fromDisplayUnit(value, element.indentUnit);
|
|
330
|
+
}
|
|
308
331
|
|
|
309
332
|
// src/plugins/text/rendering/formatting.ts
|
|
310
333
|
function resolveTextFontSize(element, text) {
|
|
@@ -324,15 +347,15 @@ function ellipsizeTextLine(text, maxWidth, measure) {
|
|
|
324
347
|
|
|
325
348
|
// src/plugins/text/rendering/draw.ts
|
|
326
349
|
var loadedFonts = /* @__PURE__ */ new WeakMap();
|
|
327
|
-
var DEFAULT_TEXT_BASELINE_CORRECTION_RATIO = 0.05;
|
|
328
350
|
function prepareTextFont(element, signal) {
|
|
329
351
|
const family = element.fontFamily?.trim();
|
|
330
352
|
const source = element.fontSource?.trim();
|
|
331
353
|
if (!family || !source) return Promise.resolve();
|
|
332
354
|
if (typeof document === "undefined" || typeof FontFace === "undefined")
|
|
333
|
-
return Promise.
|
|
355
|
+
return Promise.resolve();
|
|
334
356
|
signal?.throwIfAborted();
|
|
335
|
-
const ready = ensureTextFont(element, document)
|
|
357
|
+
const ready = ensureTextFont(element, document).catch(() => {
|
|
358
|
+
});
|
|
336
359
|
if (!signal) return ready;
|
|
337
360
|
return new Promise((resolve, reject) => {
|
|
338
361
|
const onAbort = () => reject(signal.reason);
|
|
@@ -399,7 +422,7 @@ var drawTextElement = (element, context) => {
|
|
|
399
422
|
const resolvedFontSize = resolveTextFontSize(element, resolvedText);
|
|
400
423
|
const fontSize = resolvedFontSize * 25.4 * scale / 72;
|
|
401
424
|
ctx.fillStyle = element.color ?? "#1f2937";
|
|
402
|
-
ctx.font = `${element.fontWeight ?? "400"} ${fontSize}px ${resolveTextFontFamily(element.fontFamily)}`;
|
|
425
|
+
ctx.font = `${element.fontStyle ?? "normal"} ${element.fontWeight ?? "400"} ${fontSize}px ${resolveTextFontFamily(element.fontFamily)}`;
|
|
403
426
|
const expanded = element.textAlign === "justify" || element.textAlign === "distributed";
|
|
404
427
|
ctx.textAlign = expanded ? "left" : element.textAlign ?? "left";
|
|
405
428
|
ctx.textBaseline = "alphabetic";
|
|
@@ -414,7 +437,9 @@ var drawTextElement = (element, context) => {
|
|
|
414
437
|
align: element.textAlign === "left" || element.textAlign === "center" ? element.textAlign : "right",
|
|
415
438
|
verticalAlign: element.verticalAlign,
|
|
416
439
|
wrap: true,
|
|
417
|
-
ellipsis: element.heightOverflow === "ellipsis"
|
|
440
|
+
ellipsis: element.heightOverflow === "ellipsis",
|
|
441
|
+
indentMode: element.indentMode,
|
|
442
|
+
indent: resolveTextIndentMm(element, resolvedFontSize) * scale
|
|
418
443
|
}
|
|
419
444
|
);
|
|
420
445
|
return;
|
|
@@ -423,19 +448,31 @@ var drawTextElement = (element, context) => {
|
|
|
423
448
|
const fontMetrics = ctx.measureText?.("Hg");
|
|
424
449
|
const ascent = fontMetrics?.fontBoundingBoxAscent ?? fontSize * 0.8;
|
|
425
450
|
const descent = fontMetrics?.fontBoundingBoxDescent ?? fontSize * 0.2;
|
|
426
|
-
const
|
|
427
|
-
const regularNoto = element.fontFamily?.startsWith("PrintDesignNotoSansSC") && !/^(?:bold|[6-9]00)$/i.test(element.fontWeight ?? "400");
|
|
428
|
-
const baselineOffset = (lineHeight - ascent - descent) / 2 + ascent - (defaultFont || regularNoto ? fontSize * DEFAULT_TEXT_BASELINE_CORRECTION_RATIO : 0);
|
|
451
|
+
const baselineOffset = (lineHeight - ascent - descent) / 2 + ascent;
|
|
429
452
|
const measure = (text) => measureSpacedText(ctx, text);
|
|
430
|
-
|
|
453
|
+
const indentPx = resolveTextIndentMm(element, resolvedFontSize) * scale;
|
|
454
|
+
let lines = layoutSpacedText(ctx, resolvedText, width, element.prewrapped, {
|
|
455
|
+
mode: element.indentMode ?? "none",
|
|
456
|
+
value: indentPx
|
|
457
|
+
});
|
|
458
|
+
if (element.prewrappedIndents)
|
|
459
|
+
lines = lines.map((line, index) => ({
|
|
460
|
+
...line,
|
|
461
|
+
indent: (element.prewrappedIndents?.[index] ?? 0) * scale
|
|
462
|
+
}));
|
|
431
463
|
if (element.heightOverflow) {
|
|
432
464
|
const fit = Math.max(0, Math.floor(height / lineHeight));
|
|
433
465
|
if (lines.length > fit) {
|
|
434
466
|
lines = lines.slice(0, fit);
|
|
435
467
|
if (fit && element.heightOverflow === "ellipsis")
|
|
436
468
|
lines[fit - 1] = {
|
|
437
|
-
text: ellipsizeTextLine(
|
|
438
|
-
|
|
469
|
+
text: ellipsizeTextLine(
|
|
470
|
+
lines[fit - 1].text,
|
|
471
|
+
Math.max(1, width - (lines[fit - 1].indent ?? 0)),
|
|
472
|
+
measure
|
|
473
|
+
),
|
|
474
|
+
last: true,
|
|
475
|
+
indent: lines[fit - 1].indent
|
|
439
476
|
};
|
|
440
477
|
}
|
|
441
478
|
ctx.beginPath();
|
|
@@ -443,16 +480,22 @@ var drawTextElement = (element, context) => {
|
|
|
443
480
|
ctx.clip();
|
|
444
481
|
}
|
|
445
482
|
const verticalOffset = element.verticalAlign === "middle" ? Math.max(0, (height - lines.length * lineHeight) / 2) : element.verticalAlign === "bottom" ? Math.max(0, height - lines.length * lineHeight) : 0;
|
|
446
|
-
const textX = element.textAlign === "center" ? x + width / 2 : element.textAlign === "right" ? x + width : x;
|
|
447
483
|
lines.forEach((line, index) => {
|
|
448
484
|
const lineY = y + verticalOffset + index * lineHeight + baselineOffset;
|
|
485
|
+
const lineIndent = Math.min(
|
|
486
|
+
Math.max(0, line.indent ?? 0),
|
|
487
|
+
Math.max(0, width)
|
|
488
|
+
);
|
|
489
|
+
const lineLeft = x + lineIndent;
|
|
490
|
+
const lineWidth = Math.max(0, width - lineIndent);
|
|
491
|
+
const textX = element.textAlign === "center" ? lineLeft + lineWidth / 2 : element.textAlign === "right" ? x + width : lineLeft;
|
|
449
492
|
if (expanded && (element.textAlign === "distributed" || !line.last)) {
|
|
450
493
|
drawAlignedTextLine(
|
|
451
494
|
ctx,
|
|
452
495
|
line.text,
|
|
453
|
-
|
|
496
|
+
lineLeft,
|
|
454
497
|
lineY,
|
|
455
|
-
|
|
498
|
+
lineWidth,
|
|
456
499
|
element.textAlign === "distributed"
|
|
457
500
|
);
|
|
458
501
|
} else {
|
|
@@ -463,8 +506,8 @@ var drawTextElement = (element, context) => {
|
|
|
463
506
|
Math.max(0, Math.floor(element.underlineCount ?? 0))
|
|
464
507
|
);
|
|
465
508
|
if (!count || !line.text) return;
|
|
466
|
-
const textWidth = Math.min(
|
|
467
|
-
const left = expanded && (element.textAlign === "distributed" || !line.last) ?
|
|
509
|
+
const textWidth = Math.min(lineWidth, measure(line.text));
|
|
510
|
+
const left = expanded && (element.textAlign === "distributed" || !line.last) ? lineLeft : element.textAlign === "center" ? textX - textWidth / 2 : element.textAlign === "right" ? textX - textWidth : textX;
|
|
468
511
|
ctx.save();
|
|
469
512
|
ctx.strokeStyle = element.underlineColor ?? element.color ?? "#1f2937";
|
|
470
513
|
ctx.lineWidth = Math.max(0.5, (element.underlineWidth ?? 0.2) * scale);
|
|
@@ -515,13 +558,24 @@ function textMarkup(text, element, size = 14, color2 = "#1f2937") {
|
|
|
515
558
|
const weight = /^(?:[1-9]00|normal|bold)$/.test(
|
|
516
559
|
textElement?.fontWeight ?? "400"
|
|
517
560
|
) ? textElement?.fontWeight ?? "400" : "400";
|
|
561
|
+
const fontStyle = textElement?.fontStyle === "italic" ? "italic" : "normal";
|
|
518
562
|
const fontSize = textElement ? resolveTextFontSize(textElement, text) : cssNumber(size, 14);
|
|
519
|
-
if (textElement?.textDirection === "vertical")
|
|
520
|
-
|
|
563
|
+
if (textElement?.textDirection === "vertical") {
|
|
564
|
+
const indentMm2 = resolveTextIndentMm(textElement, fontSize);
|
|
565
|
+
const paragraphStyle = indentMm2 <= 0 ? "" : textElement.indentMode === "firstLine" ? `text-indent:${cssNumber(indentMm2, 0)}mm;` : `padding-top:${cssNumber(indentMm2, 0)}mm;text-indent:-${cssNumber(indentMm2, 0)}mm;box-sizing:border-box;`;
|
|
566
|
+
const content = indentMm2 > 0 ? text.split("\n").map(
|
|
567
|
+
(paragraph) => `<div style="${paragraphStyle}">${escapeHtml(paragraph) || "<br>"}</div>`
|
|
568
|
+
).join("") : escapeHtml(text);
|
|
569
|
+
return `<div class="pd-text" style="display:block;font:${fontStyle} ${weight} ${fontSize}pt ${escapeHtml(cssFont(resolveTextFontFamily(textElement.fontFamily)))};color:${cssColor(color2, "#1f2937")};writing-mode:vertical-rl;text-orientation:upright;white-space:pre-wrap;text-align:${vertical === "middle" ? "center" : vertical === "bottom" ? "end" : "start"};line-height:${cssNumber(textElement.lineHeight, 1.35)}">${content}</div>`;
|
|
570
|
+
}
|
|
571
|
+
const indentMm = textElement ? resolveTextIndentMm(textElement, fontSize) : 0;
|
|
572
|
+
const indentStyle = (lineIndex) => indentMm > 0 && textElement ? textElement.indentMode === "firstLine" ? lineIndex === 0 ? `text-indent:${cssNumber(indentMm, 0)}mm;` : "" : textElement.indentMode === "hanging" ? `padding-left:${cssNumber(indentMm, 0)}mm;text-indent:${`-${cssNumber(indentMm, 0)}mm` };box-sizing:border-box;` : "" : "";
|
|
521
573
|
const lines = textElement?.prewrapped ? text.split("\n").map(
|
|
522
|
-
(line) => `<div style="white-space:pre;overflow:hidden;flex:none"><span style="${underlineCss(textElement)}">${escapeHtml(line) || "<br>"}</span></div>`
|
|
574
|
+
(line, index) => `<div style="white-space:pre;overflow:hidden;flex:none${textElement.prewrappedIndents ? `;box-sizing:border-box;padding-left:${cssNumber(textElement.prewrappedIndents[index] ?? 0, 0)}mm` : ""}"><span style="${underlineCss(textElement)}">${escapeHtml(line) || "<br>"}</span></div>`
|
|
575
|
+
).join("") : indentMm > 0 ? text.split("\n").map(
|
|
576
|
+
(paragraph) => `<div style="min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;${indentStyle(0)}"><span style="${textElement ? underlineCss(textElement) : ""}">${escapeHtml(paragraph) || "<br>"}</span></div>`
|
|
523
577
|
).join("") : `<div style="min-width:0;white-space:pre-wrap;overflow-wrap:anywhere"><span style="${textElement ? underlineCss(textElement) : ""}">${escapeHtml(text)}</span></div>`;
|
|
524
|
-
return `<div class="pd-text" style="font:${weight} ${fontSize}pt ${escapeHtml(cssFont(resolveTextFontFamily(textElement?.fontFamily)))};color:${cssColor(color2, "#1f2937")};text-align:${align};line-height:${cssNumber(textElement?.lineHeight, 1.35)};justify-content:${vertical === "middle" ? "center" : vertical === "bottom" ? "flex-end" : "flex-start"}">${lines}</div>`;
|
|
578
|
+
return `<div class="pd-text" style="font:${fontStyle} ${weight} ${fontSize}pt ${escapeHtml(cssFont(resolveTextFontFamily(textElement?.fontFamily)))};color:${cssColor(color2, "#1f2937")};text-align:${align};line-height:${cssNumber(textElement?.lineHeight, 1.35)};justify-content:${vertical === "middle" ? "center" : vertical === "bottom" ? "flex-end" : "flex-start"}">${lines}</div>`;
|
|
525
579
|
}
|
|
526
580
|
function underlineCss(element) {
|
|
527
581
|
const count = Math.min(
|
|
@@ -556,6 +610,18 @@ function textFontCss(element) {
|
|
|
556
610
|
return `@font-face{font-family:${cssFont(element.fontFamily)};src:url("${source}")}`;
|
|
557
611
|
}
|
|
558
612
|
var PT_TO_MM = 25.4 / 72;
|
|
613
|
+
function layoutText(element, text, measure) {
|
|
614
|
+
if (element.prewrapped)
|
|
615
|
+
return text.split("\n").map((line, index) => ({
|
|
616
|
+
text: line,
|
|
617
|
+
last: true,
|
|
618
|
+
indent: element.prewrappedIndents?.[index] ?? 0
|
|
619
|
+
}));
|
|
620
|
+
return layoutAlignedText(text, element.width, measure, {
|
|
621
|
+
mode: element.indentMode ?? "none",
|
|
622
|
+
value: resolveTextIndentMm(element, resolveTextFontSize(element, text))
|
|
623
|
+
});
|
|
624
|
+
}
|
|
559
625
|
function paginateText(element, { data, startPage, startY, top, bottom, pageAt }) {
|
|
560
626
|
const text = element.dataConfig?.mode === "binding" ? element.text : resolveDesignText(element.text, data);
|
|
561
627
|
if (element.textDirection === "vertical") {
|
|
@@ -583,9 +649,7 @@ function paginateText(element, { data, startPage, startY, top, bottom, pageAt })
|
|
|
583
649
|
);
|
|
584
650
|
let lines;
|
|
585
651
|
try {
|
|
586
|
-
lines =
|
|
587
|
-
(line) => line.text
|
|
588
|
-
);
|
|
652
|
+
lines = layoutText(element, text, measurement.measure);
|
|
589
653
|
} finally {
|
|
590
654
|
measurement.dispose();
|
|
591
655
|
}
|
|
@@ -614,7 +678,8 @@ function paginateText(element, { data, startPage, startY, top, bottom, pageAt })
|
|
|
614
678
|
previewSourceId: element.previewSourceId ?? element.id,
|
|
615
679
|
y,
|
|
616
680
|
height,
|
|
617
|
-
text: chunk.join("\n"),
|
|
681
|
+
text: chunk.map((line) => line.text).join("\n"),
|
|
682
|
+
...element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? { prewrappedIndents: chunk.map((line) => line.indent ?? 0) } : {},
|
|
618
683
|
prewrapped: true,
|
|
619
684
|
verticalAlign: "top",
|
|
620
685
|
dataConfig: void 0
|
|
@@ -642,7 +707,11 @@ function prewrapText(element) {
|
|
|
642
707
|
(value) => estimateTextWidth(value, fontMm)
|
|
643
708
|
);
|
|
644
709
|
try {
|
|
645
|
-
|
|
710
|
+
const lines = layoutText(element, element.text, measurement.measure);
|
|
711
|
+
return {
|
|
712
|
+
text: lines.map((line) => line.text).join("\n"),
|
|
713
|
+
indents: element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? lines.map((line) => line.indent ?? 0) : void 0
|
|
714
|
+
};
|
|
646
715
|
} finally {
|
|
647
716
|
measurement.dispose();
|
|
648
717
|
}
|
|
@@ -655,12 +724,12 @@ function estimateTextHeight(element) {
|
|
|
655
724
|
(value) => estimateTextWidth(value, fontMm)
|
|
656
725
|
);
|
|
657
726
|
try {
|
|
658
|
-
return
|
|
727
|
+
return layoutText(element, element.text, measurement.measure).length * fontMm * (element.lineHeight ?? 1.35);
|
|
659
728
|
} finally {
|
|
660
729
|
measurement.dispose();
|
|
661
730
|
}
|
|
662
731
|
}
|
|
663
|
-
function
|
|
732
|
+
function truncateTextLayout(element, height, mode) {
|
|
664
733
|
const fontMm = Math.max(1, (element.fontSize ?? 14) * PT_TO_MM);
|
|
665
734
|
const lineMm = fontMm * (element.lineHeight ?? 1.35);
|
|
666
735
|
const measurement = createHtmlTextMeasure(
|
|
@@ -669,21 +738,21 @@ function truncateText(element, height, mode) {
|
|
|
669
738
|
(value) => estimateTextWidth(value, fontMm)
|
|
670
739
|
);
|
|
671
740
|
try {
|
|
672
|
-
const lines =
|
|
673
|
-
element.text,
|
|
674
|
-
element.width,
|
|
675
|
-
measurement.measure
|
|
676
|
-
);
|
|
741
|
+
const lines = layoutText(element, element.text, measurement.measure);
|
|
677
742
|
const fit = Math.max(0, Math.floor(height / lineMm));
|
|
678
|
-
|
|
679
|
-
const visible =
|
|
743
|
+
const visibleLines = lines.slice(0, fit);
|
|
744
|
+
const visible = visibleLines.map((line) => line.text);
|
|
680
745
|
if (fit && mode === "ellipsis")
|
|
681
746
|
visible[fit - 1] = ellipsizeTextLine(
|
|
682
747
|
visible[fit - 1],
|
|
683
|
-
element.width,
|
|
748
|
+
Math.max(1, element.width - (lines[fit - 1]?.indent ?? 0)),
|
|
684
749
|
measurement.measure
|
|
685
750
|
);
|
|
686
|
-
return
|
|
751
|
+
return {
|
|
752
|
+
text: visible.join("\n"),
|
|
753
|
+
indents: element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? visibleLines.map((line) => line.indent ?? 0) : void 0,
|
|
754
|
+
overflowed: lines.length > fit
|
|
755
|
+
};
|
|
687
756
|
} finally {
|
|
688
757
|
measurement.dispose();
|
|
689
758
|
}
|
|
@@ -713,11 +782,13 @@ function prepareTextPagination(element, data) {
|
|
|
713
782
|
};
|
|
714
783
|
if (element.textDirection === "vertical" || element.overflowPolicy === "split" || element.heightOverflow === "flow" && element.overflowPolicy !== "nextPage")
|
|
715
784
|
return prepared;
|
|
716
|
-
const
|
|
785
|
+
const wrapped = element.heightOverflow && element.heightOverflow !== "flow" ? truncateTextLayout(prepared, prepared.height, element.heightOverflow) : prewrapText(prepared);
|
|
786
|
+
return {
|
|
717
787
|
...prepared,
|
|
718
|
-
text:
|
|
719
|
-
|
|
720
|
-
|
|
788
|
+
text: wrapped.text,
|
|
789
|
+
...wrapped.indents ? { prewrappedIndents: wrapped.indents } : {},
|
|
790
|
+
prewrapped: true
|
|
791
|
+
};
|
|
721
792
|
}
|
|
722
793
|
function measureTextFlowHeight(element, data) {
|
|
723
794
|
if (element.heightOverflow && element.heightOverflow !== "flow")
|
|
@@ -726,7 +797,13 @@ function measureTextFlowHeight(element, data) {
|
|
|
726
797
|
return Math.max(prepared.height, estimateTextHeight(prepared));
|
|
727
798
|
}
|
|
728
799
|
function truncateTextOverflow(element, height, mode) {
|
|
729
|
-
|
|
800
|
+
const truncated = truncateTextLayout(element, height, mode);
|
|
801
|
+
return {
|
|
802
|
+
...element,
|
|
803
|
+
text: truncated.text,
|
|
804
|
+
prewrapped: true,
|
|
805
|
+
...truncated.indents ? { prewrappedIndents: truncated.indents } : {}
|
|
806
|
+
};
|
|
730
807
|
}
|
|
731
808
|
function registeredFieldBindingInfo(element, fields) {
|
|
732
809
|
const config = getPrintDesignElementDataConfig(element, fields);
|
|
@@ -799,14 +876,14 @@ function resolveTextFontSizeValue(value, defaultUnit = "mm") {
|
|
|
799
876
|
// src/plugins/text/data/binding.ts
|
|
800
877
|
function getTextBindingInfo(element) {
|
|
801
878
|
const content = registeredFieldBindingInfo(element, textDataFields);
|
|
802
|
-
const
|
|
879
|
+
const paths2 = [
|
|
803
880
|
...content.paths,
|
|
804
881
|
element.colorMode === "binding" ? element.colorPath : void 0,
|
|
805
882
|
element.fontSizeMode === "binding" ? element.fontSizePath : void 0
|
|
806
883
|
].filter((path) => !!path?.trim());
|
|
807
884
|
return {
|
|
808
885
|
bound: content.bound || element.colorMode === "binding" || element.fontSizeMode === "binding",
|
|
809
|
-
paths
|
|
886
|
+
paths: paths2
|
|
810
887
|
};
|
|
811
888
|
}
|
|
812
889
|
function missingExpressionPath(expression, data) {
|
|
@@ -866,7 +943,7 @@ function resolveTextData(element, data) {
|
|
|
866
943
|
// src/plugins/text/native.ts
|
|
867
944
|
var textNativePlugin = defineNativePlugin(
|
|
868
945
|
"text",
|
|
869
|
-
"0.1.
|
|
946
|
+
"0.1.38",
|
|
870
947
|
definePrintDesignPluginRenderer({
|
|
871
948
|
type: "text",
|
|
872
949
|
dataFields: textDataFields,
|
|
@@ -889,6 +966,268 @@ var textNativePlugin = defineNativePlugin(
|
|
|
889
966
|
inlineTextEditor: textInlineEditor
|
|
890
967
|
})
|
|
891
968
|
);
|
|
969
|
+
|
|
970
|
+
// src/plugins/rich-text/model.ts
|
|
971
|
+
function validateRichTextElement(value) {
|
|
972
|
+
if (!value || typeof value !== "object") return false;
|
|
973
|
+
const element = value;
|
|
974
|
+
return element.type === "richText" && (element.dataConfig === void 0 || element.dataConfig.mode === "static") && Array.isArray(element.runs) && element.runs.length <= 2e3 && element.runs.reduce(
|
|
975
|
+
(length, run) => length + (typeof run?.text === "string" ? run.text.length : 0),
|
|
976
|
+
0
|
|
977
|
+
) <= 1e5 && element.runs.every(
|
|
978
|
+
(run) => run && typeof run.text === "string" && run.text.length > 0 && Object.keys(run).every((key) => key === "text" || key === "style") && (run.style === void 0 || run.style && typeof run.style === "object" && !Array.isArray(run.style) && Object.keys(run.style).every(
|
|
979
|
+
(key) => ["fontFamily", "fontSize", "fontWeight", "fontStyle", "color"].includes(key)
|
|
980
|
+
) && (run.style.fontFamily === void 0 || typeof run.style.fontFamily === "string" && run.style.fontFamily.length <= 200 && /^[\p{L}\p{N}_\s,'"-]+$/u.test(run.style.fontFamily)) && (run.style.fontSize === void 0 || Number.isFinite(run.style.fontSize) && run.style.fontSize > 0 && run.style.fontSize <= 240) && (run.style.fontWeight === void 0 || typeof run.style.fontWeight === "string" && /^(?:[1-9]00|normal|bold)$/.test(run.style.fontWeight)) && (run.style.fontStyle === void 0 || ["normal", "italic"].includes(run.style.fontStyle)) && (run.style.color === void 0 || typeof run.style.color === "string" && /^#[0-9a-fA-F]{3,8}$/.test(run.style.color)))
|
|
981
|
+
) && (element.fontSize === void 0 || Number.isFinite(element.fontSize) && element.fontSize > 0 && element.fontSize <= 240) && (element.fontFamily === void 0 || typeof element.fontFamily === "string" && element.fontFamily.length <= 200 && /^[\p{L}\p{N}_\s,'"-]+$/u.test(element.fontFamily)) && (element.fontWeight === void 0 || typeof element.fontWeight === "string" && /^(?:[1-9]00|normal|bold)$/.test(element.fontWeight)) && (element.fontStyle === void 0 || ["normal", "italic"].includes(element.fontStyle)) && (element.color === void 0 || typeof element.color === "string" && /^#[0-9a-fA-F]{3,8}$/.test(element.color)) && (element.textAlign === void 0 || ["left", "center", "right"].includes(element.textAlign)) && (element.verticalAlign === void 0 || ["top", "middle", "bottom"].includes(element.verticalAlign)) && (element.lineHeight === void 0 || Number.isFinite(element.lineHeight) && element.lineHeight >= 0.5 && element.lineHeight <= 4) && (element.indentMode === void 0 || ["none", "firstLine", "hanging"].includes(element.indentMode)) && (element.indentValue === void 0 || Number.isFinite(element.indentValue) && element.indentValue >= 0) && (element.indentUnit === void 0 || ["char", "mm", "cm", "in", "pt", "px"].includes(element.indentUnit)) && (element.prewrapped === void 0 || typeof element.prewrapped === "boolean") && (element.prewrappedIndents === void 0 || Array.isArray(element.prewrappedIndents) && element.prewrappedIndents.every(
|
|
982
|
+
(indent) => Number.isFinite(indent) && indent >= 0
|
|
983
|
+
));
|
|
984
|
+
}
|
|
985
|
+
function richTextIndentMm(element) {
|
|
986
|
+
if (!element.indentMode || element.indentMode === "none") return 0;
|
|
987
|
+
const value = Math.max(0, element.indentValue ?? 0);
|
|
988
|
+
return element.indentUnit === "char" || !element.indentUnit ? value * (element.fontSize ?? 14) * 25.4 / 72 : fromDisplayUnit(value, element.indentUnit);
|
|
989
|
+
}
|
|
990
|
+
function richTextGraphemes(text) {
|
|
991
|
+
const Segmenter = Intl.Segmenter;
|
|
992
|
+
return Segmenter ? Array.from(
|
|
993
|
+
new Segmenter(void 0, { granularity: "grapheme" }).segment(text),
|
|
994
|
+
(part) => part.segment
|
|
995
|
+
) : Array.from(text);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// src/plugins/rich-text/rendering.ts
|
|
999
|
+
function runStyle(element, run) {
|
|
1000
|
+
return {
|
|
1001
|
+
fontFamily: resolvePrintDesignFontFamily(
|
|
1002
|
+
run.style?.fontFamily ?? element.fontFamily
|
|
1003
|
+
),
|
|
1004
|
+
fontSize: run.style?.fontSize ?? element.fontSize ?? 14,
|
|
1005
|
+
fontWeight: run.style?.fontWeight ?? element.fontWeight ?? "400",
|
|
1006
|
+
fontStyle: run.style?.fontStyle ?? element.fontStyle ?? "normal",
|
|
1007
|
+
color: run.style?.color ?? element.color ?? "#1f2937"
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
function layoutRichTextLines(element, width, scale, measure) {
|
|
1011
|
+
const indent = richTextIndentMm(element) * scale;
|
|
1012
|
+
const lineHeight = element.lineHeight ?? 1.35;
|
|
1013
|
+
const lines = [];
|
|
1014
|
+
let paragraphLine = 0;
|
|
1015
|
+
const addLine = () => {
|
|
1016
|
+
const inset = element.prewrapped ? (element.prewrappedIndents?.[lines.length] ?? 0) * scale : element.indentMode === "firstLine" && paragraphLine === 0 || element.indentMode === "hanging" && paragraphLine > 0 ? indent : 0;
|
|
1017
|
+
lines.push({
|
|
1018
|
+
chars: [],
|
|
1019
|
+
width: 0,
|
|
1020
|
+
indent: inset,
|
|
1021
|
+
height: (element.fontSize ?? 14) * 25.4 / 72 * scale * lineHeight
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
addLine();
|
|
1025
|
+
for (const run of element.runs) {
|
|
1026
|
+
const style = runStyle(element, run);
|
|
1027
|
+
const fontSize = style.fontSize * 25.4 / 72 * scale;
|
|
1028
|
+
for (const char of richTextGraphemes(run.text.replace(/\r\n?/g, "\n"))) {
|
|
1029
|
+
if (char === "\n") {
|
|
1030
|
+
paragraphLine = 0;
|
|
1031
|
+
addLine();
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
const charWidth = measure(char, style, fontSize);
|
|
1035
|
+
let line = lines[lines.length - 1];
|
|
1036
|
+
if (!element.prewrapped && line.chars.length && line.width + charWidth > Math.max(1, width - line.indent)) {
|
|
1037
|
+
paragraphLine++;
|
|
1038
|
+
addLine();
|
|
1039
|
+
line = lines[lines.length - 1];
|
|
1040
|
+
}
|
|
1041
|
+
line.chars.push({ text: char, width: charWidth, style });
|
|
1042
|
+
line.width += charWidth;
|
|
1043
|
+
line.height = Math.max(line.height, fontSize * lineHeight);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
return lines;
|
|
1047
|
+
}
|
|
1048
|
+
function drawRichTextElement(element, { ctx, scale, x, y, width, height }) {
|
|
1049
|
+
const lineHeight = element.lineHeight ?? 1.35;
|
|
1050
|
+
const lines = layoutRichTextLines(
|
|
1051
|
+
element,
|
|
1052
|
+
width,
|
|
1053
|
+
scale,
|
|
1054
|
+
(char, style, fontSize) => {
|
|
1055
|
+
ctx.font = `${style.fontStyle} ${style.fontWeight} ${fontSize}px ${style.fontFamily}`;
|
|
1056
|
+
return ctx.measureText(char).width;
|
|
1057
|
+
}
|
|
1058
|
+
);
|
|
1059
|
+
const totalHeight = lines.reduce((sum, line) => sum + line.height, 0);
|
|
1060
|
+
let top = y + (element.verticalAlign === "middle" ? Math.max(0, (height - totalHeight) / 2) : element.verticalAlign === "bottom" ? Math.max(0, height - totalHeight) : 0);
|
|
1061
|
+
ctx.save();
|
|
1062
|
+
ctx.beginPath();
|
|
1063
|
+
ctx.rect(x, y, width, height);
|
|
1064
|
+
ctx.clip();
|
|
1065
|
+
ctx.textAlign = "left";
|
|
1066
|
+
ctx.textBaseline = "alphabetic";
|
|
1067
|
+
for (const line of lines) {
|
|
1068
|
+
let left = x + line.indent;
|
|
1069
|
+
const available = Math.max(0, width - line.indent);
|
|
1070
|
+
if (element.textAlign === "center") left += (available - line.width) / 2;
|
|
1071
|
+
if (element.textAlign === "right") left += available - line.width;
|
|
1072
|
+
for (const char of line.chars) {
|
|
1073
|
+
const fontSize = char.style.fontSize * 25.4 / 72 * scale;
|
|
1074
|
+
ctx.font = `${char.style.fontStyle} ${char.style.fontWeight} ${fontSize}px ${char.style.fontFamily}`;
|
|
1075
|
+
ctx.fillStyle = char.style.color;
|
|
1076
|
+
ctx.fillText(
|
|
1077
|
+
char.text,
|
|
1078
|
+
left,
|
|
1079
|
+
top + (line.height - fontSize * lineHeight) / 2 + fontSize
|
|
1080
|
+
);
|
|
1081
|
+
left += char.width;
|
|
1082
|
+
}
|
|
1083
|
+
top += line.height;
|
|
1084
|
+
}
|
|
1085
|
+
ctx.restore();
|
|
1086
|
+
}
|
|
1087
|
+
function renderRichTextHtml(element) {
|
|
1088
|
+
const baseSize = cssNumber(element.fontSize, 14);
|
|
1089
|
+
const indent = richTextIndentMm(element);
|
|
1090
|
+
const paragraphs = [""];
|
|
1091
|
+
for (const run of element.runs) {
|
|
1092
|
+
const style = runStyle(element, run);
|
|
1093
|
+
const css = `font-family:${escapeHtml(cssFont(style.fontFamily))};font-size:${cssNumber(style.fontSize, baseSize)}pt;font-weight:${escapeHtml(style.fontWeight)};font-style:${style.fontStyle};color:${cssColor(style.color, "#1f2937")}`;
|
|
1094
|
+
const chunks = run.text.replace(/\r\n?/g, "\n").split("\n");
|
|
1095
|
+
chunks.forEach((chunk, index) => {
|
|
1096
|
+
if (index) paragraphs.push("");
|
|
1097
|
+
paragraphs[paragraphs.length - 1] += `<span style="${css}">${escapeHtml(chunk)}</span>`;
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
const paragraphCss = element.indentMode === "firstLine" && indent > 0 ? `text-indent:${cssNumber(indent, 0)}mm;` : element.indentMode === "hanging" && indent > 0 ? `padding-left:${cssNumber(indent, 0)}mm;text-indent:-${cssNumber(indent, 0)}mm;box-sizing:border-box;` : "";
|
|
1101
|
+
const body = paragraphs.map(
|
|
1102
|
+
(paragraph, index) => `<div style="${element.prewrapped ? `white-space:pre;overflow:hidden;flex:none;box-sizing:border-box;padding-left:${cssNumber(element.prewrappedIndents?.[index], 0)}mm;` : paragraphCss}">${paragraph || "<br>"}</div>`
|
|
1103
|
+
).join("");
|
|
1104
|
+
return renderPrintDesignHtmlFrame(
|
|
1105
|
+
element,
|
|
1106
|
+
`<div style="width:100%;height:100%;overflow:hidden;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-all;text-spacing-trim:space-all;text-autospace:no-autospace;line-height:${cssNumber(element.lineHeight, 1.35)};font-family:${escapeHtml(cssFont(element.fontFamily))};font-size:${baseSize}pt;font-weight:${escapeHtml(element.fontWeight ?? "400")};font-style:${element.fontStyle ?? "normal"};color:${cssColor(element.color, "#1f2937")};text-align:${element.textAlign ?? "left"};display:flex;flex-direction:column;justify-content:${element.verticalAlign === "middle" ? "center" : element.verticalAlign === "bottom" ? "flex-end" : "flex-start"}">${body}</div>`
|
|
1107
|
+
);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// src/plugins/rich-text/pagination.ts
|
|
1111
|
+
function measureLines(element) {
|
|
1112
|
+
const canvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
|
|
1113
|
+
const context = canvas?.getContext("2d");
|
|
1114
|
+
return layoutRichTextLines(element, element.width, 1, (text, style, size) => {
|
|
1115
|
+
if (context) {
|
|
1116
|
+
context.font = `${style.fontStyle} ${style.fontWeight} ${size}px ${style.fontFamily}`;
|
|
1117
|
+
return context.measureText(text).width;
|
|
1118
|
+
}
|
|
1119
|
+
return size * (/[^\p{ASCII}]/u.test(text) ? 1 : 0.55);
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
function linesToRuns(lines) {
|
|
1123
|
+
const result = [];
|
|
1124
|
+
for (const [index, line] of lines.entries()) {
|
|
1125
|
+
if (index) result.push({ text: "\n" });
|
|
1126
|
+
for (const char of line.chars) {
|
|
1127
|
+
const previous = result[result.length - 1];
|
|
1128
|
+
const style = char.style;
|
|
1129
|
+
if (previous && JSON.stringify(previous.style) === JSON.stringify(style))
|
|
1130
|
+
previous.text += char.text;
|
|
1131
|
+
else result.push({ text: char.text, style });
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
return result;
|
|
1135
|
+
}
|
|
1136
|
+
function truncateRichTextOverflow(element, height, mode) {
|
|
1137
|
+
const lines = measureLines(element);
|
|
1138
|
+
const visible = [];
|
|
1139
|
+
let used = 0;
|
|
1140
|
+
for (const line of lines) {
|
|
1141
|
+
if (visible.length && used + line.height > height) break;
|
|
1142
|
+
visible.push({ ...line, chars: [...line.chars] });
|
|
1143
|
+
used += line.height;
|
|
1144
|
+
}
|
|
1145
|
+
if (mode === "ellipsis" && visible.length < lines.length && visible.length) {
|
|
1146
|
+
const last = visible[visible.length - 1];
|
|
1147
|
+
const style = last.chars[last.chars.length - 1]?.style ?? {
|
|
1148
|
+
fontFamily: element.fontFamily ?? "Arial, sans-serif",
|
|
1149
|
+
fontSize: element.fontSize ?? 14,
|
|
1150
|
+
fontWeight: element.fontWeight ?? "400",
|
|
1151
|
+
fontStyle: element.fontStyle ?? "normal",
|
|
1152
|
+
color: element.color ?? "#1f2937"
|
|
1153
|
+
};
|
|
1154
|
+
const ellipsisWidth = style.fontSize * 25.4 / 72;
|
|
1155
|
+
while (last.chars.length && last.width + ellipsisWidth > element.width - last.indent) {
|
|
1156
|
+
last.width -= last.chars.pop().width;
|
|
1157
|
+
}
|
|
1158
|
+
last.chars.push({ text: "\u2026", style, width: ellipsisWidth });
|
|
1159
|
+
last.width += ellipsisWidth;
|
|
1160
|
+
}
|
|
1161
|
+
return {
|
|
1162
|
+
...element,
|
|
1163
|
+
runs: linesToRuns(visible),
|
|
1164
|
+
prewrapped: true,
|
|
1165
|
+
prewrappedIndents: visible.map((line) => line.indent),
|
|
1166
|
+
verticalAlign: "top"
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
function paginateRichText(element, context) {
|
|
1170
|
+
const lines = measureLines(element);
|
|
1171
|
+
let pageIndex = context.startPage;
|
|
1172
|
+
let y = context.startY;
|
|
1173
|
+
let offset = 0;
|
|
1174
|
+
do {
|
|
1175
|
+
const remaining = () => context.bottom - y;
|
|
1176
|
+
if (remaining() < (lines[offset]?.height ?? 0) && y > context.top) {
|
|
1177
|
+
pageIndex++;
|
|
1178
|
+
y = context.top;
|
|
1179
|
+
}
|
|
1180
|
+
const chunk = [];
|
|
1181
|
+
let height = 0;
|
|
1182
|
+
while (offset < lines.length && (!chunk.length || height + lines[offset].height <= remaining())) {
|
|
1183
|
+
chunk.push(lines[offset]);
|
|
1184
|
+
height += lines[offset].height;
|
|
1185
|
+
offset++;
|
|
1186
|
+
}
|
|
1187
|
+
const continues = offset < lines.length;
|
|
1188
|
+
const finalHeight = continues ? Math.max(0, remaining()) : Math.max(height, element.height);
|
|
1189
|
+
context.pageAt(pageIndex).elements.push({
|
|
1190
|
+
...element,
|
|
1191
|
+
id: `${element.id}:flow:${pageIndex}`,
|
|
1192
|
+
previewSourceId: element.previewSourceId ?? element.id,
|
|
1193
|
+
y,
|
|
1194
|
+
height: Math.min(Math.max(0, remaining()), finalHeight),
|
|
1195
|
+
runs: linesToRuns(chunk),
|
|
1196
|
+
prewrapped: true,
|
|
1197
|
+
prewrappedIndents: chunk.map((line) => line.indent),
|
|
1198
|
+
verticalAlign: "top"
|
|
1199
|
+
});
|
|
1200
|
+
y += Math.min(Math.max(0, remaining()), finalHeight);
|
|
1201
|
+
if (continues) {
|
|
1202
|
+
pageIndex++;
|
|
1203
|
+
y = context.top;
|
|
1204
|
+
}
|
|
1205
|
+
} while (offset < lines.length);
|
|
1206
|
+
return {
|
|
1207
|
+
logicalEnd: pageIndex * (context.bottom - context.top) + (y - context.top)
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
function measureRichTextFlowHeight(element) {
|
|
1211
|
+
return Math.max(
|
|
1212
|
+
element.height,
|
|
1213
|
+
measureLines(element).reduce((height, line) => height + line.height, 0)
|
|
1214
|
+
);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// src/plugins/rich-text/native.ts
|
|
1218
|
+
var richTextNativePlugin = defineNativePlugin(
|
|
1219
|
+
"richText",
|
|
1220
|
+
"0.1.1",
|
|
1221
|
+
definePrintDesignPluginRenderer({
|
|
1222
|
+
type: "richText",
|
|
1223
|
+
validate: validateRichTextElement,
|
|
1224
|
+
drawCanvas: drawRichTextElement,
|
|
1225
|
+
renderHtml: (element) => renderRichTextHtml(element),
|
|
1226
|
+
paginate: paginateRichText,
|
|
1227
|
+
measureFlowHeight: measureRichTextFlowHeight,
|
|
1228
|
+
truncateOverflow: truncateRichTextOverflow
|
|
1229
|
+
})
|
|
1230
|
+
);
|
|
892
1231
|
var drawListElement = (element, context) => {
|
|
893
1232
|
const { ctx, x, y, width, height, scale, data } = context;
|
|
894
1233
|
const row = Math.max(1, element.rowHeight ?? 8) * scale;
|
|
@@ -989,8 +1328,8 @@ function itemPaths(text) {
|
|
|
989
1328
|
return [...text.matchAll(LIST_EXPRESSION)].map((match) => match[1]);
|
|
990
1329
|
}
|
|
991
1330
|
function listBindingInfo(element) {
|
|
992
|
-
const
|
|
993
|
-
return { bound:
|
|
1331
|
+
const paths2 = [...new Set(element.items.flatMap((item) => itemPaths(item.text)))];
|
|
1332
|
+
return { bound: paths2.length > 0, paths: paths2 };
|
|
994
1333
|
}
|
|
995
1334
|
function validateListTemplateData(element, data) {
|
|
996
1335
|
if (!data) return [];
|
|
@@ -1001,13 +1340,45 @@ function validateListTemplateData(element, data) {
|
|
|
1001
1340
|
);
|
|
1002
1341
|
}
|
|
1003
1342
|
|
|
1343
|
+
// src/plugins/list/interaction/commands.ts
|
|
1344
|
+
var listCommands = {
|
|
1345
|
+
execute(element, command, payload) {
|
|
1346
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
1347
|
+
const args = payload;
|
|
1348
|
+
const index = args.index;
|
|
1349
|
+
if (!Number.isInteger(index)) return;
|
|
1350
|
+
const at = index;
|
|
1351
|
+
const items = [...element.items];
|
|
1352
|
+
if (command === "remove-item") {
|
|
1353
|
+
if (at < 0 || at >= items.length) return;
|
|
1354
|
+
items.splice(at, 1);
|
|
1355
|
+
} else if (command === "insert-item") {
|
|
1356
|
+
if (at < 0 || at > items.length || typeof args.text !== "string") return;
|
|
1357
|
+
items.splice(at, 0, { text: args.text, checked: false });
|
|
1358
|
+
} else if (command === "update-item") {
|
|
1359
|
+
if (at < 0 || at >= items.length) return;
|
|
1360
|
+
if (args.text !== void 0 && typeof args.text !== "string") return;
|
|
1361
|
+
if (args.checked !== void 0 && typeof args.checked !== "boolean")
|
|
1362
|
+
return;
|
|
1363
|
+
items[at] = {
|
|
1364
|
+
...items[at],
|
|
1365
|
+
...args.text === void 0 ? {} : { text: args.text },
|
|
1366
|
+
...args.checked === void 0 ? {} : { checked: args.checked }
|
|
1367
|
+
};
|
|
1368
|
+
} else return;
|
|
1369
|
+
const next = { ...element, items };
|
|
1370
|
+
return validateListElement(next) ? next : void 0;
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
|
|
1004
1374
|
// src/plugins/list/native.ts
|
|
1005
1375
|
var listNativePlugin = defineNativePlugin(
|
|
1006
1376
|
"list",
|
|
1007
|
-
"0.1.
|
|
1377
|
+
"0.1.9",
|
|
1008
1378
|
definePrintDesignPluginRenderer({
|
|
1009
1379
|
type: "list",
|
|
1010
1380
|
validate: validateListElement,
|
|
1381
|
+
commands: listCommands,
|
|
1011
1382
|
bindingInfo: listBindingInfo,
|
|
1012
1383
|
validateTemplateData: validateListTemplateData,
|
|
1013
1384
|
drawCanvas: drawListElement,
|
|
@@ -1073,9 +1444,9 @@ function dateTimeBindingInfo(element) {
|
|
|
1073
1444
|
}
|
|
1074
1445
|
function validateDateTimeTemplateData(element, data) {
|
|
1075
1446
|
if (!data) return [];
|
|
1076
|
-
const { bound, paths } = dateTimeBindingInfo(element);
|
|
1447
|
+
const { bound, paths: paths2 } = dateTimeBindingInfo(element);
|
|
1077
1448
|
if (!bound) return [];
|
|
1078
|
-
const expression =
|
|
1449
|
+
const expression = paths2[0];
|
|
1079
1450
|
if (!expression) return ["\u672A\u914D\u7F6E\u65E5\u671F\u65F6\u95F4\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
1080
1451
|
const value = resolvePrintDesignBinding(data, expression);
|
|
1081
1452
|
const text = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value).trim() : "";
|
|
@@ -1202,9 +1573,9 @@ function moneyUpperBindingInfo(element) {
|
|
|
1202
1573
|
}
|
|
1203
1574
|
function validateMoneyUpperTemplateData(element, data) {
|
|
1204
1575
|
if (!data) return [];
|
|
1205
|
-
const { bound, paths } = moneyUpperBindingInfo(element);
|
|
1576
|
+
const { bound, paths: paths2 } = moneyUpperBindingInfo(element);
|
|
1206
1577
|
if (!bound) return [];
|
|
1207
|
-
const expression =
|
|
1578
|
+
const expression = paths2[0];
|
|
1208
1579
|
if (!expression) return ["\u672A\u914D\u7F6E\u91D1\u989D\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
1209
1580
|
const value = resolvePrintDesignBinding(data, expression);
|
|
1210
1581
|
const numeric2 = typeof value === "number" || typeof value === "string" && value.trim() !== "" ? Number(value) : NaN;
|
|
@@ -1284,9 +1655,9 @@ function pageNumberBindingInfo(element) {
|
|
|
1284
1655
|
}
|
|
1285
1656
|
function validatePageNumberTemplateData(element, data) {
|
|
1286
1657
|
if (!data) return [];
|
|
1287
|
-
const { bound, paths } = pageNumberBindingInfo(element);
|
|
1658
|
+
const { bound, paths: paths2 } = pageNumberBindingInfo(element);
|
|
1288
1659
|
if (!bound) return [];
|
|
1289
|
-
const expression =
|
|
1660
|
+
const expression = paths2[0];
|
|
1290
1661
|
if (!expression) return ["\u672A\u914D\u7F6E\u9875\u7801\u524D\u7F00\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
1291
1662
|
const value = resolvePrintDesignBinding(data, expression);
|
|
1292
1663
|
return typeof value === "string" && value.trim() !== "" || typeof value === "number" || typeof value === "boolean" ? [] : [`\u7684\u9875\u7801\u524D\u7F00\u5B57\u6BB5\u300C${expression}\u300D\u5728\u5F53\u524D\u6570\u636E\u4E2D\u4E0D\u5B58\u5728`];
|
|
@@ -1388,23 +1759,18 @@ function renderWatermarkHtml(element, data, preciseClip = false) {
|
|
|
1388
1759
|
const text = escapeHtml(
|
|
1389
1760
|
element.dataConfig ? element.text : resolveDesignText(element.text, data)
|
|
1390
1761
|
);
|
|
1391
|
-
if (!preciseClip) {
|
|
1392
|
-
const fontSize2 = cssNumber(element.fontSize, 24);
|
|
1393
|
-
const cell = `<span style="color:${cssColor(element.color, "#94a3b8")};font-size:${fontSize2}pt;transform:rotate(${cssNumber(element.textRotation, 45)}deg) translateY(-${fontSize2 * DEFAULT_TEXT_BASELINE_CORRECTION_RATIO}pt)">${text}</span>`;
|
|
1394
|
-
const content2 = `<div class="pd-watermark" style="grid-template-columns:repeat(${columns},1fr);grid-template-rows:repeat(${rows},1fr)">${cell.repeat(rows * columns)}</div>`;
|
|
1395
|
-
return renderPrintDesignHtmlFrame(element, content2);
|
|
1396
|
-
}
|
|
1397
1762
|
const width = Math.max(0, element.width);
|
|
1398
1763
|
const height = Math.max(0, element.height);
|
|
1399
1764
|
const fontSize = cssNumber(element.fontSize, 24) * 25.4 / 72;
|
|
1400
1765
|
const color2 = cssColor(element.color, "#94a3b8");
|
|
1401
1766
|
const rotation = cssNumber(element.textRotation, 45);
|
|
1767
|
+
const baselineFactor = preciseClip ? 0.3 : 0.39;
|
|
1402
1768
|
const cells = Array.from({ length: rows * columns }, (_, index) => {
|
|
1403
1769
|
const centerX = (index % columns + 0.5) * (width / columns);
|
|
1404
1770
|
const centerY = (Math.floor(index / columns) + 0.5) * (height / rows);
|
|
1405
|
-
return `<text x="${centerX}" y="${centerY + fontSize *
|
|
1771
|
+
return `<text x="${centerX}" y="${centerY + fontSize * baselineFactor}" text-anchor="middle" transform="rotate(${rotation} ${centerX} ${centerY})">${text}</text>`;
|
|
1406
1772
|
}).join("");
|
|
1407
|
-
const content = `<svg class="pd-watermark" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none" font-size="${fontSize}" font-family="${escapeHtml(PRINT_DESIGN_DEFAULT_FONT_FAMILY)}" fill="${color2}" style="display:block;width:100%;height:100%;overflow:hidden">${cells}</svg>`;
|
|
1773
|
+
const content = `<svg class="pd-watermark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none" font-size="${fontSize}" font-family="${escapeHtml(PRINT_DESIGN_DEFAULT_FONT_FAMILY)}" fill="${color2}" style="display:block;width:100%;height:100%;overflow:hidden">${cells}</svg>`;
|
|
1408
1774
|
return renderPrintDesignHtmlFrame(element, content);
|
|
1409
1775
|
}
|
|
1410
1776
|
|
|
@@ -1429,9 +1795,9 @@ function watermarkBindingInfo(element) {
|
|
|
1429
1795
|
}
|
|
1430
1796
|
function validateWatermarkTemplateData(element, data) {
|
|
1431
1797
|
if (!data) return [];
|
|
1432
|
-
const { bound, paths } = watermarkBindingInfo(element);
|
|
1798
|
+
const { bound, paths: paths2 } = watermarkBindingInfo(element);
|
|
1433
1799
|
if (!bound) return [];
|
|
1434
|
-
const expression =
|
|
1800
|
+
const expression = paths2[0];
|
|
1435
1801
|
if (!expression) return ["\u672A\u914D\u7F6E\u6C34\u5370\u6587\u5B57\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
1436
1802
|
for (const match of expression.matchAll(
|
|
1437
1803
|
/\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
|
|
@@ -1446,7 +1812,7 @@ function validateWatermarkTemplateData(element, data) {
|
|
|
1446
1812
|
// src/plugins/watermark/native.ts
|
|
1447
1813
|
var watermarkNativePlugin = defineNativePlugin(
|
|
1448
1814
|
"watermark",
|
|
1449
|
-
"0.1.
|
|
1815
|
+
"0.1.10",
|
|
1450
1816
|
definePrintDesignPluginRenderer({
|
|
1451
1817
|
type: "watermark",
|
|
1452
1818
|
validate: validateWatermarkElement,
|
|
@@ -1466,8 +1832,7 @@ var watermarkNativePlugin = defineNativePlugin(
|
|
|
1466
1832
|
physical && physical.y + physical.height > context.page.height
|
|
1467
1833
|
)
|
|
1468
1834
|
);
|
|
1469
|
-
}
|
|
1470
|
-
htmlCss: ".pd-watermark{display:grid;overflow:hidden;width:100%;height:100%}.pd-watermark span{display:flex;align-items:center;justify-content:center;white-space:nowrap}"
|
|
1835
|
+
}
|
|
1471
1836
|
}),
|
|
1472
1837
|
[{ id: "builtin.text", minVersion: "0.1.16" }]
|
|
1473
1838
|
);
|
|
@@ -2655,16 +3020,51 @@ function pointToSegmentDistance(point, a, b) {
|
|
|
2655
3020
|
return Math.hypot(point.x - a.x - t * dx, point.y - a.y - t * dy);
|
|
2656
3021
|
}
|
|
2657
3022
|
|
|
3023
|
+
// src/plugins/shape/interaction/commands.ts
|
|
3024
|
+
var validPoints = (value) => Array.isArray(value) && value.every(
|
|
3025
|
+
(point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
3026
|
+
);
|
|
3027
|
+
var shapeCommands = {
|
|
3028
|
+
execute(element, command, payload) {
|
|
3029
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
3030
|
+
const args = payload;
|
|
3031
|
+
if (!validPoints(args.points)) return;
|
|
3032
|
+
const points = args.points;
|
|
3033
|
+
let next;
|
|
3034
|
+
if (command === "set-polygon-points") {
|
|
3035
|
+
if (!["triangle", "polygon", "star"].includes(element.shape) || points.length < 3)
|
|
3036
|
+
return;
|
|
3037
|
+
next = { ...element, polygonPoints: points };
|
|
3038
|
+
} else if (command === "set-curve-points") {
|
|
3039
|
+
if (!["curve-quadratic", "curve-cubic", "curve-multi"].includes(
|
|
3040
|
+
element.shape
|
|
3041
|
+
) || points.length < 2)
|
|
3042
|
+
return;
|
|
3043
|
+
next = { ...element, curvePoints: points };
|
|
3044
|
+
} else if (command === "set-path-points") {
|
|
3045
|
+
if (element.shape !== "curve-path") return;
|
|
3046
|
+
if (args.closed !== void 0 && typeof args.closed !== "boolean") return;
|
|
3047
|
+
next = {
|
|
3048
|
+
...element,
|
|
3049
|
+
pathPoints: points,
|
|
3050
|
+
...args.closed === void 0 ? {} : { pathClosed: args.closed }
|
|
3051
|
+
};
|
|
3052
|
+
} else return;
|
|
3053
|
+
return validateShapeElement(next) ? next : void 0;
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
|
|
2658
3057
|
// src/plugins/shape/native.ts
|
|
2659
3058
|
var shapeNativePlugin = defineNativePlugin(
|
|
2660
3059
|
"shape",
|
|
2661
|
-
"0.1.
|
|
3060
|
+
"0.1.21",
|
|
2662
3061
|
definePrintDesignPluginRenderer({
|
|
2663
3062
|
type: "shape",
|
|
2664
3063
|
dataFields: shapeDataFields,
|
|
2665
3064
|
bindingInfo: (element) => registeredFieldBindingInfo(element, shapeDataFields),
|
|
2666
3065
|
validateTemplateData: (element, data) => validateRegisteredFieldBindings(element, shapeDataFields, data),
|
|
2667
3066
|
validate: validateShapeElement,
|
|
3067
|
+
commands: shapeCommands,
|
|
2668
3068
|
drawCanvas: drawShapeElement,
|
|
2669
3069
|
renderHtml: (element, context) => renderShapeHtml(element, context.data),
|
|
2670
3070
|
hitTest: hitShape,
|
|
@@ -3006,13 +3406,42 @@ var brushPointerStroke = {
|
|
|
3006
3406
|
}
|
|
3007
3407
|
};
|
|
3008
3408
|
|
|
3409
|
+
// src/plugins/brush/interaction/commands.ts
|
|
3410
|
+
var brushCommands = {
|
|
3411
|
+
execute(element, command, payload) {
|
|
3412
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
3413
|
+
const args = payload;
|
|
3414
|
+
if (command === "append-stroke") {
|
|
3415
|
+
if (!Array.isArray(args.points) || args.points.length < 2) return;
|
|
3416
|
+
const next2 = {
|
|
3417
|
+
...element,
|
|
3418
|
+
strokes: [
|
|
3419
|
+
...element.strokes,
|
|
3420
|
+
args.points
|
|
3421
|
+
]
|
|
3422
|
+
};
|
|
3423
|
+
return validateBrushElement(next2) ? next2 : void 0;
|
|
3424
|
+
}
|
|
3425
|
+
if (command !== "remove-stroke" || !Number.isInteger(args.index)) return;
|
|
3426
|
+
const index = args.index;
|
|
3427
|
+
if (index < 0 || index >= element.strokes.length) return;
|
|
3428
|
+
const next = {
|
|
3429
|
+
...element,
|
|
3430
|
+
strokes: element.strokes.filter((_, at) => at !== index),
|
|
3431
|
+
strokeStyles: element.strokeStyles?.filter((_, at) => at !== index)
|
|
3432
|
+
};
|
|
3433
|
+
return validateBrushElement(next) ? next : void 0;
|
|
3434
|
+
}
|
|
3435
|
+
};
|
|
3436
|
+
|
|
3009
3437
|
// src/plugins/brush/native.ts
|
|
3010
3438
|
var brushNativePlugin = defineNativePlugin(
|
|
3011
3439
|
"brush",
|
|
3012
|
-
"0.1.
|
|
3440
|
+
"0.1.5",
|
|
3013
3441
|
definePrintDesignPluginRenderer({
|
|
3014
3442
|
type: "brush",
|
|
3015
3443
|
validate: validateBrushElement,
|
|
3444
|
+
commands: brushCommands,
|
|
3016
3445
|
drawCanvas: drawBrushElement,
|
|
3017
3446
|
renderHtml: (element) => renderBrushHtml(element),
|
|
3018
3447
|
hitTest: hitBrush,
|
|
@@ -4008,6 +4437,46 @@ function validateConnectorElement(value) {
|
|
|
4008
4437
|
const validPoint = (point) => !!point && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
4009
4438
|
return element.type === "connector" && (element.lineType === void 0 || ["straight", "curve", "polyline"].includes(element.lineType)) && (element.polylinePoints === void 0 || Array.isArray(element.polylinePoints) && element.polylinePoints.every(validPoint)) && (element.strokeWidth === void 0 || Number.isFinite(element.strokeWidth) && element.strokeWidth >= 0) && (element.textPosition === void 0 || Number.isFinite(element.textPosition) && element.textPosition >= 0 && element.textPosition <= 1);
|
|
4010
4439
|
}
|
|
4440
|
+
|
|
4441
|
+
// src/plugins/connector/interaction/commands.ts
|
|
4442
|
+
var validEndpoint = (value) => {
|
|
4443
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4444
|
+
const endpoint2 = value;
|
|
4445
|
+
return (endpoint2.elementId === void 0 || typeof endpoint2.elementId === "string") && (endpoint2.anchor === void 0 || typeof endpoint2.anchor === "string" && ([
|
|
4446
|
+
"auto",
|
|
4447
|
+
"top",
|
|
4448
|
+
"right",
|
|
4449
|
+
"bottom",
|
|
4450
|
+
"left",
|
|
4451
|
+
"top-left",
|
|
4452
|
+
"top-right",
|
|
4453
|
+
"bottom-right",
|
|
4454
|
+
"bottom-left"
|
|
4455
|
+
].includes(endpoint2.anchor) || /^(edge|vertex):\d+$/.test(endpoint2.anchor)));
|
|
4456
|
+
};
|
|
4457
|
+
var connectorCommands = {
|
|
4458
|
+
execute(element, command, payload) {
|
|
4459
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
4460
|
+
const args = payload;
|
|
4461
|
+
if (command === "set-endpoint") {
|
|
4462
|
+
if (args.side !== "start" && args.side !== "end") return;
|
|
4463
|
+
if (!validEndpoint(args.endpoint)) return;
|
|
4464
|
+
const next2 = { ...element, [args.side]: args.endpoint };
|
|
4465
|
+
return validateConnectorElement(next2) ? next2 : void 0;
|
|
4466
|
+
}
|
|
4467
|
+
if (command !== "set-waypoints" || element.lineType !== "polyline")
|
|
4468
|
+
return;
|
|
4469
|
+
if (!Array.isArray(args.points) || !args.points.every(
|
|
4470
|
+
(point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
4471
|
+
))
|
|
4472
|
+
return;
|
|
4473
|
+
const next = {
|
|
4474
|
+
...element,
|
|
4475
|
+
polylinePoints: args.points
|
|
4476
|
+
};
|
|
4477
|
+
return validateConnectorElement(next) ? next : void 0;
|
|
4478
|
+
}
|
|
4479
|
+
};
|
|
4011
4480
|
var CONNECTOR_EXPRESSION = /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g;
|
|
4012
4481
|
function labelPaths(element) {
|
|
4013
4482
|
return [...(element.text ?? "").matchAll(CONNECTOR_EXPRESSION)].map(
|
|
@@ -4015,8 +4484,8 @@ function labelPaths(element) {
|
|
|
4015
4484
|
);
|
|
4016
4485
|
}
|
|
4017
4486
|
function connectorBindingInfo(element) {
|
|
4018
|
-
const
|
|
4019
|
-
return { bound:
|
|
4487
|
+
const paths2 = [...new Set(labelPaths(element))];
|
|
4488
|
+
return { bound: paths2.length > 0, paths: paths2 };
|
|
4020
4489
|
}
|
|
4021
4490
|
function validateConnectorTemplateData(element, data) {
|
|
4022
4491
|
if (!data) return [];
|
|
@@ -4028,10 +4497,11 @@ function validateConnectorTemplateData(element, data) {
|
|
|
4028
4497
|
// src/plugins/connector/native.ts
|
|
4029
4498
|
var connectorNativePlugin = defineNativePlugin(
|
|
4030
4499
|
"connector",
|
|
4031
|
-
"0.1.
|
|
4500
|
+
"0.1.32",
|
|
4032
4501
|
definePrintDesignPluginRenderer({
|
|
4033
4502
|
type: "connector",
|
|
4034
4503
|
validate: validateConnectorElement,
|
|
4504
|
+
commands: connectorCommands,
|
|
4035
4505
|
bindingInfo: connectorBindingInfo,
|
|
4036
4506
|
validateTemplateData: validateConnectorTemplateData,
|
|
4037
4507
|
allowSignedSize: true,
|
|
@@ -4826,13 +5296,13 @@ function gridMarkup(element, data) {
|
|
|
4826
5296
|
|
|
4827
5297
|
// src/plugins/grid/data/binding.ts
|
|
4828
5298
|
function getGridBindingInfo(element) {
|
|
4829
|
-
const
|
|
5299
|
+
const paths2 = [
|
|
4830
5300
|
element.contentPath,
|
|
4831
5301
|
element.loopsPath,
|
|
4832
5302
|
element.columnLoopsPath,
|
|
4833
5303
|
...(element.cells ?? []).filter((cell) => cell.contentMode === "binding").map((cell) => cell.contentPath)
|
|
4834
5304
|
].map((path) => path?.trim()).filter((path) => !!path);
|
|
4835
|
-
return { bound:
|
|
5305
|
+
return { bound: paths2.length > 0, paths: paths2 };
|
|
4836
5306
|
}
|
|
4837
5307
|
function validateGridTemplateData(element, data) {
|
|
4838
5308
|
if (!data) return [];
|
|
@@ -4919,13 +5389,68 @@ function gridDebugRegions(element, context, hitElement = element) {
|
|
|
4919
5389
|
return [...cells, ...loops, ...columnLoops];
|
|
4920
5390
|
}
|
|
4921
5391
|
|
|
5392
|
+
// src/plugins/grid/interaction/commands.ts
|
|
5393
|
+
function executeGridCommand(element, command, payload, validate) {
|
|
5394
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
5395
|
+
const args = payload;
|
|
5396
|
+
if (command === "resize-grid") {
|
|
5397
|
+
const rows = args.rows;
|
|
5398
|
+
const columns = args.columns;
|
|
5399
|
+
if (!Number.isInteger(rows) || !Number.isInteger(columns)) return;
|
|
5400
|
+
if (rows < 1 || rows > 50 || columns < 1 || columns > 50)
|
|
5401
|
+
return;
|
|
5402
|
+
const cells2 = Array.from(
|
|
5403
|
+
{ length: rows * columns },
|
|
5404
|
+
(_, index2) => {
|
|
5405
|
+
const row = Math.floor(index2 / columns);
|
|
5406
|
+
const column = index2 % columns;
|
|
5407
|
+
return element.cells?.[row * element.columns + column] ?? {};
|
|
5408
|
+
}
|
|
5409
|
+
);
|
|
5410
|
+
const next2 = {
|
|
5411
|
+
...element,
|
|
5412
|
+
rows,
|
|
5413
|
+
columns,
|
|
5414
|
+
cells: cells2
|
|
5415
|
+
};
|
|
5416
|
+
return validate(next2) ? next2 : void 0;
|
|
5417
|
+
}
|
|
5418
|
+
if (command !== "set-cell") return;
|
|
5419
|
+
const rowIndex = args.rowIndex;
|
|
5420
|
+
const columnIndex = args.columnIndex;
|
|
5421
|
+
if (!Number.isInteger(rowIndex) || !Number.isInteger(columnIndex)) return;
|
|
5422
|
+
if (rowIndex < 0 || rowIndex >= element.rows || columnIndex < 0 || columnIndex >= element.columns)
|
|
5423
|
+
return;
|
|
5424
|
+
const cell = args.cell;
|
|
5425
|
+
if (!cell || typeof cell !== "object" || Array.isArray(cell)) return;
|
|
5426
|
+
const index = rowIndex * element.columns + columnIndex;
|
|
5427
|
+
const cells = Array.from(
|
|
5428
|
+
{ length: element.rows * element.columns },
|
|
5429
|
+
(_, at) => ({ ...element.cells?.[at] })
|
|
5430
|
+
);
|
|
5431
|
+
cells[index] = { ...cells[index], ...cell };
|
|
5432
|
+
const next = { ...element, cells };
|
|
5433
|
+
return validate(next) ? next : void 0;
|
|
5434
|
+
}
|
|
5435
|
+
var gridCommands = {
|
|
5436
|
+
execute(element, command, payload) {
|
|
5437
|
+
return executeGridCommand(
|
|
5438
|
+
element,
|
|
5439
|
+
command,
|
|
5440
|
+
payload,
|
|
5441
|
+
(value) => !!value && typeof value === "object" && value.type === "grid" && validateGridSettings(value)
|
|
5442
|
+
);
|
|
5443
|
+
}
|
|
5444
|
+
};
|
|
5445
|
+
|
|
4922
5446
|
// src/plugins/grid/native.ts
|
|
4923
5447
|
var gridNativePlugin = defineNativePlugin(
|
|
4924
5448
|
"grid",
|
|
4925
|
-
"0.1.
|
|
5449
|
+
"0.1.16",
|
|
4926
5450
|
definePrintDesignPluginRenderer({
|
|
4927
5451
|
type: "grid",
|
|
4928
5452
|
validate: validateGridElement,
|
|
5453
|
+
commands: gridCommands,
|
|
4929
5454
|
validateTemplateData: validateGridTemplateData,
|
|
4930
5455
|
bindingInfo: getGridBindingInfo,
|
|
4931
5456
|
drawCanvas: drawGridElement,
|
|
@@ -5236,10 +5761,18 @@ function coordinateDebugRegions(element, context) {
|
|
|
5236
5761
|
// src/plugins/coordinate/native.ts
|
|
5237
5762
|
var coordinateNativePlugin = defineNativePlugin(
|
|
5238
5763
|
"coordinate",
|
|
5239
|
-
"0.1.
|
|
5764
|
+
"0.1.16",
|
|
5240
5765
|
definePrintDesignPluginRenderer({
|
|
5241
5766
|
type: "coordinate",
|
|
5242
5767
|
validate: validateCoordinateElement,
|
|
5768
|
+
commands: {
|
|
5769
|
+
execute: (element, command, payload) => executeGridCommand(
|
|
5770
|
+
element,
|
|
5771
|
+
command,
|
|
5772
|
+
payload,
|
|
5773
|
+
validateCoordinateElement
|
|
5774
|
+
)
|
|
5775
|
+
},
|
|
5243
5776
|
validateTemplateData: validateGridTemplateData,
|
|
5244
5777
|
bindingInfo: getGridBindingInfo,
|
|
5245
5778
|
drawCanvas: drawCoordinateElement,
|
|
@@ -5736,17 +6269,48 @@ function validateFlowTemplateData(element, data) {
|
|
|
5736
6269
|
return [];
|
|
5737
6270
|
}
|
|
5738
6271
|
|
|
6272
|
+
// src/plugins/flow/interaction/commands.ts
|
|
6273
|
+
var flowCommands = {
|
|
6274
|
+
execute(element, command, payload) {
|
|
6275
|
+
if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
|
|
6276
|
+
return;
|
|
6277
|
+
const args = payload;
|
|
6278
|
+
const index = args.index;
|
|
6279
|
+
if (!Number.isInteger(index)) return;
|
|
6280
|
+
const at = index;
|
|
6281
|
+
if (command === "remove-item") {
|
|
6282
|
+
if (at < 0 || at >= element.items.length) return;
|
|
6283
|
+
return { ...element, items: element.items.filter((_, i) => i !== at) };
|
|
6284
|
+
}
|
|
6285
|
+
const item = args.item;
|
|
6286
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return;
|
|
6287
|
+
const items = [...element.items];
|
|
6288
|
+
if (command === "insert-item") {
|
|
6289
|
+
if (at < 0 || at > items.length) return;
|
|
6290
|
+
items.splice(at, 0, item);
|
|
6291
|
+
} else if (command === "update-item") {
|
|
6292
|
+
if (at < 0 || at >= items.length) return;
|
|
6293
|
+
items[at] = { ...items[at], ...item };
|
|
6294
|
+
} else return;
|
|
6295
|
+
const next = { ...element, items };
|
|
6296
|
+
return validateFlowElement(next) ? next : void 0;
|
|
6297
|
+
}
|
|
6298
|
+
};
|
|
6299
|
+
|
|
5739
6300
|
// src/plugins/flow/native.ts
|
|
5740
6301
|
var flowNativePlugin = defineNativePlugin(
|
|
5741
6302
|
"flow",
|
|
5742
|
-
"0.1.
|
|
6303
|
+
"0.1.7",
|
|
5743
6304
|
definePrintDesignPluginRenderer({
|
|
5744
6305
|
type: "flow",
|
|
5745
6306
|
validate: validateFlowElement,
|
|
6307
|
+
commands: flowCommands,
|
|
5746
6308
|
validateTemplateData: validateFlowTemplateData,
|
|
5747
6309
|
bindingInfo: (element) => ({
|
|
5748
6310
|
bound: (element.dataMode ?? element.dataConfig?.mode) === "binding",
|
|
5749
|
-
paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [
|
|
6311
|
+
paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [
|
|
6312
|
+
element.dataPath ?? element.dataConfig?.bindings?.items ?? ""
|
|
6313
|
+
].filter(Boolean) : []
|
|
5750
6314
|
}),
|
|
5751
6315
|
drawCanvas: drawFlowElement,
|
|
5752
6316
|
renderHtml: (element, context) => renderFlowHtml(element, context.data)
|
|
@@ -5986,9 +6550,9 @@ function clockBindingInfo(element) {
|
|
|
5986
6550
|
}
|
|
5987
6551
|
function validateClockTemplateData(element, data) {
|
|
5988
6552
|
if (!data) return [];
|
|
5989
|
-
const { bound, paths } = clockBindingInfo(element);
|
|
6553
|
+
const { bound, paths: paths2 } = clockBindingInfo(element);
|
|
5990
6554
|
if (!bound) return [];
|
|
5991
|
-
const expression =
|
|
6555
|
+
const expression = paths2[0];
|
|
5992
6556
|
if (!expression) return ["\u672A\u914D\u7F6E\u65F6\u949F\u65F6\u95F4\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
5993
6557
|
for (const match of expression.matchAll(
|
|
5994
6558
|
/\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
|
|
@@ -6227,9 +6791,9 @@ function imageBindingInfo(element) {
|
|
|
6227
6791
|
}
|
|
6228
6792
|
function validateImageTemplateData(element, data) {
|
|
6229
6793
|
if (!data) return [];
|
|
6230
|
-
const { bound, paths } = imageBindingInfo(element);
|
|
6794
|
+
const { bound, paths: paths2 } = imageBindingInfo(element);
|
|
6231
6795
|
if (!bound) return [];
|
|
6232
|
-
const expression =
|
|
6796
|
+
const expression = paths2[0];
|
|
6233
6797
|
if (!expression) return ["\u672A\u914D\u7F6E\u56FE\u7247\u5730\u5740\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
6234
6798
|
for (const match of expression.matchAll(
|
|
6235
6799
|
/\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
|
|
@@ -6462,6 +7026,19 @@ function fitImageToPage(image, page, current2) {
|
|
|
6462
7026
|
return { x, y, width, height };
|
|
6463
7027
|
}
|
|
6464
7028
|
|
|
7029
|
+
// src/plugins/image/interaction/commands.ts
|
|
7030
|
+
var imageCommands = {
|
|
7031
|
+
execute(element, command, payload) {
|
|
7032
|
+
if (element.locked) return;
|
|
7033
|
+
if (command === "clear-crop") return { ...element, crop: void 0 };
|
|
7034
|
+
if (command !== "set-crop" || !payload || typeof payload !== "object")
|
|
7035
|
+
return;
|
|
7036
|
+
const crop = payload;
|
|
7037
|
+
const next = { ...element, crop };
|
|
7038
|
+
return validateImageElement(next) ? next : void 0;
|
|
7039
|
+
}
|
|
7040
|
+
};
|
|
7041
|
+
|
|
6465
7042
|
// src/plugins/image/native.ts
|
|
6466
7043
|
var componentCropBehavior = {
|
|
6467
7044
|
source: (element) => element.src,
|
|
@@ -6482,7 +7059,7 @@ var componentCropBehavior = {
|
|
|
6482
7059
|
};
|
|
6483
7060
|
var imageNativePlugin = defineNativePlugin(
|
|
6484
7061
|
"image",
|
|
6485
|
-
"0.1.
|
|
7062
|
+
"0.1.17",
|
|
6486
7063
|
definePrintDesignPluginRenderer({
|
|
6487
7064
|
type: "image",
|
|
6488
7065
|
dataFields: imageDataFields,
|
|
@@ -6491,6 +7068,7 @@ var imageNativePlugin = defineNativePlugin(
|
|
|
6491
7068
|
replaceResourceUri: (element, uri, replacement) => element.src === uri ? { ...element, src: replacement } : element,
|
|
6492
7069
|
validateTemplateData: validateImageTemplateData,
|
|
6493
7070
|
validate: validateImageElement,
|
|
7071
|
+
commands: imageCommands,
|
|
6494
7072
|
drawCanvas: drawImageElement,
|
|
6495
7073
|
prepareCanvas: (element, { signal }) => prepareImage(element.src, signal),
|
|
6496
7074
|
needsCanvasPreparation: (element) => Boolean(element.src && !getLoadedImageSize(element.src)),
|
|
@@ -6569,9 +7147,9 @@ function barcodeBindingInfo(element) {
|
|
|
6569
7147
|
}
|
|
6570
7148
|
function validateBarcodeTemplateData(element, data) {
|
|
6571
7149
|
if (!data) return [];
|
|
6572
|
-
const { bound, paths } = barcodeBindingInfo(element);
|
|
7150
|
+
const { bound, paths: paths2 } = barcodeBindingInfo(element);
|
|
6573
7151
|
if (!bound) return [];
|
|
6574
|
-
const expression =
|
|
7152
|
+
const expression = paths2[0];
|
|
6575
7153
|
if (!expression) return ["\u672A\u914D\u7F6E\u6761\u5F62\u7801\u5185\u5BB9\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
6576
7154
|
for (const match of expression.matchAll(
|
|
6577
7155
|
/\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
|
|
@@ -6671,9 +7249,9 @@ function qrcodeBindingInfo(element) {
|
|
|
6671
7249
|
}
|
|
6672
7250
|
function validateQrCodeTemplateData(element, data) {
|
|
6673
7251
|
if (!data) return [];
|
|
6674
|
-
const { bound, paths } = qrcodeBindingInfo(element);
|
|
7252
|
+
const { bound, paths: paths2 } = qrcodeBindingInfo(element);
|
|
6675
7253
|
if (!bound) return [];
|
|
6676
|
-
const expression =
|
|
7254
|
+
const expression = paths2[0];
|
|
6677
7255
|
if (!expression) return ["\u672A\u914D\u7F6E\u4E8C\u7EF4\u7801\u5185\u5BB9\u7ED1\u5B9A\u5B57\u6BB5"];
|
|
6678
7256
|
for (const match of expression.matchAll(
|
|
6679
7257
|
/\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
|
|
@@ -6907,13 +7485,58 @@ function renderChartHtml(element, data) {
|
|
|
6907
7485
|
});
|
|
6908
7486
|
}
|
|
6909
7487
|
|
|
7488
|
+
// src/plugins/chart/interaction/commands.ts
|
|
7489
|
+
var chartCommands = {
|
|
7490
|
+
execute(element, command, payload) {
|
|
7491
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
7492
|
+
const args = payload;
|
|
7493
|
+
const chartData = readChartData(element);
|
|
7494
|
+
if (command === "set-categories") {
|
|
7495
|
+
if (!Array.isArray(args.categories) || !args.categories.every((item) => typeof item === "string"))
|
|
7496
|
+
return;
|
|
7497
|
+
const categories = args.categories;
|
|
7498
|
+
const next2 = {
|
|
7499
|
+
...element,
|
|
7500
|
+
chartData: {
|
|
7501
|
+
...chartData,
|
|
7502
|
+
categories,
|
|
7503
|
+
series: chartData.series.map((series2) => ({
|
|
7504
|
+
...series2,
|
|
7505
|
+
values: categories.map((_, index2) => series2.values[index2] ?? 0)
|
|
7506
|
+
}))
|
|
7507
|
+
}
|
|
7508
|
+
};
|
|
7509
|
+
return validateChartElement(next2) ? next2 : void 0;
|
|
7510
|
+
}
|
|
7511
|
+
if (command !== "set-series") return;
|
|
7512
|
+
const index = args.index;
|
|
7513
|
+
if (!Number.isInteger(index) || index < 0 || index > chartData.series.length)
|
|
7514
|
+
return;
|
|
7515
|
+
if (typeof args.name !== "string" || !Array.isArray(args.values) || args.values.length !== chartData.categories.length || !args.values.every(
|
|
7516
|
+
(value) => typeof value === "number" && Number.isFinite(value)
|
|
7517
|
+
))
|
|
7518
|
+
return;
|
|
7519
|
+
if (["pie", "gauge"].includes(element.chartType) && index > 0)
|
|
7520
|
+
return;
|
|
7521
|
+
const series = [...chartData.series];
|
|
7522
|
+
series[index] = {
|
|
7523
|
+
name: args.name,
|
|
7524
|
+
values: args.values,
|
|
7525
|
+
...typeof args.field === "string" ? { field: args.field } : {}
|
|
7526
|
+
};
|
|
7527
|
+
const next = { ...element, chartData: { ...chartData, series } };
|
|
7528
|
+
return validateChartElement(next) ? next : void 0;
|
|
7529
|
+
}
|
|
7530
|
+
};
|
|
7531
|
+
|
|
6910
7532
|
// src/plugins/chart/native.ts
|
|
6911
7533
|
var chartNativePlugin = defineNativePlugin(
|
|
6912
7534
|
"chart",
|
|
6913
|
-
"0.1.
|
|
7535
|
+
"0.1.9",
|
|
6914
7536
|
definePrintDesignPluginRenderer({
|
|
6915
7537
|
type: "chart",
|
|
6916
7538
|
validate: validateChartElement,
|
|
7539
|
+
commands: chartCommands,
|
|
6917
7540
|
validateTemplateData: validateChartTemplateData,
|
|
6918
7541
|
bindingInfo: (element) => ({
|
|
6919
7542
|
bound: element.chartData?.mode === "binding",
|
|
@@ -7554,7 +8177,7 @@ function resolveDiagonalCount(count) {
|
|
|
7554
8177
|
function diagonalCellLayout(direction, count, corner) {
|
|
7555
8178
|
const lineCount = resolveDiagonalCount(count);
|
|
7556
8179
|
const activeCorner = lineCount === 1 ? direction === "down" ? "top-left" : "bottom-left" : corner ?? (direction === "down" ? "top-left" : "bottom-left");
|
|
7557
|
-
const
|
|
8180
|
+
const paths2 = {
|
|
7558
8181
|
"top-left": [
|
|
7559
8182
|
[0, 0],
|
|
7560
8183
|
[1, 0],
|
|
@@ -7580,7 +8203,7 @@ function diagonalCellLayout(direction, count, corner) {
|
|
|
7580
8203
|
[0, 1]
|
|
7581
8204
|
]
|
|
7582
8205
|
};
|
|
7583
|
-
const [apex, first, bend, last] =
|
|
8206
|
+
const [apex, first, bend, last] = paths2[activeCorner];
|
|
7584
8207
|
const farPoint = (position) => position <= 1 ? [
|
|
7585
8208
|
first[0] + (bend[0] - first[0]) * position,
|
|
7586
8209
|
first[1] + (bend[1] - first[1]) * position
|
|
@@ -9116,6 +9739,10 @@ function hitTableColumnBoundary(element, point, scale, includeSelector = false,
|
|
|
9116
9739
|
}
|
|
9117
9740
|
return nearest;
|
|
9118
9741
|
}
|
|
9742
|
+
function boundaryHitRadius(height, scale, selector) {
|
|
9743
|
+
const radius = 5 / scale;
|
|
9744
|
+
return selector || height * scale >= 12 ? radius : Math.min(radius, height / 4);
|
|
9745
|
+
}
|
|
9119
9746
|
function unmergedBoundarySegments(element, rowIndex, merges) {
|
|
9120
9747
|
if (!merges.length) return [{ x: element.x + 3, width: element.width - 6 }];
|
|
9121
9748
|
const columns = tableLeafColumns(
|
|
@@ -9157,11 +9784,25 @@ function tableHeaderResizeLayout(element, scale, data = {}) {
|
|
|
9157
9784
|
for (let index = 0; index < depth; index++) {
|
|
9158
9785
|
const edge = element.y + (index + 1) * height;
|
|
9159
9786
|
if (edge > visibleBottom + 1e-9) break;
|
|
9160
|
-
const shared = { rowIndex: index, edge, height
|
|
9161
|
-
|
|
9787
|
+
const shared = { rowIndex: index, edge, height };
|
|
9788
|
+
const selectorRadius = boundaryHitRadius(height, scale, true);
|
|
9789
|
+
regions.push({
|
|
9790
|
+
...shared,
|
|
9791
|
+
x: element.x - 6,
|
|
9792
|
+
width: 6,
|
|
9793
|
+
selector: true,
|
|
9794
|
+
radius: selectorRadius,
|
|
9795
|
+
y: edge - selectorRadius
|
|
9796
|
+
});
|
|
9162
9797
|
if (edge < visibleBottom - 1e-9 && element.width > 6)
|
|
9163
9798
|
for (const segment of unmergedBoundarySegments(element, index, headers))
|
|
9164
|
-
regions.push({
|
|
9799
|
+
regions.push({
|
|
9800
|
+
...shared,
|
|
9801
|
+
...segment,
|
|
9802
|
+
selector: false,
|
|
9803
|
+
radius: boundaryHitRadius(height, scale, false),
|
|
9804
|
+
y: edge - boundaryHitRadius(height, scale, false)
|
|
9805
|
+
});
|
|
9165
9806
|
}
|
|
9166
9807
|
return regions;
|
|
9167
9808
|
}
|
|
@@ -9176,7 +9817,7 @@ function hitTableHeaderBoundary(element, point, scale, data = {}) {
|
|
|
9176
9817
|
-(element.rotation ?? 0) * Math.PI / 180
|
|
9177
9818
|
);
|
|
9178
9819
|
const region = tableHeaderResizeLayout(element, scale, data).filter(
|
|
9179
|
-
(item) => local.x >= item.x && local.x < item.x + item.width && local.y
|
|
9820
|
+
(item) => local.x >= item.x && local.x < item.x + item.width && Math.abs(local.y - item.edge) <= item.radius
|
|
9180
9821
|
).sort((a, b) => Math.abs(local.y - a.edge) - Math.abs(local.y - b.edge))[0];
|
|
9181
9822
|
return region && {
|
|
9182
9823
|
elementId: element.id,
|
|
@@ -9208,13 +9849,26 @@ function tableRowResizeLayout(element, scale, data = {}) {
|
|
|
9208
9849
|
const shared = {
|
|
9209
9850
|
rowIndex: index + (element.sourceRowOffset ?? 0),
|
|
9210
9851
|
edge: boundary,
|
|
9211
|
-
height
|
|
9212
|
-
y: boundary - 5 / scale
|
|
9852
|
+
height
|
|
9213
9853
|
};
|
|
9214
|
-
|
|
9854
|
+
const selectorRadius = boundaryHitRadius(height, scale, true);
|
|
9855
|
+
regions.push({
|
|
9856
|
+
...shared,
|
|
9857
|
+
x: element.x - 6,
|
|
9858
|
+
width: 6,
|
|
9859
|
+
selector: true,
|
|
9860
|
+
radius: selectorRadius,
|
|
9861
|
+
y: boundary - selectorRadius
|
|
9862
|
+
});
|
|
9215
9863
|
if (index < heights.length - 1 && element.width > 6)
|
|
9216
9864
|
for (const segment of unmergedBoundarySegments(element, index, cells))
|
|
9217
|
-
regions.push({
|
|
9865
|
+
regions.push({
|
|
9866
|
+
...shared,
|
|
9867
|
+
...segment,
|
|
9868
|
+
selector: false,
|
|
9869
|
+
radius: boundaryHitRadius(height, scale, false),
|
|
9870
|
+
y: boundary - boundaryHitRadius(height, scale, false)
|
|
9871
|
+
});
|
|
9218
9872
|
}
|
|
9219
9873
|
return regions;
|
|
9220
9874
|
}
|
|
@@ -9229,7 +9883,7 @@ function hitTableRowBoundary(element, point, scale, data = {}) {
|
|
|
9229
9883
|
-(element.rotation ?? 0) * Math.PI / 180
|
|
9230
9884
|
);
|
|
9231
9885
|
const region = tableRowResizeLayout(element, scale, data).filter(
|
|
9232
|
-
(item) => local.x >= item.x && local.x < item.x + item.width && local.y
|
|
9886
|
+
(item) => local.x >= item.x && local.x < item.x + item.width && Math.abs(local.y - item.edge) <= item.radius
|
|
9233
9887
|
).sort((a, b) => Math.abs(local.y - a.edge) - Math.abs(local.y - b.edge))[0];
|
|
9234
9888
|
return region && {
|
|
9235
9889
|
elementId: element.id,
|
|
@@ -9364,12 +10018,12 @@ function tableDebugRegions(table2, context, options = {}) {
|
|
|
9364
10018
|
...owner,
|
|
9365
10019
|
id: `${area}-resize:${index}`,
|
|
9366
10020
|
category: "resize",
|
|
9367
|
-
label: `${area === "header" ? `\u8868\u5934 H${region.rowIndex + 1}` : `\u884C ${region.rowIndex + 1}`} \u5E95\u7EBF \
|
|
10021
|
+
label: `${area === "header" ? `\u8868\u5934 H${region.rowIndex + 1}` : `\u884C ${region.rowIndex + 1}`} \u5E95\u7EBF \xB1${Math.round(region.radius * scale)}px${hit ? " \u547D\u4E2D" : ""}`,
|
|
9368
10022
|
bounds: {
|
|
9369
10023
|
x: region.x,
|
|
9370
10024
|
y: region.y,
|
|
9371
10025
|
width: region.width,
|
|
9372
|
-
height:
|
|
10026
|
+
height: region.radius * 2
|
|
9373
10027
|
},
|
|
9374
10028
|
interactive: true,
|
|
9375
10029
|
hit,
|
|
@@ -10359,37 +11013,253 @@ function emptyTableRow(element) {
|
|
|
10359
11013
|
);
|
|
10360
11014
|
}
|
|
10361
11015
|
|
|
10362
|
-
// src/plugins/table/
|
|
10363
|
-
|
|
10364
|
-
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
const
|
|
10371
|
-
|
|
10372
|
-
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
11016
|
+
// src/plugins/table/data/packed-report-defaults.ts
|
|
11017
|
+
function fillPackedReportDefaults(columns, rows, current2) {
|
|
11018
|
+
const visible = tableLeafColumns(columns).filter((column) => !column.hidden);
|
|
11019
|
+
const keys2 = visible.map(
|
|
11020
|
+
(column) => typeof column.dataIndex === "string" ? column.dataIndex : ""
|
|
11021
|
+
);
|
|
11022
|
+
const repeats = /* @__PURE__ */ new Map();
|
|
11023
|
+
keys2.forEach((key) => {
|
|
11024
|
+
const match = /^(.+?)([1-9]\d*)$/.exec(key);
|
|
11025
|
+
if (!match) return;
|
|
11026
|
+
const slots = repeats.get(match[1]) ?? /* @__PURE__ */ new Set();
|
|
11027
|
+
slots.add(Number(match[2]));
|
|
11028
|
+
repeats.set(match[1], slots);
|
|
11029
|
+
});
|
|
11030
|
+
const series = [...repeats].filter(
|
|
11031
|
+
([, slots]) => slots.has(1) && slots.has(2)
|
|
11032
|
+
);
|
|
11033
|
+
const itemsPerRow = Math.max(
|
|
11034
|
+
1,
|
|
11035
|
+
...series.map(([, slots]) => Math.max(...slots))
|
|
11036
|
+
);
|
|
11037
|
+
const sample = rows.find((row) => row && typeof row === "object") ?? {};
|
|
11038
|
+
const groupFields = {};
|
|
11039
|
+
keys2.forEach((key, index) => {
|
|
11040
|
+
const repeated = series.some(
|
|
11041
|
+
([prefix, slots]) => [...slots].some((slot) => key === `${prefix}${slot}`)
|
|
11042
|
+
);
|
|
11043
|
+
if (key && !repeated && !visible[index]?.summary && visible[index]?.summaryTitle == null) {
|
|
11044
|
+
groupFields[key] = key in sample ? key : "";
|
|
11045
|
+
}
|
|
11046
|
+
});
|
|
11047
|
+
const itemFields = series.map(([prefix]) => ({
|
|
11048
|
+
prefix,
|
|
11049
|
+
.../^(sequence|seq|index|序号)$/i.test(prefix) ? { mode: "index" } : { mode: "value", path: prefix in sample ? prefix : "" }
|
|
11050
|
+
}));
|
|
11051
|
+
const totals = {};
|
|
11052
|
+
visible.forEach((column, index) => {
|
|
11053
|
+
const key = keys2[index];
|
|
11054
|
+
const summary = column.summary;
|
|
11055
|
+
const type = typeof summary === "object" ? summary.type ?? "sum" : "sum";
|
|
11056
|
+
if (key && summary && type === "sum") {
|
|
11057
|
+
const prefix = series.find(
|
|
11058
|
+
([name, slots]) => [...slots].some((slot) => key === `${name}${slot}`)
|
|
11059
|
+
)?.[0];
|
|
11060
|
+
totals[key] = {
|
|
11061
|
+
sumPath: key in sample ? key : prefix && prefix in sample ? prefix : "",
|
|
11062
|
+
...typeof summary === "object" && summary.precision != null ? { decimals: summary.precision } : {}
|
|
11063
|
+
};
|
|
11064
|
+
}
|
|
11065
|
+
});
|
|
11066
|
+
const subtotalLabelKey = keys2.find(
|
|
11067
|
+
(key) => key && !(key in totals) && !(key in groupFields)
|
|
11068
|
+
);
|
|
11069
|
+
const totalLabelKey = keys2.find((key) => key && !(key in totals));
|
|
11070
|
+
const subtotal = { ...totals };
|
|
11071
|
+
if (subtotalLabelKey) subtotal[subtotalLabelKey] = { text: "\u5C0F\u8BA1" };
|
|
11072
|
+
if (totalLabelKey) totals[totalLabelKey] = { text: "\u603B\u8BA1" };
|
|
11073
|
+
return {
|
|
11074
|
+
groupBy: current2?.groupBy ?? [],
|
|
11075
|
+
itemsPerRow: current2?.itemsPerRow ?? itemsPerRow,
|
|
11076
|
+
groupFields: Object.keys(current2?.groupFields ?? {}).length ? current2.groupFields : groupFields,
|
|
11077
|
+
groupMergeColumns: Object.keys(current2?.groupFields ?? {}).length ? current2.groupMergeColumns : keys2.flatMap(
|
|
11078
|
+
(key, index) => key && key in groupFields ? [index] : []
|
|
11079
|
+
),
|
|
11080
|
+
itemFields: current2?.itemFields?.length ? current2.itemFields : itemFields,
|
|
11081
|
+
subtotal: Object.keys(current2?.subtotal ?? {}).length ? current2.subtotal : subtotal,
|
|
11082
|
+
subtotalMerges: current2?.subtotalMerges ?? [],
|
|
11083
|
+
total: Object.keys(current2?.total ?? {}).length ? current2.total : totals,
|
|
11084
|
+
totalMerges: current2?.totalMerges ?? [],
|
|
11085
|
+
appendRows: current2?.appendRows ?? [],
|
|
11086
|
+
...current2?.footerElementIds ? { footerElementIds: current2.footerElementIds } : {}
|
|
11087
|
+
};
|
|
11088
|
+
}
|
|
11089
|
+
|
|
11090
|
+
// src/plugins/table/interaction/agent-commands.ts
|
|
11091
|
+
function object(input) {
|
|
11092
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
11093
|
+
throw new TypeError("\u8868\u683C\u547D\u4EE4\u53C2\u6570\u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
|
|
11094
|
+
return input;
|
|
11095
|
+
}
|
|
11096
|
+
function safePart(value) {
|
|
11097
|
+
return !!value.trim() && !value.split(/[.[\]]/).some((part) => ["__proto__", "prototype", "constructor"].includes(part));
|
|
11098
|
+
}
|
|
11099
|
+
function fieldPath(input, label) {
|
|
11100
|
+
if (typeof input === "string" && safePart(input)) return input.trim();
|
|
11101
|
+
if (Array.isArray(input) && input.length > 0 && input.every(
|
|
11102
|
+
(part) => typeof part === "string" && safePart(part) || typeof part === "number" && Number.isInteger(part) && part >= 0
|
|
11103
|
+
))
|
|
11104
|
+
return input;
|
|
11105
|
+
throw new TypeError(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\u6216\u5B57\u6BB5\u8DEF\u5F84\u6570\u7EC4\u3002`);
|
|
11106
|
+
}
|
|
11107
|
+
function paths(input, label) {
|
|
11108
|
+
if (input === void 0) return [];
|
|
11109
|
+
if (!Array.isArray(input)) throw new TypeError(`${label} \u5FC5\u987B\u662F\u6570\u7EC4\u3002`);
|
|
11110
|
+
return input.map((value) => fieldPath(value, label));
|
|
11111
|
+
}
|
|
11112
|
+
function stringPaths(input, label) {
|
|
11113
|
+
if (!Array.isArray(input) || !input.length)
|
|
11114
|
+
throw new TypeError(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u8DEF\u5F84\u6570\u7EC4\u3002`);
|
|
11115
|
+
return input.map((value) => {
|
|
11116
|
+
if (typeof value !== "string" || !safePart(value))
|
|
11117
|
+
throw new TypeError(`${label} \u4E2D\u7684\u5B57\u6BB5\u8DEF\u5F84\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
11118
|
+
return value.trim();
|
|
11119
|
+
});
|
|
11120
|
+
}
|
|
11121
|
+
function configureTableAutoMerge(element, rawPayload) {
|
|
11122
|
+
const payload = object(rawPayload);
|
|
11123
|
+
if (payload.enabled === false) return { ...element, mergeCell: void 0 };
|
|
11124
|
+
const rowKeys = paths(payload.rowKeys, "rowKeys");
|
|
11125
|
+
const rowColumns = paths(payload.rowColumns, "rowColumns");
|
|
11126
|
+
const columnKeys = paths(payload.columnKeys, "columnKeys");
|
|
11127
|
+
if (!rowKeys.length && !columnKeys.length)
|
|
11128
|
+
throw new TypeError(
|
|
11129
|
+
"\u81F3\u5C11\u63D0\u4F9B rowKeys \u6216 columnKeys\uFF1B\u5173\u95ED\u65F6\u4F20 enabled=false\u3002"
|
|
11130
|
+
);
|
|
11131
|
+
if (rowColumns.length && !rowKeys.length)
|
|
11132
|
+
throw new TypeError("\u8BBE\u7F6E rowColumns \u65F6\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B rowKeys\u3002");
|
|
11133
|
+
const visible = tableLeafColumns(element.columns).filter((column) => !column.hidden).map((column) => JSON.stringify(column.dataIndex));
|
|
11134
|
+
for (const path of [
|
|
11135
|
+
...rowColumns.length ? rowColumns : rowKeys,
|
|
11136
|
+
...columnKeys
|
|
11137
|
+
])
|
|
11138
|
+
if (!visible.includes(JSON.stringify(path)))
|
|
11139
|
+
throw new TypeError(`\u5408\u5E76\u76EE\u6807\u5217\u4E0D\u5B58\u5728\uFF1A${JSON.stringify(path)}\u3002`);
|
|
11140
|
+
return {
|
|
11141
|
+
...element,
|
|
11142
|
+
mergeCell: {
|
|
11143
|
+
...rowKeys.length ? {
|
|
11144
|
+
row: {
|
|
11145
|
+
keys: rowKeys,
|
|
11146
|
+
...rowColumns.length ? { columns: rowColumns } : {}
|
|
11147
|
+
}
|
|
11148
|
+
} : {},
|
|
11149
|
+
...columnKeys.length ? { column: { keys: columnKeys } } : {}
|
|
11150
|
+
}
|
|
11151
|
+
};
|
|
11152
|
+
}
|
|
11153
|
+
function configureTableGroupAggregation(element, rawPayload, data) {
|
|
11154
|
+
const payload = object(rawPayload);
|
|
11155
|
+
if (payload.enabled === false) return { ...element, packedReport: void 0 };
|
|
11156
|
+
const groupBy = stringPaths(payload.groupBy, "groupBy");
|
|
11157
|
+
if (payload.itemsPerRow !== void 0 && (!Number.isInteger(payload.itemsPerRow) || Number(payload.itemsPerRow) < 1))
|
|
11158
|
+
throw new TypeError("itemsPerRow \u5FC5\u987B\u662F\u5927\u4E8E\u96F6\u7684\u6574\u6570\u3002");
|
|
11159
|
+
if (payload.sums !== void 0 && !Array.isArray(payload.sums))
|
|
11160
|
+
throw new TypeError("sums \u5FC5\u987B\u662F\u6570\u7EC4\u3002");
|
|
11161
|
+
const source = element.dataMode === "binding" ? resolveTableDataSource(data, element.dataPath) : element.dataSource;
|
|
11162
|
+
const rows = Array.isArray(source) ? source.filter(
|
|
11163
|
+
(row) => !!row && typeof row === "object" && !Array.isArray(row)
|
|
11164
|
+
) : element.dataSource;
|
|
11165
|
+
for (const path of groupBy)
|
|
11166
|
+
if (rows.length && !rows.some((row) => resolvePrintDesignDataPath(row, path) !== void 0))
|
|
11167
|
+
throw new TypeError(`\u5206\u7EC4\u5B57\u6BB5\u5728\u6570\u636E\u4E2D\u4E0D\u5B58\u5728\uFF1A${path}\u3002`);
|
|
11168
|
+
const report = fillPackedReportDefaults(
|
|
11169
|
+
element.columns,
|
|
11170
|
+
rows,
|
|
11171
|
+
element.packedReport
|
|
11172
|
+
);
|
|
11173
|
+
const visible = tableLeafColumns(element.columns).filter(
|
|
11174
|
+
(column) => !column.hidden
|
|
11175
|
+
);
|
|
11176
|
+
const groupFields = { ...report.groupFields };
|
|
11177
|
+
const subtotal = { ...report.subtotal };
|
|
11178
|
+
const total = { ...report.total };
|
|
11179
|
+
const sumColumns = /* @__PURE__ */ new Set();
|
|
11180
|
+
for (const raw of payload.sums ?? []) {
|
|
11181
|
+
const sum = object(raw);
|
|
11182
|
+
if (typeof sum.column !== "string" || !safePart(sum.column))
|
|
11183
|
+
throw new TypeError("sums.column \u5FC5\u987B\u662F\u8868\u683C\u5217\u7684 dataIndex \u5B57\u7B26\u4E32\u3002");
|
|
11184
|
+
const column = sum.column.trim();
|
|
11185
|
+
if (!visible.some((item) => item.dataIndex === column))
|
|
11186
|
+
throw new TypeError(`\u6C47\u603B\u5217\u4E0D\u5B58\u5728\uFF1A${column}\u3002`);
|
|
11187
|
+
if (sumColumns.has(column)) throw new TypeError(`\u6C47\u603B\u5217\u91CD\u590D\uFF1A${column}\u3002`);
|
|
11188
|
+
if (typeof sum.path !== "string" || !safePart(sum.path))
|
|
11189
|
+
throw new TypeError("sums.path \u5FC5\u987B\u662F\u539F\u59CB\u6570\u636E\u7684\u975E\u7A7A\u5B57\u6BB5\u8DEF\u5F84\u3002");
|
|
11190
|
+
if (rows.length && !rows.some(
|
|
11191
|
+
(row) => resolvePrintDesignDataPath(row, sum.path) !== void 0
|
|
11192
|
+
))
|
|
11193
|
+
throw new TypeError(`\u6C42\u548C\u5B57\u6BB5\u5728\u6570\u636E\u4E2D\u4E0D\u5B58\u5728\uFF1A${sum.path}\u3002`);
|
|
11194
|
+
if (sum.decimals !== void 0 && (!Number.isInteger(sum.decimals) || Number(sum.decimals) < 0 || Number(sum.decimals) > 10))
|
|
11195
|
+
throw new TypeError("sums.decimals \u5FC5\u987B\u662F 0 \u5230 10 \u7684\u6574\u6570\u3002");
|
|
11196
|
+
sumColumns.add(column);
|
|
11197
|
+
delete groupFields[column];
|
|
11198
|
+
const rule = {
|
|
11199
|
+
sumPath: sum.path.trim(),
|
|
11200
|
+
...sum.decimals === void 0 ? {} : { decimals: sum.decimals }
|
|
11201
|
+
};
|
|
11202
|
+
subtotal[column] = rule;
|
|
11203
|
+
total[column] = rule;
|
|
11204
|
+
}
|
|
11205
|
+
if (sumColumns.size && !Object.values(subtotal).some((rule) => rule.text === "\u5C0F\u8BA1")) {
|
|
11206
|
+
const labelColumn = visible.find(
|
|
11207
|
+
(column) => typeof column.dataIndex === "string" && !sumColumns.has(column.dataIndex)
|
|
11208
|
+
);
|
|
11209
|
+
if (typeof labelColumn?.dataIndex === "string")
|
|
11210
|
+
subtotal[labelColumn.dataIndex] = { text: "\u5C0F\u8BA1" };
|
|
11211
|
+
}
|
|
11212
|
+
return {
|
|
11213
|
+
...element,
|
|
11214
|
+
packedReport: {
|
|
11215
|
+
...report,
|
|
11216
|
+
groupBy,
|
|
11217
|
+
...payload.itemsPerRow === void 0 ? {} : { itemsPerRow: payload.itemsPerRow },
|
|
11218
|
+
groupFields,
|
|
11219
|
+
groupMergeColumns: report.groupMergeColumns.filter(
|
|
11220
|
+
(index) => !sumColumns.has(String(visible[index]?.dataIndex ?? ""))
|
|
11221
|
+
),
|
|
11222
|
+
subtotal,
|
|
11223
|
+
total
|
|
11224
|
+
}
|
|
11225
|
+
};
|
|
11226
|
+
}
|
|
11227
|
+
|
|
11228
|
+
// src/plugins/table/interaction/commands.ts
|
|
11229
|
+
var tableCommands = {
|
|
11230
|
+
execute(element, command, rawPayload, context) {
|
|
11231
|
+
if (element.locked) return;
|
|
11232
|
+
if (!rawPayload || typeof rawPayload !== "object") return;
|
|
11233
|
+
if (command === "configure-auto-merge")
|
|
11234
|
+
return configureTableAutoMerge(element, rawPayload);
|
|
11235
|
+
if (command === "configure-group-aggregation")
|
|
11236
|
+
return configureTableGroupAggregation(element, rawPayload, context.data);
|
|
11237
|
+
const payload = rawPayload;
|
|
11238
|
+
const rowIndex = payload.rowIndex ?? 0;
|
|
11239
|
+
const columnIndex = payload.columnIndex ?? 0;
|
|
11240
|
+
const rowSpan = payload.rowSpan ?? 1;
|
|
11241
|
+
const colSpan = payload.colSpan ?? 1;
|
|
11242
|
+
if (!Number.isInteger(rowIndex) || !Number.isInteger(columnIndex) || !Number.isInteger(rowSpan) || !Number.isInteger(colSpan))
|
|
11243
|
+
return;
|
|
11244
|
+
if (command === "merge-body") {
|
|
11245
|
+
const rows = resolveTableRows(element, context.data);
|
|
11246
|
+
const columns = tableLeafColumns(element.columns).filter(
|
|
11247
|
+
(column) => !column.hidden
|
|
11248
|
+
);
|
|
11249
|
+
if (rowIndex < 0 || columnIndex < 0 || rowSpan < 1 || colSpan < 1 || rowIndex + rowSpan > rows.length || columnIndex + colSpan > columns.length)
|
|
11250
|
+
return;
|
|
11251
|
+
const blocked = Array.from(
|
|
11252
|
+
{ length: rowSpan },
|
|
11253
|
+
(_, row) => Array.from(
|
|
11254
|
+
{ length: colSpan },
|
|
11255
|
+
(_2, column) => coveringTableCell(
|
|
11256
|
+
element.cells,
|
|
11257
|
+
rowIndex + row,
|
|
11258
|
+
columnIndex + column
|
|
11259
|
+
)
|
|
11260
|
+
)
|
|
11261
|
+
).flat().some(
|
|
11262
|
+
(cell) => cell && (cell.rowIndex !== rowIndex || cell.columnIndex !== columnIndex) && ((cell.rowSpan ?? 1) > 1 || (cell.colSpan ?? 1) > 1)
|
|
10393
11263
|
);
|
|
10394
11264
|
if (blocked) return;
|
|
10395
11265
|
const previous = element.cells?.find(
|
|
@@ -10758,7 +11628,7 @@ function validateTableTemplateData(element, data) {
|
|
|
10758
11628
|
// src/plugins/table/native.ts
|
|
10759
11629
|
var tableNativePlugin = defineNativePlugin(
|
|
10760
11630
|
"table",
|
|
10761
|
-
"0.1.
|
|
11631
|
+
"0.1.70",
|
|
10762
11632
|
definePrintDesignPluginRenderer({
|
|
10763
11633
|
type: "table",
|
|
10764
11634
|
validate: validateTableElement,
|
|
@@ -11091,6 +11961,41 @@ var pivotTableBoundaryResize = {
|
|
|
11091
11961
|
}
|
|
11092
11962
|
};
|
|
11093
11963
|
|
|
11964
|
+
// src/plugins/pivot-table/interaction/commands.ts
|
|
11965
|
+
var areas = ["filter", "column", "row", "value"];
|
|
11966
|
+
var pivotTableCommands = {
|
|
11967
|
+
execute(element, command, payload) {
|
|
11968
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
11969
|
+
const args = payload;
|
|
11970
|
+
const fieldKey = args.fieldKey;
|
|
11971
|
+
if (typeof fieldKey !== "string" || !element.fields.some((field) => field.key === fieldKey))
|
|
11972
|
+
return;
|
|
11973
|
+
if (command === "remove-field")
|
|
11974
|
+
return {
|
|
11975
|
+
...element,
|
|
11976
|
+
layout: removePivotField(element.layout, fieldKey)
|
|
11977
|
+
};
|
|
11978
|
+
if (command !== "move-field" || !areas.includes(args.area))
|
|
11979
|
+
return;
|
|
11980
|
+
const index = args.index;
|
|
11981
|
+
if (index !== void 0 && (!Number.isInteger(index) || index < 0))
|
|
11982
|
+
return;
|
|
11983
|
+
const sourceArea = args.sourceArea;
|
|
11984
|
+
if (sourceArea !== void 0 && !areas.includes(sourceArea))
|
|
11985
|
+
return;
|
|
11986
|
+
return {
|
|
11987
|
+
...element,
|
|
11988
|
+
layout: movePivotField(
|
|
11989
|
+
element.layout,
|
|
11990
|
+
fieldKey,
|
|
11991
|
+
args.area,
|
|
11992
|
+
index,
|
|
11993
|
+
sourceArea
|
|
11994
|
+
)
|
|
11995
|
+
};
|
|
11996
|
+
}
|
|
11997
|
+
};
|
|
11998
|
+
|
|
11094
11999
|
// src/plugins/pivot-table/model.ts
|
|
11095
12000
|
function validatePivotTableElement(value) {
|
|
11096
12001
|
if (!value || typeof value !== "object") return false;
|
|
@@ -11104,11 +12009,12 @@ function validatePivotTableElement(value) {
|
|
|
11104
12009
|
// src/plugins/pivot-table/native.ts
|
|
11105
12010
|
var pivotTableNativePlugin = defineNativePlugin(
|
|
11106
12011
|
"pivotTable",
|
|
11107
|
-
"0.1.
|
|
12012
|
+
"0.1.19",
|
|
11108
12013
|
definePrintDesignPluginRenderer({
|
|
11109
12014
|
type: "pivotTable",
|
|
11110
12015
|
htmlCss: tableHtmlCss,
|
|
11111
12016
|
validate: validatePivotTableElement,
|
|
12017
|
+
commands: pivotTableCommands,
|
|
11112
12018
|
validateTemplateData: validatePivotTemplateData,
|
|
11113
12019
|
bindingInfo: (element) => ({
|
|
11114
12020
|
bound: element.dataMode === "binding",
|
|
@@ -11619,13 +12525,49 @@ function ganttMarkup(element, data, pageNumber) {
|
|
|
11619
12525
|
return `<svg class="pd-media" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none"><rect width="${width}" height="${height}" fill="${cssColor(theme.backgroundColor, "transparent")}"/>${header > 0 ? `<rect width="${width}" height="${header}" fill="${cssColor(theme.headerBackgroundColor, "transparent")}"/>` : ""}${ticks}${taskSplit}${headerEdges}${headerTitle}${maskedDependencies}${bars}${frame}</svg>`;
|
|
11620
12526
|
}
|
|
11621
12527
|
|
|
12528
|
+
// src/plugins/gantt/interaction/commands.ts
|
|
12529
|
+
var ganttCommands = {
|
|
12530
|
+
execute(element, command, payload) {
|
|
12531
|
+
if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
|
|
12532
|
+
return;
|
|
12533
|
+
const args = payload;
|
|
12534
|
+
const tasks = [...element.tasks];
|
|
12535
|
+
if (command === "insert-task") {
|
|
12536
|
+
const index = args.index;
|
|
12537
|
+
if (!Number.isInteger(index) || index < 0 || index > tasks.length)
|
|
12538
|
+
return;
|
|
12539
|
+
if (!args.task || typeof args.task !== "object" || Array.isArray(args.task))
|
|
12540
|
+
return;
|
|
12541
|
+
const task = args.task;
|
|
12542
|
+
if (tasks.some((existing) => existing.id === task.id)) return;
|
|
12543
|
+
tasks.splice(index, 0, task);
|
|
12544
|
+
} else {
|
|
12545
|
+
const taskId = args.taskId;
|
|
12546
|
+
if (typeof taskId !== "string") return;
|
|
12547
|
+
const index = tasks.findIndex((task) => task.id === taskId);
|
|
12548
|
+
if (index < 0) return;
|
|
12549
|
+
if (command === "remove-task") tasks.splice(index, 1);
|
|
12550
|
+
else if (command === "update-task") {
|
|
12551
|
+
if (!args.patch || typeof args.patch !== "object" || Array.isArray(args.patch))
|
|
12552
|
+
return;
|
|
12553
|
+
const patch = args.patch;
|
|
12554
|
+
if (patch.id !== void 0 || patch.tasks !== void 0) return;
|
|
12555
|
+
tasks[index] = { ...tasks[index], ...patch };
|
|
12556
|
+
} else return;
|
|
12557
|
+
}
|
|
12558
|
+
const next = { ...element, tasks };
|
|
12559
|
+
return validateGanttElement(next) ? next : void 0;
|
|
12560
|
+
}
|
|
12561
|
+
};
|
|
12562
|
+
|
|
11622
12563
|
// src/plugins/gantt/native.ts
|
|
11623
12564
|
var ganttNativePlugin = defineNativePlugin(
|
|
11624
12565
|
"gantt",
|
|
11625
|
-
"0.1.
|
|
12566
|
+
"0.1.7",
|
|
11626
12567
|
definePrintDesignPluginRenderer({
|
|
11627
12568
|
type: "gantt",
|
|
11628
12569
|
validate: validateGanttElement,
|
|
12570
|
+
commands: ganttCommands,
|
|
11629
12571
|
validateTemplateData: validateGanttTemplateData,
|
|
11630
12572
|
bindingInfo: (element) => ({
|
|
11631
12573
|
bound: element.dataMode === "binding",
|
|
@@ -11639,6 +12581,7 @@ var ganttNativePlugin = defineNativePlugin(
|
|
|
11639
12581
|
// src/native.ts
|
|
11640
12582
|
var builtinNativeComponentPlugins = [
|
|
11641
12583
|
textNativePlugin,
|
|
12584
|
+
richTextNativePlugin,
|
|
11642
12585
|
listNativePlugin,
|
|
11643
12586
|
dateTimeNativePlugin,
|
|
11644
12587
|
moneyUpperNativePlugin,
|
|
@@ -11901,8 +12844,36 @@ var propertySections = [{
|
|
|
11901
12844
|
visibleWhen: (element) => element.type === "text" && Boolean(element.fontSource),
|
|
11902
12845
|
toPatch: () => ({ fontSource: "" })
|
|
11903
12846
|
},
|
|
11904
|
-
{ path: "fontWeight", label: "\
|
|
11905
|
-
{ path: "
|
|
12847
|
+
{ path: "fontWeight", label: "\u52A0\u7C97", kind: "select", defaultValue: "400", ariaLabel: "\u6587\u672C\u5B57\u91CD", options: FONT_WEIGHT_OPTIONS, fullWidth: false },
|
|
12848
|
+
{ path: "fontStyle", label: "\u503E\u659C", kind: "select", defaultValue: "normal", ariaLabel: "\u6587\u672C\u503E\u659C", fullWidth: false, options: [
|
|
12849
|
+
{ label: "\u5E38\u89C4", value: "normal" },
|
|
12850
|
+
{ label: "\u503E\u659C", value: "italic" }
|
|
12851
|
+
] },
|
|
12852
|
+
{ path: "lineHeight", label: "\u884C\u9AD8\u500D\u6570", kind: "number", defaultValue: 1.35, min: 0.5, max: 4, precision: 2, fullWidth: true, ariaLabel: "\u6587\u672C\u884C\u9AD8\u500D\u6570" },
|
|
12853
|
+
{ path: "indentMode", label: "\u7F29\u8FDB", kind: "select", defaultValue: "none", fullWidth: false, options: [
|
|
12854
|
+
{ label: "\u65E0", value: "none" },
|
|
12855
|
+
{ label: "\u9996\u884C\u7F29\u8FDB", value: "firstLine" },
|
|
12856
|
+
{ label: "\u60AC\u6302\u7F29\u8FDB", value: "hanging" }
|
|
12857
|
+
] },
|
|
12858
|
+
{
|
|
12859
|
+
path: "indentValue",
|
|
12860
|
+
label: "\u7F29\u8FDB\u5EA6\u91CF\u503C",
|
|
12861
|
+
kind: "number",
|
|
12862
|
+
defaultValue: 0,
|
|
12863
|
+
min: 0,
|
|
12864
|
+
max: 1e4,
|
|
12865
|
+
precision: 2,
|
|
12866
|
+
fullWidth: false,
|
|
12867
|
+
unitSelector: { path: "indentUnit", label: "\u7F29\u8FDB\u5355\u4F4D", defaultValue: "char", options: [
|
|
12868
|
+
{ label: "\u5B57\u7B26", value: "char" },
|
|
12869
|
+
{ label: "mm", value: "mm" },
|
|
12870
|
+
{ label: "cm", value: "cm" },
|
|
12871
|
+
{ label: "in", value: "in" },
|
|
12872
|
+
{ label: "pt", value: "pt" },
|
|
12873
|
+
{ label: "px", value: "px" }
|
|
12874
|
+
] },
|
|
12875
|
+
visibleWhen: (element) => element.type === "text" && element.indentMode !== void 0 && element.indentMode !== "none"
|
|
12876
|
+
},
|
|
11906
12877
|
{ path: "heightOverflow", label: "\u8D85\u51FA\u56FA\u5B9A\u9AD8\u5EA6", kind: "select", defaultValue: "flow", ariaLabel: "\u6587\u672C\u8D85\u51FA\u56FA\u5B9A\u9AD8\u5EA6\u5904\u7406\u65B9\u5F0F", options: TEXT_OVERFLOW_OPTIONS },
|
|
11907
12878
|
{ path: "underlineCount", label: "\u4E0B\u5212\u7EBF\u6761\u6570", kind: "number", defaultValue: 0, min: 0, max: 5, precision: 0, ariaLabel: "\u4E0B\u5212\u7EBF\u6761\u6570" },
|
|
11908
12879
|
{ path: "underlineStyle", label: "\u4E0B\u5212\u7EBF\u7EBF\u578B", kind: "select", defaultValue: "solid", ariaLabel: "\u4E0B\u5212\u7EBF\u7EBF\u578B", options: UNDERLINE_STYLE_OPTIONS },
|
|
@@ -11941,11 +12912,178 @@ var textPlugin = defineBuiltinReactPlugin(textNativePlugin, {
|
|
|
11941
12912
|
menuGroups,
|
|
11942
12913
|
propertySections
|
|
11943
12914
|
});
|
|
12915
|
+
function RichTextInlineEditor(props) {
|
|
12916
|
+
const [runs, setRuns] = useState(props.element.runs);
|
|
12917
|
+
const runsRef = useRef(runs);
|
|
12918
|
+
runsRef.current = runs;
|
|
12919
|
+
const editorRef = useRef(null);
|
|
12920
|
+
const overlayRef = useRef(null);
|
|
12921
|
+
const finishedRef = useRef(false);
|
|
12922
|
+
const finish = (commit) => {
|
|
12923
|
+
if (finishedRef.current) return;
|
|
12924
|
+
finishedRef.current = true;
|
|
12925
|
+
if (commit && JSON.stringify(runsRef.current) !== JSON.stringify(props.element.runs))
|
|
12926
|
+
props.onCommit(runsRef.current);
|
|
12927
|
+
else props.onClose();
|
|
12928
|
+
};
|
|
12929
|
+
useEffect(() => {
|
|
12930
|
+
const containsEditorUi = (target) => target instanceof Node && (overlayRef.current?.contains(target) || target instanceof Element && !!target.closest(".canvas-react-rich-text-popup"));
|
|
12931
|
+
const onPointerDown = (event) => {
|
|
12932
|
+
if (!containsEditorUi(event.target)) finish(true);
|
|
12933
|
+
};
|
|
12934
|
+
const onFocusIn = (event) => {
|
|
12935
|
+
if (!containsEditorUi(event.target)) finish(true);
|
|
12936
|
+
};
|
|
12937
|
+
const onKeyDown = (event) => {
|
|
12938
|
+
if (event.key !== "Escape") return;
|
|
12939
|
+
event.preventDefault();
|
|
12940
|
+
event.stopPropagation();
|
|
12941
|
+
finish(false);
|
|
12942
|
+
};
|
|
12943
|
+
document.addEventListener("pointerdown", onPointerDown, true);
|
|
12944
|
+
document.addEventListener("focusin", onFocusIn, true);
|
|
12945
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
12946
|
+
editorRef.current?.focus();
|
|
12947
|
+
return () => {
|
|
12948
|
+
document.removeEventListener("pointerdown", onPointerDown, true);
|
|
12949
|
+
document.removeEventListener("focusin", onFocusIn, true);
|
|
12950
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
12951
|
+
};
|
|
12952
|
+
}, []);
|
|
12953
|
+
const scale = props.element.width > 0 ? props.rect.width / props.element.width : 1;
|
|
12954
|
+
const ptToPx = (size) => `${size * 25.4 / 72 * scale}px`;
|
|
12955
|
+
const indentPx = richTextIndentMm(props.element) * scale;
|
|
12956
|
+
const transform = props.element.transform ? (() => {
|
|
12957
|
+
const matrix = elementTransformHomography(props.element);
|
|
12958
|
+
const perspective = `matrix3d(${matrix.a},${matrix.b},0,${matrix.g / scale},${matrix.c},${matrix.d},0,${matrix.h / scale},0,0,1,0,${matrix.e * scale},${matrix.f * scale},0,1)`;
|
|
12959
|
+
const rotation = props.element.rotation ? ` translate(${props.rect.width / 2}px,${props.rect.height / 2}px) rotate(${props.element.rotation}deg) translate(${-props.rect.width / 2}px,${-props.rect.height / 2}px)` : "";
|
|
12960
|
+
return perspective + rotation;
|
|
12961
|
+
})() : `rotate(${props.element.rotation ?? 0}deg)`;
|
|
12962
|
+
return /* @__PURE__ */ jsx(
|
|
12963
|
+
"div",
|
|
12964
|
+
{
|
|
12965
|
+
ref: overlayRef,
|
|
12966
|
+
className: "cc-print-design-rich-text-overlay",
|
|
12967
|
+
style: {
|
|
12968
|
+
position: "fixed",
|
|
12969
|
+
zIndex: 1e4,
|
|
12970
|
+
left: props.rect.left,
|
|
12971
|
+
top: props.rect.top,
|
|
12972
|
+
width: props.rect.width,
|
|
12973
|
+
height: props.rect.height,
|
|
12974
|
+
background: "transparent",
|
|
12975
|
+
outline: "1px solid #1677ff",
|
|
12976
|
+
transform,
|
|
12977
|
+
transformOrigin: props.element.transform ? "0 0" : "center"
|
|
12978
|
+
},
|
|
12979
|
+
onKeyDownCapture: (event) => {
|
|
12980
|
+
event.stopPropagation();
|
|
12981
|
+
if (event.key === "Escape") {
|
|
12982
|
+
event.preventDefault();
|
|
12983
|
+
finish(false);
|
|
12984
|
+
}
|
|
12985
|
+
},
|
|
12986
|
+
children: /* @__PURE__ */ jsx(
|
|
12987
|
+
ReactRichText,
|
|
12988
|
+
{
|
|
12989
|
+
ref: editorRef,
|
|
12990
|
+
value: runs,
|
|
12991
|
+
onChange: setRuns,
|
|
12992
|
+
toolbarPopupZIndex: 10001,
|
|
12993
|
+
fontFamilyOptions: FONT_FAMILY_OPTIONS.map((option) => ({ label: option.label, value: String(option.value) })),
|
|
12994
|
+
defaultStyle: {
|
|
12995
|
+
fontFamily: resolvePrintDesignFontFamily(props.element.fontFamily),
|
|
12996
|
+
fontSize: props.element.fontSize ?? 14,
|
|
12997
|
+
fontWeight: props.element.fontWeight ?? "400",
|
|
12998
|
+
fontStyle: props.element.fontStyle ?? "normal",
|
|
12999
|
+
color: props.element.color ?? "#1f2937"
|
|
13000
|
+
},
|
|
13001
|
+
fontSizeCss: ptToPx,
|
|
13002
|
+
editorStyle: {
|
|
13003
|
+
width: "100%",
|
|
13004
|
+
height: "100%",
|
|
13005
|
+
minHeight: 0,
|
|
13006
|
+
overflow: "hidden",
|
|
13007
|
+
backgroundColor: "transparent",
|
|
13008
|
+
lineHeight: props.element.lineHeight ?? 1.35,
|
|
13009
|
+
textAlign: props.element.textAlign ?? "left",
|
|
13010
|
+
textIndent: props.element.indentMode === "firstLine" ? `${indentPx}px` : props.element.indentMode === "hanging" ? `-${indentPx}px` : void 0,
|
|
13011
|
+
paddingLeft: props.element.indentMode === "hanging" ? `${indentPx}px` : void 0
|
|
13012
|
+
}
|
|
13013
|
+
}
|
|
13014
|
+
)
|
|
13015
|
+
}
|
|
13016
|
+
);
|
|
13017
|
+
}
|
|
13018
|
+
|
|
13019
|
+
// src/plugins/rich-text/factory.ts
|
|
13020
|
+
var richTextFactory = {
|
|
13021
|
+
type: "richText",
|
|
13022
|
+
label: "\u5BCC\u6587\u672C",
|
|
13023
|
+
showDataPanel: false,
|
|
13024
|
+
defaultOverflowPolicy: "split",
|
|
13025
|
+
overflowPolicyOptions: [
|
|
13026
|
+
{ label: "\u81EA\u52A8\u6EA2\u51FA\u5230\u7EED\u9875", value: "split" },
|
|
13027
|
+
{ label: "\u6574\u4F53\u653E\u5230\u4E0B\u4E00\u9875", value: "nextPage" },
|
|
13028
|
+
{ label: "\u88C1\u5207", value: "clip" },
|
|
13029
|
+
{ label: "\u8D85\u51FA\u663E\u793A...", value: "ellipsis" }
|
|
13030
|
+
],
|
|
13031
|
+
renderInlineEditor: ({ element, rect, onCommit, onClose }) => createElement(RichTextInlineEditor, {
|
|
13032
|
+
element,
|
|
13033
|
+
rect,
|
|
13034
|
+
onCommit: (runs) => onCommit({ runs }),
|
|
13035
|
+
onClose
|
|
13036
|
+
}),
|
|
13037
|
+
create: () => ({
|
|
13038
|
+
...createCommonElementDefaults(),
|
|
13039
|
+
type: "richText",
|
|
13040
|
+
name: "\u5BCC\u6587\u672C",
|
|
13041
|
+
runs: [{ text: "\u53CC\u51FB\u7F16\u8F91\u5BCC\u6587\u672C" }],
|
|
13042
|
+
fontSize: 14,
|
|
13043
|
+
color: "#1f2937"
|
|
13044
|
+
})
|
|
13045
|
+
};
|
|
13046
|
+
var menuGroups2 = [
|
|
13047
|
+
{
|
|
13048
|
+
id: "basic",
|
|
13049
|
+
title: "\u57FA\u7840\u5143\u7D20",
|
|
13050
|
+
order: 0,
|
|
13051
|
+
items: [
|
|
13052
|
+
{
|
|
13053
|
+
id: "richText",
|
|
13054
|
+
type: "richText",
|
|
13055
|
+
label: "\u5BCC\u6587\u672C",
|
|
13056
|
+
icon: createElement(ReactFontSizeOutlined, { "aria-hidden": true }),
|
|
13057
|
+
order: 1
|
|
13058
|
+
}
|
|
13059
|
+
]
|
|
13060
|
+
}
|
|
13061
|
+
];
|
|
13062
|
+
|
|
13063
|
+
// src/plugins/rich-text/react.ts
|
|
13064
|
+
var richTextPlugin = defineBuiltinReactPlugin(richTextNativePlugin, {
|
|
13065
|
+
factory: richTextFactory,
|
|
13066
|
+
menuGroups: menuGroups2
|
|
13067
|
+
});
|
|
11944
13068
|
|
|
11945
13069
|
// src/plugins/list/factory.ts
|
|
11946
13070
|
var listFactory = {
|
|
11947
13071
|
type: "list",
|
|
11948
13072
|
label: "\u5217\u8868",
|
|
13073
|
+
agentCommands: [
|
|
13074
|
+
{
|
|
13075
|
+
name: "insert-item",
|
|
13076
|
+
description: "\u5728\u5217\u8868\u6307\u5B9A\u4F4D\u7F6E\u63D2\u5165\u9879\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, text: \u9879\u6587\u5B57 }\u3002"
|
|
13077
|
+
},
|
|
13078
|
+
{
|
|
13079
|
+
name: "update-item",
|
|
13080
|
+
description: "\u4FEE\u6539\u5217\u8868\u9879\u3002payload: { index: 0 \u8D77\u59CB\u9879\u4F4D\u7F6E, text?: \u9879\u6587\u5B57, checked?: \u662F\u5426\u9009\u4E2D }\u3002"
|
|
13081
|
+
},
|
|
13082
|
+
{
|
|
13083
|
+
name: "remove-item",
|
|
13084
|
+
description: "\u79FB\u9664\u5217\u8868\u9879\u3002payload: { index: 0 \u8D77\u59CB\u9879\u4F4D\u7F6E }\u3002"
|
|
13085
|
+
}
|
|
13086
|
+
],
|
|
11949
13087
|
showDataPanel: false,
|
|
11950
13088
|
tourFields: () => [],
|
|
11951
13089
|
acceptsPreset: (preset) => ["ordered", "unordered", "radio", "checkbox"].includes(preset),
|
|
@@ -11977,7 +13115,7 @@ var listFactory = {
|
|
|
11977
13115
|
};
|
|
11978
13116
|
|
|
11979
13117
|
// src/plugins/list/menu.ts
|
|
11980
|
-
var
|
|
13118
|
+
var menuGroups3 = [
|
|
11981
13119
|
{
|
|
11982
13120
|
id: "list",
|
|
11983
13121
|
title: "\u5217\u8868\u7EC4\u4EF6",
|
|
@@ -12079,7 +13217,7 @@ var propertySections2 = [
|
|
|
12079
13217
|
// src/plugins/list/react.ts
|
|
12080
13218
|
var listPlugin = defineBuiltinReactPlugin(listNativePlugin, {
|
|
12081
13219
|
factory: listFactory,
|
|
12082
|
-
menuGroups:
|
|
13220
|
+
menuGroups: menuGroups3,
|
|
12083
13221
|
propertySections: propertySections2
|
|
12084
13222
|
});
|
|
12085
13223
|
|
|
@@ -12102,7 +13240,7 @@ var dateTimeFactory = {
|
|
|
12102
13240
|
};
|
|
12103
13241
|
}
|
|
12104
13242
|
};
|
|
12105
|
-
var
|
|
13243
|
+
var menuGroups4 = [
|
|
12106
13244
|
{
|
|
12107
13245
|
id: "date-time",
|
|
12108
13246
|
title: "\u65E5\u671F\u65F6\u95F4",
|
|
@@ -12143,7 +13281,7 @@ var propertySections3 = [
|
|
|
12143
13281
|
];
|
|
12144
13282
|
var dateTimePlugin = defineBuiltinReactPlugin(dateTimeNativePlugin, {
|
|
12145
13283
|
factory: dateTimeFactory,
|
|
12146
|
-
menuGroups:
|
|
13284
|
+
menuGroups: menuGroups4,
|
|
12147
13285
|
propertySections: propertySections3
|
|
12148
13286
|
});
|
|
12149
13287
|
|
|
@@ -12166,7 +13304,7 @@ var moneyUpperFactory = {
|
|
|
12166
13304
|
};
|
|
12167
13305
|
}
|
|
12168
13306
|
};
|
|
12169
|
-
var
|
|
13307
|
+
var menuGroups5 = [
|
|
12170
13308
|
{
|
|
12171
13309
|
id: "basic",
|
|
12172
13310
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -12220,7 +13358,7 @@ var propertySections4 = [
|
|
|
12220
13358
|
];
|
|
12221
13359
|
var moneyUpperPlugin = defineBuiltinReactPlugin(
|
|
12222
13360
|
moneyUpperNativePlugin,
|
|
12223
|
-
{ factory: moneyUpperFactory, menuGroups:
|
|
13361
|
+
{ factory: moneyUpperFactory, menuGroups: menuGroups5, propertySections: propertySections4 }
|
|
12224
13362
|
);
|
|
12225
13363
|
|
|
12226
13364
|
// src/plugins/page-number/factory.ts
|
|
@@ -12242,7 +13380,7 @@ var pageNumberFactory = {
|
|
|
12242
13380
|
};
|
|
12243
13381
|
}
|
|
12244
13382
|
};
|
|
12245
|
-
var
|
|
13383
|
+
var menuGroups6 = [
|
|
12246
13384
|
{
|
|
12247
13385
|
id: "basic",
|
|
12248
13386
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -12291,7 +13429,7 @@ var propertySections5 = [
|
|
|
12291
13429
|
];
|
|
12292
13430
|
var pageNumberPlugin = defineBuiltinReactPlugin(
|
|
12293
13431
|
pageNumberNativePlugin,
|
|
12294
|
-
{ factory: pageNumberFactory, menuGroups:
|
|
13432
|
+
{ factory: pageNumberFactory, menuGroups: menuGroups6, propertySections: propertySections5 }
|
|
12295
13433
|
);
|
|
12296
13434
|
|
|
12297
13435
|
// src/plugins/watermark/factory.ts
|
|
@@ -12331,7 +13469,7 @@ var watermarkFactory = {
|
|
|
12331
13469
|
};
|
|
12332
13470
|
}
|
|
12333
13471
|
};
|
|
12334
|
-
var
|
|
13472
|
+
var menuGroups7 = [
|
|
12335
13473
|
{
|
|
12336
13474
|
id: "basic",
|
|
12337
13475
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -12385,7 +13523,7 @@ var propertySections6 = [
|
|
|
12385
13523
|
];
|
|
12386
13524
|
var watermarkPlugin = defineBuiltinReactPlugin(watermarkNativePlugin, {
|
|
12387
13525
|
factory: watermarkFactory,
|
|
12388
|
-
menuGroups:
|
|
13526
|
+
menuGroups: menuGroups7,
|
|
12389
13527
|
propertySections: propertySections6
|
|
12390
13528
|
});
|
|
12391
13529
|
|
|
@@ -12393,6 +13531,20 @@ var watermarkPlugin = defineBuiltinReactPlugin(watermarkNativePlugin, {
|
|
|
12393
13531
|
var shapeFactory = {
|
|
12394
13532
|
type: "shape",
|
|
12395
13533
|
label: "\u56FE\u5F62",
|
|
13534
|
+
agentCommands: [
|
|
13535
|
+
{
|
|
13536
|
+
name: "set-polygon-points",
|
|
13537
|
+
description: "\u8BBE\u7F6E\u4E09\u89D2\u5F62\u3001\u591A\u8FB9\u5F62\u6216\u661F\u5F62\u9876\u70B9\u3002payload: { points: \u81F3\u5C11 3 \u4E2A { x, y } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
|
|
13538
|
+
},
|
|
13539
|
+
{
|
|
13540
|
+
name: "set-curve-points",
|
|
13541
|
+
description: "\u8BBE\u7F6E\u4E8C\u6B21\u3001\u4E09\u6B21\u6216\u591A\u6BB5\u66F2\u7EBF\u63A7\u5236\u70B9\u3002payload: { points: \u81F3\u5C11 2 \u4E2A { x, y } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
|
|
13542
|
+
},
|
|
13543
|
+
{
|
|
13544
|
+
name: "set-path-points",
|
|
13545
|
+
description: "\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u8DEF\u5F84\u8282\u70B9\u3002payload: { points: { x, y } \u5F52\u4E00\u5316\u5750\u6807\u6570\u7EC4, closed?: \u662F\u5426\u95ED\u5408 }\u3002"
|
|
13546
|
+
}
|
|
13547
|
+
],
|
|
12396
13548
|
acceptsPreset: (preset) => [
|
|
12397
13549
|
"triangle",
|
|
12398
13550
|
"rect",
|
|
@@ -12512,7 +13664,7 @@ var shapeFactory = {
|
|
|
12512
13664
|
};
|
|
12513
13665
|
|
|
12514
13666
|
// src/plugins/shape/menu.ts
|
|
12515
|
-
var
|
|
13667
|
+
var menuGroups8 = [
|
|
12516
13668
|
{
|
|
12517
13669
|
id: "shape",
|
|
12518
13670
|
title: "\u5F62\u72B6\u7EC4\u4EF6",
|
|
@@ -12658,15 +13810,15 @@ var menuGroups7 = [
|
|
|
12658
13810
|
|
|
12659
13811
|
// src/plugins/shape/layout/options.ts
|
|
12660
13812
|
var SHAPE_OPTIONS = [
|
|
12661
|
-
...(
|
|
13813
|
+
...(menuGroups8.find((group) => group.id === "shape")?.items ?? []).map(
|
|
12662
13814
|
({ id, label }) => ({ value: id, label })
|
|
12663
13815
|
),
|
|
12664
13816
|
{ value: "ellipse", label: "\u692D\u5706" },
|
|
12665
13817
|
{ value: "line", label: "\u76F4\u7EBF" },
|
|
12666
|
-
...(
|
|
13818
|
+
...(menuGroups8.find((group) => group.id === "bracket")?.items ?? []).map(
|
|
12667
13819
|
({ id, label }) => ({ value: id, label })
|
|
12668
13820
|
),
|
|
12669
|
-
...(
|
|
13821
|
+
...(menuGroups8.find((group) => group.id === "curve")?.items ?? []).map(
|
|
12670
13822
|
({ id, label }) => ({ value: id, label })
|
|
12671
13823
|
),
|
|
12672
13824
|
{ value: "curve-path", label: "\u8DEF\u5F84" }
|
|
@@ -12884,7 +14036,7 @@ var propertySections7 = [
|
|
|
12884
14036
|
// src/plugins/shape/react.ts
|
|
12885
14037
|
var shapePlugin = defineBuiltinReactPlugin(shapeNativePlugin, {
|
|
12886
14038
|
factory: shapeFactory,
|
|
12887
|
-
menuGroups:
|
|
14039
|
+
menuGroups: menuGroups8,
|
|
12888
14040
|
propertySections: propertySections7
|
|
12889
14041
|
});
|
|
12890
14042
|
|
|
@@ -12915,6 +14067,7 @@ function BrushToolbarButton({
|
|
|
12915
14067
|
title: active ? "\u9000\u51FA\u753B\u7B14\u6A21\u5F0F" : "\u65B0\u5EFA\u753B\u7B14\u56FE\u5C42\u5E76\u7ED8\u5236",
|
|
12916
14068
|
"aria-label": "\u753B\u7B14\u6A21\u5F0F",
|
|
12917
14069
|
"aria-pressed": active,
|
|
14070
|
+
type: active ? "primary" : "default",
|
|
12918
14071
|
disabled: readonly,
|
|
12919
14072
|
icon: /* @__PURE__ */ jsxs(
|
|
12920
14073
|
"svg",
|
|
@@ -12949,6 +14102,16 @@ function BrushToolbarButton({
|
|
|
12949
14102
|
var brushFactory = {
|
|
12950
14103
|
type: "brush",
|
|
12951
14104
|
label: "\u753B\u7B14",
|
|
14105
|
+
agentCommands: [
|
|
14106
|
+
{
|
|
14107
|
+
name: "append-stroke",
|
|
14108
|
+
description: "\u8FFD\u52A0\u4E00\u7B14\u3002payload: { points: \u81F3\u5C11\u4E24\u4E2A { x, y, pressure?: 0 \u5230 1 } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
|
|
14109
|
+
},
|
|
14110
|
+
{
|
|
14111
|
+
name: "remove-stroke",
|
|
14112
|
+
description: "\u5220\u9664\u6307\u5B9A\u7B14\u753B\u5E76\u540C\u6B65\u5BF9\u5E94\u6837\u5F0F\u3002payload: { index: 0 \u8D77\u59CB\u7B14\u753B\u4F4D\u7F6E }\u3002"
|
|
14113
|
+
}
|
|
14114
|
+
],
|
|
12952
14115
|
showDataPanel: false,
|
|
12953
14116
|
tourFields: () => [],
|
|
12954
14117
|
create: createBrushElement,
|
|
@@ -12956,7 +14119,7 @@ var brushFactory = {
|
|
|
12956
14119
|
};
|
|
12957
14120
|
|
|
12958
14121
|
// src/plugins/brush/menu.ts
|
|
12959
|
-
var
|
|
14122
|
+
var menuGroups9 = [];
|
|
12960
14123
|
|
|
12961
14124
|
// src/plugins/brush/properties.ts
|
|
12962
14125
|
var propertySections8 = [
|
|
@@ -13040,7 +14203,7 @@ var propertySections8 = [
|
|
|
13040
14203
|
// src/plugins/brush/react.ts
|
|
13041
14204
|
var brushPlugin = defineBuiltinReactPlugin(brushNativePlugin, {
|
|
13042
14205
|
factory: brushFactory,
|
|
13043
|
-
menuGroups:
|
|
14206
|
+
menuGroups: menuGroups9,
|
|
13044
14207
|
propertySections: propertySections8
|
|
13045
14208
|
});
|
|
13046
14209
|
|
|
@@ -13048,6 +14211,16 @@ var brushPlugin = defineBuiltinReactPlugin(brushNativePlugin, {
|
|
|
13048
14211
|
var connectorFactory = {
|
|
13049
14212
|
type: "connector",
|
|
13050
14213
|
label: "\u8FDE\u63A5\u7EBF",
|
|
14214
|
+
agentCommands: [
|
|
14215
|
+
{
|
|
14216
|
+
name: "set-endpoint",
|
|
14217
|
+
description: "\u5C06\u8FDE\u63A5\u7EBF\u8D77\u70B9\u6216\u7EC8\u70B9\u8FDE\u63A5\u5230\u5DF2\u6709\u5143\u7D20\u3002payload: { side: start|end, endpoint: { elementId?: \u76EE\u6807\u5143\u7D20 ID, anchor?: auto|top|right|bottom|left|top-left|top-right|bottom-right|bottom-left|edge:\u7D22\u5F15|vertex:\u7D22\u5F15 } }\u3002"
|
|
14218
|
+
},
|
|
14219
|
+
{
|
|
14220
|
+
name: "set-waypoints",
|
|
14221
|
+
description: "\u8BBE\u7F6E\u6298\u7EBF\u4E2D\u95F4\u8DEF\u5F84\u70B9\uFF0C\u4EC5\u9002\u7528\u4E8E lineType=polyline\u3002payload: { points: \u9875\u9762\u6BEB\u7C73\u5750\u6807\u6570\u7EC4 [{ x, y }] }\u3002"
|
|
14222
|
+
}
|
|
14223
|
+
],
|
|
13051
14224
|
create: (preset = "bar") => {
|
|
13052
14225
|
const common = createCommonElementDefaults();
|
|
13053
14226
|
const type = "connector";
|
|
@@ -13068,7 +14241,7 @@ var connectorFactory = {
|
|
|
13068
14241
|
};
|
|
13069
14242
|
|
|
13070
14243
|
// src/plugins/connector/menu.ts
|
|
13071
|
-
var
|
|
14244
|
+
var menuGroups10 = [
|
|
13072
14245
|
{
|
|
13073
14246
|
id: "connector",
|
|
13074
14247
|
title: "\u8FDE\u63A5\u7EBF",
|
|
@@ -13183,7 +14356,7 @@ var propertySections9 = [
|
|
|
13183
14356
|
// src/plugins/connector/react.ts
|
|
13184
14357
|
var connectorPlugin = defineBuiltinReactPlugin(connectorNativePlugin, {
|
|
13185
14358
|
factory: connectorFactory,
|
|
13186
|
-
menuGroups:
|
|
14359
|
+
menuGroups: menuGroups10,
|
|
13187
14360
|
propertySections: propertySections9
|
|
13188
14361
|
});
|
|
13189
14362
|
|
|
@@ -13208,7 +14381,7 @@ var dividerFactory = {
|
|
|
13208
14381
|
};
|
|
13209
14382
|
}
|
|
13210
14383
|
};
|
|
13211
|
-
var
|
|
14384
|
+
var menuGroups11 = [
|
|
13212
14385
|
{
|
|
13213
14386
|
id: "basic",
|
|
13214
14387
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -13267,7 +14440,7 @@ var propertySections10 = [
|
|
|
13267
14440
|
// src/plugins/divider/react.ts
|
|
13268
14441
|
var dividerPlugin = defineBuiltinReactPlugin(dividerNativePlugin, {
|
|
13269
14442
|
factory: dividerFactory,
|
|
13270
|
-
menuGroups:
|
|
14443
|
+
menuGroups: menuGroups11,
|
|
13271
14444
|
propertySections: propertySections10
|
|
13272
14445
|
});
|
|
13273
14446
|
|
|
@@ -13304,7 +14477,7 @@ var rulerFactory = {
|
|
|
13304
14477
|
};
|
|
13305
14478
|
|
|
13306
14479
|
// src/plugins/ruler/menu.ts
|
|
13307
|
-
var
|
|
14480
|
+
var menuGroups12 = [
|
|
13308
14481
|
{
|
|
13309
14482
|
id: "ruler",
|
|
13310
14483
|
title: "\u523B\u5EA6\u5C3A\u7EC4\u4EF6",
|
|
@@ -13397,7 +14570,7 @@ var propertySections11 = [
|
|
|
13397
14570
|
// src/plugins/ruler/react.ts
|
|
13398
14571
|
var rulerPlugin = defineBuiltinReactPlugin(rulerNativePlugin, {
|
|
13399
14572
|
factory: rulerFactory,
|
|
13400
|
-
menuGroups:
|
|
14573
|
+
menuGroups: menuGroups12,
|
|
13401
14574
|
propertySections: propertySections11
|
|
13402
14575
|
});
|
|
13403
14576
|
|
|
@@ -13405,6 +14578,16 @@ var rulerPlugin = defineBuiltinReactPlugin(rulerNativePlugin, {
|
|
|
13405
14578
|
var gridFactory = {
|
|
13406
14579
|
type: "grid",
|
|
13407
14580
|
label: "\u7F51\u683C",
|
|
14581
|
+
agentCommands: [
|
|
14582
|
+
{
|
|
14583
|
+
name: "resize-grid",
|
|
14584
|
+
description: "\u8C03\u6574\u7F51\u683C\u884C\u5217\u6570\uFF0C\u4FDD\u7559\u91CD\u53E0\u533A\u57DF\u7684\u5355\u5143\u683C\u3002payload: { rows: 1 \u5230 50 \u7684\u6574\u6570, columns: 1 \u5230 50 \u7684\u6574\u6570 }\u3002"
|
|
14585
|
+
},
|
|
14586
|
+
{
|
|
14587
|
+
name: "set-cell",
|
|
14588
|
+
description: "\u66F4\u65B0\u6307\u5B9A\u7F51\u683C\u5355\u5143\u683C\u3002payload: { rowIndex: 0 \u8D77\u59CB\u884C, columnIndex: 0 \u8D77\u59CB\u5217, cell: { content?: none|x|*, contentMode?: static|binding, contentPath?: \u5B57\u7B26\u4E32, backgroundColor?: \u5B57\u7B26\u4E32 } }\u3002"
|
|
14589
|
+
}
|
|
14590
|
+
],
|
|
13408
14591
|
showDataPanel: false,
|
|
13409
14592
|
tourFields: (element) => element.type === "grid" ? [
|
|
13410
14593
|
{ key: "rows", label: "\u884C\u6570", value: element.rows },
|
|
@@ -13429,7 +14612,7 @@ var gridFactory = {
|
|
|
13429
14612
|
};
|
|
13430
14613
|
}
|
|
13431
14614
|
};
|
|
13432
|
-
var
|
|
14615
|
+
var menuGroups13 = [
|
|
13433
14616
|
{
|
|
13434
14617
|
id: "grid",
|
|
13435
14618
|
title: "\u7F51\u683C\u7EC4\u4EF6",
|
|
@@ -13639,7 +14822,7 @@ var propertySections12 = [
|
|
|
13639
14822
|
// src/plugins/grid/react.ts
|
|
13640
14823
|
var gridPlugin = defineBuiltinReactPlugin(gridNativePlugin, {
|
|
13641
14824
|
factory: gridFactory,
|
|
13642
|
-
menuGroups:
|
|
14825
|
+
menuGroups: menuGroups13,
|
|
13643
14826
|
propertySections: propertySections12
|
|
13644
14827
|
});
|
|
13645
14828
|
|
|
@@ -13647,6 +14830,16 @@ var gridPlugin = defineBuiltinReactPlugin(gridNativePlugin, {
|
|
|
13647
14830
|
var coordinateFactory = {
|
|
13648
14831
|
type: "coordinate",
|
|
13649
14832
|
label: "\u5750\u6807\u7F51\u683C",
|
|
14833
|
+
agentCommands: [
|
|
14834
|
+
{
|
|
14835
|
+
name: "resize-grid",
|
|
14836
|
+
description: "\u8C03\u6574\u5750\u6807\u7F51\u683C\u884C\u5217\u6570\uFF0C\u4FDD\u7559\u91CD\u53E0\u533A\u57DF\u5355\u5143\u683C\u3002payload: { rows: 1 \u5230 50 \u7684\u6574\u6570, columns: 1 \u5230 50 \u7684\u6574\u6570 }\u3002"
|
|
14837
|
+
},
|
|
14838
|
+
{
|
|
14839
|
+
name: "set-cell",
|
|
14840
|
+
description: "\u66F4\u65B0\u5750\u6807\u7F51\u683C\u5355\u5143\u683C\u3002payload: { rowIndex: 0 \u8D77\u59CB\u884C, columnIndex: 0 \u8D77\u59CB\u5217, cell: { content?: none|x|*, contentMode?: static|binding, contentPath?: \u5B57\u7B26\u4E32, backgroundColor?: \u5B57\u7B26\u4E32 } }\u3002"
|
|
14841
|
+
}
|
|
14842
|
+
],
|
|
13650
14843
|
showDataPanel: false,
|
|
13651
14844
|
tourFields: (element) => element.type === "coordinate" ? [
|
|
13652
14845
|
{ key: "rows", label: "\u884C\u6570", value: element.rows },
|
|
@@ -13691,7 +14884,7 @@ var coordinateFactory = {
|
|
|
13691
14884
|
};
|
|
13692
14885
|
}
|
|
13693
14886
|
};
|
|
13694
|
-
var
|
|
14887
|
+
var menuGroups14 = [
|
|
13695
14888
|
{
|
|
13696
14889
|
id: "grid",
|
|
13697
14890
|
title: "\u7F51\u683C\u7EC4\u4EF6",
|
|
@@ -13842,7 +15035,7 @@ var propertySections13 = [
|
|
|
13842
15035
|
// src/plugins/coordinate/react.ts
|
|
13843
15036
|
var coordinatePlugin = defineBuiltinReactPlugin(
|
|
13844
15037
|
coordinateNativePlugin,
|
|
13845
|
-
{ factory: coordinateFactory, menuGroups:
|
|
15038
|
+
{ factory: coordinateFactory, menuGroups: menuGroups14, propertySections: propertySections13 }
|
|
13846
15039
|
);
|
|
13847
15040
|
|
|
13848
15041
|
// src/plugins/progress/factory.ts
|
|
@@ -13877,7 +15070,7 @@ var progressFactory = {
|
|
|
13877
15070
|
};
|
|
13878
15071
|
|
|
13879
15072
|
// src/plugins/progress/menu.ts
|
|
13880
|
-
var
|
|
15073
|
+
var menuGroups15 = [
|
|
13881
15074
|
{
|
|
13882
15075
|
id: "progress",
|
|
13883
15076
|
title: "\u8FDB\u5EA6\u7EC4\u4EF6",
|
|
@@ -14009,7 +15202,7 @@ var propertySections14 = [
|
|
|
14009
15202
|
// src/plugins/progress/react.ts
|
|
14010
15203
|
var progressPlugin = defineBuiltinReactPlugin(progressNativePlugin, {
|
|
14011
15204
|
factory: progressFactory,
|
|
14012
|
-
menuGroups:
|
|
15205
|
+
menuGroups: menuGroups15,
|
|
14013
15206
|
propertySections: propertySections14
|
|
14014
15207
|
});
|
|
14015
15208
|
|
|
@@ -14017,6 +15210,20 @@ var progressPlugin = defineBuiltinReactPlugin(progressNativePlugin, {
|
|
|
14017
15210
|
var flowFactory = {
|
|
14018
15211
|
type: "flow",
|
|
14019
15212
|
label: "\u6D41\u7A0B\u56FE",
|
|
15213
|
+
agentCommands: [
|
|
15214
|
+
{
|
|
15215
|
+
name: "insert-item",
|
|
15216
|
+
description: "\u5728\u9759\u6001\u6D41\u7A0B\u6307\u5B9A\u4F4D\u7F6E\u63D2\u5165\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, item: { content: \u5B57\u7B26\u4E32, title?: \u5B57\u7B26\u4E32, color?: \u5B57\u7B26\u4E32, position?: start|end, loading?: \u5E03\u5C14\u503C, icon?: circle|check|clock|cross } }\u3002"
|
|
15217
|
+
},
|
|
15218
|
+
{
|
|
15219
|
+
name: "update-item",
|
|
15220
|
+
description: "\u4FEE\u6539\u9759\u6001\u6D41\u7A0B\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u8282\u70B9\u4F4D\u7F6E, item: \u9700\u4FEE\u6539\u7684\u8282\u70B9\u5B57\u6BB5 }\u3002"
|
|
15221
|
+
},
|
|
15222
|
+
{
|
|
15223
|
+
name: "remove-item",
|
|
15224
|
+
description: "\u79FB\u9664\u9759\u6001\u6D41\u7A0B\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u8282\u70B9\u4F4D\u7F6E }\u3002"
|
|
15225
|
+
}
|
|
15226
|
+
],
|
|
14020
15227
|
showDataPanel: false,
|
|
14021
15228
|
tourFields: () => [],
|
|
14022
15229
|
create: (preset = "bar") => {
|
|
@@ -14045,7 +15252,7 @@ var flowFactory = {
|
|
|
14045
15252
|
};
|
|
14046
15253
|
}
|
|
14047
15254
|
};
|
|
14048
|
-
var
|
|
15255
|
+
var menuGroups16 = [
|
|
14049
15256
|
{
|
|
14050
15257
|
id: "basic",
|
|
14051
15258
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -14181,7 +15388,7 @@ var propertySections15 = [{
|
|
|
14181
15388
|
// src/plugins/flow/react.ts
|
|
14182
15389
|
var flowPlugin = defineBuiltinReactPlugin(flowNativePlugin, {
|
|
14183
15390
|
factory: flowFactory,
|
|
14184
|
-
menuGroups:
|
|
15391
|
+
menuGroups: menuGroups16,
|
|
14185
15392
|
propertySections: propertySections15
|
|
14186
15393
|
});
|
|
14187
15394
|
|
|
@@ -14223,7 +15430,7 @@ var clockFactory = {
|
|
|
14223
15430
|
};
|
|
14224
15431
|
}
|
|
14225
15432
|
};
|
|
14226
|
-
var
|
|
15433
|
+
var menuGroups17 = [
|
|
14227
15434
|
{
|
|
14228
15435
|
id: "date-time",
|
|
14229
15436
|
title: "\u65E5\u671F\u65F6\u95F4",
|
|
@@ -14322,7 +15529,7 @@ var propertySections16 = [
|
|
|
14322
15529
|
// src/plugins/clock/react.ts
|
|
14323
15530
|
var clockPlugin = defineBuiltinReactPlugin(clockNativePlugin, {
|
|
14324
15531
|
factory: clockFactory,
|
|
14325
|
-
menuGroups:
|
|
15532
|
+
menuGroups: menuGroups17,
|
|
14326
15533
|
propertySections: propertySections16
|
|
14327
15534
|
});
|
|
14328
15535
|
|
|
@@ -14399,6 +15606,16 @@ function placeExternalImage(image, point, page, index = 0) {
|
|
|
14399
15606
|
var imageFactory = {
|
|
14400
15607
|
type: "image",
|
|
14401
15608
|
label: "\u56FE\u7247",
|
|
15609
|
+
agentCommands: [
|
|
15610
|
+
{
|
|
15611
|
+
name: "set-crop",
|
|
15612
|
+
description: "\u8BBE\u7F6E\u56FE\u7247\u88C1\u526A\u533A\u57DF\u3002payload: { x, y, width, height }\uFF0C\u5747\u4E3A\u539F\u56FE\u5BBD\u9AD8\u7684 0 \u5230 1 \u6BD4\u4F8B\uFF0C\u533A\u57DF\u5FC5\u987B\u5728\u539F\u56FE\u5185\uFF1B\u53EF\u9009 sourceWidth\u3001sourceHeight \u4E3A\u539F\u56FE\u50CF\u7D20\u5C3A\u5BF8\u3002"
|
|
15613
|
+
},
|
|
15614
|
+
{
|
|
15615
|
+
name: "clear-crop",
|
|
15616
|
+
description: "\u79FB\u9664\u56FE\u7247\u88C1\u526A\uFF0C\u663E\u793A\u5B8C\u6574\u56FE\u7247\uFF1Bpayload \u4F20\u7A7A\u5BF9\u8C61\u3002"
|
|
15617
|
+
}
|
|
15618
|
+
],
|
|
14402
15619
|
dataFields: imageDataFields,
|
|
14403
15620
|
staticFieldPatch: (_element, key, value) => key === "src" ? { src: String(value), crop: void 0 } : { [key]: value },
|
|
14404
15621
|
externalDrop: {
|
|
@@ -14431,7 +15648,7 @@ var imageFactory = {
|
|
|
14431
15648
|
return { ...common, type, name: "\u56FE\u7247", src: "", fit: "contain" };
|
|
14432
15649
|
}
|
|
14433
15650
|
};
|
|
14434
|
-
var
|
|
15651
|
+
var menuGroups18 = [
|
|
14435
15652
|
{
|
|
14436
15653
|
id: "basic",
|
|
14437
15654
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -14486,7 +15703,7 @@ var propertySections17 = [
|
|
|
14486
15703
|
// src/plugins/image/react.ts
|
|
14487
15704
|
var imagePlugin = defineBuiltinReactPlugin(imageNativePlugin, {
|
|
14488
15705
|
factory: imageFactory,
|
|
14489
|
-
menuGroups:
|
|
15706
|
+
menuGroups: menuGroups18,
|
|
14490
15707
|
propertySections: propertySections17
|
|
14491
15708
|
});
|
|
14492
15709
|
var barcodeFactory = {
|
|
@@ -14516,7 +15733,7 @@ var barcodeFactory = {
|
|
|
14516
15733
|
};
|
|
14517
15734
|
}
|
|
14518
15735
|
};
|
|
14519
|
-
var
|
|
15736
|
+
var menuGroups19 = [
|
|
14520
15737
|
{
|
|
14521
15738
|
id: "basic",
|
|
14522
15739
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -14576,7 +15793,7 @@ var propertySections18 = [
|
|
|
14576
15793
|
// src/plugins/barcode/react.ts
|
|
14577
15794
|
var barcodePlugin = defineBuiltinReactPlugin(barcodeNativePlugin, {
|
|
14578
15795
|
factory: barcodeFactory,
|
|
14579
|
-
menuGroups:
|
|
15796
|
+
menuGroups: menuGroups19,
|
|
14580
15797
|
propertySections: propertySections18
|
|
14581
15798
|
});
|
|
14582
15799
|
|
|
@@ -14598,7 +15815,7 @@ var qrcodeFactory = {
|
|
|
14598
15815
|
};
|
|
14599
15816
|
}
|
|
14600
15817
|
};
|
|
14601
|
-
var
|
|
15818
|
+
var menuGroups20 = [
|
|
14602
15819
|
{
|
|
14603
15820
|
id: "basic",
|
|
14604
15821
|
title: "\u57FA\u7840\u5143\u7D20",
|
|
@@ -14757,7 +15974,7 @@ var propertySections19 = [
|
|
|
14757
15974
|
// src/plugins/qrcode/react.ts
|
|
14758
15975
|
var qrcodePlugin = defineBuiltinReactPlugin(qrcodeNativePlugin, {
|
|
14759
15976
|
factory: qrcodeFactory,
|
|
14760
|
-
menuGroups:
|
|
15977
|
+
menuGroups: menuGroups20,
|
|
14761
15978
|
propertySections: propertySections19
|
|
14762
15979
|
});
|
|
14763
15980
|
|
|
@@ -14839,6 +16056,16 @@ function createChartPreset(id) {
|
|
|
14839
16056
|
var chartFactory = {
|
|
14840
16057
|
type: "chart",
|
|
14841
16058
|
label: "\u56FE\u8868",
|
|
16059
|
+
agentCommands: [
|
|
16060
|
+
{
|
|
16061
|
+
name: "set-categories",
|
|
16062
|
+
description: "\u8BBE\u7F6E\u56FE\u8868\u9759\u6001\u5206\u7C7B\u6216\u9ED8\u8BA4\u5206\u7C7B\uFF0C\u5E76\u4F7F\u5404\u7CFB\u5217\u6570\u503C\u957F\u5EA6\u5339\u914D\u3002payload: { categories: \u5B57\u7B26\u4E32\u6570\u7EC4 }\u3002"
|
|
16063
|
+
},
|
|
16064
|
+
{
|
|
16065
|
+
name: "set-series",
|
|
16066
|
+
description: "\u66F4\u65B0\u6307\u5B9A\u6570\u503C\u7CFB\u5217\uFF0C\u4E5F\u53EF\u5728\u672B\u5C3E\u65B0\u589E\u3002payload: { index: 0 \u8D77\u59CB\u7CFB\u5217\u4F4D\u7F6E, name: \u7CFB\u5217\u540D\u79F0, values: \u4E0E categories \u7B49\u957F\u7684\u6709\u9650\u6570\u5B57\u6570\u7EC4, field?: \u7ED1\u5B9A\u5B57\u6BB5\u8DEF\u5F84 }\uFF1B\u997C\u56FE\u548C\u4EEA\u8868\u76D8\u4EC5\u652F\u6301\u7D22\u5F15 0\u3002"
|
|
16067
|
+
}
|
|
16068
|
+
],
|
|
14842
16069
|
showDataPanel: false,
|
|
14843
16070
|
acceptsPreset: (preset) => chartPresets.some((item) => item.id === preset),
|
|
14844
16071
|
create: (preset = "bar") => {
|
|
@@ -14853,7 +16080,7 @@ var chartFactory = {
|
|
|
14853
16080
|
};
|
|
14854
16081
|
}
|
|
14855
16082
|
};
|
|
14856
|
-
var
|
|
16083
|
+
var menuGroups21 = [
|
|
14857
16084
|
{
|
|
14858
16085
|
id: "chart",
|
|
14859
16086
|
title: "\u56FE\u8868\u7EC4\u4EF6",
|
|
@@ -15116,14 +16343,131 @@ var propertySections20 = [{
|
|
|
15116
16343
|
// src/plugins/chart/react.ts
|
|
15117
16344
|
var chartPlugin = defineBuiltinReactPlugin(chartNativePlugin, {
|
|
15118
16345
|
factory: chartFactory,
|
|
15119
|
-
menuGroups:
|
|
16346
|
+
menuGroups: menuGroups21,
|
|
15120
16347
|
propertySections: propertySections20
|
|
15121
16348
|
});
|
|
15122
16349
|
|
|
15123
16350
|
// src/plugins/table/factory.ts
|
|
16351
|
+
var fieldPathSchema = {
|
|
16352
|
+
anyOf: [
|
|
16353
|
+
{ type: "string", minLength: 1 },
|
|
16354
|
+
{
|
|
16355
|
+
type: "array",
|
|
16356
|
+
items: {
|
|
16357
|
+
anyOf: [
|
|
16358
|
+
{ type: "string", minLength: 1 },
|
|
16359
|
+
{ type: "integer", minimum: 0 }
|
|
16360
|
+
]
|
|
16361
|
+
},
|
|
16362
|
+
minItems: 1
|
|
16363
|
+
}
|
|
16364
|
+
]
|
|
16365
|
+
};
|
|
15124
16366
|
var tableFactory = {
|
|
15125
16367
|
type: "table",
|
|
15126
16368
|
label: "\u8868\u683C",
|
|
16369
|
+
agentCommands: [
|
|
16370
|
+
{
|
|
16371
|
+
name: "insert-row",
|
|
16372
|
+
description: "\u5728\u9759\u6001\u8868\u683C\u7684 rowIndex \u884C\u524D\u63D2\u5165\u884C\uFF1Bafter=true \u65F6\u63D2\u5728\u884C\u540E\u3002",
|
|
16373
|
+
parameters: {
|
|
16374
|
+
type: "object",
|
|
16375
|
+
properties: {
|
|
16376
|
+
rowIndex: { type: "integer", minimum: 0 },
|
|
16377
|
+
after: { type: "boolean" }
|
|
16378
|
+
},
|
|
16379
|
+
required: ["rowIndex"],
|
|
16380
|
+
additionalProperties: false
|
|
16381
|
+
}
|
|
16382
|
+
},
|
|
16383
|
+
{
|
|
16384
|
+
name: "insert-column",
|
|
16385
|
+
description: "\u5728 columnIndex \u5217\u524D\u63D2\u5165\u5217\uFF1Bafter=true \u65F6\u63D2\u5728\u5217\u540E\u3002",
|
|
16386
|
+
parameters: {
|
|
16387
|
+
type: "object",
|
|
16388
|
+
properties: {
|
|
16389
|
+
columnIndex: { type: "integer", minimum: 0 },
|
|
16390
|
+
after: { type: "boolean" }
|
|
16391
|
+
},
|
|
16392
|
+
required: ["columnIndex"],
|
|
16393
|
+
additionalProperties: false
|
|
16394
|
+
}
|
|
16395
|
+
},
|
|
16396
|
+
{
|
|
16397
|
+
name: "merge-body",
|
|
16398
|
+
description: "\u5408\u5E76\u8868\u4F53\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002",
|
|
16399
|
+
parameters: {
|
|
16400
|
+
type: "object",
|
|
16401
|
+
properties: {
|
|
16402
|
+
rowIndex: { type: "integer", minimum: 0 },
|
|
16403
|
+
columnIndex: { type: "integer", minimum: 0 },
|
|
16404
|
+
rowSpan: { type: "integer", minimum: 1 },
|
|
16405
|
+
colSpan: { type: "integer", minimum: 1 }
|
|
16406
|
+
},
|
|
16407
|
+
required: ["rowIndex", "columnIndex", "rowSpan", "colSpan"],
|
|
16408
|
+
additionalProperties: false
|
|
16409
|
+
}
|
|
16410
|
+
},
|
|
16411
|
+
{
|
|
16412
|
+
name: "merge-header",
|
|
16413
|
+
description: "\u5408\u5E76\u8868\u5934\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002",
|
|
16414
|
+
parameters: {
|
|
16415
|
+
type: "object",
|
|
16416
|
+
properties: {
|
|
16417
|
+
rowIndex: { type: "integer", minimum: 0 },
|
|
16418
|
+
columnIndex: { type: "integer", minimum: 0 },
|
|
16419
|
+
rowSpan: { type: "integer", minimum: 1 },
|
|
16420
|
+
colSpan: { type: "integer", minimum: 1 }
|
|
16421
|
+
},
|
|
16422
|
+
required: ["rowIndex", "columnIndex", "rowSpan", "colSpan"],
|
|
16423
|
+
additionalProperties: false
|
|
16424
|
+
}
|
|
16425
|
+
},
|
|
16426
|
+
{
|
|
16427
|
+
name: "configure-auto-merge",
|
|
16428
|
+
description: '\u6309\u6570\u636E\u5B57\u6BB5\u81EA\u52A8\u5408\u5E76\u8FDE\u7EED\u884C\u6216\u540C\u884C\u76F8\u90BB\u5217\u3002payload \u793A\u4F8B\uFF1A{rowKeys:["group"],rowColumns:["group"],columnKeys:["name"]}\uFF1B\u5B57\u6BB5\u53EF\u7528\u975E\u7A7A\u5B57\u7B26\u4E32\u6216\u8DEF\u5F84\u6570\u7EC4\uFF0C\u76EE\u6807\u5217\u987B\u5B58\u5728\u3002\u53EA\u9700\u884C\u5408\u5E76\u6216\u5217\u5408\u5E76\u65F6\u7701\u7565\u53E6\u4E00\u7C7B\u5B57\u6BB5\uFF1B\u4F20 {enabled:false} \u5173\u95ED\u3002\u914D\u7F6E\u4F1A\u6574\u4F53\u66FF\u6362\u539F\u81EA\u52A8\u5408\u5E76\u89C4\u5219\u3002',
|
|
16429
|
+
parameters: {
|
|
16430
|
+
type: "object",
|
|
16431
|
+
properties: {
|
|
16432
|
+
enabled: { type: "boolean" },
|
|
16433
|
+
rowKeys: { type: "array", items: fieldPathSchema },
|
|
16434
|
+
rowColumns: { type: "array", items: fieldPathSchema },
|
|
16435
|
+
columnKeys: { type: "array", items: fieldPathSchema }
|
|
16436
|
+
},
|
|
16437
|
+
additionalProperties: false
|
|
16438
|
+
}
|
|
16439
|
+
},
|
|
16440
|
+
{
|
|
16441
|
+
name: "configure-group-aggregation",
|
|
16442
|
+
description: '\u542F\u7528\u5206\u7EC4\u805A\u5408\u62A5\u8868\u5E76\u81EA\u52A8\u8865\u9F50\u660E\u7EC6\u3001\u5C0F\u8BA1\u548C\u603B\u8BA1\u89C4\u5219\u3002payload \u793A\u4F8B\uFF1A{groupBy:["region"],sums:[{column:"amount",path:"amount",decimals:2}],itemsPerRow:1}\uFF1BgroupBy \u4E3A\u539F\u59CB\u6570\u636E\u5B57\u6BB5\u8DEF\u5F84\uFF0Csums.column \u4E3A\u73B0\u6709\u53EF\u89C1\u5217 dataIndex\uFF0Csums.path \u4E3A\u6C42\u548C\u6E90\u5B57\u6BB5\u3002\u4F20 {enabled:false} \u5173\u95ED\u3002',
|
|
16443
|
+
parameters: {
|
|
16444
|
+
type: "object",
|
|
16445
|
+
properties: {
|
|
16446
|
+
enabled: { type: "boolean" },
|
|
16447
|
+
groupBy: {
|
|
16448
|
+
type: "array",
|
|
16449
|
+
items: { type: "string", minLength: 1 },
|
|
16450
|
+
minItems: 1
|
|
16451
|
+
},
|
|
16452
|
+
sums: {
|
|
16453
|
+
type: "array",
|
|
16454
|
+
items: {
|
|
16455
|
+
type: "object",
|
|
16456
|
+
properties: {
|
|
16457
|
+
column: { type: "string", minLength: 1 },
|
|
16458
|
+
path: { type: "string", minLength: 1 },
|
|
16459
|
+
decimals: { type: "integer", minimum: 0, maximum: 10 }
|
|
16460
|
+
},
|
|
16461
|
+
required: ["column", "path"],
|
|
16462
|
+
additionalProperties: false
|
|
16463
|
+
}
|
|
16464
|
+
},
|
|
16465
|
+
itemsPerRow: { type: "integer", minimum: 1 }
|
|
16466
|
+
},
|
|
16467
|
+
additionalProperties: false
|
|
16468
|
+
}
|
|
16469
|
+
}
|
|
16470
|
+
],
|
|
15127
16471
|
defaultOverflowPolicy: "split",
|
|
15128
16472
|
showDataPanel: false,
|
|
15129
16473
|
tourFields: (element) => {
|
|
@@ -15205,7 +16549,7 @@ var tableFactory = {
|
|
|
15205
16549
|
};
|
|
15206
16550
|
}
|
|
15207
16551
|
};
|
|
15208
|
-
var
|
|
16552
|
+
var menuGroups22 = [
|
|
15209
16553
|
{
|
|
15210
16554
|
id: "table",
|
|
15211
16555
|
title: "\u8868\u683C\u7EC4\u4EF6",
|
|
@@ -17083,6 +18427,7 @@ function TableCellsPanel({
|
|
|
17083
18427
|
title: label,
|
|
17084
18428
|
"aria-label": `${name}\u6587\u672C${label}`,
|
|
17085
18429
|
"aria-pressed": (textStyle.textAlign ?? "center") === value,
|
|
18430
|
+
type: (textStyle.textAlign ?? "center") === value ? "primary" : "default",
|
|
17086
18431
|
onClick: () => updateStyle({ textAlign: value })
|
|
17087
18432
|
},
|
|
17088
18433
|
value
|
|
@@ -17106,6 +18451,7 @@ function TableCellsPanel({
|
|
|
17106
18451
|
title: "\u52A0\u7C97",
|
|
17107
18452
|
"aria-label": `${name}\u6587\u672C\u52A0\u7C97`,
|
|
17108
18453
|
"aria-pressed": textStyle.bold === true,
|
|
18454
|
+
type: textStyle.bold === true ? "primary" : "default",
|
|
17109
18455
|
onClick: () => updateStyle({ bold: !textStyle.bold })
|
|
17110
18456
|
}
|
|
17111
18457
|
),
|
|
@@ -17116,6 +18462,7 @@ function TableCellsPanel({
|
|
|
17116
18462
|
title: "\u503E\u659C",
|
|
17117
18463
|
"aria-label": `${name}\u6587\u672C\u503E\u659C`,
|
|
17118
18464
|
"aria-pressed": textStyle.italic === true,
|
|
18465
|
+
type: textStyle.italic === true ? "primary" : "default",
|
|
17119
18466
|
onClick: () => updateStyle({ italic: !textStyle.italic })
|
|
17120
18467
|
}
|
|
17121
18468
|
)
|
|
@@ -17132,80 +18479,6 @@ function TableCellsPanel({
|
|
|
17132
18479
|
)
|
|
17133
18480
|
] });
|
|
17134
18481
|
}
|
|
17135
|
-
|
|
17136
|
-
// src/plugins/table/data/packed-report-defaults.ts
|
|
17137
|
-
function fillPackedReportDefaults(columns, rows, current2) {
|
|
17138
|
-
const visible = tableLeafColumns(columns).filter((column) => !column.hidden);
|
|
17139
|
-
const keys2 = visible.map(
|
|
17140
|
-
(column) => typeof column.dataIndex === "string" ? column.dataIndex : ""
|
|
17141
|
-
);
|
|
17142
|
-
const repeats = /* @__PURE__ */ new Map();
|
|
17143
|
-
keys2.forEach((key) => {
|
|
17144
|
-
const match = /^(.+?)([1-9]\d*)$/.exec(key);
|
|
17145
|
-
if (!match) return;
|
|
17146
|
-
const slots = repeats.get(match[1]) ?? /* @__PURE__ */ new Set();
|
|
17147
|
-
slots.add(Number(match[2]));
|
|
17148
|
-
repeats.set(match[1], slots);
|
|
17149
|
-
});
|
|
17150
|
-
const series = [...repeats].filter(
|
|
17151
|
-
([, slots]) => slots.has(1) && slots.has(2)
|
|
17152
|
-
);
|
|
17153
|
-
const itemsPerRow = Math.max(
|
|
17154
|
-
1,
|
|
17155
|
-
...series.map(([, slots]) => Math.max(...slots))
|
|
17156
|
-
);
|
|
17157
|
-
const sample = rows.find((row) => row && typeof row === "object") ?? {};
|
|
17158
|
-
const groupFields = {};
|
|
17159
|
-
keys2.forEach((key, index) => {
|
|
17160
|
-
const repeated = series.some(
|
|
17161
|
-
([prefix, slots]) => [...slots].some((slot) => key === `${prefix}${slot}`)
|
|
17162
|
-
);
|
|
17163
|
-
if (key && !repeated && !visible[index]?.summary && visible[index]?.summaryTitle == null) {
|
|
17164
|
-
groupFields[key] = key in sample ? key : "";
|
|
17165
|
-
}
|
|
17166
|
-
});
|
|
17167
|
-
const itemFields = series.map(([prefix]) => ({
|
|
17168
|
-
prefix,
|
|
17169
|
-
.../^(sequence|seq|index|序号)$/i.test(prefix) ? { mode: "index" } : { mode: "value", path: prefix in sample ? prefix : "" }
|
|
17170
|
-
}));
|
|
17171
|
-
const totals = {};
|
|
17172
|
-
visible.forEach((column, index) => {
|
|
17173
|
-
const key = keys2[index];
|
|
17174
|
-
const summary = column.summary;
|
|
17175
|
-
const type = typeof summary === "object" ? summary.type ?? "sum" : "sum";
|
|
17176
|
-
if (key && summary && type === "sum") {
|
|
17177
|
-
const prefix = series.find(
|
|
17178
|
-
([name, slots]) => [...slots].some((slot) => key === `${name}${slot}`)
|
|
17179
|
-
)?.[0];
|
|
17180
|
-
totals[key] = {
|
|
17181
|
-
sumPath: key in sample ? key : prefix && prefix in sample ? prefix : "",
|
|
17182
|
-
...typeof summary === "object" && summary.precision != null ? { decimals: summary.precision } : {}
|
|
17183
|
-
};
|
|
17184
|
-
}
|
|
17185
|
-
});
|
|
17186
|
-
const subtotalLabelKey = keys2.find(
|
|
17187
|
-
(key) => key && !(key in totals) && !(key in groupFields)
|
|
17188
|
-
);
|
|
17189
|
-
const totalLabelKey = keys2.find((key) => key && !(key in totals));
|
|
17190
|
-
const subtotal = { ...totals };
|
|
17191
|
-
if (subtotalLabelKey) subtotal[subtotalLabelKey] = { text: "\u5C0F\u8BA1" };
|
|
17192
|
-
if (totalLabelKey) totals[totalLabelKey] = { text: "\u603B\u8BA1" };
|
|
17193
|
-
return {
|
|
17194
|
-
groupBy: current2?.groupBy ?? [],
|
|
17195
|
-
itemsPerRow: current2?.itemsPerRow ?? itemsPerRow,
|
|
17196
|
-
groupFields: Object.keys(current2?.groupFields ?? {}).length ? current2.groupFields : groupFields,
|
|
17197
|
-
groupMergeColumns: Object.keys(current2?.groupFields ?? {}).length ? current2.groupMergeColumns : keys2.flatMap(
|
|
17198
|
-
(key, index) => key && key in groupFields ? [index] : []
|
|
17199
|
-
),
|
|
17200
|
-
itemFields: current2?.itemFields?.length ? current2.itemFields : itemFields,
|
|
17201
|
-
subtotal: Object.keys(current2?.subtotal ?? {}).length ? current2.subtotal : subtotal,
|
|
17202
|
-
subtotalMerges: current2?.subtotalMerges ?? [],
|
|
17203
|
-
total: Object.keys(current2?.total ?? {}).length ? current2.total : totals,
|
|
17204
|
-
totalMerges: current2?.totalMerges ?? [],
|
|
17205
|
-
appendRows: current2?.appendRows ?? [],
|
|
17206
|
-
...current2?.footerElementIds ? { footerElementIds: current2.footerElementIds } : {}
|
|
17207
|
-
};
|
|
17208
|
-
}
|
|
17209
18482
|
var isTableRows = (value) => Array.isArray(value) && value.every(
|
|
17210
18483
|
(row) => row !== null && typeof row === "object" && !Array.isArray(row)
|
|
17211
18484
|
);
|
|
@@ -18362,7 +19635,7 @@ function PackedReportPanel({
|
|
|
18362
19635
|
] })
|
|
18363
19636
|
] });
|
|
18364
19637
|
}
|
|
18365
|
-
var
|
|
19638
|
+
var fieldPath2 = (value) => Array.isArray(value) ? value.join(".") : String(value);
|
|
18366
19639
|
function TableAutoMergePanel({
|
|
18367
19640
|
element,
|
|
18368
19641
|
samples = [],
|
|
@@ -18415,7 +19688,7 @@ function TableAutoMergePanel({
|
|
|
18415
19688
|
DataPathPicker,
|
|
18416
19689
|
{
|
|
18417
19690
|
label: `${label} ${index + 1}`,
|
|
18418
|
-
value:
|
|
19691
|
+
value: fieldPath2(value),
|
|
18419
19692
|
samples,
|
|
18420
19693
|
onChange: (path) => set(
|
|
18421
19694
|
values.map(
|
|
@@ -18998,16 +20271,19 @@ function TableColumnsPanel({
|
|
|
18998
20271
|
] });
|
|
18999
20272
|
}
|
|
19000
20273
|
function fixedTableWidth(columns) {
|
|
19001
|
-
return tableLeafColumns(columns).filter((column) => !column.hidden).reduce(
|
|
19002
|
-
column
|
|
19003
|
-
|
|
19004
|
-
|
|
20274
|
+
return tableLeafColumns(columns).filter((column) => !column.hidden).reduce(
|
|
20275
|
+
(sum, column) => sum + Math.min(
|
|
20276
|
+
column.maxWidth ?? Number.POSITIVE_INFINITY,
|
|
20277
|
+
Math.max(column.minWidth ?? 1, column.width ?? 100)
|
|
20278
|
+
),
|
|
20279
|
+
0
|
|
20280
|
+
) * 25.4 / 96;
|
|
19005
20281
|
}
|
|
19006
20282
|
function TableColumnsControl(context) {
|
|
19007
20283
|
if (context.element.type !== "table") return null;
|
|
19008
20284
|
const element = context.element;
|
|
19009
20285
|
const page = context.page;
|
|
19010
|
-
return /* @__PURE__ */ jsxs(
|
|
20286
|
+
return /* @__PURE__ */ jsxs("div", { className: "cc-print-design-column-control cc-print-design-field-full", children: [
|
|
19011
20287
|
/* @__PURE__ */ jsx(
|
|
19012
20288
|
TableColumnsPanel,
|
|
19013
20289
|
{
|
|
@@ -19039,10 +20315,18 @@ function TableColumnsControl(context) {
|
|
|
19039
20315
|
{
|
|
19040
20316
|
icon: /* @__PURE__ */ jsx(ReactPlusOutlined, { "aria-hidden": "true" }),
|
|
19041
20317
|
disabled: context.readonly,
|
|
19042
|
-
onClick: () => context.onChange({
|
|
19043
|
-
|
|
19044
|
-
|
|
19045
|
-
|
|
20318
|
+
onClick: () => context.onChange({
|
|
20319
|
+
columns: [
|
|
20320
|
+
...element.columns,
|
|
20321
|
+
{
|
|
20322
|
+
key: crypto.randomUUID(),
|
|
20323
|
+
title: "\u65B0\u5217",
|
|
20324
|
+
dataIndex: `field${element.columns.length + 1}`,
|
|
20325
|
+
cellType: "text",
|
|
20326
|
+
width: 100
|
|
20327
|
+
}
|
|
20328
|
+
]
|
|
20329
|
+
}),
|
|
19046
20330
|
children: "\u6DFB\u52A0\u5217"
|
|
19047
20331
|
}
|
|
19048
20332
|
),
|
|
@@ -19262,7 +20546,7 @@ var propertySections21 = [
|
|
|
19262
20546
|
// src/plugins/table/react.ts
|
|
19263
20547
|
var tablePlugin = defineBuiltinReactPlugin(tableNativePlugin, {
|
|
19264
20548
|
factory: tableFactory,
|
|
19265
|
-
menuGroups:
|
|
20549
|
+
menuGroups: menuGroups22,
|
|
19266
20550
|
contextMenu: tableContextMenu,
|
|
19267
20551
|
propertySections: propertySections21
|
|
19268
20552
|
});
|
|
@@ -19271,6 +20555,16 @@ var tablePlugin = defineBuiltinReactPlugin(tableNativePlugin, {
|
|
|
19271
20555
|
var pivotTableFactory = {
|
|
19272
20556
|
type: "pivotTable",
|
|
19273
20557
|
label: "\u900F\u89C6\u8868",
|
|
20558
|
+
agentCommands: [
|
|
20559
|
+
{
|
|
20560
|
+
name: "move-field",
|
|
20561
|
+
description: "\u79FB\u52A8\u900F\u89C6\u5B57\u6BB5\u3002payload: { fieldKey: \u5DF2\u6709\u5B57\u6BB5 key, area: filter|column|row|value, index?: \u4ECE 0 \u5F00\u59CB\u7684\u76EE\u6807\u4F4D\u7F6E, sourceArea?: \u539F\u533A\u57DF }\u3002"
|
|
20562
|
+
},
|
|
20563
|
+
{
|
|
20564
|
+
name: "remove-field",
|
|
20565
|
+
description: "\u4ECE\u900F\u89C6\u5E03\u5C40\u7684\u6240\u6709\u533A\u57DF\u79FB\u9664\u5B57\u6BB5\uFF0C\u4E0D\u5220\u9664\u5B57\u6BB5\u5B9A\u4E49\u3002payload: { fieldKey: \u5DF2\u6709\u5B57\u6BB5 key }\u3002"
|
|
20566
|
+
}
|
|
20567
|
+
],
|
|
19274
20568
|
defaultOverflowPolicy: "split",
|
|
19275
20569
|
showDataPanel: false,
|
|
19276
20570
|
tourFields: (element) => {
|
|
@@ -19328,7 +20622,7 @@ var pivotTableFactory = {
|
|
|
19328
20622
|
};
|
|
19329
20623
|
}
|
|
19330
20624
|
};
|
|
19331
|
-
var
|
|
20625
|
+
var menuGroups23 = [
|
|
19332
20626
|
{
|
|
19333
20627
|
id: "table",
|
|
19334
20628
|
title: "\u8868\u683C\u7EC4\u4EF6",
|
|
@@ -20033,7 +21327,7 @@ var pivotTablePlugin = defineBuiltinReactPlugin(
|
|
|
20033
21327
|
pivotTableNativePlugin,
|
|
20034
21328
|
{
|
|
20035
21329
|
factory: pivotTableFactory,
|
|
20036
|
-
menuGroups:
|
|
21330
|
+
menuGroups: menuGroups23,
|
|
20037
21331
|
propertySections: propertySections22
|
|
20038
21332
|
}
|
|
20039
21333
|
);
|
|
@@ -20042,6 +21336,20 @@ var pivotTablePlugin = defineBuiltinReactPlugin(
|
|
|
20042
21336
|
var ganttFactory = {
|
|
20043
21337
|
type: "gantt",
|
|
20044
21338
|
label: "\u7518\u7279\u56FE",
|
|
21339
|
+
agentCommands: [
|
|
21340
|
+
{
|
|
21341
|
+
name: "insert-task",
|
|
21342
|
+
description: "\u5728\u9759\u6001\u7518\u7279\u56FE\u9876\u5C42\u4EFB\u52A1\u5217\u8868\u63D2\u5165\u4EFB\u52A1\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, task: { id: \u552F\u4E00\u5B57\u7B26\u4E32, title: \u5B57\u7B26\u4E32, start?: \u65E5\u671F, end?: \u65E5\u671F, progress?: 0 \u5230 100, ... } }\u3002"
|
|
21343
|
+
},
|
|
21344
|
+
{
|
|
21345
|
+
name: "update-task",
|
|
21346
|
+
description: "\u4FEE\u6539\u9876\u5C42\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u4FEE\u6539 id \u6216\u5D4C\u5957 tasks\u3002payload: { taskId: \u4EFB\u52A1 id, patch: { title?, start?, end?, progress?, color?, progressColor?, dependencies? } }\u3002"
|
|
21347
|
+
},
|
|
21348
|
+
{
|
|
21349
|
+
name: "remove-task",
|
|
21350
|
+
description: "\u79FB\u9664\u9759\u6001\u7518\u7279\u56FE\u9876\u5C42\u4EFB\u52A1\u3002payload: { taskId: \u4EFB\u52A1 id }\u3002"
|
|
21351
|
+
}
|
|
21352
|
+
],
|
|
20045
21353
|
showDataPanel: false,
|
|
20046
21354
|
tourFields: (element) => {
|
|
20047
21355
|
if (element.type !== "gantt") return [];
|
|
@@ -20094,7 +21402,7 @@ var ganttFactory = {
|
|
|
20094
21402
|
};
|
|
20095
21403
|
}
|
|
20096
21404
|
};
|
|
20097
|
-
var
|
|
21405
|
+
var menuGroups24 = [
|
|
20098
21406
|
{
|
|
20099
21407
|
id: "table",
|
|
20100
21408
|
title: "\u8868\u683C\u7EC4\u4EF6",
|
|
@@ -20468,7 +21776,7 @@ var propertySections23 = [
|
|
|
20468
21776
|
// src/plugins/gantt/react.ts
|
|
20469
21777
|
var ganttPlugin = defineBuiltinReactPlugin(ganttNativePlugin, {
|
|
20470
21778
|
factory: ganttFactory,
|
|
20471
|
-
menuGroups:
|
|
21779
|
+
menuGroups: menuGroups24,
|
|
20472
21780
|
propertySections: propertySections23
|
|
20473
21781
|
});
|
|
20474
21782
|
function formatTime(value) {
|
|
@@ -21242,6 +22550,7 @@ var pagePropertyPanels = new PrintDesignScopedPropertyRegistry([
|
|
|
21242
22550
|
ReactButton,
|
|
21243
22551
|
{
|
|
21244
22552
|
"aria-pressed": settings?.showGrid ?? false,
|
|
22553
|
+
type: settings?.showGrid ? "primary" : "default",
|
|
21245
22554
|
disabled: readonly,
|
|
21246
22555
|
onClick: () => onSettingsChange?.({
|
|
21247
22556
|
showGrid: !(settings?.showGrid ?? false)
|
|
@@ -21381,9 +22690,9 @@ var themeSettingsSections = [{
|
|
|
21381
22690
|
render: ({ preferences }, readonly, onChange) => /* @__PURE__ */ jsx("div", { className: "cc-print-design-theme-options", role: "group", "aria-label": "\u7F16\u8F91\u5668\u4E3B\u9898", children: Object.keys(editorThemes).map((key) => {
|
|
21382
22691
|
const theme = editorThemes[key];
|
|
21383
22692
|
return /* @__PURE__ */ jsxs(
|
|
21384
|
-
|
|
22693
|
+
ReactButton,
|
|
21385
22694
|
{
|
|
21386
|
-
type: "
|
|
22695
|
+
type: (preferences.theme ?? "light") === key ? "primary" : "default",
|
|
21387
22696
|
className: "cc-print-design-theme-option",
|
|
21388
22697
|
"aria-pressed": (preferences.theme ?? "light") === key,
|
|
21389
22698
|
disabled: readonly,
|
|
@@ -21808,6 +23117,80 @@ var settingsInteractionTool = {
|
|
|
21808
23117
|
sectionId: "interaction",
|
|
21809
23118
|
settingsSections: interactionSettingsSections
|
|
21810
23119
|
};
|
|
23120
|
+
var keyboardMoveSettingsSections = [
|
|
23121
|
+
{
|
|
23122
|
+
sectionId: "keyboard-move",
|
|
23123
|
+
title: "\u952E\u76D8\u79FB\u52A8",
|
|
23124
|
+
fields: [
|
|
23125
|
+
{
|
|
23126
|
+
path: "canvas.keyboardMoveStep",
|
|
23127
|
+
label: "\u65B9\u5411\u952E\u6B65\u957F",
|
|
23128
|
+
kind: "number",
|
|
23129
|
+
persistence: "local",
|
|
23130
|
+
min: 1e-3,
|
|
23131
|
+
read: ({ settings, preferences }) => toDisplayUnit(
|
|
23132
|
+
settings.keyboardMoveStep ?? 1,
|
|
23133
|
+
preferences.displayUnit
|
|
23134
|
+
),
|
|
23135
|
+
write: (value, { preferences }) => ({
|
|
23136
|
+
kind: "canvas",
|
|
23137
|
+
patch: {
|
|
23138
|
+
keyboardMoveStep: Math.max(
|
|
23139
|
+
0.01,
|
|
23140
|
+
fromDisplayUnit(value, preferences.displayUnit)
|
|
23141
|
+
)
|
|
23142
|
+
}
|
|
23143
|
+
})
|
|
23144
|
+
},
|
|
23145
|
+
{
|
|
23146
|
+
path: "canvas.keyboardMoveAcceleration",
|
|
23147
|
+
label: "\u957F\u6309\u52A0\u901F",
|
|
23148
|
+
kind: "toggle",
|
|
23149
|
+
persistence: "local",
|
|
23150
|
+
onLabel: "\u5F00\u542F",
|
|
23151
|
+
offLabel: "\u5173\u95ED",
|
|
23152
|
+
read: ({ settings }) => settings.keyboardMoveAcceleration ?? false,
|
|
23153
|
+
write: (keyboardMoveAcceleration) => ({
|
|
23154
|
+
kind: "canvas",
|
|
23155
|
+
patch: { keyboardMoveAcceleration }
|
|
23156
|
+
})
|
|
23157
|
+
},
|
|
23158
|
+
{
|
|
23159
|
+
path: "help.keyboardMove",
|
|
23160
|
+
label: "\u64CD\u4F5C\u63D0\u793A",
|
|
23161
|
+
kind: "hint",
|
|
23162
|
+
persistence: "session",
|
|
23163
|
+
read: () => "\u9009\u4E2D\u7EC4\u4EF6\u540E\u7528\u65B9\u5411\u952E\u79FB\u52A8\uFF1B\u6309\u4F4F\u65B9\u5411\u952E\u8FDE\u7EED\u79FB\u52A8\uFF0C\u53EF\u914D\u7F6E\u662F\u5426\u52A0\u901F\uFF1B\u6309\u4F4F Shift \u53EF\u6309\u5341\u500D\u6B65\u957F\u79FB\u52A8\u3002"
|
|
23164
|
+
}
|
|
23165
|
+
]
|
|
23166
|
+
}
|
|
23167
|
+
];
|
|
23168
|
+
|
|
23169
|
+
// src/tools/settings-keyboard-move/react.tsx
|
|
23170
|
+
var settingsKeyboardMoveTool = {
|
|
23171
|
+
toolId: "builtin.settings.keyboard-move",
|
|
23172
|
+
version: "0.1.0",
|
|
23173
|
+
label: "\u952E\u76D8\u79FB\u52A8",
|
|
23174
|
+
order: 60,
|
|
23175
|
+
placement: "section",
|
|
23176
|
+
parentToolId: "builtin.settings",
|
|
23177
|
+
sectionId: "keyboard-move",
|
|
23178
|
+
settingsSections: keyboardMoveSettingsSections,
|
|
23179
|
+
resolveKeyboardMove(event, heldMs, settings) {
|
|
23180
|
+
const direction = {
|
|
23181
|
+
ArrowLeft: { dx: -1, dy: 0 },
|
|
23182
|
+
ArrowRight: { dx: 1, dy: 0 },
|
|
23183
|
+
ArrowUp: { dx: 0, dy: -1 },
|
|
23184
|
+
ArrowDown: { dx: 0, dy: 1 }
|
|
23185
|
+
}[event.key];
|
|
23186
|
+
if (!direction) return null;
|
|
23187
|
+
const configuredStep = settings.keyboardMoveStep ?? 1;
|
|
23188
|
+
const baseStep = Number.isFinite(configuredStep) && configuredStep > 0 ? configuredStep : 1;
|
|
23189
|
+
const acceleration = settings.keyboardMoveAcceleration === true ? heldMs >= 1800 ? 10 : heldMs >= 1e3 ? 5 : heldMs >= 500 ? 2 : 1 : 1;
|
|
23190
|
+
const step = baseStep * acceleration * (event.shiftKey ? 10 : 1);
|
|
23191
|
+
return { dx: direction.dx * step, dy: direction.dy * step };
|
|
23192
|
+
}
|
|
23193
|
+
};
|
|
21811
23194
|
|
|
21812
23195
|
// src/tools/settings-indicators/properties.ts
|
|
21813
23196
|
var indicatorSettingsSections = [{
|
|
@@ -21899,11 +23282,13 @@ var builtinReactTools = [
|
|
|
21899
23282
|
settingsRulersTool,
|
|
21900
23283
|
settingsGuidesTool,
|
|
21901
23284
|
settingsInteractionTool,
|
|
23285
|
+
settingsKeyboardMoveTool,
|
|
21902
23286
|
settingsIndicatorsTool,
|
|
21903
23287
|
pluginmarketTool
|
|
21904
23288
|
];
|
|
21905
23289
|
var builtinReactComponentPlugins = [
|
|
21906
23290
|
textPlugin,
|
|
23291
|
+
richTextPlugin,
|
|
21907
23292
|
listPlugin,
|
|
21908
23293
|
dateTimePlugin,
|
|
21909
23294
|
moneyUpperPlugin,
|
|
@@ -21927,17 +23312,17 @@ var builtinReactComponentPlugins = [
|
|
|
21927
23312
|
pivotTablePlugin,
|
|
21928
23313
|
ganttPlugin
|
|
21929
23314
|
];
|
|
21930
|
-
var
|
|
23315
|
+
var menuGroups25 = /* @__PURE__ */ new Map();
|
|
21931
23316
|
for (const plugin of builtinReactComponentPlugins) {
|
|
21932
23317
|
for (const group of plugin.menuGroups) {
|
|
21933
|
-
const current2 =
|
|
23318
|
+
const current2 = menuGroups25.get(group.id);
|
|
21934
23319
|
if (current2) {
|
|
21935
23320
|
if (current2.title !== group.title || current2.order !== group.order) {
|
|
21936
23321
|
throw new Error(`\u83DC\u5355\u5206\u7EC4\u5B9A\u4E49\u4E0D\u4E00\u81F4\uFF1A${group.id}`);
|
|
21937
23322
|
}
|
|
21938
23323
|
current2.items.push(...group.items);
|
|
21939
23324
|
} else {
|
|
21940
|
-
|
|
23325
|
+
menuGroups25.set(group.id, { ...group, items: [...group.items] });
|
|
21941
23326
|
}
|
|
21942
23327
|
}
|
|
21943
23328
|
}
|
|
@@ -21978,7 +23363,7 @@ var builtinPrintDesignPlugins = Object.freeze({
|
|
|
21978
23363
|
componentFactories: new PrintDesignComponentFactoryRegistry(
|
|
21979
23364
|
builtinReactComponentPlugins.map((plugin) => plugin.factory)
|
|
21980
23365
|
),
|
|
21981
|
-
componentMenu: [...
|
|
23366
|
+
componentMenu: [...menuGroups25.values()].sort((a, b) => a.order - b.order).map((group) => ({
|
|
21982
23367
|
id: group.id,
|
|
21983
23368
|
title: group.title,
|
|
21984
23369
|
items: group.items.sort((a, b) => a.order - b.order)
|