feat:optimize add content block
This commit is contained in:
@@ -10,6 +10,7 @@ export interface IDialogData {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
|
required?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IDialogConfirm {
|
export interface IDialogConfirm {
|
||||||
@@ -84,6 +85,9 @@ export class Dialog {
|
|||||||
const optionName = document.createElement('span')
|
const optionName = document.createElement('span')
|
||||||
optionName.append(document.createTextNode(option.label))
|
optionName.append(document.createTextNode(option.label))
|
||||||
optionItemContainer.append(optionName)
|
optionItemContainer.append(optionName)
|
||||||
|
if (option.required) {
|
||||||
|
optionName.classList.add('dialog-option__item--require')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 选项输入框
|
// 选项输入框
|
||||||
let optionInput: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
|
let optionInput: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
margin-right: 12px;
|
margin-right: 12px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #3d4757;
|
color: #3d4757;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-option__item input,
|
.dialog-option__item input,
|
||||||
@@ -84,6 +85,14 @@
|
|||||||
border-color: #4991f2;
|
border-color: #4991f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dialog-option__item--require::before {
|
||||||
|
content: "*";
|
||||||
|
color: #f56c6c;
|
||||||
|
margin-right: 4px;
|
||||||
|
position: absolute;
|
||||||
|
left: -8px;
|
||||||
|
}
|
||||||
|
|
||||||
.dialog-menu {
|
.dialog-menu {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
z-index: 0;
|
z-index: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
background-color: #ffffff;
|
||||||
border: 1px solid rgb(235 236 240);
|
border: 1px solid rgb(235 236 240);
|
||||||
}
|
}
|
||||||
@@ -430,7 +430,9 @@ export class CommandAdapt {
|
|||||||
trList
|
trList
|
||||||
}
|
}
|
||||||
// 格式化element
|
// 格式化element
|
||||||
formatElementList([element])
|
formatElementList([element], {
|
||||||
|
editorOptions: this.options
|
||||||
|
})
|
||||||
const curIndex = startIndex + 1
|
const curIndex = startIndex + 1
|
||||||
if (startIndex === endIndex) {
|
if (startIndex === endIndex) {
|
||||||
elementList.splice(curIndex, 0, element)
|
elementList.splice(curIndex, 0, element)
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import { ControlComponent, ControlType } from '../dataset/enum/Control'
|
|||||||
|
|
||||||
interface IFormatElementListOption {
|
interface IFormatElementListOption {
|
||||||
isHandleFirstElement?: boolean;
|
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>{
|
const { isHandleFirstElement, editorOptions } = <IFormatElementListOption>{
|
||||||
isHandleFirstElement: true,
|
isHandleFirstElement: true,
|
||||||
...options
|
...options
|
||||||
@@ -237,9 +237,16 @@ export function formatElementList(elementList: IElement[], options: IFormatEleme
|
|||||||
if (el.value === '\n') {
|
if (el.value === '\n') {
|
||||||
el.value = ZERO
|
el.value = ZERO
|
||||||
}
|
}
|
||||||
if (el.type === ElementType.IMAGE || el.type === ElementType.BLOCK) {
|
if (el.type === ElementType.IMAGE) {
|
||||||
el.id = getUUID()
|
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) {
|
if (el.type === ElementType.LATEX) {
|
||||||
const { svg, width, height } = LaTexParticle.convertLaTextToSVG(el.value)
|
const { svg, width, height } = LaTexParticle.convertLaTextToSVG(el.value)
|
||||||
el.width = el.width || width
|
el.width = el.width || width
|
||||||
|
|||||||
+25
-7
@@ -273,11 +273,13 @@ window.onload = function () {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
label: '文本',
|
label: '文本',
|
||||||
name: 'name',
|
name: 'name',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入文本'
|
placeholder: '请输入文本'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
label: '链接',
|
label: '链接',
|
||||||
name: 'url',
|
name: 'url',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入链接'
|
placeholder: '请输入链接'
|
||||||
}],
|
}],
|
||||||
onConfirm: (payload) => {
|
onConfirm: (payload) => {
|
||||||
@@ -340,16 +342,19 @@ window.onload = function () {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
label: '内容',
|
label: '内容',
|
||||||
name: 'data',
|
name: 'data',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入内容'
|
placeholder: '请输入内容'
|
||||||
}, {
|
}, {
|
||||||
type: 'color',
|
type: 'color',
|
||||||
label: '颜色',
|
label: '颜色',
|
||||||
name: 'color',
|
name: 'color',
|
||||||
|
required: true,
|
||||||
value: '#AEB5C0'
|
value: '#AEB5C0'
|
||||||
}, {
|
}, {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
label: '字体大小',
|
label: '字体大小',
|
||||||
name: 'size',
|
name: 'size',
|
||||||
|
required: true,
|
||||||
value: '120'
|
value: '120'
|
||||||
}],
|
}],
|
||||||
onConfirm: (payload) => {
|
onConfirm: (payload) => {
|
||||||
@@ -435,6 +440,7 @@ window.onload = function () {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
label: '占位符',
|
label: '占位符',
|
||||||
name: 'placeholder',
|
name: 'placeholder',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入占位符'
|
placeholder: '请输入占位符'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -469,6 +475,7 @@ window.onload = function () {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
label: '占位符',
|
label: '占位符',
|
||||||
name: 'placeholder',
|
name: 'placeholder',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入占位符'
|
placeholder: '请输入占位符'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@@ -479,6 +486,7 @@ window.onload = function () {
|
|||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
label: '值集',
|
label: '值集',
|
||||||
name: 'valueSets',
|
name: 'valueSets',
|
||||||
|
required: true,
|
||||||
height: 100,
|
height: 100,
|
||||||
placeholder: `请输入值集JSON,例:\n[{\n"value":"有",\n"code":"98175"\n}]`
|
placeholder: `请输入值集JSON,例:\n[{\n"value":"有",\n"code":"98175"\n}]`
|
||||||
}],
|
}],
|
||||||
@@ -514,6 +522,7 @@ window.onload = function () {
|
|||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
label: '值集',
|
label: '值集',
|
||||||
name: 'valueSets',
|
name: 'valueSets',
|
||||||
|
required: true,
|
||||||
height: 100,
|
height: 100,
|
||||||
placeholder: `请输入值集JSON,例:\n[{\n"value":"有",\n"code":"98175"\n}]`
|
placeholder: `请输入值集JSON,例:\n[{\n"value":"有",\n"code":"98175"\n}]`
|
||||||
}],
|
}],
|
||||||
@@ -622,6 +631,7 @@ window.onload = function () {
|
|||||||
label: '类型',
|
label: '类型',
|
||||||
name: 'type',
|
name: 'type',
|
||||||
value: 'iframe',
|
value: 'iframe',
|
||||||
|
required: true,
|
||||||
options: [{
|
options: [{
|
||||||
label: '网址',
|
label: '网址',
|
||||||
value: 'iframe'
|
value: 'iframe'
|
||||||
@@ -633,17 +643,19 @@ window.onload = function () {
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
label: '宽度',
|
label: '宽度',
|
||||||
name: 'width',
|
name: 'width',
|
||||||
placeholder: '请输入宽度'
|
placeholder: '请输入宽度(默认页面内宽度)'
|
||||||
}, {
|
}, {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
label: '宽度',
|
label: '高度',
|
||||||
name: 'height',
|
name: 'height',
|
||||||
placeholder: '请输入宽度'
|
required: true,
|
||||||
|
placeholder: '请输入高度'
|
||||||
}, {
|
}, {
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
label: '地址',
|
label: '地址',
|
||||||
height: 100,
|
height: 100,
|
||||||
name: 'value',
|
name: 'value',
|
||||||
|
required: true,
|
||||||
placeholder: '请输入地址'
|
placeholder: '请输入地址'
|
||||||
}],
|
}],
|
||||||
onConfirm: (payload) => {
|
onConfirm: (payload) => {
|
||||||
@@ -652,7 +664,6 @@ window.onload = function () {
|
|||||||
const value = payload.find(p => p.name === 'value')?.value
|
const value = payload.find(p => p.name === 'value')?.value
|
||||||
if (!value) return
|
if (!value) return
|
||||||
const width = payload.find(p => p.name === 'width')?.value
|
const width = payload.find(p => p.name === 'width')?.value
|
||||||
if (!width) return
|
|
||||||
const height = payload.find(p => p.name === 'height')?.value
|
const height = payload.find(p => p.name === 'height')?.value
|
||||||
if (!height) return
|
if (!height) return
|
||||||
const block: IBlock = {
|
const block: IBlock = {
|
||||||
@@ -667,13 +678,16 @@ window.onload = function () {
|
|||||||
src: value
|
src: value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
instance.command.executeInsertElementList([{
|
const blockElement: IElement = {
|
||||||
type: ElementType.BLOCK,
|
type: ElementType.BLOCK,
|
||||||
value: '',
|
value: '',
|
||||||
width: Number(width),
|
|
||||||
height: Number(height),
|
height: Number(height),
|
||||||
block
|
block
|
||||||
}])
|
}
|
||||||
|
if (width) {
|
||||||
|
blockElement.width = Number(width)
|
||||||
|
}
|
||||||
|
instance.command.executeInsertElementList([blockElement])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -798,24 +812,28 @@ window.onload = function () {
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
label: '上边距',
|
label: '上边距',
|
||||||
name: 'top',
|
name: 'top',
|
||||||
|
required: true,
|
||||||
value: `${topMargin}`,
|
value: `${topMargin}`,
|
||||||
placeholder: '请输入上边距'
|
placeholder: '请输入上边距'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
label: '下边距',
|
label: '下边距',
|
||||||
name: 'bottom',
|
name: 'bottom',
|
||||||
|
required: true,
|
||||||
value: `${bottomMargin}`,
|
value: `${bottomMargin}`,
|
||||||
placeholder: '请输入下边距'
|
placeholder: '请输入下边距'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
label: '左边距',
|
label: '左边距',
|
||||||
name: 'left',
|
name: 'left',
|
||||||
|
required: true,
|
||||||
value: `${leftMargin}`,
|
value: `${leftMargin}`,
|
||||||
placeholder: '请输入左边距'
|
placeholder: '请输入左边距'
|
||||||
}, {
|
}, {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
label: '右边距',
|
label: '右边距',
|
||||||
name: 'right',
|
name: 'right',
|
||||||
|
required: true,
|
||||||
value: `${rightMargin}`,
|
value: `${rightMargin}`,
|
||||||
placeholder: '请输入右边距'
|
placeholder: '请输入右边距'
|
||||||
}],
|
}],
|
||||||
|
|||||||
Reference in New Issue
Block a user