fix:row flex and row margin command
This commit is contained in:
@@ -343,18 +343,17 @@ export class CommandAdapt {
|
||||
if (isReadonly) return
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
if (!~startIndex && !~endIndex) return
|
||||
const pageNo = this.draw.getPageNo()
|
||||
// 选区行信息
|
||||
const rangeRow = this.range.getRangeRow()
|
||||
if (!rangeRow) return
|
||||
const positionList = this.position.getPositionList()
|
||||
// 开始/结束行号
|
||||
const startRowNo = positionList[startIndex].rowNo
|
||||
const endRowNo = positionList[endIndex].rowNo
|
||||
const elementList = this.draw.getElementList()
|
||||
// 当前选区所在行
|
||||
for (let p = 0; p < positionList.length; p++) {
|
||||
const position = positionList[p]
|
||||
if (position.pageNo !== pageNo) continue
|
||||
if (position.rowNo > endRowNo) break
|
||||
if (position.rowNo >= startRowNo && position.rowNo <= endRowNo) {
|
||||
const rowSet = rangeRow.get(position.pageNo)
|
||||
if (!rowSet) continue
|
||||
if (rowSet.has(position.rowNo)) {
|
||||
elementList[p].rowFlex = payload
|
||||
}
|
||||
}
|
||||
@@ -369,18 +368,17 @@ export class CommandAdapt {
|
||||
if (isReadonly) return
|
||||
const { startIndex, endIndex } = this.range.getRange()
|
||||
if (!~startIndex && !~endIndex) return
|
||||
const pageNo = this.draw.getPageNo()
|
||||
// 选区行信息
|
||||
const rangeRow = this.range.getRangeRow()
|
||||
if (!rangeRow) return
|
||||
const positionList = this.position.getPositionList()
|
||||
// 开始/结束行号
|
||||
const startRowNo = positionList[startIndex].rowNo
|
||||
const endRowNo = positionList[endIndex].rowNo
|
||||
const elementList = this.draw.getElementList()
|
||||
// 当前选区所在行
|
||||
for (let p = 0; p < positionList.length; p++) {
|
||||
const position = positionList[p]
|
||||
if (position.pageNo !== pageNo) continue
|
||||
if (position.rowNo > endRowNo) break
|
||||
if (position.rowNo >= startRowNo && position.rowNo <= endRowNo) {
|
||||
const rowSet = rangeRow.get(position.pageNo)
|
||||
if (!rowSet) continue
|
||||
if (rowSet.has(position.rowNo)) {
|
||||
elementList[p].rowMargin = payload
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,11 @@ import { ElementType } from '../..'
|
||||
import { ControlComponent } from '../../dataset/enum/Control'
|
||||
import { IEditorOption } from '../../interface/Editor'
|
||||
import { IElement } from '../../interface/Element'
|
||||
import { IRange } from '../../interface/Range'
|
||||
import { IRange, RangeRowMap } from '../../interface/Range'
|
||||
import { Draw } from '../draw/Draw'
|
||||
import { HistoryManager } from '../history/HistoryManager'
|
||||
import { Listener } from '../listener/Listener'
|
||||
import { Position } from '../position/Position'
|
||||
|
||||
export class RangeManager {
|
||||
|
||||
@@ -13,12 +14,14 @@ export class RangeManager {
|
||||
private options: Required<IEditorOption>
|
||||
private range: IRange
|
||||
private listener: Listener
|
||||
private position: Position
|
||||
private historyManager: HistoryManager
|
||||
|
||||
constructor(draw: Draw) {
|
||||
this.draw = draw
|
||||
this.options = draw.getOptions()
|
||||
this.listener = draw.getListener()
|
||||
this.position = draw.getPosition()
|
||||
this.historyManager = draw.getHistoryManager()
|
||||
this.range = {
|
||||
startIndex: -1,
|
||||
@@ -37,6 +40,26 @@ export class RangeManager {
|
||||
return elementList.slice(startIndex + 1, endIndex + 1)
|
||||
}
|
||||
|
||||
// 获取光标所选位置行信息
|
||||
public getRangeRow(): RangeRowMap | null {
|
||||
const { startIndex, endIndex } = this.range
|
||||
if (!~startIndex && !~endIndex) return null
|
||||
const positionList = this.position.getPositionList()
|
||||
const rangeRow: RangeRowMap = new Map()
|
||||
for (let p = startIndex; p < endIndex + 1; p++) {
|
||||
const { pageNo, rowNo } = positionList[p]
|
||||
const rowSet = rangeRow.get(pageNo)
|
||||
if (!rowSet) {
|
||||
rangeRow.set(pageNo, new Set([rowNo]))
|
||||
} else {
|
||||
if (!rowSet.has(rowNo)) {
|
||||
rowSet.add(rowNo)
|
||||
}
|
||||
}
|
||||
}
|
||||
return rangeRow
|
||||
}
|
||||
|
||||
public setRange(
|
||||
startIndex: number,
|
||||
endIndex: number,
|
||||
|
||||
@@ -8,3 +8,5 @@ export interface IRange {
|
||||
startTrIndex?: number;
|
||||
endTrIndex?: number;
|
||||
}
|
||||
|
||||
export type RangeRowMap = Map<number, Set<number>>
|
||||
|
||||
Reference in New Issue
Block a user