Skip to content

文本编辑

双击文本进入编辑状态,需要先安装 图形编辑器 插件。

适用平台

目前仅 web 平台支持。

安装插件

需要安装 text-editor 插件才能使用。

sh
npm install @leafer-in/text-editor
sh
pnpm add @leafer-in/text-editor
sh
bun add @leafer-in/text-editor

通过 script 标签引入

通过全局变量 LeaferIN.textEditor 访问插件内部功能。

html
<script src="https://unpkg.com/@leafer-in/text-editor@1.0.2/dist/text-editor.min.js"></script>
<script>
  const { TextEditor } = LeaferIN.textEditor
</script>
html
<script src="https://unpkg.com/@leafer-in/text-editor@1.0.2/dist/text-editor.js"></script>
<script>
  const { TextEditor } = LeaferIN.textEditor
</script>

https://unpkg.com 无法访问时,可替换为 https://cdn.jsdelivr.net/npm

开始体验

ts
import { App, Text } from 'leafer-ui'
import '@leafer-in/editor'
import '@leafer-in/text-editor'

const app = new App({
    view: window,
    editor: {}
})

app.tree.add(Text.one({
    text: 'Action is the proper fruit of knowledge.',
    editable: true, fill: '#FFE04B', fontSize: 16,
}, 100, 100, 100))

下一步

TextEditor 工具

Released under the MIT License.