Skip to content

Commit 9e8e89f

Browse files
committed
feat(editor): mixin custom component for plugin props into editor
1 parent 28a0310 commit 9e8e89f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

front-end/h5/src/views/Editor.vue

+14-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,12 @@ const LbpButton = {
203203
}),
204204
computed: {
205205
value_: {
206-
get: () => this.value,
206+
// TODO 关于箭头函数中的this:这里不能写成箭头函数,否则 this 为 undefined,为何?
207+
// http://davidshariff.com/blog/what-is-the-execution-context-in-javascript/
208+
// https://tangxiaolang101.github.io/2016/08/01/%E6%B7%B1%E5%85%A5%E6%8E%A2%E8%AE%A8JavaScript%E7%9A%84%E6%89%A7%E8%A1%8C%E7%8E%AF%E5%A2%83%E5%92%8C%E6%A0%88%EF%BC%88What%20is%20the%20Execution%20Context%20&%20Stack%20in%20JavaScript%EF%BC%89/
209+
get () {
210+
return this.value
211+
},
207212
set (val) {
208213
this.$emit('input', val)
209214
}
@@ -350,8 +355,16 @@ const Editor = {
350355
const editorConfig = this.getEditorConfig(name)
351356
this.elements.push(new Element({ name, zindex, editorConfig }))
352357
},
358+
mixinPluginCustomComponents2Editor () {
359+
const { components } = this.editingElement.editorConfig
360+
for (const key in components) {
361+
if (this.$options.components[key]) return
362+
this.$options.components[key] = components[key]
363+
}
364+
},
353365
setCurrentEditingElement (element) {
354366
this.editingElement = element
367+
this.mixinPluginCustomComponents2Editor()
355368
},
356369
/**
357370
* #!zh: renderCanvas 渲染中间画布

0 commit comments

Comments
 (0)