@affino/diagram-vue 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ const pointer = useDiagramPointerController(diagram)
78
78
  </template>
79
79
  ```
80
80
 
81
- Double-click a cell or focus it and press Enter/F2 to edit. Enter commits and returns focus to the cell; Escape discards; blur commits; Up/Down move to the adjacent cell, and Left/Right move when the text caret is at the corresponding edge. While selected, the accessible table toolbar exposes row/column insertion and deletion, row/column sizes, cell alignment, grid visibility/color/width/style, and outer border visibility/color/width/style/radius. Set `showToolbar` to `false` to hide only that built-in toolbar and expose commands in an external inspector through `useDiagramTable(diagram, id)`; cell editing and diagram interactions remain enabled. Toolbar/editor pointer events stop at the controls; the table surface continues to bubble pointer gestures to the diagram controller.
81
+ Double-click a cell or focus it and press Enter/F2 to edit. Typing a printable key starts editing with that character replacing the previous cell text; IME composition and Ctrl/Meta/Alt shortcuts do not trigger replacement. Enter commits and returns focus to the cell; Escape discards; blur commits; Up/Down move to the adjacent cell, and Left/Right move when the text caret is at the corresponding edge. Keyboard-focused cells use a subtle `--affino-focus-ring-color`/`--affino-accent` ring that adapts to the active theme and does not alter grid strokes. While selected, the accessible table toolbar exposes row/column insertion and deletion, row/column sizes, cell alignment, grid visibility/color/width/style, and outer border visibility/color/width/style/radius. Set `showToolbar` to `false` to hide only that built-in toolbar and expose commands in an external inspector through `useDiagramTable(diagram, id)`; cell editing and diagram interactions remain enabled. Toolbar/editor pointer events stop at the controls; the table surface continues to bubble pointer gestures to the diagram controller.
82
82
 
83
83
  ## Viewport resize
84
84
 
@@ -59,9 +59,9 @@ export const DiagramTableView = defineComponent({
59
59
  };
60
60
  const cancelEdit = () => { const edit = editing.value; editing.value = null; if (edit)
61
61
  focusCell(edit.row, edit.column); };
62
- const beginEdit = (table, row, column) => {
62
+ const beginEdit = (table, row, column, initialText) => {
63
63
  selectedCell.value = { row, column };
64
- editing.value = { row, column, text: currentCell(table, row, column).text };
64
+ editing.value = { row, column, text: initialText !== null && initialText !== void 0 ? initialText : currentCell(table, row, column).text };
65
65
  };
66
66
  const navigateEdit = (table, rowDelta, columnDelta, expected) => {
67
67
  commitEdit(expected);
@@ -111,7 +111,7 @@ export const DiagramTableView = defineComponent({
111
111
  const anchor = cell.horizontalAlign === "center" ? "middle" : cell.horizontalAlign === "right" ? "end" : "start";
112
112
  const textX = anchor === "start" ? x + padding : anchor === "end" ? x + width - padding : x + width / 2;
113
113
  const textY = cell.verticalAlign === "top" ? y + padding : cell.verticalAlign === "bottom" ? y + height - padding : y + height / 2;
114
- children.push(h("rect", { x, y, width, height, fill: active && selected.value ? "var(--affino-diagram-table-cell-active, rgba(59, 130, 246, 0.08))" : "transparent", stroke: active && selected.value ? "var(--affino-accent, #3b82f6)" : "transparent", "stroke-width": active && selected.value ? 1 : 0, role: "gridcell", tabindex: selected.value && active ? 0 : -1, "data-table-row": row, "data-table-column": column, "aria-label": `Row ${row + 1}, column ${column + 1}: ${cell.text}`, onClick: (event) => { event.stopPropagation(); selectedCell.value = { row, column }; }, onDblclick: (event) => { event.stopPropagation(); beginEdit(table, row, column); }, onKeydown: (event) => onCellKey(event, table, row, column, beginEdit, selectedCell) }));
114
+ children.push(h("rect", { class: "affino-diagram-table-cell", x, y, width, height, fill: active && selected.value ? "var(--affino-diagram-table-cell-active, rgba(59, 130, 246, 0.08))" : "transparent", stroke: active && selected.value ? "var(--affino-accent, #3b82f6)" : "transparent", "stroke-width": active && selected.value ? 1 : 0, role: "gridcell", tabindex: selected.value && active ? 0 : -1, "data-table-row": row, "data-table-column": column, "aria-label": `Row ${row + 1}, column ${column + 1}: ${cell.text}`, onClick: (event) => { event.stopPropagation(); selectedCell.value = { row, column }; }, onDblclick: (event) => { event.stopPropagation(); beginEdit(table, row, column); }, onKeydown: (event) => onCellKey(event, table, row, column, beginEdit, selectedCell) }));
115
115
  if (!isEditing)
116
116
  children.push(h("text", { x: textX, y: textY, "text-anchor": anchor, "dominant-baseline": cell.verticalAlign === "top" ? "hanging" : cell.verticalAlign === "bottom" ? "auto" : "middle", fill: "var(--affino-diagram-table-text, currentColor)", "font-size": 14, "pointer-events": "none" }, cell.text));
117
117
  }
@@ -120,7 +120,7 @@ export const DiagramTableView = defineComponent({
120
120
  children.push(h("rect", { x: table.x + style.border.stroke.width / 2, y: table.y + style.border.stroke.width / 2, width: Math.max(0, table.width - style.border.stroke.width), height: Math.max(0, table.height - style.border.stroke.width), rx: style.border.radius, fill: "none", stroke: style.border.stroke.color, "stroke-width": style.border.stroke.width, "stroke-dasharray": dash(style.border.stroke.style), "vector-effect": "non-scaling-stroke", "pointer-events": "none" }));
121
121
  const tableTransform = svgTransform(0, table.flipX === true, table.flipY === true, table);
122
122
  const visualChildren = children.splice(0, children.length);
123
- children.push(h("g", { transform: tableTransform }, visualChildren));
123
+ children.push(h("style", tableCellFocusStyles), h("g", { transform: tableTransform }, visualChildren));
124
124
  const activeEdit = editing.value;
125
125
  if (activeEdit) {
126
126
  const cellX = columnOffsets[activeEdit.column];
@@ -209,14 +209,29 @@ function onCellKey(event, table, row, column, beginEdit, selectedCell) {
209
209
  if (event.key === "Enter" || event.key === "F2") {
210
210
  event.preventDefault();
211
211
  beginEdit(table, row, column);
212
+ return;
213
+ }
214
+ if (isPrintableCellInput(event)) {
215
+ event.preventDefault();
216
+ event.stopPropagation();
217
+ beginEdit(table, row, column, event.key);
212
218
  }
213
219
  }
220
+ function isPrintableCellInput(event) {
221
+ return !event.isComposing
222
+ && event.keyCode !== 229
223
+ && !event.ctrlKey
224
+ && !event.metaKey
225
+ && !event.altKey
226
+ && Array.from(event.key).length === 1;
227
+ }
214
228
  function currentCellValue(table, cell) { var _a, _b, _c, _d; return (_d = (_c = (_b = (_a = table.cells) === null || _a === void 0 ? void 0 : _a[cell.row]) === null || _b === void 0 ? void 0 : _b[cell.column]) !== null && _c !== void 0 ? _c : table.defaultCell) !== null && _d !== void 0 ? _d : { text: "" }; }
215
229
  function offsets(sizes, start) { const result = [start]; for (const size of sizes)
216
230
  result.push(result[result.length - 1] + size); return result; }
217
231
  function dash(style) { return style === "dashed" ? "6 4" : style === "dotted" ? "1 3" : undefined; }
218
232
  function colorInputValue(color) { return /^#[0-9a-f]{6}$/i.test(color) ? color : "#64748b"; }
219
233
  const defaultStyle = { grid: { visible: true, stroke: { color: "#d1d5db", width: 1, style: "solid" } }, border: { visible: true, stroke: { color: "#9ca3af", width: 1, style: "solid" }, radius: 8 }, cellPadding: 8 };
234
+ const tableCellFocusStyles = `.affino-diagram-table-cell:focus{outline:none}.affino-diagram-table-cell:focus-visible{stroke:var(--affino-focus-ring-color,var(--affino-accent,#3b82f6));stroke-width:2;vector-effect:non-scaling-stroke}`;
220
235
  const buttonStyle = { border: "1px solid var(--affino-border, #d1d5db)", borderRadius: "5px", background: "var(--affino-surface, #fff)", color: "var(--affino-text, #111827)", fontSize: "12px", padding: "3px 6px", whiteSpace: "nowrap" };
221
236
  const inputStyle = { boxSizing: "border-box", maxWidth: "72px", border: "1px solid var(--affino-border, #d1d5db)", borderRadius: "4px", background: "var(--affino-surface, #fff)", color: "var(--affino-text, #111827)", fontSize: "12px", padding: "3px" };
222
237
  const fieldStyle = { display: "inline-flex", alignItems: "center", gap: "3px", fontSize: "11px", whiteSpace: "nowrap" };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@affino/diagram-vue",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "author": "Anton Pavlov <a.pavlov@affino.dev>",
5
5
  "type": "module",
6
6
  "description": "Vue adapter for @affino/diagram-core",