@editorjs/personality

中文文档
2.0.2发布于 2020/09/06MITCommonJS零依赖近 30 天下载 3034

Personality tool for Editor.js

原始使用文档
文档目录9 节
  1. Features
  2. Get the package
  3. Install via NPM
  4. Download to your project's source dir
  5. Load from CDN
  6. Usage
  7. Config Params
  8. Output data
  9. Backend response format

Personality Tool

Personality Tool for the Editor.js.

Features

This tool allows you to create Personality block in your articles.

Note Tool requires server-side implementation for image uploading. See backend response format for more details.

Get the package

You can get the package using any of these ways.

Install via NPM

Get the package

npm i --save-dev @editorjs/personality

Include module at your application

const Personality = require('@editorjs/personality');

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/[email protected]

Then require this script on page with Editor.js through the <script src=""></script> tag.

Usage

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

var editor = EditorJS({
  ...

  tools: {
    ...
    personality: {
      class: Personality,
      config: {
        endpoint: 'http://localhost:8008/uploadFile'  // Your backend file uploader endpoint
      }
    }
  }

  ...
});

Config Params

Personality Tool supports these configuration parameters:

FieldTypeDescription
endpointstringRequired Endpoint for photo uploading.
fieldstring(default: image) Name of uploaded image field in POST request
typesstring(default: image/*) Mime-types of files that can be accepted with file selection.
namePlaceholderstring(default: Name) Placeholder for name field
descriptionPlaceholderstring(default: Description) Placeholder for description field
linkPlaceholderstring(default: Link) Link field placeholder

Output data

This Tool returns data with following format

FieldTypeDescription
namestringPerson's name
descriptionstringPerson's description
linkstringLink to person's website
photostringUploaded image url from backend.
{
    "type" : "personality",
    "data" : {
        "name" : "Elon Musk",
        "description" : "Elon Reeve Musk FRS is a technology entrepreneur, investor, and engineer. He holds South African, Canadian, and U.S. citizenship and is the founder",
        "link" : "https://twitter.com/elonmusk",
        "photo" : "https://capella.pics/3c0e1b97-bc56-4961-b54e-2a6c2c3260f2.jpg"
    }
}

Backend response format

This Tool works with uploading files from the device

Scenario:

  1. User select file from the device
  2. Tool sends it to your backend (on config.endpoint.byFile route)
  3. Your backend should save file and return file data with JSON at specified format.
  4. Personality tool shows saved image and stores server answer

So, you can implement backend for file saving by your own way. It is a specific and trivial task depending on your environment and stack.

Response of your uploader should cover following format:

{
    "success" : 1,
    "file": {
        "url" : "https://capella.pics/3c0e1b97-bc56-4961-b54e-2a6c2c3260f2.jpg"
    }
}

success - uploading status. 1 for successful, 0 for failed

file - uploaded file data. Must contain an url field with full public path to the uploaded image.

版本与发布记录

@editorjs/personality 共发布 3 个版本,首次发布于 2019/07/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.2latest2020/09/066 年前
2.0.12019/07/277 年前
2.0.02019/07/187 年前

关于 @editorjs/personality 的常见问题

@editorjs/personality 是什么?

Personality tool for Editor.js

如何安装 @editorjs/personality?

在项目目录运行 npm install @editorjs/personality,或使用 pnpm add / yarn add / bun add。

@editorjs/personality 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/editorjs__personality 是否存在。

@editorjs/personality 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@editorjs/personality 可以商用吗?

@editorjs/personality 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@editorjs/personality 的下载量有多少?

根据 npm 官方下载统计,@editorjs/personality 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,034 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@editorjs/personality 还在维护吗?

最新版本 2.0.2 发布于 2020/09/06(6 年前);至今共发布 3 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/07/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。