A tiptap image resizing extension for React, Vue, Next, and VanillaJS. Additionally, it can align the image position.
npm install tiptap-extension-resize-imagetiptap-extension-resize-image



!tiptap-extension-resize-image
Tiptap is a suite of open source content editing and real-time collaboration tools for developers building apps like Notion or Google Docs.
This package provides the ability to adjust the size of the tip tab image. It has been tested in React, Vue, and NextJS, and stability in VanillaJS may not be guaranteed. Additionally, it can align the image position.
| tiptap-extension-resize-image | Supported TipTap Versions |
| ----------------------------- | ------------------------- |
| ≤ 1.2.2 | v2 only |
| ≥ 1.2.3 | v2 and v3 |
You can install it using npm:
``bash`
$ npm install tiptap-extension-resize-image
`javascript
import StarterKit from '@tiptap/starter-kit';
import ImageResize from 'tiptap-extension-resize-image';
import { EditorContent, useEditor } from '@tiptap/react';
const editor = useEditor({
extensions: [StarterKit, ImageResize],
content: ,`
});
If you want to render images as inline elements, you can configure the extension like this:
`javascript
const editor = useEditor({
extensions: [
StarterKit,
ImageResize.configure({
inline: true,
}),
],
content: ,`
});
You can set minimum and maximum width constraints to limit how small or large images can be resized:
`javascript
const editor = useEditor({
extensions: [
StarterKit,
ImageResize.configure({
minWidth: 100, // Minimum width in pixels
maxWidth: 800, // Maximum width in pixels
}),
],
content: ,`
});
Both minWidth and maxWidth are optional. You can set one, both, or neither:
`javascript
// Only set a minimum width
ImageResize.configure({ minWidth: 50 });
// Only set a maximum width
ImageResize.configure({ maxWidth: 1200 });
// Set both constraints
ImageResize.configure({ minWidth: 100, maxWidth: 800 });
`
| Option | Type | Default | Description |
| ---------- | --------- | ----------- | ----------------------------------------------- |
| inline | boolean | false | Render images as inline elements |minWidth
| | number | undefined | Minimum width in pixels (cannot resize smaller) |maxWidth
| | number | undefined` | Maximum width in pixels (cannot resize larger) |
Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.