@agilehub/agile-editor 1.8.3 → 1.8.6
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/dist/agile-editor.css +1 -1
- package/dist/agile-editor.js +25442 -17377
- package/dist/{i18n-E7gk29NK.js → i18n-BZGLJU1q.js} +511 -620
- package/dist/types/components/editor/callout-dialog.vue.d.ts +48 -0
- package/dist/types/components/editor/callout-gradient-editor.vue.d.ts +12 -0
- package/dist/types/components/editor/figure-caption-numbering-dialog.vue.d.ts +11 -0
- package/dist/types/components/editor/index.vue.d.ts +2 -2
- package/dist/types/components/editor/table-background-control.vue.d.ts +11 -0
- package/dist/types/components/editor/table-cell-properties.vue.d.ts +8 -0
- package/dist/types/components/editor/table-property-section.vue.d.ts +22 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.vue.d.ts +945 -21
- package/dist/types/components/menus/bubble/image/replace.vue.d.ts +3 -0
- package/dist/types/components/menus/bubble/image/size.vue.d.ts +3 -0
- package/dist/types/components/menus/bubble/link/edit.vue.d.ts +3 -0
- package/dist/types/components/menus/bubble/menus.vue.d.ts +2 -2
- package/dist/types/components/menus/toolbar/tools/bubble-note-editor.vue.d.ts +52 -0
- package/dist/types/components/menus/toolbar/tools/bubble-note-image.d.ts +3 -0
- package/dist/types/components/menus/toolbar/tools/bubble-note.vue.d.ts +9 -0
- package/dist/types/components/menus/toolbar/tools/figure-caption-numbering.vue.d.ts +15 -1
- package/dist/types/components/picker/color-panel.vue.d.ts +37 -0
- package/dist/types/components/picker/color.vue.d.ts +9 -0
- package/dist/types/components/statusbar/countdown.vue.d.ts +2 -2
- package/dist/types/components/toolbar/classic.vue.d.ts +10 -10
- package/dist/types/components/toolbar/ribbon.vue.d.ts +10 -10
- package/dist/types/composables/i18n.d.ts +942 -18
- package/dist/types/extensions/bubble-note-content.d.ts +48 -0
- package/dist/types/extensions/bubble-note-extensions.d.ts +12 -0
- package/dist/types/extensions/bubble-note-render.d.ts +1 -0
- package/dist/types/extensions/bubble-note.d.ts +5 -0
- package/dist/types/extensions/callout/index.d.ts +3 -3
- package/dist/types/extensions/callout/title-view.vue.d.ts +93 -0
- package/dist/types/extensions/callout/title.d.ts +7 -0
- package/dist/types/extensions/code-block/index.d.ts +8 -0
- package/dist/types/extensions/columns/schema.d.ts +6 -1
- package/dist/types/extensions/courseware/reader-visibility.d.ts +6 -0
- package/dist/types/extensions/file/index.d.ts +4 -0
- package/dist/types/extensions/image/automatic-attributes.d.ts +6 -0
- package/dist/types/extensions/image/paste.d.ts +3 -0
- package/dist/types/extensions/indent.d.ts +1 -0
- package/dist/types/extensions/insert-newline.d.ts +2 -3
- package/dist/types/extensions/math/index.d.ts +2 -1
- package/dist/types/extensions/smart-sheet/model.d.ts +5 -0
- package/dist/types/extensions/table-column-resize.d.ts +15 -0
- package/dist/types/extensions/table.d.ts +29 -0
- package/dist/types/extensions/timeline/content.vue.d.ts +1 -0
- package/dist/types/extensions/timeline/index.d.ts +3 -6
- package/dist/types/extensions/timeline/model.d.ts +18 -15
- package/dist/types/extensions/trailing-node.d.ts +14 -0
- package/dist/types/i18n.d.ts +942 -18
- package/dist/types/options/config/callout-assets.d.ts +3 -0
- package/dist/types/options/config/callout-color-picker.d.ts +13 -0
- package/dist/types/options/config/callout-templates.d.ts +66 -0
- package/dist/types/options/config/index.d.ts +12 -0
- package/dist/types/options/config/table-color-picker.d.ts +6 -0
- package/dist/types/utils/base64url.d.ts +2 -0
- package/dist/types/utils/block-menu.d.ts +1 -0
- package/dist/types/utils/bookmark-attributes.d.ts +2 -0
- package/dist/types/utils/bubble-note-selection.d.ts +7 -0
- package/dist/types/utils/callout.d.ts +204 -0
- package/dist/types/utils/caption-numbering.d.ts +62 -0
- package/dist/types/utils/code-block-indent.d.ts +15 -0
- package/dist/types/utils/column-width.d.ts +9 -0
- package/dist/types/utils/document-attributes.d.ts +3 -0
- package/dist/types/utils/document-import.d.ts +4 -0
- package/dist/types/utils/document-loading.d.ts +14 -0
- package/dist/types/utils/document-save.d.ts +5 -0
- package/dist/types/utils/editor-scroll.d.ts +1 -0
- package/dist/types/utils/editor-view.d.ts +12 -0
- package/dist/types/utils/figure-caption-numbering.d.ts +11 -55
- package/dist/types/utils/figure-caption-visibility.d.ts +8 -0
- package/dist/types/utils/file.d.ts +5 -2
- package/dist/types/utils/font-size.d.ts +2 -0
- package/dist/types/utils/formula-size.d.ts +23 -0
- package/dist/types/utils/iframe.d.ts +5 -0
- package/dist/types/utils/image-display-size.d.ts +13 -0
- package/dist/types/utils/image-file-caption.d.ts +11 -0
- package/dist/types/utils/image-replacement.d.ts +31 -0
- package/dist/types/utils/image-source.d.ts +2 -0
- package/dist/types/utils/inline-style.d.ts +9 -0
- package/dist/types/utils/insert-newline-position.d.ts +23 -0
- package/dist/types/utils/link.d.ts +5 -0
- package/dist/types/utils/player.d.ts +12 -4
- package/dist/types/utils/pointer-hover-scheduler.d.ts +9 -0
- package/dist/types/utils/selection.d.ts +2 -1
- package/dist/types/utils/source-attributes.d.ts +7 -0
- package/dist/types/utils/style-target.d.ts +4 -0
- package/dist/types/utils/table-appearance.d.ts +33 -0
- package/dist/types/utils/table-attributes.d.ts +14 -0
- package/dist/types/utils/table-border.d.ts +38 -0
- package/dist/types/utils/table-caption-numbering.d.ts +19 -0
- package/dist/types/utils/table-caption-visibility.d.ts +32 -0
- package/dist/types/utils/table-column-resize.d.ts +10 -0
- package/dist/types/utils/table-layout.d.ts +10 -0
- package/dist/types/utils/table-properties.d.ts +39 -0
- package/dist/types/utils/table-reset.d.ts +23 -0
- package/dist/types/utils/table-row-resize.d.ts +8 -0
- package/dist/types/utils/table-selection.d.ts +18 -0
- package/dist/types/utils/thousands-separator.d.ts +1 -0
- package/dist/types/utils/tracking-attributes.d.ts +8 -0
- package/dist/types/utils/video-frame.d.ts +1 -0
- package/dist/types/utils/video-skin.d.ts +1 -0
- package/dist/{viewer-DmoW4doo.js → viewer-Bg-htPGM.js} +2 -2
- package/docs/FORMATTING_TEMPLATES.md +253 -253
- package/docs/FORMATTING_TEMPLATE_BUSINESS_GUIDE.md +536 -536
- package/docs/SECONDARY_DEVELOPMENT.md +13 -9
- package/docs/features.md +1 -1
- package/docs/superpowers/plans/2026-11-27-table-reset-controls.md +185 -0
- package/docs/superpowers/plans/2026-11-28-bubble-note-rich-content.md +101 -0
- package/docs/superpowers/plans/2026-11-28-image-replace.md +190 -0
- package/docs/superpowers/plans/2026-11-28-table-image-resize-preview.md +121 -0
- package/docs/superpowers/plans/2026-11-28-table-property-category-actions.md +192 -0
- package/docs/superpowers/specs/2026-11-27-table-reset-controls-design.md +66 -0
- package/docs/superpowers/specs/2026-11-28-bubble-note-rich-content-design.md +64 -0
- package/docs/superpowers/specs/2026-11-28-image-replace-design.md +40 -0
- package/docs/superpowers/specs/2026-11-28-table-image-resize-preview-design.md +30 -0
- package/docs/superpowers/specs/2026-11-28-table-property-category-actions-design.md +63 -0
- package/package.json +5 -5
- package/dist/types/components/menus/bubble/callout/background.vue.d.ts +0 -7
- package/dist/types/components/menus/bubble/callout/emoji-remove.vue.d.ts +0 -7
- /package/dist/types/components/{menus/bubble/callout/builtin.vue.d.ts → editor/table-cell-context-menu.vue.d.ts} +0 -0
- /package/dist/types/components/{menus/bubble/image/open.vue.d.ts → editor/table-quick-toolbar.vue.d.ts} +0 -0
|
@@ -62,6 +62,10 @@ Vue 菜单按钮 → 调用 Tiptap 命令 → 更新文档节点 → NodeView
|
|
|
62
62
|
|
|
63
63
|
内置表格的 JSON 结构为 `tableFigure → tableCaption + table → tableRow → tableCell/tableHeader`。`tableCaption` 是包含行内文字和格式标记的文本节点,使用正文的选区、工具栏和撤销记录;HTML 保存为真实的 `<table><caption>…</caption><tbody>…</tbody></table>`。标题显隐通过 `toggleTableCaption()` 切换,隐藏时保留文字。加载或插入旧版 JSON 表格时,会将原来的 `caption` / `captionHtml` 属性转换为标题节点。
|
|
64
64
|
|
|
65
|
+
表格选区进入编辑状态时,`table-quick-toolbar` 会定位到表格上方,提供整表选择、表格属性、行属性和单元格属性。宽度、高度、边框和标题使用表格节点属性保存;纯色、渐变和图片背景写入对应节点的 `inlineStyle`。行级边框和背景通过 `setTableRowCellAttributes()`、`setTableRowBackgroundStyle()` 同步到当前行所有单元格,避免表头单元格背景覆盖行背景。
|
|
66
|
+
|
|
67
|
+
由于表格标题会让 `<table>` 的第一个子节点变为 `<caption>`,列宽拖拽使用 `table-column-resize.ts` 显式查找 `<colgroup>`,不能依赖 ProseMirror 默认的 `table.firstChild` 假设。
|
|
68
|
+
|
|
65
69
|
### 2.1 完整开发顺序与调用关系
|
|
66
70
|
|
|
67
71
|
先确定要做的功能:**在“插入”工具栏放一个“插入说明块”按钮;点击后正文出现可编辑的说明块;保存再打开仍保留内容。** 下文始终使用这一例子,不需要把不同示例拼在一起猜测。
|
|
@@ -523,15 +527,15 @@ function onCreated({ editor }: { editor: Editor }): void {
|
|
|
523
527
|
|
|
524
528
|
### 4.4 可用插槽和公开组件
|
|
525
529
|
|
|
526
|
-
| 入口
|
|
527
|
-
|
|
|
528
|
-
| `toolbar_base`
|
|
529
|
-
| `toolbar_insert`
|
|
530
|
-
| `toolbar_table`、`toolbar_tools`、`toolbar_view`、`toolbar_review` | 对应工具栏追加组件;所属菜单需要启用
|
|
531
|
-
| `toolbar_actions`
|
|
532
|
-
| `bubble_menu`
|
|
533
|
-
| `AgileMenuButton`
|
|
534
|
-
| `AgileDialog`、`AgileTooltip`
|
|
530
|
+
| 入口 | 用途与注意事项 |
|
|
531
|
+
| ------------------------------------------------------------------ | -------------------------------------------------------------------- |
|
|
532
|
+
| `toolbar_base` | 开始工具栏追加业务组件 |
|
|
533
|
+
| `toolbar_insert` | 插入工具栏追加业务组件,本例使用此插槽 |
|
|
534
|
+
| `toolbar_table`、`toolbar_tools`、`toolbar_view`、`toolbar_review` | 对应工具栏追加组件;所属菜单需要启用 |
|
|
535
|
+
| `toolbar_actions` | 工具栏操作区域 |
|
|
536
|
+
| `bubble_menu` | 编辑器浮动菜单中的自定义内容;受浮动菜单显示条件约束,不是常驻工具栏 |
|
|
537
|
+
| `AgileMenuButton` | 菜单按钮,使用 `@menu-click` 执行操作 |
|
|
538
|
+
| `AgileDialog`、`AgileTooltip` | 可显式导入复用的弹窗和提示组件 |
|
|
535
539
|
|
|
536
540
|
工具栏插槽会提供 `toolbar-mode`(`classic` 或 `ribbon`),但不会自动提供 `editor` 参数。可通过 `#toolbar_insert="{ toolbarMode }"` 获取布局模式,按需调整按钮尺寸。
|
|
537
541
|
|
package/docs/features.md
CHANGED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Table Reset Controls Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Add table, row, and cell reset controls that clear only their own level of formatting through centralized Tiptap commands.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Pure update builders in `src/utils/table-reset.ts` define the exact default attributes and nodes affected. `src/extensions/table.ts` exposes three commands that apply those updates in one transaction. The existing table quick toolbar and cell properties panel only call commands and render localized buttons.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Vue 3, TypeScript, Tiptap 3, ProseMirror transactions, Node test runner, TDesign Vue Next.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-27-table-reset-controls-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Table reset must not touch row or cell formatting.
|
|
16
|
+
- Row reset must not touch other rows or cell content.
|
|
17
|
+
- Cell reset must not delete content or reset text marks such as color, font, and size.
|
|
18
|
+
- Every reset must be one undoable transaction.
|
|
19
|
+
- Do not add a confirmation dialog.
|
|
20
|
+
- All visible copy must have `zh-CN` and `en-US` translations.
|
|
21
|
+
|
|
22
|
+
## Review Focus
|
|
23
|
+
|
|
24
|
+
- Reset commands must remove `sourceAttributes` styles that could replay old formatting after reset.
|
|
25
|
+
- Row reset must clear shared borders without removing cell width or text alignment.
|
|
26
|
+
- Cell reset must remove imported inline text alignment while preserving other paragraph styles.
|
|
27
|
+
- Empty or invalid selections must return `false` without dispatching a transaction.
|
|
28
|
+
- All reset buttons must remain enabled in their own settings panel but fail safely outside a table.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Task 1: Pure Reset Update Builders
|
|
33
|
+
|
|
34
|
+
**Files:**
|
|
35
|
+
- Create: `src/utils/table-reset.ts`
|
|
36
|
+
- Create: `tests/table-reset.test.mjs`
|
|
37
|
+
- Modify: `package.json:test:style-target`
|
|
38
|
+
|
|
39
|
+
**Interfaces:**
|
|
40
|
+
- Consumes: ProseMirror `Node`, `TableMap`, and existing `removeInlineStyleProperties`.
|
|
41
|
+
- Produces:
|
|
42
|
+
- `getTableResetAttributes(attrs: Record<string, unknown>): Record<string, unknown>`
|
|
43
|
+
- `getTableRowResetUpdates(doc: ProseMirrorNode, tableStart: number, row: number, map: TableMap): TableResetUpdate[]`
|
|
44
|
+
- `getTableCellResetUpdates(doc: ProseMirrorNode, cellPosition: number): TableResetUpdate[] | null`
|
|
45
|
+
- `type TableResetUpdate = { position: number; attrs: Record<string, unknown> }`
|
|
46
|
+
|
|
47
|
+
- [ ] **Step 1: Write failing tests for all three scopes**
|
|
48
|
+
|
|
49
|
+
Test names and assertions:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
test('table reset clears table styling without touching rows or cells', () => {
|
|
53
|
+
// Table attrs gain defaults and lose sourceAttributes/preset/background styles.
|
|
54
|
+
// Row and cell attrs remain byte-for-byte equal to the fixture.
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('row reset clears row styling while preserving cell width and content', () => {
|
|
58
|
+
// Selected row loses rowHeight/borders/background/header role.
|
|
59
|
+
// A different row and each cell's colwidth/textAlign remain unchanged.
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test('cell reset clears cell styling and generated text alignment', () => {
|
|
63
|
+
// Selected cell loses all appearance attrs, colwidth and sourceAttributes.
|
|
64
|
+
// Paragraph text remains, while textAlign and inline text-align are cleared.
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- [ ] **Step 2: Run the new test file to verify RED**
|
|
69
|
+
|
|
70
|
+
Run: `node --test tests/table-reset.test.mjs`
|
|
71
|
+
|
|
72
|
+
Expected: FAIL because `src/utils/table-reset.ts` does not exist.
|
|
73
|
+
|
|
74
|
+
- [ ] **Step 3: Implement the pure update builders**
|
|
75
|
+
|
|
76
|
+
Table defaults are `sourceAttributes: null`, `inlineStyle: null`, `presetStyle: null`, `presetColor: null`, `presetShading: ''`, `indentNormalized: false`, `borderType: 'all'`, `borderColor: null`, `borderStyle: '1px solid'`, `dateTableType: 'table'`. Preserve `id` and track-change metadata.
|
|
77
|
+
|
|
78
|
+
Row updates use `TableMap` to find every mapped cell for the selected row. Clear row `rowHeight` and `inlineStyle`; remove background properties from row cell inline styles; clear all cell border attrs; convert each row cell to `tableCell`.
|
|
79
|
+
|
|
80
|
+
Cell reset clears all appearance, alignment, width, border, and source attrs. For each internal text block, set `textAlign: 'left'` and remove `text-align`/`text-align-last` from `inlineStyle`.
|
|
81
|
+
|
|
82
|
+
- [ ] **Step 4: Run the new tests to verify GREEN**
|
|
83
|
+
|
|
84
|
+
Run: `node --test tests/table-reset.test.mjs`
|
|
85
|
+
|
|
86
|
+
Expected: PASS, 3 tests.
|
|
87
|
+
|
|
88
|
+
- [ ] **Step 5: Run the full suite**
|
|
89
|
+
|
|
90
|
+
Run: `npm run test:style-target`
|
|
91
|
+
|
|
92
|
+
Expected: PASS, all tests.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Task 2: Tiptap Reset Commands
|
|
97
|
+
|
|
98
|
+
**Files:**
|
|
99
|
+
- Modify: `src/extensions/table.ts`
|
|
100
|
+
- Test: `tests/table-reset.test.mjs`
|
|
101
|
+
|
|
102
|
+
**Interfaces:**
|
|
103
|
+
- Consumes: Task 1 update builders.
|
|
104
|
+
- Produces commands:
|
|
105
|
+
- `clearTableSettings(): ReturnType`
|
|
106
|
+
- `clearTableRowSettings(): ReturnType`
|
|
107
|
+
- `clearTableCellSettings(): ReturnType`
|
|
108
|
+
|
|
109
|
+
- [ ] **Step 1: Add a characterization assertion for command-level target resolution**
|
|
110
|
+
|
|
111
|
+
Add a test that verifies the selected table row is derived from the current cell rectangle and that invalid table positions yield no updates.
|
|
112
|
+
|
|
113
|
+
- [ ] **Step 2: Run the characterization test to verify RED**
|
|
114
|
+
|
|
115
|
+
Run: `node --test tests/table-reset.test.mjs`
|
|
116
|
+
|
|
117
|
+
Expected: FAIL because the target-resolution helper is missing.
|
|
118
|
+
|
|
119
|
+
- [ ] **Step 3: Implement the three commands**
|
|
120
|
+
|
|
121
|
+
`clearTableSettings` finds the current `tableFigure`, updates its `table` child attrs with `getTableResetAttributes`, and sets the figure's `tableCaption.hidden` to `true`.
|
|
122
|
+
|
|
123
|
+
`clearTableRowSettings` uses `selectionCell`, `selectedRect`, `TableMap`, and the existing row range to apply Task 1 row updates to all selected rows in one transaction.
|
|
124
|
+
|
|
125
|
+
`clearTableCellSettings` applies Task 1 cell updates to every selected cell.
|
|
126
|
+
|
|
127
|
+
All commands return `false` when no table, row, or cell can be resolved and dispatch no transaction.
|
|
128
|
+
|
|
129
|
+
- [ ] **Step 4: Run the focused tests to verify GREEN**
|
|
130
|
+
|
|
131
|
+
Run: `node --test tests/table-reset.test.mjs`
|
|
132
|
+
|
|
133
|
+
Expected: PASS.
|
|
134
|
+
|
|
135
|
+
- [ ] **Step 5: Run typecheck**
|
|
136
|
+
|
|
137
|
+
Run: `npm run typecheck`
|
|
138
|
+
|
|
139
|
+
Expected: exit 0.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### Task 3: Reset Buttons and Localization
|
|
144
|
+
|
|
145
|
+
**Files:**
|
|
146
|
+
- Modify: `src/components/editor/table-quick-toolbar.vue`
|
|
147
|
+
- Modify: `src/components/editor/table-cell-properties.vue`
|
|
148
|
+
- Modify: `src/locales/zh-CN.json`
|
|
149
|
+
- Modify: `src/locales/en-US.json`
|
|
150
|
+
|
|
151
|
+
**Interfaces:**
|
|
152
|
+
- Consumes: Task 2 commands.
|
|
153
|
+
- Produces: table/row/cell reset buttons with the exact translation keys `table.quickTools.clearTable`, `clearRow`, and `clearCell`.
|
|
154
|
+
|
|
155
|
+
- [ ] **Step 1: Add the three localized labels**
|
|
156
|
+
|
|
157
|
+
Use Chinese labels `清除表格设置`, `清除表行设置`, `清除单元格属性设置`; use English equivalents `Clear table settings`, `Clear row settings`, `Clear cell properties`.
|
|
158
|
+
|
|
159
|
+
- [ ] **Step 2: Add reset buttons left of each apply button**
|
|
160
|
+
|
|
161
|
+
Use the existing text-button treatment already used by “清除背景”. Keep the reset and apply buttons in one right-aligned action row.
|
|
162
|
+
|
|
163
|
+
- [ ] **Step 3: Wire the buttons**
|
|
164
|
+
|
|
165
|
+
Call `editor.chain().focus().clearTableSettings().run()`, `clearTableRowSettings()`, and `clearTableCellSettings()` respectively. Keep the active panel open so the form can resync to cleared values.
|
|
166
|
+
|
|
167
|
+
- [ ] **Step 4: Run typecheck and focused tests**
|
|
168
|
+
|
|
169
|
+
Run: `npm run typecheck && node --test tests/table-reset.test.mjs`
|
|
170
|
+
|
|
171
|
+
Expected: both exit 0.
|
|
172
|
+
|
|
173
|
+
- [ ] **Step 5: Verify in the browser**
|
|
174
|
+
|
|
175
|
+
Create a table with width, alignment, background, preset style, row height/background/border, and cell width/alignment/background/border. Verify each clear button changes only its own scope, preserves content, and can be undone with one undo.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Final Verification
|
|
180
|
+
|
|
181
|
+
- [ ] Run `npm run test:style-target`
|
|
182
|
+
- [ ] Run `npm run typecheck`
|
|
183
|
+
- [ ] Run `npm run build`
|
|
184
|
+
- [ ] Run lint on all modified files
|
|
185
|
+
- [ ] Review `git diff --check`
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Bubble Note Rich Content Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Add safe rich text, images, and formulas to bubble-note bodies without breaking legacy plain-text notes.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Persist a constrained Tiptap document in the existing `bubbleNote` mark, keep a plain-text mirror, edit it in a dedicated nested editor, and render it read-only through the same sanitized schema.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Vue 3, Tiptap 3, TDesign Vue Next, `@agilehub/latex-formula`, Node `node:test`.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-28-bubble-note-rich-content-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Preserve the 20-character anchor limit.
|
|
16
|
+
- Use `agile-` CSS prefixes and existing TDesign/theme variables.
|
|
17
|
+
- Keep old `data-annotation` documents readable.
|
|
18
|
+
- Do not introduce unsupported arbitrary HTML rendering.
|
|
19
|
+
- Keep image and formula creation inside the bubble-note scope.
|
|
20
|
+
|
|
21
|
+
## Review Focus
|
|
22
|
+
|
|
23
|
+
- Legacy plain annotations must open as valid rich content.
|
|
24
|
+
- Malformed rich JSON must fall back without losing text.
|
|
25
|
+
- Unsupported pasted nodes and unsafe links must not enter stored content.
|
|
26
|
+
- Image upload failure must leave the editor usable.
|
|
27
|
+
- Read-only and keyboard interaction must remain available outside edit mode.
|
|
28
|
+
|
|
29
|
+
### Task 1: Rich Content Codec And Sanitizer
|
|
30
|
+
|
|
31
|
+
**Files:**
|
|
32
|
+
- Create: `src/extensions/bubble-note-content.ts`
|
|
33
|
+
- Test: `tests/bubble-note-rich-content.test.mjs`
|
|
34
|
+
|
|
35
|
+
**Interfaces:**
|
|
36
|
+
- Produces: `createBubbleNoteContent(text)`, `normalizeBubbleNoteContent(value, fallbackText)`, `encodeBubbleNoteContent(value)`, `decodeBubbleNoteContent(value)`, `getBubbleNoteText(value)`, `validateBubbleNoteContent(value, limits)`.
|
|
37
|
+
|
|
38
|
+
- [x] Write failing tests for legacy conversion, round-trip encoding, malformed input, allowed marks, and limits.
|
|
39
|
+
- [x] Run `node --test tests/bubble-note-rich-content.test.mjs` and confirm the missing module failure.
|
|
40
|
+
- [x] Implement the codec and sanitizer.
|
|
41
|
+
- [x] Re-run the focused test until it passes.
|
|
42
|
+
|
|
43
|
+
### Task 2: Bubble Note Mark Persistence
|
|
44
|
+
|
|
45
|
+
**Files:**
|
|
46
|
+
- Modify: `src/extensions/bubble-note.ts`
|
|
47
|
+
- Modify: `tests/style-schema.test.mjs`
|
|
48
|
+
|
|
49
|
+
**Interfaces:**
|
|
50
|
+
- Consumes: Task 1 codec functions.
|
|
51
|
+
- Produces: `annotationContent` and `annotationVersion` mark attributes with HTML parse/render.
|
|
52
|
+
|
|
53
|
+
- [x] Extend the schema test to require rich-content attributes and HTML round-trip.
|
|
54
|
+
- [x] Run the focused schema test and confirm it fails.
|
|
55
|
+
- [x] Add mark attrs, Base64URL HTML persistence, and legacy fallback parsing.
|
|
56
|
+
- [x] Re-run the focused test until it passes.
|
|
57
|
+
|
|
58
|
+
### Task 3: Constrained Note Editor
|
|
59
|
+
|
|
60
|
+
**Files:**
|
|
61
|
+
- Create: `src/components/menus/toolbar/tools/bubble-note-editor.vue`
|
|
62
|
+
- Create: `src/components/menus/toolbar/tools/bubble-note-image.ts`
|
|
63
|
+
- Modify: `src/components/editor/formula-dialog.vue`
|
|
64
|
+
|
|
65
|
+
**Interfaces:**
|
|
66
|
+
- Consumes: Task 1 content model, existing `Math`, `CustomInlineMath`, and `CustomBlockMath`.
|
|
67
|
+
- Produces: a nested editor with toolbar, image insertion, formula insertion, character count, and `getContent()` snapshot.
|
|
68
|
+
|
|
69
|
+
- [x] Add focused tests for note image HTML rendering and content limits.
|
|
70
|
+
- [x] Run the focused tests and confirm they fail.
|
|
71
|
+
- [x] Implement the image node and nested editor.
|
|
72
|
+
- [x] Re-run focused tests and typecheck.
|
|
73
|
+
|
|
74
|
+
### Task 4: Dialog And Popup Integration
|
|
75
|
+
|
|
76
|
+
**Files:**
|
|
77
|
+
- Modify: `src/components/menus/toolbar/tools/bubble-note.vue`
|
|
78
|
+
- Modify: `src/extensions/bubble-note.ts`
|
|
79
|
+
- Modify: `src/assets/styles/editor.less`
|
|
80
|
+
- Modify: `src/locales/zh-CN.json`
|
|
81
|
+
- Modify: `src/locales/en-US.json`
|
|
82
|
+
|
|
83
|
+
**Interfaces:**
|
|
84
|
+
- Consumes: Task 2 persistence and Task 3 editor.
|
|
85
|
+
- Produces: rich edit dialog, static rich popup, keyboard anchor activation, mobile sheet layout.
|
|
86
|
+
|
|
87
|
+
- [x] Add failing assertions for rich popup parsing and keyboard-open metadata.
|
|
88
|
+
- [x] Run the focused test and confirm it fails.
|
|
89
|
+
- [x] Replace the textarea with the note editor and render the saved rich body.
|
|
90
|
+
- [x] Add responsive and dark-theme styles.
|
|
91
|
+
- [x] Run focused tests and typecheck.
|
|
92
|
+
|
|
93
|
+
### Task 5: Verification
|
|
94
|
+
|
|
95
|
+
**Files:**
|
|
96
|
+
- Modify only files required by failures found here.
|
|
97
|
+
|
|
98
|
+
- [x] Run `node --test tests/bubble-note-rich-content.test.mjs tests/style-schema.test.mjs`.
|
|
99
|
+
- [x] Run `npm run typecheck`.
|
|
100
|
+
- [x] Run `npm run build`.
|
|
101
|
+
- [x] Run the project test suite when practical and report unrelated failures separately.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
# Image Replacement Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Add an image bubble-menu action that replaces the selected image source while preserving every other image attribute and caption setting.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Keep ProseMirror node identity intact and update only source-related attributes through one transaction. A small pure utility owns the attribute merge and stale-target checks; a Vue bubble-menu component owns file selection and uploading.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Vue 3, TypeScript, Tiptap 3, VueUse `useFileDialog`, Node.js built-in test runner.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-28-image-replace-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Support both `image` and `inlineImage`.
|
|
16
|
+
- Preserve `id`, `imageId`, `style`, `class`, source HTML attributes, dimensions, rotation, flip, drag position, caption content, caption style, and caption visibility.
|
|
17
|
+
- Only update source state: `src`, `srcEncoding`, `srcMimeType`, `uploaded`, and `error`.
|
|
18
|
+
- Use `options.onFileUpload` when it differs from `defaultOptions.onFileUpload`.
|
|
19
|
+
- When no custom upload callback is configured, read the selected file as a base64 DataURL.
|
|
20
|
+
- Do not delete the replaced image resource.
|
|
21
|
+
- Cancel, validation failure, upload failure, or stale target must not modify the document.
|
|
22
|
+
- Replacement must be a single undoable transaction.
|
|
23
|
+
|
|
24
|
+
## Review Focus
|
|
25
|
+
|
|
26
|
+
- Empty file selections and canceled dialogs must not create a transaction.
|
|
27
|
+
- An async upload completing after the target node moved, disappeared, or changed must abort instead of overwriting another node.
|
|
28
|
+
- Oversized or non-image files must leave the original image unchanged.
|
|
29
|
+
- Inline images must preserve their inline node type and all wrapper attributes.
|
|
30
|
+
- One undo must restore the old source without resetting dimensions, captions, or styles.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### Task 1: Image Replacement Model
|
|
35
|
+
|
|
36
|
+
**Files:**
|
|
37
|
+
- Create: `src/utils/image-replacement.ts`
|
|
38
|
+
- Create: `tests/image-replacement.test.mjs`
|
|
39
|
+
- Modify: `package.json`
|
|
40
|
+
|
|
41
|
+
**Interfaces:**
|
|
42
|
+
- Consumes: no earlier task interfaces.
|
|
43
|
+
- Produces:
|
|
44
|
+
- `type ImageReplacementTarget = { position: number; id: string | null; src: string | null; type: 'image' | 'inlineImage' }`
|
|
45
|
+
- `type ImageNodeLike = { type: { name: string }; attrs: Record<string, any> }`
|
|
46
|
+
- `createImageReplacementAttrs(attrs: Record<string, any>, src: string): Record<string, any>`
|
|
47
|
+
- `findImageReplacementTarget(doc: { nodeAt(position: number): ImageNodeLike | null }, target: ImageReplacementTarget): ImageNodeLike | null`
|
|
48
|
+
|
|
49
|
+
- [ ] **Step 1: Write the failing replacement-model tests**
|
|
50
|
+
|
|
51
|
+
Create `tests/image-replacement.test.mjs` with tests that import the not-yet-created utility and assert:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const originalAttrs = {
|
|
55
|
+
id: 'image-1',
|
|
56
|
+
imageId: 'image-node-1',
|
|
57
|
+
src: 'https://example.com/old.png',
|
|
58
|
+
srcEncoding: 'base64url',
|
|
59
|
+
srcMimeType: 'image/png',
|
|
60
|
+
imageStyle: 'border: 1px solid red',
|
|
61
|
+
sourceAttributes: { class: 'hero-image', style: 'aspect-ratio: 16/9' },
|
|
62
|
+
width: 640,
|
|
63
|
+
height: 360,
|
|
64
|
+
angle: 15,
|
|
65
|
+
captionStyle: 'color: red',
|
|
66
|
+
showTitle: true,
|
|
67
|
+
uploaded: false,
|
|
68
|
+
error: true,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const nextAttrs = createImageReplacementAttrs(
|
|
72
|
+
originalAttrs,
|
|
73
|
+
'data:image/png;base64,bmV3',
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
assert.deepEqual(nextAttrs, {
|
|
77
|
+
...originalAttrs,
|
|
78
|
+
src: 'data:image/png;base64,bmV3',
|
|
79
|
+
srcEncoding: null,
|
|
80
|
+
srcMimeType: null,
|
|
81
|
+
uploaded: true,
|
|
82
|
+
error: false,
|
|
83
|
+
})
|
|
84
|
+
assert.notEqual(nextAttrs, originalAttrs)
|
|
85
|
+
assert.equal(originalAttrs.src, 'https://example.com/old.png')
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Also assert that `findImageReplacementTarget` returns a node only when its type, `id`, and `src` match the captured target, accepts `inlineImage`, and returns `null` for a missing node or mismatched `id`/`src`.
|
|
89
|
+
|
|
90
|
+
- [ ] **Step 2: Run the new test and verify RED**
|
|
91
|
+
|
|
92
|
+
Run: `node --test tests/image-replacement.test.mjs`
|
|
93
|
+
|
|
94
|
+
Expected: FAIL because `src/utils/image-replacement.ts` does not exist.
|
|
95
|
+
|
|
96
|
+
- [ ] **Step 3: Implement the minimal replacement model**
|
|
97
|
+
|
|
98
|
+
Create `src/utils/image-replacement.ts` with the interfaces above. `createImageReplacementAttrs` returns a new object with only source state changed. `findImageReplacementTarget` safely reads `doc.nodeAt(target.position)` and returns it only when the node type is `image` or `inlineImage`, and both `id` and `src` equal the captured target.
|
|
99
|
+
|
|
100
|
+
- [ ] **Step 4: Run the focused test and verify GREEN**
|
|
101
|
+
|
|
102
|
+
Run: `node --test tests/image-replacement.test.mjs`
|
|
103
|
+
|
|
104
|
+
Expected: PASS with all replacement-model subtests passing.
|
|
105
|
+
|
|
106
|
+
- [ ] **Step 5: Add the focused test to the repository test command**
|
|
107
|
+
|
|
108
|
+
Append `tests/image-replacement.test.mjs` to the `test:style-target` script in `package.json`, then run:
|
|
109
|
+
|
|
110
|
+
`npm run test:style-target`
|
|
111
|
+
|
|
112
|
+
Expected: PASS with no failing tests.
|
|
113
|
+
|
|
114
|
+
- [ ] **Step 6: Commit Task 1**
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git add docs/superpowers/specs/2026-11-28-image-replace-design.md docs/superpowers/plans/2026-11-28-image-replace.md src/utils/image-replacement.ts tests/image-replacement.test.mjs package.json
|
|
118
|
+
git commit -m "feat: add image replacement model"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Task 2: Bubble-Menu Replacement Action
|
|
122
|
+
|
|
123
|
+
**Files:**
|
|
124
|
+
- Create: `src/components/menus/bubble/image/replace.vue`
|
|
125
|
+
- Modify: `src/components/menus/bubble/menus.vue`
|
|
126
|
+
- Modify: `src/locales/zh-CN.json`
|
|
127
|
+
- Modify: `src/locales/en-US.json`
|
|
128
|
+
|
|
129
|
+
**Interfaces:**
|
|
130
|
+
- Consumes:
|
|
131
|
+
- `createImageReplacementAttrs(attrs, src)` from `src/utils/image-replacement.ts`
|
|
132
|
+
- `findImageReplacementTarget(doc, target)` from `src/utils/image-replacement.ts`
|
|
133
|
+
- `getImageAccept`, `getImageMaxSize`, and `validateImageFileSize` from `src/utils/upload.ts`
|
|
134
|
+
- Produces: `MenusBubbleImageReplace`, auto-registered as `<menus-bubble-image-replace />`.
|
|
135
|
+
|
|
136
|
+
- [ ] **Step 1: Add the replacement action to the image bubble menu**
|
|
137
|
+
|
|
138
|
+
Create `src/components/menus/bubble/image/replace.vue`:
|
|
139
|
+
|
|
140
|
+
- Render a `menus-button` with `ico="node-switch"`, translated text, and an uploading disabled state.
|
|
141
|
+
- Capture a `NodeSelection` for `image` or `inlineImage` into `ImageReplacementTarget` before opening a single-file image picker.
|
|
142
|
+
- Configure `useFileDialog` with `accept: computed(() => getImageAccept(options.value))`, `multiple: false`, and `reset: true`.
|
|
143
|
+
- On selection, clear the pending target first. If no file is selected, return without dispatching.
|
|
144
|
+
- Reject files outside the concrete MIME list returned by `getImageAccept(options.value)` and files larger than `getImageMaxSize(options.value)`, using the existing `file.limit` message for size failures and `bubbleMenu.image.replaceFailed` for upload/type failures.
|
|
145
|
+
- Use `options.value.onFileUpload(file)` only when it differs from `defaultOptions.onFileUpload`; otherwise read the file as a base64 DataURL.
|
|
146
|
+
- Re-read the target with `findImageReplacementTarget(editor.value.state.doc, target)` after the async upload.
|
|
147
|
+
- Dispatch one `setNodeMarkup` transaction using `createImageReplacementAttrs(node.attrs, url)`.
|
|
148
|
+
|
|
149
|
+
Insert `<menus-bubble-image-replace />` in the image branch of `src/components/menus/bubble/menus.vue`, after image size controls and before image-title/crop controls.
|
|
150
|
+
|
|
151
|
+
- [ ] **Step 2: Add localized labels**
|
|
152
|
+
|
|
153
|
+
Add `bubbleMenu.image.replace`, `bubbleMenu.image.replacing`, and `bubbleMenu.image.replaceFailed` to both `src/locales/zh-CN.json` and `src/locales/en-US.json`. Preserve valid JSON formatting.
|
|
154
|
+
|
|
155
|
+
- [ ] **Step 3: Run static verification**
|
|
156
|
+
|
|
157
|
+
Run: `npm run typecheck`
|
|
158
|
+
|
|
159
|
+
Expected: PASS with no TypeScript or Vue SFC errors.
|
|
160
|
+
|
|
161
|
+
Run: `npm run lint`
|
|
162
|
+
|
|
163
|
+
Expected: PASS; only intentional auto-fixes in touched source files are allowed.
|
|
164
|
+
|
|
165
|
+
- [ ] **Step 4: Run the full automated verification**
|
|
166
|
+
|
|
167
|
+
Run: `npm run test:style-target`
|
|
168
|
+
|
|
169
|
+
Expected: PASS with no failing tests.
|
|
170
|
+
|
|
171
|
+
Run: `npm run build`
|
|
172
|
+
|
|
173
|
+
Expected: PASS and produce the library build.
|
|
174
|
+
|
|
175
|
+
- [ ] **Step 5: Browser verification**
|
|
176
|
+
|
|
177
|
+
Start `npm run dev`, open the editor, and verify:
|
|
178
|
+
|
|
179
|
+
1. Select a block image, click “替换图片”, choose a local image, and confirm the image changes.
|
|
180
|
+
2. Inspect the resulting HTML node and confirm `id`, `style`, `class`, dimensions, and caption content are unchanged.
|
|
181
|
+
3. Repeat with an inline image.
|
|
182
|
+
4. Undo once and confirm the original image source returns with all settings intact.
|
|
183
|
+
5. Cancel the file picker and confirm the document does not change.
|
|
184
|
+
|
|
185
|
+
- [ ] **Step 6: Commit Task 2**
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
git add src/components/menus/bubble/image/replace.vue src/components/menus/bubble/menus.vue src/locales/zh-CN.json src/locales/en-US.json
|
|
189
|
+
git commit -m "feat: add image replacement bubble action"
|
|
190
|
+
```
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Table Image Resize Preview Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Make images inside table cells follow the resize pointer continuously and commit the final size immediately on pointer release.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Keep the document unchanged during the gesture. Add a local reactive preview size to the image NodeView, drive the image/dragger rendering from that preview, and dispatch exactly one final transaction from `resize-end`.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Vue 3 reactivity macros, Tiptap 3 NodeView, ProseMirror transactions, `es-drager`, Node test runner.
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-11-28-table-image-resize-preview-design.md`
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- No editor transaction may be dispatched from pointer-move resize events.
|
|
16
|
+
- The final image-size transaction must keep `skipUniqueId` and `addToHistory: false`.
|
|
17
|
+
- Table width, table ID, image ID, `imageId`, and the image NodeView instance must remain stable.
|
|
18
|
+
- Preserve the existing 14px minimum and table-cell content-width clamp.
|
|
19
|
+
- Runtime attribute, style, and size changes must never rewrite an existing element ID or mark ID.
|
|
20
|
+
- Runtime ID normalization may only fill missing IDs; duplicate-ID repair belongs to initial full normalization.
|
|
21
|
+
|
|
22
|
+
## Review Focus
|
|
23
|
+
|
|
24
|
+
- Pointer move to pointer release: the image must continuously preview the pointer size and commit immediately on release.
|
|
25
|
+
- Pointer cancel or editor blur after a preview: pending dimensions must not be silently lost.
|
|
26
|
+
- Proportional and free resizing: preview dimensions must respect `attrs.equalProportion`.
|
|
27
|
+
- Cropped images: preview scaling must continue to account for `cropData`.
|
|
28
|
+
- Rapid consecutive gestures: no timers or attribute transactions may accumulate.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
### Task 1: Replace delayed document resizing with local preview
|
|
33
|
+
|
|
34
|
+
**Files:**
|
|
35
|
+
|
|
36
|
+
- Modify: `src/extensions/image/node-view.vue:209-220`
|
|
37
|
+
- Modify: `src/extensions/image/node-view.vue:320-355`
|
|
38
|
+
- Modify: `src/extensions/image/node-view.vue:1295-1425`
|
|
39
|
+
- Verify: `src/extensions/image/node-view.vue`
|
|
40
|
+
|
|
41
|
+
**Interfaces:**
|
|
42
|
+
|
|
43
|
+
- Consumes: existing `onResize({ width, height })`, `onResizeStart()`, `onResizeEnd()`, `pendingResizeAttrs`, and `commitPendingResize(restoreSelection)`.
|
|
44
|
+
- Produces: reactive `resizePreviewSize: { width: number; height: number } | null`; `commitPendingResize(restoreSelection)` remains the single document-write path.
|
|
45
|
+
|
|
46
|
+
- [x] **Step 1: Reproduce the delayed commit in the browser**
|
|
47
|
+
|
|
48
|
+
Open a table image with a visible resize handle, keep the mouse button down while moving the handle, and inspect the editor document before release. On current code, expect the document width to remain unchanged until 1.2 seconds after release.
|
|
49
|
+
|
|
50
|
+
- [x] **Step 2: Add the local preview state**
|
|
51
|
+
|
|
52
|
+
Add `resizePreviewSize` as Vue-reactive state. Initialize it in `onResizeStart()` from pending dimensions or current attributes, update it in every `onResize()` call without dispatching a transaction, and clear it after commit or cancellation.
|
|
53
|
+
|
|
54
|
+
- [x] **Step 3: Render from preview state during the gesture**
|
|
55
|
+
|
|
56
|
+
Use `resizePreviewSize` for the image/dragger display width and height while `isImageResizing` is true. Keep the outer frame at `resizeStartSize` during the gesture so table layout does not continuously reflow.
|
|
57
|
+
|
|
58
|
+
- [x] **Step 4: Commit immediately from `resize-end`**
|
|
59
|
+
|
|
60
|
+
Remove `resizeCommitTimer` and the 1200ms timeout. Set `isImageResizing = false`, clear `resizeStartSize`, and call `commitPendingResize(true)` synchronously when final dimensions are pending.
|
|
61
|
+
|
|
62
|
+
- [x] **Step 5: Keep interruption safety**
|
|
63
|
+
|
|
64
|
+
Retain the selection-loss and editor-blur paths that call `commitPendingResize()` while a preview is pending, and clear the preview state on unmount.
|
|
65
|
+
|
|
66
|
+
- [x] **Step 6: Run static verification**
|
|
67
|
+
|
|
68
|
+
Run:
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
pnpm run typecheck
|
|
72
|
+
pnpm exec oxlint src/extensions/image/node-view.vue
|
|
73
|
+
pnpm exec stylelint "src/extensions/image/node-view.vue"
|
|
74
|
+
pnpm run test:style-target
|
|
75
|
+
git diff --check
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Expected: all commands exit 0.
|
|
79
|
+
|
|
80
|
+
- [x] **Step 7: Verify real pointer behavior**
|
|
81
|
+
|
|
82
|
+
In the browser, hold and move the bottom-right resize handle. Before release, confirm the rendered image dimensions change continuously while the editor document retains the starting width. After release, confirm the document stores the final width immediately. Repeat at least six shrink/enlarge gestures and verify stable table width, IDs, NodeView instance, and dragger count.
|
|
83
|
+
|
|
84
|
+
- [x] **Step 8: Commit** (skipped by ledger ruling: user requested code changes, not a Git commit)
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git add src/extensions/image/node-view.vue docs/superpowers/specs/2026-11-28-table-image-resize-preview-design.md docs/superpowers/plans/2026-11-28-table-image-resize-preview.md
|
|
88
|
+
git commit -m "fix: make table image resizing preview immediately"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Task 2: Preserve existing IDs during runtime updates
|
|
92
|
+
|
|
93
|
+
**Files:**
|
|
94
|
+
|
|
95
|
+
- Modify: `src/utils/html-element-id.ts`
|
|
96
|
+
- Test: `tests/style-schema.test.mjs`
|
|
97
|
+
|
|
98
|
+
**Interfaces:**
|
|
99
|
+
|
|
100
|
+
- Consumes: `ensureHtmlElementIds(state, ranges?)`.
|
|
101
|
+
- Produces: range-based calls preserve every non-empty existing ID and only generate IDs for missing values; no-range calls retain full duplicate normalization.
|
|
102
|
+
|
|
103
|
+
- [x] **Step 1: Write the failing regression test**
|
|
104
|
+
|
|
105
|
+
Create two runtime nodes with the same pre-existing business ID and assert a range-based normalization transaction is not created because runtime changes must not rewrite either ID.
|
|
106
|
+
|
|
107
|
+
- [x] **Step 2: Run the test to verify it fails**
|
|
108
|
+
|
|
109
|
+
Run: `node --test --test-name-pattern="runtime id normalization" tests/style-schema.test.mjs`
|
|
110
|
+
|
|
111
|
+
Expected before the fix: FAIL because the second existing ID is treated as a runtime duplicate and rewritten.
|
|
112
|
+
|
|
113
|
+
- [x] **Step 3: Preserve existing IDs in range-based normalization**
|
|
114
|
+
|
|
115
|
+
Pre-collect all existing IDs into the used-ID set, preserve every non-empty existing node/mark ID during range traversal, and generate values only for missing IDs.
|
|
116
|
+
|
|
117
|
+
- [x] **Step 4: Verify runtime and initial behavior**
|
|
118
|
+
|
|
119
|
+
Run: `node --test --test-name-pattern="runtime id normalization|real editor schema" tests/style-schema.test.mjs`
|
|
120
|
+
|
|
121
|
+
Expected: PASS; runtime IDs stay unchanged while full initial normalization still repairs duplicate IDs.
|