mirror of
https://gitee.com/hoslay/ddei-editor.git
synced 2025-12-07 01:28:28 +08:00
优化创建控件API,引入转换器插件
This commit is contained in:
parent
3e0843ed74
commit
c272632ec9
116
src/App.vue
116
src/App.vue
@ -110,25 +110,27 @@ export default defineComponent({
|
||||
"ruler": true,
|
||||
"background": {color:"#123456",opacity:0.1},
|
||||
// "theme": "ddei-core-theme-black",
|
||||
controls: [
|
||||
{
|
||||
id: "act_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
text: "第一步",
|
||||
border:{color:"yellow",dash:[10,10,5,5],width:5},
|
||||
fill:{color:"grey"},
|
||||
},
|
||||
{
|
||||
id: "act_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步",
|
||||
y: -70,
|
||||
}
|
||||
]
|
||||
initData: {
|
||||
controls:[
|
||||
{
|
||||
id: "act_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
text: "第一步",
|
||||
border:{color:"yellow",dash:[10,10,5,5],width:5},
|
||||
fill:{color:"grey"},
|
||||
},
|
||||
{
|
||||
id: "act_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步",
|
||||
y: -70,
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
//配置扩展插件
|
||||
extensions: [
|
||||
@ -144,24 +146,26 @@ export default defineComponent({
|
||||
access:{"DEL":false},
|
||||
"paper":"A5",
|
||||
"ruler": true,
|
||||
controls: [
|
||||
{
|
||||
id: "act_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
text: "第一步",
|
||||
y: 70,
|
||||
},
|
||||
{
|
||||
id: "act_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步",
|
||||
y: -70,
|
||||
}
|
||||
]
|
||||
initData: {
|
||||
controls: [
|
||||
{
|
||||
id: "act_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
text: "第一步",
|
||||
y: 70,
|
||||
},
|
||||
{
|
||||
id: "act_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步",
|
||||
y: -70,
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
//配置扩展插件
|
||||
extensions: [
|
||||
@ -183,24 +187,26 @@ export default defineComponent({
|
||||
EXT_STAGE_HEIGHT:false,
|
||||
ruler:0,
|
||||
grid: 0,
|
||||
controls: [
|
||||
{
|
||||
id: "rect_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第一步"
|
||||
},
|
||||
{
|
||||
id: "rect_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步"
|
||||
}
|
||||
]
|
||||
initData: {
|
||||
controls: [
|
||||
{
|
||||
id: "rect_1",
|
||||
model: "102010",
|
||||
code: "active_01",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第一步"
|
||||
},
|
||||
{
|
||||
id: "rect_2",
|
||||
model: "102010",
|
||||
code: "active_02",
|
||||
width: 200,
|
||||
height: 100,
|
||||
text: "第二步"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
//配置扩展插件
|
||||
extensions: [
|
||||
|
||||
@ -100,15 +100,15 @@ export default {
|
||||
DDeiEditorUtil.getControlIcons(this.editor);
|
||||
|
||||
//初始化控件
|
||||
if(this.options?.config?.controls){
|
||||
if(this.options?.config?.initData){
|
||||
//调用转换器,将输入内容转换为设计器能够识别的格式
|
||||
let controls = this.options?.config?.controls;
|
||||
let converters = this.editor.getEnabledConverters(controls, 1);
|
||||
let initData = this.options?.config?.initData
|
||||
let converters = this.editor.getEnabledConverters(initData, 1);
|
||||
//依次调用converters
|
||||
converters?.forEach(converter => {
|
||||
controls = converter.input(controls)
|
||||
initData = converter.input(initData)
|
||||
});
|
||||
this.editor.addControls(controls)
|
||||
this.editor.addControls(initData.controls)
|
||||
}
|
||||
if (this.options?.config?.access){
|
||||
this.editor.setAccessInfo(this.options?.config?.access)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user