Commit 0bf1d9eeb4ac5bef3671e4708e4e8e0c9193493b

Authored by ly525
1 parent 05c56f89

fix: #107

front-end/h5/public/index.html
... ... @@ -11,6 +11,7 @@
11 11 outline: none;
12 12 }
13 13 </style>
  14 + <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
14 15 </head>
15 16 <body>
16 17 <noscript>
... ...
front-end/h5/src/components/core/editor/shortcuts-panel/index.js
1 1 import ShortcutButton from './shortcut-button'
  2 +import LoadNpmPlugins from './load-npm-plugins.vue'
2 3 import langMixin from '@/mixins/i18n'
3 4 export default {
4 5 mixins: [langMixin],
... ... @@ -12,6 +13,9 @@ export default {
12 13 type: Function
13 14 }
14 15 },
  16 + data: () => ({
  17 + npmPackages: []
  18 + }),
15 19 methods: {
16 20 onClickShortcut (item) {
17 21 if (this.handleClickShortcut) {
... ... @@ -89,7 +93,7 @@ export default {
89 93 return (
90 94 <a-row gutter={20}>
91 95 {
92   - this.pluginsList.filter(plugin => plugin.visible).map(plugin => (
  96 + [].concat(this.pluginsList, this.npmPackages).filter(plugin => plugin.visible).map(plugin => (
93 97 <a-col span={12} style={{ marginTop: '10px' }}>
94 98 <ShortcutButton
95 99 clickFn={this.onClickShortcut.bind(this, plugin)}
... ... @@ -101,6 +105,9 @@ export default {
101 105 </a-col>
102 106 ))
103 107 }
  108 + <LoadNpmPlugins onLoadComplete={npmPackages => {
  109 + this.npmPackages = npmPackages
  110 + }} />
104 111 </a-row>
105 112 )
106 113 }
... ...
front-end/h5/src/components/core/models/element.js
... ... @@ -31,7 +31,7 @@ class Element {
31 31 * 3. 为何需要 clone,因为会有 element.clone() 以及 page.clone(),
32 32 * element.pluginProps 和 elementcommonStyle 是引用类型,如果不做 deep_clone 可能会出现意外错误
33 33 */
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 || {})
35 35 this.commonStyle = (typeof ele.commonStyle === 'object' && cloneObj(ele.commonStyle)) || { ...defaultStyle, zindex: ele.zindex }
36 36 this.events = []
37 37 this.animations = ele.animations || []
... ... @@ -39,7 +39,9 @@ class Element {
39 39  
40 40 // init prop of plugin
41 41 getDefaultPluginProps (propsConfig) {
42   - const pluginProps = {}
  42 + const pluginProps = {
  43 + uuid: this.uuid
  44 + }
43 45 Object.keys(propsConfig).forEach(key => {
44 46 // #6
45 47 if (key === 'name') {
... ...
front-end/h5/src/components/plugins/lbp-form-checkbox-group.js
1 1 import LbpFormRadio from './lbp-form-radio.js'
2   -import { genUUID } from '../../utils/element.js'
3 2  
4 3 const defaultItems = [
5 4 {
... ... @@ -21,7 +20,7 @@ export default {
21 20 props: {
22 21 aliasName: {
23 22 type: String,
24   - default: `标题演示-${genUUID().slice(0, 6)}`,
  23 + default: `标题演示`,
25 24 editor: {
26 25 type: 'a-input',
27 26 label: '填写标题',
... ... @@ -110,7 +109,7 @@ export default {
110 109 render () {
111 110 return (
112 111 <div>
113   - <h3>{this.aliasName}{this.type}</h3>
  112 + <h3>{this.aliasName}</h3>
114 113 <input type="text" hidden value={this.value_} data-type="lbp-form-input" data-uuid={this.uuid} />
115 114 {
116 115 this.items.map(item => (
... ... @@ -118,7 +117,7 @@ export default {
118 117 vertical
119 118 value={item.value}
120 119 checked={this.type === 'radio' ? this.value === item.value : this.value.includes(item.value)}
121   - aliasName={this.aliasName}
  120 + aliasName={this.uuid}
122 121 type={this.type}
123 122 onChange={this.onChange}
124 123 >{item.value}</lbp-form-radio>
... ...
front-end/h5/src/components/plugins/lbp-form-radio-group.js
... ... @@ -18,7 +18,7 @@ export default {
18 18 props: {
19 19 aliasName: {
20 20 type: String,
21   - default: `标题演示-${genUUID().slice(0, 6)}`,
  21 + default: `标题演示`,
22 22 editor: {
23 23 type: 'a-input',
24 24 label: '填写标题',
... ... @@ -115,7 +115,7 @@ export default {
115 115 vertical
116 116 value={item.value}
117 117 checked={this.value === item.value}
118   - aliasName={this.aliasName}
  118 + aliasName={this.uuid}
119 119 type={this.type}
120 120 onChange={this.onChange}
121 121 >{item.value}
... ...