diff --git a/src/editor/core/draw/control/select/SelectControl.ts b/src/editor/core/draw/control/select/SelectControl.ts index b4be457..3751a97 100644 --- a/src/editor/core/draw/control/select/SelectControl.ts +++ b/src/editor/core/draw/control/select/SelectControl.ts @@ -5,6 +5,7 @@ import { import { EDITOR_ELEMENT_STYLE_ATTR } from '../../../../dataset/constant/Element' import { ControlComponent } from '../../../../dataset/enum/Control' import { EditorComponent } from '../../../../dataset/enum/Editor' +import { ElementType } from '../../../../dataset/enum/Element' import { KeyMap } from '../../../../dataset/enum/KeyMap' import { IControlContext, @@ -231,6 +232,7 @@ export class SelectControl implements IControlInstance { const newElement: IElement = { ...styleElement, ...propertyElement, + type: ElementType.TEXT, value: data[i], controlComponent: ControlComponent.VALUE } diff --git a/src/editor/utils/element.ts b/src/editor/utils/element.ts index 9214b60..612fc0e 100644 --- a/src/editor/utils/element.ts +++ b/src/editor/utils/element.ts @@ -265,7 +265,6 @@ export function formatElementList( ...valueStyleList[valueStyleIndex], controlId, value, - type: el.type, letterSpacing: isLastLetter ? checkboxOption.gap : 0, control: el.control, controlComponent: ControlComponent.VALUE @@ -297,7 +296,7 @@ export function formatElementList( ...element, controlId, value, - type: el.type, + type: element.type || ElementType.TEXT, control: el.control, controlComponent: ControlComponent.VALUE }) @@ -831,21 +830,18 @@ export function createDomFromElementList( const tab = document.createElement('span') tab.innerHTML = `${NON_BREAKING_SPACE}${NON_BREAKING_SPACE}` clipboardDom.append(tab) + } else if (element.type === ElementType.CONTROL) { + const controlElement = document.createElement('span') + const childDom = buildDom(zipElementList(element.control?.value || [])) + controlElement.innerHTML = childDom.innerHTML + clipboardDom.append(controlElement) } else if ( !element.type || element.type === ElementType.LATEX || TEXTLIKE_ELEMENT_TYPE.includes(element.type) ) { let text = '' - if (element.controlId) { - text = - element - .control!.value?.filter( - v => !v.type || TEXTLIKE_ELEMENT_TYPE.includes(v.type) - ) - .map(v => v.value) - .join('') || '' - } else if (element.type === ElementType.DATE) { + if (element.type === ElementType.DATE) { text = element.valueList?.map(v => v.value).join('') || '' } else { text = element.value