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
+1
View File
@@ -3,5 +3,6 @@
z-index: 0;
overflow: hidden;
border-radius: 8px;
background-color: #ffffff;
border: 1px solid rgb(235 236 240);
}
+3 -1
View File
@@ -430,7 +430,9 @@ export class CommandAdapt {
trList
}
// 格式化element
formatElementList([element])
formatElementList([element], {
editorOptions: this.options
})
const curIndex = startIndex + 1
if (startIndex === endIndex) {
elementList.splice(curIndex, 0, element)
+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