feat: add selection info to rangeContext

pr675
Hufe921 2 years ago
parent afce688249
commit 2df03ed386

@ -2085,6 +2085,10 @@ export class CommandAdapt {
if (!~startIndex && !~endIndex) return null if (!~startIndex && !~endIndex) return null
// 选区信息 // 选区信息
const isCollapsed = startIndex === endIndex const isCollapsed = startIndex === endIndex
const selectionText = this.range.toString()
const selectionElementList = zipElementList(
this.range.getSelectionElementList() || []
)
// 元素信息 // 元素信息
const elementList = this.draw.getElementList() const elementList = this.draw.getElementList()
const startElement = pickElementAttr( const startElement = pickElementAttr(
@ -2172,7 +2176,9 @@ export class CommandAdapt {
isTable, isTable,
trIndex: trIndex ?? null, trIndex: trIndex ?? null,
tdIndex: tdIndex ?? null, tdIndex: tdIndex ?? null,
tableElement tableElement,
selectionText,
selectionElementList
}) })
} }

@ -31,6 +31,8 @@ export type RangeContext = {
trIndex: number | null trIndex: number | null
tdIndex: number | null tdIndex: number | null
tableElement: IElement | null tableElement: IElement | null
selectionText: string | null
selectionElementList: IElement[]
} }
export interface IRangeParagraphInfo { export interface IRangeParagraphInfo {

Loading…
Cancel
Save