|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import { ElementType } from '../..'
|
|
|
|
import { ElementType } from '../..'
|
|
|
|
import { ZERO } from '../../dataset/constant/Common'
|
|
|
|
import { ZERO } from '../../dataset/constant/Common'
|
|
|
|
|
|
|
|
import { TEXTLIKE_ELEMENT_TYPE } from '../../dataset/constant/Element'
|
|
|
|
import { ControlComponent } from '../../dataset/enum/Control'
|
|
|
|
import { ControlComponent } from '../../dataset/enum/Control'
|
|
|
|
import { IEditorOption } from '../../interface/Editor'
|
|
|
|
import { IEditorOption } from '../../interface/Editor'
|
|
|
|
import { IElement } from '../../interface/Element'
|
|
|
|
import { IElement } from '../../interface/Element'
|
|
|
|
@ -45,6 +46,12 @@ export class RangeManager {
|
|
|
|
return elementList.slice(startIndex + 1, endIndex + 1)
|
|
|
|
return elementList.slice(startIndex + 1, endIndex + 1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getTextLikeSelection(): IElement[] | null {
|
|
|
|
|
|
|
|
const selection = this.getSelection()
|
|
|
|
|
|
|
|
if (!selection) return null
|
|
|
|
|
|
|
|
return selection.filter(s => !s.type || TEXTLIKE_ELEMENT_TYPE.includes(s.type))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取光标所选位置行信息
|
|
|
|
// 获取光标所选位置行信息
|
|
|
|
public getRangeRow(): RangeRowMap | null {
|
|
|
|
public getRangeRow(): RangeRowMap | null {
|
|
|
|
const { startIndex, endIndex } = this.range
|
|
|
|
const { startIndex, endIndex } = this.range
|
|
|
|
@ -135,6 +142,7 @@ export class RangeManager {
|
|
|
|
const type = curElement.type || ElementType.TEXT
|
|
|
|
const type = curElement.type || ElementType.TEXT
|
|
|
|
// 富文本
|
|
|
|
// 富文本
|
|
|
|
const font = curElement.font || this.options.defaultFont
|
|
|
|
const font = curElement.font || this.options.defaultFont
|
|
|
|
|
|
|
|
const size = curElement.size || this.options.defaultSize
|
|
|
|
const bold = !~curElementList.findIndex(el => !el.bold)
|
|
|
|
const bold = !~curElementList.findIndex(el => !el.bold)
|
|
|
|
const italic = !~curElementList.findIndex(el => !el.italic)
|
|
|
|
const italic = !~curElementList.findIndex(el => !el.italic)
|
|
|
|
const underline = !~curElementList.findIndex(el => !el.underline)
|
|
|
|
const underline = !~curElementList.findIndex(el => !el.underline)
|
|
|
|
@ -154,6 +162,7 @@ export class RangeManager {
|
|
|
|
redo,
|
|
|
|
redo,
|
|
|
|
painter,
|
|
|
|
painter,
|
|
|
|
font,
|
|
|
|
font,
|
|
|
|
|
|
|
|
size,
|
|
|
|
bold,
|
|
|
|
bold,
|
|
|
|
italic,
|
|
|
|
italic,
|
|
|
|
underline,
|
|
|
|
underline,
|
|
|
|
@ -169,6 +178,7 @@ export class RangeManager {
|
|
|
|
public recoveryRangeStyle() {
|
|
|
|
public recoveryRangeStyle() {
|
|
|
|
if (!this.listener.rangeStyleChange) return
|
|
|
|
if (!this.listener.rangeStyleChange) return
|
|
|
|
const font = this.options.defaultFont
|
|
|
|
const font = this.options.defaultFont
|
|
|
|
|
|
|
|
const size = this.options.defaultSize
|
|
|
|
const rowMargin = this.options.defaultRowMargin
|
|
|
|
const rowMargin = this.options.defaultRowMargin
|
|
|
|
const painter = !!this.draw.getPainterStyle()
|
|
|
|
const painter = !!this.draw.getPainterStyle()
|
|
|
|
const undo = this.historyManager.isCanUndo()
|
|
|
|
const undo = this.historyManager.isCanUndo()
|
|
|
|
@ -179,6 +189,7 @@ export class RangeManager {
|
|
|
|
redo,
|
|
|
|
redo,
|
|
|
|
painter,
|
|
|
|
painter,
|
|
|
|
font,
|
|
|
|
font,
|
|
|
|
|
|
|
|
size,
|
|
|
|
bold: false,
|
|
|
|
bold: false,
|
|
|
|
italic: false,
|
|
|
|
italic: false,
|
|
|
|
underline: false,
|
|
|
|
underline: false,
|
|
|
|
|