1.2.0 • Published 2 years ago

ckeditor5-image-remove-event-callback-plugin v1.2.0

Weekly downloads
6
License
MIT
Repository
github
Last release
2 years ago

npm Downloads

CKEditor 5 Image Remove Event Callback Plugin

Handle image remove event callback from CKEditor 5

Usage:

Install package

npm install ckeditor5-image-remove-event-callback-plugin -D

Use in Build

// app.js
// ...
import ImageRemoveEventCallbackPlugin from 'ckeditor5-image-remove-event-callback-plugin'; // Add this
// ...

ClassicEditor.builtinPlugins = [
    // ...
    ImageRemoveEventCallbackPlugin
    // ...

]

Use in CKEditor 5 initialization

ClassicEditor.create(document.querySelector('#editor'), {
    //... 
    imageRemoveEvent: {
        additionalElementTypes: null, // Add additional element types to invoke callback events. Default is null and it's not required. Already included ['image','imageBlock','inlineImage']
        // additionalElementTypes: ['image', 'imageBlock', 'inlineImage'], // Demo to write additional element types
        callback: (imagesSrc, nodeObjects) => {
            // note: imagesSrc is array of src & nodeObjects is array of nodeObject
            // node object api: https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_model_node-Node.html

            console.log('callback called', imagesSrc, nodeObjects)
        }
    },
    // ...
});

Note: There is a demo project for using this plugin in demo folder.