Skip to content

Commit

Permalink
JSON EDitor
Browse files Browse the repository at this point in the history
  • Loading branch information
skamril committed Jan 10, 2024
1 parent 76a6a59 commit a1203c8
Show file tree
Hide file tree
Showing 6 changed files with 2,871 additions and 2,277 deletions.
1 change: 1 addition & 0 deletions webapp/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = function override(config, env) {
os: require.resolve("os-browserify/browser"),
buffer: require.resolve("buffer"),
stream: require.resolve("stream-browserify"),
"process/browser": require.resolve("process/browser"),
};
config.plugins.push(
new webpack.ProvidePlugin({
Expand Down
4,849 changes: 2,841 additions & 2,008 deletions webapp/package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"i18next-xhr-backend": "3.2.2",
"immer": "10.0.3",
"js-cookie": "3.0.5",
"jsoneditor": "^9.10.4",
"jwt-decode": "3.1.2",
"lodash": "4.17.21",
"material-react-table": "2.0.5",
Expand Down Expand Up @@ -78,6 +77,7 @@
"url": "0.11.3",
"use-undo": "1.1.1",
"uuid": "9.0.1",
"vanilla-jsoneditor": "0.21.1",
"xml-js": "1.6.11"
},
"scripts": {
Expand Down Expand Up @@ -106,7 +106,6 @@
"@total-typescript/ts-reset": "0.5.1",
"@types/debug": "4.1.9",
"@types/js-cookie": "3.0.4",
"@types/jsoneditor": "^9.9.5",
"@types/lodash": "4.14.199",
"@types/ramda": "0.29.5",
"@types/react-beautiful-dnd": "13.1.5",
Expand Down
28 changes: 28 additions & 0 deletions webapp/src/components/common/JSONEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useEffect, useRef } from "react";
import { useMount } from "react-use";
import {
JSONEditor as JSONEditorLib,
type JSONEditorPropsOptional,
} from "vanilla-jsoneditor";
import "vanilla-jsoneditor/themes/jse-theme-dark.css";

export type JSONEditorProps = JSONEditorPropsOptional;

function JSONEditor(props: JSONEditorProps) {
const targetRef = useRef<HTMLDivElement>(null!);
const editorRef = useRef<JSONEditorLib | null>(null);

useMount(() => {
const editor = new JSONEditorLib({ target: targetRef.current, props });
editorRef.current = editor;
return () => editor.destroy();
});

useEffect(() => {
editorRef.current?.updateProps(props);
}, [props]);

return <div ref={targetRef} className="jse-theme-dark" />;
}

export default JSONEditor;
227 changes: 0 additions & 227 deletions webapp/src/components/common/JSONEditor/dark-theme.css

This file was deleted.

40 changes: 0 additions & 40 deletions webapp/src/components/common/JSONEditor/index.tsx

This file was deleted.

0 comments on commit a1203c8

Please sign in to comment.