Skip to content

Commit 1070215

Browse files
committed
feat: add shortcutProps to support shortcut themes; !#zh: 增加 shortcutProps 以支持快捷面板定制化/主题化
1 parent cf70307 commit 1070215

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

front-end/h5/src/components/core/editor/index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,16 @@ export default {
148148
* !#zh 点击插件,copy 其基础数据到组件树(中间画布)
149149
* #!en click the plugin shortcut, create new Element with the plugin's meta data
150150
* pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo
151+
*
152+
* shortcutItem: PluginListItem = {
153+
name: String,
154+
shortcutProps: {}
155+
}
151156
*/
152-
clone ({ name }) {
157+
clone (shortcutItem) {
153158
this.elementManager({
154159
type: 'add',
155-
value: { name }
160+
value: shortcutItem
156161
})
157162
},
158163
/**

front-end/h5/src/components/core/models/element.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ class Element {
5353
if (typeof ele.pluginProps === 'object') {
5454
return cloneObj({ ...ele.pluginProps, uuid: this.uuid })
5555
}
56-
return this.getDefaultPluginProps(ele.props || {})
56+
return this.getDefaultPluginProps(ele.props, ele.shortcutProps)
5757
}
5858

5959
// init prop of plugin
60-
getDefaultPluginProps (props) {
61-
const pluginProps = {
60+
getDefaultPluginProps (props = {}, shortcutProps) {
61+
let pluginProps = {
6262
uuid: this.uuid
6363
}
6464
Object.keys(props).forEach(key => {
@@ -70,6 +70,12 @@ class Element {
7070
const defaultValue = props[key].default
7171
pluginProps[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue
7272
})
73+
74+
pluginProps = {
75+
...pluginProps,
76+
...shortcutProps
77+
}
78+
7379
return pluginProps
7480
}
7581

front-end/h5/src/store/modules/element.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const mutations = {
4040
switch (type) {
4141
case 'add':
4242
const vm = getVM(value.name)
43+
vm.$options.shortcutProps = value.shortcutProps
4344
const element = new Element(vm.$options)
4445
elements.push(element)
4546
break

0 commit comments

Comments
 (0)