tiptap-extension-resize-image
Version:
A tiptap image resizing extension for React, Vue, Next, and VanillaJS. Additionally, it can align the image position.
45 lines (32 loc) • 1.61 kB
Markdown
# `tiptap-extension-resize-image`

[Tiptap](https://tiptap.dev/) 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](https://codesandbox.io/p/devbox/react-tiptap-image-extension-3ztv5s?file=%2Fsrc%2Ftiptap.tsx%3A5%2C26-5%2C55), [Vue](https://codesandbox.io/p/devbox/vue-tiptap-image-extension-tvxx62?file=%2Fsrc%2FTiptap.vue%3A9%2C1), and [NextJS](https://codesandbox.io/p/devbox/nextjs-tiptap-image-extension-nk6v7p?file=%2Fapp%2Ftiptap.tsx%3A17%2C1), and stability in VanillaJS may not be guaranteed. Additionally, it can align the image position.
## Installation
You can install it using npm:
```bash
$ npm install tiptap-extension-resize-image
```
## Usage
```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: `<img src="https://source.unsplash.com/8xznAGy4HcY/800x400" />`,
});
```
### Use as inline
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: `<img src="..."/>`,
});
```