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 | 148 | * !#zh 点击插件,copy 其基础数据到组件树(中间画布) |
| 149 | 149 | * #!en click the plugin shortcut, create new Element with the plugin's meta data |
| 150 | 150 | * pluginInfo {Object}: 插件列表中的基础数据, {name}=pluginInfo |
| 151 | + * | |
| 152 | + * shortcutItem: PluginListItem = { | |
| 153 | + name: String, | |
| 154 | + shortcutProps: {} | |
| 155 | + } | |
| 151 | 156 | */ |
| 152 | - clone ({ name }) { | |
| 157 | + clone (shortcutItem) { | |
| 153 | 158 | this.elementManager({ |
| 154 | 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 | 53 | if (typeof ele.pluginProps === 'object') { |
| 54 | 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 | 59 | // init prop of plugin |
| 60 | - getDefaultPluginProps (props) { | |
| 61 | - const pluginProps = { | |
| 60 | + getDefaultPluginProps (props = {}, shortcutProps) { | |
| 61 | + let pluginProps = { | |
| 62 | 62 | uuid: this.uuid |
| 63 | 63 | } |
| 64 | 64 | Object.keys(props).forEach(key => { |
| ... | ... | @@ -70,6 +70,12 @@ class Element { |
| 70 | 70 | const defaultValue = props[key].default |
| 71 | 71 | pluginProps[key] = typeof defaultValue === 'function' ? defaultValue() : defaultValue |
| 72 | 72 | }) |
| 73 | + | |
| 74 | + pluginProps = { | |
| 75 | + ...pluginProps, | |
| 76 | + ...shortcutProps | |
| 77 | + } | |
| 78 | + | |
| 73 | 79 | return pluginProps |
| 74 | 80 | } |
| 75 | 81 | ... | ... |
front-end/h5/src/store/modules/element.js