@haklex/rich-ext-poll
读取/ 投出部件扩展名 。 单选或多选投票,可选的贴近时间和结果可视性政策为Haklex富编辑.
安装
pnpm add @haklex/rich-ext-poll
同伴依赖关系
| 软件包 | 版本 |
|---|---|
@haklex/rich-editor | 工作空间 |
@haklex/rich-editor-ui | 工作空间 |
lexical | ^0.45.0 |
lucide-react | ^1.0.0 |
react | >=19 |
使用量
注册节点
编辑器( 读 + 写) :
import { pollEditNodes } from '@haklex/rich-ext-poll/edit';
const editorConfig = { nodes: [...pollEditNodes] };
静态/ 只读 :
import { pollNodes } from '@haklex/rich-ext-poll/node';
const staticConfig = { nodes: [...pollNodes] };
提供数据适配器
制片人读取计票结果,通过 PollDataAdapter。用 PollDataProvider数字 :
import { PollDataProvider } from '@haklex/rich-ext-poll/renderer';
<PollDataProvider adapter={myAdapter} initialStates={initial}>
<RichRenderer value={state} />
</PollDataProvider>;
没有适配器,渲染器会倒回静态只读显示.
为安全部门改革提取民意测验元数据
import { extractPolls } from '@haklex/rich-ext-poll/node';
const polls = extractPolls(serializedEditorState);
显示默认渲染器
默认 PollRenderer 实值 没有 静态导入 PollNode。为了不包含在你的捆绑中,只登记 pollNodes 并且通过 RendererConfig数字 :
import { POLL_NODE_KEY, pollNodes } from '@haklex/rich-ext-poll/node';
import type { RichRendererModule } from '@haklex/rich-compose';
const lightPollModule: RichRendererModule = {
name: 'poll',
nodes: pollNodes,
renderers: { [POLL_NODE_KEY]: MyLightPollRenderer },
};
@haklex/rich-compose 船舶a pollModule 懒惰地装入默认的渲染器 lazyRenderers; 将上面的模块导入,而将重的默认块完全关闭.
导入样式
import '@haklex/rich-ext-poll/style.css';
出口
节点
| 导出 | 说明 |
|---|---|
PollNode | 静态( 只读) 民意调查节点 |
PollEditNode | 使用交互式 UI 编辑- mode 民调节点 |
$createPollNode() 编号 : $isPollNode() | 语法助手 |
pollNodes | 配置注册的静态节点阵列 |
pollEditNodes | 配置注册的编辑节点阵列 |
extractPolls(state) | 从编辑器状态提取民调元数据用于 SSR |
渲染器
| 导出 | 说明 |
|---|---|
PollRenderer | 播放选票的静态民意测验制作器 |
PollEditDecorator | 带有民意测验配置的编辑模式装饰器 |
PollDataProvider | 投票计数适配器的背景提供者 |
usePollData() | 访问民意调查数据的背景 |
槽密钥
| 导出 | 说明 |
|---|---|
POLL_NODE_KEY | 'Poll' 常数 RendererConfig 搜索档 |
类型
| 导出 | 说明 |
|---|---|
PollChoice | 个人民意测验选择类型 |
PollConfig | 投票配置(选择、接近时间、能见度) |
PollDataAdapter | 投票和计票的适配界面 |
SerializedPollNode | 连续投票节点类型 |
子路径导出
| 路径 | 说明 |
|---|---|
@haklex/rich-ext-poll | 完全导出( 节点 + 渲染器 + 编辑) |
@haklex/rich-ext-poll/node | 轻量级节点+槽键+类型 — 无默认渲染器 |
@haklex/rich-ext-poll/renderer | 默认 PollRenderer (重) + (轻) PollDataProvider |
@haklex/rich-ext-poll/edit | 编辑-模式节点+ PollEditDecorator |
@haklex/rich-ext-poll/static | 方便:节点+渲染器(SSR捆绑) |
@haklex/rich-ext-poll/style.css | 样式表 |
哈克历克的一部分
此软件包是 哈克历 丰富的编辑生态系统.
许可证
麻省理工学院