|
| 1 | +--- |
| 2 | +title: Column |
| 3 | +description: Add Columns to your document. |
| 4 | +docs: |
| 5 | + - route: /docs/components/column-element |
| 6 | + title: Column Element |
| 7 | + - route: /docs/components/column-group-element |
| 8 | + title: Column Group Element |
| 9 | +--- |
| 10 | + |
| 11 | +<ComponentPreview name="playground-demo" id="column" /> |
| 12 | + |
| 13 | +<PackageInfo> |
| 14 | + |
| 15 | +## Features |
| 16 | + |
| 17 | +- Add columns to your document. |
| 18 | +- Choose from a variety of column layouts using `column-group-element` toolbar. |
| 19 | +- [ ] Resizable columns |
| 20 | + |
| 21 | +</PackageInfo> |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +```bash |
| 26 | +npm install @udecode/plate-layout |
| 27 | +``` |
| 28 | + |
| 29 | +## Usage |
| 30 | + |
| 31 | +```tsx |
| 32 | +// ... |
| 33 | +import { createColumnPlugin } from '@udecode/plate-layout'; |
| 34 | + |
| 35 | +const plugins = [ |
| 36 | + // ...otherPlugins, |
| 37 | + createColumnPlugin(), |
| 38 | +]; |
| 39 | +``` |
| 40 | + |
| 41 | +## API |
| 42 | + |
| 43 | +### createColumnPlugin |
| 44 | + |
| 45 | +Add Column Plugin to your document. |
| 46 | + |
| 47 | +### TColumnGroupElement |
| 48 | + |
| 49 | +<APIAttributes> |
| 50 | +Extends `TElement`. |
| 51 | + |
| 52 | +<APIItem name="layout" type="number[]" optional> |
| 53 | + Set the width of it’s children `Column` |
| 54 | +</APIItem> |
| 55 | +</APIAttributes> |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +### TColumnElement |
| 60 | + |
| 61 | +<APIAttributes> |
| 62 | +Extends `TElement`. |
| 63 | + |
| 64 | +<APIItem name="width" type="string" optional> |
| 65 | + The `Column`'s width end with `%` |
| 66 | +</APIItem> |
| 67 | +</APIAttributes> |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +### insertColumnGroup |
| 72 | + |
| 73 | +Insert an columnGroup with two empty column. |
| 74 | + |
| 75 | +<APIParameters> |
| 76 | + <APIItem name="editor" type="TEditor"> |
| 77 | + The editor instance. |
| 78 | + </APIItem> |
| 79 | +</APIParameters> |
| 80 | + |
| 81 | +### insertEmptyColumn |
| 82 | + |
| 83 | +Insert an empty column. You can set the with by options.width default is "33%" |
| 84 | + |
| 85 | +<APIParameters> |
| 86 | + <APIItem name="editor" type="TEditor"> |
| 87 | + The editor instance. |
| 88 | + </APIItem> |
| 89 | + <APIItem name="options" type="InsertNodesOptions<V> & { width?: string }"> |
| 90 | + InsertNodesOptions and with to set the insert behavior. |
| 91 | + </APIItem> |
| 92 | +</APIParameters> |
| 93 | + |
| 94 | +### moveMiddleColumn |
| 95 | + |
| 96 | +Move the middle column to the left of right by options.direction. if the middle node is empty return false and remove it. |
| 97 | + |
| 98 | +<APIParameters> |
| 99 | + <APIItem name="editor" type="TEditor"> |
| 100 | + The editor instance. |
| 101 | + </APIItem> |
| 102 | + <APIItem name="nodeEntry" type="TNodeEntry<N>"> |
| 103 | + The node entry of `column` element |
| 104 | + </APIItem> |
| 105 | + <APIItem name="options" type="{ direction: 'left' | 'right' }"> |
| 106 | + Control the middle column move to |
| 107 | + </APIItem> |
| 108 | +</APIParameters> |
| 109 | + |
| 110 | +### setColumnWidth |
| 111 | + |
| 112 | +Set the width of `ColumnGroup`'s children.In general you don't need to use this function,Since we will call this function automatically when the property of `layout` changed. |
| 113 | +If you want to set the `layout` use setNodes. |
| 114 | + |
| 115 | +<APIParameters> |
| 116 | + <APIItem name="editor" type="TEditor"> |
| 117 | + The editor instance. |
| 118 | + </APIItem> |
| 119 | + <APIItem name="groupPathRef" type="PathRef"> |
| 120 | + the path ref of `ColumnGoup` |
| 121 | + </APIItem> |
| 122 | + <APIItem name="layout" type="number"> |
| 123 | + The element property of `layout` |
| 124 | + </APIItem> |
| 125 | +</APIParameters> |
| 126 | + |
| 127 | +## API Components |
| 128 | + |
| 129 | +### useColumnState |
| 130 | + |
| 131 | +<APIReturns> |
| 132 | + <APIItem name="setDoubleColumn" type="function"> |
| 133 | + Call this function make the `ColumnGroup`'s children, column bisects the |
| 134 | + parent element space.This nature is set the `layout` property of |
| 135 | + `ColumnGroup` to `[50,50]` |
| 136 | + </APIItem> |
| 137 | + <APIItem name="setThreeColumn" type="function"> |
| 138 | + Set the `layout` property of `ColumnGroup` to `[33, 33, 33]` |
| 139 | + </APIItem> |
| 140 | + <APIItem name="setRightSideDoubleColumn" type="function"> |
| 141 | + Set the `layout` property of `ColumnGroup` to `[70,30]` |
| 142 | + </APIItem> |
| 143 | + <APIItem name="setLeftSideDoubleColumn" type="function"> |
| 144 | + Set the `layout` property of `ColumnGroup` to `[30,70]` |
| 145 | + </APIItem> |
| 146 | + <APIItem name="setDoubleSideDoubleColumn" type="function"> |
| 147 | + Set the `layout` property of `ColumnGroup` to `[25, 50, 25]` |
| 148 | + </APIItem> |
| 149 | +</APIReturns> |
| 150 | + |
| 151 | +### useDebouncePopoverOpen |
| 152 | + |
| 153 | +<APIReturns> |
| 154 | + |
| 155 | +<APIItem type="boolean">Control the `popover` is open or not</APIItem> |
| 156 | + |
| 157 | +</APIReturns> |
0 commit comments