基于 Editor.js 開發(fā)富文本編輯器庫

開始

Editor.js 提供了簡單而直觀的用戶界面,根據(jù)需求可以靈活添加自定義的編輯工具,通過插件擴(kuò)展功能

Editorjs 使用 js 開發(fā),脫離框架依賴,因此可以基于它封裝富文本編輯器,用于 Vue 和 React 項(xiàng)目

editor-js-component 是基于 Editorjs 封裝的庫,通過 monorepo 管理項(xiàng)目,不局限框架

Demo 示例

image.png

editor-js-component

editorjs-js-component 是基于 Editor.js 封裝的庫,不局限框架,可以用于 Vue 和 React 項(xiàng)目

安裝

# NPM
npm install --save editor-js-component

# or Yarn
yarn add editor-js-component

# or Pnpm
pnpm add editor-js-component

查看文檔,使用

import { useEditorjs } from 'editor-js-component'

// 執(zhí)行函數(shù)
const editorInstance = useEditorjs({
  ...
})


// 實(shí)例化編輯器,開啟執(zhí)行
editorInstance.start()

editorjs-component-vue

editorjs-component-vue 是基于 editor-js-component 封裝 Vue3 組件

文檔 查看使用

# NPM
npm install --save editorjs-component-vue

# or Yarn
yarn add editorjs-component-vue

# or Pnpm
pnpm add editorjs-component-vue

組件注冊(cè)

import { 
  EditorJsVue,
  EditorJsParser
} from 'editorjs-component-vue'

// or 全局注冊(cè)組件

const app = createApp()

app.use(EditorJsVue)

組件使用

<EditorJsVue
    class="editor-left"
    ref="editor"
    :data="data"
    :messages="i18nMessage"
    :initialized="onInitialized"
    :tool-config="toolConfig"
    @changeData="editorChange"
  />

插件

Editorjs 以模塊化的方式開發(fā),通過插件方式擴(kuò)展功能,如標(biāo)題、段落、列表、表格等

根據(jù) Editorjs 提供的 API 開發(fā)富文本插件功能

插件列表,可以開發(fā)滿足于自己的插件

  • header
  • list
  • code
  • inlineCode
  • personality
  • embed
  • linkTool
  • marker
  • table
  • raw
  • delimiter
  • quote
  • image
  • warning
  • paragraph
  • checklist

如果對(duì)富文本編輯器感興趣,歡迎加入

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容