Skip to content

Inline 按需拼装

Inline Editor 没有 preset 层,默认工具栏类似评论输入框:

ts
{
  undoRedo: true,
  textFormat: true,
  link: true,
}

精细控制时传入 toolbar

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

工具栏配置同时也是 Inline 扩展注册的能力来源。例如 toolbar.link !== true 表示隐藏链接按钮且不注册链接扩展。

也可以自行组装 inline shell:

ts
import { buildExtensions, resolveInlineGates, CAPABILITIES } from "@yanivjs/yaniv-editor/inline";

const toolbar = { undoRedo: true, textFormat: true, link: true };
const gates = resolveInlineGates(toolbar, CAPABILITIES);

const extensions = await buildExtensions("inline", {
  gates,
  locale: {
    /* resolved locale messages */
  },
  isEditable: () => true,
});

buildExtensionsresolveInlineGates 是 Inline 扩展注册的唯一来源。请勿使用已移除的 buildInlineExtensionsresolveInlineExtensionGates API。