1.0.2 • Published 12 months ago

@coolbytes/editorjs-image v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Image block tool for Editor.js

This Editor.js block tool allows you to add images. This implementation is directly taken from the Editor.js Docs.

Preview

Block Tool

image

Block Settings

settings

Installation

Using npm

npm install @coolbytes/editorjs-image

Using yarn

yarn add @coolbytes/editorjs-image

Usage

Include it in the tools property of Editor.js config:

const editor = new EditorJS({
  tools: {
    image: Image
  }
});

Config Params

FieldTypeOptionalDefaultDescription
imageAltstringYespictureAlternate text for images
enableCaptionbooleanYesfalseFlag to enable image caption
captionPlaceholderstringYesEnter a captionPlaceholder text for image caption

Custom Configuration

const editor = EditorJS({
  tools: {
    image: {
      class: Image,
      inlineToolbar: true,
      config: {
        enableCaption: true,
        captionPlaceholder: 'Enter a caption'
      }
    }
  }
});

Output data

FieldTypeDescription
urlstringImage src URL
captionstringImage caption
withBorderbooleanIndicates if image border is added
withBackgroundbooleanIndicates if image background is added
stretchedbooleanIndicates if image is stretched

 

Example:

{
  "time": 1715969561758,
  "blocks": [
    {
      "id": "_K5QcJHHuK",
      "type": "image",
      "data": {
        "url": "https://cdn.pixabay.com/photo/2017/09/01/21/53/blue-2705642_1280.jpg",
        "caption": "Source: Editor.js",
        "withBorder": true,
        "stretched": true,
        "withBackground": false
      }
    }
  ],
  "version": "2.29.1"
}
1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago