@editorjs/link

中文文档
2.6.2发布于 2023/11/10MITESM + CJS近 30 天下载 22.3万

Link Tool for Editor.js

原始使用文档
文档目录6 节
  1. Features
  2. Installation
  3. Usage
  4. Config Params
  5. Output data
  6. Backend response format

Link Tool

Link Block for the Editor.js.

Features

Allows adding link previews to your articles.

Note: this Tool requires server-side implementation for link data fetching. See backend response format for more details.

Installation

Get the package

yarn add @editorjs/link

Include module at your application

import LinkTool from '@editorjs/link';

Optionally, you can load this tool from CDN JsDelivr CDN

Usage

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

const editor = EditorJS({
  ...

  tools: {
    ...
    linkTool: {
      class: LinkTool,
      config: {
        endpoint: 'http://localhost:8008/fetchUrl', // Your backend endpoint for url data fetching,
      }
    }
  },

  ...
});

Config Params

Link Tool supports these configuration parameters:

FieldTypeDescription
endpointstringRequired: the endpoint for link data fetching.
headersobjectOptional: the headers used in the GET request.

Output data

This Tool returns data with following format

FieldTypeDescription
linkstringPasted link's url
metaobjectFetched link's data. Any data got from the backend. Currently, the plugin's design supports the 'title', 'image', and 'description' fields.
{
    "type" : "linkTool",
    "data" : {
        "link" : "https://codex.so",
        "meta" : {
            "title" : "CodeX Team",
            "site_name" : "CodeX",
            "description" : "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
            "image" : {
                "url" : "https://codex.so/public/app/img/meta_img.png"
            }
        }
    }
}

Backend response format

You can implement a backend for link data fetching your own way. It is a specific and trivial task depending on your environment and stack.

Backend response should cover following format:

{
    "success" : 1,
    "link": "https://codex.so", // Optionally return a link to set the hyperlink URL
    "meta": {
        // ... any fields you want
    }
}

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

link - Optional response parameter to override the URL provided

meta — link fetched data.

Currently, the plugin's design supports the 'title', 'image', and 'description' fields. They should have the following format in the response:

{
    "success" : 1,
    "meta": {
        "title" : "CodeX Team",
        "description" : "Club of web-development, design and marketing. We build team learning how to build full-valued projects on the world market.",
        "image" : {
            "url" : "https://codex.so/public/app/img/meta_img.png"
        }
    }
}

Also, it can contain any additional fields you want to store.

About CodeX

CodeX is a team of digital specialists around the world interested in building high-quality open source products on a global market. We are open for young people who want to constantly improve their skills and grow professionally with experiments in cutting-edge technologies.

🌐Join 👋TwitterInstagram
codex.socodex.so/join@codex_team@codex_team

版本与发布记录

@editorjs/link 共发布 15 个版本,首次发布于 2019/03/02;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.6.2latest2023/11/103 年前
2.6.12023/11/083 年前
2.6.02023/11/083 年前
2.5.02022/11/303 年前
2.4.22022/10/244 年前
2.4.12022/04/224 年前

关于 @editorjs/link 的常见问题

@editorjs/link 是什么?

Link Tool for Editor.js

如何安装 @editorjs/link?

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

@editorjs/link 支持 TypeScript 吗?

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

@editorjs/link 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@editorjs/link 可以商用吗?

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

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

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

@editorjs/link 还在维护吗?

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