@agilehub/agile-editor 1.8.5 → 1.9.0

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 (37) hide show
  1. package/dist/agile-editor.css +1 -1
  2. package/dist/agile-editor.js +31160 -14002
  3. package/dist/{i18n-DZxiNlPY.js → i18n-CChALhQN.js} +36 -2
  4. package/dist/types/components/editor/table-background-control.vue.d.ts +1 -1
  5. package/dist/types/components/index.vue.d.ts +55 -4
  6. package/dist/types/components/menus/bubble/menus.vue.d.ts +2 -2
  7. package/dist/types/components/menus/toolbar/insert/emoji.vue.d.ts +3 -0
  8. package/dist/types/components/picker/color-panel.vue.d.ts +37 -0
  9. package/dist/types/components/picker/color.vue.d.ts +9 -0
  10. package/dist/types/components/preview-toolbar/drawing-layer.vue.d.ts +1 -1
  11. package/dist/types/components/statusbar/countdown.vue.d.ts +2 -2
  12. package/dist/types/composables/i18n.d.ts +51 -0
  13. package/dist/types/extensions/bubble-note-extensions.d.ts +1 -1
  14. package/dist/types/i18n.d.ts +51 -0
  15. package/dist/types/options/config/dicts.d.ts +8 -1
  16. package/dist/types/options/config/emojis.d.ts +15 -0
  17. package/dist/types/options/config/index.d.ts +8 -1
  18. package/dist/types/utils/emoji-search.d.ts +21 -0
  19. package/dist/types/utils/player.d.ts +12 -4
  20. package/dist/types/utils/video-frame.d.ts +1 -0
  21. package/dist/types/utils/video-skin.d.ts +1 -0
  22. package/dist/{viewer-DWO1FZ3A.js → viewer-Cv5V0Gjs.js} +2 -2
  23. package/docs/FORMATTING_TEMPLATES.md +253 -253
  24. package/docs/FORMATTING_TEMPLATE_BUSINESS_GUIDE.md +536 -536
  25. package/docs/SECONDARY_DEVELOPMENT.md +799 -799
  26. package/docs/features.md +1 -1
  27. package/docs/superpowers/plans/2026-11-27-table-reset-controls.md +185 -185
  28. package/docs/superpowers/plans/2026-11-28-bubble-note-rich-content.md +101 -101
  29. package/docs/superpowers/plans/2026-11-28-image-replace.md +190 -190
  30. package/docs/superpowers/plans/2026-11-28-table-image-resize-preview.md +121 -121
  31. package/docs/superpowers/plans/2026-11-28-table-property-category-actions.md +192 -192
  32. package/docs/superpowers/specs/2026-11-27-table-reset-controls-design.md +66 -66
  33. package/docs/superpowers/specs/2026-11-28-bubble-note-rich-content-design.md +64 -64
  34. package/docs/superpowers/specs/2026-11-28-image-replace-design.md +40 -40
  35. package/docs/superpowers/specs/2026-11-28-table-image-resize-preview-design.md +30 -30
  36. package/docs/superpowers/specs/2026-11-28-table-property-category-actions-design.md +63 -63
  37. package/package.json +165 -165
@@ -1,190 +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
- ```
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
+ ```
@@ -1,121 +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.
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.