Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 13ea974

Browse files
committed
Docs
1 parent 5e1e83b commit 13ea974

File tree

6 files changed

+63
-98
lines changed

6 files changed

+63
-98
lines changed

.gitattributes

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
# Git
1+
docs export-ignore
2+
src export-ignore
3+
.editorconfig export-ignore
24
.gitattributes export-ignore
35
.gitignore export-ignore
6+
package-lock.json export-ignore
7+
package.json export-ignore

README.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

docs/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# kirby-json
2+
3+
Kirby JSON field and JSON editor Vue component.
4+
5+
## Installation
6+
7+
With Composer:
8+
9+
```
10+
composer require oblik/kirby-json
11+
```
12+
13+
## Usage
14+
15+
### Field
16+
17+
In the blueprint:
18+
19+
```yml
20+
fields:
21+
myData:
22+
type: json
23+
```
24+
25+
Available blueprint options for the editor:
26+
27+
```yml
28+
array: false # Saved value should be an array?
29+
keys: false # Edit object keys?
30+
values: true # Edit values?
31+
mutate: false # Add/remove entries?
32+
sort: true # Allow entry reordering?
33+
```
34+
35+
In the template, use the native Kirby `toData()` method:
36+
37+
```php
38+
$data = $page->myData()->toData('json');
39+
```
40+
41+
### Component
42+
43+
If you're building a plugin and you need to allow the user to edit JSON, you can use the same component that the above JSON field uses, `k-json-editor`, in your own panel plugin:
44+
45+
```html
46+
<template>
47+
<k-json-editor
48+
v-model="data"
49+
:label="label"
50+
:options="options"
51+
@input="input"
52+
></k-json-editor>
53+
</template>
54+
```
55+
56+
![JSON editor component](editor.png)

docs/editor.png

31.3 KB
Loading

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Field.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
default: true
2626
},
2727
mutate: { // Add/remove entries?
28-
default: true
28+
default: false
2929
},
3030
sort: { // Allow entry reordering?
3131
default: true

0 commit comments

Comments
 (0)