The `prosemirror-resizable-view` package provides a specialized `NodeView` implementation for ProseMirror that enables users to resize custom nodes directly within the editor interface. It is an integral part of the broader Remirror ecosystem and currently aligns with Remirror's stable version 3.0.0. This package itself is at version 3.0.0, benefiting from the active development cadence of the Remirror project, which includes regular patch releases for bug fixes and dependency updates. Its primary differentiator lies in abstracting the complexities of implementing resizable DOM elements within a ProseMirror `NodeView`, offering a convenient base class that handles drag events and dimension management. This significantly simplifies the development process for integrating dynamic resize functionality for various content types like images, video embeds, or custom block components. The package comes with comprehensive TypeScript type definitions, enhancing developer experience and code safety.
npm install prosemirror-resizable-viewVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic ProseMirror editor with a custom `image` node, then renders this node using `ResizableImageView` to allow users to resize images within the editor. It includes schema definition, `ResizableNodeView` extension, and editor setup.
Ensure your TypeScript configuration (`tsconfig.json`) is set to support Stage 3 decorators (e.g., `"experimentalDecorators": true` and `"emitDecoratorMetadata": true` if using decorators with reflection, and potentially `"target": "es2020"` or higher).
Check the `peerDependencies` of `prosemirror-resizable-view` (or the wider Remirror ecosystem) and ensure your direct `prosemirror-*` dependencies match the specified ranges to avoid runtime errors or unexpected behavior due to API mismatches.
Always reflect size changes in the ProseMirror node's attributes and dispatch a transaction using `view.dispatch(view.state.tr.setNodeMarkup(...))` within the `updateSize` callback of `ResizableNodeView` or similar methods.
Create a subclass that extends `ResizableNodeView` and explicitly implements the `createElement(props: { node: ProsemirrorNode; view: EditorView; })` method to return an `HTMLElement` for your node view.Ensure that the CSS for your resizable node view and its handles is correctly applied to make the resize controls interactive. Refer to the package's documentation or examples for recommended styling approaches, or use development tools to inspect event listeners.
Ensure your `ResizableNodeView` subclass implements an `update(node: ProsemirrorNode)` method that appropriately handles attribute changes and returns `true` if it can update the DOM in place, or `false` if ProseMirror should redraw the node view entirely.
Verify that your `ResizableNodeView` subclass's `createElement` method always returns a valid `HTMLElement`, and that the `dom` property of the `NodeView` instance is correctly assigned to this element.
Inspect the CSS of the resize handles to ensure `pointer-events` are not set to `none` (unless intended) and that they are positioned above other elements. Double-check that event listeners for resizing are correctly bound to the resize handle elements.