Commit 1070215d7013beb68b4b3f79762d6e17aa316c69
1 parent
cf703071
feat: add shortcutProps to support shortcut themes; !#zh: 增加 shortcutProps 以支持快捷面板定制化/主题化
Showing
3 changed files
with
17 additions
and
5 deletions
front-end/h5/src/components/core/editor/index.js
| @@ -148,11 +148,16 @@ export default { | @@ -148,11 +148,16 @@ export default { | ||
| 148 | * !#zh 点击插件,copy 其基础数据到组件树(中间画布) | 148 | * !#zh 点击插件,copy 其基础数据到组件树(中间画布) |
| 149 | * #!en click the plugin shortcut, create new Element with the plugin's meta data | 149 | * #!en click the plugin shortcut, create new Element with the plugin's meta data |
| 150 | * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo | 150 | * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo |
| 151 | + * | ||
| 152 | + * shortcutItem: PluginListItem = { | ||
| 153 | + name: String, | ||
| 154 | + shortcutProps: {} | ||
| 155 | + } | ||
| 151 | */ | 156 | */ |
| 152 | - clone ({ name }) { | 157 | + clone (shortcutItem) { |
| 153 | this.elementManager({ | 158 | this.elementManager({ |
| 154 | type: 'add', | 159 | type: 'add', |
| 155 | - value: { name } | 160 | + value: shortcutItem |
| 156 | }) | 161 | }) |
| 157 | }, | 162 | }, |
| 158 | /** | 163 | /** |
front-end/h5/src/components/core/models/element.js
| @@ -53,12 +53,12 @@ class Element { | @@ -53,12 +53,12 @@ class Element { | ||
| 53 | if (typeof ele.pluginProps === 'object') { | 53 | if (typeof ele.pluginProps === 'object') { |
| 54 | return cloneObj({ ...ele.pluginProps, uuid: this.uuid }) | 54 | return cloneObj({ ...ele.pluginProps, uuid: this.uuid }) |
| 55 | } | 55 | } |
| 56 | - return this.getDefaultPluginProps(ele.props || {}) | 56 | + return this.getDefaultPluginProps(ele.props, ele.shortcutProps) |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // init prop of plugin | 59 | // init prop of plugin |
| 60 | - getDefaultPluginProps (props) { | ||
| 61 | - const pluginProps = { | 60 | + getDefaultPluginProps (props = {}, shortcutProps) { |
| 61 | + let pluginProps = { | ||
| 62 | uuid: this.uuid | 62 | uuid: this.uuid |
| 63 | } | 63 | } |
| 64 | Object.keys(props).forEach(key => { | 64 | Object.keys(props).forEach(key => { |
| @@ -70,6 +70,12 @@ class Element { | @@ -70,6 +70,12 @@ class Element { | ||
| 70 | const defaultValue = props[key].default | 70 | const defaultValue = props[key].default |
| 71 | pluginProps[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue | 71 | pluginProps[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue |
| 72 | }) | 72 | }) |
| 73 | + | ||
| 74 | + pluginProps = { | ||
| 75 | + ...pluginProps, | ||
| 76 | + ...shortcutProps | ||
| 77 | + } | ||
| 78 | + | ||
| 73 | return pluginProps | 79 | return pluginProps |
| 74 | } | 80 | } |
| 75 | 81 |
front-end/h5/src/store/modules/element.js
| @@ -40,6 +40,7 @@ export const mutations = { | @@ -40,6 +40,7 @@ export const mutations = { | ||
| 40 | switch (type) { | 40 | switch (type) { |
| 41 | case 'add': | 41 | case 'add': |
| 42 | const vm = getVM(value.name) | 42 | const vm = getVM(value.name) |
| 43 | + vm.$options.shortcutProps = value.shortcutProps | ||
| 43 | const element = new Element(vm.$options) | 44 | const element = new Element(vm.$options) |
| 44 | elements.push(element) | 45 | elements.push(element) |
| 45 | break | 46 | break |