Giter VIP home page Giter VIP logo

prosemirror-image-uploader's Introduction

prosemirror-image-uploader

The necessary image uploader for prosemirror based editors like (tiptap, remirror).

Features ๐ŸŽ‰

  • โœ… Image drop handling
  • โœ… Image paste handling
  • โœ… <img> tag insertion handling
  • โœ… Typescript definitions
  • โœ… Collaboration/undo history friendly
  • โœ… No widgets/decorations

Installation ๐Ÿ“ฆ

npm i prosemirror-image-uploader

Basic Usage ๐Ÿ“Œ

In your code, register the image upload plugin with the required upload function.

import { imageUploader } from 'prosemirror-image-uploader'

EditorState.create({
  plugins: [
    imageUploader({
      async upload(fileOrUrl: File | string, view: EditorView) {

        let url: string /// await uploadFileOrUrlToServerAndObtainUrl()

        return url
      }
    })
  ]
})

Also adjust your image node to accept 2 attributes, a boolean error, and a string uploadId:

{
  image: {
    attrs: {
      src: {},
      alt: { default: null },
      title: { default: null },
      uploadId: { default: null }, /// added
      error: { default: null }   /// added
    },
    parseDOM: [{tag: 'img[src]', getAttrs(dom) {
      return {
        src: dom.getAttribute('src'),
        title: dom.getAttribute('title'),
        alt: dom.getAttribute('alt'),
        uploadId: dom.getAttribute('uploadId'), /// added
        error: dom.getAttribute('error') /// added
      }
    }}],
    toDOM(node) { 
      let { src, alt, title, uploadId, error } = node.attrs;  /// updated
      return ['img', { src, alt, title, uploadId, error }] /// updated
    }
  },
}

Approach ๐Ÿ“š

Google Docs like approach is pursued. More coming soon...

Guide ๐Ÿ”ญ

Coming soon...

Caveats

Coming soon...

Examples

Coming soon...

Credits

Love our work?

Hit the star button. It helps โค๏ธ

License

The MIT License (MIT). Please see License File for more information.

prosemirror-image-uploader's People

Contributors

orkhanalikhanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

prosemirror-image-uploader's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.