Block Editor: Enable TipTap native image resize
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Description
Enable image resizing in the Block Editor (libs/new-block-editor) using the resize support built into @tiptap/extension-image.
Laura raised this as feedback: content authors currently have no way to change an image's displayed size from inside the editor. The only layout controls available today are textWrap (left/right) and textAlign (left/center/right), both written as <figure> classes by DotImage.
Reference: https://tiptap.dev/docs/editor/extensions/nodes/image#resize
⚠️ Blocked on product approval. The behavior is agreed technically but has not been signed off by Product. Do not start implementation until approval is recorded on this issue.
Current state (verified)
@tiptap/extension-image@3.22.2 — already the installed version — exposes resize natively:
resize: {
enabled: boolean;
directions?: ResizableNodeViewDirection[];
minWidth?: number;
minHeight?: number;
alwaysPreserveAspectRatio?: boolean;
} | false; // default: false
The parent extension also already declares width / height node attributes and accepts them in setImage(), so DotImage's ...this.parent?.() spread picks them up for free.
Known technical constraint
DotImage overrides addNodeView() in core-web/libs/new-block-editor/src/lib/editor/extensions/nodes/image.extension.ts to build the <figure> / <a> / <img> wrapper by hand. TipTap's resize handles are provided by the parent's own resizable node view, which that override replaces — so simply setting resize: { enabled: true } will not surface handles until the custom node view is reworked to compose with the resizable node view (or to render the handles itself).
This is the main implementation cost of the ticket and should be scoped before committing to a sprint.
Files in scope
| File | Change |
|---|---|
core-web/libs/new-block-editor/src/lib/editor/extensions/nodes/image.extension.ts |
Enable resize, rework addNodeView() to keep handles, persist width/height |
dotCMS/src/main/webapp/WEB-INF/velocity/static/storyblock/dotImage.vtl |
Emit width/height on <img> |
core-web/libs/sdk/** (React, Vue, Angular ×2) |
Emit width/height on <img> |
core-web/libs/sdk/types/src/lib/components/block-editor-renderer/internal.ts |
Add width/height to the image attrs type |
Acceptance Criteria
Preconditions
- Product approval for the resize behavior is recorded as a comment on this issue before implementation starts
Happy path
- Selecting an image in the Block Editor shows TipTap resize handles on the image
- Dragging a resize handle changes the image's rendered size live in the editor
- Releasing a resize handle persists the resulting
widthandheightas attributes on thedotImagenode - Reopening the contentlet renders the image at the persisted size, not at its intrinsic size
Rendering parity
- A resized image renders at the persisted size through the VTL renderer (
dotImage.vtl) - A resized image renders at the persisted size through the React, Vue, and both Angular SDK block renderers
Interaction with existing layout attrs
- Resizing an image that has
textWrapset keeps theimage-wrap-left/image-wrap-rightfigure class intact - Resizing an image that has
textAlignset keeps theimage-align-*figure class intact - Resizing an image wrapped in a link (
hrefset) does not break the anchor or the node-selection fix from #36361
Edge cases
- Resizing below the configured
minWidth/minHeightclamps to the minimum instead of collapsing the image - Existing stored content with no
width/heightattributes renders unchanged (no regression)
Tests
- Unit specs in
libs/new-block-editor/cover: resize persists width/height, minimum clamping, and layout-attr preservation
Priority
Medium
Additional Context
- Scope is
libs/new-block-editoronly. The legacylibs/block-editoris not in scope. - Related: caption field work (#37496) touches the same node and the same set of renderers — coordinate to avoid conflicting edits to
image.extension.tsanddotImage.vtl.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Wait for Product approval before starting. Then inspect core-web/libs/new-block-editor/src/lib/editor/extensions/nodes/image.extension.ts, especially addNodeView(), and review the unit specs in libs/new-block-editor/. Update the VTL and React, Vue, and Angular renderers plus the image attrs type so persisted width and height survive resizing while existing layout and link behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, react, typescript
- Domain
- content, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100