From a29c225216569bf8ff119b2e01cc66376c48c992 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Wed, 7 Aug 2024 01:55:24 +0300 Subject: [PATCH] JsonEditor for Yjs --- .../{JsonViewer.svelte => JsonSource.svelte} | 0 ng-app/src/apps/YArrayJsonSource.svelte | 0 ng-app/src/apps/YArraySource.svelte | 19 +++ ng-app/src/apps/YArrayViewer.svelte | 19 +++ ng-app/src/apps/YMapSource.svelte | 79 ++++++++++ ng-app/src/apps/YMapViewer.svelte | 140 ++++++++++++++++++ ng-app/src/classes.ts | 6 +- ng-app/src/tab.ts | 2 + ng-app/src/zeras.ts | 50 ++++++- 9 files changed, 306 insertions(+), 9 deletions(-) rename ng-app/src/apps/{JsonViewer.svelte => JsonSource.svelte} (100%) create mode 100644 ng-app/src/apps/YArrayJsonSource.svelte create mode 100644 ng-app/src/apps/YArraySource.svelte create mode 100644 ng-app/src/apps/YArrayViewer.svelte create mode 100644 ng-app/src/apps/YMapSource.svelte create mode 100644 ng-app/src/apps/YMapViewer.svelte diff --git a/ng-app/src/apps/JsonViewer.svelte b/ng-app/src/apps/JsonSource.svelte similarity index 100% rename from ng-app/src/apps/JsonViewer.svelte rename to ng-app/src/apps/JsonSource.svelte diff --git a/ng-app/src/apps/YArrayJsonSource.svelte b/ng-app/src/apps/YArrayJsonSource.svelte new file mode 100644 index 0000000..e69de29 diff --git a/ng-app/src/apps/YArraySource.svelte b/ng-app/src/apps/YArraySource.svelte new file mode 100644 index 0000000..5a9a1fd --- /dev/null +++ b/ng-app/src/apps/YArraySource.svelte @@ -0,0 +1,19 @@ + + + + + + diff --git a/ng-app/src/apps/YArrayViewer.svelte b/ng-app/src/apps/YArrayViewer.svelte new file mode 100644 index 0000000..5f89854 --- /dev/null +++ b/ng-app/src/apps/YArrayViewer.svelte @@ -0,0 +1,19 @@ + + + + + + diff --git a/ng-app/src/apps/YMapSource.svelte b/ng-app/src/apps/YMapSource.svelte new file mode 100644 index 0000000..f4fceeb --- /dev/null +++ b/ng-app/src/apps/YMapSource.svelte @@ -0,0 +1,79 @@ + + + +
+ {#if source} + + + + {:else if $cur_tab_doc_can_edit} + + {/if} + +
+ \ No newline at end of file diff --git a/ng-app/src/apps/YMapViewer.svelte b/ng-app/src/apps/YMapViewer.svelte new file mode 100644 index 0000000..b55634b --- /dev/null +++ b/ng-app/src/apps/YMapViewer.svelte @@ -0,0 +1,140 @@ + + + +
+ + +
+ + \ No newline at end of file diff --git a/ng-app/src/classes.ts b/ng-app/src/classes.ts index b3dc107..f42ab99 100644 --- a/ng-app/src/classes.ts +++ b/ng-app/src/classes.ts @@ -288,7 +288,7 @@ export const official_classes = { "ng:crdt": "Automerge", "ng:n": "JSON", "ng:a": "JSON Data CRDT", - "ng:o": "n:g:z:json_viewer", // default viewer + "ng:o": "n:g:z:json_automerge_viewer", // default viewer "ng:w": "n:g:z:json_automerge_editor", // default editor "ng:compat": ["file:iana:application:json", "code:json"], }, @@ -296,7 +296,7 @@ export const official_classes = { "ng:crdt": "YArray", "ng:n": "Array", "ng:a": "Yjs Array CRDT", - "ng:o": "n:g:z:json_viewer", // default viewer + "ng:o": "n:g:z:json_yarray_viewer", // default viewer "ng:w": "n:g:z:json_yarray_editor", // default editor "ng:compat": ["file:iana:application:json", "code:json"], }, @@ -304,7 +304,7 @@ export const official_classes = { "ng:crdt": "YMap", "ng:n": "Object", "ng:a": "Yjs Map CRDT", - "ng:o": "n:g:z:json_viewer", // default viewer + "ng:o": "n:g:z:json_ymap_viewer", // default viewer "ng:w": "n:g:z:json_ymap_editor", // default editor "ng:compat": ["file:iana:application:json", "code:json"], }, diff --git a/ng-app/src/tab.ts b/ng-app/src/tab.ts index aa20304..dd4618b 100644 --- a/ng-app/src/tab.ts +++ b/ng-app/src/tab.ts @@ -104,7 +104,9 @@ const find_source_viewer_for_class = (class_def, class_name) => { case 'Graph': return "n:g:z:crdt_source_viewer:rdf"; case 'YMap': + return "n:g:z:crdt_source_viewer:ymap"; case 'YArray': + return "n:g:z:crdt_source_viewer:yarray"; case 'Automerge': case 'Elmer': return "n:g:z:crdt_source_viewer:json"; diff --git a/ng-app/src/zeras.ts b/ng-app/src/zeras.ts index 7105a51..8d115d0 100644 --- a/ng-app/src/zeras.ts +++ b/ng-app/src/zeras.ts @@ -115,14 +115,32 @@ export const official_apps = { "ng:o": ["data:graph"], "ng:w": [], }, - "n:g:z:json_viewer": { + "n:g:z:json_ymap_viewer": { "ng:n": "JSON", "ng:a": "View the JSON data", "ng:c": "app", "ng:u": "json_editor",//favicon. can be a did:ng:j - "ng:g": "n:g:z:json_viewer", - "ng:b": "JsonViewer", - "ng:o": ["data:json","data:array","data:map"], + "ng:g": "n:g:z:json_ymap_viewer", + "ng:b": "YMapViewer", + "ng:o": ["data:map"], + }, + "n:g:z:json_yarray_viewer": { + "ng:n": "JSON", + "ng:a": "View the JSON data", + "ng:c": "app", + "ng:u": "json_editor",//favicon. can be a did:ng:j + "ng:g": "n:g:z:json_yarray_viewer", + "ng:b": "YArrayViewer", + "ng:o": ["data:array"], + }, + "n:g:z:json_automerge_viewer": { + "ng:n": "JSON", + "ng:a": "View the JSON data", + "ng:c": "app", + "ng:u": "json_editor",//favicon. can be a did:ng:j + "ng:g": "n:g:z:json_automerge_viewer", + "ng:b": "AutomergeViewer", + "ng:o": ["data:json"], }, "n:g:z:triple_viewer": { "ng:n": "Graph Triples", @@ -295,13 +313,33 @@ export const official_apps = { "ng:w": [], }, "n:g:z:crdt_source_viewer:json": { - "ng:n": "JSON source", + "ng:n": "JSON Source", "ng:a": "See the source code of this document, in JSON", "ng:c": "app", "ng:u": "source",//favicon. can be a did:ng:j "ng:g": "n:g:z:crdt_source_viewer:json", "ng:b": "JsonSource", // displayed with highlight.js , with option to download - "ng:o": ["data:json", "data:map", "data:array", "data:table", "doc:diagram:jsmind", "doc:diagram:gantt", "doc:diagram:excalidraw", "doc:viz:*", "doc:chart:*", "prod:cad"], + "ng:o": ["data:json", "data:table", "doc:diagram:jsmind", "doc:diagram:gantt", "doc:diagram:excalidraw", "doc:viz:*", "doc:chart:*", "prod:cad"], + "ng:w": [], + }, + "n:g:z:crdt_source_viewer:ymap": { + "ng:n": "JSON Source", + "ng:a": "See the source code of this document, in JSON", + "ng:c": "app", + "ng:u": "source",//favicon. can be a did:ng:j + "ng:g": "n:g:z:crdt_source_viewer:ymap", + "ng:b": "YMapSource", // displayed with highlight.js , with option to download + "ng:o": ["data:map"], + "ng:w": [], + }, + "n:g:z:crdt_source_viewer:yarray": { + "ng:n": "JSON Source", + "ng:a": "See the source code of this document, in JSON", + "ng:c": "app", + "ng:u": "source",//favicon. can be a did:ng:j + "ng:g": "n:g:z:crdt_source_viewer:yarray", + "ng:b": "YArraySource", // displayed with highlight.js , with option to download + "ng:o": ["data:array"], "ng:w": [], }, "n:g:z:crdt_source_viewer:text": {