Code Monkey home page Code Monkey logo

ckeditor5-upload-adapter's Introduction

ckeditor5-upload-adapter

The upload adapter plugin for ckeditor5.

Quick start

First, install the build from npm:

pnpm i @rickx/ckeditor5-upload-adapter
# or
yarn add @rickx/ckeditor5-upload-adapter
# or
npm i @rickx/ckeditor5-upload-adapter

Use ImageUploadAdapter in your application:

import { ImageUploadAdapter } from '@rickx/ckeditor5-upload-adapter'

Add ImageUploadAdapter to your editor:

ClassicEditor
  .create(document.querySelector('#editor'), {
    plugins: [
      /* ..., */
      ImageUploadAdapter, // add it to your plugins array
    ],
    imageUpload: {
      // The URL that the images are uploaded to.
      uploadUrl: 'http://example.com',
      // Enable the XMLHttpRequest.withCredentials property.
      withCredentials: true,
      // Headers sent along with the XMLHttpRequest to the upload server.
      headers: {
        'X-CSRF-TOKEN': 'CSRF-Token',
        'Authorization': 'Bearer <JSON Web Token>',
      },
      // Params sent along with the XMLHttpRequest to the upload server.
      params: {
        foo: 'bar',
        text: new Blob(['Another text'], { type: 'text/plain' })
      }
    },
  })
  .then(/* ... */)
  .catch(/* ... */)

Use CustomUploadAdapter in your application:

import { CustomUploadAdapter } from '@rickx/ckeditor5-upload-adapter'

Add CustomUploadAdapter to your editor:

ClassicEditor
  .create(document.querySelector('#editor'), {
    plugins: [
      /* ..., */
      CustomUploadAdapter, // add it to your plugins array
    ],
    customUpload: {
      onUpload: (file) => {
        return Promise.resolve('http://server/default-size.image.png')
      },
      onAbort: () => {
        console.log('Upload abort')
      }
    }
  })
  .then(/* ... */)
  .catch(/* ... */)

License

Licensed under the terms of GNU General Public License Version 2 or later.

ckeditor5-upload-adapter's People

Contributors

rickx81 avatar

Watchers

 avatar

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.