JSPM

tiptap-extension-image

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 76
  • Score
    100M100P100Q70844F
  • License ISC

Make tiptap support image tags to provide predefined styles for img.

Package Exports

  • tiptap-extension-image
  • tiptap-extension-image/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tiptap-extension-image) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tiptap-extension-image

Make tiptap support image tags to provide predefined styles for img.


NPM URL version



Install

npm install tiptap-extension-image -S

Usage

import Image from "tiptap-extension-image";

const editor = new Editor({
  element: document.querySelector(".editor"),
  extensions: [
    StarterKit,
    Image.configure({ inline: true, allowBase64: true })
  ],
});

editor
  .chain()
  .focus()
  .setImage({
    src: dataString,
  })
  .run();

Supports the presence of the style attribute of the inserted img as baseStyle.

const html = `<img style="width: 100%; display: inline-block" src="/88f84b8.png"/>`

editor
  .chain()
  .focus()
  .insertContent(html, {
    parseOptions: {
      preserveWhitespace: false,
    },
  })
  .run();
// baseStyle: "width: 100%; display: inline-block"

Relations

@tiptap/extension-image: https://github.com/ueberdosis/tiptap/tree/develop/packages/extension-image

tiptap-appmsg-editor: https://github.com/KID-1912/tiptap-appmsg-editor