0.1.1 • Published 2 years ago

@lukegreaves/editorjs-custom-templates v0.1.1

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

Airtable Headers for EditorJS with React

Allows searching of Airtable headers (Airtable API) that can be added an EditorJS instance.

The ideal us case for this library would be for building a CMS that needs to reference Airtable data.

Installation

Install via NPM

Get the package

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

Usage

import AirtableHeaders from '@lukegreaves/editorjs-airtable-headers'

export const ContentEditorTools = {
    airtableHeaders: {
        class: AirtableHeaders,
        config: {
          endpoint: 'http://localhost:5500/api/team/airtable/headers/events',
          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.1.1

2 years ago

0.1.0

2 years ago