-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bumping plate to v30 [TOL-1834] (#1605)
- Loading branch information
1 parent
5a4ab39
commit db22a21
Showing
12 changed files
with
311 additions
and
88 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
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
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
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
32 changes: 32 additions & 0 deletions
32
packages/rich-text/src/plugins/Table/withInsertFragmentTableOverride.ts
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,32 @@ | ||
import { ELEMENT_DEFAULT, getPluginType, getTEditor, TElement } from '@udecode/plate-common'; | ||
import { ELEMENT_TABLE } from '@udecode/plate-table'; | ||
|
||
import { insertNodes, PlateEditor } from '../../internal'; | ||
|
||
export const withInsertFragmentTableOverride = (editor: PlateEditor) => { | ||
const myEditor = getTEditor(editor); | ||
|
||
const upstreamInsertFragment = myEditor.insertFragment; | ||
myEditor.insertFragment = (fragment) => { | ||
const insertedTable = fragment.find( | ||
(n) => (n as TElement).type === getPluginType(editor, ELEMENT_TABLE) | ||
); | ||
|
||
// Overriding https://github.com/udecode/plate/blob/aa5ad441cb72cfb6704315237c430f9a43570ffe/packages/table/src/withInsertFragmentTable.ts#L159C9-L163C8 | ||
// as we don't want the empty paragraph before the table when inserting a table | ||
if (insertedTable && fragment.length === 1 && fragment[0].type === ELEMENT_TABLE) { | ||
// needed to insert as node, otherwise it will be inserted as text | ||
insertNodes(editor, fragment, { | ||
removeEmpty: { | ||
// removes empty paragraph before table | ||
exclude: [ELEMENT_DEFAULT], | ||
}, | ||
}); | ||
return; | ||
} else { | ||
upstreamInsertFragment(fragment); | ||
} | ||
}; | ||
|
||
return editor; | ||
}; |
Oops, something went wrong.