@canvas-components/print-design-plugin 0.1.6 → 0.1.8

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.
@@ -1003,13 +1003,45 @@ function validateListTemplateData(element, data) {
1003
1003
  );
1004
1004
  }
1005
1005
 
1006
+ // src/plugins/list/interaction/commands.ts
1007
+ var listCommands = {
1008
+ execute(element, command, payload) {
1009
+ if (element.locked || !payload || typeof payload !== "object") return;
1010
+ const args = payload;
1011
+ const index = args.index;
1012
+ if (!Number.isInteger(index)) return;
1013
+ const at = index;
1014
+ const items = [...element.items];
1015
+ if (command === "remove-item") {
1016
+ if (at < 0 || at >= items.length) return;
1017
+ items.splice(at, 1);
1018
+ } else if (command === "insert-item") {
1019
+ if (at < 0 || at > items.length || typeof args.text !== "string") return;
1020
+ items.splice(at, 0, { text: args.text, checked: false });
1021
+ } else if (command === "update-item") {
1022
+ if (at < 0 || at >= items.length) return;
1023
+ if (args.text !== void 0 && typeof args.text !== "string") return;
1024
+ if (args.checked !== void 0 && typeof args.checked !== "boolean")
1025
+ return;
1026
+ items[at] = {
1027
+ ...items[at],
1028
+ ...args.text === void 0 ? {} : { text: args.text },
1029
+ ...args.checked === void 0 ? {} : { checked: args.checked }
1030
+ };
1031
+ } else return;
1032
+ const next = { ...element, items };
1033
+ return validateListElement(next) ? next : void 0;
1034
+ }
1035
+ };
1036
+
1006
1037
  // src/plugins/list/native.ts
