Skip to content

Commit 37550b6

Browse files
committed
feat: move widgetStyle to widget
1 parent 8a6c2a8 commit 37550b6

File tree

6 files changed

+23
-28
lines changed

6 files changed

+23
-28
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ You can add custom components, save callback.
5151
| save | `(data) => void` | When you click the Save button, feed back to you to save the data |
5252
| value | `Object` | Editor initial value, you can pass the value of the save callback and resume the draft |
5353
| widgets | `Object` | Vue Components. Custom components for editor. see [Example](https://github.com/fireyy/vue-page-designer-widgets/blob/master/src/index.js) |
54-
| widgetStyle | `Object` | Vue Components. Custom components style config for editor. see [Example](https://github.com/fireyy/vue-page-designer-widgets/blob/master/src/index.js) |
5554

5655
## Parameter: `save`
5756

@@ -75,7 +74,7 @@ The `value` came from `save`.
7574
</template>
7675
```
7776

78-
## Parameter: `widgets` and `widgetStyle`
77+
## Parameter: `widgets`
7978

8079
You can install default widget in `vue-page-designer-widgets`
8180

@@ -88,18 +87,17 @@ Import and use it
8887
```html
8988
<template>
9089
<div id="app">
91-
<vue-page-designer :widgets="widgets" :widgetStyle="widgetStyle" />
90+
<vue-page-designer :widgets="widgets" />
9291
</div>
9392
</template>
9493
<script>
9594
import vuePageDesigner from 'vue-page-designer'
96-
import { widgets, widgetStyle } from 'vue-page-designer-widgets'
95+
import widgets from 'vue-page-designer-widgets'
9796
9897
export default {
9998
data () {
10099
return {
101-
widgets,
102-
widgetStyle
100+
widgets
103101
}
104102
},
105103

example/App.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<template>
22
<div id="app">
3-
<vue-page-designer :value="value" :widgets="widgets" :widgetStyle="widgetStyle" @save="handleSave" />
3+
<vue-page-designer :value="value" :widgets="widgets" @save="handleSave" />
44
</div>
55
</template>
66

77
<script>
8-
import { widgets, widgetStyle } from 'vue-page-designer-widgets'
8+
import widgets from 'vue-page-designer-widgets'
99
import vuePageDesigner from '../src'
1010
1111
export default {
1212
data () {
1313
return {
1414
value: null,
15-
widgets,
16-
widgetStyle
15+
widgets
1716
}
1817
},
1918

src/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,13 @@ const vuePageDesigner = {
2929
store,
3030
props: {
3131
value: Object,
32-
widgets: Object,
33-
widgetStyle: Object
32+
widgets: Object
3433
},
3534
components: { App },
3635
created () {
3736
// 注册 widgets
38-
// TODO: 合并 widgets 和 widgetStyle
3937
Vue.use(widget, {
40-
widgets: this.widgets,
41-
widgetStyle: this.widgetStyle
38+
widgets: this.widgets
4239
})
4340
// 初始化已有数据
4441
if (this.value) {

src/plugins/widget.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
// 注册 内置 widgets
2-
import * as inner from '../widgets'
2+
import inner from '../widgets'
33

4-
var widgets, widgetStyle
4+
var widgets
5+
var widgetStyle = {}
56

67
const install = (Vue, config = {}) => {
78
if (install.installed) return
89

9-
widgets = Object.assign({}, inner.widgets, config.widgets)
10-
widgetStyle = Object.assign({}, inner.widgetStyle, config.widgetStyle)
10+
widgets = Object.assign({}, inner, config.widgets)
1111

1212
Object.keys(widgets).forEach(key => {
1313
Vue.component(key, widgets[key])
14-
})
15-
Object.keys(widgetStyle).forEach(key => {
16-
Vue.component(key, widgetStyle[key])
14+
// style panel
15+
let panel = Object.assign({}, widgets[key]['panel'])
16+
Vue.component(panel.name, panel)
17+
widgetStyle[panel.name] = panel
18+
// remove panel from object
19+
delete widgets[key]['panel']
1720
})
1821
}
1922

src/widgets/container/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
</template>
4040

4141
<script>
42+
import stylec from './style.vue'
43+
4244
export default {
4345
name: 'braid-container',
4446
icon: 'layout',
4547
title: '容器',
48+
panel: stylec,
4649
setting: {
4750
type: 'braid-container',
4851
hasGuide: true,

src/widgets/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import braidContainer from './container/index.vue'
2-
import braidContainerStyle from './container/style.vue'
32

4-
export const widgets = {
3+
export default {
54
braidContainer
65
}
7-
8-
export const widgetStyle = {
9-
braidContainerStyle
10-
}

0 commit comments

Comments
 (0)