feat: add cursor setting option to executeSetValue api #715
This commit is contained in:
@@ -51,6 +51,7 @@ import {
|
||||
IEditorOption,
|
||||
IEditorResult,
|
||||
IEditorText,
|
||||
ISetValueOption,
|
||||
IUpdateOption
|
||||
} from '../../interface/Editor'
|
||||
import {
|
||||
@@ -2301,8 +2302,8 @@ export class CommandAdapt {
|
||||
}
|
||||
}
|
||||
|
||||
public setValue(payload: Partial<IEditorData>) {
|
||||
this.draw.setValue(payload)
|
||||
public setValue(payload: Partial<IEditorData>, options?: ISetValueOption) {
|
||||
this.draw.setValue(payload, options)
|
||||
}
|
||||
|
||||
public removeControl() {
|
||||
|
||||
@@ -15,7 +15,8 @@ import {
|
||||
import {
|
||||
IEditorData,
|
||||
IEditorOption,
|
||||
IEditorResult
|
||||
IEditorResult,
|
||||
ISetValueOption
|
||||
} from '../../interface/Editor'
|
||||
import {
|
||||
IElement,
|
||||
@@ -1034,9 +1035,10 @@ export class Draw {
|
||||
}
|
||||
}
|
||||
|
||||
public setValue(payload: Partial<IEditorData>) {
|
||||
public setValue(payload: Partial<IEditorData>, options?: ISetValueOption) {
|
||||
const { header, main, footer } = deepClone(payload)
|
||||
if (!header && !main && !footer) return
|
||||
const { isSetCursor = false } = options || {}
|
||||
const pageComponentData = [header, main, footer]
|
||||
pageComponentData.forEach(data => {
|
||||
if (!data) return
|
||||
@@ -1051,8 +1053,17 @@ export class Draw {
|
||||
})
|
||||
// 渲染&计算&清空历史记录
|
||||
this.historyManager.recovery()
|
||||
const curIndex = isSetCursor
|
||||
? main?.length
|
||||
? main.length - 1
|
||||
: 0
|
||||
: undefined
|
||||
if (curIndex !== undefined) {
|
||||
this.range.setRange(curIndex, curIndex)
|
||||
}
|
||||
this.render({
|
||||
isSetCursor: false,
|
||||
curIndex,
|
||||
isSetCursor,
|
||||
isFirstRender: true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -117,3 +117,7 @@ export type IUpdateOption = Omit<
|
||||
| 'historyMaxRecordCount'
|
||||
| 'scrollContainerSelector'
|
||||
>
|
||||
|
||||
export interface ISetValueOption {
|
||||
isSetCursor?: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user