feat: add executeInsertControl api
This commit is contained in:
@@ -92,6 +92,7 @@ export class Command {
|
||||
public executeSetControlProperties: CommandAdapt['setControlProperties']
|
||||
public executeSetControlHighlight: CommandAdapt['setControlHighlight']
|
||||
public executeLocationControl: CommandAdapt['locationControl']
|
||||
public executeInsertControl: CommandAdapt['insertControl']
|
||||
public executeUpdateOptions: CommandAdapt['updateOptions']
|
||||
public executeInsertTitle: CommandAdapt['insertTitle']
|
||||
public getCatalog: CommandAdapt['getCatalog']
|
||||
@@ -242,5 +243,6 @@ export class Command {
|
||||
this.getControlValue = adapt.getControlValue.bind(adapt)
|
||||
this.getControlList = adapt.getControlList.bind(adapt)
|
||||
this.executeLocationControl = adapt.locationControl.bind(adapt)
|
||||
this.executeInsertControl = adapt.insertControl.bind(adapt)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2582,6 +2582,25 @@ export class CommandAdapt {
|
||||
}
|
||||
}
|
||||
|
||||
public insertControl(payload: IElement) {
|
||||
const isReadonly = this.draw.isReadonly()
|
||||
if (isReadonly) return
|
||||
const cloneElement = deepClone(payload)
|
||||
// 格式化上下文信息
|
||||
const { startIndex } = this.range.getRange()
|
||||
const elementList = this.draw.getElementList()
|
||||
const copyElement = getAnchorElement(elementList, startIndex)
|
||||
if (!copyElement) return
|
||||
const cloneAttr = [
|
||||
...TABLE_CONTEXT_ATTR,
|
||||
...EDITOR_ROW_ATTR,
|
||||
...LIST_CONTEXT_ATTR
|
||||
]
|
||||
cloneProperty<IElement>(cloneAttr, copyElement, cloneElement)
|
||||
// 插入控件
|
||||
this.draw.insertElementList([cloneElement])
|
||||
}
|
||||
|
||||
public getContainer(): HTMLDivElement {
|
||||
return this.draw.getContainer()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user