feat: add setCellSelection command
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
|||||||
toggleHeaderCell,
|
toggleHeaderCell,
|
||||||
setCellAttr,
|
setCellAttr,
|
||||||
fixTables,
|
fixTables,
|
||||||
|
CellSelection,
|
||||||
} from 'prosemirror-tables'
|
} from 'prosemirror-tables'
|
||||||
import { NodeView } from 'prosemirror-view'
|
import { NodeView } from 'prosemirror-view'
|
||||||
import { TextSelection } from 'prosemirror-state'
|
import { TextSelection } from 'prosemirror-state'
|
||||||
@@ -62,6 +63,7 @@ declare module '@tiptap/core' {
|
|||||||
goToNextCell: () => Command,
|
goToNextCell: () => Command,
|
||||||
goToPreviousCell: () => Command,
|
goToPreviousCell: () => Command,
|
||||||
fixTables: () => Command,
|
fixTables: () => Command,
|
||||||
|
setCellSelection: (position: { anchorCell: number, headCell?: number }) => Command,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +184,16 @@ export const Table = Node.create<TableOptions>({
|
|||||||
fixTables(state)
|
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
|
return true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user