feat: add executeInsertTitle api #604
This commit is contained in:
@@ -921,3 +921,13 @@ Usage:
|
|||||||
```javascript
|
```javascript
|
||||||
instance.command.executeUpdateOptions(payload: IUpdateOption)
|
instance.command.executeUpdateOptions(payload: IUpdateOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeInsertTitle
|
||||||
|
|
||||||
|
Feature: Insert title
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeInsertTitle(payload: IElement)
|
||||||
|
```
|
||||||
|
|||||||
@@ -921,3 +921,13 @@ instance.command.executeSetControlHighlight(payload: ISetControlHighlightOption)
|
|||||||
```javascript
|
```javascript
|
||||||
instance.command.executeUpdateOptions(payload: IUpdateOption)
|
instance.command.executeUpdateOptions(payload: IUpdateOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## executeInsertTitle
|
||||||
|
|
||||||
|
功能:插入标题
|
||||||
|
|
||||||
|
用法:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
instance.command.executeInsertTitle(payload: IElement)
|
||||||
|
```
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export class Command {
|
|||||||
public executeSetControlProperties: CommandAdapt['setControlProperties']
|
public executeSetControlProperties: CommandAdapt['setControlProperties']
|
||||||
public executeSetControlHighlight: CommandAdapt['setControlHighlight']
|
public executeSetControlHighlight: CommandAdapt['setControlHighlight']
|
||||||
public executeUpdateOptions: CommandAdapt['updateOptions']
|
public executeUpdateOptions: CommandAdapt['updateOptions']
|
||||||
|
public executeInsertTitle: CommandAdapt['insertTitle']
|
||||||
public getCatalog: CommandAdapt['getCatalog']
|
public getCatalog: CommandAdapt['getCatalog']
|
||||||
public getImage: CommandAdapt['getImage']
|
public getImage: CommandAdapt['getImage']
|
||||||
public getOptions: CommandAdapt['getOptions']
|
public getOptions: CommandAdapt['getOptions']
|
||||||
@@ -207,6 +208,7 @@ export class Command {
|
|||||||
this.executeLocationGroup = adapt.locationGroup.bind(adapt)
|
this.executeLocationGroup = adapt.locationGroup.bind(adapt)
|
||||||
this.executeSetZone = adapt.setZone.bind(adapt)
|
this.executeSetZone = adapt.setZone.bind(adapt)
|
||||||
this.executeUpdateOptions = adapt.updateOptions.bind(adapt)
|
this.executeUpdateOptions = adapt.updateOptions.bind(adapt)
|
||||||
|
this.executeInsertTitle = adapt.insertTitle.bind(adapt)
|
||||||
// 获取
|
// 获取
|
||||||
this.getImage = adapt.getImage.bind(adapt)
|
this.getImage = adapt.getImage.bind(adapt)
|
||||||
this.getOptions = adapt.getOptions.bind(adapt)
|
this.getOptions = adapt.getOptions.bind(adapt)
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { NBSP, WRAP, ZERO } from '../../dataset/constant/Common'
|
import { NBSP, WRAP, ZERO } from '../../dataset/constant/Common'
|
||||||
import { EDITOR_ELEMENT_STYLE_ATTR } from '../../dataset/constant/Element'
|
import {
|
||||||
|
EDITOR_ELEMENT_STYLE_ATTR,
|
||||||
|
EDITOR_ROW_ATTR,
|
||||||
|
LIST_CONTEXT_ATTR,
|
||||||
|
TABLE_CONTEXT_ATTR
|
||||||
|
} from '../../dataset/constant/Element'
|
||||||
import {
|
import {
|
||||||
titleOrderNumberMapping,
|
titleOrderNumberMapping,
|
||||||
titleSizeMapping
|
titleSizeMapping
|
||||||
@@ -61,7 +66,13 @@ import {
|
|||||||
IGetTitleValueResult
|
IGetTitleValueResult
|
||||||
} from '../../interface/Title'
|
} from '../../interface/Title'
|
||||||
import { IWatermark } from '../../interface/Watermark'
|
import { IWatermark } from '../../interface/Watermark'
|
||||||
import { deepClone, downloadFile, getUUID, isObjectEqual } from '../../utils'
|
import {
|
||||||
|
cloneProperty,
|
||||||
|
deepClone,
|
||||||
|
downloadFile,
|
||||||
|
getUUID,
|
||||||
|
isObjectEqual
|
||||||
|
} from '../../utils'
|
||||||
import {
|
import {
|
||||||
createDomFromElementList,
|
createDomFromElementList,
|
||||||
formatElementContext,
|
formatElementContext,
|
||||||
@@ -70,7 +81,8 @@ import {
|
|||||||
pickElementAttr,
|
pickElementAttr,
|
||||||
getElementListByHTML,
|
getElementListByHTML,
|
||||||
getTextFromElementList,
|
getTextFromElementList,
|
||||||
zipElementList
|
zipElementList,
|
||||||
|
getAnchorElement
|
||||||
} from '../../utils/element'
|
} from '../../utils/element'
|
||||||
import { mergeOption } from '../../utils/option'
|
import { mergeOption } from '../../utils/option'
|
||||||
import { printImageBase64 } from '../../utils/print'
|
import { printImageBase64 } from '../../utils/print'
|
||||||
@@ -716,6 +728,7 @@ export class CommandAdapt {
|
|||||||
} else {
|
} else {
|
||||||
if (el.titleId) {
|
if (el.titleId) {
|
||||||
delete el.titleId
|
delete el.titleId
|
||||||
|
delete el.title
|
||||||
delete el.level
|
delete el.level
|
||||||
delete el.size
|
delete el.size
|
||||||
delete el.bold
|
delete el.bold
|
||||||
@@ -2496,4 +2509,25 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public insertTitle(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
|
||||||
|
]
|
||||||
|
cloneElement.valueList?.forEach(valueItem => {
|
||||||
|
cloneProperty<IElement>(cloneAttr, copyElement, valueItem)
|
||||||
|
})
|
||||||
|
// 插入标题
|
||||||
|
this.draw.insertElementList([cloneElement])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user