Skip to content

Commit 0bf1d9e

Browse files
committed
fix: #107
1 parent 05c56f8 commit 0bf1d9e

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

front-end/h5/public/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
outline: none;
1212
}
1313
</style>
14+
<script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
1415
</head>
1516
<body>
1617
<noscript>

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ShortcutButton from './shortcut-button'
2+
import LoadNpmPlugins from './load-npm-plugins.vue'
23
import langMixin from '@/mixins/i18n'
34
export default {
45
mixins: [langMixin],
@@ -12,6 +13,9 @@ export default {
1213
type: Function
1314
}
1415
},
16+
data: () => ({
17+
npmPackages: []
18+
}),
1519
methods: {
1620
onClickShortcut (item) {
1721
if (this.handleClickShortcut) {
@@ -89,7 +93,7 @@ export default {
8993
return (
9094
<a-row gutter={20}>
9195
{
92-
this.pluginsList.filter(plugin => plugin.visible).map(plugin => (
96+
[].concat(this.pluginsList, this.npmPackages).filter(plugin => plugin.visible).map(plugin => (
9397
<a-col span={12} style={{ marginTop: '10px' }}>
9498
<ShortcutButton
9599
clickFn={this.onClickShortcut.bind(this, plugin)}
@@ -101,6 +105,9 @@ export default {
101105
</a-col>
102106
))
103107
}
108+
<LoadNpmPlugins onLoadComplete={npmPackages => {
109+
this.npmPackages = npmPackages
110+
}} />
104111
</a-row>
105112
)
106113
}

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ class Element {
3131
* 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(),
3232
* element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误
3333
*/
34-
this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj(ele.pluginProps)) || this.getDefaultPluginProps(ele.editorConfig || {})
34+
this.pluginProps = (typeof ele.pluginProps === 'object' && cloneObj({ ...ele.pluginProps, uuid: this.uuid })) || this.getDefaultPluginProps(ele.editorConfig || {})
3535
this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex }
3636
this.events = []
3737
this.animations = ele.animations || []
3838
}
3939

4040
// init prop of plugin
4141
getDefaultPluginProps (propsConfig) {
42-
const pluginProps = {}
42+
const pluginProps = {
43+
uuid: this.uuid
44+
}
4345
Object.keys(propsConfig).forEach(key => {
4446
// #6
4547
if (key === 'name') {

front-end/h5/src/components/plugins/lbp-form-checkbox-group.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import LbpFormRadio from './lbp-form-radio.js'
2-
import { genUUID } from '../../utils/element.js'
32

43
const defaultItems = [
54
{
@@ -21,7 +20,7 @@ export default {
2120
props: {
2221
aliasName: {
2322
type: String,
24-
default: `标题演示-${genUUID().slice(0, 6)}`,
23+
default: `标题演示`,
2524
editor: {
2625
type: 'a-input',
2726
label: '填写标题',
@@ -110,15 +109,15 @@ export default {
110109
render () {
111110
return (
112111
<div>
113-
<h3>{this.aliasName}{this.type}</h3>
112+
<h3>{this.aliasName}</h3>
114113
<input type="text" hidden value={this.value_} data-type="lbp-form-input" data-uuid={this.uuid} />
115114
{
116115
this.items.map(item => (
117116
<lbp-form-radio
118117
vertical
119118
value={item.value}
120119
checked={this.type === 'radio' ? this.value === item.value : this.value.includes(item.value)}
121-
aliasName={this.aliasName}
120+
aliasName={this.uuid}
122121
type={this.type}
123122
onChange={this.onChange}
124123
>{item.value}</lbp-form-radio>

front-end/h5/src/components/plugins/lbp-form-radio-group.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default {
1818
props: {
1919
aliasName: {
2020
type: String,
21-
default: `标题演示-${genUUID().slice(0, 6)}`,
21+
default: `标题演示`,
2222
editor: {
2323
type: 'a-input',
2424
label: '填写标题',
@@ -115,7 +115,7 @@ export default {
115115
vertical
116116
value={item.value}
117117
checked={this.value === item.value}
118-
aliasName={this.aliasName}
118+
aliasName={this.uuid}
119119
type={this.type}
120120
onChange={this.onChange}
121121
>{item.value}

0 commit comments

Comments
 (0)