0.1.1 • Published 3 years ago

editorjs-wquote v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm.io

WordQuote Tool

Provides WordQuote Blocks for the Editor.js.

npm.io

Installation

Install via NPM

Get the package

npm i --save-dev @editorjs/wquote

Include module at your application

const WordQuote = require('@editorjs/wquote');

Download to your project's source dir

  1. Upload folder dist from repository
  2. Add dist/bundle.js file to your page.

Load from CDN

You can load specific version of package from jsDelivr CDN.

https://cdn.jsdelivr.net/npm/@editorjs/wquote@latest

Then require this script on page with Editor.js.

<script src="..."></script>

Usage

Add a new Tool to the tools property of the Editor.js initial config.

var editor = EditorJS({
  ...
  
  tools: {
    ...
    wquote: WordQuote,
  },
  
  ...
});

Or init WordQuote Tool with additional settings

var editor = EditorJS({
  ...
  
  tools: {
    ...
    wquote: {
      class: WordQuote,
      inlineToolbar: true,
      shortcut: 'CMD+SHIFT+O',
      config: {
        wquotePlaceholder: 'Enter a wquote',
        captionPlaceholder: 'WordQuote\'s author',
      },
    },
  },
  
  ...
});

Config Params

FieldTypeDescription
wquotePlaceholderstringwquote's placeholder string
captionPlaceholderstringcaption's placeholder string

Tool's settings

npm.io

You can choose alignment for the wquote. It takes no effect while editing, but saved the «alignment» param.

Output data

FieldTypeDescription
textstringwquote's text
captionstringcaption or an author
alignmentstringleft or center
{
    "type" : "wquote",
    "data" : {
        "text" : "The unexamined life is not worth living.",
        "caption" : "Socrates",
        "alignment" : "left"
    }
}