Skip to content

Commit e337dc9

Browse files
committed
docs: explain the the association between binding value and modes
1 parent 116af8e commit e337dc9

File tree

4 files changed

+294
-288
lines changed

4 files changed

+294
-288
lines changed

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,6 @@ module.exports = {
943943
| mode /<br>v-model:mode (Vue 3) /<br>:mode.sync (Vue 2) | edit mode | [Mode](#Mode) |
944944
| ... | properties of [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) | |
945945

946-
> [!Tip]
947-
>
948-
> kebab-case is required for tag & prop name when using from CDN.
949-
950946
### Binding value difference between svelte-jsoneditor and json-editor-vue
951947

952948
- svelte-jsoneditor: An object contains a stringified JSON or a parsed JSON, will do `JSON.parse` when passing as a stringified JSON.
@@ -963,7 +959,19 @@ If you prefer the behavior of svelte-jsoneditor:
963959
/>
964960
```
965961

966-
If you want to ensure you always get parsed JSON in text mode:
962+
### The association between binding value and modes
963+
964+
> [!Important]
965+
>
966+
> You can pass a stringified JSON or a parsed JSON to the editor independent of in what mode it is.
967+
>
968+
> The **output value** of text mode is a stringified JSON, the **output value** of tree mode is a parsed JSON.
969+
>
970+
> **But this correspondence can be disrupted by programmatic changes or mode switching.**
971+
>
972+
> See https://github.com/josdejong/svelte-jsoneditor/pull/166 for more details.
973+
974+
FAQ: How to get parsed JSON in text mode:
967975

968976
> [!Caution]
969977
>
@@ -1005,7 +1013,13 @@ or without `try...catch`:
10051013
/>
10061014
```
10071015

1008-
> See https://github.com/josdejong/svelte-jsoneditor/pull/166 for more details.
1016+
### Naming convention
1017+
1018+
Support camelCase and kebab-case for tag & property name.
1019+
1020+
> [!Tip]
1021+
>
1022+
> When using json-editor-vue or any Vue component via CDN (HTML), kebab-case must be used exclusively due to HTML's case insensitivity.
10091023
10101024
### Boolean properties
10111025

docs/README.zh-CN.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -941,10 +941,6 @@ module.exports = {
941941
| mode /<br>v-model:mode (Vue 3) /<br>:mode.sync (Vue 2) | 编辑模式 | [Mode](#Mode) |
942942
| ... | [svelte-jsoneditor](https://github.com/josdejong/svelte-jsoneditor/#properties) 的属性 | |
943943

944-
> [!Tip]
945-
>
946-
> 通过 CDN 使用时,标签、属性名称都必须使用短横线命名
947-
948944
### svelte-jsoneditor 与 json-editor-vue 中绑定值的差异
949945

950946
- svelte-jsoneditor:一个包含 “stringified JSON” 或 “parsed JSON” 的对象,当作为 “stringified JSON” 传入时,会经过 `JSON.parse` 解析
@@ -961,7 +957,19 @@ module.exports = {
961957
/>
962958
```
963959

964-
如果你想确保在 text 模式中总是得到 “parsed JSON”:
960+
### 绑定值与模式的关系
961+
962+
> [!Important]
963+
>
964+
> 绑定值可以传 stringified JSON 或 parsed JSON,跟模式无关
965+
>
966+
> text 模式下的**输出值**是 stringified JSON,tree 模式下的**输出值**是 parsed JSON
967+
>
968+
> **但这个对应关系会被编程式输入或模式切换打破**
969+
>
970+
> 详情见 https://github.com/josdejong/svelte-jsoneditor/pull/166
971+
972+
FAQ: 如何在 text 模式中获取 parsed JSON:
965973

966974
> [!Caution]
967975
>
@@ -1003,7 +1011,13 @@ createApp(App)
10031011
/>
10041012
```
10051013

1006-
> 详情见 https://github.com/josdejong/svelte-jsoneditor/pull/166
1014+
### 命名惯例
1015+
1016+
标签、属性名称支持驼峰命名和短横线命名
1017+
1018+
> [!Tip]
1019+
>
1020+
> 通过 CDN (HTML) 使用 json-editor-vue 或任何 Vue 组件时,由于 HTML 大小写不敏感,仅能使用短横线命名
10071021
10081022
### 布尔类型属性
10091023

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"@types/prompts": "^2.4.9",
8686
"@types/semver": "^7.5.8",
8787
"@vitejs/plugin-vue": "^5.0.4",
88-
"@vitest/ui": "^1.4.0",
88+
"@vitest/ui": "^1.5.0",
8989
"@vue/compiler-sfc": "^3.4.21",
9090
"@vue/test-utils": "^2.4.5",
9191
"case-police": "^0.6.1",
@@ -101,7 +101,7 @@
101101
"lint-staged": "^15.2.2",
102102
"lodash-es": "^4.17.21",
103103
"lossless-json": "^4.0.1",
104-
"magicast": "^0.3.3",
104+
"magicast": "^0.3.4",
105105
"only-allow": "^1.2.1",
106106
"open": "^10.1.0",
107107
"prompts": "^2.4.2",
@@ -112,9 +112,9 @@
112112
"unplugin-auto-import": "^0.17.5",
113113
"unplugin-vue-components": "^0.26.0",
114114
"vite": "^5.2.8",
115-
"vite-plugin-dts": "^3.8.1",
115+
"vite-plugin-dts": "^3.8.2",
116116
"vitepress": "^1.1.0",
117-
"vitest": "^1.4.0",
117+
"vitest": "^1.5.0",
118118
"vue": "^3.4.21",
119119
"vue-global-config": "^0.6.0",
120120
"zhlint": "^0.8.1"

0 commit comments

Comments
 (0)