1007
1038
  var listNativePlugin = defineNativePlugin(
1008
1039
  "list",
1009
- "0.1.8",
1040
+ "0.1.9",
1010
1041
  printDesign.definePrintDesignPluginRenderer({
1011
1042
  type: "list",
1012
1043
  validate: validateListElement,
1044
+ commands: listCommands,
1013
1045
  bindingInfo: listBindingInfo,
1014
1046
  validateTemplateData: validateListTemplateData,
1015
1047
  drawCanvas: drawListElement,
@@ -2657,16 +2689,51 @@ function pointToSegmentDistance(point, a, b) {
2657
2689
  return Math.hypot(point.x - a.x - t * dx, point.y - a.y - t * dy);
2658
2690
  }
2659
2691
 
2692
+ // src/plugins/shape/interaction/commands.ts
2693
+ var validPoints = (value) => Array.isArray(value) && value.every(
2694
+ (point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
2695
+ );
2696
+ var shapeCommands = {
2697
+ execute(element, command, payload) {
2698
+ if (element.locked || !payload || typeof payload !== "object") return;
2699
+ const args = payload;
2700
+ if (!validPoints(args.points)) return;
2701
+ const points = args.points;
2702
+ let next;
2703
+ if (command === "set-polygon-points") {
2704
+ if (!["triangle", "polygon", "star"].includes(element.shape) || points.length < 3)
2705
+ return;
2706
+ next = { ...element, polygonPoints: points };
2707
+ } else if (command === "set-curve-points") {
2708
+ if (!["curve-quadratic", "curve-cubic", "curve-multi"].includes(
2709
+ element.shape
2710
+ ) || points.length < 2)
2711
+ return;
2712
+ next = { ...element, curvePoints: points };
2713
+ } else if (command === "set-path-points") {
2714
+ if (element.shape !== "curve-path") return;
2715
+ if (args.closed !== void 0 && typeof args.closed !== "boolean") return;
2716
+ next = {
2717
+ ...element,
2718
+ pathPoints: points,
2719
+ ...args.closed === void 0 ? {} : { pathClosed: args.closed }
2720
+ };
2721
+ } else return;
2722
+ return validateShapeElement(next) ? next : void 0;
2723
+ }
2724
+ };
2725
+
2660
2726
  // src/plugins/shape/native.ts
2661
2727
  var shapeNativePlugin = defineNativePlugin(
2662
2728
  "shape",
2663
- "0.1.20",
2729
+ "0.1.21",
2664
2730
  printDesign.definePrintDesignPluginRenderer({
2665
2731
  type: "shape",
2666
2732
  dataFields: shapeDataFields,
2667
2733
  bindingInfo: (element) => registeredFieldBindingInfo(element, shapeDataFields),
2668
2734
  validateTemplateData: (element, data) => validateRegisteredFieldBindings(element, shapeDataFields, data),
2669
2735
  validate: validateShapeElement,
2736
+ commands: shapeCommands,
2670
2737
  drawCanvas: drawShapeElement,
2671
2738
  renderHtml: (element, context) => renderShapeHtml(element, context.data),
2672
2739
  hitTest: hitShape,
@@ -3008,13 +3075,42 @@ var brushPointerStroke = {
3008
3075
  }
3009
3076
  };
3010
3077
 
3078
+ // src/plugins/brush/interaction/commands.ts
3079
+ var brushCommands = {
3080
+ execute(element, command, payload) {
3081
+ if (element.locked || !payload || typeof payload !== "object") return;
3082
+ const args = payload;
3083
+ if (command === "append-stroke") {
3084
+ if (!Array.isArray(args.points) || args.points.length < 2) return;
3085
+ const next2 = {
3086
+ ...element,
3087
+ strokes: [
3088
+ ...element.strokes,
3089
+ args.points
3090
+ ]
3091
+ };
3092
+ return validateBrushElement(next2) ? next2 : void 0;
3093
+ }
3094
+ if (command !== "remove-stroke" || !Number.isInteger(args.index)) return;
3095
+ const index = args.index;
3096
+ if (index < 0 || index >= element.strokes.length) return;
3097
+ const next = {
3098
+ ...element,
3099
+ strokes: element.strokes.filter((_, at) => at !== index),
3100
+ strokeStyles: element.strokeStyles?.filter((_, at) => at !== index)
3101
+ };
3102
+ return validateBrushElement(next) ? next : void 0;
3103
+ }
3104
+ };
3105
+
3011
3106
  // src/plugins/brush/native.ts
3012
3107
  var brushNativePlugin = defineNativePlugin(
3013
3108
  "brush",
3014
- "0.1.4",
3109
+ "0.1.5",
3015
3110
  printDesign.definePrintDesignPluginRenderer({
3016
3111
  type: "brush",
3017
3112
  validate: validateBrushElement,
3113
+ commands: brushCommands,
3018
3114
  drawCanvas: drawBrushElement,
3019
3115
  renderHtml: (element) => renderBrushHtml(element),
3020
3116
  hitTest: hitBrush,
@@ -4010,6 +4106,46 @@ function validateConnectorElement(value) {
4010
4106
  const validPoint = (point) => !!point && Number.isFinite(point.x) && Number.isFinite(point.y);
4011
4107
  return element.type === "connector" && (element.lineType === void 0 || ["straight", "curve", "polyline"].includes(element.lineType)) && (element.polylinePoints === void 0 || Array.isArray(element.polylinePoints) && element.polylinePoints.every(validPoint)) && (element.strokeWidth === void 0 || Number.isFinite(element.strokeWidth) && element.strokeWidth >= 0) && (element.textPosition === void 0 || Number.isFinite(element.textPosition) && element.textPosition >= 0 && element.textPosition <= 1);
4012
4108
  }
4109
+
4110
+ // src/plugins/connector/interaction/commands.ts
4111
+ var validEndpoint = (value) => {
4112
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
4113
+ const endpoint2 = value;
4114
+ return (endpoint2.elementId === void 0 || typeof endpoint2.elementId === "string") && (endpoint2.anchor === void 0 || typeof endpoint2.anchor === "string" && ([
4115
+ "auto",
4116
+ "top",
4117
+ "right",
4118
+ "bottom",
4119
+ "left",
4120
+ "top-left",
4121
+ "top-right",
4122
+ "bottom-right",
4123
+ "bottom-left"
4124
+ ].includes(endpoint2.anchor) || /^(edge|vertex):\d+$/.test(endpoint2.anchor)));
4125
+ };
4126
+ var connectorCommands = {
4127
+ execute(element, command, payload) {
4128
+ if (element.locked || !payload || typeof payload !== "object") return;
4129
+ const args = payload;
4130
+ if (command === "set-endpoint") {
4131
+ if (args.side !== "start" && args.side !== "end") return;
4132
+ if (!validEndpoint(args.endpoint)) return;
4133
+ const next2 = { ...element, [args.side]: args.endpoint };
4134
+ return validateConnectorElement(next2) ? next2 : void 0;
4135
+ }
4136
+ if (command !== "set-waypoints" || element.lineType !== "polyline")
4137
+ return;
4138
+ if (!Array.isArray(args.points) || !args.points.every(
4139
+ (point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
4140
+ ))
4141
+ return;
4142
+ const next = {
4143
+ ...element,
4144
+ polylinePoints: args.points
4145
+ };
4146
+ return validateConnectorElement(next) ? next : void 0;
4147
+ }
4148
+ };
4013
4149
  var CONNECTOR_EXPRESSION = /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g;
4014
4150
  function labelPaths(element) {
4015
4151
  return [...(element.text ?? "").matchAll(CONNECTOR_EXPRESSION)].map(
@@ -4030,10 +4166,11 @@ function validateConnectorTemplateData(element, data) {
4030
4166
  // src/plugins/connector/native.ts
4031
4167
  var connectorNativePlugin = defineNativePlugin(
4032
4168
  "connector",
4033
- "0.1.31",
4169
+ "0.1.32",
4034
4170
  printDesign.definePrintDesignPluginRenderer({
4035
4171
  type: "connector",
4036
4172
  validate: validateConnectorElement,
4173
+ commands: connectorCommands,
4037
4174
  bindingInfo: connectorBindingInfo,
4038
4175
  validateTemplateData: validateConnectorTemplateData,
4039
4176
  allowSignedSize: true,
@@ -4921,13 +5058,68 @@ function gridDebugRegions(element, context, hitElement = element) {
4921
5058
  return [...cells, ...loops, ...columnLoops];
4922
5059
  }
4923
5060
 
5061
+ // src/plugins/grid/interaction/commands.ts
5062
+ function executeGridCommand(element, command, payload, validate) {
5063
+ if (element.locked || !payload || typeof payload !== "object") return;
5064
+ const args = payload;
5065
+ if (command === "resize-grid") {
5066
+ const rows = args.rows;
5067
+ const columns = args.columns;
5068
+ if (!Number.isInteger(rows) || !Number.isInteger(columns)) return;
5069
+ if (rows < 1 || rows > 50 || columns < 1 || columns > 50)
5070
+ return;
5071
+ const cells2 = Array.from(
5072
+ { length: rows * columns },
5073
+ (_, index2) => {
5074
+ const row = Math.floor(index2 / columns);
5075
+ const column = index2 % columns;
5076
+ return element.cells?.[row * element.columns + column] ?? {};
5077
+ }
5078
+ );
5079
+ const next2 = {
5080
+ ...element,
5081
+ rows,
5082
+ columns,
5083
+ cells: cells2
5084
+ };
5085
+ return validate(next2) ? next2 : void 0;
5086
+ }
5087
+ if (command !== "set-cell") return;
5088
+ const rowIndex = args.rowIndex;
5089
+ const columnIndex = args.columnIndex;
5090
+ if (!Number.isInteger(rowIndex) || !Number.isInteger(columnIndex)) return;
5091
+ if (rowIndex < 0 || rowIndex >= element.rows || columnIndex < 0 || columnIndex >= element.columns)
5092
+ return;
5093
+ const cell = args.cell;
5094
+ if (!cell || typeof cell !== "object" || Array.isArray(cell)) return;
5095
+ const index = rowIndex * element.columns + columnIndex;
5096
+ const cells = Array.from(
5097
+ { length: element.rows * element.columns },
5098
+ (_, at) => ({ ...element.cells?.[at] })
5099
+ );
5100
+ cells[index] = { ...cells[index], ...cell };
5101
+ const next = { ...element, cells };
5102
+ return validate(next) ? next : void 0;
5103
+ }
5104
+ var gridCommands = {
5105
+ execute(element, command, payload) {
5106
+ return executeGridCommand(
5107
+ element,
5108
+ command,
5109
+ payload,
5110
+ (value) => !!value && typeof value === "object" && value.type === "grid" && validateGridSettings(value)
5111
+ );
5112
+ }
5113
+ };
5114
+
4924
5115
  // src/plugins/grid/native.ts
4925
5116
  var gridNativePlugin = defineNativePlugin(
4926
5117
  "grid",
4927
- "0.1.15",
5118
+ "0.1.16",
4928
5119
  printDesign.definePrintDesignPluginRenderer({
4929
5120
  type: "grid",
4930
5121
  validate: validateGridElement,
5122
+ commands: gridCommands,
4931
5123
  validateTemplateData: validateGridTemplateData,
4932
5124
  bindingInfo: getGridBindingInfo,
4933
5125
  drawCanvas: drawGridElement,
@@ -5238,10 +5430,18 @@ function coordinateDebugRegions(element, context) {
5238
5430
  // src/plugins/coordinate/native.ts
5239
5431
  var coordinateNativePlugin = defineNativePlugin(
5240
5432
  "coordinate",
5241
- "0.1.15",
5433
+ "0.1.16",
5242
5434
  printDesign.definePrintDesignPluginRenderer({
5243
5435
  type: "coordinate",
5244
5436
  validate: validateCoordinateElement,
5437
+ commands: {
5438
+ execute: (element, command, payload) => executeGridCommand(
5439
+ element,
5440
+ command,
5441
+ payload,
5442
+ validateCoordinateElement
5443
+ )
5444
+ },
5245
5445
  validateTemplateData: validateGridTemplateData,
5246
5446
  bindingInfo: getGridBindingInfo,
5247
5447
  drawCanvas: drawCoordinateElement,
@@ -5738,17 +5938,48 @@ function validateFlowTemplateData(element, data) {
5738
5938
  return [];
5739
5939
  }
5740
5940
 
5941
+ // src/plugins/flow/interaction/commands.ts
5942
+ var flowCommands = {
5943
+ execute(element, command, payload) {
5944
+ if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
5945
+ return;
5946
+ const args = payload;
5947
+ const index = args.index;
5948
+ if (!Number.isInteger(index)) return;
5949
+ const at = index;
5950
+ if (command === "remove-item") {
5951
+ if (at < 0 || at >= element.items.length) return;
5952
+ return { ...element, items: element.items.filter((_, i) => i !== at) };
5953
+ }
5954
+ const item = args.item;
5955
+ if (!item || typeof item !== "object" || Array.isArray(item)) return;
5956
+ const items = [...element.items];
5957
+ if (command === "insert-item") {
5958
+ if (at < 0 || at > items.length) return;
5959
+ items.splice(at, 0, item);
5960
+ } else if (command === "update-item") {
5961
+ if (at < 0 || at >= items.length) return;
5962
+ items[at] = { ...items[at], ...item };
5963
+ } else return;
5964
+ const next = { ...element, items };
5965
+ return validateFlowElement(next) ? next : void 0;
5966
+ }
5967
+ };
5968
+
5741
5969
  // src/plugins/flow/native.ts
5742
5970
  var flowNativePlugin = defineNativePlugin(
5743
5971
  "flow",
5744
- "0.1.6",
5972
+ "0.1.7",
5745
5973
  printDesign.definePrintDesignPluginRenderer({
5746
5974
  type: "flow",
5747
5975
  validate: validateFlowElement,
5976
+ commands: flowCommands,
5748
5977
  validateTemplateData: validateFlowTemplateData,
5749
5978
  bindingInfo: (element) => ({
5750
5979
  bound: (element.dataMode ?? element.dataConfig?.mode) === "binding",
5751
- paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [element.dataPath ?? element.dataConfig?.bindings?.items ?? ""].filter(Boolean) : []
5980
+ paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [
5981
+ element.dataPath ?? element.dataConfig?.bindings?.items ?? ""
5982
+ ].filter(Boolean) : []
5752
5983
  }),
5753
5984
  drawCanvas: drawFlowElement,
5754
5985
  renderHtml: (element, context) => renderFlowHtml(element, context.data)
@@ -6464,6 +6695,19 @@ function fitImageToPage(image, page, current2) {
6464
6695
  return { x, y, width, height };
6465
6696
  }
6466
6697
 
6698
+ // src/plugins/image/interaction/commands.ts
6699
+ var imageCommands = {
6700
+ execute(element, command, payload) {
6701
+ if (element.locked) return;
6702
+ if (command === "clear-crop") return { ...element, crop: void 0 };
6703
+ if (command !== "set-crop" || !payload || typeof payload !== "object")
6704
+ return;
6705
+ const crop = payload;
6706
+ const next = { ...element, crop };
6707
+ return validateImageElement(next) ? next : void 0;
6708
+ }
6709
+ };
6710
+
6467
6711
  // src/plugins/image/native.ts
6468
6712
  var componentCropBehavior = {
6469
6713
  source: (element) => element.src,
@@ -6484,7 +6728,7 @@ var componentCropBehavior = {
6484
6728
  };
6485
6729
  var imageNativePlugin = defineNativePlugin(
6486
6730
  "image",
6487
- "0.1.16",
6731
+ "0.1.17",
6488
6732
  printDesign.definePrintDesignPluginRenderer({
6489
6733
  type: "image",
6490
6734
  dataFields: imageDataFields,
@@ -6493,6 +6737,7 @@ var imageNativePlugin = defineNativePlugin(
6493
6737
  replaceResourceUri: (element, uri, replacement) => element.src === uri ? { ...element, src: replacement } : element,
6494
6738
  validateTemplateData: validateImageTemplateData,
6495
6739
  validate: validateImageElement,
6740
+ commands: imageCommands,
6496
6741
  drawCanvas: drawImageElement,
6497
6742
  prepareCanvas: (element, { signal }) => prepareImage(element.src, signal),
6498
6743
  needsCanvasPreparation: (element) => Boolean(element.src && !getLoadedImageSize(element.src)),
@@ -6909,13 +7154,58 @@ function renderChartHtml(element, data) {
6909
7154
  });
6910
7155
  }
6911
7156
 
7157
+ // src/plugins/chart/interaction/commands.ts
7158
+ var chartCommands = {
7159
+ execute(element, command, payload) {
7160
+ if (element.locked || !payload || typeof payload !== "object") return;
7161
+ const args = payload;
7162
+ const chartData = readChartData(element);
7163
+ if (command === "set-categories") {
7164
+ if (!Array.isArray(args.categories) || !args.categories.every((item) => typeof item === "string"))
7165
+ return;
7166
+ const categories = args.categories;
7167
+ const next2 = {
7168
+ ...element,
7169
+ chartData: {
7170
+ ...chartData,
7171
+ categories,
7172
+ series: chartData.series.map((series2) => ({
7173
+ ...series2,
7174
+ values: categories.map((_, index2) => series2.values[index2] ?? 0)
7175
+ }))
7176
+ }
7177
+ };
7178
+ return validateChartElement(next2) ? next2 : void 0;
7179
+ }
7180
+ if (command !== "set-series") return;
7181
+ const index = args.index;
7182
+ if (!Number.isInteger(index) || index < 0 || index > chartData.series.length)
7183
+ return;
7184
+ if (typeof args.name !== "string" || !Array.isArray(args.values) || args.values.length !== chartData.categories.length || !args.values.every(
7185
+ (value) => typeof value === "number" && Number.isFinite(value)
7186
+ ))
7187
+ return;
7188
+ if (["pie", "gauge"].includes(element.chartType) && index > 0)
7189
+ return;
7190
+ const series = [...chartData.series];
7191
+ series[index] = {
7192
+ name: args.name,
7193
+ values: args.values,
7194
+ ...typeof args.field === "string" ? { field: args.field } : {}
7195
+ };
7196
+ const next = { ...element, chartData: { ...chartData, series } };
7197
+ return validateChartElement(next) ? next : void 0;
7198
+ }
7199
+ };
7200
+
6912
7201
  // src/plugins/chart/native.ts
6913
7202
  var chartNativePlugin = defineNativePlugin(
6914
7203
  "chart",
6915
- "0.1.8",
7204
+ "0.1.9",
6916
7205
  printDesign.definePrintDesignPluginRenderer({
6917
7206
  type: "chart",
6918
7207
  validate: validateChartElement,
7208
+ commands: chartCommands,
6919
7209
  validateTemplateData: validateChartTemplateData,
6920
7210
  bindingInfo: (element) => ({
6921
7211
  bound: element.chartData?.mode === "binding",
@@ -10760,7 +11050,7 @@ function validateTableTemplateData(element, data) {
10760
11050
  // src/plugins/table/native.ts
10761
11051
  var tableNativePlugin = defineNativePlugin(
10762
11052
  "table",
10763
- "0.1.68",
11053
+ "0.1.69",
10764
11054
  printDesign.definePrintDesignPluginRenderer({
10765
11055
  type: "table",
10766
11056
  validate: validateTableElement,
@@ -11093,6 +11383,41 @@ var pivotTableBoundaryResize = {
11093
11383
  }
11094
11384
  };
11095
11385
 
11386
+ // src/plugins/pivot-table/interaction/commands.ts
11387
+ var areas = ["filter", "column", "row", "value"];
11388
+ var pivotTableCommands = {
11389
+ execute(element, command, payload) {
11390
+ if (element.locked || !payload || typeof payload !== "object") return;
11391
+ const args = payload;
11392
+ const fieldKey = args.fieldKey;
11393
+ if (typeof fieldKey !== "string" || !element.fields.some((field) => field.key === fieldKey))
11394
+ return;
11395
+ if (command === "remove-field")
11396
+ return {
11397
+ ...element,
11398
+ layout: removePivotField(element.layout, fieldKey)
11399
+ };
11400
+ if (command !== "move-field" || !areas.includes(args.area))
11401
+ return;
11402
+ const index = args.index;
11403
+ if (index !== void 0 && (!Number.isInteger(index) || index < 0))
11404
+ return;
11405
+ const sourceArea = args.sourceArea;
11406
+ if (sourceArea !== void 0 && !areas.includes(sourceArea))
11407
+ return;
11408
+ return {
11409
+ ...element,
11410
+ layout: movePivotField(
11411
+ element.layout,
11412
+ fieldKey,
11413
+ args.area,
11414
+ index,
11415
+ sourceArea
11416
+ )
11417
+ };
11418
+ }
11419
+ };
11420
+
11096
11421
  // src/plugins/pivot-table/model.ts
11097
11422
  function validatePivotTableElement(value) {
11098
11423
  if (!value || typeof value !== "object") return false;
@@ -11106,11 +11431,12 @@ function validatePivotTableElement(value) {
11106
11431
  // src/plugins/pivot-table/native.ts
11107
11432
  var pivotTableNativePlugin = defineNativePlugin(
11108
11433
  "pivotTable",
11109
- "0.1.18",
11434
+ "0.1.19",
11110
11435
  printDesign.definePrintDesignPluginRenderer({
11111
11436
  type: "pivotTable",
11112
11437
  htmlCss: tableHtmlCss,
11113
11438
  validate: validatePivotTableElement,
11439
+ commands: pivotTableCommands,
11114
11440
  validateTemplateData: validatePivotTemplateData,
11115
11441
  bindingInfo: (element) => ({
11116
11442
  bound: element.dataMode === "binding",
@@ -11621,13 +11947,49 @@ function ganttMarkup(element, data, pageNumber) {
11621
11947
  return `<svg class="pd-media" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none"><rect width="${width}" height="${height}" fill="${printDesign.cssColor(theme.backgroundColor, "transparent")}"/>${header > 0 ? `<rect width="${width}" height="${header}" fill="${printDesign.cssColor(theme.headerBackgroundColor, "transparent")}"/>` : ""}${ticks}${taskSplit}${headerEdges}${headerTitle}${maskedDependencies}${bars}${frame}</svg>`;
11622
11948
  }
11623
11949
 
11950
+ // src/plugins/gantt/interaction/commands.ts
11951
+ var ganttCommands = {
11952
+ execute(element, command, payload) {
11953
+ if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
11954
+ return;
11955
+ const args = payload;
11956
+ const tasks = [...element.tasks];
11957
+ if (command === "insert-task") {
11958
+ const index = args.index;
11959
+ if (!Number.isInteger(index) || index < 0 || index > tasks.length)
11960
+ return;
11961
+ if (!args.task || typeof args.task !== "object" || Array.isArray(args.task))
11962
+ return;
11963
+ const task = args.task;
11964
+ if (tasks.some((existing) => existing.id === task.id)) return;
11965
+ tasks.splice(index, 0, task);
11966
+ } else {
11967
+ const taskId = args.taskId;
11968
+ if (typeof taskId !== "string") return;
11969
+ const index = tasks.findIndex((task) => task.id === taskId);
11970
+ if (index < 0) return;
11971
+ if (command === "remove-task") tasks.splice(index, 1);
11972
+ else if (command === "update-task") {
11973
+ if (!args.patch || typeof args.patch !== "object" || Array.isArray(args.patch))
11974
+ return;
11975
+ const patch = args.patch;
11976
+ if (patch.id !== void 0 || patch.tasks !== void 0) return;
11977
+ tasks[index] = { ...tasks[index], ...patch };
11978
+ } else return;
11979
+ }
11980
+ const next = { ...element, tasks };
11981
+ return validateGanttElement(next) ? next : void 0;
11982
+ }
11983
+ };
11984
+
11624
11985
  // src/plugins/gantt/native.ts
11625
11986
  var ganttNativePlugin = defineNativePlugin(
11626
11987
  "gantt",
11627
- "0.1.6",
11988
+ "0.1.7",
11628
11989
  printDesign.definePrintDesignPluginRenderer({
11629
11990
  type: "gantt",
11630
11991
  validate: validateGanttElement,
11992
+ commands: ganttCommands,
11631
11993
  validateTemplateData: validateGanttTemplateData,
11632
11994
  bindingInfo: (element) => ({
11633
11995
  bound: element.dataMode === "binding",
@@ -11948,6 +12310,20 @@ var textPlugin = defineBuiltinReactPlugin(textNativePlugin, {
11948
12310
  var listFactory = {
11949
12311
  type: "list",
11950
12312
  label: "\u5217\u8868",
12313
+ agentCommands: [
12314
+ {
12315
+ name: "insert-item",
12316
+ description: "\u5728\u5217\u8868\u6307\u5B9A\u4F4D\u7F6E\u63D2\u5165\u9879\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, text: \u9879\u6587\u5B57 }\u3002"
12317
+ },
12318
+ {
12319
+ name: "update-item",
12320
+ description: "\u4FEE\u6539\u5217\u8868\u9879\u3002payload: { index: 0 \u8D77\u59CB\u9879\u4F4D\u7F6E, text?: \u9879\u6587\u5B57, checked?: \u662F\u5426\u9009\u4E2D }\u3002"
12321
+ },
12322
+ {
12323
+ name: "remove-item",
12324
+ description: "\u79FB\u9664\u5217\u8868\u9879\u3002payload: { index: 0 \u8D77\u59CB\u9879\u4F4D\u7F6E }\u3002"
12325
+ }
12326
+ ],
11951
12327
  showDataPanel: false,
11952
12328
  tourFields: () => [],
11953
12329
  acceptsPreset: (preset) => ["ordered", "unordered", "radio", "checkbox"].includes(preset),
@@ -12395,6 +12771,20 @@ var watermarkPlugin = defineBuiltinReactPlugin(watermarkNativePlugin, {
12395
12771
  var shapeFactory = {
12396
12772
  type: "shape",
12397
12773
  label: "\u56FE\u5F62",
12774
+ agentCommands: [
12775
+ {
12776
+ name: "set-polygon-points",
12777
+ description: "\u8BBE\u7F6E\u4E09\u89D2\u5F62\u3001\u591A\u8FB9\u5F62\u6216\u661F\u5F62\u9876\u70B9\u3002payload: { points: \u81F3\u5C11 3 \u4E2A { x, y } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
12778
+ },
12779
+ {
12780
+ name: "set-curve-points",
12781
+ description: "\u8BBE\u7F6E\u4E8C\u6B21\u3001\u4E09\u6B21\u6216\u591A\u6BB5\u66F2\u7EBF\u63A7\u5236\u70B9\u3002payload: { points: \u81F3\u5C11 2 \u4E2A { x, y } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
12782
+ },
12783
+ {
12784
+ name: "set-path-points",
12785
+ description: "\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u8DEF\u5F84\u8282\u70B9\u3002payload: { points: { x, y } \u5F52\u4E00\u5316\u5750\u6807\u6570\u7EC4, closed?: \u662F\u5426\u95ED\u5408 }\u3002"
12786
+ }
12787
+ ],
12398
12788
  acceptsPreset: (preset) => [
12399
12789
  "triangle",
12400
12790
  "rect",
@@ -12951,6 +13341,16 @@ function BrushToolbarButton({
12951
13341
  var brushFactory = {
12952
13342
  type: "brush",
12953
13343
  label: "\u753B\u7B14",
13344
+ agentCommands: [
13345
+ {
13346
+ name: "append-stroke",
13347
+ description: "\u8FFD\u52A0\u4E00\u7B14\u3002payload: { points: \u81F3\u5C11\u4E24\u4E2A { x, y, pressure?: 0 \u5230 1 } \u5F52\u4E00\u5316\u5750\u6807 }\u3002"
13348
+ },
13349
+ {
13350
+ name: "remove-stroke",
13351
+ description: "\u5220\u9664\u6307\u5B9A\u7B14\u753B\u5E76\u540C\u6B65\u5BF9\u5E94\u6837\u5F0F\u3002payload: { index: 0 \u8D77\u59CB\u7B14\u753B\u4F4D\u7F6E }\u3002"
13352
+ }
13353
+ ],
12954
13354
  showDataPanel: false,
12955
13355
  tourFields: () => [],
12956
13356
  create: createBrushElement,
@@ -13050,6 +13450,16 @@ var brushPlugin = defineBuiltinReactPlugin(brushNativePlugin, {
13050
13450
  var connectorFactory = {
13051
13451
  type: "connector",
13052
13452
  label: "\u8FDE\u63A5\u7EBF",
13453
+ agentCommands: [
13454
+ {
13455
+ name: "set-endpoint",
13456
+ description: "\u5C06\u8FDE\u63A5\u7EBF\u8D77\u70B9\u6216\u7EC8\u70B9\u8FDE\u63A5\u5230\u5DF2\u6709\u5143\u7D20\u3002payload: { side: start|end, endpoint: { elementId?: \u76EE\u6807\u5143\u7D20 ID, anchor?: auto|top|right|bottom|left|top-left|top-right|bottom-right|bottom-left|edge:\u7D22\u5F15|vertex:\u7D22\u5F15 } }\u3002"
13457
+ },
13458
+ {
13459
+ name: "set-waypoints",
13460
+ description: "\u8BBE\u7F6E\u6298\u7EBF\u4E2D\u95F4\u8DEF\u5F84\u70B9\uFF0C\u4EC5\u9002\u7528\u4E8E lineType=polyline\u3002payload: { points: \u9875\u9762\u6BEB\u7C73\u5750\u6807\u6570\u7EC4 [{ x, y }] }\u3002"
13461
+ }
13462
+ ],
13053
13463
  create: (preset = "bar") => {
13054
13464
  const common = createCommonElementDefaults();
13055
13465
  const type = "connector";
@@ -13407,6 +13817,16 @@ var rulerPlugin = defineBuiltinReactPlugin(rulerNativePlugin, {
13407
13817
  var gridFactory = {
13408
13818
  type: "grid",
13409
13819
  label: "\u7F51\u683C",
13820
+ agentCommands: [
13821
+ {
13822
+ name: "resize-grid",
13823
+ description: "\u8C03\u6574\u7F51\u683C\u884C\u5217\u6570\uFF0C\u4FDD\u7559\u91CD\u53E0\u533A\u57DF\u7684\u5355\u5143\u683C\u3002payload: { rows: 1 \u5230 50 \u7684\u6574\u6570, columns: 1 \u5230 50 \u7684\u6574\u6570 }\u3002"
13824
+ },
13825
+ {
13826
+ name: "set-cell",
13827
+ description: "\u66F4\u65B0\u6307\u5B9A\u7F51\u683C\u5355\u5143\u683C\u3002payload: { rowIndex: 0 \u8D77\u59CB\u884C, columnIndex: 0 \u8D77\u59CB\u5217, cell: { content?: none|x|*, contentMode?: static|binding, contentPath?: \u5B57\u7B26\u4E32, backgroundColor?: \u5B57\u7B26\u4E32 } }\u3002"
13828
+ }
13829
+ ],
13410
13830
  showDataPanel: false,
13411
13831
  tourFields: (element) => element.type === "grid" ? [
13412
13832
  { key: "rows", label: "\u884C\u6570", value: element.rows },
@@ -13649,6 +14069,16 @@ var gridPlugin = defineBuiltinReactPlugin(gridNativePlugin, {
13649
14069
  var coordinateFactory = {
13650
14070
  type: "coordinate",
13651
14071
  label: "\u5750\u6807\u7F51\u683C",
14072
+ agentCommands: [
14073
+ {
14074
+ name: "resize-grid",
14075
+ description: "\u8C03\u6574\u5750\u6807\u7F51\u683C\u884C\u5217\u6570\uFF0C\u4FDD\u7559\u91CD\u53E0\u533A\u57DF\u5355\u5143\u683C\u3002payload: { rows: 1 \u5230 50 \u7684\u6574\u6570, columns: 1 \u5230 50 \u7684\u6574\u6570 }\u3002"
14076
+ },
14077
+ {
14078
+ name: "set-cell",
14079
+ description: "\u66F4\u65B0\u5750\u6807\u7F51\u683C\u5355\u5143\u683C\u3002payload: { rowIndex: 0 \u8D77\u59CB\u884C, columnIndex: 0 \u8D77\u59CB\u5217, cell: { content?: none|x|*, contentMode?: static|binding, contentPath?: \u5B57\u7B26\u4E32, backgroundColor?: \u5B57\u7B26\u4E32 } }\u3002"
14080
+ }
14081
+ ],
13652
14082
  showDataPanel: false,
13653
14083
  tourFields: (element) => element.type === "coordinate" ? [
13654
14084
  { key: "rows", label: "\u884C\u6570", value: element.rows },
@@ -14019,6 +14449,20 @@ var progressPlugin = defineBuiltinReactPlugin(progressNativePlugin, {
14019
14449
  var flowFactory = {
14020
14450
  type: "flow",
14021
14451
  label: "\u6D41\u7A0B\u56FE",
14452
+ agentCommands: [
14453
+ {
14454
+ name: "insert-item",
14455
+ description: "\u5728\u9759\u6001\u6D41\u7A0B\u6307\u5B9A\u4F4D\u7F6E\u63D2\u5165\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, item: { content: \u5B57\u7B26\u4E32, title?: \u5B57\u7B26\u4E32, color?: \u5B57\u7B26\u4E32, position?: start|end, loading?: \u5E03\u5C14\u503C, icon?: circle|check|clock|cross } }\u3002"
14456
+ },
14457
+ {
14458
+ name: "update-item",
14459
+ description: "\u4FEE\u6539\u9759\u6001\u6D41\u7A0B\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u8282\u70B9\u4F4D\u7F6E, item: \u9700\u4FEE\u6539\u7684\u8282\u70B9\u5B57\u6BB5 }\u3002"
14460
+ },
14461
+ {
14462
+ name: "remove-item",
14463
+ description: "\u79FB\u9664\u9759\u6001\u6D41\u7A0B\u8282\u70B9\u3002payload: { index: 0 \u8D77\u59CB\u8282\u70B9\u4F4D\u7F6E }\u3002"
14464
+ }
14465
+ ],
14022
14466
  showDataPanel: false,
14023
14467
  tourFields: () => [],
14024
14468
  create: (preset = "bar") => {
@@ -14401,6 +14845,16 @@ function placeExternalImage(image, point, page, index = 0) {
14401
14845
  var imageFactory = {
14402
14846
  type: "image",
14403
14847
  label: "\u56FE\u7247",
14848
+ agentCommands: [
14849
+ {
14850
+ name: "set-crop",
14851
+ description: "\u8BBE\u7F6E\u56FE\u7247\u88C1\u526A\u533A\u57DF\u3002payload: { x, y, width, height }\uFF0C\u5747\u4E3A\u539F\u56FE\u5BBD\u9AD8\u7684 0 \u5230 1 \u6BD4\u4F8B\uFF0C\u533A\u57DF\u5FC5\u987B\u5728\u539F\u56FE\u5185\uFF1B\u53EF\u9009 sourceWidth\u3001sourceHeight \u4E3A\u539F\u56FE\u50CF\u7D20\u5C3A\u5BF8\u3002"
14852
+ },
14853
+ {
14854
+ name: "clear-crop",
14855
+ description: "\u79FB\u9664\u56FE\u7247\u88C1\u526A\uFF0C\u663E\u793A\u5B8C\u6574\u56FE\u7247\uFF1Bpayload \u4F20\u7A7A\u5BF9\u8C61\u3002"
14856
+ }
14857
+ ],
14404
14858
  dataFields: imageDataFields,
14405
14859
  staticFieldPatch: (_element, key, value) => key === "src" ? { src: String(value), crop: void 0 } : { [key]: value },
14406
14860
  externalDrop: {
@@ -14841,6 +15295,16 @@ function createChartPreset(id) {
14841
15295
  var chartFactory = {
14842
15296
  type: "chart",
14843
15297
  label: "\u56FE\u8868",
15298
+ agentCommands: [
15299
+ {
15300
+ name: "set-categories",
15301
+ description: "\u8BBE\u7F6E\u56FE\u8868\u9759\u6001\u5206\u7C7B\u6216\u9ED8\u8BA4\u5206\u7C7B\uFF0C\u5E76\u4F7F\u5404\u7CFB\u5217\u6570\u503C\u957F\u5EA6\u5339\u914D\u3002payload: { categories: \u5B57\u7B26\u4E32\u6570\u7EC4 }\u3002"
15302
+ },
15303
+ {
15304
+ name: "set-series",
15305
+ description: "\u66F4\u65B0\u6307\u5B9A\u6570\u503C\u7CFB\u5217\uFF0C\u4E5F\u53EF\u5728\u672B\u5C3E\u65B0\u589E\u3002payload: { index: 0 \u8D77\u59CB\u7CFB\u5217\u4F4D\u7F6E, name: \u7CFB\u5217\u540D\u79F0, values: \u4E0E categories \u7B49\u957F\u7684\u6709\u9650\u6570\u5B57\u6570\u7EC4, field?: \u7ED1\u5B9A\u5B57\u6BB5\u8DEF\u5F84 }\uFF1B\u997C\u56FE\u548C\u4EEA\u8868\u76D8\u4EC5\u652F\u6301\u7D22\u5F15 0\u3002"
15306
+ }
15307
+ ],
14844
15308
  showDataPanel: false,
14845
15309
  acceptsPreset: (preset) => chartPresets.some((item) => item.id === preset),
14846
15310
  create: (preset = "bar") => {
@@ -15126,6 +15590,24 @@ var chartPlugin = defineBuiltinReactPlugin(chartNativePlugin, {
15126
15590
  var tableFactory = {
15127
15591
  type: "table",
15128
15592
  label: "\u8868\u683C",
15593
+ agentCommands: [
15594
+ {
15595
+ 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"
15597
+ },
15598
+ {
15599
+ name: "insert-column",
15600
+ description: "\u5728 columnIndex \u5217\u524D\u63D2\u5165\u5217\uFF1Bafter=true \u65F6\u63D2\u5728\u5217\u540E\u3002"
15601
+ },
15602
+ {
15603
+ name: "merge-body",
15604
+ description: "\u5408\u5E76\u8868\u4F53\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002"
15605
+ },
15606
+ {
15607
+ name: "merge-header",
15608
+ description: "\u5408\u5E76\u8868\u5934\u5355\u5143\u683C\uFF1B\u4F20 rowIndex\u3001columnIndex\u3001rowSpan\u3001colSpan\u3002"
15609
+ }
15610
+ ],
15129
15611
  defaultOverflowPolicy: "split",
15130
15612
  showDataPanel: false,
15131
15613
  tourFields: (element) => {
@@ -19273,6 +19755,16 @@ var tablePlugin = defineBuiltinReactPlugin(tableNativePlugin, {
19273
19755
  var pivotTableFactory = {
19274
19756
  type: "pivotTable",
19275
19757
  label: "\u900F\u89C6\u8868",
19758
+ agentCommands: [
19759
+ {
19760
+ name: "move-field",
19761
+ description: "\u79FB\u52A8\u900F\u89C6\u5B57\u6BB5\u3002payload: { fieldKey: \u5DF2\u6709\u5B57\u6BB5 key, area: filter|column|row|value, index?: \u4ECE 0 \u5F00\u59CB\u7684\u76EE\u6807\u4F4D\u7F6E, sourceArea?: \u539F\u533A\u57DF }\u3002"
19762
+ },
19763
+ {
19764
+ name: "remove-field",
19765
+ description: "\u4ECE\u900F\u89C6\u5E03\u5C40\u7684\u6240\u6709\u533A\u57DF\u79FB\u9664\u5B57\u6BB5\uFF0C\u4E0D\u5220\u9664\u5B57\u6BB5\u5B9A\u4E49\u3002payload: { fieldKey: \u5DF2\u6709\u5B57\u6BB5 key }\u3002"
19766
+ }
19767
+ ],
19276
19768
  defaultOverflowPolicy: "split",
19277
19769
  showDataPanel: false,
19278
19770
  tourFields: (element) => {
@@ -20044,6 +20536,20 @@ var pivotTablePlugin = defineBuiltinReactPlugin(
20044
20536
  var ganttFactory = {
20045
20537
  type: "gantt",
20046
20538
  label: "\u7518\u7279\u56FE",
20539
+ agentCommands: [
20540
+ {
20541
+ name: "insert-task",
20542
+ description: "\u5728\u9759\u6001\u7518\u7279\u56FE\u9876\u5C42\u4EFB\u52A1\u5217\u8868\u63D2\u5165\u4EFB\u52A1\u3002payload: { index: 0 \u8D77\u59CB\u63D2\u5165\u4F4D\u7F6E, task: { id: \u552F\u4E00\u5B57\u7B26\u4E32, title: \u5B57\u7B26\u4E32, start?: \u65E5\u671F, end?: \u65E5\u671F, progress?: 0 \u5230 100, ... } }\u3002"
20543
+ },
20544
+ {
20545
+ name: "update-task",
20546
+ description: "\u4FEE\u6539\u9876\u5C42\u4EFB\u52A1\uFF0C\u4E0D\u80FD\u4FEE\u6539 id \u6216\u5D4C\u5957 tasks\u3002payload: { taskId: \u4EFB\u52A1 id, patch: { title?, start?, end?, progress?, color?, progressColor?, dependencies? } }\u3002"
20547
+ },
20548
+ {
20549
+ name: "remove-task",
20550
+ description: "\u79FB\u9664\u9759\u6001\u7518\u7279\u56FE\u9876\u5C42\u4EFB\u52A1\u3002payload: { taskId: \u4EFB\u52A1 id }\u3002"
20551
+ }
20552
+ ],
20047
20553
  showDataPanel: false,
20048
20554
  tourFields: (element) => {
20049
20555
  if (element.type !== "gantt") return [];