mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-08-06 13:38:49 +08:00
feat: add setCellSelection command
This commit is contained in:
parent
811bf693eb
commit
eb7e92f10a
@ -24,6 +24,7 @@ import {
|
||||
toggleHeaderCell,
|
||||
setCellAttr,
|
||||
fixTables,
|
||||
CellSelection,
|
||||
} from 'prosemirror-tables'
|
||||
import { NodeView } from 'prosemirror-view'
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
@ -62,6 +63,7 @@ declare module '@tiptap/core' {
|
||||
goToNextCell: () => Command,
|
||||
goToPreviousCell: () => Command,
|
||||
fixTables: () => Command,
|
||||
setCellSelection: (position: { anchorCell: number, headCell?: number }) => Command,
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,6 +184,16 @@ export const Table = Node.create<TableOptions>({
|
||||
fixTables(state)
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
setCellSelection: position => ({ tr, dispatch }) => {
|
||||
if (dispatch) {
|
||||
const selection = CellSelection.create(tr.doc, position.anchorCell, position.headCell)
|
||||
|
||||
// @ts-ignore
|
||||
tr.setSelection(selection)
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user