tiptap-extension-resizable-image
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

tiptap-extension-resizable-image

Pull request workflows NPM npm GitHub Repo stars

Links

Quickstart

Installation

npm install tiptap-extension-resizable-image

Import the CSS file:

import 'tiptap-extension-resizable-image/styles.css';

Add the extension to Tiptap:

import { useEditor, EditorContent } from '@tiptap/react';
import StarterKit from '@tiptap/starter-kit';
import { ResizableImage } from 'tiptap-extension-resizable-image';

const Demo = () => {
  const editor = useEditor({
    extensions: [StarterKit, ResizableImage],
    content: /* html */ `
      <p>
        <img
          src="https://daily.jstor.org/wp-content/uploads/2016/10/Moving_Forest_1050_700.jpg"
          alt="image alt"
          title="image title"
          width="300"
          data-keep-ratio="true"
        >
      </p>
    `,
  });

  return (
    <div>
      <EditorContent editor={editor} className='editor' />
    </div>
  );
};

export default Demo;

Commands

setResizableImage

editor.commands.setResizableImage({
  src: '',
  alt: '',
  title: '',
  width: 200,
  height: 200,
  className: '',
  'data-keep-ratio': true,
  caption: '',
});

License

The MIT License.

Package Sidebar

Install

npm i tiptap-extension-resizable-image

Weekly Downloads

224

Version

1.0.3

License

MIT

Unpacked Size

71.2 kB

Total Files

26

Last publish

Collaborators

  • hohieuluc