0.2.0 • Published 3 years ago

@mrpritchett/editorjs-mentions v0.2.0

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

Mentions

Allows searching of a user API in order to add mentions to an EditorJS instance.

Installation

Install via NPM

Get the package

npm i --save-dev @mrpritchett/editorjs-mentions

Load from CDN

You can use package from jsDelivr CDN.

<script src="https://cdn.jsdelivr.net/npm/@mrpritchett/editorjs-mentions"></script>

Usage

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

var editor = EditorJS({
  ...

  /**
   * Tools list
   */
  tools: {
    mention: {
      class: MentionTool,
      config: {
        endpoint: 'http://localhost:3000/',
        queryParam: 'search'
      }
    }
  },

  ...
});

Config Params

Search requests will be sent to the server by GET requests with a search string as a query param.

List of server connection params which may be configured.

endpoint — URL of the server's endpoint for getting suggestions.

queryParam — param name to be sent with the search string.

Server response data format

For endpoint requests server should answer with a JSON containing following properties:

  • success (boolean) — state of processing: true or false
  • items ({name: string, profile_photo?: string}) — an array of found items. Each item must contain name param. The profile_photoparam is optional. You can also return any other fields which will be stored in a link dataset.

Content-Type: application/json.

{
  "success": true,
  "items": [
    {
      "profile_photo": "http://placehold.it/300x200",
      "name": "John Doe",
    },
    {
      "href": "http://placehold.it/300x200",
      "name": "Jane Doe",
    }
  ]
}

Output data

Marked text will be wrapped with a span tag.

Additional data will be store in element's dataset: data-name, data-profile_photo and other custom fields.

{
    "type" : "text",
    "data" : {
        "text" : "Create a directory for your module, enter it and run <a href=\"https://codex.so/\" data-name=\"CodeX Site\">npm init</a> command."
    }
}

Shortcut

By default, shortcut CMD (CTRL) + 2 is used for pasting links as usual.

0.2.0

3 years ago

0.1.39

3 years ago

0.1.38

3 years ago

0.1.37

3 years ago

0.1.36

3 years ago

0.1.35

3 years ago

0.1.34

3 years ago

0.1.33

3 years ago

0.1.32

3 years ago

0.1.31

3 years ago

0.1.30

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.26

3 years ago

0.1.25

3 years ago

0.1.24

3 years ago

0.1.23

3 years ago

0.1.22

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago