Alignment
Align your content to different positions.
components/demo.tsx
'use client';
import React from 'react';
import { Plate } from '@udecode/plate-common/react';
import { editorPlugins } from '@/components/editor/plugins/editor-plugins';
import { useCreateEditor } from '@/components/editor/use-create-editor';
import { Editor, EditorContainer } from '@/components/plate-ui/editor';
import { DEMO_VALUES } from './values/demo-values';
export default function Demo({ id }: { id: string }) {
const editor = useCreateEditor({
plugins: [...editorPlugins],
value: DEMO_VALUES[id],
});
return (
<Plate editor={editor}>
<EditorContainer variant="demo">
<Editor />
</EditorContainer>
</Plate>
);
}
安装
npm install @udecode/plate-alignment
Usage
// ...
import { createPlateEditor } from '@udecode/plate-common/react';
import { AlignPlugin } from '@udecode/plate-alignment/react';
import { ParagraphPlugin } from '@udecode/plate-common/react';
import { HeadingPlugin } from '@udecode/plate-heading/react';
const editor = createPlateEditor({
plugins: [
HeadingPlugin,
AlignPlugin.configure({
inject: {
targetPlugins: [
ParagraphPlugin.key,
HeadingPlugin.key,
],
},
}),
],
});
插件
AlignPlugin
API
setAlign
设置指定块元素的对齐方式。
Parameters
Collapse all
编辑器实例。
API 组件
useAlignDropdownMenuState
Returns
Collapse all
对齐方式的值。
useAlignDropdownMenu
State
Collapse all
对齐方式的值。
Returns
Collapse all
单选按钮组的属性。