diff --git a/playground/next/editor.mjs b/playground/next/editor.mjs index f37ccca5..1fa0bb2b 100644 --- a/playground/next/editor.mjs +++ b/playground/next/editor.mjs @@ -93,16 +93,17 @@ function editorListener(docName) { const latestChange = changes[changes.length-1]; if (latestChange === '') { this[docName] = ''; - this.parseError = ''; + this.parseError = {}; setEditorValue(readOnlyEditor, ''); return; } else { try { const parsed = JSON.parse(latestChange); this[docName] = parsed; - this.parseError = ''; + this.parseError = {}; + this.setOutputTab(this.outputTab); } catch (err) { - this.parseError = err.message; + this.parseError = err; }; } }, 1000).call(this, docName); @@ -325,17 +326,16 @@ window.app = createApp({ remoteDocURL: '', remoteSideDocURL: '', message: {type: '', text: ''}, - parseError: '', + parseError: {}, inputTab: 'json-ld', outputTab: 'expanded', options: { - processingMode: '', + processingMode: 'json-ld-1.1', base: '', - baseUrl: '', compactArrays: true, compactToRelative: true, rdfDirection: '', - safe: '' + safe: false }, tabs: { expanded: {icon: 'expand alternate', label: 'Expanded'}, @@ -412,7 +412,7 @@ window.app = createApp({ this.remoteDocURL = ''; this.remoteSideDocURL = ''; } catch (err) { - this.parseError = err.message; + this.parseError = err; } }, async loadExample(file) { @@ -431,7 +431,7 @@ window.app = createApp({ this.setOutputTab(this.outputTab); }, async setOutputTab(value) { - if (!value || !this.doc) return; + if (!this.doc) return; if (value) this.outputTab = value; let context = this.contextDoc; switch (this.outputTab) { @@ -440,9 +440,9 @@ window.app = createApp({ try { const expanded = await jsonld.expand(this.doc, this.options); setEditorValue(readOnlyEditor, expanded); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'compacted': @@ -457,9 +457,9 @@ window.app = createApp({ try { const compacted = await jsonld.compact(this.doc, {'@context': context['@context'] || {}}, this.options); setEditorValue(readOnlyEditor, compacted); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'flattened': @@ -474,18 +474,18 @@ window.app = createApp({ try { const flattened = await jsonld.flatten(this.doc, {'@context': context['@context'] || {}}, this.options); setEditorValue(readOnlyEditor, flattened); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'framed': try { const framed = await jsonld.frame(this.doc, this.frameDoc, this.options); setEditorValue(readOnlyEditor, framed); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'nquads': @@ -496,21 +496,21 @@ window.app = createApp({ ...this.options }); setEditorValue(readOnlyEditor, output); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'canonized': // TODO: this should happen elsewhere...like a watcher try { const output = await jsonld.canonize(this.doc, { - format: 'application/n-quads', ...this.options + format: 'application/n-quads', ...{...this.options, ...{safe: true}} }); setEditorValue(readOnlyEditor, output); - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'table': @@ -518,9 +518,9 @@ window.app = createApp({ try { const output = await jsonld.toRDF(this.doc, this.options); this.tableQuads = output; - this.parseError = ''; + this.parseError = {}; } catch(err) { - this.parseError = err.message; + this.parseError = err; } break; case 'yamlld': @@ -544,10 +544,10 @@ window.app = createApp({ this.cborLD.diagnostics = cbor2.diagnose(this.cborLD.bytes, { pretty: true}) setEditorValue(readOnlyEditor, this.cborLD.diagnostics, 'cbor'); - this.parseError = ''; + this.parseError = {}; } catch (err) { // TODO: currently, the editor keeps it's old value...unupdated... - this.parseError = err.message; + this.parseError = err; console.error(err); } break; diff --git a/playground/next/index.html b/playground/next/index.html index dda25087..599b766d 100644 --- a/playground/next/index.html +++ b/playground/next/index.html @@ -143,24 +143,17 @@

JSON-LD Playground

-
-
- - -
-
+ v-model="options.processingMode" @change="setOutputTab()">
+ v-model="options.processingMode" @change="setOutputTab()">
@@ -168,23 +161,9 @@

JSON-LD Playground

-
-
- - -
-
-
-
- - -
-
-
+
+ v-model="options.base" @change="setOutputTab()">
@@ -193,7 +172,7 @@

JSON-LD Playground

+ v-model="options.compactArrays" @change="setOutputTab()">
@@ -204,7 +183,7 @@

JSON-LD Playground

+ v-model="options.compactToRelative" @change="setOutputTab()">
@@ -216,14 +195,14 @@

JSON-LD Playground

+ v-model="options.rdfDirection" @change="setOutputTab()">
+ v-model="options.rdfDirection" @change="setOutputTab()">
@@ -235,22 +214,15 @@

JSON-LD Playground

- - -
-
-
-
- +
- +
@@ -291,7 +263,12 @@

JSON-LD Playground

-
+
+
+
+

+    
+