@canvas-components/print-design-plugin 0.1.8 → 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.
@@ -55,7 +55,9 @@ function assertNativePluginDependencies(plugins) {
55
55
  function validateTextElement(value) {
56
56
  if (!value || typeof value !== "object") return false;
57
57
  const element = value;
58
- 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.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(
58
+ 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(
59
+ (value2) => Number.isFinite(value2) && value2 >= 0
60
+ )) && (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(
59
61
  (rule) => rule && Number.isInteger(rule.maxChars) && rule.maxChars >= 1 && Number.isFinite(rule.fontSize) && rule.fontSize > 0
60
62
  ));
61
63
  }
@@ -71,23 +73,36 @@ function graphemes(text) {
71
73
  function drawVerticalText(ctx, text, box, options) {
72
74
  if (box.width <= 0 || box.height <= 0) return;
73
75
  const step = Math.max(1, options.fontSize * options.lineHeight);
74
- const capacity = Math.max(1, Math.floor(box.height / step));
75
76
  const paragraphs = text.split(/\r?\n/).map(graphemes);
76
77
  const columns = paragraphs.flatMap((chars) => {
77
- if (!options.wrap || chars.length <= capacity) return [chars];
78
78
  const chunks = [];
79
- for (let index = 0; index < chars.length; index += capacity)
80
- chunks.push(chars.slice(index, index + capacity));
79
+ let offset = 0;
80
+ do {
81
+ const indent = options.indentMode === "firstLine" ? chunks.length === 0 ? options.indent ?? 0 : 0 : options.indentMode === "hanging" && chunks.length > 0 ? options.indent ?? 0 : 0;
82
+ const capacity = Math.max(1, Math.floor((box.height - indent) / step));
83
+ chunks.push({
84
+ chars: options.wrap === false ? chars.slice(offset) : chars.slice(offset, offset + capacity),
85
+ indent
86
+ });
87
+ offset += capacity;
88
+ } while (options.wrap !== false && offset < chars.length);
81
89
  return chunks;
82
90
  });
83
91
  const visibleCount = Math.max(1, Math.floor(box.width / step));
84
92
  const visible = columns.slice(0, visibleCount);
85
- const overflowed = columns.length > visibleCount || !options.wrap && visible.some((chars) => chars.length > capacity);
93
+ const overflowed = columns.length > visibleCount || !options.wrap && visible.some(
94
+ ({ chars, indent }) => chars.length > Math.max(1, Math.floor((box.height - indent) / step))
95
+ );
86
96
  if (options.ellipsis && overflowed && visible.length) {
87
- const last = [...visible[visible.length - 1]];
97
+ const previous = visible[visible.length - 1];
98
+ const capacity = Math.max(
99
+ 1,
100
+ Math.floor((box.height - previous.indent) / step)
101
+ );
102
+ const last = [...previous.chars];
88
103
  last.length = Math.min(last.length, capacity);
89
104
  last[Math.max(0, Math.min(last.length, capacity) - 1)] = "\u2026";
90
- visible[visible.length - 1] = last;
105
+ visible[visible.length - 1] = { ...previous, chars: last };
91
106
  }
92
107
  const blockWidth = visible.length * step;
93
108
  const left = options.align === "left" ? box.x : options.align === "center" ? box.x + (box.width - blockWidth) / 2 : box.x + box.width - blockWidth;
@@ -97,12 +112,17 @@ function drawVerticalText(ctx, text, box, options) {
97
112
  ctx.clip();
98
113
  ctx.textAlign = "center";
99
114
  ctx.textBaseline = "middle";
100
- visible.forEach((chars, column) => {
115
+ visible.forEach(({ chars, indent }, column) => {
101
116
  const textHeight = chars.length * step;
102
- const offset = options.verticalAlign === "bottom" ? Math.max(0, box.height - textHeight) : options.verticalAlign === "middle" ? Math.max(0, (box.height - textHeight) / 2) : 0;
117
+ const availableHeight = Math.max(0, box.height - indent);
118
+ const offset = options.verticalAlign === "bottom" ? Math.max(0, availableHeight - textHeight) : options.verticalAlign === "middle" ? Math.max(0, (availableHeight - textHeight) / 2) : 0;
103
119
  const centerX = left + blockWidth - (column + 0.5) * step;
104
120
  chars.forEach(
105
- (char, index) => ctx.fillText(char, centerX, box.y + offset + (index + 0.5) * step)
121
+ (char, index) => ctx.fillText(
122
+ char,
123
+ centerX,
124
+ box.y + indent + offset + (index + 0.5) * step
125
+ )
106
126
  );
107
127
  });
108
128
  ctx.restore();
@@ -143,15 +163,16 @@ function getTextLayoutCache(ctx) {
143
163
  }
144
164
  return entry;
145
165
  }
146
- function layoutSpacedText(ctx, text, width, prewrapped = false) {
166
+ function layoutSpacedText(ctx, text, width, prewrapped = false, indent) {
147
167
  const cache = getTextLayoutCache(ctx);
148
- const key = `${prewrapped}:${width}\0${text}`;
168
+ const key = `${prewrapped}:${width}:${indent?.mode ?? "none"}:${indent?.value ?? 0}\0${text}`;
149
169
  let lines = cache.lines.get(key);
150
170
  if (!lines) {
151
171
  lines = prewrapped ? text.split("\n").map((text2) => ({ text: text2, last: true })) : layoutAlignedText(
152
172
  text,
153
173
  width,
154
- (value) => measureSpacedText(ctx, value)
174
+ (value) => measureSpacedText(ctx, value),
175
+ indent
155
176
  );
156
177
  if (cache.lines.size >= 128) cache.lines.clear();
157
178
  cache.lines.set(key, lines);
@@ -205,28 +226,30 @@ function drawSpacedText(ctx, text, x, y) {
205
226
  });
206
227
  ctx.textAlign = align;
207
228
  }
208
- function layoutAlignedText(text, width, measure) {
229
+ function layoutAlignedText(text, width, measure, indent) {
209
230
  return text.split("\n").flatMap((paragraph) => {
210
231
  const lines = [];
211
232
  let line = "";
233
+ const indentation = (index) => indent?.mode === "firstLine" ? index === 0 ? indent.value : 0 : indent?.mode === "hanging" && index > 0 ? indent.value : 0;
212
234
  const tokens = paragraph.match(
213
235
  /[¥¥$€£]?\p{N}+(?:[.,:/-]\p{N}+)*(?:[%%])?|[\p{Script=Latin}\p{N}]+|\s+|[^\p{Script=Latin}\p{N}\s]+/gu
214
236
  ) ?? [];
215
237
  const pieces = tokens.flatMap(
216
238
  (token) => /^(?:[¥¥$€£]?\p{N}+(?:[.,:/-]\p{N}+)*(?:[%%])?|[\p{Script=Latin}\p{N}\s]+)$/u.test(
217
239
  token
218
- ) && measure(token) <= width ? [token] : graphemes(token)
240
+ ) && measure(token) <= Math.max(1, width - Math.max(0, indent?.value ?? 0)) ? [token] : graphemes(token)
219
241
  );
220
242
  for (const piece of pieces) {
221
- if (line && measure(line + piece) > width) {
222
- lines.push(line.trimEnd());
243
+ if (line && measure(line + piece) > Math.max(1, width - indentation(lines.length))) {
244
+ lines.push({ text: line.trimEnd(), indent: indentation(lines.length) });
223
245
  line = "";
224
246
  }
225
247
  if (line || piece.trim()) line += piece;
226
248
  }
227
- lines.push(line.trimEnd());
249
+ lines.push({ text: line.trimEnd(), indent: indentation(lines.length) });
228
250
  return lines.map((value, index) => ({
229
- text: value,
251
+ text: value.text,
252
+ ...indent && indent.mode !== "none" && indent.value > 0 ? { indent: value.indent } : {},
230
253
  last: index === lines.length - 1
231
254
  }));
232
255
  });
@@ -252,13 +275,7 @@ function drawAlignedTextLine(ctx, text, x, y, width, distributed) {
252
275
  });
253
276
  }
254
277
  function resolveTextFontFamily(family) {
255
- const selected = family?.trim();
256
- if (!selected) return printDesign.PRINT_DESIGN_DEFAULT_FONT_FAMILY;
257
- if (/\bPrintDesignNotoSansSC\b/i.test(selected)) return selected;
258
- if (!/(?:^|,)\s*['"]?Times New Roman['"]?(?:,|$)/i.test(selected) && !/(?:^|,)\s*serif\s*$/i.test(selected))
259
- return selected;
260
- const generic = /,\s*(sans-serif|serif|monospace|cursive|fantasy|system-ui)\s*$/i;
261
- return generic.test(selected) ? selected.replace(generic, ", PrintDesignNotoSansSC, $1") : `${selected}, PrintDesignNotoSansSC`;
278
+ return printDesign.resolvePrintDesignFontFamily(family);
262
279
  }
263
280
 
264
281
  // src/plugins/text/layout/measure.ts
@@ -276,7 +293,7 @@ function createHtmlTextMeasure(element, fontSize, fallback) {
276
293
  widths = /* @__PURE__ */ new Map();
277
294
  widthCaches.set(ownerDocument, widths);
278
295
  }
279
- const font = `${element.fontWeight ?? "400"} ${fontSize}pt ${resolveTextFontFamily(element.fontFamily)}`;
296
+ const font = `${element.fontStyle ?? "normal"} ${element.fontWeight ?? "400"} ${fontSize}pt ${resolveTextFontFamily(element.fontFamily)}`;
280
297
  let span;
281
298
  return {
282
299
  measure: (value) => {
@@ -307,6 +324,12 @@ function createHtmlTextMeasure(element, fontSize, fallback) {
307
324
  dispose: () => span?.remove()
308
325
  };
309
326
  }
327
+ function resolveTextIndentMm(element, fontSizePt) {
328
+ if (!element.indentMode || element.indentMode === "none") return 0;
329
+ const value = Math.max(0, element.indentValue ?? 0);
330
+ if (!Number.isFinite(value)) return 0;
331
+ return element.indentUnit === "char" || !element.indentUnit ? value * fontSizePt * 25.4 / 72 : printDesign.fromDisplayUnit(value, element.indentUnit);
332
+ }
310
333
 
311
334
  // src/plugins/text/rendering/formatting.ts
312
335
  function resolveTextFontSize(element, text) {
@@ -326,15 +349,15 @@ function ellipsizeTextLine(text, maxWidth, measure) {
326
349
 
327
350
  // src/plugins/text/rendering/draw.ts
328
351
  var loadedFonts = /* @__PURE__ */ new WeakMap();
329
- var DEFAULT_TEXT_BASELINE_CORRECTION_RATIO = 0.05;
330
352
  function prepareTextFont(element, signal) {
331
353
  const family = element.fontFamily?.trim();
332
354
  const source = element.fontSource?.trim();
333
355
  if (!family || !source) return Promise.resolve();
334
356
  if (typeof document === "undefined" || typeof FontFace === "undefined")
335
- return Promise.reject(new Error("\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u52A0\u8F7D\u6253\u5370\u5B57\u4F53\u3002"));
357
+ return Promise.resolve();
336
358
  signal?.throwIfAborted();
337
- const ready = ensureTextFont(element, document);
359
+ const ready = ensureTextFont(element, document).catch(() => {
360
+ });
338
361
  if (!signal) return ready;
339
362
  return new Promise((resolve, reject) => {
340
363
  const onAbort = () => reject(signal.reason);
@@ -401,7 +424,7 @@ var drawTextElement = (element, context) => {
401
424
  const resolvedFontSize = resolveTextFontSize(element, resolvedText);
402
425
  const fontSize = resolvedFontSize * 25.4 * scale / 72;
403
426
  ctx.fillStyle = element.color ?? "#1f2937";
404
- ctx.font = `${element.fontWeight ?? "400"} ${fontSize}px ${resolveTextFontFamily(element.fontFamily)}`;
427
+ ctx.font = `${element.fontStyle ?? "normal"} ${element.fontWeight ?? "400"} ${fontSize}px ${resolveTextFontFamily(element.fontFamily)}`;
405
428
  const expanded = element.textAlign === "justify" || element.textAlign === "distributed";
406
429
  ctx.textAlign = expanded ? "left" : element.textAlign ?? "left";
407
430
  ctx.textBaseline = "alphabetic";
@@ -416,7 +439,9 @@ var drawTextElement = (element, context) => {
416
439
  align: element.textAlign === "left" || element.textAlign === "center" ? element.textAlign : "right",
417
440
  verticalAlign: element.verticalAlign,
418
441
  wrap: true,
419
- ellipsis: element.heightOverflow === "ellipsis"
442
+ ellipsis: element.heightOverflow === "ellipsis",
443
+ indentMode: element.indentMode,
444
+ indent: resolveTextIndentMm(element, resolvedFontSize) * scale
420
445
  }
421
446
  );
422
447
  return;
@@ -425,19 +450,31 @@ var drawTextElement = (element, context) => {
425
450
  const fontMetrics = ctx.measureText?.("Hg");
426
451
  const ascent = fontMetrics?.fontBoundingBoxAscent ?? fontSize * 0.8;
427
452
  const descent = fontMetrics?.fontBoundingBoxDescent ?? fontSize * 0.2;
428
- const defaultFont = !element.fontFamily || element.fontFamily === printDesign.PRINT_DESIGN_DEFAULT_FONT_FAMILY;
429
- const regularNoto = element.fontFamily?.startsWith("PrintDesignNotoSansSC") && !/^(?:bold|[6-9]00)$/i.test(element.fontWeight ?? "400");
430
- const baselineOffset = (lineHeight - ascent - descent) / 2 + ascent - (defaultFont || regularNoto ? fontSize * DEFAULT_TEXT_BASELINE_CORRECTION_RATIO : 0);
453
+ const baselineOffset = (lineHeight - ascent - descent) / 2 + ascent;
431
454
  const measure = (text) => measureSpacedText(ctx, text);
432
- let lines = layoutSpacedText(ctx, resolvedText, width, element.prewrapped);
455
+ const indentPx = resolveTextIndentMm(element, resolvedFontSize) * scale;
456
+ let lines = layoutSpacedText(ctx, resolvedText, width, element.prewrapped, {
457
+ mode: element.indentMode ?? "none",
458
+ value: indentPx
459
+ });
460
+ if (element.prewrappedIndents)
461
+ lines = lines.map((line, index) => ({
462
+ ...line,
463
+ indent: (element.prewrappedIndents?.[index] ?? 0) * scale
464
+ }));
433
465
  if (element.heightOverflow) {
434
466
  const fit = Math.max(0, Math.floor(height / lineHeight));
435
467
  if (lines.length > fit) {
436
468
  lines = lines.slice(0, fit);
437
469
  if (fit && element.heightOverflow === "ellipsis")
438
470
  lines[fit - 1] = {
439
- text: ellipsizeTextLine(lines[fit - 1].text, width, measure),
440
- last: true
471
+ text: ellipsizeTextLine(
472
+ lines[fit - 1].text,
473
+ Math.max(1, width - (lines[fit - 1].indent ?? 0)),
474
+ measure
475
+ ),
476
+ last: true,
477
+ indent: lines[fit - 1].indent
441
478
  };
442
479
  }
443
480
  ctx.beginPath();
@@ -445,16 +482,22 @@ var drawTextElement = (element, context) => {
445
482
  ctx.clip();
446
483
  }
447
484
  const verticalOffset = element.verticalAlign === "middle" ? Math.max(0, (height - lines.length * lineHeight) / 2) : element.verticalAlign === "bottom" ? Math.max(0, height - lines.length * lineHeight) : 0;
448
- const textX = element.textAlign === "center" ? x + width / 2 : element.textAlign === "right" ? x + width : x;
449
485
  lines.forEach((line, index) => {
450
486
  const lineY = y + verticalOffset + index * lineHeight + baselineOffset;
487
+ const lineIndent = Math.min(
488
+ Math.max(0, line.indent ?? 0),
489
+ Math.max(0, width)
490
+ );
491
+ const lineLeft = x + lineIndent;
492
+ const lineWidth = Math.max(0, width - lineIndent);
493
+ const textX = element.textAlign === "center" ? lineLeft + lineWidth / 2 : element.textAlign === "right" ? x + width : lineLeft;
451
494
  if (expanded && (element.textAlign === "distributed" || !line.last)) {
452
495
  drawAlignedTextLine(
453
496
  ctx,
454
497
  line.text,
455
- x,
498
+ lineLeft,
456
499
  lineY,
457
- width,
500
+ lineWidth,
458
501
  element.textAlign === "distributed"
459
502
  );
460
503
  } else {
@@ -465,8 +508,8 @@ var drawTextElement = (element, context) => {
465
508
  Math.max(0, Math.floor(element.underlineCount ?? 0))
466
509
  );
467
510
  if (!count || !line.text) return;
468
- const textWidth = Math.min(width, measure(line.text));
469
- const left = expanded && (element.textAlign === "distributed" || !line.last) ? x : element.textAlign === "center" ? textX - textWidth / 2 : element.textAlign === "right" ? textX - textWidth : textX;
511
+ const textWidth = Math.min(lineWidth, measure(line.text));
512
+ const left = expanded && (element.textAlign === "distributed" || !line.last) ? lineLeft : element.textAlign === "center" ? textX - textWidth / 2 : element.textAlign === "right" ? textX - textWidth : textX;
470
513
  ctx.save();
471
514
  ctx.strokeStyle = element.underlineColor ?? element.color ?? "#1f2937";
472
515
  ctx.lineWidth = Math.max(0.5, (element.underlineWidth ?? 0.2) * scale);
@@ -517,13 +560,24 @@ function textMarkup(text, element, size = 14, color2 = "#1f2937") {
517
560
  const weight = /^(?:[1-9]00|normal|bold)$/.test(
518
561
  textElement?.fontWeight ?? "400"
519
562
  ) ? textElement?.fontWeight ?? "400" : "400";
563
+ const fontStyle = textElement?.fontStyle === "italic" ? "italic" : "normal";
520
564
  const fontSize = textElement ? resolveTextFontSize(textElement, text) : printDesign.cssNumber(size, 14);
521
- if (textElement?.textDirection === "vertical")
522
- return `<div class="pd-text" style="display:block;font:${weight} ${fontSize}pt ${printDesign.escapeHtml(printDesign.cssFont(resolveTextFontFamily(textElement.fontFamily)))};color:${printDesign.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:${printDesign.cssNumber(textElement.lineHeight, 1.35)}">${printDesign.escapeHtml(text)}</div>`;
565
+ if (textElement?.textDirection === "vertical") {
566
+ const indentMm2 = resolveTextIndentMm(textElement, fontSize);
567
+ const paragraphStyle = indentMm2 <= 0 ? "" : textElement.indentMode === "firstLine" ? `text-indent:${printDesign.cssNumber(indentMm2, 0)}mm;` : `padding-top:${printDesign.cssNumber(indentMm2, 0)}mm;text-indent:-${printDesign.cssNumber(indentMm2, 0)}mm;box-sizing:border-box;`;
568
+ const content = indentMm2 > 0 ? text.split("\n").map(
569
+ (paragraph) => `<div style="${paragraphStyle}">${printDesign.escapeHtml(paragraph) || "<br>"}</div>`
570
+ ).join("") : printDesign.escapeHtml(text);
571
+ return `<div class="pd-text" style="display:block;font:${fontStyle} ${weight} ${fontSize}pt ${printDesign.escapeHtml(printDesign.cssFont(resolveTextFontFamily(textElement.fontFamily)))};color:${printDesign.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:${printDesign.cssNumber(textElement.lineHeight, 1.35)}">${content}</div>`;
572
+ }
573
+ const indentMm = textElement ? resolveTextIndentMm(textElement, fontSize) : 0;
574
+ const indentStyle = (lineIndex) => indentMm > 0 && textElement ? textElement.indentMode === "firstLine" ? lineIndex === 0 ? `text-indent:${printDesign.cssNumber(indentMm, 0)}mm;` : "" : textElement.indentMode === "hanging" ? `padding-left:${printDesign.cssNumber(indentMm, 0)}mm;text-indent:${`-${printDesign.cssNumber(indentMm, 0)}mm` };box-sizing:border-box;` : "" : "";
523
575
  const lines = textElement?.prewrapped ? text.split("\n").map(
524
- (line) => `<div style="white-space:pre;overflow:hidden;flex:none"><span style="${underlineCss(textElement)}">${printDesign.escapeHtml(line) || "<br>"}</span></div>`
576
+ (line, index) => `<div style="white-space:pre;overflow:hidden;flex:none${textElement.prewrappedIndents ? `;box-sizing:border-box;padding-left:${printDesign.cssNumber(textElement.prewrappedIndents[index] ?? 0, 0)}mm` : ""}"><span style="${underlineCss(textElement)}">${printDesign.escapeHtml(line) || "<br>"}</span></div>`
577
+ ).join("") : indentMm > 0 ? text.split("\n").map(
578
+ (paragraph) => `<div style="min-width:0;white-space:pre-wrap;overflow-wrap:anywhere;${indentStyle(0)}"><span style="${textElement ? underlineCss(textElement) : ""}">${printDesign.escapeHtml(paragraph) || "<br>"}</span></div>`
525
579
  ).join("") : `<div style="min-width:0;white-space:pre-wrap;overflow-wrap:anywhere"><span style="${textElement ? underlineCss(textElement) : ""}">${printDesign.escapeHtml(text)}</span></div>`;
526
- return `<div class="pd-text" style="font:${weight} ${fontSize}pt ${printDesign.escapeHtml(printDesign.cssFont(resolveTextFontFamily(textElement?.fontFamily)))};color:${printDesign.cssColor(color2, "#1f2937")};text-align:${align};line-height:${printDesign.cssNumber(textElement?.lineHeight, 1.35)};justify-content:${vertical === "middle" ? "center" : vertical === "bottom" ? "flex-end" : "flex-start"}">${lines}</div>`;
580
+ return `<div class="pd-text" style="font:${fontStyle} ${weight} ${fontSize}pt ${printDesign.escapeHtml(printDesign.cssFont(resolveTextFontFamily(textElement?.fontFamily)))};color:${printDesign.cssColor(color2, "#1f2937")};text-align:${align};line-height:${printDesign.cssNumber(textElement?.lineHeight, 1.35)};justify-content:${vertical === "middle" ? "center" : vertical === "bottom" ? "flex-end" : "flex-start"}">${lines}</div>`;
527
581
  }
528
582
  function underlineCss(element) {
529
583
  const count = Math.min(
@@ -558,6 +612,18 @@ function textFontCss(element) {
558
612
  return `@font-face{font-family:${printDesign.cssFont(element.fontFamily)};src:url("${source}")}`;
559
613
  }
560
614
  var PT_TO_MM = 25.4 / 72;
615
+ function layoutText(element, text, measure) {
616
+ if (element.prewrapped)
617
+ return text.split("\n").map((line, index) => ({
618
+ text: line,
619
+ last: true,
620
+ indent: element.prewrappedIndents?.[index] ?? 0
621
+ }));
622
+ return layoutAlignedText(text, element.width, measure, {
623
+ mode: element.indentMode ?? "none",
624
+ value: resolveTextIndentMm(element, resolveTextFontSize(element, text))
625
+ });
626
+ }
561
627
  function paginateText(element, { data, startPage, startY, top, bottom, pageAt }) {
562
628
  const text = element.dataConfig?.mode === "binding" ? element.text : printDesign.resolveDesignText(element.text, data);
563
629
  if (element.textDirection === "vertical") {
@@ -585,9 +651,7 @@ function paginateText(element, { data, startPage, startY, top, bottom, pageAt })
585
651
  );
586
652
  let lines;
587
653
  try {
588
- lines = layoutAlignedText(text, element.width, measurement.measure).map(
589
- (line) => line.text
590
- );
654
+ lines = layoutText(element, text, measurement.measure);
591
655
  } finally {
592
656
  measurement.dispose();
593
657
  }
@@ -616,7 +680,8 @@ function paginateText(element, { data, startPage, startY, top, bottom, pageAt })
616
680
  previewSourceId: element.previewSourceId ?? element.id,
617
681
  y,
618
682
  height,
619
- text: chunk.join("\n"),
683
+ text: chunk.map((line) => line.text).join("\n"),
684
+ ...element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? { prewrappedIndents: chunk.map((line) => line.indent ?? 0) } : {},
620
685
  prewrapped: true,
621
686
  verticalAlign: "top",
622
687
  dataConfig: void 0
@@ -644,7 +709,11 @@ function prewrapText(element) {
644
709
  (value) => estimateTextWidth(value, fontMm)
645
710
  );
646
711
  try {
647
- return layoutAlignedText(element.text, element.width, measurement.measure).map((line) => line.text).join("\n");
712
+ const lines = layoutText(element, element.text, measurement.measure);
713
+ return {
714
+ text: lines.map((line) => line.text).join("\n"),
715
+ indents: element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? lines.map((line) => line.indent ?? 0) : void 0
716
+ };
648
717
  } finally {
649
718
  measurement.dispose();
650
719
  }
@@ -657,12 +726,12 @@ function estimateTextHeight(element) {
657
726
  (value) => estimateTextWidth(value, fontMm)
658
727
  );
659
728
  try {
660
- return layoutAlignedText(element.text, element.width, measurement.measure).length * fontMm * (element.lineHeight ?? 1.35);
729
+ return layoutText(element, element.text, measurement.measure).length * fontMm * (element.lineHeight ?? 1.35);
661
730
  } finally {
662
731
  measurement.dispose();
663
732
  }
664
733
  }
665
- function truncateText(element, height, mode) {
734
+ function truncateTextLayout(element, height, mode) {
666
735
  const fontMm = Math.max(1, (element.fontSize ?? 14) * PT_TO_MM);
667
736
  const lineMm = fontMm * (element.lineHeight ?? 1.35);
668
737
  const measurement = createHtmlTextMeasure(
@@ -671,21 +740,21 @@ function truncateText(element, height, mode) {
671
740
  (value) => estimateTextWidth(value, fontMm)
672
741
  );
673
742
  try {
674
- const lines = layoutAlignedText(
675
- element.text,
676
- element.width,
677
- measurement.measure
678
- );
743
+ const lines = layoutText(element, element.text, measurement.measure);
679
744
  const fit = Math.max(0, Math.floor(height / lineMm));
680
- if (lines.length <= fit) return element.text;
681
- const visible = lines.slice(0, fit).map((line) => line.text);
745
+ const visibleLines = lines.slice(0, fit);
746
+ const visible = visibleLines.map((line) => line.text);
682
747
  if (fit && mode === "ellipsis")
683
748
  visible[fit - 1] = ellipsizeTextLine(
684
749
  visible[fit - 1],
685
- element.width,
750
+ Math.max(1, element.width - (lines[fit - 1]?.indent ?? 0)),
686
751
  measurement.measure
687
752
  );
688
- return visible.join("\n");
753
+ return {
754
+ text: visible.join("\n"),
755
+ indents: element.indentMode && element.indentMode !== "none" && (element.indentValue ?? 0) > 0 ? visibleLines.map((line) => line.indent ?? 0) : void 0,
756
+ overflowed: lines.length > fit
757
+ };
689
758
  } finally {
690
759
  measurement.dispose();
691
760
  }
@@ -715,11 +784,13 @@ function prepareTextPagination(element, data) {
715
784
  };
716
785
  if (element.textDirection === "vertical" || element.overflowPolicy === "split" || element.heightOverflow === "flow" && element.overflowPolicy !== "nextPage")
717
786
  return prepared;
718
- const printable = element.heightOverflow && element.heightOverflow !== "flow" ? {
787
+ const wrapped = element.heightOverflow && element.heightOverflow !== "flow" ? truncateTextLayout(prepared, prepared.height, element.heightOverflow) : prewrapText(prepared);
788
+ return {
719
789
  ...prepared,
720
- text: truncateText(prepared, prepared.height, element.heightOverflow)
721
- } : prepared;
722
- return { ...printable, text: prewrapText(printable), prewrapped: true };
790
+ text: wrapped.text,
791
+ ...wrapped.indents ? { prewrappedIndents: wrapped.indents } : {},
792
+ prewrapped: true
793
+ };
723
794
  }
724
795
  function measureTextFlowHeight(element, data) {
725
796
  if (element.heightOverflow && element.heightOverflow !== "flow")
@@ -728,7 +799,13 @@ function measureTextFlowHeight(element, data) {
728
799
  return Math.max(prepared.height, estimateTextHeight(prepared));
729
800
  }
730
801
  function truncateTextOverflow(element, height, mode) {
731
- return { ...element, text: truncateText(element, height, mode) };
802
+ const truncated = truncateTextLayout(element, height, mode);
803
+ return {
804
+ ...element,
805
+ text: truncated.text,
806
+ prewrapped: true,
807
+ ...truncated.indents ? { prewrappedIndents: truncated.indents } : {}
808
+ };
732
809
  }
733
810
  function registeredFieldBindingInfo(element, fields) {
734
811
  const config = printDesign.getPrintDesignElementDataConfig(element, fields);
@@ -801,14 +878,14 @@ function resolveTextFontSizeValue(value, defaultUnit = "mm") {
801
878
  // src/plugins/text/data/binding.ts
802
879
  function getTextBindingInfo(element) {
803
880
  const content = registeredFieldBindingInfo(element, textDataFields);
804
- const paths = [
881
+ const paths2 = [
805
882
  ...content.paths,
806
883
  element.colorMode === "binding" ? element.colorPath : void 0,
807
884
  element.fontSizeMode === "binding" ? element.fontSizePath : void 0
808
885
  ].filter((path) => !!path?.trim());
809
886
  return {
810
887
  bound: content.bound || element.colorMode === "binding" || element.fontSizeMode === "binding",
811
- paths
888
+ paths: paths2
812
889
  };
813
890
  }
814
891
  function missingExpressionPath(expression, data) {
@@ -868,7 +945,7 @@ function resolveTextData(element, data) {
868
945
  // src/plugins/text/native.ts
869
946
  var textNativePlugin = defineNativePlugin(
870
947
  "text",
871
- "0.1.34",
948
+ "0.1.38",
872
949
  printDesign.definePrintDesignPluginRenderer({
873
950
  type: "text",
874
951
  dataFields: textDataFields,
@@ -891,6 +968,268 @@ var textNativePlugin = defineNativePlugin(
891
968
  inlineTextEditor: textInlineEditor
892
969
  })
893
970
  );
971
+
972
+ // src/plugins/rich-text/model.ts
973
+ function validateRichTextElement(value) {
974
+ if (!value || typeof value !== "object") return false;
975
+ const element = value;
976
+ return element.type === "richText" && (element.dataConfig === void 0 || element.dataConfig.mode === "static") && Array.isArray(element.runs) && element.runs.length <= 2e3 && element.runs.reduce(
977
+ (length, run) => length + (typeof run?.text === "string" ? run.text.length : 0),
978
+ 0
979
+ ) <= 1e5 && element.runs.every(
980
+ (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(
981
+ (key) => ["fontFamily", "fontSize", "fontWeight", "fontStyle", "color"].includes(key)
982
+ ) && (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)))
983
+ ) && (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(
984
+ (indent) => Number.isFinite(indent) && indent >= 0
985
+ ));
986
+ }
987
+ function richTextIndentMm(element) {
988
+ if (!element.indentMode || element.indentMode === "none") return 0;
989
+ const value = Math.max(0, element.indentValue ?? 0);
990
+ return element.indentUnit === "char" || !element.indentUnit ? value * (element.fontSize ?? 14) * 25.4 / 72 : printDesign.fromDisplayUnit(value, element.indentUnit);
991
+ }
992
+ function richTextGraphemes(text) {
993
+ const Segmenter = Intl.Segmenter;
994
+ return Segmenter ? Array.from(
995
+ new Segmenter(void 0, { granularity: "grapheme" }).segment(text),
996
+ (part) => part.segment
997
+ ) : Array.from(text);
998
+ }
999
+
1000
+ // src/plugins/rich-text/rendering.ts
1001
+ function runStyle(element, run) {
1002
+ return {
1003
+ fontFamily: printDesign.resolvePrintDesignFontFamily(
1004
+ run.style?.fontFamily ?? element.fontFamily
1005
+ ),
1006
+ fontSize: run.style?.fontSize ?? element.fontSize ?? 14,
1007
+ fontWeight: run.style?.fontWeight ?? element.fontWeight ?? "400",
1008
+ fontStyle: run.style?.fontStyle ?? element.fontStyle ?? "normal",
1009
+ color: run.style?.color ?? element.color ?? "#1f2937"
1010
+ };
1011
+ }
1012
+ function layoutRichTextLines(element, width, scale, measure) {
1013
+ const indent = richTextIndentMm(element) * scale;
1014
+ const lineHeight = element.lineHeight ?? 1.35;
1015
+ const lines = [];
1016
+ let paragraphLine = 0;
1017
+ const addLine = () => {
1018
+ const inset = element.prewrapped ? (element.prewrappedIndents?.[lines.length] ?? 0) * scale : element.indentMode === "firstLine" && paragraphLine === 0 || element.indentMode === "hanging" && paragraphLine > 0 ? indent : 0;
1019
+ lines.push({
1020
+ chars: [],
1021
+ width: 0,
1022
+ indent: inset,
1023
+ height: (element.fontSize ?? 14) * 25.4 / 72 * scale * lineHeight
1024
+ });
1025
+ };
1026
+ addLine();
1027
+ for (const run of element.runs) {
1028
+ const style = runStyle(element, run);
1029
+ const fontSize = style.fontSize * 25.4 / 72 * scale;
1030
+ for (const char of richTextGraphemes(run.text.replace(/\r\n?/g, "\n"))) {
1031
+ if (char === "\n") {
1032
+ paragraphLine = 0;
1033
+ addLine();
1034
+ continue;
1035
+ }
1036
+ const charWidth = measure(char, style, fontSize);
1037
+ let line = lines[lines.length - 1];
1038
+ if (!element.prewrapped && line.chars.length && line.width + charWidth > Math.max(1, width - line.indent)) {
1039
+ paragraphLine++;
1040
+ addLine();
1041
+ line = lines[lines.length - 1];
1042
+ }
1043
+ line.chars.push({ text: char, width: charWidth, style });
1044
+ line.width += charWidth;
1045
+ line.height = Math.max(line.height, fontSize * lineHeight);
1046
+ }
1047
+ }
1048
+ return lines;
1049
+ }
1050
+ function drawRichTextElement(element, { ctx, scale, x, y, width, height }) {
1051
+ const lineHeight = element.lineHeight ?? 1.35;
1052
+ const lines = layoutRichTextLines(
1053
+ element,
1054
+ width,
1055
+ scale,
1056
+ (char, style, fontSize) => {
1057
+ ctx.font = `${style.fontStyle} ${style.fontWeight} ${fontSize}px ${style.fontFamily}`;
1058
+ return ctx.measureText(char).width;
1059
+ }
1060
+ );
1061
+ const totalHeight = lines.reduce((sum, line) => sum + line.height, 0);
1062
+ let top = y + (element.verticalAlign === "middle" ? Math.max(0, (height - totalHeight) / 2) : element.verticalAlign === "bottom" ? Math.max(0, height - totalHeight) : 0);
1063
+ ctx.save();
1064
+ ctx.beginPath();
1065
+ ctx.rect(x, y, width, height);
1066
+ ctx.clip();
1067
+ ctx.textAlign = "left";
1068
+ ctx.textBaseline = "alphabetic";
1069
+ for (const line of lines) {
1070
+ let left = x + line.indent;
1071
+ const available = Math.max(0, width - line.indent);
1072
+ if (element.textAlign === "center") left += (available - line.width) / 2;
1073
+ if (element.textAlign === "right") left += available - line.width;
1074
+ for (const char of line.chars) {
1075
+ const fontSize = char.style.fontSize * 25.4 / 72 * scale;
1076
+ ctx.font = `${char.style.fontStyle} ${char.style.fontWeight} ${fontSize}px ${char.style.fontFamily}`;
1077
+ ctx.fillStyle = char.style.color;
1078
+ ctx.fillText(
1079
+ char.text,
1080
+ left,
1081
+ top + (line.height - fontSize * lineHeight) / 2 + fontSize
1082
+ );
1083
+ left += char.width;
1084
+ }
1085
+ top += line.height;
1086
+ }
1087
+ ctx.restore();
1088
+ }
1089
+ function renderRichTextHtml(element) {
1090
+ const baseSize = printDesign.cssNumber(element.fontSize, 14);
1091
+ const indent = richTextIndentMm(element);
1092
+ const paragraphs = [""];
1093
+ for (const run of element.runs) {
1094
+ const style = runStyle(element, run);
1095
+ const css = `font-family:${printDesign.escapeHtml(printDesign.cssFont(style.fontFamily))};font-size:${printDesign.cssNumber(style.fontSize, baseSize)}pt;font-weight:${printDesign.escapeHtml(style.fontWeight)};font-style:${style.fontStyle};color:${printDesign.cssColor(style.color, "#1f2937")}`;
1096
+ const chunks = run.text.replace(/\r\n?/g, "\n").split("\n");
1097
+ chunks.forEach((chunk, index) => {
1098
+ if (index) paragraphs.push("");
1099
+ paragraphs[paragraphs.length - 1] += `<span style="${css}">${printDesign.escapeHtml(chunk)}</span>`;
1100
+ });
1101
+ }
1102
+ const paragraphCss = element.indentMode === "firstLine" && indent > 0 ? `text-indent:${printDesign.cssNumber(indent, 0)}mm;` : element.indentMode === "hanging" && indent > 0 ? `padding-left:${printDesign.cssNumber(indent, 0)}mm;text-indent:-${printDesign.cssNumber(indent, 0)}mm;box-sizing:border-box;` : "";
1103
+ const body = paragraphs.map(
1104
+ (paragraph, index) => `<div style="${element.prewrapped ? `white-space:pre;overflow:hidden;flex:none;box-sizing:border-box;padding-left:${printDesign.cssNumber(element.prewrappedIndents?.[index], 0)}mm;` : paragraphCss}">${paragraph || "<br>"}</div>`
1105
+ ).join("");
1106
+ return printDesign.renderPrintDesignHtmlFrame(
1107
+ element,
1108
+ `<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:${printDesign.cssNumber(element.lineHeight, 1.35)};font-family:${printDesign.escapeHtml(printDesign.cssFont(element.fontFamily))};font-size:${baseSize}pt;font-weight:${printDesign.escapeHtml(element.fontWeight ?? "400")};font-style:${element.fontStyle ?? "normal"};color:${printDesign.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>`
1109
+ );
1110
+ }
1111
+
1112
+ // src/plugins/rich-text/pagination.ts
1113
+ function measureLines(element) {
1114
+ const canvas = typeof document !== "undefined" ? document.createElement("canvas") : null;
1115
+ const context = canvas?.getContext("2d");
1116
+ return layoutRichTextLines(element, element.width, 1, (text, style, size) => {
1117
+ if (context) {
1118
+ context.font = `${style.fontStyle} ${style.fontWeight} ${size}px ${style.fontFamily}`;
1119
+ return context.measureText(text).width;
1120
+ }
1121
+ return size * (/[^\p{ASCII}]/u.test(text) ? 1 : 0.55);
1122
+ });
1123
+ }
1124
+ function linesToRuns(lines) {
1125
+ const result = [];
1126
+ for (const [index, line] of lines.entries()) {
1127
+ if (index) result.push({ text: "\n" });
1128
+ for (const char of line.chars) {
1129
+ const previous = result[result.length - 1];
1130
+ const style = char.style;
1131
+ if (previous && JSON.stringify(previous.style) === JSON.stringify(style))
1132
+ previous.text += char.text;
1133
+ else result.push({ text: char.text, style });
1134
+ }
1135
+ }
1136
+ return result;
1137
+ }
1138
+ function truncateRichTextOverflow(element, height, mode) {
1139
+ const lines = measureLines(element);
1140
+ const visible = [];
1141
+ let used = 0;
1142
+ for (const line of lines) {
1143
+ if (visible.length && used + line.height > height) break;
1144
+ visible.push({ ...line, chars: [...line.chars] });
1145
+ used += line.height;
1146
+ }
1147
+ if (mode === "ellipsis" && visible.length < lines.length && visible.length) {
1148
+ const last = visible[visible.length - 1];
1149
+ const style = last.chars[last.chars.length - 1]?.style ?? {
1150
+ fontFamily: element.fontFamily ?? "Arial, sans-serif",
1151
+ fontSize: element.fontSize ?? 14,
1152
+ fontWeight: element.fontWeight ?? "400",
1153
+ fontStyle: element.fontStyle ?? "normal",
1154
+ color: element.color ?? "#1f2937"
1155
+ };
1156
+ const ellipsisWidth = style.fontSize * 25.4 / 72;
1157
+ while (last.chars.length && last.width + ellipsisWidth > element.width - last.indent) {
1158
+ last.width -= last.chars.pop().width;
1159
+ }
1160
+ last.chars.push({ text: "\u2026", style, width: ellipsisWidth });
1161
+ last.width += ellipsisWidth;
1162
+ }
1163
+ return {
1164
+ ...element,
1165
+ runs: linesToRuns(visible),
1166
+ prewrapped: true,
1167
+ prewrappedIndents: visible.map((line) => line.indent),
1168
+ verticalAlign: "top"
1169
+ };
1170
+ }
1171
+ function paginateRichText(element, context) {
1172
+ const lines = measureLines(element);
1173
+ let pageIndex = context.startPage;
1174
+ let y = context.startY;
1175
+ let offset = 0;
1176
+ do {
1177
+ const remaining = () => context.bottom - y;
1178
+ if (remaining() < (lines[offset]?.height ?? 0) && y > context.top) {
1179
+ pageIndex++;
1180
+ y = context.top;
1181
+ }
1182
+ const chunk = [];
1183
+ let height = 0;
1184
+ while (offset < lines.length && (!chunk.length || height + lines[offset].height <= remaining())) {
1185
+ chunk.push(lines[offset]);
1186
+ height += lines[offset].height;
1187
+ offset++;
1188
+ }
1189
+ const continues = offset < lines.length;
1190
+ const finalHeight = continues ? Math.max(0, remaining()) : Math.max(height, element.height);
1191
+ context.pageAt(pageIndex).elements.push({
1192
+ ...element,
1193
+ id: `${element.id}:flow:${pageIndex}`,
1194
+ previewSourceId: element.previewSourceId ?? element.id,
1195
+ y,
1196
+ height: Math.min(Math.max(0, remaining()), finalHeight),
1197
+ runs: linesToRuns(chunk),
1198
+ prewrapped: true,
1199
+ prewrappedIndents: chunk.map((line) => line.indent),
1200
+ verticalAlign: "top"
1201
+ });
1202
+ y += Math.min(Math.max(0, remaining()), finalHeight);
1203
+ if (continues) {
1204
+ pageIndex++;
1205
+ y = context.top;
1206
+ }
1207
+ } while (offset < lines.length);
1208
+ return {
1209
+ logicalEnd: pageIndex * (context.bottom - context.top) + (y - context.top)
1210
+ };
1211
+ }
1212
+ function measureRichTextFlowHeight(element) {
1213
+ return Math.max(
1214
+ element.height,
1215
+ measureLines(element).reduce((height, line) => height + line.height, 0)
1216
+ );
1217
+ }
1218
+
1219
+ // src/plugins/rich-text/native.ts
1220
+ var richTextNativePlugin = defineNativePlugin(
1221
+ "richText",
1222
+ "0.1.1",
1223
+ printDesign.definePrintDesignPluginRenderer({
1224
+ type: "richText",
1225
+ validate: validateRichTextElement,
1226
+ drawCanvas: drawRichTextElement,
1227
+ renderHtml: (element) => renderRichTextHtml(element),
1228
+ paginate: paginateRichText,
1229
+ measureFlowHeight: measureRichTextFlowHeight,
1230
+ truncateOverflow: truncateRichTextOverflow
1231
+ })
1232
+ );
894
1233
  var drawListElement = (element, context) => {
895
1234
  const { ctx, x, y, width, height, scale, data } = context;
896
1235
  const row = Math.max(1, element.rowHeight ?? 8) * scale;
@@ -991,8 +1330,8 @@ function itemPaths(text) {
991
1330
  return [...text.matchAll(LIST_EXPRESSION)].map((match) => match[1]);
992
1331
  }
993
1332
  function listBindingInfo(element) {
994
- const paths = [...new Set(element.items.flatMap((item) => itemPaths(item.text)))];
995
- return { bound: paths.length > 0, paths };
1333
+ const paths2 = [...new Set(element.items.flatMap((item) => itemPaths(item.text)))];
1334
+ return { bound: paths2.length > 0, paths: paths2 };
996
1335
  }
997
1336
  function validateListTemplateData(element, data) {
998
1337
  if (!data) return [];
@@ -1107,9 +1446,9 @@ function dateTimeBindingInfo(element) {
1107
1446
  }
1108
1447
  function validateDateTimeTemplateData(element, data) {
1109
1448
  if (!data) return [];
1110
- const { bound, paths } = dateTimeBindingInfo(element);
1449
+ const { bound, paths: paths2 } = dateTimeBindingInfo(element);
1111
1450
  if (!bound) return [];
1112
- const expression = paths[0];
1451
+ const expression = paths2[0];
1113
1452
  if (!expression) return ["\u672A\u914D\u7F6E\u65E5\u671F\u65F6\u95F4\u7ED1\u5B9A\u5B57\u6BB5"];
1114
1453
  const value = printDesign.resolvePrintDesignBinding(data, expression);
1115
1454
  const text = typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value).trim() : "";
@@ -1236,9 +1575,9 @@ function moneyUpperBindingInfo(element) {
1236
1575
  }
1237
1576
  function validateMoneyUpperTemplateData(element, data) {
1238
1577
  if (!data) return [];
1239
- const { bound, paths } = moneyUpperBindingInfo(element);
1578
+ const { bound, paths: paths2 } = moneyUpperBindingInfo(element);
1240
1579
  if (!bound) return [];
1241
- const expression = paths[0];
1580
+ const expression = paths2[0];
1242
1581
  if (!expression) return ["\u672A\u914D\u7F6E\u91D1\u989D\u7ED1\u5B9A\u5B57\u6BB5"];
1243
1582
  const value = printDesign.resolvePrintDesignBinding(data, expression);
1244
1583
  const numeric2 = typeof value === "number" || typeof value === "string" && value.trim() !== "" ? Number(value) : NaN;
@@ -1318,9 +1657,9 @@ function pageNumberBindingInfo(element) {
1318
1657
  }
1319
1658
  function validatePageNumberTemplateData(element, data) {
1320
1659
  if (!data) return [];
1321
- const { bound, paths } = pageNumberBindingInfo(element);
1660
+ const { bound, paths: paths2 } = pageNumberBindingInfo(element);
1322
1661
  if (!bound) return [];
1323
- const expression = paths[0];
1662
+ const expression = paths2[0];
1324
1663
  if (!expression) return ["\u672A\u914D\u7F6E\u9875\u7801\u524D\u7F00\u7ED1\u5B9A\u5B57\u6BB5"];
1325
1664
  const value = printDesign.resolvePrintDesignBinding(data, expression);
1326
1665
  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`];
@@ -1422,23 +1761,18 @@ function renderWatermarkHtml(element, data, preciseClip = false) {
1422
1761
  const text = printDesign.escapeHtml(
1423
1762
  element.dataConfig ? element.text : printDesign.resolveDesignText(element.text, data)
1424
1763
  );
1425
- if (!preciseClip) {
1426
- const fontSize2 = printDesign.cssNumber(element.fontSize, 24);
1427
- const cell = `<span style="color:${printDesign.cssColor(element.color, "#94a3b8")};font-size:${fontSize2}pt;transform:rotate(${printDesign.cssNumber(element.textRotation, 45)}deg) translateY(-${fontSize2 * DEFAULT_TEXT_BASELINE_CORRECTION_RATIO}pt)">${text}</span>`;
1428
- const content2 = `<div class="pd-watermark" style="grid-template-columns:repeat(${columns},1fr);grid-template-rows:repeat(${rows},1fr)">${cell.repeat(rows * columns)}</div>`;
1429
- return printDesign.renderPrintDesignHtmlFrame(element, content2);
1430
- }
1431
1764
  const width = Math.max(0, element.width);
1432
1765
  const height = Math.max(0, element.height);
1433
1766
  const fontSize = printDesign.cssNumber(element.fontSize, 24) * 25.4 / 72;
1434
1767
  const color2 = printDesign.cssColor(element.color, "#94a3b8");
1435
1768
  const rotation = printDesign.cssNumber(element.textRotation, 45);
1769
+ const baselineFactor = preciseClip ? 0.3 : 0.39;
1436
1770
  const cells = Array.from({ length: rows * columns }, (_, index) => {
1437
1771
  const centerX = (index % columns + 0.5) * (width / columns);
1438
1772
  const centerY = (Math.floor(index / columns) + 0.5) * (height / rows);
1439
- return `<text x="${centerX}" y="${centerY + fontSize * 0.3}" text-anchor="middle" transform="rotate(${rotation} ${centerX} ${centerY})">${text}</text>`;
1773
+ return `<text x="${centerX}" y="${centerY + fontSize * baselineFactor}" text-anchor="middle" transform="rotate(${rotation} ${centerX} ${centerY})">${text}</text>`;
1440
1774
  }).join("");
1441
- const content = `<svg class="pd-watermark" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none" font-size="${fontSize}" font-family="${printDesign.escapeHtml(printDesign.PRINT_DESIGN_DEFAULT_FONT_FAMILY)}" fill="${color2}" style="display:block;width:100%;height:100%;overflow:hidden">${cells}</svg>`;
1775
+ 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="${printDesign.escapeHtml(printDesign.PRINT_DESIGN_DEFAULT_FONT_FAMILY)}" fill="${color2}" style="display:block;width:100%;height:100%;overflow:hidden">${cells}</svg>`;
1442
1776
  return printDesign.renderPrintDesignHtmlFrame(element, content);
1443
1777
  }
1444
1778
 
@@ -1463,9 +1797,9 @@ function watermarkBindingInfo(element) {
1463
1797
  }
1464
1798
  function validateWatermarkTemplateData(element, data) {
1465
1799
  if (!data) return [];
1466
- const { bound, paths } = watermarkBindingInfo(element);
1800
+ const { bound, paths: paths2 } = watermarkBindingInfo(element);
1467
1801
  if (!bound) return [];
1468
- const expression = paths[0];
1802
+ const expression = paths2[0];
1469
1803
  if (!expression) return ["\u672A\u914D\u7F6E\u6C34\u5370\u6587\u5B57\u7ED1\u5B9A\u5B57\u6BB5"];
1470
1804
  for (const match of expression.matchAll(
1471
1805
  /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
@@ -1480,7 +1814,7 @@ function validateWatermarkTemplateData(element, data) {
1480
1814
  // src/plugins/watermark/native.ts
1481
1815
  var watermarkNativePlugin = defineNativePlugin(
1482
1816
  "watermark",
1483
- "0.1.9",
1817
+ "0.1.10",
1484
1818
  printDesign.definePrintDesignPluginRenderer({
1485
1819
  type: "watermark",
1486
1820
  validate: validateWatermarkElement,
@@ -1500,8 +1834,7 @@ var watermarkNativePlugin = defineNativePlugin(
1500
1834
  physical && physical.y + physical.height > context.page.height
1501
1835
  )
1502
1836
  );
1503
- },
1504
- 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}"
1837
+ }
1505
1838
  }),
1506
1839
  [{ id: "builtin.text", minVersion: "0.1.16" }]
1507
1840
  );
@@ -4153,8 +4486,8 @@ function labelPaths(element) {
4153
4486
  );
4154
4487
  }
4155
4488
  function connectorBindingInfo(element) {
4156
- const paths = [...new Set(labelPaths(element))];
4157
- return { bound: paths.length > 0, paths };
4489
+ const paths2 = [...new Set(labelPaths(element))];
4490
+ return { bound: paths2.length > 0, paths: paths2 };
4158
4491
  }
4159
4492
  function validateConnectorTemplateData(element, data) {
4160
4493
  if (!data) return [];
@@ -4965,13 +5298,13 @@ function gridMarkup(element, data) {
4965
5298
 
4966
5299
  // src/plugins/grid/data/binding.ts
4967
5300
  function getGridBindingInfo(element) {
4968
- const paths = [
5301
+ const paths2 = [
4969
5302
  element.contentPath,
4970
5303
  element.loopsPath,
4971
5304
  element.columnLoopsPath,
4972
5305
  ...(element.cells ?? []).filter((cell) => cell.contentMode === "binding").map((cell) => cell.contentPath)
4973
5306
  ].map((path) => path?.trim()).filter((path) => !!path);
4974
- return { bound: paths.length > 0, paths };
5307
+ return { bound: paths2.length > 0, paths: paths2 };
4975
5308
  }
4976
5309
  function validateGridTemplateData(element, data) {
4977
5310
  if (!data) return [];
@@ -6219,9 +6552,9 @@ function clockBindingInfo(element) {
6219
6552
  }
6220
6553
  function validateClockTemplateData(element, data) {
6221
6554
  if (!data) return [];
6222
- const { bound, paths } = clockBindingInfo(element);
6555
+ const { bound, paths: paths2 } = clockBindingInfo(element);
6223
6556
  if (!bound) return [];
6224
- const expression = paths[0];
6557
+ const expression = paths2[0];
6225
6558
  if (!expression) return ["\u672A\u914D\u7F6E\u65F6\u949F\u65F6\u95F4\u7ED1\u5B9A\u5B57\u6BB5"];
6226
6559
  for (const match of expression.matchAll(
6227
6560
  /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
@@ -6460,9 +6793,9 @@ function imageBindingInfo(element) {
6460
6793
  }
6461
6794
  function validateImageTemplateData(element, data) {
6462
6795
  if (!data) return [];
6463
- const { bound, paths } = imageBindingInfo(element);
6796
+ const { bound, paths: paths2 } = imageBindingInfo(element);
6464
6797
  if (!bound) return [];
6465
- const expression = paths[0];
6798
+ const expression = paths2[0];
6466
6799
  if (!expression) return ["\u672A\u914D\u7F6E\u56FE\u7247\u5730\u5740\u7ED1\u5B9A\u5B57\u6BB5"];
6467
6800
  for (const match of expression.matchAll(
6468
6801
  /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
@@ -6816,9 +7149,9 @@ function barcodeBindingInfo(element) {
6816
7149
  }
6817
7150
  function validateBarcodeTemplateData(element, data) {
6818
7151
  if (!data) return [];
6819
- const { bound, paths } = barcodeBindingInfo(element);
7152
+ const { bound, paths: paths2 } = barcodeBindingInfo(element);
6820
7153
  if (!bound) return [];
6821
- const expression = paths[0];
7154
+ const expression = paths2[0];
6822
7155
  if (!expression) return ["\u672A\u914D\u7F6E\u6761\u5F62\u7801\u5185\u5BB9\u7ED1\u5B9A\u5B57\u6BB5"];
6823
7156
  for (const match of expression.matchAll(
6824
7157
  /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
@@ -6918,9 +7251,9 @@ function qrcodeBindingInfo(element) {
6918
7251
  }
6919
7252
  function validateQrCodeTemplateData(element, data) {
6920
7253
  if (!data) return [];
6921
- const { bound, paths } = qrcodeBindingInfo(element);
7254
+ const { bound, paths: paths2 } = qrcodeBindingInfo(element);
6922
7255
  if (!bound) return [];
6923
- const expression = paths[0];
7256
+ const expression = paths2[0];
6924
7257
  if (!expression) return ["\u672A\u914D\u7F6E\u4E8C\u7EF4\u7801\u5185\u5BB9\u7ED1\u5B9A\u5B57\u6BB5"];
6925
7258
  for (const match of expression.matchAll(
6926
7259
  /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g
@@ -7846,7 +8179,7 @@ function resolveDiagonalCount(count) {
7846
8179
  function diagonalCellLayout(direction, count, corner) {
7847
8180
  const lineCount = resolveDiagonalCount(count);
7848
8181
  const activeCorner = lineCount === 1 ? direction === "down" ? "top-left" : "bottom-left" : corner ?? (direction === "down" ? "top-left" : "bottom-left");
7849
- const paths = {
8182
+ const paths2 = {
7850
8183
  "top-left": [
7851
8184
  [0, 0],
7852
8185
  [1, 0],
@@ -7872,7 +8205,7 @@ function diagonalCellLayout(direction, count, corner) {
7872
8205
  [0, 1]
7873
8206
  ]
7874
8207
  };
7875
- const [apex, first, bend, last] = paths[activeCorner];
8208
+ const [apex, first, bend, last] = paths2[activeCorner];
7876
8209
  const farPoint = (position) => position <= 1 ? [
7877
8210
  first[0] + (bend[0] - first[0]) * position,
7878
8211
  first[1] + (bend[1] - first[1]) * position
@@ -9408,6 +9741,10 @@ function hitTableColumnBoundary(element, point, scale, includeSelector = false,
9408
9741
  }
9409
9742
  return nearest;
9410
9743
  }
9744
+ function boundaryHitRadius(height, scale, selector) {
9745
+ const radius = 5 / scale;
9746
+ return selector || height * scale >= 12 ? radius : Math.min(radius, height / 4);
9747
+ }
9411
9748
  function unmergedBoundarySegments(element, rowIndex, merges) {
9412
9749
  if (!merges.length) return [{ x: element.x + 3, width: element.width - 6 }];
9413
9750
  const columns = tableLeafColumns(
@@ -9449,11 +9786,25 @@ function tableHeaderResizeLayout(element, scale, data = {}) {
9449
9786
  for (let index = 0; index < depth; index++) {
9450
9787
  const edge = element.y + (index + 1) * height;
9451
9788
  if (edge > visibleBottom + 1e-9) break;
9452
- const shared = { rowIndex: index, edge, height, y: edge - 5 / scale };
9453
- regions.push({ ...shared, x: element.x - 6, width: 6, selector: true });
9789
+ const shared = { rowIndex: index, edge, height };
9790
+ const selectorRadius = boundaryHitRadius(height, scale, true);
9791
+ regions.push({
9792
+ ...shared,
9793
+ x: element.x - 6,
9794
+ width: 6,
9795
+ selector: true,
9796
+ radius: selectorRadius,
9797
+ y: edge - selectorRadius
9798
+ });
9454
9799
  if (edge < visibleBottom - 1e-9 && element.width > 6)
9455
9800
  for (const segment of unmergedBoundarySegments(element, index, headers))
9456
- regions.push({ ...shared, ...segment, selector: false });
9801
+ regions.push({
9802
+ ...shared,
9803
+ ...segment,
9804
+ selector: false,
9805
+ radius: boundaryHitRadius(height, scale, false),
9806
+ y: edge - boundaryHitRadius(height, scale, false)
9807
+ });
9457
9808
  }
9458
9809
  return regions;
9459
9810
  }
@@ -9468,7 +9819,7 @@ function hitTableHeaderBoundary(element, point, scale, data = {}) {
9468
9819
  -(element.rotation ?? 0) * Math.PI / 180
9469
9820
  );
9470
9821
  const region = tableHeaderResizeLayout(element, scale, data).filter(
9471
- (item) => local.x >= item.x && local.x < item.x + item.width && local.y >= item.y && local.y <= item.y + 10 / scale
9822
+ (item) => local.x >= item.x && local.x < item.x + item.width && Math.abs(local.y - item.edge) <= item.radius
9472
9823
  ).sort((a, b) => Math.abs(local.y - a.edge) - Math.abs(local.y - b.edge))[0];
9473
9824
  return region && {
9474
9825
  elementId: element.id,
@@ -9500,13 +9851,26 @@ function tableRowResizeLayout(element, scale, data = {}) {
9500
9851
  const shared = {
9501
9852
  rowIndex: index + (element.sourceRowOffset ?? 0),
9502
9853
  edge: boundary,
9503
- height,
9504
- y: boundary - 5 / scale
9854
+ height
9505
9855
  };
9506
- regions.push({ ...shared, x: element.x - 6, width: 6, selector: true });
9856
+ const selectorRadius = boundaryHitRadius(height, scale, true);
9857
+ regions.push({
9858
+ ...shared,
9859
+ x: element.x - 6,
9860
+ width: 6,
9861
+ selector: true,
9862
+ radius: selectorRadius,
9863
+ y: boundary - selectorRadius
9864
+ });
9507
9865
  if (index < heights.length - 1 && element.width > 6)
9508
9866
  for (const segment of unmergedBoundarySegments(element, index, cells))
9509
- regions.push({ ...shared, ...segment, selector: false });
9867
+ regions.push({
9868
+ ...shared,
9869
+ ...segment,
9870
+ selector: false,
9871
+ radius: boundaryHitRadius(height, scale, false),
9872
+ y: boundary - boundaryHitRadius(height, scale, false)
9873
+ });
9510
9874
  }
9511
9875
  return regions;
9512
9876
  }
@@ -9521,7 +9885,7 @@ function hitTableRowBoundary(element, point, scale, data = {}) {
9521
9885
  -(element.rotation ?? 0) * Math.PI / 180
9522
9886
  );
9523
9887
  const region = tableRowResizeLayout(element, scale, data).filter(
9524
- (item) => local.x >= item.x && local.x < item.x + item.width && local.y >= item.y && local.y <= item.y + 10 / scale
9888
+ (item) => local.x >= item.x && local.x < item.x + item.width && Math.abs(local.y - item.edge) <= item.radius
9525
9889
  ).sort((a, b) => Math.abs(local.y - a.edge) - Math.abs(local.y - b.edge))[0];
9526
9890
  return region && {
9527
9891
  elementId: element.id,
@@ -9656,12 +10020,12 @@ function tableDebugRegions(table2, context, options = {}) {
9656
10020
  ...owner,
9657
10021
  id: `${area}-resize:${index}`,
9658
10022
  category: "resize",
9659
- label: `${area === "header" ? `\u8868\u5934 H${region.rowIndex + 1}` : `\u884C ${region.rowIndex + 1}`} \u5E95\u7EBF \xB15px${hit ? " \u547D\u4E2D" : ""}`,
10023
+ 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" : ""}`,
9660
10024
  bounds: {
9661
10025
  x: region.x,
9662
10026
  y: region.y,
9663
10027
  width: region.width,
9664
- height: 10 / scale
10028
+ height: region.radius * 2
9665
10029
  },
9666
10030
  interactive: true,
9667
10031
  hit,
@@ -10651,11 +11015,227 @@ function emptyTableRow(element) {
10651
11015
  );
10652
11016
  }
10653
11017
 
11018
+ // src/plugins/table/data/packed-report-defaults.ts
11019
+ function fillPackedReportDefaults(columns, rows, current2) {
11020
+ const visible = tableLeafColumns(columns).filter((column) => !column.hidden);
11021
+ const keys2 = visible.map(
11022
+ (column) => typeof column.dataIndex === "string" ? column.dataIndex : ""
11023
+ );
11024
+ const repeats = /* @__PURE__ */ new Map();
11025
+ keys2.forEach((key) => {
11026
+ const match = /^(.+?)([1-9]\d*)$/.exec(key);
11027
+ if (!match) return;
11028
+ const slots = repeats.get(match[1]) ?? /* @__PURE__ */ new Set();
11029
+ slots.add(Number(match[2]));
11030
+ repeats.set(match[1], slots);
11031
+ });
11032
+ const series = [...repeats].filter(
11033
+ ([, slots]) => slots.has(1) && slots.has(2)
11034
+ );
11035
+ const itemsPerRow = Math.max(
11036
+ 1,
11037
+ ...series.map(([, slots]) => Math.max(...slots))
11038
+ );
11039
+ const sample = rows.find((row) => row && typeof row === "object") ?? {};
11040
+ const groupFields = {};
11041
+ keys2.forEach((key, index) => {
11042
+ const repeated = series.some(
11043
+ ([prefix, slots]) => [...slots].some((slot) => key === `${prefix}${slot}`)
11044
+ );
11045
+ if (key && !repeated && !visible[index]?.summary && visible[index]?.summaryTitle == null) {
11046
+ groupFields[key] = key in sample ? key : "";
11047
+ }
11048
+ });
11049
+ const itemFields = series.map(([prefix]) => ({
11050
+ prefix,
11051
+ .../^(sequence|seq|index|序号)$/i.test(prefix) ? { mode: "index" } : { mode: "value", path: prefix in sample ? prefix : "" }
11052
+ }));
11053
+ const totals = {};
11054
+ visible.forEach((column, index) => {
11055
+ const key = keys2[index];
11056
+ const summary = column.summary;
11057
+ const type = typeof summary === "object" ? summary.type ?? "sum" : "sum";
11058
+ if (key && summary && type === "sum") {
11059
+ const prefix = series.find(
11060
+ ([name, slots]) => [...slots].some((slot) => key === `${name}${slot}`)
11061
+ )?.[0];
11062
+ totals[key] = {
11063
+ sumPath: key in sample ? key : prefix && prefix in sample ? prefix : "",
11064
+ ...typeof summary === "object" && summary.precision != null ? { decimals: summary.precision } : {}
11065
+ };
11066
+ }
11067
+ });
11068
+ const subtotalLabelKey = keys2.find(
11069
+ (key) => key && !(key in totals) && !(key in groupFields)
11070
+ );
11071
+ const totalLabelKey = keys2.find((key) => key && !(key in totals));
11072
+ const subtotal = { ...totals };
11073
+ if (subtotalLabelKey) subtotal[subtotalLabelKey] = { text: "\u5C0F\u8BA1" };
11074
+ if (totalLabelKey) totals[totalLabelKey] = { text: "\u603B\u8BA1" };
11075
+ return {
11076
+ groupBy: current2?.groupBy ?? [],
11077
+ itemsPerRow: current2?.itemsPerRow ?? itemsPerRow,
11078
+ groupFields: Object.keys(current2?.groupFields ?? {}).length ? current2.groupFields : groupFields,
11079
+ groupMergeColumns: Object.keys(current2?.groupFields ?? {}).length ? current2.groupMergeColumns : keys2.flatMap(
11080
+ (key, index) => key && key in groupFields ? [index] : []
11081
+ ),
11082
+ itemFields: current2?.itemFields?.length ? current2.itemFields : itemFields,
11083
+ subtotal: Object.keys(current2?.subtotal ?? {}).length ? current2.subtotal : subtotal,
11084
+ subtotalMerges: current2?.subtotalMerges ?? [],
11085
+ total: Object.keys(current2?.total ?? {}).length ? current2.total : totals,
11086
+ totalMerges: current2?.totalMerges ?? [],
11087
+ appendRows: current2?.appendRows ?? [],
11088
+ ...current2?.footerElementIds ? { footerElementIds: current2.footerElementIds } : {}
11089
+ };
11090
+ }
11091
+
11092
+ // src/plugins/table/interaction/agent-commands.ts
11093
+ function object(input) {
11094
+ if (!input || typeof input !== "object" || Array.isArray(input))
11095
+ throw new TypeError("\u8868\u683C\u547D\u4EE4\u53C2\u6570\u5FC5\u987B\u662F\u5BF9\u8C61\u3002");
11096
+ return input;
11097
+ }
11098
+ function safePart(value) {
11099
+ return !!value.trim() && !value.split(/[.[\]]/).some((part) => ["__proto__", "prototype", "constructor"].includes(part));
11100
+ }
11101
+ function fieldPath(input, label) {
11102
+ if (typeof input === "string" && safePart(input)) return input.trim();
11103
+ if (Array.isArray(input) && input.length > 0 && input.every(
11104
+ (part) => typeof part === "string" && safePart(part) || typeof part === "number" && Number.isInteger(part) && part >= 0
11105
+ ))
11106
+ return input;
11107
+ throw new TypeError(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\u6216\u5B57\u6BB5\u8DEF\u5F84\u6570\u7EC4\u3002`);
11108
+ }
11109
+ function paths(input, label) {
11110
+ if (input === void 0) return [];
11111
+ if (!Array.isArray(input)) throw new TypeError(`${label} \u5FC5\u987B\u662F\u6570\u7EC4\u3002`);
11112
+ return input.map((value) => fieldPath(value, label));
11113
+ }
11114
+ function stringPaths(input, label) {
11115
+ if (!Array.isArray(input) || !input.length)
11116
+ throw new TypeError(`${label} \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u8DEF\u5F84\u6570\u7EC4\u3002`);
11117
+ return input.map((value) => {
11118
+ if (typeof value !== "string" || !safePart(value))
11119
+ throw new TypeError(`${label} \u4E2D\u7684\u5B57\u6BB5\u8DEF\u5F84\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002`);
11120
+ return value.trim();
11121
+ });
11122
+ }
11123
+ function configureTableAutoMerge(element, rawPayload) {
11124
+ const payload = object(rawPayload);
11125
+ if (payload.enabled === false) return { ...element, mergeCell: void 0 };
11126
+ const rowKeys = paths(payload.rowKeys, "rowKeys");
11127
+ const rowColumns = paths(payload.rowColumns, "rowColumns");
11128
+ const columnKeys = paths(payload.columnKeys, "columnKeys");
11129
+ if (!rowKeys.length && !columnKeys.length)
11130
+ throw new TypeError(
11131
+ "\u81F3\u5C11\u63D0\u4F9B rowKeys \u6216 columnKeys\uFF1B\u5173\u95ED\u65F6\u4F20 enabled=false\u3002"
11132
+ );
11133
+ if (rowColumns.length && !rowKeys.length)
11134
+ throw new TypeError("\u8BBE\u7F6E rowColumns \u65F6\u5FC5\u987B\u540C\u65F6\u63D0\u4F9B rowKeys\u3002");
11135
+ const visible = tableLeafColumns(element.columns).filter((column) => !column.hidden).map((column) => JSON.stringify(column.dataIndex));
11136
+ for (const path of [
11137
+ ...rowColumns.length ? rowColumns : rowKeys,
11138
+ ...columnKeys
11139
+ ])
11140
+ if (!visible.includes(JSON.stringify(path)))
11141
+ throw new TypeError(`\u5408\u5E76\u76EE\u6807\u5217\u4E0D\u5B58\u5728\uFF1A${JSON.stringify(path)}\u3002`);
11142
+ return {
11143
+ ...element,
11144
+ mergeCell: {
11145
+ ...rowKeys.length ? {
11146
+ row: {
11147
+ keys: rowKeys,
11148
+ ...rowColumns.length ? { columns: rowColumns } : {}
11149
+ }
11150
+ } : {},
11151
+ ...columnKeys.length ? { column: { keys: columnKeys } } : {}
11152
+ }
11153
+ };
11154
+ }
11155
+ function configureTableGroupAggregation(element, rawPayload, data) {
11156
+ const payload = object(rawPayload);
11157
+ if (payload.enabled === false) return { ...element, packedReport: void 0 };
11158
+ const groupBy = stringPaths(payload.groupBy, "groupBy");
11159
+ if (payload.itemsPerRow !== void 0 && (!Number.isInteger(payload.itemsPerRow) || Number(payload.itemsPerRow) < 1))
11160
+ throw new TypeError("itemsPerRow \u5FC5\u987B\u662F\u5927\u4E8E\u96F6\u7684\u6574\u6570\u3002");
11161
+ if (payload.sums !== void 0 && !Array.isArray(payload.sums))
11162
+ throw new TypeError("sums \u5FC5\u987B\u662F\u6570\u7EC4\u3002");
11163
+ const source = element.dataMode === "binding" ? resolveTableDataSource(data, element.dataPath) : element.dataSource;
11164
+ const rows = Array.isArray(source) ? source.filter(
11165
+ (row) => !!row && typeof row === "object" && !Array.isArray(row)
11166
+ ) : element.dataSource;
11167
+ for (const path of groupBy)
11168
+ if (rows.length && !rows.some((row) => printDesign.resolvePrintDesignDataPath(row, path) !== void 0))
11169
+ throw new TypeError(`\u5206\u7EC4\u5B57\u6BB5\u5728\u6570\u636E\u4E2D\u4E0D\u5B58\u5728\uFF1A${path}\u3002`);
11170
+ const report = fillPackedReportDefaults(
11171
+ element.columns,
11172
+ rows,
11173
+ element.packedReport
11174
+ );
11175
+ const visible = tableLeafColumns(element.columns).filter(
11176
+ (column) => !column.hidden
11177
+ );
11178
+ const groupFields = { ...report.groupFields };
11179
+ const subtotal = { ...report.subtotal };
11180
+ const total = { ...report.total };
11181
+ const sumColumns = /* @__PURE__ */ new Set();
11182
+ for (const raw of payload.sums ?? []) {
11183
+ const sum = object(raw);
11184
+ if (typeof sum.column !== "string" || !safePart(sum.column))
11185
+ throw new TypeError("sums.column \u5FC5\u987B\u662F\u8868\u683C\u5217\u7684 dataIndex \u5B57\u7B26\u4E32\u3002");
11186
+ const column = sum.column.trim();
11187
+ if (!visible.some((item) => item.dataIndex === column))
11188
+ throw new TypeError(`\u6C47\u603B\u5217\u4E0D\u5B58\u5728\uFF1A${column}\u3002`);
11189
+ if (sumColumns.has(column)) throw new TypeError(`\u6C47\u603B\u5217\u91CD\u590D\uFF1A${column}\u3002`);
11190
+ if (typeof sum.path !== "string" || !safePart(sum.path))
11191
+ throw new TypeError("sums.path \u5FC5\u987B\u662F\u539F\u59CB\u6570\u636E\u7684\u975E\u7A7A\u5B57\u6BB5\u8DEF\u5F84\u3002");
11192
+ if (rows.length && !rows.some(
11193
+ (row) => printDesign.resolvePrintDesignDataPath(row, sum.path) !== void 0
11194
+ ))
11195
+ throw new TypeError(`\u6C42\u548C\u5B57\u6BB5\u5728\u6570\u636E\u4E2D\u4E0D\u5B58\u5728\uFF1A${sum.path}\u3002`);
11196
+ if (sum.decimals !== void 0 && (!Number.isInteger(sum.decimals) || Number(sum.decimals) < 0 || Number(sum.decimals) > 10))
11197
+ throw new TypeError("sums.decimals \u5FC5\u987B\u662F 0 \u5230 10 \u7684\u6574\u6570\u3002");
11198
+ sumColumns.add(column);
11199
+ delete groupFields[column];
11200
+ const rule = {
11201
+ sumPath: sum.path.trim(),
11202
+ ...sum.decimals === void 0 ? {} : { decimals: sum.decimals }
11203
+ };
11204
+ subtotal[column] = rule;
11205
+ total[column] = rule;
11206
+ }
11207
+ if (sumColumns.size && !Object.values(subtotal).some((rule) => rule.text === "\u5C0F\u8BA1")) {
11208
+ const labelColumn = visible.find(
11209
+ (column) => typeof column.dataIndex === "string" && !sumColumns.has(column.dataIndex)
11210
+ );
11211
+ if (typeof labelColumn?.dataIndex === "string")
11212
+ subtotal[labelColumn.dataIndex] = { text: "\u5C0F\u8BA1" };
11213
+ }
11214
+ return {
11215
+ ...element,
11216
+ packedReport: {
11217
+ ...report,
11218
+ groupBy,
11219
+ ...payload.itemsPerRow === void 0 ? {} : { itemsPerRow: payload.itemsPerRow },
11220
+ groupFields,
11221
+ groupMergeColumns: report.groupMergeColumns.filter(
11222
+ (index) => !sumColumns.has(String(visible[index]?.dataIndex ?? ""))
11223
+ ),
11224
+ subtotal,
11225
+ total
11226
+ }
11227
+ };
11228
+ }
11229
+
10654
11230
  // src/plugins/table/interaction/commands.ts
10655
11231
  var tableCommands = {
10656
11232
  execute(element, command, rawPayload, context) {
10657
11233
  if (element.locked) return;
10658
11234
  if (!rawPayload || typeof rawPayload !== "object") return;
11235
+ if (command === "configure-auto-merge")
11236
+ return configureTableAutoMerge(element, rawPayload);
11237
+ if (command === "configure-group-aggregation")
11238
+ return configureTableGroupAggregation(element, rawPayload, context.data);
10659
11239
  const payload = rawPayload;
10660
11240
  const rowIndex = payload.rowIndex ?? 0;
10661
11241
  const columnIndex = payload.columnIndex ?? 0;
@@ -11050,7 +11630,7 @@ function validateTableTemplateData(element, data) {
11050
11630
  // src/plugins/table/native.ts
11051
11631
  var tableNativePlugin = defineNativePlugin(
11052
11632
  "table",
11053
- "0.1.69",
11633
+ "0.1.70",
11054
11634
  printDesign.definePrintDesignPluginRenderer({
11055
11635
  type: "table",
11056
11636
  validate: validateTableElement,
@@ -12003,6 +12583,7 @@ var ganttNativePlugin = defineNativePlugin(
12003
12583
  // src/native.ts
12004
12584
  var builtinNativeComponentPlugins = [
12005
12585
  textNativePlugin,
12586
+ richTextNativePlugin,
12006
12587
  listNativePlugin,
12007
12588
  dateTimeNativePlugin,
12008
12589
  moneyUpperNativePlugin,
@@ -12265,8 +12846,36 @@ var propertySections = [{
12265
12846
  visibleWhen: (element) => element.type === "text" && Boolean(element.fontSource),
12266
12847
  toPatch: () => ({ fontSource: "" })
12267
12848
  },
12268
- { path: "fontWeight", label: "\u5B57\u91CD", kind: "select", defaultValue: "400", ariaLabel: "\u6587\u672C\u5B57\u91CD", options: FONT_WEIGHT_OPTIONS },
12269
- { path: "lineHeight", label: "\u884C\u9AD8\u500D\u6570", kind: "number", defaultValue: 1.35, min: 0.5, max: 4, precision: 2, ariaLabel: "\u6587\u672C\u884C\u9AD8\u500D\u6570" },
12849
+ { path: "fontWeight", label: "\u52A0\u7C97", kind: "select", defaultValue: "400", ariaLabel: "\u6587\u672C\u5B57\u91CD", options: FONT_WEIGHT_OPTIONS, fullWidth: false },
12850
+ { path: "fontStyle", label: "\u503E\u659C", kind: "select", defaultValue: "normal", ariaLabel: "\u6587\u672C\u503E\u659C", fullWidth: false, options: [
12851
+ { label: "\u5E38\u89C4", value: "normal" },
12852
+ { label: "\u503E\u659C", value: "italic" }
12853
+ ] },
12854
+ { 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" },
12855
+ { path: "indentMode", label: "\u7F29\u8FDB", kind: "select", defaultValue: "none", fullWidth: false, options: [
12856
+ { label: "\u65E0", value: "none" },
12857
+ { label: "\u9996\u884C\u7F29\u8FDB", value: "firstLine" },
12858
+ { label: "\u60AC\u6302\u7F29\u8FDB", value: "hanging" }
12859
+ ] },
12860
+ {
12861
+ path: "indentValue",
12862
+ label: "\u7F29\u8FDB\u5EA6\u91CF\u503C",
12863
+ kind: "number",
12864
+ defaultValue: 0,
12865
+ min: 0,
12866
+ max: 1e4,
12867
+ precision: 2,
12868
+ fullWidth: false,
12869
+ unitSelector: { path: "indentUnit", label: "\u7F29\u8FDB\u5355\u4F4D", defaultValue: "char", options: [
12870
+ { label: "\u5B57\u7B26", value: "char" },
12871
+ { label: "mm", value: "mm" },
12872
+ { label: "cm", value: "cm" },
12873
+ { label: "in", value: "in" },
12874
+ { label: "pt", value: "pt" },
12875
+ { label: "px", value: "px" }
12876
+ ] },
12877
+ visibleWhen: (element) => element.type === "text" && element.indentMode !== void 0 && element.indentMode !== "none"
12878
+ },
12270
12879
  { 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 },
12271
12880
  { path: "underlineCount", label: "\u4E0B\u5212\u7EBF\u6761\u6570", kind: "number", defaultValue: 0, min: 0, max: 5, precision: 0, ariaLabel: "\u4E0B\u5212\u7EBF\u6761\u6570" },
12272
12881
  { path: "underlineStyle", label: "\u4E0B\u5212\u7EBF\u7EBF\u578B", kind: "select", defaultValue: "solid", ariaLabel: "\u4E0B\u5212\u7EBF\u7EBF\u578B", options: UNDERLINE_STYLE_OPTIONS },
@@ -12305,6 +12914,159 @@ var textPlugin = defineBuiltinReactPlugin(textNativePlugin, {
12305
12914
  menuGroups,
12306
12915
  propertySections
12307
12916
  });
12917
+ function RichTextInlineEditor(props) {
12918
+ const [runs, setRuns] = react.useState(props.element.runs);
12919
+ const runsRef = react.useRef(runs);
12920
+ runsRef.current = runs;
12921
+ const editorRef = react.useRef(null);
12922
+ const overlayRef = react.useRef(null);
12923
+ const finishedRef = react.useRef(false);
12924
+ const finish = (commit) => {
12925
+ if (finishedRef.current) return;
12926
+ finishedRef.current = true;
12927
+ if (commit && JSON.stringify(runsRef.current) !== JSON.stringify(props.element.runs))
12928
+ props.onCommit(runsRef.current);
12929
+ else props.onClose();
12930
+ };
12931
+ react.useEffect(() => {
12932
+ const containsEditorUi = (target) => target instanceof Node && (overlayRef.current?.contains(target) || target instanceof Element && !!target.closest(".canvas-react-rich-text-popup"));
12933
+ const onPointerDown = (event) => {
12934
+ if (!containsEditorUi(event.target)) finish(true);
12935
+ };
12936
+ const onFocusIn = (event) => {
12937
+ if (!containsEditorUi(event.target)) finish(true);
12938
+ };
12939
+ const onKeyDown = (event) => {
12940
+ if (event.key !== "Escape") return;
12941
+ event.preventDefault();
12942
+ event.stopPropagation();
12943
+ finish(false);
12944
+ };
12945
+ document.addEventListener("pointerdown", onPointerDown, true);
12946
+ document.addEventListener("focusin", onFocusIn, true);
12947
+ document.addEventListener("keydown", onKeyDown, true);
12948
+ editorRef.current?.focus();
12949
+ return () => {
12950
+ document.removeEventListener("pointerdown", onPointerDown, true);
12951
+ document.removeEventListener("focusin", onFocusIn, true);
12952
+ document.removeEventListener("keydown", onKeyDown, true);
12953
+ };
12954
+ }, []);
12955
+ const scale = props.element.width > 0 ? props.rect.width / props.element.width : 1;
12956
+ const ptToPx = (size) => `${size * 25.4 / 72 * scale}px`;
12957
+ const indentPx = richTextIndentMm(props.element) * scale;
12958
+ const transform = props.element.transform ? (() => {
12959
+ const matrix = printDesign.elementTransformHomography(props.element);
12960
+ 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)`;
12961
+ 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)` : "";
12962
+ return perspective + rotation;
12963
+ })() : `rotate(${props.element.rotation ?? 0}deg)`;
12964
+ return /* @__PURE__ */ jsxRuntime.jsx(
12965
+ "div",
12966
+ {
12967
+ ref: overlayRef,
12968
+ className: "cc-print-design-rich-text-overlay",
12969
+ style: {
12970
+ position: "fixed",
12971
+ zIndex: 1e4,
12972
+ left: props.rect.left,
12973
+ top: props.rect.top,
12974
+ width: props.rect.width,
12975
+ height: props.rect.height,
12976
+ background: "transparent",
12977
+ outline: "1px solid #1677ff",
12978
+ transform,
12979
+ transformOrigin: props.element.transform ? "0 0" : "center"
12980
+ },
12981
+ onKeyDownCapture: (event) => {
12982
+ event.stopPropagation();
12983
+ if (event.key === "Escape") {
12984
+ event.preventDefault();
12985
+ finish(false);
12986
+ }
12987
+ },
12988
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12989
+ reactComponents.ReactRichText,
12990
+ {
12991
+ ref: editorRef,
12992
+ value: runs,
12993
+ onChange: setRuns,
12994
+ toolbarPopupZIndex: 10001,
12995
+ fontFamilyOptions: reactPrintDesign.FONT_FAMILY_OPTIONS.map((option) => ({ label: option.label, value: String(option.value) })),
12996
+ defaultStyle: {
12997
+ fontFamily: printDesign.resolvePrintDesignFontFamily(props.element.fontFamily),
12998
+ fontSize: props.element.fontSize ?? 14,
12999
+ fontWeight: props.element.fontWeight ?? "400",
13000
+ fontStyle: props.element.fontStyle ?? "normal",
13001
+ color: props.element.color ?? "#1f2937"
13002
+ },
13003
+ fontSizeCss: ptToPx,
13004
+ editorStyle: {
13005
+ width: "100%",
13006
+ height: "100%",
13007
+ minHeight: 0,
13008
+ overflow: "hidden",
13009
+ backgroundColor: "transparent",
13010
+ lineHeight: props.element.lineHeight ?? 1.35,
13011
+ textAlign: props.element.textAlign ?? "left",
13012
+ textIndent: props.element.indentMode === "firstLine" ? `${indentPx}px` : props.element.indentMode === "hanging" ? `-${indentPx}px` : void 0,
13013
+ paddingLeft: props.element.indentMode === "hanging" ? `${indentPx}px` : void 0
13014
+ }
13015
+ }
13016
+ )
13017
+ }
13018
+ );
13019
+ }
13020
+
13021
+ // src/plugins/rich-text/factory.ts
13022
+ var richTextFactory = {
13023
+ type: "richText",
13024
+ label: "\u5BCC\u6587\u672C",
13025
+ showDataPanel: false,
13026
+ defaultOverflowPolicy: "split",
13027
+ overflowPolicyOptions: [
13028
+ { label: "\u81EA\u52A8\u6EA2\u51FA\u5230\u7EED\u9875", value: "split" },
13029
+ { label: "\u6574\u4F53\u653E\u5230\u4E0B\u4E00\u9875", value: "nextPage" },
13030
+ { label: "\u88C1\u5207", value: "clip" },
13031
+ { label: "\u8D85\u51FA\u663E\u793A...", value: "ellipsis" }
13032
+ ],
13033
+ renderInlineEditor: ({ element, rect, onCommit, onClose }) => react.createElement(RichTextInlineEditor, {
13034
+ element,
13035
+ rect,
13036
+ onCommit: (runs) => onCommit({ runs }),
13037
+ onClose
13038
+ }),
13039
+ create: () => ({
13040
+ ...createCommonElementDefaults(),
13041
+ type: "richText",
13042
+ name: "\u5BCC\u6587\u672C",
13043
+ runs: [{ text: "\u53CC\u51FB\u7F16\u8F91\u5BCC\u6587\u672C" }],
13044
+ fontSize: 14,
13045
+ color: "#1f2937"
13046
+ })
13047
+ };
13048
+ var menuGroups2 = [
13049
+ {
13050
+ id: "basic",
13051
+ title: "\u57FA\u7840\u5143\u7D20",
13052
+ order: 0,
13053
+ items: [
13054
+ {
13055
+ id: "richText",
13056
+ type: "richText",
13057
+ label: "\u5BCC\u6587\u672C",
13058
+ icon: react.createElement(reactComponents.ReactFontSizeOutlined, { "aria-hidden": true }),
13059
+ order: 1
13060
+ }
13061
+ ]
13062
+ }
13063
+ ];
13064
+
13065
+ // src/plugins/rich-text/react.ts
13066
+ var richTextPlugin = defineBuiltinReactPlugin(richTextNativePlugin, {
13067
+ factory: richTextFactory,
13068
+ menuGroups: menuGroups2
13069
+ });
12308
13070
 
12309
13071
  // src/plugins/list/factory.ts
12310
13072
  var listFactory = {
@@ -12355,7 +13117,7 @@ var listFactory = {
12355
13117
  };
12356
13118
 
12357
13119
  // src/plugins/list/menu.ts
12358
- var menuGroups2 = [
13120
+ var menuGroups3 = [
12359
13121
  {
12360
13122
  id: "list",
12361
13123
  title: "\u5217\u8868\u7EC4\u4EF6",
@@ -12457,7 +13219,7 @@ var propertySections2 = [
12457
13219
  // src/plugins/list/react.ts
12458
13220
  var listPlugin = defineBuiltinReactPlugin(listNativePlugin, {
12459
13221
  factory: listFactory,
12460
- menuGroups: menuGroups2,
13222
+ menuGroups: menuGroups3,
12461
13223
  propertySections: propertySections2
12462
13224
  });
12463
13225
 
@@ -12480,7 +13242,7 @@ var dateTimeFactory = {
12480
13242
  };
12481
13243
  }
12482
13244
  };
12483
- var menuGroups3 = [
13245
+ var menuGroups4 = [
12484
13246
  {
12485
13247
  id: "date-time",
12486
13248
  title: "\u65E5\u671F\u65F6\u95F4",
@@ -12521,7 +13283,7 @@ var propertySections3 = [
12521
13283
  ];
12522
13284
  var dateTimePlugin = defineBuiltinReactPlugin(dateTimeNativePlugin, {
12523
13285
  factory: dateTimeFactory,
12524
- menuGroups: menuGroups3,
13286
+ menuGroups: menuGroups4,
12525
13287
  propertySections: propertySections3
12526
13288
  });
12527
13289
 
@@ -12544,7 +13306,7 @@ var moneyUpperFactory = {
12544
13306
  };
12545
13307
  }
12546
13308
  };
12547
- var menuGroups4 = [
13309
+ var menuGroups5 = [
12548
13310
  {
12549
13311
  id: "basic",
12550
13312
  title: "\u57FA\u7840\u5143\u7D20",
@@ -12598,7 +13360,7 @@ var propertySections4 = [
12598
13360
  ];
12599
13361
  var moneyUpperPlugin = defineBuiltinReactPlugin(
12600
13362
  moneyUpperNativePlugin,
12601
- { factory: moneyUpperFactory, menuGroups: menuGroups4, propertySections: propertySections4 }
13363
+ { factory: moneyUpperFactory, menuGroups: menuGroups5, propertySections: propertySections4 }
12602
13364
  );
12603
13365
 
12604
13366
  // src/plugins/page-number/factory.ts
@@ -12620,7 +13382,7 @@ var pageNumberFactory = {
12620
13382
  };
12621
13383
  }
12622
13384
  };
12623
- var menuGroups5 = [
13385
+ var menuGroups6 = [
12624
13386
  {
12625
13387
  id: "basic",
12626
13388
  title: "\u57FA\u7840\u5143\u7D20",
@@ -12669,7 +13431,7 @@ var propertySections5 = [
12669
13431
  ];
12670
13432
  var pageNumberPlugin = defineBuiltinReactPlugin(
12671
13433
  pageNumberNativePlugin,
12672
- { factory: pageNumberFactory, menuGroups: menuGroups5, propertySections: propertySections5 }
13434
+ { factory: pageNumberFactory, menuGroups: menuGroups6, propertySections: propertySections5 }
12673
13435
  );
12674
13436
 
12675
13437
  // src/plugins/watermark/factory.ts
@@ -12709,7 +13471,7 @@ var watermarkFactory = {
12709
13471
  };
12710
13472
  }
12711
13473
  };
12712
- var menuGroups6 = [
13474
+ var menuGroups7 = [
12713
13475
  {
12714
13476
  id: "basic",
12715
13477
  title: "\u57FA\u7840\u5143\u7D20",
@@ -12763,7 +13525,7 @@ var propertySections6 = [
12763
13525
  ];
12764
13526
  var watermarkPlugin = defineBuiltinReactPlugin(watermarkNativePlugin, {
12765
13527
  factory: watermarkFactory,
12766
- menuGroups: menuGroups6,
13528
+ menuGroups: menuGroups7,
12767
13529
  propertySections: propertySections6
12768
13530
  });
12769
13531
 
@@ -12904,7 +13666,7 @@ var shapeFactory = {
12904
13666
  };
12905
13667
 
12906
13668
  // src/plugins/shape/menu.ts
12907
- var menuGroups7 = [
13669
+ var menuGroups8 = [
12908
13670
  {
12909
13671
  id: "shape",
12910
13672
  title: "\u5F62\u72B6\u7EC4\u4EF6",
@@ -13050,15 +13812,15 @@ var menuGroups7 = [
13050
13812
 
13051
13813
  // src/plugins/shape/layout/options.ts
13052
13814
  var SHAPE_OPTIONS = [
13053
- ...(menuGroups7.find((group) => group.id === "shape")?.items ?? []).map(
13815
+ ...(menuGroups8.find((group) => group.id === "shape")?.items ?? []).map(
13054
13816
  ({ id, label }) => ({ value: id, label })
13055
13817
  ),
13056
13818
  { value: "ellipse", label: "\u692D\u5706" },
13057
13819
  { value: "line", label: "\u76F4\u7EBF" },
13058
- ...(menuGroups7.find((group) => group.id === "bracket")?.items ?? []).map(
13820
+ ...(menuGroups8.find((group) => group.id === "bracket")?.items ?? []).map(
13059
13821
  ({ id, label }) => ({ value: id, label })
13060
13822
  ),
13061
- ...(menuGroups7.find((group) => group.id === "curve")?.items ?? []).map(
13823
+ ...(menuGroups8.find((group) => group.id === "curve")?.items ?? []).map(
13062
13824
  ({ id, label }) => ({ value: id, label })
13063
13825
  ),
13064
13826
  { value: "curve-path", label: "\u8DEF\u5F84" }
@@ -13276,7 +14038,7 @@ var propertySections7 = [
13276
14038
  // src/plugins/shape/react.ts
13277
14039
  var shapePlugin = defineBuiltinReactPlugin(shapeNativePlugin, {
13278
14040
  factory: shapeFactory,
13279
- menuGroups: menuGroups7,
14041
+ menuGroups: menuGroups8,
13280
14042
  propertySections: propertySections7
13281
14043
  });
13282
14044
 
@@ -13307,6 +14069,7 @@ function BrushToolbarButton({
13307
14069
  title: active ? "\u9000\u51FA\u753B\u7B14\u6A21\u5F0F" : "\u65B0\u5EFA\u753B\u7B14\u56FE\u5C42\u5E76\u7ED8\u5236",
13308
14070
  "aria-label": "\u753B\u7B14\u6A21\u5F0F",
13309
14071
  "aria-pressed": active,
14072
+ type: active ? "primary" : "default",
13310
14073
  disabled: readonly,
13311
14074
  icon: /* @__PURE__ */ jsxRuntime.jsxs(
13312
14075
  "svg",
@@ -13358,7 +14121,7 @@ var brushFactory = {
13358
14121
  };
13359
14122
 
13360
14123
  // src/plugins/brush/menu.ts
13361
- var menuGroups8 = [];
14124
+ var menuGroups9 = [];
13362
14125
 
13363
14126
  // src/plugins/brush/properties.ts
13364
14127
  var propertySections8 = [
@@ -13442,7 +14205,7 @@ var propertySections8 = [
13442
14205
  // src/plugins/brush/react.ts
13443
14206
  var brushPlugin = defineBuiltinReactPlugin(brushNativePlugin, {
13444
14207
  factory: brushFactory,
13445
- menuGroups: menuGroups8,
14208
+ menuGroups: menuGroups9,
13446
14209
  propertySections: propertySections8
13447
14210
  });
13448
14211
 
@@ -13480,7 +14243,7 @@ var connectorFactory = {
13480
14243
  };
13481
14244
 
13482
14245
  // src/plugins/connector/menu.ts
13483
- var menuGroups9 = [
14246
+ var menuGroups10 = [
13484
14247
  {
13485
14248
  id: "connector",
13486
14249
  title: "\u8FDE\u63A5\u7EBF",
@@ -13595,7 +14358,7 @@ var propertySections9 = [
13595
14358
  // src/plugins/connector/react.ts
13596
14359
  var connectorPlugin = defineBuiltinReactPlugin(connectorNativePlugin, {
13597
14360
  factory: connectorFactory,
13598
- menuGroups: menuGroups9,
14361
+ menuGroups: menuGroups10,
13599
14362
  propertySections: propertySections9
13600
14363
  });
13601
14364
 
@@ -13620,7 +14383,7 @@ var dividerFactory = {
13620
14383
  };
13621
14384
  }
13622
14385
  };
13623
- var menuGroups10 = [
14386
+ var menuGroups11 = [
13624
14387
  {
13625
14388
  id: "basic",
13626
14389
  title: "\u57FA\u7840\u5143\u7D20",
@@ -13679,7 +14442,7 @@ var propertySections10 = [
13679
14442
  // src/plugins/divider/react.ts
13680
14443
  var dividerPlugin = defineBuiltinReactPlugin(dividerNativePlugin, {
13681
14444
  factory: dividerFactory,
13682
- menuGroups: menuGroups10,
14445
+ menuGroups: menuGroups11,
13683
14446
  propertySections: propertySections10
13684
14447
  });
13685
14448
 
@@ -13716,7 +14479,7 @@ var rulerFactory = {
13716
14479
  };
13717
14480
 
13718
14481
  // src/plugins/ruler/menu.ts
13719
- var menuGroups11 = [
14482
+ var menuGroups12 = [
13720
14483
  {
13721
14484
  id: "ruler",
13722
14485
  title: "\u523B\u5EA6\u5C3A\u7EC4\u4EF6",
@@ -13809,7 +14572,7 @@ var propertySections11 = [
13809
14572
  // src/plugins/ruler/react.ts
13810
14573
  var rulerPlugin = defineBuiltinReactPlugin(rulerNativePlugin, {
13811
14574
  factory: rulerFactory,
13812
- menuGroups: menuGroups11,
14575
+ menuGroups: menuGroups12,
13813
14576
  propertySections: propertySections11
13814
14577
  });
13815
14578
 
@@ -13851,7 +14614,7 @@ var gridFactory = {
13851
14614
  };
13852
14615
  }
13853
14616
  };
13854
- var menuGroups12 = [
14617
+ var menuGroups13 = [
13855
14618
  {
13856
14619
  id: "grid",
13857
14620
  title: "\u7F51\u683C\u7EC4\u4EF6",
@@ -14061,7 +14824,7 @@ var propertySections12 = [
14061
14824
  // src/plugins/grid/react.ts
14062
14825
  var gridPlugin = defineBuiltinReactPlugin(gridNativePlugin, {
14063
14826
  factory: gridFactory,
14064
- menuGroups: menuGroups12,
14827
+ menuGroups: menuGroups13,
14065
14828
  propertySections: propertySections12
14066
14829
  });
14067
14830
 
@@ -14123,7 +14886,7 @@ var coordinateFactory = {
14123
14886
  };
14124
14887
  }
14125
14888
  };
14126
- var menuGroups13 = [
14889
+ var menuGroups14 = [
14127
14890
  {
14128
14891
  id: "grid",
14129
14892
  title: "\u7F51\u683C\u7EC4\u4EF6",
@@ -14274,7 +15037,7 @@ var propertySections13 = [
14274
15037
  // src/plugins/coordinate/react.ts
14275
15038
  var coordinatePlugin = defineBuiltinReactPlugin(
14276
15039
  coordinateNativePlugin,
14277
- { factory: coordinateFactory, menuGroups: menuGroups13, propertySections: propertySections13 }
15040
+ { factory: coordinateFactory, menuGroups: menuGroups14, propertySections: propertySections13 }
14278
15041
  );
14279
15042
 
14280
15043
  // src/plugins/progress/factory.ts
@@ -14309,7 +15072,7 @@ var progressFactory = {
14309
15072
  };
14310
15073
 
14311
15074
  // src/plugins/progress/menu.ts
14312
- var menuGroups14 = [
15075
+ var menuGroups15 = [
14313
15076
  {
14314
15077
  id: "progress",
14315
15078
  title: "\u8FDB\u5EA6\u7EC4\u4EF6",
@@ -14441,7 +15204,7 @@ var propertySections14 = [
14441
15204
  // src/plugins/progress/react.ts
14442
15205
  var progressPlugin = defineBuiltinReactPlugin(progressNativePlugin, {
14443
15206
  factory: progressFactory,
14444
- menuGroups: menuGroups14,
15207
+ menuGroups: menuGroups15,
14445
15208
  propertySections: propertySections14
14446
15209
  });
14447
15210
 
@@ -14491,7 +15254,7 @@ var flowFactory = {
14491
15254
  };
14492
15255
  }
14493
15256
  };
14494
- var menuGroups15 = [
15257
+ var menuGroups16 = [
14495
15258
  {
14496
15259
  id: "basic",
14497
15260
  title: "\u57FA\u7840\u5143\u7D20",
@@ -14627,7 +15390,7 @@ var propertySections15 = [{
14627
15390
  // src/plugins/flow/react.ts
14628
15391
  var flowPlugin = defineBuiltinReactPlugin(flowNativePlugin, {
14629
15392
  factory: flowFactory,
14630
- menuGroups: menuGroups15,
15393
+ menuGroups: menuGroups16,
14631
15394
  propertySections: propertySections15
14632
15395
  });
14633
15396
 
@@ -14669,7 +15432,7 @@ var clockFactory = {
14669
15432
  };
14670
15433
  }
14671
15434
  };
14672
- var menuGroups16 = [
15435
+ var menuGroups17 = [
14673
15436
  {
14674
15437
  id: "date-time",
14675
15438
  title: "\u65E5\u671F\u65F6\u95F4",
@@ -14768,7 +15531,7 @@ var propertySections16 = [
14768
15531
  // src/plugins/clock/react.ts
14769
15532
  var clockPlugin = defineBuiltinReactPlugin(clockNativePlugin, {
14770
15533
  factory: clockFactory,
14771
- menuGroups: menuGroups16,
15534
+ menuGroups: menuGroups17,
14772
15535
  propertySections: propertySections16
14773
15536
  });
14774
15537
 
@@ -14887,7 +15650,7 @@ var imageFactory = {
14887
15650
  return { ...common, type, name: "\u56FE\u7247", src: "", fit: "contain" };
14888
15651
  }
14889
15652
  };
14890
- var menuGroups17 = [
15653
+ var menuGroups18 = [
14891
15654
  {
14892
15655
  id: "basic",
14893
15656
  title: "\u57FA\u7840\u5143\u7D20",
@@ -14942,7 +15705,7 @@ var propertySections17 = [
14942
15705
  // src/plugins/image/react.ts
14943
15706
  var imagePlugin = defineBuiltinReactPlugin(imageNativePlugin, {
14944
15707
  factory: imageFactory,
14945
- menuGroups: menuGroups17,
15708
+ menuGroups: menuGroups18,
14946
15709
  propertySections: propertySections17
14947
15710
  });
14948
15711
  var barcodeFactory = {
@@ -14972,7 +15735,7 @@ var barcodeFactory = {
14972
15735
  };
14973
15736
  }
14974
15737
  };
14975
- var menuGroups18 = [
15738
+ var menuGroups19 = [
14976
15739
  {
14977
15740
  id: "basic",
14978
15741
  title: "\u57FA\u7840\u5143\u7D20",
@@ -15032,7 +15795,7 @@ var propertySections18 = [
15032
15795
  // src/plugins/barcode/react.ts
15033
15796
  var barcodePlugin = defineBuiltinReactPlugin(barcodeNativePlugin, {
15034
15797
  factory: barcodeFactory,
15035
- menuGroups: menuGroups18,
15798
+ menuGroups: menuGroups19,
15036
15799
  propertySections: propertySections18
15037
15800
  });
15038
15801
 
@@ -15054,7 +15817,7 @@ var qrcodeFactory = {
15054
15817
  };
15055
15818
  }
15056
15819
  };
15057
- var menuGroups19 = [
15820
+ var menuGroups20 = [
15058
15821
  {
15059
15822
  id: "basic",
15060
15823
  title: "\u57FA\u7840\u5143\u7D20",
@@ -15213,7 +15976,7 @@ var propertySections19 = [
15213
15976
  // src/plugins/qrcode/react.ts
15214
15977
  var qrcodePlugin = defineBuiltinReactPlugin(qrcodeNativePlugin, {
15215
15978
  factory: qrcodeFactory,
15216
- menuGroups: menuGroups19,
15979
+ menuGroups: menuGroups20,
15217
15980
  propertySections: propertySections19
15218
15981
  });
15219
15982
 
@@ -15319,7 +16082,7 @@ var chartFactory = {
15319
16082
  };
15320
16083
  }
15321
16084
  };
15322
- var menuGroups20 = [
16085
+ var menuGroups21 = [
15323
16086
  {
15324
16087
  id: "chart",
15325
16088
  title: "\u56FE\u8868\u7EC4\u4EF6",
@@ -15582,30 +16345,129 @@ var propertySections20 = [{
15582
16345
  // src/plugins/chart/react.ts
15583
16346
  var chartPlugin = defineBuiltinReactPlugin(chartNativePlugin, {
15584
16347
  factory: chartFactory,
15585
- menuGroups: menuGroups20,
16348
+ menuGroups: menuGroups21,
15586
16349
  propertySections: propertySections20
15587
16350
  });
15588
16351
 
15589
16352
  // src/plugins/table/factory.ts
16353
+ var fieldPathSchema = {
16354
+ anyOf: [
16355
+ { type: "string", minLength: 1 },
16356
+ {
16357
+ type: "array",
16358
+ items: {
16359
+ anyOf: [
16360
+ { type: "string", minLength: 1 },
16361
+ { type: "integer", minimum: 0 }
16362
+ ]
16363
+ },
16364
+ minItems: 1
16365
+ }
16366
+ ]
16367
+ };
15590
16368
  var tableFactory = {
15591
16369
  type: "table",
15592
16370
  label: "\u8868\u683C",
15593
16371
  agentCommands: [
15594
16372
  {
15595
16373
  name: "insert-row",
15596
- description: "\u5728\u9759\u6001\u8868\u683C\u7684 rowIndex \u884C\u524D\u63D2\u5165\u884C\uFF1Bafter=true \u65F6\u63D2\u5728\u884C\u540E\u3002"
16374
+ description: "\u5728\u9759\u6001\u8868\u683C\u7684 rowIndex \u884C\u524D\u63D2\u5165\u884C\uFF1Bafter=true \u65F6\u63D2\u5728\u884C\u540E\u3002",
16375
+ parameters: {
16376
+ type: "object",
16377
+ properties: {
16378
+ rowIndex: { type: "integer", minimum: 0 },
16379
+ after: { type: "boolean" }
16380
+ },
16381
+ required: ["rowIndex"],
16382
+ additionalProperties: false
16383
+ }
15597
16384
  },
15598
16385
  {
15599
16386
  name: "insert-column",
15600
- description: "\u5728 columnIndex \u5217\u524D\u63D2\u5165\u5217\uFF1Bafter=true \u65F6\u63D2\u5728\u5217\u540E\u3002"
16387
+ description: "\u5728 columnIndex \u5217\u524D\u63D2\u5165\u5217\uFF1Bafter=true \u65F6\u63D2\u5728\u5217\u540E\u3002",
16388
+ parameters: {
16389
+ type: "object",
16390
+ properties: {
16391
+ columnIndex: { type: "integer", minimum: 0 },
16392
+ after: { type: "boolean" }
16393
+ },
16394
+ required: ["columnIndex"],
16395
+ additionalProperties: false
16396
+ }
15601
16397
  },
15602
16398
  {
15603
16399
  name: "merge-body",
15604
- description: "\u5408\u5E76\u8868\u4F53\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002"
16400
+ description: "\u5408\u5E76\u8868\u4F53\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002",
16401
+ parameters: {
16402
+ type: "object",
16403
+ properties: {
16404
+ rowIndex: { type: "integer", minimum: 0 },
16405
+ columnIndex: { type: "integer", minimum: 0 },
16406
+ rowSpan: { type: "integer", minimum: 1 },
16407
+ colSpan: { type: "integer", minimum: 1 }
16408
+ },
16409
+ required: ["rowIndex", "columnIndex", "rowSpan", "colSpan"],
16410
+ additionalProperties: false
16411
+ }
15605
16412
  },
15606
16413
  {
15607
16414
  name: "merge-header",
15608
- description: "\u5408\u5E76\u8868\u5934\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002"
16415
+ description: "\u5408\u5E76\u8868\u5934\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002",
16416
+ parameters: {
16417
+ type: "object",
16418
+ properties: {
16419
+ rowIndex: { type: "integer", minimum: 0 },
16420
+ columnIndex: { type: "integer", minimum: 0 },
16421
+ rowSpan: { type: "integer", minimum: 1 },
16422
+ colSpan: { type: "integer", minimum: 1 }
16423
+ },
16424
+ required: ["rowIndex", "columnIndex", "rowSpan", "colSpan"],
16425
+ additionalProperties: false
16426
+ }
16427
+ },
16428
+ {
16429
+ name: "configure-auto-merge",
16430
+ 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',
16431
+ parameters: {
16432
+ type: "object",
16433
+ properties: {
16434
+ enabled: { type: "boolean" },
16435
+ rowKeys: { type: "array", items: fieldPathSchema },
16436
+ rowColumns: { type: "array", items: fieldPathSchema },
16437
+ columnKeys: { type: "array", items: fieldPathSchema }
16438
+ },
16439
+ additionalProperties: false
16440
+ }
16441
+ },
16442
+ {
16443
+ name: "configure-group-aggregation",
16444
+ 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',
16445
+ parameters: {
16446
+ type: "object",
16447
+ properties: {
16448
+ enabled: { type: "boolean" },
16449
+ groupBy: {
16450
+ type: "array",
16451
+ items: { type: "string", minLength: 1 },
16452
+ minItems: 1
16453
+ },
16454
+ sums: {
16455
+ type: "array",
16456
+ items: {
16457
+ type: "object",
16458
+ properties: {
16459
+ column: { type: "string", minLength: 1 },
16460
+ path: { type: "string", minLength: 1 },
16461
+ decimals: { type: "integer", minimum: 0, maximum: 10 }
16462
+ },
16463
+ required: ["column", "path"],
16464
+ additionalProperties: false
16465
+ }
16466
+ },
16467
+ itemsPerRow: { type: "integer", minimum: 1 }
16468
+ },
16469
+ additionalProperties: false
16470
+ }
15609
16471
  }
15610
16472
  ],
15611
16473
  defaultOverflowPolicy: "split",
@@ -15689,7 +16551,7 @@ var tableFactory = {
15689
16551
  };
15690
16552
  }
15691
16553
  };
15692
- var menuGroups21 = [
16554
+ var menuGroups22 = [
15693
16555
  {
15694
16556
  id: "table",
15695
16557
  title: "\u8868\u683C\u7EC4\u4EF6",
@@ -17567,6 +18429,7 @@ function TableCellsPanel({
17567
18429
  title: label,
17568
18430
  "aria-label": `${name}\u6587\u672C${label}`,
17569
18431
  "aria-pressed": (textStyle.textAlign ?? "center") === value,
18432
+ type: (textStyle.textAlign ?? "center") === value ? "primary" : "default",
17570
18433
  onClick: () => updateStyle({ textAlign: value })
17571
18434
  },
17572
18435
  value
@@ -17590,6 +18453,7 @@ function TableCellsPanel({
17590
18453
  title: "\u52A0\u7C97",
17591
18454
  "aria-label": `${name}\u6587\u672C\u52A0\u7C97`,
17592
18455
  "aria-pressed": textStyle.bold === true,
18456
+ type: textStyle.bold === true ? "primary" : "default",
17593
18457
  onClick: () => updateStyle({ bold: !textStyle.bold })
17594
18458
  }
17595
18459
  ),
@@ -17600,6 +18464,7 @@ function TableCellsPanel({
17600
18464
  title: "\u503E\u659C",
17601
18465
  "aria-label": `${name}\u6587\u672C\u503E\u659C`,
17602
18466
  "aria-pressed": textStyle.italic === true,
18467
+ type: textStyle.italic === true ? "primary" : "default",
17603
18468
  onClick: () => updateStyle({ italic: !textStyle.italic })
17604
18469
  }
17605
18470
  )
@@ -17616,80 +18481,6 @@ function TableCellsPanel({
17616
18481
  )
17617
18482
  ] });
17618
18483
  }
17619
-
17620
- // src/plugins/table/data/packed-report-defaults.ts
17621
- function fillPackedReportDefaults(columns, rows, current2) {
17622
- const visible = tableLeafColumns(columns).filter((column) => !column.hidden);
17623
- const keys2 = visible.map(
17624
- (column) => typeof column.dataIndex === "string" ? column.dataIndex : ""
17625
- );
17626
- const repeats = /* @__PURE__ */ new Map();
17627
- keys2.forEach((key) => {
17628
- const match = /^(.+?)([1-9]\d*)$/.exec(key);
17629
- if (!match) return;
17630
- const slots = repeats.get(match[1]) ?? /* @__PURE__ */ new Set();
17631
- slots.add(Number(match[2]));
17632
- repeats.set(match[1], slots);
17633
- });
17634
- const series = [...repeats].filter(
17635
- ([, slots]) => slots.has(1) && slots.has(2)
17636
- );
17637
- const itemsPerRow = Math.max(
17638
- 1,
17639
- ...series.map(([, slots]) => Math.max(...slots))
17640
- );
17641
- const sample = rows.find((row) => row && typeof row === "object") ?? {};
17642
- const groupFields = {};
17643
- keys2.forEach((key, index) => {
17644
- const repeated = series.some(
17645
- ([prefix, slots]) => [...slots].some((slot) => key === `${prefix}${slot}`)
17646
- );
17647
- if (key && !repeated && !visible[index]?.summary && visible[index]?.summaryTitle == null) {
17648
- groupFields[key] = key in sample ? key : "";
17649
- }
17650
- });
17651
- const itemFields = series.map(([prefix]) => ({
17652
- prefix,
17653
- .../^(sequence|seq|index|序号)$/i.test(prefix) ? { mode: "index" } : { mode: "value", path: prefix in sample ? prefix : "" }
17654
- }));
17655
- const totals = {};
17656
- visible.forEach((column, index) => {
17657
- const key = keys2[index];
17658
- const summary = column.summary;
17659
- const type = typeof summary === "object" ? summary.type ?? "sum" : "sum";
17660
- if (key && summary && type === "sum") {
17661
- const prefix = series.find(
17662
- ([name, slots]) => [...slots].some((slot) => key === `${name}${slot}`)
17663
- )?.[0];
17664
- totals[key] = {
17665
- sumPath: key in sample ? key : prefix && prefix in sample ? prefix : "",
17666
- ...typeof summary === "object" && summary.precision != null ? { decimals: summary.precision } : {}
17667
- };
17668
- }
17669
- });
17670
- const subtotalLabelKey = keys2.find(
17671
- (key) => key && !(key in totals) && !(key in groupFields)
17672
- );
17673
- const totalLabelKey = keys2.find((key) => key && !(key in totals));
17674
- const subtotal = { ...totals };
17675
- if (subtotalLabelKey) subtotal[subtotalLabelKey] = { text: "\u5C0F\u8BA1" };
17676
- if (totalLabelKey) totals[totalLabelKey] = { text: "\u603B\u8BA1" };
17677
- return {
17678
- groupBy: current2?.groupBy ?? [],
17679
- itemsPerRow: current2?.itemsPerRow ?? itemsPerRow,
17680
- groupFields: Object.keys(current2?.groupFields ?? {}).length ? current2.groupFields : groupFields,
17681
- groupMergeColumns: Object.keys(current2?.groupFields ?? {}).length ? current2.groupMergeColumns : keys2.flatMap(
17682
- (key, index) => key && key in groupFields ? [index] : []
17683
- ),
17684
- itemFields: current2?.itemFields?.length ? current2.itemFields : itemFields,
17685
- subtotal: Object.keys(current2?.subtotal ?? {}).length ? current2.subtotal : subtotal,
17686
- subtotalMerges: current2?.subtotalMerges ?? [],
17687
- total: Object.keys(current2?.total ?? {}).length ? current2.total : totals,
17688
- totalMerges: current2?.totalMerges ?? [],
17689
- appendRows: current2?.appendRows ?? [],
17690
- ...current2?.footerElementIds ? { footerElementIds: current2.footerElementIds } : {}
17691
- };
17692
- }
17693
18484
  var isTableRows = (value) => Array.isArray(value) && value.every(
17694
18485
  (row) => row !== null && typeof row === "object" && !Array.isArray(row)
17695
18486
  );
@@ -18846,7 +19637,7 @@ function PackedReportPanel({
18846
19637
  ] })
18847
19638
  ] });
18848
19639
  }
18849
- var fieldPath = (value) => Array.isArray(value) ? value.join(".") : String(value);
19640
+ var fieldPath2 = (value) => Array.isArray(value) ? value.join(".") : String(value);
18850
19641
  function TableAutoMergePanel({
18851
19642
  element,
18852
19643
  samples = [],
@@ -18899,7 +19690,7 @@ function TableAutoMergePanel({
18899
19690
  reactPrintDesign.DataPathPicker,
18900
19691
  {
18901
19692
  label: `${label} ${index + 1}`,
18902
- value: fieldPath(value),
19693
+ value: fieldPath2(value),
18903
19694
  samples,
18904
19695
  onChange: (path) => set(
18905
19696
  values.map(
@@ -19482,16 +20273,19 @@ function TableColumnsPanel({
19482
20273
  ] });
19483
20274
  }
19484
20275
  function fixedTableWidth(columns) {
19485
- return tableLeafColumns(columns).filter((column) => !column.hidden).reduce((sum, column) => sum + Math.min(
19486
- column.maxWidth ?? Number.POSITIVE_INFINITY,
19487
- Math.max(column.minWidth ?? 1, column.width ?? 100)
19488
- ), 0) * 25.4 / 96;
20276
+ return tableLeafColumns(columns).filter((column) => !column.hidden).reduce(
20277
+ (sum, column) => sum + Math.min(
20278
+ column.maxWidth ?? Number.POSITIVE_INFINITY,
20279
+ Math.max(column.minWidth ?? 1, column.width ?? 100)
20280
+ ),
20281
+ 0
20282
+ ) * 25.4 / 96;
19489
20283
  }
19490
20284
  function TableColumnsControl(context) {
19491
20285
  if (context.element.type !== "table") return null;
19492
20286
  const element = context.element;
19493
20287
  const page = context.page;
19494
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
20288
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cc-print-design-column-control cc-print-design-field-full", children: [
19495
20289
  /* @__PURE__ */ jsxRuntime.jsx(
19496
20290
  TableColumnsPanel,
19497
20291
  {
@@ -19523,10 +20317,18 @@ function TableColumnsControl(context) {
19523
20317
  {
19524
20318
  icon: /* @__PURE__ */ jsxRuntime.jsx(reactComponents.ReactPlusOutlined, { "aria-hidden": "true" }),
19525
20319
  disabled: context.readonly,
19526
- onClick: () => context.onChange({ columns: [
19527
- ...element.columns,
19528
- { key: crypto.randomUUID(), title: "\u65B0\u5217", dataIndex: `field${element.columns.length + 1}`, cellType: "text", width: 100 }
19529
- ] }),
20320
+ onClick: () => context.onChange({
20321
+ columns: [
20322
+ ...element.columns,
20323
+ {
20324
+ key: crypto.randomUUID(),
20325
+ title: "\u65B0\u5217",
20326
+ dataIndex: `field${element.columns.length + 1}`,
20327
+ cellType: "text",
20328
+ width: 100
20329
+ }
20330
+ ]
20331
+ }),
19530
20332
  children: "\u6DFB\u52A0\u5217"
19531
20333
  }
19532
20334
  ),
@@ -19746,7 +20548,7 @@ var propertySections21 = [
19746
20548
  // src/plugins/table/react.ts
19747
20549
  var tablePlugin = defineBuiltinReactPlugin(tableNativePlugin, {
19748
20550
  factory: tableFactory,
19749
- menuGroups: menuGroups21,
20551
+ menuGroups: menuGroups22,
19750
20552
  contextMenu: tableContextMenu,
19751
20553
  propertySections: propertySections21
19752
20554
  });
@@ -19822,7 +20624,7 @@ var pivotTableFactory = {
19822
20624
  };
19823
20625
  }
19824
20626
  };
19825
- var menuGroups22 = [
20627
+ var menuGroups23 = [
19826
20628
  {
19827
20629
  id: "table",
19828
20630
  title: "\u8868\u683C\u7EC4\u4EF6",
@@ -20527,7 +21329,7 @@ var pivotTablePlugin = defineBuiltinReactPlugin(
20527
21329
  pivotTableNativePlugin,
20528
21330
  {
20529
21331
  factory: pivotTableFactory,
20530
- menuGroups: menuGroups22,
21332
+ menuGroups: menuGroups23,
20531
21333
  propertySections: propertySections22
20532
21334
  }
20533
21335
  );
@@ -20602,7 +21404,7 @@ var ganttFactory = {
20602
21404
  };
20603
21405
  }
20604
21406
  };
20605
- var menuGroups23 = [
21407
+ var menuGroups24 = [
20606
21408
  {
20607
21409
  id: "table",
20608
21410
  title: "\u8868\u683C\u7EC4\u4EF6",
@@ -20976,7 +21778,7 @@ var propertySections23 = [
20976
21778
  // src/plugins/gantt/react.ts
20977
21779
  var ganttPlugin = defineBuiltinReactPlugin(ganttNativePlugin, {
20978
21780
  factory: ganttFactory,
20979
- menuGroups: menuGroups23,
21781
+ menuGroups: menuGroups24,
20980
21782
  propertySections: propertySections23
20981
21783
  });
20982
21784
  function formatTime(value) {
@@ -21750,6 +22552,7 @@ var pagePropertyPanels = new reactPrintDesign.PrintDesignScopedPropertyRegistry(
21750
22552
  reactComponents.ReactButton,
21751
22553
  {
21752
22554
  "aria-pressed": settings?.showGrid ?? false,
22555
+ type: settings?.showGrid ? "primary" : "default",
21753
22556
  disabled: readonly,
21754
22557
  onClick: () => onSettingsChange?.({
21755
22558
  showGrid: !(settings?.showGrid ?? false)
@@ -21889,9 +22692,9 @@ var themeSettingsSections = [{
21889
22692
  render: ({ preferences }, readonly, onChange) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cc-print-design-theme-options", role: "group", "aria-label": "\u7F16\u8F91\u5668\u4E3B\u9898", children: Object.keys(reactPrintDesign.editorThemes).map((key) => {
21890
22693
  const theme = reactPrintDesign.editorThemes[key];
21891
22694
  return /* @__PURE__ */ jsxRuntime.jsxs(
21892
- "button",
22695
+ reactComponents.ReactButton,
21893
22696
  {
21894
- type: "button",
22697
+ type: (preferences.theme ?? "light") === key ? "primary" : "default",
21895
22698
  className: "cc-print-design-theme-option",
21896
22699
  "aria-pressed": (preferences.theme ?? "light") === key,
21897
22700
  disabled: readonly,
@@ -22316,6 +23119,80 @@ var settingsInteractionTool = {
22316
23119
  sectionId: "interaction",
22317
23120
  settingsSections: interactionSettingsSections
22318
23121
  };
23122
+ var keyboardMoveSettingsSections = [
23123
+ {
23124
+ sectionId: "keyboard-move",
23125
+ title: "\u952E\u76D8\u79FB\u52A8",
23126
+ fields: [
23127
+ {
23128
+ path: "canvas.keyboardMoveStep",
23129
+ label: "\u65B9\u5411\u952E\u6B65\u957F",
23130
+ kind: "number",
23131
+ persistence: "local",
23132
+ min: 1e-3,
23133
+ read: ({ settings, preferences }) => printDesign.toDisplayUnit(
23134
+ settings.keyboardMoveStep ?? 1,
23135
+ preferences.displayUnit
23136
+ ),
23137
+ write: (value, { preferences }) => ({
23138
+ kind: "canvas",
23139
+ patch: {
23140
+ keyboardMoveStep: Math.max(
23141
+ 0.01,
23142
+ printDesign.fromDisplayUnit(value, preferences.displayUnit)
23143
+ )
23144
+ }
23145
+ })
23146
+ },
23147
+ {
23148
+ path: "canvas.keyboardMoveAcceleration",
23149
+ label: "\u957F\u6309\u52A0\u901F",
23150
+ kind: "toggle",
23151
+ persistence: "local",
23152
+ onLabel: "\u5F00\u542F",
23153
+ offLabel: "\u5173\u95ED",
23154
+ read: ({ settings }) => settings.keyboardMoveAcceleration ?? false,
23155
+ write: (keyboardMoveAcceleration) => ({
23156
+ kind: "canvas",
23157
+ patch: { keyboardMoveAcceleration }
23158
+ })
23159
+ },
23160
+ {
23161
+ path: "help.keyboardMove",
23162
+ label: "\u64CD\u4F5C\u63D0\u793A",
23163
+ kind: "hint",
23164
+ persistence: "session",
23165
+ 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"
23166
+ }
23167
+ ]
23168
+ }
23169
+ ];
23170
+
23171
+ // src/tools/settings-keyboard-move/react.tsx
23172
+ var settingsKeyboardMoveTool = {
23173
+ toolId: "builtin.settings.keyboard-move",
23174
+ version: "0.1.0",
23175
+ label: "\u952E\u76D8\u79FB\u52A8",
23176
+ order: 60,
23177
+ placement: "section",
23178
+ parentToolId: "builtin.settings",
23179
+ sectionId: "keyboard-move",
23180
+ settingsSections: keyboardMoveSettingsSections,
23181
+ resolveKeyboardMove(event, heldMs, settings) {
23182
+ const direction = {
23183
+ ArrowLeft: { dx: -1, dy: 0 },
23184
+ ArrowRight: { dx: 1, dy: 0 },
23185
+ ArrowUp: { dx: 0, dy: -1 },
23186
+ ArrowDown: { dx: 0, dy: 1 }
23187
+ }[event.key];
23188
+ if (!direction) return null;
23189
+ const configuredStep = settings.keyboardMoveStep ?? 1;
23190
+ const baseStep = Number.isFinite(configuredStep) && configuredStep > 0 ? configuredStep : 1;
23191
+ const acceleration = settings.keyboardMoveAcceleration === true ? heldMs >= 1800 ? 10 : heldMs >= 1e3 ? 5 : heldMs >= 500 ? 2 : 1 : 1;
23192
+ const step = baseStep * acceleration * (event.shiftKey ? 10 : 1);
23193
+ return { dx: direction.dx * step, dy: direction.dy * step };
23194
+ }
23195
+ };
22319
23196
 
22320
23197
  // src/tools/settings-indicators/properties.ts
22321
23198
  var indicatorSettingsSections = [{
@@ -22407,11 +23284,13 @@ var builtinReactTools = [
22407
23284
  settingsRulersTool,
22408
23285
  settingsGuidesTool,
22409
23286
  settingsInteractionTool,
23287
+ settingsKeyboardMoveTool,
22410
23288
  settingsIndicatorsTool,
22411
23289
  pluginmarketTool
22412
23290
  ];
22413
23291
  var builtinReactComponentPlugins = [
22414
23292
  textPlugin,
23293
+ richTextPlugin,
22415
23294
  listPlugin,
22416
23295
  dateTimePlugin,
22417
23296
  moneyUpperPlugin,
@@ -22435,17 +23314,17 @@ var builtinReactComponentPlugins = [
22435
23314
  pivotTablePlugin,
22436
23315
  ganttPlugin
22437
23316
  ];
22438
- var menuGroups24 = /* @__PURE__ */ new Map();
23317
+ var menuGroups25 = /* @__PURE__ */ new Map();
22439
23318
  for (const plugin of builtinReactComponentPlugins) {
22440
23319
  for (const group of plugin.menuGroups) {
22441
- const current2 = menuGroups24.get(group.id);
23320
+ const current2 = menuGroups25.get(group.id);
22442
23321
  if (current2) {
22443
23322
  if (current2.title !== group.title || current2.order !== group.order) {
22444
23323
  throw new Error(`\u83DC\u5355\u5206\u7EC4\u5B9A\u4E49\u4E0D\u4E00\u81F4\uFF1A${group.id}`);
22445
23324
  }
22446
23325
  current2.items.push(...group.items);
22447
23326
  } else {
22448
- menuGroups24.set(group.id, { ...group, items: [...group.items] });
23327
+ menuGroups25.set(group.id, { ...group, items: [...group.items] });
22449
23328
  }
22450
23329
  }
22451
23330
  }
@@ -22486,7 +23365,7 @@ var builtinPrintDesignPlugins = Object.freeze({
22486
23365
  componentFactories: new reactPrintDesign.PrintDesignComponentFactoryRegistry(
22487
23366
  builtinReactComponentPlugins.map((plugin) => plugin.factory)
22488
23367
  ),
22489
- componentMenu: [...menuGroups24.values()].sort((a, b) => a.order - b.order).map((group) => ({
23368
+ componentMenu: [...menuGroups25.values()].sort((a, b) => a.order - b.order).map((group) => ({
22490
23369
  id: group.id,
22491
23370
  title: group.title,
22492
23371
  items: group.items.sort((a, b) => a.order - b.order)