-
-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve selection, indices computation
- Loading branch information
Showing
15 changed files
with
336 additions
and
198 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Value } from '@udecode/plate-common'; | ||
|
||
import { TablePlugin, TTableCellElement, TTableElement } from '../types'; | ||
import { getIndices } from './getIndices'; | ||
import { getIndicesWithSpans } from './getIndicesWithSpans'; | ||
|
||
export const findCellByIndexes1 = ( | ||
options: TablePlugin<Value>, | ||
table: TTableElement, | ||
searchRowIndex: number, | ||
searchColIndex: number | ||
) => { | ||
const allCells = table.children.flatMap( | ||
(current) => current.children | ||
) as TTableCellElement[]; | ||
|
||
// console.log('searching for', searchRowIndex, searchColIndex); | ||
const foundCell = allCells.find((cell) => { | ||
const cellElement = cell as TTableCellElement; | ||
|
||
const { _startColIndex, _startRowIndex } = getIndices(options, cellElement); | ||
const { _endRowIndex, _endColIndex } = getIndicesWithSpans( | ||
options, | ||
cellElement | ||
); | ||
|
||
// console.log('current', colIndex, endColIndex, rowIndex, endRowIndex); | ||
if ( | ||
searchColIndex >= _startColIndex && | ||
searchColIndex <= _endColIndex && | ||
searchRowIndex >= _startRowIndex && | ||
searchRowIndex <= _endRowIndex | ||
) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
return foundCell; | ||
}; |
Oops, something went wrong.