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