Skip to content

YanivInlineEditor API

导入

ts
import { YanivInlineEditor } from "@yanivjs/yaniv-editor/inline";
import "@yanivjs/yaniv-editor/inline.css";

Props

Prop类型默认值说明
contentstring"<p></p>"HTML 内容,支持 v-model:content
mode"edit" | "preview""edit"运行状态
colorMode"light" | "dark" | "auto""light"颜色模式
toolbarInlineToolbarConfig撤销/重做 + 文本格式 + 链接工具栏控件
placeholderstring空段落提示
extraExtensionsAnyExtension[][]额外 Tiptap 扩展
editorPropsRecord<string, unknown>Tiptap editor props
localestring"zh-CN"语言代码
zIndexBasenumber1000浮层 z-index 基准;不触发 session 重建

placeholderextraExtensions 变化会更新 sessionKey 并触发 session 重建(内容会快照保留)。

浮层挂载与 token 详见 Z-Index 与浮层

示例

vue
<YanivInlineEditor v-model:content="html" mode="edit" />
<YanivInlineEditor :content="html" mode="preview" color-mode="auto" />

自定义工具栏:

vue
<YanivInlineEditor
  v-model:content="html"
  :toolbar="{ undoRedo: true, textFormat: true, link: true, list: true }"
/>

mode="preview" 时不渲染内置工具栏和自定义工具栏 slot。内容仍可选择,链接保持正常文档链接行为。

高级导出

inline 入口还导出用于自定义 inline shell 的构建块:

ts
import {
  InlineToolbar,
  UndoRedoButton,
  LinkButton,
  buildExtensions,
  resolveInlineGates,
  resolveShowInlineToolbar,
  CAPABILITIES,
  provideYanivEditor,
  useYanivEditor,
} from "@yanivjs/yaniv-editor/inline";

完整自定义 shell 示例见 Inline 按需拼装