json5: extend to remote editing

This commit is contained in:
jean-emmanuel 2017-10-04 20:21:15 +02:00
parent 294812b2a3
commit cb310317c0
5 changed files with 13 additions and 9 deletions

View file

@ -8,8 +8,9 @@
- messages received almost simultaneously are now bundled before being sent to the clients. This helps preserving their order.
- widgets
- sliders/pads: when receiving feedback while touched, the widget waits to be released before updating to the latest received value.
- editor
- misc
- property fields are now parsed using [JSON5](https://github.com/json5/json5), a more flexible notation. Session files are still written in standard JSON format, this is just a way to avoid typing mistakes when using the editor.
- remote editing also accepts JSON5 notation
## 0.20.3

View file

@ -10,7 +10,7 @@ Apply a set of options to an existing widget by replacing the old ones with the
- `id`: `string`, widget's `id`
- `options`: `string`, JSON stringified object defining the new properties to merge
- `options`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge
- example: `{"label":"New Label", "color":"red"}`
!!! warning ""
@ -22,7 +22,7 @@ Apply a set of options to an existing widget by merging them to the widget's opt
- `id`: `string`, widget's `id`
- `options`: `string`, JSON stringified object defining the new properties to merge
- `options`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge
- example: `{"label":"New Label", "color":"red"}`
!!! warning ""

View file

@ -1,7 +1,6 @@
var updateDom = require('./data-workers').updateDom,
{widgets, categories} = require('../widgets'),
{icon} = require('../utils'),
JSON5 = require('json5'),
defaults = {}
for (var k in widgets) {
@ -97,12 +96,12 @@ var editObject = function(container, data, refresh){
}
input.on('change',function(){
// var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val()
var title = input.attr('title'),
v
try {
v = JSON5.parse(input.val())
v = JSON.parseFlex(input.val())
} catch(err) {
v = input.val()
}

View file

@ -13,7 +13,7 @@ var callbacks = {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
newdata = JSON.parseFlex(json),
containers = widgetManager.getWidgetById(id)
if (!containers.length) return
@ -32,7 +32,7 @@ var callbacks = {
if (READ_ONLY) return
var [id, json] = args,
newdata = JSON.parse(json),
newdata = JSON.parseFlex(json),
containers = widgetManager.getWidgetById(id)
if (!containers.length) return
@ -54,7 +54,7 @@ var callbacks = {
$(`.tablink[data-widget="${w.hash}"]`).trigger('fake-click')
}
}
}
}

View file

@ -53,6 +53,10 @@ request.send()
///////////////////////
window.JSON.parseFlex = require('json5').parse
///////////////////////
window.$ = require('jquery/dist/jquery.slim.min.js')
require('./libs/jquery.ui')
require('./libs/jquery.drag')