@canvas-components/print-design 0.1.3 → 0.1.5

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.
Files changed (3) hide show
  1. package/dist/index.cjs +119 -29
  2. package/dist/index.js +119 -29
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1209,11 +1209,12 @@ function resolveTableCells(element, rows, columns) {
1209
1209
  (cell) => ((cell.rowSpan ?? 1) > 1 || (cell.colSpan ?? 1) > 1) && row < cell.rowIndex + Math.max(1, cell.rowSpan ?? 1) && row + rowSpan > cell.rowIndex && column < cell.columnIndex + Math.max(1, cell.colSpan ?? 1) && column + colSpan > cell.columnIndex
1210
1210
  );
1211
1211
  const rowRule = rule.row;
1212
- if (rowRule?.keys?.length) {
1213
- const targets = rowRule.columns?.length ? rowRule.columns : rowRule.keys;
1214
- const groupKey = (row) => JSON.stringify(
1215
- rowRule.keys.map((key) => valueKey(readTableCell(row, key)))
1216
- );
1212
+ const hasPath = (path) => Array.isArray(path) ? path.length > 0 : String(path ?? "").trim().length > 0;
1213
+ const rowKeys = rowRule?.keys.filter(hasPath) ?? [];
1214
+ if (rowKeys.length) {
1215
+ const rowColumns = rowRule?.columns?.filter(hasPath) ?? [];
1216
+ const targets = rowColumns.length ? rowColumns : rowKeys;
1217
+ const groupKey = (row) => JSON.stringify(rowKeys.map((key) => valueKey(readTableCell(row, key))));
1217
1218
  for (const [columnIndex, column] of columns.entries()) {
1218
1219
  if (!targets.some((key) => samePath(column.dataIndex, key))) continue;
1219
1220
  let rowIndex = 0;
@@ -1240,12 +1241,13 @@ function resolveTableCells(element, rows, columns) {
1240
1241
  }
1241
1242
  }
1242
1243
  const columnRule = rule.column;
1243
- if (columnRule?.keys?.length) {
1244
+ const columnKeys = columnRule?.keys.filter(hasPath) ?? [];
1245
+ if (columnKeys.length) {
1244
1246
  for (const [rowIndex, row] of rows.entries()) {
1245
1247
  let columnIndex = 0;
1246
1248
  while (columnIndex < columns.length) {
1247
1249
  const column = columns[columnIndex];
1248
- if (!columnRule.keys.some((key) => samePath(column.dataIndex, key)) || overlaps(rowIndex, columnIndex, 1, 1)) {
1250
+ if (!columnKeys.some((key) => samePath(column.dataIndex, key)) || overlaps(rowIndex, columnIndex, 1, 1)) {
1249
1251
  columnIndex++;
1250
1252
  continue;
1251
1253
  }
@@ -1254,7 +1256,7 @@ function resolveTableCells(element, rows, columns) {
1254
1256
  while (columnIndex + colSpan < columns.length) {
1255
1257
  const nextIndex = columnIndex + colSpan;
1256
1258
  const next = columns[nextIndex];
1257
- if (!columnRule.keys.some((key) => samePath(next.dataIndex, key)) || valueKey(readTableCell(row, next.dataIndex)) !== current || overlaps(rowIndex, nextIndex, 1, 1))
1259
+ if (!columnKeys.some((key) => samePath(next.dataIndex, key)) || valueKey(readTableCell(row, next.dataIndex)) !== current || overlaps(rowIndex, nextIndex, 1, 1))
1258
1260
  break;
1259
1261
  colSpan++;
1260
1262
  }
@@ -6315,9 +6317,11 @@ function materializePackedReport(document, data) {
6315
6317
  const table = source.elements.find(
6316
6318
  (element) => element.type === "table" && !!element.packedReport
6317
6319
  );
6318
- if (!table?.packedReport || !table.dataPath) return [source];
6319
- const input = resolveTableDataSource(data, table.dataPath);
6320
- if (!Array.isArray(input) && table.fallbackToStatic) return [source];
6320
+ if (!table?.packedReport) return [source];
6321
+ if (table.dataMode === "binding" && !table.dataPath) return [source];
6322
+ const input = table.dataMode === "binding" ? resolveTableDataSource(data, table.dataPath) : table.dataSource;
6323
+ if (table.dataMode === "binding" && !Array.isArray(input) && table.fallbackToStatic)
6324
+ return [source];
6321
6325
  const records = (Array.isArray(input) ? input : []).filter(
6322
6326
  (item) => !!item && typeof item === "object" && !Array.isArray(item)
6323
6327
  );
@@ -7762,6 +7766,26 @@ function hitTableColumnBoundary(element, point, scale, _document) {
7762
7766
  -(element.rotation ?? 0) * Math.PI / 180
7763
7767
  );
7764
7768
  if (local.y < element.y || local.y > element.y + element.height) return;
7769
+ const { widths, regions } = tableColumnResizeLayout(element, scale);
7770
+ let nearest;
7771
+ let distance2 = 5;
7772
+ for (const region of regions) {
7773
+ if (local.y < region.y || local.y >= region.y + region.height) continue;
7774
+ const edgeDistance = Math.abs(local.x - region.edge) * scale;
7775
+ if (edgeDistance <= distance2) {
7776
+ distance2 = edgeDistance;
7777
+ nearest = {
7778
+ elementId: element.id,
7779
+ boundary: region.boundary,
7780
+ widths,
7781
+ columns: element.columns,
7782
+ rotation: element.rotation ?? 0
7783
+ };
7784
+ }
7785
+ }
7786
+ return nearest;
7787
+ }
7788
+ function tableColumnResizeLayout(element, scale) {
7765
7789
  const columns = tableLeafColumns(
7766
7790
  element.columns.filter((column) => !column.hidden)
7767
7791
  ).filter((column) => !column.hidden);
@@ -7770,19 +7794,39 @@ function hitTableColumnBoundary(element, point, scale, _document) {
7770
7794
  const widths = weights.map(
7771
7795
  (value) => element.width * 96 / 25.4 * value / total
7772
7796
  );
7797
+ const regions = [];
7798
+ if (element.locked || element.visible === false || element.groupPath?.length)
7799
+ return { widths, regions };
7800
+ const rowHeight = element.headerRowHeight ?? 9;
7801
+ const depth = element.showHeader === false ? 0 : tableHeaderDepth(element.columns);
7802
+ const headers = tableHeaderCells(element);
7773
7803
  let offset = 0;
7774
- for (let i = 0; i < widths.length - 1; i++) {
7775
- offset += widths[i];
7776
- const edge = offset * 25.4 / 96;
7777
- if (Math.abs(local.x - element.x - edge) * scale <= 5)
7778
- return {
7779
- elementId: element.id,
7780
- boundary: i,
7781
- widths,
7782
- columns: element.columns,
7783
- rotation: element.rotation ?? 0
7784
- };
7804
+ for (let boundary = 0; boundary < widths.length - 1; boundary++) {
7805
+ offset += widths[boundary] * 25.4 / 96;
7806
+ const edge = element.x + offset;
7807
+ const add = (top, bottom, header) => {
7808
+ bottom = Math.min(bottom, element.height);
7809
+ if (bottom <= top) return;
7810
+ regions.push({
7811
+ boundary,
7812
+ edge,
7813
+ x: edge - 5 / scale,
7814
+ y: element.y + top,
7815
+ width: 10 / scale,
7816
+ height: bottom - top,
7817
+ header
7818
+ });
7819
+ };
7820
+ for (let row = 0; row < depth; row++) {
7821
+ if (headers.some(
7822
+ (cell) => row >= cell.rowIndex && row < cell.rowIndex + cell.rowSpan && (cell.columnIndex === boundary + 1 || cell.columnIndex + cell.colSpan === boundary + 1)
7823
+ )) {
7824
+ add(row * rowHeight, (row + 1) * rowHeight, true);
7825
+ }
7826
+ }
7827
+ add(depth * rowHeight, element.height, false);
7785
7828
  }
7829
+ return { widths, regions };
7786
7830
  }
7787
7831
  function resizeTableColumns(session, dx, dy) {
7788
7832
  const angle = session.rotation * Math.PI / 180;
@@ -9002,7 +9046,8 @@ function drawPrintDesignDebugOverlay(params) {
9002
9046
  table,
9003
9047
  params.scale,
9004
9048
  params.data,
9005
- element.type === "table" && params.showTableSelectors !== false && params.selectedIds.length === 1 && params.selectedIds[0] === element.id
9049
+ element.type === "table" && params.showTableSelectors !== false && params.selectedIds.length === 1 && params.selectedIds[0] === element.id,
9050
+ options.showHitTarget ? pointer : null
9006
9051
  );
9007
9052
  }
9008
9053
  });
@@ -9032,7 +9077,7 @@ function drawPrintDesignDebugOverlay(params) {
9032
9077
  }
9033
9078
  context.restore();
9034
9079
  }
9035
- function drawTableDebugBounds(context, table, scale, data = {}, showSelectors = false) {
9080
+ function drawTableDebugBounds(context, table, scale, data = {}, showSelectors = false, pointer = null) {
9036
9081
  const bounds = getSelectionRect(table, scale, data);
9037
9082
  const centerX = (bounds.x + bounds.width / 2) * scale;
9038
9083
  const centerY = (bounds.y + bounds.height / 2) * scale;
@@ -9060,6 +9105,41 @@ function drawTableDebugBounds(context, table, scale, data = {}, showSelectors =
9060
9105
  selector.height * scale
9061
9106
  );
9062
9107
  }
9108
+ const hit = pointer ? hitTableColumnBoundary(table, pointer, scale) : void 0;
9109
+ context.setLineDash([]);
9110
+ for (const region of tableColumnResizeLayout(table, scale).regions) {
9111
+ if (!region.header) continue;
9112
+ const active = hit?.boundary === region.boundary;
9113
+ context.fillStyle = active ? "rgba(34,197,94,0.35)" : "rgba(236,72,153,0.18)";
9114
+ context.fillRect(
9115
+ region.x * scale,
9116
+ region.y * scale,
9117
+ region.width * scale,
9118
+ region.height * scale
9119
+ );
9120
+ context.strokeStyle = active ? "#16a34a" : "#ec4899";
9121
+ context.strokeRect(
9122
+ region.x * scale,
9123
+ region.y * scale,
9124
+ region.width * scale,
9125
+ region.height * scale
9126
+ );
9127
+ context.fillStyle = active ? "#16a34a" : "#db2777";
9128
+ context.fillRect(
9129
+ region.edge * scale - 0.5,
9130
+ region.y * scale,
9131
+ 1,
9132
+ region.height * scale
9133
+ );
9134
+ context.font = "10px sans-serif";
9135
+ context.textAlign = "left";
9136
+ context.textBaseline = "bottom";
9137
+ context.fillText(
9138
+ `\u5217 ${region.boundary + 1}/${region.boundary + 2} \xB15px${active ? " \u547D\u4E2D" : ""}`,
9139
+ region.edge * scale + 6,
9140
+ region.y * scale
9141
+ );
9142
+ }
9063
9143
  context.restore();
9064
9144
  }
9065
9145
  function drawElementBounds(context, element, scale, color2, data = {}) {
@@ -9484,7 +9564,7 @@ var PrintDesignRenderer = class extends PrintDesignTextEditing {
9484
9564
  }
9485
9565
  }
9486
9566
  const debugOptions = resolvePrintDesignDebugOptions(this.options.debug);
9487
- if (!preview && debugOptions.enabled) {
9567
+ if (debugOptions.enabled) {
9488
9568
  ctx.save();
9489
9569
  ctx.beginPath();
9490
9570
  ctx.rect(0, 0, pageWidth, pageHeight);
@@ -9492,7 +9572,7 @@ var PrintDesignRenderer = class extends PrintDesignTextEditing {
9492
9572
  drawPrintDesignDebugOverlay({
9493
9573
  context: ctx,
9494
9574
  page,
9495
- data: this.options.data,
9575
+ data: preview?.data ?? this.options.data,
9496
9576
  scale,
9497
9577
  options: debugOptions,
9498
9578
  pointer: this.debugPointer,
@@ -11065,8 +11145,11 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
11065
11145
  return;
11066
11146
  }
11067
11147
  if (this.options.preview && !session) {
11068
- const source = this.previewSourceAt(point, origin.scale);
11069
- this.canvas.style.cursor = source && !source.element.locked && !this.options.readonly ? "move" : "grab";
11148
+ this.updateCursor(event, point);
11149
+ if (resolvePrintDesignDebugOptions(this.options.debug).enabled) {
11150
+ this.debugPointer = point;
11151
+ this.render();
11152
+ }
11070
11153
  return;
11071
11154
  }
11072
11155
  if (!session) {
@@ -12191,7 +12274,14 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
12191
12274
  y: (event.clientY - rect2.top - origin2.y) / origin2.scale
12192
12275
  };
12193
12276
  const source = this.previewSourceAt(cursorPoint2, origin2.scale);
12194
- this.canvas.style.cursor = source && !source.element.locked && !this.options.readonly ? "move" : "grab";
12277
+ const editable = source && !source.element.locked && !this.options.readonly;
12278
+ const boundary = editable && source.previewElement?.type === "table" && !event.shiftKey && !event.metaKey && !event.ctrlKey && hitTableColumnBoundary(
12279
+ source.previewElement,
12280
+ cursorPoint2,
12281
+ origin2.scale,
12282
+ this.container.ownerDocument
12283
+ );
12284
+ this.canvas.style.cursor = boundary ? "col-resize" : editable ? "move" : "grab";
12195
12285
  return;
12196
12286
  }
12197
12287
  const rect = this.canvas.getBoundingClientRect();
package/dist/index.js CHANGED
@@ -1207,11 +1207,12 @@ function resolveTableCells(element, rows, columns) {
1207
1207
  (cell) => ((cell.rowSpan ?? 1) > 1 || (cell.colSpan ?? 1) > 1) && row < cell.rowIndex + Math.max(1, cell.rowSpan ?? 1) && row + rowSpan > cell.rowIndex && column < cell.columnIndex + Math.max(1, cell.colSpan ?? 1) && column + colSpan > cell.columnIndex
1208
1208
  );
1209
1209
  const rowRule = rule.row;
1210
- if (rowRule?.keys?.length) {
1211
- const targets = rowRule.columns?.length ? rowRule.columns : rowRule.keys;
1212
- const groupKey = (row) => JSON.stringify(
1213
- rowRule.keys.map((key) => valueKey(readTableCell(row, key)))
1214
- );
1210
+ const hasPath = (path) => Array.isArray(path) ? path.length > 0 : String(path ?? "").trim().length > 0;
1211
+ const rowKeys = rowRule?.keys.filter(hasPath) ?? [];
1212
+ if (rowKeys.length) {
1213
+ const rowColumns = rowRule?.columns?.filter(hasPath) ?? [];
1214
+ const targets = rowColumns.length ? rowColumns : rowKeys;
1215
+ const groupKey = (row) => JSON.stringify(rowKeys.map((key) => valueKey(readTableCell(row, key))));
1215
1216
  for (const [columnIndex, column] of columns.entries()) {
1216
1217
  if (!targets.some((key) => samePath(column.dataIndex, key))) continue;
1217
1218
  let rowIndex = 0;
@@ -1238,12 +1239,13 @@ function resolveTableCells(element, rows, columns) {
1238
1239
  }
1239
1240
  }
1240
1241
  const columnRule = rule.column;
1241
- if (columnRule?.keys?.length) {
1242
+ const columnKeys = columnRule?.keys.filter(hasPath) ?? [];
1243
+ if (columnKeys.length) {
1242
1244
  for (const [rowIndex, row] of rows.entries()) {
1243
1245
  let columnIndex = 0;
1244
1246
  while (columnIndex < columns.length) {
1245
1247
  const column = columns[columnIndex];
1246
- if (!columnRule.keys.some((key) => samePath(column.dataIndex, key)) || overlaps(rowIndex, columnIndex, 1, 1)) {
1248
+ if (!columnKeys.some((key) => samePath(column.dataIndex, key)) || overlaps(rowIndex, columnIndex, 1, 1)) {
1247
1249
  columnIndex++;
1248
1250
  continue;
1249
1251
  }
@@ -1252,7 +1254,7 @@ function resolveTableCells(element, rows, columns) {
1252
1254
  while (columnIndex + colSpan < columns.length) {
1253
1255
  const nextIndex = columnIndex + colSpan;
1254
1256
  const next = columns[nextIndex];
1255
- if (!columnRule.keys.some((key) => samePath(next.dataIndex, key)) || valueKey(readTableCell(row, next.dataIndex)) !== current || overlaps(rowIndex, nextIndex, 1, 1))
1257
+ if (!columnKeys.some((key) => samePath(next.dataIndex, key)) || valueKey(readTableCell(row, next.dataIndex)) !== current || overlaps(rowIndex, nextIndex, 1, 1))
1256
1258
  break;
1257
1259
  colSpan++;
1258
1260
  }
@@ -6313,9 +6315,11 @@ function materializePackedReport(document, data) {
6313
6315
  const table = source.elements.find(
6314
6316
  (element) => element.type === "table" && !!element.packedReport
6315
6317
  );
6316
- if (!table?.packedReport || !table.dataPath) return [source];
6317
- const input = resolveTableDataSource(data, table.dataPath);
6318
- if (!Array.isArray(input) && table.fallbackToStatic) return [source];
6318
+ if (!table?.packedReport) return [source];
6319
+ if (table.dataMode === "binding" && !table.dataPath) return [source];
6320
+ const input = table.dataMode === "binding" ? resolveTableDataSource(data, table.dataPath) : table.dataSource;
6321
+ if (table.dataMode === "binding" && !Array.isArray(input) && table.fallbackToStatic)
6322
+ return [source];
6319
6323
  const records = (Array.isArray(input) ? input : []).filter(
6320
6324
  (item) => !!item && typeof item === "object" && !Array.isArray(item)
6321
6325
  );
@@ -7760,6 +7764,26 @@ function hitTableColumnBoundary(element, point, scale, _document) {
7760
7764
  -(element.rotation ?? 0) * Math.PI / 180
7761
7765
  );
7762
7766
  if (local.y < element.y || local.y > element.y + element.height) return;
7767
+ const { widths, regions } = tableColumnResizeLayout(element, scale);
7768
+ let nearest;
7769
+ let distance2 = 5;
7770
+ for (const region of regions) {
7771
+ if (local.y < region.y || local.y >= region.y + region.height) continue;
7772
+ const edgeDistance = Math.abs(local.x - region.edge) * scale;
7773
+ if (edgeDistance <= distance2) {
7774
+ distance2 = edgeDistance;
7775
+ nearest = {
7776
+ elementId: element.id,
7777
+ boundary: region.boundary,
7778
+ widths,
7779
+ columns: element.columns,
7780
+ rotation: element.rotation ?? 0
7781
+ };
7782
+ }
7783
+ }
7784
+ return nearest;
7785
+ }
7786
+ function tableColumnResizeLayout(element, scale) {
7763
7787
  const columns = tableLeafColumns(
7764
7788
  element.columns.filter((column) => !column.hidden)
7765
7789
  ).filter((column) => !column.hidden);
@@ -7768,19 +7792,39 @@ function hitTableColumnBoundary(element, point, scale, _document) {
7768
7792
  const widths = weights.map(
7769
7793
  (value) => element.width * 96 / 25.4 * value / total
7770
7794
  );
7795
+ const regions = [];
7796
+ if (element.locked || element.visible === false || element.groupPath?.length)
7797
+ return { widths, regions };
7798
+ const rowHeight = element.headerRowHeight ?? 9;
7799
+ const depth = element.showHeader === false ? 0 : tableHeaderDepth(element.columns);
7800
+ const headers = tableHeaderCells(element);
7771
7801
  let offset = 0;
7772
- for (let i = 0; i < widths.length - 1; i++) {
7773
- offset += widths[i];
7774
- const edge = offset * 25.4 / 96;
7775
- if (Math.abs(local.x - element.x - edge) * scale <= 5)
7776
- return {
7777
- elementId: element.id,
7778
- boundary: i,
7779
- widths,
7780
- columns: element.columns,
7781
- rotation: element.rotation ?? 0
7782
- };
7802
+ for (let boundary = 0; boundary < widths.length - 1; boundary++) {
7803
+ offset += widths[boundary] * 25.4 / 96;
7804
+ const edge = element.x + offset;
7805
+ const add = (top, bottom, header) => {
7806
+ bottom = Math.min(bottom, element.height);
7807
+ if (bottom <= top) return;
7808
+ regions.push({
7809
+ boundary,
7810
+ edge,
7811
+ x: edge - 5 / scale,
7812
+ y: element.y + top,
7813
+ width: 10 / scale,
7814
+ height: bottom - top,
7815
+ header
7816
+ });
7817
+ };
7818
+ for (let row = 0; row < depth; row++) {
7819
+ if (headers.some(
7820
+ (cell) => row >= cell.rowIndex && row < cell.rowIndex + cell.rowSpan && (cell.columnIndex === boundary + 1 || cell.columnIndex + cell.colSpan === boundary + 1)
7821
+ )) {
7822
+ add(row * rowHeight, (row + 1) * rowHeight, true);
7823
+ }
7824
+ }
7825
+ add(depth * rowHeight, element.height, false);
7783
7826
  }
7827
+ return { widths, regions };
7784
7828
  }
7785
7829
  function resizeTableColumns(session, dx, dy) {
7786
7830
  const angle = session.rotation * Math.PI / 180;
@@ -9000,7 +9044,8 @@ function drawPrintDesignDebugOverlay(params) {
9000
9044
  table,
9001
9045
  params.scale,
9002
9046
  params.data,
9003
- element.type === "table" && params.showTableSelectors !== false && params.selectedIds.length === 1 && params.selectedIds[0] === element.id
9047
+ element.type === "table" && params.showTableSelectors !== false && params.selectedIds.length === 1 && params.selectedIds[0] === element.id,
9048
+ options.showHitTarget ? pointer : null
9004
9049
  );
9005
9050
  }
9006
9051
  });
@@ -9030,7 +9075,7 @@ function drawPrintDesignDebugOverlay(params) {
9030
9075
  }
9031
9076
  context.restore();
9032
9077
  }
9033
- function drawTableDebugBounds(context, table, scale, data = {}, showSelectors = false) {
9078
+ function drawTableDebugBounds(context, table, scale, data = {}, showSelectors = false, pointer = null) {
9034
9079
  const bounds = getSelectionRect(table, scale, data);
9035
9080
  const centerX = (bounds.x + bounds.width / 2) * scale;
9036
9081
  const centerY = (bounds.y + bounds.height / 2) * scale;
@@ -9058,6 +9103,41 @@ function drawTableDebugBounds(context, table, scale, data = {}, showSelectors =
9058
9103
  selector.height * scale
9059
9104
  );
9060
9105
  }
9106
+ const hit = pointer ? hitTableColumnBoundary(table, pointer, scale) : void 0;
9107
+ context.setLineDash([]);
9108
+ for (const region of tableColumnResizeLayout(table, scale).regions) {
9109
+ if (!region.header) continue;
9110
+ const active = hit?.boundary === region.boundary;
9111
+ context.fillStyle = active ? "rgba(34,197,94,0.35)" : "rgba(236,72,153,0.18)";
9112
+ context.fillRect(
9113
+ region.x * scale,
9114
+ region.y * scale,
9115
+ region.width * scale,
9116
+ region.height * scale
9117
+ );
9118
+ context.strokeStyle = active ? "#16a34a" : "#ec4899";
9119
+ context.strokeRect(
9120
+ region.x * scale,
9121
+ region.y * scale,
9122
+ region.width * scale,
9123
+ region.height * scale
9124
+ );
9125
+ context.fillStyle = active ? "#16a34a" : "#db2777";
9126
+ context.fillRect(
9127
+ region.edge * scale - 0.5,
9128
+ region.y * scale,
9129
+ 1,
9130
+ region.height * scale
9131
+ );
9132
+ context.font = "10px sans-serif";
9133
+ context.textAlign = "left";
9134
+ context.textBaseline = "bottom";
9135
+ context.fillText(
9136
+ `\u5217 ${region.boundary + 1}/${region.boundary + 2} \xB15px${active ? " \u547D\u4E2D" : ""}`,
9137
+ region.edge * scale + 6,
9138
+ region.y * scale
9139
+ );
9140
+ }
9061
9141
  context.restore();
9062
9142
  }
9063
9143
  function drawElementBounds(context, element, scale, color2, data = {}) {
@@ -9482,7 +9562,7 @@ var PrintDesignRenderer = class extends PrintDesignTextEditing {
9482
9562
  }
9483
9563
  }
9484
9564
  const debugOptions = resolvePrintDesignDebugOptions(this.options.debug);
9485
- if (!preview && debugOptions.enabled) {
9565
+ if (debugOptions.enabled) {
9486
9566
  ctx.save();
9487
9567
  ctx.beginPath();
9488
9568
  ctx.rect(0, 0, pageWidth, pageHeight);
@@ -9490,7 +9570,7 @@ var PrintDesignRenderer = class extends PrintDesignTextEditing {
9490
9570
  drawPrintDesignDebugOverlay({
9491
9571
  context: ctx,
9492
9572
  page,
9493
- data: this.options.data,
9573
+ data: preview?.data ?? this.options.data,
9494
9574
  scale,
9495
9575
  options: debugOptions,
9496
9576
  pointer: this.debugPointer,
@@ -11063,8 +11143,11 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
11063
11143
  return;
11064
11144
  }
11065
11145
  if (this.options.preview && !session) {
11066
- const source = this.previewSourceAt(point, origin.scale);
11067
- this.canvas.style.cursor = source && !source.element.locked && !this.options.readonly ? "move" : "grab";
11146
+ this.updateCursor(event, point);
11147
+ if (resolvePrintDesignDebugOptions(this.options.debug).enabled) {
11148
+ this.debugPointer = point;
11149
+ this.render();
11150
+ }
11068
11151
  return;
11069
11152
  }
11070
11153
  if (!session) {
@@ -12189,7 +12272,14 @@ var PrintDesignInteraction = class extends PrintDesignRenderer {
12189
12272
  y: (event.clientY - rect2.top - origin2.y) / origin2.scale
12190
12273
  };
12191
12274
  const source = this.previewSourceAt(cursorPoint2, origin2.scale);
12192
- this.canvas.style.cursor = source && !source.element.locked && !this.options.readonly ? "move" : "grab";
12275
+ const editable = source && !source.element.locked && !this.options.readonly;
12276
+ const boundary = editable && source.previewElement?.type === "table" && !event.shiftKey && !event.metaKey && !event.ctrlKey && hitTableColumnBoundary(
12277
+ source.previewElement,
12278
+ cursorPoint2,
12279
+ origin2.scale,
12280
+ this.container.ownerDocument
12281
+ );
12282
+ this.canvas.style.cursor = boundary ? "col-resize" : editable ? "move" : "grab";
12193
12283
  return;
12194
12284
  }
12195
12285
  const rect = this.canvas.getBoundingClientRect();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvas-components/print-design",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Framework-agnostic Canvas print design engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "pnpm": ">=9.0.0"
27
27
  },
28
28
  "dependencies": {
29
- "@canvas-components/barcode": "0.2.3",
30
29
  "@canvas-components/chart": "0.3.9",
30
+ "@canvas-components/barcode": "0.2.3",
31
31
  "@canvas-components/qrcode": "0.2.3"
32
32
  },
33
33
  "scripts": {