feat:optimize add content block
This commit is contained in:
@@ -3,5 +3,6 @@
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 8px;
|
||||
background-color: #ffffff;
|
||||
border: 1px solid rgb(235 236 240);
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user