Skip to content

Commit

Permalink
feat:render checkbox control with style
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Mar 10, 2023
1 parent a3664a2 commit 9f64a06
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/editor/utils/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
if (type === ControlType.CHECKBOX) {
const codeList = code ? code.split(',') : []
if (Array.isArray(valueSets) && valueSets.length) {
// 拆分valueList优先使用其属性
const valueStyleList = valueList.reduce(
(pre, cur) => pre.concat(cur.value.split('').map(v => ({ ...cur, value: v }))),
[] as IElement[]
)
let valueStyleIndex = 0
for (let v = 0; v < valueSets.length; v++) {
const valueSet = valueSets[v]
// checkbox组件
Expand All @@ -155,13 +161,15 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
const value = valueStrList[e]
const isLastLetter = e === valueStrList.length - 1
elementList.splice(i, 0, {
...valueStyleList[valueStyleIndex],
controlId,
value,
type: el.type,
letterSpacing: isLastLetter ? defaultCheckboxOption.gap : 0,
control: el.control,
controlComponent: ControlComponent.VALUE
})
valueStyleIndex++
i++
}
}
Expand Down

0 comments on commit 9f64a06

Please sign in to comment.