-
-
Notifications
You must be signed in to change notification settings - Fork 631
refactor: less use of PartialBlocks and type cleanup #2111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bd154ed
30c5581
f2d191e
75bd4e5
5eb10ec
b99822a
53bd6d7
cba8abb
c37934c
0920bf9
56f4245
d15becc
b028a1b
6ffa70e
553932b
cbda9e7
0dcd4f8
b8383f7
2cfa627
282a966
bbe2299
7b44f98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| import { DefaultBlockSchema } from "../../../blocks/defaultBlocks.js"; | ||
| import { | ||
| BlockFromConfigNoChildren, | ||
| PartialTableContent, | ||
| TableCell, | ||
| TableContent, | ||
| } from "../../../schema/blocks/types.js"; | ||
| import { | ||
| type BlockFromConfig, | ||
| type PartialTableContent, | ||
| type TableCell, | ||
| type TableContent, | ||
| isPartialLinkInlineContent, | ||
| isStyledTextInlineContent, | ||
| } from "../../../schema/index.js"; | ||
|
|
@@ -185,7 +183,7 @@ type OccupancyGrid = (RelativeCellIndices & { | |
| * @returns an {@link OccupancyGrid} | ||
| */ | ||
| export function getTableCellOccupancyGrid( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stopped exporting
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we are cleaning up types, I believe that: BlockFromConfig<DefaultBlockSchema["table"], any, any>Should only be: BlockFromConfig<DefaultBlockSchema["table"]>Most of the time we don't care about the other parameters, and have to remove their defaults with any. This goes for most instances of B, I, S |
||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| ): OccupancyGrid { | ||
| const { height, width } = getDimensionsOfTable(block); | ||
|
|
||
|
|
@@ -295,7 +293,7 @@ export function getAbsoluteTableCells( | |
| /** | ||
| * The table block containing the cell. | ||
| */ | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| /** | ||
| * The occupancy grid of the table. | ||
| */ | ||
|
|
@@ -327,7 +325,7 @@ export function getAbsoluteTableCells( | |
| * @returns The height and width of the table. | ||
| */ | ||
| export function getDimensionsOfTable( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| ): { | ||
| /** | ||
| * The number of rows in the table. | ||
|
|
@@ -370,7 +368,7 @@ export function getRelativeTableCells( | |
| /** | ||
| * The table block containing the cell. | ||
| */ | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| /** | ||
| * The occupancy grid of the table. | ||
| */ | ||
|
|
@@ -428,7 +426,7 @@ export function getRelativeTableCells( | |
| * @returns All of the cells associated with the relative row of the table. (All cells that have the same relative row index) | ||
| */ | ||
| export function getCellsAtRowHandle( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| relativeRowIndex: RelativeCellIndices["row"], | ||
| ) { | ||
| const occupancyGrid = getTableCellOccupancyGrid(block); | ||
|
|
@@ -507,7 +505,7 @@ export function getCellsAtRowHandle( | |
| * @returns All of the cells associated with the relative column of the table. (All cells that have the same relative column index) | ||
| */ | ||
| export function getCellsAtColumnHandle( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| relativeColumnIndex: RelativeCellIndices["col"], | ||
| ) { | ||
| const occupancyGrid = getTableCellOccupancyGrid(block); | ||
|
|
@@ -563,7 +561,7 @@ export function getCellsAtColumnHandle( | |
| * @note This is a destructive operation, it will modify the provided {@link OccupancyGrid} in place. | ||
| */ | ||
| export function moveColumn( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| fromColIndex: RelativeCellIndices["col"], | ||
| toColIndex: RelativeCellIndices["col"], | ||
| occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block), | ||
|
|
@@ -607,7 +605,7 @@ export function moveColumn( | |
| * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place. | ||
| */ | ||
| export function moveRow( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| fromRowIndex: RelativeCellIndices["row"], | ||
| toRowIndex: RelativeCellIndices["row"], | ||
| occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block), | ||
|
|
@@ -656,7 +654,8 @@ function isCellEmpty( | |
| return true; | ||
| } | ||
| if (isPartialTableCell(cell)) { | ||
| return isCellEmpty(cell.content); | ||
| // TODO: what happened here? | ||
| return isCellEmpty(cell); | ||
YousefED marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else if (typeof cell === "string") { | ||
| return cell.length === 0; | ||
| } else if (Array.isArray(cell)) { | ||
|
|
@@ -682,7 +681,7 @@ function isCellEmpty( | |
| * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place. | ||
| */ | ||
| export function cropEmptyRowsOrColumns( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| removeEmpty: "columns" | "rows", | ||
| occupancyGrid: OccupancyGrid = getTableCellOccupancyGrid(block), | ||
| ): TableContent<any, any>["rows"] { | ||
|
|
@@ -744,7 +743,7 @@ export function cropEmptyRowsOrColumns( | |
| * @note This is a destructive operation, it will modify the {@link OccupancyGrid} in place. | ||
| */ | ||
| export function addRowsOrColumns( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| addType: "columns" | "rows", | ||
| /** | ||
| * The number of rows or columns to add. | ||
|
|
@@ -800,7 +799,7 @@ export function addRowsOrColumns( | |
| * Checks if a row can be safely dropped at the target row index without splitting merged cells. | ||
| */ | ||
| export function canRowBeDraggedInto( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| draggingIndex: RelativeCellIndices["row"], | ||
| targetRowIndex: RelativeCellIndices["row"], | ||
| ) { | ||
|
|
@@ -835,7 +834,7 @@ export function canRowBeDraggedInto( | |
| * Checks if a column can be safely dropped at the target column index without splitting merged cells. | ||
| */ | ||
| export function canColumnBeDraggedInto( | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| draggingIndex: RelativeCellIndices["col"], | ||
| targetColumnIndex: RelativeCellIndices["col"], | ||
| ) { | ||
|
|
@@ -874,7 +873,7 @@ export function canColumnBeDraggedInto( | |
| export function areInSameColumn( | ||
| from: RelativeCellIndices, | ||
| to: RelativeCellIndices, | ||
| block: BlockFromConfigNoChildren<DefaultBlockSchema["table"], any, any>, | ||
| block: BlockFromConfig<DefaultBlockSchema["table"], any, any>, | ||
| ) { | ||
| // Table indices are relative to the table, so we need to resolve the absolute cell indices | ||
| const anchorAbsoluteCellIndices = getAbsoluteTableCells(from, block); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.