Skip to content

Commit 0d2f489

Browse files
committed
release: v0.10.0
1 parent 21a3c28 commit 0d2f489

File tree

6 files changed

+72
-66
lines changed

6 files changed

+72
-66
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ createApp()
9898
"vue": "https://unpkg.com/vue/dist/vue.esm-browser.prod.js",
9999
"vue-demi": "https://unpkg.com/vue-demi/lib/v3/index.mjs",
100100
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
101-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
101+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
102102
}
103103
}
104104
</script>
@@ -120,7 +120,7 @@ createApp()
120120

121121
##### Using the Global Build
122122

123-
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
123+
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
124124
125125
```html
126126
<!DOCTYPE html>
@@ -138,7 +138,7 @@ createApp()
138138
<script src="https://unpkg.com/vue"></script>
139139
<script src="https://unpkg.com/vue-demi"></script>
140140
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
141-
<script src="https://unpkg.com/json-editor-vue"></script>
141+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
142142
<script>
143143
const { createApp, ref } = Vue
144144
@@ -210,7 +210,7 @@ Vue.use(JsonEditorVue, {
210210
"vue": "https://unpkg.com/vue@2/dist/vue.esm.browser.min.js",
211211
"vue-demi": "https://unpkg.com/vue-demi/lib/v2.7/index.mjs",
212212
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
213-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
213+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
214214
}
215215
}
216216
</script>
@@ -234,7 +234,7 @@ Vue.use(JsonEditorVue, {
234234

235235
##### Using the Global Build
236236

237-
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
237+
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
238238
239239
```html
240240
<!DOCTYPE html>
@@ -252,7 +252,7 @@ Vue.use(JsonEditorVue, {
252252
<script src="https://unpkg.com/vue@2"></script>
253253
<script src="https://unpkg.com/vue-demi"></script>
254254
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
255-
<script src="https://unpkg.com/json-editor-vue"></script>
255+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
256256
<script>
257257
new Vue({
258258
components: { 'json-editor-vue': JsonEditorVue },
@@ -342,7 +342,7 @@ Vue.use(JsonEditorVue, {
342342
"@vue/composition-api/dist/vue-composition-api.mjs": "https://unpkg.com/@vue/composition-api/dist/ vue-composition-api.mjs",
343343
"vue-demi": "https://unpkg.com/vue-demi/lib/v2/index.mjs",
344344
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
345-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
345+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
346346
}
347347
}
348348
</script>
@@ -365,7 +365,7 @@ Vue.use(JsonEditorVue, {
365365

366366
##### Using the Global Build
367367

368-
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
368+
> Not yet supported because `vanilla-jsoneditor` does not export UMD, please leave a message [here](https://github.com/josdejong/svelte-jsoneditor/discussions/196) if you need it.
369369
370370
```html
371371
<!DOCTYPE html>
@@ -384,7 +384,7 @@ Vue.use(JsonEditorVue, {
384384
<script src="https://unpkg.com/@vue/composition-api"></script>
385385
<script src="https://unpkg.com/vue-demi"></script>
386386
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
387-
<script src="https://unpkg.com/json-editor-vue"></script>
387+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
388388
<script>
389389
const { createApp, ref } = VueCompositionAPI
390390

docs/README.zh-CN.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ createApp()
9696
"vue": "https://unpkg.com/vue/dist/vue.esm-browser.prod.js",
9797
"vue-demi": "https://unpkg.com/vue-demi/lib/v3/index.mjs",
9898
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
99-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
99+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
100100
}
101101
}
102102
</script>
@@ -118,7 +118,7 @@ createApp()
118118

119119
##### 使用全局构建版本
120120

121-
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
121+
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
122122
123123
```html
124124
<!DOCTYPE html>
@@ -136,7 +136,7 @@ createApp()
136136
<script src="https://unpkg.com/vue"></script>
137137
<script src="https://unpkg.com/vue-demi"></script>
138138
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
139-
<script src="https://unpkg.com/json-editor-vue"></script>
139+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
140140
<script>
141141
const { createApp, ref } = Vue
142142
@@ -208,7 +208,7 @@ Vue.use(JsonEditorVue, {
208208
"vue": "https://unpkg.com/vue@2/dist/vue.esm.browser.min.js",
209209
"vue-demi": "https://unpkg.com/vue-demi/lib/v2.7/index.mjs",
210210
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
211-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
211+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
212212
}
213213
}
214214
</script>
@@ -232,7 +232,7 @@ Vue.use(JsonEditorVue, {
232232

233233
##### 使用全局构建版本
234234

235-
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
235+
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
236236
237237
```html
238238
<!DOCTYPE html>
@@ -250,7 +250,7 @@ Vue.use(JsonEditorVue, {
250250
<script src="https://unpkg.com/vue@2"></script>
251251
<script src="https://unpkg.com/vue-demi"></script>
252252
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
253-
<script src="https://unpkg.com/json-editor-vue"></script>
253+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
254254
<script>
255255
new Vue({
256256
components: { 'json-editor-vue': JsonEditorVue },
@@ -340,7 +340,7 @@ Vue.use(JsonEditorVue, {
340340
"@vue/composition-api/dist/vue-composition-api.mjs": "https://unpkg.com/@vue/composition-api/dist/ vue-composition-api.mjs",
341341
"vue-demi": "https://unpkg.com/vue-demi/lib/v2/index.mjs",
342342
"vanilla-jsoneditor": "https://unpkg.com/vanilla-jsoneditor",
343-
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.9/dist/json-editor-vue.mjs"
343+
"json-editor-vue": "https://unpkg.com/json-editor-vue@0.10/dist/json-editor-vue.mjs"
344344
}
345345
}
346346
</script>
@@ -363,7 +363,7 @@ Vue.use(JsonEditorVue, {
363363

364364
##### 使用全局构建版本
365365

366-
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
366+
> 暂不支持(`vanilla-jsoneditor` 不提供 UMD 导出),如有需要请在[这里](https://github.com/josdejong/svelte-jsoneditor/discussions/196)留言。
367367
368368
```html
369369
<!DOCTYPE html>
@@ -382,7 +382,7 @@ Vue.use(JsonEditorVue, {
382382
<script src="https://unpkg.com/@vue/composition-api"></script>
383383
<script src="https://unpkg.com/vue-demi"></script>
384384
<!-- TODO --> <script src="./vanilla-jsoneditor.umd.js"></script>
385-
<script src="https://unpkg.com/json-editor-vue"></script>
385+
<script src="https://unpkg.com/json-editor-vue@0.10"></script>
386386
<script>
387387
const { createApp, ref } = VueCompositionAPI
388388

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "json-editor-vue",
33
"pascalCasedName": "JsonEditorVue",
4-
"version": "0.9.2",
4+
"version": "0.10.0",
55
"private": false,
66
"packageManager": "pnpm@latest",
77
"description": "JSON editor & viewer for Vue 2.6 / 2.7 / 3 & Nuxt 2 / 3.",
@@ -45,7 +45,7 @@
4545
"doc": "vitepress dev --open /README",
4646
"lint": "eslint --cache {src,__tests__}/**.*",
4747
"build": "vite build",
48-
"test-unit": "vitest",
48+
"test-unit": "vitest run",
4949
"coverage": "vitest run --coverage",
5050
"release": "cl switchVue 3 && npx case-police --fix && npx lint-staged && pnpm test-unit && pnpm build && cl release"
5151
},
@@ -99,4 +99,4 @@
9999
"publishConfig": {
100100
"registry": "https://registry.npmjs.org/"
101101
}
102-
}
102+
}

src/Component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { JSONEditor } from 'vanilla-jsoneditor'
1414
import { conclude } from 'vue-global-config'
1515
import { debounce } from 'lodash-es'
1616
import { pascalCasedName as name } from '../package.json'
17-
import { globalAttrs, globalProps } from './index'
17+
import { globalAttrs, globalProps } from './install'
1818

1919
export type Mode = 'tree' | 'text'
2020

src/index.ts

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,6 @@
1-
import type { Plugin } from 'vue'
2-
import { useGlobalConfig } from 'vue-global-config'
3-
import Component from './Component'
4-
import type { Mode } from './Component'
5-
6-
type SFCWithInstall<T> = T & Plugin
7-
8-
const withInstall = <T, E extends Record<string, any>>(
9-
main: T,
10-
extra?: E,
11-
) => {
12-
(main as SFCWithInstall<T>).install = (app): void => {
13-
for (const comp of [main, ...Object.values(extra ?? {})]) {
14-
app.component(comp.name, comp)
15-
}
16-
}
17-
18-
if (extra) {
19-
for (const [key, comp] of Object.entries(extra)) {
20-
(main as any)[key] = comp
21-
}
22-
}
23-
return main as SFCWithInstall<T> & E
24-
}
25-
26-
const globalProps: Record<string, any> = {}
27-
const globalAttrs: Record<string, any> = {}
28-
const globalListeners: Record<string, any> = {}
29-
const globalHooks: Record<string, any> = {}
30-
31-
const ComponentWithInstall = withInstall(Component)
32-
33-
ComponentWithInstall.install = (app: any, options = {}) => {
34-
const { props, attrs, listeners, hooks } = useGlobalConfig(options, Component.props)
35-
Object.assign(globalProps, props)
36-
Object.assign(globalAttrs, attrs)
37-
Object.assign(globalListeners, listeners)
38-
Object.assign(globalHooks, hooks)
39-
app.component(ComponentWithInstall.name, ComponentWithInstall)
40-
}
1+
import ComponentWithInstall from './install'
2+
import type { Mode } from './install'
413

424
export default ComponentWithInstall
43-
export {
44-
globalProps, globalAttrs, globalListeners, globalHooks,
45-
Mode,
46-
}
5+
export { Mode }
6+

src/install.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Plugin } from 'vue'
2+
import { useGlobalConfig } from 'vue-global-config'
3+
import Component from './Component'
4+
import type { Mode } from './Component'
5+
6+
type SFCWithInstall<T> = T & Plugin
7+
8+
const withInstall = <T, E extends Record<string, any>>(
9+
main: T,
10+
extra?: E,
11+
) => {
12+
(main as SFCWithInstall<T>).install = (app): void => {
13+
for (const comp of [main, ...Object.values(extra ?? {})]) {
14+
app.component(comp.name, comp)
15+
}
16+
}
17+
18+
if (extra) {
19+
for (const [key, comp] of Object.entries(extra)) {
20+
(main as any)[key] = comp
21+
}
22+
}
23+
return main as SFCWithInstall<T> & E
24+
}
25+
26+
const globalProps: Record<string, any> = {}
27+
const globalAttrs: Record<string, any> = {}
28+
const globalListeners: Record<string, any> = {}
29+
const globalHooks: Record<string, any> = {}
30+
31+
const ComponentWithInstall = withInstall(Component)
32+
33+
ComponentWithInstall.install = (app: any, options = {}) => {
34+
const { props, attrs, listeners, hooks } = useGlobalConfig(options, Component.props)
35+
Object.assign(globalProps, props)
36+
Object.assign(globalAttrs, attrs)
37+
Object.assign(globalListeners, listeners)
38+
Object.assign(globalHooks, hooks)
39+
app.component(ComponentWithInstall.name, ComponentWithInstall)
40+
}
41+
42+
export default ComponentWithInstall
43+
export {
44+
globalProps, globalAttrs, globalListeners, globalHooks,
45+
Mode,
46+
}

0 commit comments

Comments
 (0)