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,
|
"ruler": true,
|
||||||
"background": {color:"#123456",opacity:0.1},
|
"background": {color:"#123456",opacity:0.1},
|
||||||
// "theme": "ddei-core-theme-black",
|
// "theme": "ddei-core-theme-black",
|
||||||
controls: [
|
initData: {
|
||||||
{
|
controls:[
|
||||||
id: "act_1",
|
{
|
||||||
model: "102010",
|
id: "act_1",
|
||||||
code: "active_01",
|
model: "102010",
|
||||||
text: "第一步",
|
code: "active_01",
|
||||||
border:{color:"yellow",dash:[10,10,5,5],width:5},
|
text: "第一步",
|
||||||
fill:{color:"grey"},
|
border:{color:"yellow",dash:[10,10,5,5],width:5},
|
||||||
},
|
fill:{color:"grey"},
|
||||||
{
|
},
|
||||||
id: "act_2",
|
{
|
||||||
model: "102010",
|
id: "act_2",
|
||||||
code: "active_02",
|
model: "102010",
|
||||||
width: 200,
|
code: "active_02",
|
||||||
height: 100,
|
width: 200,
|
||||||
text: "第二步",
|
height: 100,
|
||||||
y: -70,
|
text: "第二步",
|
||||||
}
|
y: -70,
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
//配置扩展插件
|
//配置扩展插件
|
||||||
extensions: [
|
extensions: [
|
||||||
@ -144,24 +146,26 @@ export default defineComponent({
|
|||||||
access:{"DEL":false},
|
access:{"DEL":false},
|
||||||
"paper":"A5",
|
"paper":"A5",
|
||||||
"ruler": true,
|
"ruler": true,
|
||||||
controls: [
|
initData: {
|
||||||
{
|
controls: [
|
||||||
id: "act_1",
|
{
|
||||||
model: "102010",
|
id: "act_1",
|
||||||
code: "active_01",
|
model: "102010",
|
||||||
text: "第一步",
|
code: "active_01",
|
||||||
y: 70,
|
text: "第一步",
|
||||||
},
|
y: 70,
|
||||||
{
|
},
|
||||||
id: "act_2",
|
{
|
||||||
model: "102010",
|
id: "act_2",
|
||||||
code: "active_02",
|
model: "102010",
|
||||||
width: 200,
|
code: "active_02",
|
||||||
height: 100,
|
width: 200,
|
||||||
text: "第二步",
|
height: 100,
|
||||||
y: -70,
|
text: "第二步",
|
||||||
}
|
y: -70,
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
//配置扩展插件
|
//配置扩展插件
|
||||||
extensions: [
|
extensions: [
|
||||||
@ -183,24 +187,26 @@ export default defineComponent({
|
|||||||
EXT_STAGE_HEIGHT:false,
|
EXT_STAGE_HEIGHT:false,
|
||||||
ruler:0,
|
ruler:0,
|
||||||
grid: 0,
|
grid: 0,
|
||||||
controls: [
|
initData: {
|
||||||
{
|
controls: [
|
||||||
id: "rect_1",
|
{
|
||||||
model: "102010",
|
id: "rect_1",
|
||||||
code: "active_01",
|
model: "102010",
|
||||||
width: 200,
|
code: "active_01",
|
||||||
height: 100,
|
width: 200,
|
||||||
text: "第一步"
|
height: 100,
|
||||||
},
|
text: "第一步"
|
||||||
{
|
},
|
||||||
id: "rect_2",
|
{
|
||||||
model: "102010",
|
id: "rect_2",
|
||||||
code: "active_02",
|
model: "102010",
|
||||||
width: 200,
|
code: "active_02",
|
||||||
height: 100,
|
width: 200,
|
||||||
text: "第二步"
|
height: 100,
|
||||||
}
|
text: "第二步"
|
||||||
]
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
//配置扩展插件
|
//配置扩展插件
|
||||||
extensions: [
|
extensions: [
|
||||||
|
|||||||
@ -100,15 +100,15 @@ export default {
|
|||||||
DDeiEditorUtil.getControlIcons(this.editor);
|
DDeiEditorUtil.getControlIcons(this.editor);
|
||||||
|
|
||||||
//初始化控件
|
//初始化控件
|
||||||
if(this.options?.config?.controls){
|
if(this.options?.config?.initData){
|
||||||
//调用转换器,将输入内容转换为设计器能够识别的格式
|
//调用转换器,将输入内容转换为设计器能够识别的格式
|
||||||
let controls = this.options?.config?.controls;
|
let initData = this.options?.config?.initData
|
||||||
let converters = this.editor.getEnabledConverters(controls, 1);
|
let converters = this.editor.getEnabledConverters(initData, 1);
|
||||||
//依次调用converters
|
//依次调用converters
|
||||||
converters?.forEach(converter => {
|
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){
|
if (this.options?.config?.access){
|
||||||
this.editor.setAccessInfo(this.options?.config?.access)
|
this.editor.setAccessInfo(this.options?.config?.access)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user