mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-05 04:19:07 +08:00
1.8 KiB
1.8 KiB
description | icon |
---|---|
Add an image (but a beautiful one), when words aren’t enough. | image-line |
Image
Use this extension to render <img>
HTML tags. By default, those images are blocks. If you want to render images in line with text set the inline
option to true
.
:::warning Restrictions This extension does only the rendering of images. It doesn’t upload images to your server, that’s a whole different story. :::
Installation
# with npm
npm install @tiptap/extension-image
# with Yarn
yarn add @tiptap/extension-image
Settings
HTMLAttributes
Custom HTML attributes that should be added to the rendered HTML tag.
Image.configure({
HTMLAttributes: {
class: 'my-custom-class',
},
})
inline
Renders the image node inline, for example in a paragraph tag: <p><img src="spacer.gif"></p>
. By default images are on the same level as paragraphs.
It totally depends on what kind of editing experience you’d like to have, but can be useful if you (for example) migrate from Quill to tiptap.
Default: false
Image.configure({
inline: true,
})
Commands
setImage()
Makes the current node an image.
editor.commands.setImage({ src: 'https://example.com/foobar.png')
editor.commands.setImage({ src: 'https://example.com/foobar.png', alt: 'A boring example image', title: 'An example' })