ees-jsoneditor 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +183 -0
  3. package/angular.json +169 -0
  4. package/e2e/app.e2e-spec.ts +17 -0
  5. package/e2e/app.po.ts +11 -0
  6. package/e2e/tsconfig.e2e.json +12 -0
  7. package/package.json +79 -0
  8. package/projects/ees-jsoneditor/.eslintrc.json +37 -0
  9. package/projects/ees-jsoneditor/README.md +200 -0
  10. package/projects/ees-jsoneditor/ng-package.json +7 -0
  11. package/projects/ees-jsoneditor/package.json +27 -0
  12. package/projects/ees-jsoneditor/src/lib/jsoneditor.component.spec.ts +25 -0
  13. package/projects/ees-jsoneditor/src/lib/jsoneditor.component.ts +269 -0
  14. package/projects/ees-jsoneditor/src/lib/jsoneditoroptions.ts +166 -0
  15. package/projects/ees-jsoneditor/src/public-api.ts +6 -0
  16. package/projects/ees-jsoneditor/tsconfig.lib.json +14 -0
  17. package/projects/ees-jsoneditor/tsconfig.lib.prod.json +10 -0
  18. package/projects/ees-jsoneditor/tsconfig.spec.json +14 -0
  19. package/renovate.json +38 -0
  20. package/src/app/app.component.css +0 -0
  21. package/src/app/app.component.html +6 -0
  22. package/src/app/app.component.spec.ts +27 -0
  23. package/src/app/app.component.ts +13 -0
  24. package/src/app/app.config.ts +8 -0
  25. package/src/app/app.routes.ts +7 -0
  26. package/src/app/demo/demo.component.css +1 -0
  27. package/src/app/demo/demo.component.html +65 -0
  28. package/src/app/demo/demo.component.spec.ts +31 -0
  29. package/src/app/demo/demo.component.ts +211 -0
  30. package/src/app/demo/schema.value.ts +111 -0
  31. package/src/app/demo/show.component.ts +15 -0
  32. package/src/assets/.gitkeep +0 -0
  33. package/src/assets/printDemo.png +0 -0
  34. package/src/environments/environment.prod.ts +3 -0
  35. package/src/environments/environment.ts +8 -0
  36. package/src/favicon.ico +0 -0
  37. package/src/index.html +14 -0
  38. package/src/main.ts +6 -0
  39. package/src/styles.scss +2 -0
  40. package/tsconfig.app.json +14 -0
  41. package/tsconfig.json +39 -0
  42. package/tsconfig.spec.json +14 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 David Herges
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # Angular Json Editor
2
+
3
+
4
+ Angular Json Editor (wrapper for [jsoneditor](https://github.com/josdejong/jsoneditor)). View/Edit Json file with formatting.
5
+
6
+ [StackBlitz template](https://stackblitz.com/edit/ees-jsoneditor)
7
+
8
+ Working with latest Angular 20.
9
+
10
+ ![Demo Image](/src/assets/printDemo.png)
11
+
12
+ ## Installation
13
+
14
+ To install this library with npm, run below command:
15
+
16
+ ```sh
17
+ $ npm install --save jsoneditor ees-jsoneditor
18
+ ```
19
+
20
+ Example:
21
+
22
+ ```html
23
+ <json-editor [options]="editorOptions" [data]="data" (change)="getData($event)"></json-editor>
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Configuration
29
+
30
+ Import the standalone component as below:
31
+
32
+ ```ts
33
+ import { Component, ViewChild } from '@angular/core';
34
+ import { InfinityJsonEditorComponent, JsonEditorOptions } from 'ees-jsoneditor';
35
+
36
+ @Component({
37
+ selector: 'app-root',
38
+ template: '<json-editor [options]="editorOptions" [data]="data"></json-editor>',
39
+ styleUrls: ['./app.component.css'],
40
+ imports: [InfinityJsonEditorComponent]
41
+ })
42
+ export class AppComponent {
43
+ public editorOptions: JsonEditorOptions;
44
+ public data: any;
45
+ // optional
46
+ @ViewChild(InfinityJsonEditorComponent, { static: false }) editor: InfinityJsonEditorComponent;
47
+
48
+ constructor() {
49
+ this.editorOptions = new JsonEditorOptions()
50
+ this.editorOptions.modes = ['code', 'text', 'tree', 'view']; // set all allowed modes
51
+ //this.options.mode = 'code'; //set only one mode
52
+
53
+ this.data = {"products":[{"name":"car","product":[{"name":"honda","model":[{"id":"civic","name":"civic"},{"id":"accord","name":"accord"},{"id":"crv","name":"crv"},{"id":"pilot","name":"pilot"},{"id":"odyssey","name":"odyssey"}]}]}]}
54
+ }
55
+
56
+ }
57
+ ```
58
+ Note : For better styling, add below line to your main style.css file
59
+
60
+ ```js
61
+ @import "~jsoneditor/dist/jsoneditor.min.css";
62
+ ```
63
+
64
+
65
+ ### Forms
66
+
67
+ Build it integrated with ReactiveForms:
68
+
69
+ ```ts
70
+ this.form = this.fb.group({
71
+ myinput: [this.data]
72
+ });
73
+ ```
74
+ ```html
75
+ <form [formGroup]="form" (submit)="submit()">
76
+ <json-editor [options]="editorOptions2" formControlName="myinput">
77
+ </json-editor>
78
+ </form>
79
+ ```
80
+
81
+ ### Extra Features
82
+
83
+ Besides all the
84
+ [configuration options](https://github.com/josdejong/jsoneditor/blob/master/docs/api.md)
85
+ from the original jsoneditor, Angular Json Editor supports one additional option:
86
+
87
+ _expandAll_ - to automatically expand all nodes upon json loaded with the _data_ input.
88
+
89
+ # Troubleshoot
90
+
91
+ If you have issue with the height of the component, you can try one of those solutions:
92
+
93
+ When you import CSS:
94
+
95
+ ```css
96
+ @import "~jsoneditor/dist/jsoneditor.min.css";
97
+ textarea.jsoneditor-text{min-height:350px;}
98
+ ```
99
+
100
+ Or Customizing the CSS:
101
+
102
+ ```css
103
+ :host ::ng-deep json-editor,
104
+ :host ::ng-deep json-editor .jsoneditor,
105
+ :host ::ng-deep json-editor > div,
106
+ :host ::ng-deep json-editor jsoneditor-outer {
107
+ height: 500px;
108
+ }
109
+ ```
110
+
111
+ Or as a inner style in component:
112
+
113
+ ```html
114
+ <json-editor class="col-md-12" #editorExample style="min-height: 300px;" [options]="editorOptionsData" [data]="dataStructure"></json-editor>
115
+ ```
116
+
117
+ For code view you can change the height using this example:
118
+ ```css
119
+ .ace_editor.ace-jsoneditor {
120
+ min-height: 500px;
121
+ }
122
+ ```
123
+
124
+ Use debug mode to see in your console the data and options passed to jsoneditor. Copy this and paste in your issue when reporting bugs.
125
+
126
+ ```html
127
+ <json-editor [debug]="true" [options]="editorOptionsData" [data]="dataStructure"></json-editor>
128
+ ```
129
+
130
+ ## JSONOptions missing params
131
+
132
+ If you find youself trying to use an custom option that is not mapped here, you can do:
133
+
134
+ ```ts
135
+ let editorOptions: JsonEditorOptions = new JsonEditorOptions(); (<any>this.editorOptions).templates = [{menu options objects as in json editor documentation}]
136
+ ```
137
+
138
+ See the [issue](https://github.com/yasir-nazir/ees-jsoneditor/issues/57)
139
+
140
+ ## Internet Explorer
141
+
142
+ If you want to support IE, please follow this guide:
143
+ * https://github.com/yasir-nazir/ees-jsoneditor/issues/44#issuecomment-508650610
144
+
145
+ ## Multiple editors
146
+
147
+ To use multiple jsoneditors in your view you cannot use the same editor options.
148
+
149
+ You should have something like:
150
+
151
+ ```html
152
+ <div *ngFor="let prd of data.products" class="w-100-p p-24" >
153
+ <json-editor [options]="makeOptions()" [data]="prd" (change)="showJson($event)"></json-editor>
154
+ </div>
155
+ ```
156
+
157
+ ```ts
158
+ makeOptions = () => {
159
+ return new JsonEditorOptions();
160
+ }
161
+ ```
162
+
163
+ # Demo
164
+
165
+ Demo component files are included in Git Project.
166
+
167
+ Demo Project with a lot of different implementations (ngInit, change event and others):
168
+ [https://github.com/yasir-nazir/ees-jsoneditor/tree/master/src/app/demo)
169
+
170
+ When publishing it to npm, look over this docs: https://docs.npmjs.com/misc/developers
171
+
172
+ # Collaborate
173
+
174
+ Fork, clone this repo and install dependencies.
175
+ This project just works with webpack 4 (dont change to 5):
176
+
177
+ ```sh
178
+ npm i -g rimraf
179
+ npm i
180
+ ```
181
+
182
+ # License
183
+ MIT(./LICENSE)
package/angular.json ADDED
@@ -0,0 +1,169 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "ees-jsoneditor-demo": {
7
+ "projectType": "application",
8
+ "schematics": {
9
+ "@schematics/angular:component": {
10
+ "style": "scss"
11
+ }
12
+ },
13
+ "root": "",
14
+ "sourceRoot": "src",
15
+ "prefix": "app",
16
+ "architect": {
17
+ "build": {
18
+ "builder": "@angular/build:application",
19
+ "options": {
20
+ "outputPath": "dist/ees-jsoneditor-demo",
21
+ "index": "src/index.html",
22
+ "browser": "src/main.ts",
23
+ "polyfills": [
24
+ "zone.js"
25
+ ],
26
+ "tsConfig": "tsconfig.app.json",
27
+ "inlineStyleLanguage": "scss",
28
+ "assets": [
29
+ "src/favicon.ico",
30
+ "src/assets"
31
+ ],
32
+ "styles": [
33
+ "src/styles.scss"
34
+ ],
35
+ "scripts": []
36
+ },
37
+ "configurations": {
38
+ "production": {
39
+ "budgets": [
40
+ {
41
+ "type": "initial",
42
+ "maximumWarning": "500kb",
43
+ "maximumError": "2mb"
44
+ },
45
+ {
46
+ "type": "anyComponentStyle",
47
+ "maximumWarning": "2kb",
48
+ "maximumError": "4kb"
49
+ }
50
+ ],
51
+ "outputHashing": "all"
52
+ },
53
+ "development": {
54
+ "optimization": false,
55
+ "extractLicenses": false,
56
+ "sourceMap": true
57
+ }
58
+ },
59
+ "defaultConfiguration": "production"
60
+ },
61
+ "serve": {
62
+ "builder": "@angular/build:dev-server",
63
+ "configurations": {
64
+ "production": {
65
+ "buildTarget": "ees-jsoneditor-demo:build:production"
66
+ },
67
+ "development": {
68
+ "buildTarget": "ees-jsoneditor-demo:build:development"
69
+ }
70
+ },
71
+ "defaultConfiguration": "development"
72
+ },
73
+ "extract-i18n": {
74
+ "builder": "@angular/build:extract-i18n",
75
+ "options": {
76
+ "buildTarget": "ees-jsoneditor-demo:build"
77
+ }
78
+ },
79
+ "test": {
80
+ "builder": "@angular/build:karma",
81
+ "options": {
82
+ "polyfills": [
83
+ "zone.js",
84
+ "zone.js/testing"
85
+ ],
86
+ "tsConfig": "tsconfig.spec.json",
87
+ "inlineStyleLanguage": "scss",
88
+ "assets": [
89
+ "src/favicon.ico",
90
+ "src/assets"
91
+ ],
92
+ "styles": [
93
+ "src/styles.scss"
94
+ ],
95
+ "scripts": []
96
+ }
97
+ }
98
+ }
99
+ },
100
+ "ees-jsoneditor": {
101
+ "projectType": "library",
102
+ "root": "projects/ees-jsoneditor",
103
+ "sourceRoot": "projects/ees-jsoneditor/src",
104
+ "prefix": "lib",
105
+ "architect": {
106
+ "build": {
107
+ "builder": "@angular/build:ng-packagr",
108
+ "options": {
109
+ "project": "projects/ees-jsoneditor/ng-package.json"
110
+ },
111
+ "configurations": {
112
+ "production": {
113
+ "tsConfig": "projects/ees-jsoneditor/tsconfig.lib.prod.json"
114
+ },
115
+ "development": {
116
+ "tsConfig": "projects/ees-jsoneditor/tsconfig.lib.json"
117
+ }
118
+ },
119
+ "defaultConfiguration": "production"
120
+ },
121
+ "test": {
122
+ "builder": "@angular/build:karma",
123
+ "options": {
124
+ "tsConfig": "projects/ees-jsoneditor/tsconfig.spec.json",
125
+ "polyfills": [
126
+ "zone.js",
127
+ "zone.js/testing"
128
+ ]
129
+ }
130
+ }
131
+ }
132
+ }
133
+ },
134
+ "schematics": {
135
+ "@schematics/angular:component": {
136
+ "prefix": "app",
137
+ "style": "css",
138
+ "type": "component"
139
+ },
140
+ "@schematics/angular:directive": {
141
+ "prefix": "app",
142
+ "type": "directive"
143
+ },
144
+ "@schematics/angular:service": {
145
+ "type": "service"
146
+ },
147
+ "@schematics/angular:guard": {
148
+ "typeSeparator": "."
149
+ },
150
+ "@schematics/angular:interceptor": {
151
+ "typeSeparator": "."
152
+ },
153
+ "@schematics/angular:module": {
154
+ "typeSeparator": "."
155
+ },
156
+ "@schematics/angular:pipe": {
157
+ "typeSeparator": "."
158
+ },
159
+ "@schematics/angular:resolver": {
160
+ "typeSeparator": "."
161
+ }
162
+ },
163
+ "cli": {
164
+ "schematicCollections": [
165
+ "@angular-eslint/schematics"
166
+ ],
167
+ "analytics": false
168
+ }
169
+ }
@@ -0,0 +1,17 @@
1
+ import { NgPackagedPage } from './app.po';
2
+
3
+ describe('ng-packaged App', () => {
4
+ let page: NgPackagedPage;
5
+
6
+ beforeEach(() => {
7
+ page = new NgPackagedPage();
8
+ });
9
+
10
+ it('should display message saying app works', () => {
11
+ page.navigateTo();
12
+ page.getParagraphText()
13
+ .then(t => {
14
+ expect(t).toEqual('Welcome to Angular Json Editor');
15
+ });
16
+ });
17
+ });
package/e2e/app.po.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { browser, by, element } from 'protractor';
2
+
3
+ export class NgPackagedPage {
4
+ navigateTo() {
5
+ return browser.get('/');
6
+ }
7
+
8
+ getParagraphText() {
9
+ return element(by.css('app-root h1')).getText();
10
+ }
11
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../out-tsc/e2e",
5
+ "module": "commonjs",
6
+ "target": "es5",
7
+ "types": [
8
+ "jasmine",
9
+ "node"
10
+ ]
11
+ }
12
+ }
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "ees-jsoneditor",
3
+ "version": "2.0.0",
4
+ "private": false,
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/yasir-nazir/ees-jsoneditor.git"
8
+ },
9
+ "license": "MIT",
10
+ "scripts": {
11
+ "ng": "ng",
12
+ "start": "ng serve",
13
+ "build": "ng build",
14
+ "build:app": "npm run build:lib && ng build",
15
+ "build:lib": "ng build --project ees-jsoneditor",
16
+ "watch": "npm run build:lib -- --watch",
17
+ "build:full": "npm run build:lib && npm run build:app",
18
+ "publishnpm": "cp README.md projects/ees-jsoneditor/README.md && npm run build:lib && cd dist/ees-jsoneditor && npm publish",
19
+ "unpublish": "npm deprecate -f 'ees-jsoneditor@1.9.3' 'this package has been deprecated'",
20
+ "test": "npm run test:dev && npm run e2e",
21
+ "test:dev": "ng test --project ees-jsoneditor-demo",
22
+ "test:unit": "ng test",
23
+ "lint": "ng lint",
24
+ "e2e": "ng e2e",
25
+ "ports": "lsof -i tcp:4201",
26
+ "reinstall": "rm package-lock.json && rm -rf node_modules && npm i",
27
+ "rebuildsass": "npm rebuild node-sass"
28
+ },
29
+ "dependencies": {
30
+ "@angular/common": "20.3.15",
31
+ "@angular/compiler": "20.3.15",
32
+ "@angular/core": "20.3.15",
33
+ "@angular/forms": "20.3.15",
34
+ "@angular/platform-browser": "20.3.15",
35
+ "@angular/platform-browser-dynamic": "20.3.15",
36
+ "@angular/router": "20.3.15",
37
+ "jsoneditor": "*",
38
+ "ng-packagr": "^20.3.2",
39
+ "rxjs": "^7.8.2",
40
+ "tslib": "^2.8.1",
41
+ "webpack": "^5.88.2",
42
+ "zone.js": "~0.15.1"
43
+ },
44
+ "devDependencies": {
45
+ "@angular-devkit/schematics": "^20.3.13",
46
+ "@angular-eslint/builder": "^20.7.0",
47
+ "@angular-eslint/eslint-plugin": "^20.7.0",
48
+ "@angular-eslint/eslint-plugin-template": "^20.7.0",
49
+ "@angular-eslint/schematics": "^20.7.0",
50
+ "@angular-eslint/template-parser": "^20.7.0",
51
+ "@angular/build": "^20.3.13",
52
+ "@angular/cli": "^20.3.13",
53
+ "@angular/compiler-cli": "20.3.15",
54
+ "@angular/language-service": "20.3.15",
55
+ "@types/jasmine": "~5.1.2",
56
+ "@types/jsoneditor": "^9.9.3",
57
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
58
+ "@typescript-eslint/parser": "^8.49.0",
59
+ "cpr": "^3.0.1",
60
+ "eslint": "^8.57.1",
61
+ "eslint-plugin-import": "latest",
62
+ "eslint-plugin-jsdoc": "latest",
63
+ "eslint-plugin-prefer-arrow": "latest",
64
+ "jasmine-core": "~5.1.2",
65
+ "karma": "6.4.2",
66
+ "karma-chrome-launcher": "3.2.0",
67
+ "karma-coverage": "~2.2.1",
68
+ "karma-jasmine": "~5.1.0",
69
+ "karma-jasmine-html-reporter": "~2.1.0",
70
+ "typescript": "5.9.3"
71
+ },
72
+ "description": "",
73
+ "main": "index.js",
74
+ "author": "Yasir Nazir",
75
+ "bugs": {
76
+ "url": "https://github.com/yasir-nazir/ees-jsoneditor/issues"
77
+ },
78
+ "homepage": "https://github.com/yasir-nazir/ees-jsoneditor#readme"
79
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "extends": "../../.eslintrc.json",
3
+ "ignorePatterns": [
4
+ "!**/*"
5
+ ],
6
+ "overrides": [
7
+ {
8
+ "files": [
9
+ "*.ts"
10
+ ],
11
+ "rules": {
12
+ "@angular-eslint/directive-selector": [
13
+ "error",
14
+ {
15
+ "type": "attribute",
16
+ "prefix": "lib",
17
+ "style": "camelCase"
18
+ }
19
+ ],
20
+ "@angular-eslint/component-selector": [
21
+ "error",
22
+ {
23
+ "type": "element",
24
+ "prefix": "lib",
25
+ "style": "kebab-case"
26
+ }
27
+ ]
28
+ }
29
+ },
30
+ {
31
+ "files": [
32
+ "*.html"
33
+ ],
34
+ "rules": {}
35
+ }
36
+ ]
37
+ }