feat:optimize add content block

This commit is contained in:
Hufe921
2022-11-29 21:23:31 +08:00
parent 67d69e9b74
commit c79f647bc7
6 changed files with 52 additions and 11 deletions
+10 -3
View File
@@ -9,10 +9,10 @@ import { ControlComponent, ControlType } from '../dataset/enum/Control'
interface IFormatElementListOption {
isHandleFirstElement?: boolean;
editorOptions?: Required<IEditorOption>;
editorOptions: Required<IEditorOption>;
}
export function formatElementList(elementList: IElement[], options: IFormatElementListOption = {}) {
export function formatElementList(elementList: IElement[], options: IFormatElementListOption) {
const { isHandleFirstElement, editorOptions } = <IFormatElementListOption>{
isHandleFirstElement: true,
...options
@@ -237,9 +237,16 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
if (el.value === '\n') {
el.value = ZERO
}
if (el.type === ElementType.IMAGE || el.type === ElementType.BLOCK) {
if (el.type === ElementType.IMAGE) {
el.id = getUUID()
}
if (el.type === ElementType.BLOCK) {
el.id = getUUID()
if (!el.width) {
const { editorOptions: { width, margins } } = options
el.width = width - margins[1] - margins[3]
}
}
if (el.type === ElementType.LATEX) {
const { svg, width, height } = LaTexParticle.convertLaTextToSVG(el.value)
el.width = el.width || width