feat: add location property to executeLocationControl api #753
Co-authored-by: Hufe921 <huangyunfeihufe@hotmail.com>
This commit is contained in:
@@ -929,7 +929,7 @@ Feature: Positioning and activating control
|
|||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
instance.command.executeLocationControl(controlId: string)
|
instance.command.executeLocationControl(controlId: string, options?: ILocationControlOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
## executeInsertControl
|
## executeInsertControl
|
||||||
|
|||||||
@@ -929,7 +929,7 @@ instance.command.executeSetControlHighlight(payload: ISetControlHighlightOption)
|
|||||||
用法:
|
用法:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
instance.command.executeLocationControl(controlId: string)
|
instance.command.executeLocationControl(controlId: string, options?: ILocationControlOption)
|
||||||
```
|
```
|
||||||
|
|
||||||
## executeInsertControl
|
## executeInsertControl
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
titleSizeMapping
|
titleSizeMapping
|
||||||
} from '../../dataset/constant/Title'
|
} from '../../dataset/constant/Title'
|
||||||
import { defaultWatermarkOption } from '../../dataset/constant/Watermark'
|
import { defaultWatermarkOption } from '../../dataset/constant/Watermark'
|
||||||
import { ImageDisplay } from '../../dataset/enum/Common'
|
import { ImageDisplay, LocationPosition } from '../../dataset/enum/Common'
|
||||||
import { ControlComponent } from '../../dataset/enum/Control'
|
import { ControlComponent } from '../../dataset/enum/Control'
|
||||||
import {
|
import {
|
||||||
EditorContext,
|
EditorContext,
|
||||||
@@ -31,6 +31,7 @@ import { DeepRequired } from '../../interface/Common'
|
|||||||
import {
|
import {
|
||||||
IGetControlValueOption,
|
IGetControlValueOption,
|
||||||
IGetControlValueResult,
|
IGetControlValueResult,
|
||||||
|
ILocationControlOption,
|
||||||
ISetControlExtensionOption,
|
ISetControlExtensionOption,
|
||||||
ISetControlHighlightOption,
|
ISetControlHighlightOption,
|
||||||
ISetControlProperties,
|
ISetControlProperties,
|
||||||
@@ -2468,7 +2469,8 @@ export class CommandAdapt {
|
|||||||
return this.draw.getControl().getList()
|
return this.draw.getControl().getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
public locationControl(controlId: string) {
|
public locationControl(controlId: string, options?: ILocationControlOption) {
|
||||||
|
const isLocationAfter = options?.position === LocationPosition.AFTER
|
||||||
function location(
|
function location(
|
||||||
elementList: IElement[],
|
elementList: IElement[],
|
||||||
zone: EditorZone
|
zone: EditorZone
|
||||||
@@ -2502,7 +2504,16 @@ export class CommandAdapt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (element?.controlId !== controlId) continue
|
if (element?.controlId !== controlId) continue
|
||||||
const curIndex = i - 1
|
let curIndex = i - 1
|
||||||
|
if (isLocationAfter) {
|
||||||
|
curIndex -= 1
|
||||||
|
if (
|
||||||
|
element.controlComponent !== ControlComponent.PLACEHOLDER &&
|
||||||
|
element.controlComponent !== ControlComponent.POSTFIX
|
||||||
|
) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
zone,
|
zone,
|
||||||
range: {
|
range: {
|
||||||
|
|||||||
@@ -15,3 +15,8 @@ export enum ImageDisplay {
|
|||||||
FLOAT_TOP = 'float-top',
|
FLOAT_TOP = 'float-top',
|
||||||
FLOAT_BOTTOM = 'float-bottom'
|
FLOAT_BOTTOM = 'float-bottom'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum LocationPosition {
|
||||||
|
BEFORE = 'before',
|
||||||
|
AFTER = 'after'
|
||||||
|
}
|
||||||
|
|||||||
+3
-2
@@ -6,7 +6,7 @@ import { Command } from './core/command/Command'
|
|||||||
import { CommandAdapt } from './core/command/CommandAdapt'
|
import { CommandAdapt } from './core/command/CommandAdapt'
|
||||||
import { Listener } from './core/listener/Listener'
|
import { Listener } from './core/listener/Listener'
|
||||||
import { RowFlex } from './dataset/enum/Row'
|
import { RowFlex } from './dataset/enum/Row'
|
||||||
import { ImageDisplay } from './dataset/enum/Common'
|
import { ImageDisplay, LocationPosition } from './dataset/enum/Common'
|
||||||
import { ElementType } from './dataset/enum/Element'
|
import { ElementType } from './dataset/enum/Element'
|
||||||
import { formatElementList } from './utils/element'
|
import { formatElementList } from './utils/element'
|
||||||
import { Register } from './core/register/Register'
|
import { Register } from './core/register/Register'
|
||||||
@@ -171,7 +171,8 @@ export {
|
|||||||
BackgroundRepeat,
|
BackgroundRepeat,
|
||||||
BackgroundSize,
|
BackgroundSize,
|
||||||
TextDecorationStyle,
|
TextDecorationStyle,
|
||||||
LineNumberType
|
LineNumberType,
|
||||||
|
LocationPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对外类型
|
// 对外类型
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { LocationPosition } from '../dataset/enum/Common'
|
||||||
import { ControlType, ControlIndentation } from '../dataset/enum/Control'
|
import { ControlType, ControlIndentation } from '../dataset/enum/Control'
|
||||||
import { EditorZone } from '../dataset/enum/Editor'
|
import { EditorZone } from '../dataset/enum/Editor'
|
||||||
import { MoveDirection } from '../dataset/enum/Observer'
|
import { MoveDirection } from '../dataset/enum/Observer'
|
||||||
@@ -168,3 +169,7 @@ export interface INextControlContext {
|
|||||||
export interface IInitNextControlOption {
|
export interface IInitNextControlOption {
|
||||||
direction?: MoveDirection
|
direction?: MoveDirection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ILocationControlOption {
|
||||||
|
position: LocationPosition
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user