-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* style * feat * feat * fix: cell height * fix: delete table cells should replace cell children then reselect the range * fix: default level should be 0 * fix: copy from a single cell * feat * feat * fix: selection, replace cell children instead of cell, many blocks inside a table * feat * feat * fix: insert text across many cells * fix: normalize cell children * style * fix * fix * core.md * Create table.md * Create dnd.md * Create ui-table.md * fix * fix
- Loading branch information
Showing
31 changed files
with
1,089 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@udecode/plate-ui-dnd": patch | ||
--- | ||
|
||
- `withDraggable`: default `level` option is now 0 as expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@udecode/plate-core": minor | ||
--- | ||
|
||
- `isRangeAcrossBlocks`: Now returns true if one of the block above is found but not the other and returns undefined if no block is found. | ||
- `isRangeInSameBlock`: Whether the range is in the same block. | ||
- `removeNodeChildren`: Remove node children. | ||
- `replaceNodeChildren`: Replace node children: remove then insert. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
"@udecode/plate-table": minor | ||
--- | ||
|
||
- on delete many cells: | ||
- replace cell children by a paragraph then reselect all the selected cells | ||
- on get fragment (copy): | ||
- copying in a single cell should not copy the table anymore | ||
- on insert fragment (paste): | ||
- pasting multiple blocks into many selected cells will replace these cells children by the same blocks | ||
- replace cell children by a paragraph then reselect all the selected cells | ||
- on insert text: | ||
- it should delete the cells content by preserving the cells | ||
- normalize cells: | ||
- wrap cell children in a paragraph if they are texts | ||
- normalize selection: | ||
- it was easy to destroy the table structure when selection goes beyond a table. The current fix is to normalize the selection so it selects the whole table (see the specs) | ||
- specs: | ||
- https://github.com/udecode/editor-protocol/issues/63 | ||
- https://github.com/udecode/editor-protocol/issues/64 | ||
- https://github.com/udecode/editor-protocol/issues/65 | ||
- https://github.com/udecode/editor-protocol/issues/66 | ||
- https://github.com/udecode/editor-protocol/issues/67 | ||
- https://github.com/udecode/editor-protocol/issues/68 | ||
- https://github.com/udecode/editor-protocol/issues/69 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@udecode/plate-ui-table": patch | ||
--- | ||
|
||
- fix: table cells are now full height and not vertically centered anymore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Path, Range } from 'slate'; | ||
import { GetAboveNodeOptions, TEditor, Value } from '../slate/index'; | ||
import { getBlockAbove } from './getBlockAbove'; | ||
|
||
/** | ||
* Whether the range is in the same block. | ||
*/ | ||
export const isRangeInSameBlock = <V extends Value>( | ||
editor: TEditor<V>, | ||
{ | ||
at, | ||
...options | ||
}: Omit<GetAboveNodeOptions<V>, 'at'> & { at?: Range | null } = {} | ||
) => { | ||
if (!at) at = editor.selection; | ||
if (!at) return; | ||
|
||
const [start, end] = Range.edges(at); | ||
const startBlock = getBlockAbove(editor, { | ||
at: start, | ||
...options, | ||
}); | ||
const endBlock = getBlockAbove(editor, { | ||
at: end, | ||
...options, | ||
}); | ||
|
||
if (!startBlock || !endBlock) return; | ||
|
||
return Path.equals(startBlock[1], endBlock[1]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Path } from 'slate'; | ||
import { | ||
getNodeChildren, | ||
removeNodes, | ||
RemoveNodesOptions, | ||
TEditor, | ||
Value, | ||
withoutNormalizing, | ||
} from '../slate/index'; | ||
|
||
/** | ||
* Remove node children. | ||
*/ | ||
export const removeNodeChildren = <V extends Value = Value>( | ||
editor: TEditor<V>, | ||
path: Path, | ||
options?: Omit<RemoveNodesOptions<V>, 'at'> | ||
) => { | ||
withoutNormalizing(editor, () => { | ||
for (const [, childPath] of getNodeChildren(editor, path, { | ||
reverse: true, | ||
})) { | ||
removeNodes(editor, { ...options, at: childPath }); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Path } from 'slate'; | ||
import { | ||
EElementOrText, | ||
insertNodes, | ||
InsertNodesOptions, | ||
RemoveNodesOptions, | ||
TEditor, | ||
Value, | ||
withoutNormalizing, | ||
} from '../slate/index'; | ||
import { removeNodeChildren } from './removeNodeChildren'; | ||
|
||
/** | ||
* Replace node children: remove then insert. | ||
*/ | ||
export const replaceNodeChildren = < | ||
N extends EElementOrText<V>, | ||
V extends Value = Value | ||
>( | ||
editor: TEditor<V>, | ||
{ | ||
at, | ||
nodes, | ||
insertOptions, | ||
removeOptions, | ||
}: { | ||
at: Path; | ||
nodes: N | N[]; | ||
removeOptions?: Omit<RemoveNodesOptions<V>, 'at'>; | ||
insertOptions?: Omit<InsertNodesOptions<V>, 'at'>; | ||
} | ||
) => { | ||
withoutNormalizing(editor, () => { | ||
removeNodeChildren(editor, at, removeOptions); | ||
|
||
insertNodes(editor, nodes, { | ||
...insertOptions, | ||
at: at.concat([0]), | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
getBlockAbove, | ||
getPluginType, | ||
PlateEditor, | ||
Value, | ||
} from '@udecode/plate-core'; | ||
import { GetAboveNodeOptions } from '@udecode/plate-core/src/index'; | ||
import { ELEMENT_TABLE } from '../createTablePlugin'; | ||
|
||
export const getTableAbove = <V extends Value = Value>( | ||
editor: PlateEditor<V>, | ||
options?: GetAboveNodeOptions<V> | ||
) => | ||
getBlockAbove(editor, { | ||
match: { | ||
type: getPluginType(editor, ELEMENT_TABLE), | ||
}, | ||
...options, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
e179bf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
plate – ./
plate.udecode.io
plate-udecode.vercel.app
plate-git-main-udecode.vercel.app
www.plate.udecode.io