Commit 4a7ae5709be9f0d2017ebd7894fcf64532b73f5d
1 parent
8b27425e
chore(editor): update canvas after editing plugin props
Showing
1 changed file
with
6 additions
and
2 deletions
front-end/h5/src/views/Editor.vue
| @@ -291,8 +291,6 @@ const defaultProps = { | @@ -291,8 +291,6 @@ const defaultProps = { | ||
| 291 | 291 | ||
| 292 | class Element { | 292 | class Element { |
| 293 | constructor (ele) { | 293 | constructor (ele) { |
| 294 | - // TODO 需要处理plugin的prop中是 name 的,会覆盖 this.name, | ||
| 295 | - // 或者将plugin的props赋值给this.pluginProps,这样可以避免冲突,也可以知道哪些是plugin 的props | ||
| 296 | this.name = ele.name | 294 | this.name = ele.name |
| 297 | this.editorConfig = ele.editorConfig || {} | 295 | this.editorConfig = ele.editorConfig || {} |
| 298 | this.init() | 296 | this.init() |
| @@ -307,6 +305,11 @@ class Element { | @@ -307,6 +305,11 @@ class Element { | ||
| 307 | // init prop of plugin | 305 | // init prop of plugin |
| 308 | const propConf = this.editorConfig.propsConfig | 306 | const propConf = this.editorConfig.propsConfig |
| 309 | Object.keys(propConf).forEach(key => { | 307 | Object.keys(propConf).forEach(key => { |
| 308 | + // #6 | ||
| 309 | + if (key === 'name') { | ||
| 310 | + console.warn('Please do not use {name} as plugin prop') | ||
| 311 | + return | ||
| 312 | + } | ||
| 310 | this[key] = propConf[key].defaultPropValue | 313 | this[key] = propConf[key].defaultPropValue |
| 311 | }) | 314 | }) |
| 312 | } | 315 | } |
| @@ -381,6 +384,7 @@ const Editor = { | @@ -381,6 +384,7 @@ const Editor = { | ||
| 381 | return (() => { | 384 | return (() => { |
| 382 | const data = { | 385 | const data = { |
| 383 | style: element.getStyle(), | 386 | style: element.getStyle(), |
| 387 | + props: element, // #6 | ||
| 384 | nativeOn: { | 388 | nativeOn: { |
| 385 | click: this.setCurrentEditingElement.bind(this, element) | 389 | click: this.setCurrentEditingElement.bind(this, element) |
| 386 | } | 390 | } |