feat: add control disabled rule

pr675
Hufe921 2 years ago
parent 8acce15e76
commit 1455a2afb2

@ -82,6 +82,7 @@ interface IElement {
underline?: boolean; underline?: boolean;
extension?: unknown; extension?: unknown;
deletable?: boolean; deletable?: boolean;
disabled?: boolean;
code: string | null; code: string | null;
min?: number; min?: number;
max?: number; max?: number;

@ -82,6 +82,7 @@ interface IElement {
underline?: boolean; underline?: boolean;
extension?: unknown; extension?: unknown;
deletable?: boolean; deletable?: boolean;
disabled?: boolean;
code: string | null; code: string | null;
min?: number; min?: number;
max?: number; max?: number;

@ -242,8 +242,6 @@ export class CommandAdapt {
} }
public painter(options: IPainterOption) { public painter(options: IPainterOption) {
const isReadonly = this.draw.isReadonly()
if (isReadonly) return
const selection = this.range.getSelection() const selection = this.range.getSelection()
if (!selection) return if (!selection) return
const painterStyle: IElementStyle = {} const painterStyle: IElementStyle = {}
@ -260,12 +258,16 @@ export class CommandAdapt {
} }
public applyPainterStyle() { public applyPainterStyle() {
const isDisabled =
this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
this.canvasEvent.applyPainterStyle() this.canvasEvent.applyPainterStyle()
} }
public format() { public format() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
selection.forEach(el => { selection.forEach(el => {
@ -280,8 +282,9 @@ export class CommandAdapt {
} }
public font(payload: string) { public font(payload: string) {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
selection.forEach(el => { selection.forEach(el => {
@ -293,8 +296,9 @@ export class CommandAdapt {
public size(payload: number) { public size(payload: number) {
const { minSize, maxSize, defaultSize } = this.options const { minSize, maxSize, defaultSize } = this.options
if (payload < minSize || payload > maxSize) return if (payload < minSize || payload > maxSize) return
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getTextLikeSelectionElementList() const selection = this.range.getTextLikeSelectionElementList()
if (!selection || !selection.length) return if (!selection || !selection.length) return
let isExistUpdate = false let isExistUpdate = false
@ -314,8 +318,9 @@ export class CommandAdapt {
} }
public sizeAdd() { public sizeAdd() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getTextLikeSelectionElementList() const selection = this.range.getTextLikeSelectionElementList()
if (!selection || !selection.length) return if (!selection || !selection.length) return
const { defaultSize, maxSize } = this.options const { defaultSize, maxSize } = this.options
@ -338,8 +343,9 @@ export class CommandAdapt {
} }
public sizeMinus() { public sizeMinus() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getTextLikeSelectionElementList() const selection = this.range.getTextLikeSelectionElementList()
if (!selection || !selection.length) return if (!selection || !selection.length) return
const { defaultSize, minSize } = this.options const { defaultSize, minSize } = this.options
@ -362,8 +368,9 @@ export class CommandAdapt {
} }
public bold() { public bold() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const noBoldIndex = selection.findIndex(s => !s.bold) const noBoldIndex = selection.findIndex(s => !s.bold)
@ -374,8 +381,9 @@ export class CommandAdapt {
} }
public italic() { public italic() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const noItalicIndex = selection.findIndex(s => !s.italic) const noItalicIndex = selection.findIndex(s => !s.italic)
@ -386,8 +394,9 @@ export class CommandAdapt {
} }
public underline() { public underline() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const noUnderlineIndex = selection.findIndex(s => !s.underline) const noUnderlineIndex = selection.findIndex(s => !s.underline)
@ -401,8 +410,9 @@ export class CommandAdapt {
} }
public strikeout() { public strikeout() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const noStrikeoutIndex = selection.findIndex(s => !s.strikeout) const noStrikeoutIndex = selection.findIndex(s => !s.strikeout)
@ -416,8 +426,9 @@ export class CommandAdapt {
} }
public superscript() { public superscript() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const superscriptIndex = selection.findIndex( const superscriptIndex = selection.findIndex(
@ -445,8 +456,9 @@ export class CommandAdapt {
} }
public subscript() { public subscript() {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
const subscriptIndex = selection.findIndex( const subscriptIndex = selection.findIndex(
@ -474,8 +486,9 @@ export class CommandAdapt {
} }
public color(payload: string) { public color(payload: string) {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
selection.forEach(el => { selection.forEach(el => {
@ -488,8 +501,9 @@ export class CommandAdapt {
} }
public highlight(payload: string) { public highlight(payload: string) {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const selection = this.range.getSelectionElementList() const selection = this.range.getSelectionElementList()
if (!selection) return if (!selection) return
selection.forEach(el => { selection.forEach(el => {
@ -1447,6 +1461,8 @@ export class CommandAdapt {
} }
public deleteHyperlink() { public deleteHyperlink() {
const isReadonly = this.draw.isReadonly()
if (isReadonly) return
// 获取超链接索引 // 获取超链接索引
const hyperRange = this.getHyperlinkRange() const hyperRange = this.getHyperlinkRange()
if (!hyperRange) return if (!hyperRange) return
@ -1468,6 +1484,8 @@ export class CommandAdapt {
} }
public cancelHyperlink() { public cancelHyperlink() {
const isReadonly = this.draw.isReadonly()
if (isReadonly) return
// 获取超链接索引 // 获取超链接索引
const hyperRange = this.getHyperlinkRange() const hyperRange = this.getHyperlinkRange()
if (!hyperRange) return if (!hyperRange) return
@ -1491,6 +1509,8 @@ export class CommandAdapt {
} }
public editHyperlink(payload: string) { public editHyperlink(payload: string) {
const isReadonly = this.draw.isReadonly()
if (isReadonly) return
// 获取超链接索引 // 获取超链接索引
const hyperRange = this.getHyperlinkRange() const hyperRange = this.getHyperlinkRange()
if (!hyperRange) return if (!hyperRange) return
@ -1595,8 +1615,9 @@ export class CommandAdapt {
} }
public image(payload: IDrawImagePayload) { public image(payload: IDrawImagePayload) {
const isReadonly = this.draw.isReadonly() const isDisabled =
if (isReadonly) return this.draw.isReadonly() || this.control.isDisabledControl()
if (isDisabled) return
const activeControl = this.control.getActiveControl() const activeControl = this.control.getActiveControl()
if (activeControl) return if (activeControl) return
const { startIndex, endIndex } = this.range.getRange() const { startIndex, endIndex } = this.range.getRange()

@ -560,7 +560,9 @@ export class Draw {
// 判断是否在控件内 // 判断是否在控件内
const activeControl = this.control.getActiveControl() const activeControl = this.control.getActiveControl()
if (activeControl && !this.control.isRangInPostfix()) { if (activeControl && !this.control.isRangInPostfix()) {
curIndex = activeControl.setValue(payload) curIndex = activeControl.setValue(payload, undefined, {
isIgnoreDisabledRule: true
})
} else { } else {
const elementList = this.getElementList() const elementList = this.getElementList()
const isCollapsed = startIndex === endIndex const isCollapsed = startIndex === endIndex

@ -6,6 +6,7 @@ import {
IControlInitOption, IControlInitOption,
IControlInstance, IControlInstance,
IControlOption, IControlOption,
IControlRuleOption,
IGetControlValueOption, IGetControlValueOption,
IGetControlValueResult, IGetControlValueResult,
ISetControlExtensionOption, ISetControlExtensionOption,
@ -122,6 +123,10 @@ export class Control {
return false return false
} }
public isDisabledControl(): boolean {
return !!this.activeControl?.getElement().control?.disabled
}
public getContainer(): HTMLDivElement { public getContainer(): HTMLDivElement {
return this.draw.getContainer() return this.draw.getContainer()
} }
@ -226,11 +231,18 @@ export class Control {
} }
} }
public repaintControl(curIndex: number) { public repaintControl(curIndex?: number) {
this.range.setRange(curIndex, curIndex) if (curIndex === undefined) {
this.draw.render({ this.range.clearRange()
curIndex this.draw.render({
}) isSetCursor: false
})
} else {
this.range.setRange(curIndex, curIndex)
this.draw.render({
curIndex
})
}
} }
public moveCursor(position: IControlInitOption): IMoveCursorResult { public moveCursor(position: IControlInitOption): IMoveCursorResult {
@ -528,6 +540,9 @@ export class Control {
range: fakeRange, range: fakeRange,
elementList elementList
} }
const controlRule: IControlRuleOption = {
isIgnoreDisabledRule: true
}
if (type === ControlType.TEXT) { if (type === ControlType.TEXT) {
const formatValue = [{ value }] const formatValue = [{ value }]
formatElementList(formatValue, { formatElementList(formatValue, {
@ -536,31 +551,21 @@ export class Control {
}) })
const text = new TextControl(element, this) const text = new TextControl(element, this)
if (value) { if (value) {
text.setValue(formatValue, controlContext) text.setValue(formatValue, controlContext, controlRule)
} else { } else {
text.clearValue(controlContext) text.clearValue(controlContext, controlRule)
} }
} else if (type === ControlType.SELECT) { } else if (type === ControlType.SELECT) {
const select = new SelectControl(element, this) const select = new SelectControl(element, this)
if (value) { if (value) {
select.setSelect(value, controlContext) select.setSelect(value, controlContext, controlRule)
} else { } else {
select.clearSelect(controlContext) select.clearSelect(controlContext, controlRule)
} }
} else if (type === ControlType.CHECKBOX) { } else if (type === ControlType.CHECKBOX) {
const checkbox = new CheckboxControl(element, this) const checkbox = new CheckboxControl(element, this)
const checkboxElementList = elementList.slice(
fakeRange.startIndex + 1,
fakeRange.endIndex + 1
)
const codes = value?.split(',') || [] const codes = value?.split(',') || []
for (const checkElement of checkboxElementList) { checkbox.setSelect(codes, controlContext, controlRule)
if (checkElement.controlComponent === ControlComponent.CHECKBOX) {
const checkboxItem = checkElement.checkbox!
checkboxItem.value = codes.includes(checkboxItem.code!)
}
}
checkbox.setSelect(controlContext)
} }
// 修改后控件结束索引 // 修改后控件结束索引
let newEndIndex = i let newEndIndex = i

@ -2,7 +2,8 @@ import { ControlComponent } from '../../../../dataset/enum/Control'
import { KeyMap } from '../../../../dataset/enum/KeyMap' import { KeyMap } from '../../../../dataset/enum/KeyMap'
import { import {
IControlContext, IControlContext,
IControlInstance IControlInstance,
IControlRuleOption
} from '../../../../interface/Control' } from '../../../../interface/Control'
import { IElement } from '../../../../interface/Element' import { IElement } from '../../../../interface/Element'
import { Control } from '../Control' import { Control } from '../Control'
@ -66,12 +67,19 @@ export class CheckboxControl implements IControlInstance {
return -1 return -1
} }
public setSelect(context: IControlContext = {}) { public setSelect(
codes: string[],
context: IControlContext = {},
options: IControlRuleOption = {}
) {
// 校验是否可以设置
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
return
}
const { control } = this.element const { control } = this.element
const elementList = context.elementList || this.control.getElementList() const elementList = context.elementList || this.control.getElementList()
const { startIndex } = context.range || this.control.getRange() const { startIndex } = context.range || this.control.getRange()
const startElement = elementList[startIndex] const startElement = elementList[startIndex]
const data: string[] = []
// 向左查找 // 向左查找
let preIndex = startIndex let preIndex = startIndex
while (preIndex > 0) { while (preIndex > 0) {
@ -83,10 +91,8 @@ export class CheckboxControl implements IControlInstance {
break break
} }
if (preElement.controlComponent === ControlComponent.CHECKBOX) { if (preElement.controlComponent === ControlComponent.CHECKBOX) {
const checkbox = preElement.checkbox const checkbox = preElement.checkbox!
if (checkbox && checkbox.value && checkbox.code) { checkbox.value = codes.includes(checkbox.code!)
data.unshift(checkbox.code)
}
} }
preIndex-- preIndex--
} }
@ -101,17 +107,19 @@ export class CheckboxControl implements IControlInstance {
break break
} }
if (nextElement.controlComponent === ControlComponent.CHECKBOX) { if (nextElement.controlComponent === ControlComponent.CHECKBOX) {
const checkbox = nextElement.checkbox const checkbox = nextElement.checkbox!
if (checkbox && checkbox.value && checkbox.code) { checkbox.value = codes.includes(checkbox.code!)
data.push(checkbox.code)
}
} }
nextIndex++ nextIndex++
} }
control!.code = data.join(',') control!.code = codes.join(',')
this.control.repaintControl()
} }
public keydown(evt: KeyboardEvent): number | null { public keydown(evt: KeyboardEvent): number | null {
if (this.control.isDisabledControl()) {
return null
}
const range = this.control.getRange() const range = this.control.getRange()
// 收缩边界到Value内 // 收缩边界到Value内
this.control.shrinkBoundary() this.control.shrinkBoundary()

@ -8,7 +8,8 @@ import { EditorComponent } from '../../../../dataset/enum/Editor'
import { KeyMap } from '../../../../dataset/enum/KeyMap' import { KeyMap } from '../../../../dataset/enum/KeyMap'
import { import {
IControlContext, IControlContext,
IControlInstance IControlInstance,
IControlRuleOption
} from '../../../../interface/Control' } from '../../../../interface/Control'
import { IElement } from '../../../../interface/Element' import { IElement } from '../../../../interface/Element'
import { omitObject, pickObject, splitText } from '../../../../utils' import { omitObject, pickObject, splitText } from '../../../../utils'
@ -79,6 +80,9 @@ export class SelectControl implements IControlInstance {
} }
public keydown(evt: KeyboardEvent): number | null { public keydown(evt: KeyboardEvent): number | null {
if (this.control.isDisabledControl()) {
return null
}
const elementList = this.control.getElementList() const elementList = this.control.getElementList()
const range = this.control.getRange() const range = this.control.getRange()
// 收缩边界到Value内 // 收缩边界到Value内
@ -129,6 +133,9 @@ export class SelectControl implements IControlInstance {
} }
public cut(): number { public cut(): number {
if (this.control.isDisabledControl()) {
return -1
}
this.control.shrinkBoundary() this.control.shrinkBoundary()
const { startIndex, endIndex } = this.control.getRange() const { startIndex, endIndex } = this.control.getRange()
if (startIndex === endIndex) { if (startIndex === endIndex) {
@ -138,7 +145,14 @@ export class SelectControl implements IControlInstance {
return this.clearSelect() return this.clearSelect()
} }
public clearSelect(context: IControlContext = {}): number { public clearSelect(
context: IControlContext = {},
options: IControlRuleOption = {}
): number {
// 校验是否可以设置
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
return -1
}
const elementList = context.elementList || this.control.getElementList() const elementList = context.elementList || this.control.getElementList()
const { startIndex } = context.range || this.control.getRange() const { startIndex } = context.range || this.control.getRange()
const startElement = elementList[startIndex] const startElement = elementList[startIndex]
@ -180,7 +194,15 @@ export class SelectControl implements IControlInstance {
return preIndex return preIndex
} }
public setSelect(code: string, context: IControlContext = {}) { public setSelect(
code: string,
context: IControlContext = {},
options: IControlRuleOption = {}
) {
// 校验是否可以设置
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
return
}
const control = this.element.control! const control = this.element.control!
const valueSets = control.valueSets const valueSets = control.valueSets
if (!Array.isArray(valueSets) || !valueSets.length) return if (!Array.isArray(valueSets) || !valueSets.length) return
@ -195,6 +217,7 @@ export class SelectControl implements IControlInstance {
) )
// 清空选项 // 清空选项
const prefixIndex = this.clearSelect(context) const prefixIndex = this.clearSelect(context)
if (!~prefixIndex) return
this.control.removePlaceholder(prefixIndex, context) this.control.removePlaceholder(prefixIndex, context)
// 属性赋值元素-默认为前缀属性 // 属性赋值元素-默认为前缀属性
const propertyElement = omitObject( const propertyElement = omitObject(
@ -266,7 +289,7 @@ export class SelectControl implements IControlInstance {
} }
public awake() { public awake() {
if (this.isPopup) return if (this.isPopup || this.control.isDisabledControl()) return
const { startIndex } = this.control.getRange() const { startIndex } = this.control.getRange()
const elementList = this.control.getElementList() const elementList = this.control.getElementList()
if (elementList[startIndex + 1]?.controlId !== this.element.controlId) { if (elementList[startIndex + 1]?.controlId !== this.element.controlId) {

@ -3,7 +3,8 @@ import { ControlComponent } from '../../../../dataset/enum/Control'
import { KeyMap } from '../../../../dataset/enum/KeyMap' import { KeyMap } from '../../../../dataset/enum/KeyMap'
import { import {
IControlContext, IControlContext,
IControlInstance IControlInstance,
IControlRuleOption
} from '../../../../interface/Control' } from '../../../../interface/Control'
import { IElement } from '../../../../interface/Element' import { IElement } from '../../../../interface/Element'
import { omitObject, pickObject } from '../../../../utils' import { omitObject, pickObject } from '../../../../utils'
@ -61,7 +62,15 @@ export class TextControl implements IControlInstance {
return data return data
} }
public setValue(data: IElement[], context: IControlContext = {}): number { public setValue(
data: IElement[],
context: IControlContext = {},
options: IControlRuleOption = {}
): number {
// 校验是否可以设置
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
return -1
}
const elementList = context.elementList || this.control.getElementList() const elementList = context.elementList || this.control.getElementList()
const range = context.range || this.control.getRange() const range = context.range || this.control.getRange()
// 收缩边界到Value内 // 收缩边界到Value内
@ -97,7 +106,14 @@ export class TextControl implements IControlInstance {
return start + data.length - 1 return start + data.length - 1
} }
public clearValue(context: IControlContext = {}): number { public clearValue(
context: IControlContext = {},
options: IControlRuleOption = {}
): number {
// 校验是否可以设置
if (!options.isIgnoreDisabledRule && this.control.isDisabledControl()) {
return -1
}
const elementList = context.elementList || this.control.getElementList() const elementList = context.elementList || this.control.getElementList()
const range = context.range || this.control.getRange() const range = context.range || this.control.getRange()
const { startIndex, endIndex } = range const { startIndex, endIndex } = range
@ -112,6 +128,9 @@ export class TextControl implements IControlInstance {
} }
public keydown(evt: KeyboardEvent): number | null { public keydown(evt: KeyboardEvent): number | null {
if (this.control.isDisabledControl()) {
return null
}
const elementList = this.control.getElementList() const elementList = this.control.getElementList()
const range = this.control.getRange() const range = this.control.getRange()
// 收缩边界到Value内 // 收缩边界到Value内
@ -190,6 +209,9 @@ export class TextControl implements IControlInstance {
} }
public cut(): number { public cut(): number {
if (this.control.isDisabledControl()) {
return -1
}
this.control.shrinkBoundary() this.control.shrinkBoundary()
const { startIndex, endIndex } = this.control.getRange() const { startIndex, endIndex } = this.control.getRange()
if (startIndex === endIndex) { if (startIndex === endIndex) {

@ -27,7 +27,6 @@ export function input(data: string, host: CanvasEvent) {
const cursor = draw.getCursor() const cursor = draw.getCursor()
cursor.clearAgentDomValue() cursor.clearAgentDomValue()
} }
const activeControl = control.getActiveControl()
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType
const text = data.replaceAll(`\n`, ZERO) const text = data.replaceAll(`\n`, ZERO)
const rangeManager = draw.getRange() const rangeManager = draw.getRange()
@ -65,7 +64,7 @@ export function input(data: string, host: CanvasEvent) {
}) })
// 控件-移除placeholder // 控件-移除placeholder
let curIndex: number let curIndex: number
if (activeControl && !control.isRangInPostfix()) { if (control.getActiveControl() && !control.isRangInPostfix()) {
curIndex = control.setValue(inputData) curIndex = control.setValue(inputData)
} else { } else {
const start = startIndex + 1 const start = startIndex + 1

@ -67,26 +67,28 @@ export function mousedown(evt: MouseEvent, host: CanvasEvent) {
// 复选框 // 复选框
const isSetCheckbox = isDirectHitCheckbox && !isReadonly const isSetCheckbox = isDirectHitCheckbox && !isReadonly
if (isSetCheckbox) { if (isSetCheckbox) {
const { checkbox } = curElement const { checkbox, control } = curElement
if (checkbox) { const codes = control?.code?.split(',') || []
checkbox.value = !checkbox.value if (checkbox?.value) {
const codeIndex = codes.findIndex(c => c === checkbox.code)
codes.splice(codeIndex, 1)
} else { } else {
curElement.checkbox = { if (checkbox?.code) {
value: true codes.push(checkbox.code)
} }
} }
const control = draw.getControl() const activeControl = draw.getControl().getActiveControl()
const activeControl = control.getActiveControl()
if (activeControl instanceof CheckboxControl) { if (activeControl instanceof CheckboxControl) {
activeControl.setSelect() activeControl.setSelect(codes)
} }
} else {
draw.render({
curIndex,
isCompute: false,
isSubmitHistory: false,
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox
})
} }
draw.render({
curIndex,
isSubmitHistory: isSetCheckbox,
isSetCursor: !isDirectHitImage && !isDirectHitCheckbox,
isCompute: false
})
// 首字需定位到行首,非上一行最后一个字后 // 首字需定位到行首,非上一行最后一个字后
if (hitLineStartIndex) { if (hitLineStartIndex) {
host.getDraw().getCursor().drawCursor({ host.getDraw().getCursor().drawCursor({

@ -23,6 +23,7 @@ export interface IControlCheckbox {
export interface IControlRule { export interface IControlRule {
deletable?: boolean deletable?: boolean
disabled?: boolean
} }
export interface IControlBasic { export interface IControlBasic {
@ -66,7 +67,11 @@ export interface IControlInstance {
getValue(): IElement[] getValue(): IElement[]
setValue(data: IElement[]): number setValue(
data: IElement[],
context?: IControlContext,
options?: IControlRuleOption
): number
keydown(evt: KeyboardEvent): number | null keydown(evt: KeyboardEvent): number | null
@ -78,6 +83,10 @@ export interface IControlContext {
elementList?: IElement[] elementList?: IElement[]
} }
export interface IControlRuleOption {
isIgnoreDisabledRule?: boolean // 忽略禁用校验规则
}
export interface IGetControlValueOption { export interface IGetControlValueOption {
conceptId: string conceptId: string
} }

Loading…
Cancel
Save