Skip to content
7 changes: 4 additions & 3 deletions playground/next/editor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ window.app = createApp({
safe: ''
},
tabs: {
expanded: {icon: 'expanded alternate', label: 'Expanded'},
expanded: {icon: 'expand alternate', label: 'Expanded'},
compacted: {icon: 'compress alternate', label: 'Compacted'},
flattened: {icon: 'bars', label: 'Flattened'},
framed: {icon: 'crop alternate', label: 'Framed'},
Expand Down Expand Up @@ -395,6 +395,7 @@ window.app = createApp({
},
// methods
async retrieveDoc(_editor, docVar, url) {
if (!url) return;
try {
const rv = await fetch(url);
if (!rv.ok) {
Expand Down Expand Up @@ -573,7 +574,7 @@ window.app = createApp({
// the `json-ld` parameter can be JSON or a URL
const jsonLdOrUrl = hash.get('json-ld');
try {
this.doc = JSON.parse(jsonLdOrUrl);
this.doc = JSON.parse(jsonLdOrUrl) || this.doc;
setEditorValue(this.mainEditor, this.doc);
} catch {
this.remoteDocURL = jsonLdOrUrl;
Expand All @@ -582,6 +583,6 @@ window.app = createApp({
if (hash.get('copyContext') === 'true') {
this.copyContext();
}
this.outputTab = hash.get('startTab')?.slice(4);
this.outputTab = hash.get('startTab')?.slice(4) || this.outputTab;
}
}).mount();
43 changes: 22 additions & 21 deletions playground/next/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,29 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
</table>
</div>
</div>
<div class="ui icon message" v-if="message.text" :class="message.type">
<i class="icon" :class="{
'info circle': message.type == 'info',
'check circle': message.type == 'success',
'times circle': message.type == 'error',
'exclamation triangle': message.type == 'warning'
}"></i>
<div class="content">
<div class="header" v-text="message.text"></div>
</div>
</div>
<!-- main editor area -->
<div class="ui one column wide compact grid container" :class="[editorColumns]">
<div class="column" :class="{ 'sixteen wide': editorColumns == '' }">
<div class="ui icon message" v-show="message.text" :class="message.type">
<i class="icon" :class="{
'info circle': message.type == 'info',
'check circle': message.type == 'success',
'times circle': message.type == 'error',
'exclamation triangle': message.type == 'warning'
}"></i>
<div class="content">
<div class="header" v-text="message.text"></div>
</div>
</div>
<div class="ui top attached tabular menu">
<div :class="{ active: inputTab == 'json-ld' }" class="item" @click="inputTab = 'json-ld'"><i class="pencil alternate icon"></i> JSON-LD Input</div>
<div :class="{ active: inputTab == 'options' }" class="item" @click="inputTab = 'options'"><i class="wrench icon"></i> Options</div>
<div class="right menu">
<div class="item">
<div class="item" style="padding-right: 0">
<div class="ui icon input">
<input type="text" placeholder="Document URL"
v-model="remoteDocURL" @keyup.enter="retrieveDoc(mainEditor, 'doc', remoteDocURL)">
<i class="file link icon" @click="retrieveDoc(mainEditor, 'doc', remoteDocURL)"></i>
<i class="file link icon" :class="{ disabled: remoteDocURL == '' }" @click="retrieveDoc(mainEditor, 'doc', remoteDocURL)"></i>
</div>
</div>
</div>
Expand Down Expand Up @@ -237,7 +237,7 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
<div class="ui radio checkbox">
<input type="radio" id="options-api-safe-default" name="safe" value="" checked
v-model="options.safe">
<label for="options-api-safe-default">Default</label>
<label for="options-api-safe-default">Default (False)</label>
</div>
</div>
<div class="field">
Expand Down Expand Up @@ -271,7 +271,7 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
<span v-show="outputTab == 'framed'">JSON-LD Frame</span>
</div>
<div class="right menu">
<div class="item">
<div class="item" style="padding-right: 0">
<div class="ui icon input">
<input type="text" :placeholder="sideEditorURLFieldPlaceholderText"
v-model="remoteSideDocURL" @keyup.enter="retrieveDoc(sideEditor, sideDoc, remoteSideDocURL)">
Expand All @@ -296,11 +296,12 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
<div class="ui top attached tabular menu">
<div v-for="(tab, key) in tabs" :class="{ active: outputTab == key }" class="item" @click="setOutputTab(key)"><i class="icon" :class="tab.icon"></i> <span v-text="tab.label"></span></div>
</div>
<div class="ui fitted resizable scrolling active bottom attached tab segment">
<div class="ui grid">
<div class="column" :class="{'nine wide': outputTab == 'cborld'}">
<div class="ui fitted resizable active bottom attached tab segment">
<div class="ui very compact divided grid">
<div class="column" :class="{'eight wide': outputTab == 'cborld'}">
<div v-show="outputTab != 'table'" id="read-only-editor"><!-- replaced by CodeMirror --></div>
<table class="ui very padded table" v-show="outputTab == 'table'">
<table class="ui compact table" style="margin-top: 0"
v-show="outputTab == 'table'">
<thead>
<tr>
<th>Subject</th>
Expand Down Expand Up @@ -340,8 +341,8 @@ <h2 class="ui massive header">JSON-LD Playground</h2>
</tr>
</table>
</div>
<div class="seven wide column" v-if="outputTab == 'cborld'">
<table class="ui fixed definition table">
<div class="eight wide column" v-if="outputTab == 'cborld'">
<table class="ui fixed definition table" style="margin-left: -0.25rem">
<tr>
<td class="three wide">JSON-LD Size</td><td><span v-text="cborLD.jsonldSize"></span> bytes</td>
</tr>
Expand Down