fix: control value style not affected by prefix #227
This commit is contained in:
@@ -2,12 +2,13 @@ import {
|
|||||||
EDITOR_COMPONENT,
|
EDITOR_COMPONENT,
|
||||||
EDITOR_PREFIX
|
EDITOR_PREFIX
|
||||||
} from '../../../../dataset/constant/Editor'
|
} from '../../../../dataset/constant/Editor'
|
||||||
|
import { EDITOR_ELEMENT_STYLE_ATTR } from '../../../../dataset/constant/Element'
|
||||||
import { ControlComponent } from '../../../../dataset/enum/Control'
|
import { ControlComponent } from '../../../../dataset/enum/Control'
|
||||||
import { EditorComponent } from '../../../../dataset/enum/Editor'
|
import { EditorComponent } from '../../../../dataset/enum/Editor'
|
||||||
import { KeyMap } from '../../../../dataset/enum/KeyMap'
|
import { KeyMap } from '../../../../dataset/enum/KeyMap'
|
||||||
import { IControlInstance } from '../../../../interface/Control'
|
import { IControlInstance } from '../../../../interface/Control'
|
||||||
import { IElement } from '../../../../interface/Element'
|
import { IElement } from '../../../../interface/Element'
|
||||||
import { splitText } from '../../../../utils'
|
import { omitObject, splitText } from '../../../../utils'
|
||||||
import { formatElementContext } from '../../../../utils/element'
|
import { formatElementContext } from '../../../../utils/element'
|
||||||
import { Control } from '../Control'
|
import { Control } from '../Control'
|
||||||
|
|
||||||
@@ -189,12 +190,16 @@ export class SelectControl implements IControlInstance {
|
|||||||
// 插入
|
// 插入
|
||||||
const elementList = this.control.getElementList()
|
const elementList = this.control.getElementList()
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
|
const anchorElement =
|
||||||
|
startElement.controlComponent === ControlComponent.PREFIX
|
||||||
|
? omitObject(startElement, EDITOR_ELEMENT_STYLE_ATTR)
|
||||||
|
: startElement
|
||||||
const start = startIndex + 1
|
const start = startIndex + 1
|
||||||
const data = splitText(valueSet.value)
|
const data = splitText(valueSet.value)
|
||||||
const draw = this.control.getDraw()
|
const draw = this.control.getDraw()
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const newElement: IElement = {
|
const newElement: IElement = {
|
||||||
...startElement,
|
...anchorElement,
|
||||||
value: data[i],
|
value: data[i],
|
||||||
controlComponent: ControlComponent.VALUE
|
controlComponent: ControlComponent.VALUE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import { EDITOR_ELEMENT_STYLE_ATTR } from '../../../../dataset/constant/Element'
|
||||||
import { ControlComponent } from '../../../../dataset/enum/Control'
|
import { ControlComponent } from '../../../../dataset/enum/Control'
|
||||||
import { KeyMap } from '../../../../dataset/enum/KeyMap'
|
import { KeyMap } from '../../../../dataset/enum/KeyMap'
|
||||||
import { IControlInstance } from '../../../../interface/Control'
|
import { IControlInstance } from '../../../../interface/Control'
|
||||||
import { IElement } from '../../../../interface/Element'
|
import { IElement } from '../../../../interface/Element'
|
||||||
|
import { omitObject } from '../../../../utils'
|
||||||
import { formatElementContext } from '../../../../utils/element'
|
import { formatElementContext } from '../../../../utils/element'
|
||||||
import { Control } from '../Control'
|
import { Control } from '../Control'
|
||||||
|
|
||||||
@@ -72,10 +74,14 @@ export class TextControl implements IControlInstance {
|
|||||||
}
|
}
|
||||||
// 插入
|
// 插入
|
||||||
const startElement = elementList[startIndex]
|
const startElement = elementList[startIndex]
|
||||||
|
const anchorElement =
|
||||||
|
startElement.controlComponent === ControlComponent.PREFIX
|
||||||
|
? omitObject(startElement, EDITOR_ELEMENT_STYLE_ATTR)
|
||||||
|
: startElement
|
||||||
const start = range.startIndex + 1
|
const start = range.startIndex + 1
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
const newElement: IElement = {
|
const newElement: IElement = {
|
||||||
...startElement,
|
...anchorElement,
|
||||||
...data[i],
|
...data[i],
|
||||||
controlComponent: ControlComponent.VALUE
|
controlComponent: ControlComponent.VALUE
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,16 @@ export function cloneProperty<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function omitObject<T>(object: T, keys: (keyof T)[]): T {
|
||||||
|
const cloneObject = deepClone(object)
|
||||||
|
for (const key in object) {
|
||||||
|
if (keys.includes(key)) {
|
||||||
|
delete cloneObject[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cloneObject
|
||||||
|
}
|
||||||
|
|
||||||
export function convertStringToBase64(input: string) {
|
export function convertStringToBase64(input: string) {
|
||||||
const encoder = new TextEncoder()
|
const encoder = new TextEncoder()
|
||||||
const data = encoder.encode(input)
|
const data = encoder.encode(input)
|
||||||
|
|||||||
Reference in New Issue
Block a user