feat: add SetHTML api
Co-authored-by: Hufe921 <huangyunfeihufe@hotmail.com>
This commit is contained in:
@@ -743,3 +743,11 @@ Usage:
|
||||
```javascript
|
||||
instance.command.executeWordTool()
|
||||
```
|
||||
|
||||
## executeSetHTML
|
||||
Feature: Set the editor HTML data
|
||||
|
||||
Usage:
|
||||
```javascript
|
||||
instance.command.executeSetHTML(payload: Partial<IEditorHTML)
|
||||
```
|
||||
|
||||
@@ -743,3 +743,11 @@ instance.command.executeLocationCatalog(titleId: string)
|
||||
```javascript
|
||||
instance.command.executeWordTool()
|
||||
```
|
||||
|
||||
## executeSetHTML
|
||||
功能:设置编辑器HTML数据
|
||||
|
||||
用法:
|
||||
```javascript
|
||||
instance.command.executeSetHTML(payload: Partial<IEditorHTML)
|
||||
```
|
||||
|
||||
@@ -74,6 +74,7 @@ export class Command {
|
||||
public executeSetLocale: CommandAdapt['setLocale']
|
||||
public executeLocationCatalog: CommandAdapt['locationCatalog']
|
||||
public executeWordTool: CommandAdapt['wordTool']
|
||||
public executeSetHTML: CommandAdapt['setHTML']
|
||||
public getCatalog: CommandAdapt['getCatalog']
|
||||
public getImage: CommandAdapt['getImage']
|
||||
public getValue: CommandAdapt['getValue']
|
||||
@@ -165,6 +166,8 @@ export class Command {
|
||||
this.executeSetLocale = adapt.setLocale.bind(adapt)
|
||||
this.executeLocationCatalog = adapt.locationCatalog.bind(adapt)
|
||||
this.executeWordTool = adapt.wordTool.bind(adapt)
|
||||
this.executeSetHTML = adapt.setHTML.bind(adapt)
|
||||
|
||||
// 获取
|
||||
this.getImage = adapt.getImage.bind(adapt)
|
||||
this.getValue = adapt.getValue.bind(adapt)
|
||||
|
||||
@@ -43,7 +43,8 @@ import {
|
||||
formatElementContext,
|
||||
formatElementList,
|
||||
isTextLikeElement,
|
||||
pickElementAttr
|
||||
pickElementAttr,
|
||||
getElementListByHTML
|
||||
} from '../../utils/element'
|
||||
import { printImageBase64 } from '../../utils/print'
|
||||
import { Control } from '../draw/control/Control'
|
||||
@@ -1869,4 +1870,21 @@ export class CommandAdapt {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
public setHTML(payload: Partial<IEditorHTML>) {
|
||||
const { header, main, footer } = payload
|
||||
const innerWidth = this.draw.getOriginalInnerWidth()
|
||||
// 不设置值时数据为undefined,避免覆盖当前数据
|
||||
const getElementList = (htmlText?: string) =>
|
||||
htmlText !== undefined
|
||||
? getElementListByHTML(htmlText, {
|
||||
innerWidth
|
||||
})
|
||||
: undefined
|
||||
this.setValue({
|
||||
header: getElementList(header),
|
||||
main: getElementList(main),
|
||||
footer: getElementList(footer)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user