fix: format control element default options
This commit is contained in:
@@ -8,9 +8,7 @@ import {
|
|||||||
RowFlex
|
RowFlex
|
||||||
} from '..'
|
} from '..'
|
||||||
import { LaTexParticle } from '../core/draw/particle/latex/LaTexParticle'
|
import { LaTexParticle } from '../core/draw/particle/latex/LaTexParticle'
|
||||||
import { defaultCheckboxOption } from '../dataset/constant/Checkbox'
|
|
||||||
import { NON_BREAKING_SPACE, ZERO } from '../dataset/constant/Common'
|
import { NON_BREAKING_SPACE, ZERO } from '../dataset/constant/Common'
|
||||||
import { defaultControlOption } from '../dataset/constant/Control'
|
|
||||||
import {
|
import {
|
||||||
EDITOR_ELEMENT_CONTEXT_ATTR,
|
EDITOR_ELEMENT_CONTEXT_ATTR,
|
||||||
EDITOR_ELEMENT_ZIP_ATTR,
|
EDITOR_ELEMENT_ZIP_ATTR,
|
||||||
@@ -46,7 +44,7 @@ export function unzipElementList(elementList: IElement[]): IElement[] {
|
|||||||
|
|
||||||
interface IFormatElementListOption {
|
interface IFormatElementListOption {
|
||||||
isHandleFirstElement?: boolean
|
isHandleFirstElement?: boolean
|
||||||
editorOptions: Required<IEditorOption>
|
editorOptions: DeepRequired<IEditorOption>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function formatElementList(
|
export function formatElementList(
|
||||||
@@ -198,6 +196,9 @@ export function formatElementList(
|
|||||||
} else if (el.type === ElementType.CONTROL) {
|
} else if (el.type === ElementType.CONTROL) {
|
||||||
const { prefix, postfix, value, placeholder, code, type, valueSets } =
|
const { prefix, postfix, value, placeholder, code, type, valueSets } =
|
||||||
el.control!
|
el.control!
|
||||||
|
const {
|
||||||
|
editorOptions: { control: controlOption, checkbox: checkboxOption }
|
||||||
|
} = options
|
||||||
const controlId = getUUID()
|
const controlId = getUUID()
|
||||||
// 移除父节点
|
// 移除父节点
|
||||||
elementList.splice(i, 1)
|
elementList.splice(i, 1)
|
||||||
@@ -207,7 +208,7 @@ export function formatElementList(
|
|||||||
thePrePostfixArgs.color = editorOptions.control.bracketColor
|
thePrePostfixArgs.color = editorOptions.control.bracketColor
|
||||||
}
|
}
|
||||||
// 前缀
|
// 前缀
|
||||||
const prefixStrList = splitText(prefix || defaultControlOption.prefix)
|
const prefixStrList = splitText(prefix || controlOption.prefix)
|
||||||
for (let p = 0; p < prefixStrList.length; p++) {
|
for (let p = 0; p < prefixStrList.length; p++) {
|
||||||
const value = prefixStrList[p]
|
const value = prefixStrList[p]
|
||||||
elementList.splice(i, 0, {
|
elementList.splice(i, 0, {
|
||||||
@@ -264,7 +265,7 @@ export function formatElementList(
|
|||||||
controlId,
|
controlId,
|
||||||
value,
|
value,
|
||||||
type: el.type,
|
type: el.type,
|
||||||
letterSpacing: isLastLetter ? defaultCheckboxOption.gap : 0,
|
letterSpacing: isLastLetter ? checkboxOption.gap : 0,
|
||||||
control: el.control,
|
control: el.control,
|
||||||
controlComponent: ControlComponent.VALUE
|
controlComponent: ControlComponent.VALUE
|
||||||
})
|
})
|
||||||
@@ -324,7 +325,7 @@ export function formatElementList(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 后缀
|
// 后缀
|
||||||
const postfixStrList = splitText(postfix || defaultControlOption.postfix)
|
const postfixStrList = splitText(postfix || controlOption.postfix)
|
||||||
for (let p = 0; p < postfixStrList.length; p++) {
|
for (let p = 0; p < postfixStrList.length; p++) {
|
||||||
const value = postfixStrList[p]
|
const value = postfixStrList[p]
|
||||||
elementList.splice(i, 0, {
|
elementList.splice(i, 0, {
|
||||||
|
|||||||
Reference in New Issue
Block a user