diff --git a/app/client/index.html b/app/client/index.html index 18b4ddff..e26e602c 100644 --- a/app/client/index.html +++ b/app/client/index.html @@ -7,8 +7,6 @@ - - diff --git a/package.json b/package.json index 7f3d4a2c..aab8654b 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "yargs": "15.1.0" }, "optionalDependencies": { - "electron": "7.1.11", + "electron": "8.0.1", "electron-installer-debian": "3.0.0" }, "scripts": { diff --git a/src/client/managers/widgets.js b/src/client/managers/widgets.js index d37b5c6b..e7f5c56c 100644 --- a/src/client/managers/widgets.js +++ b/src/client/managers/widgets.js @@ -138,7 +138,6 @@ var WidgetManager = class WidgetManager extends EventEmitter { data: updatedData || { precision: widget.getProp('precision'), preArgs: widget.getProp('preArgs'), - split: widget.getSplit(), target: widget.getProp('target'), address: widget.getProp('address'), noSync: widget.getProp('noSync'), diff --git a/src/client/widgets/buttons/menu.js b/src/client/widgets/buttons/menu.js index 5aab958b..fe3804b2 100644 --- a/src/client/widgets/buttons/menu.js +++ b/src/client/widgets/buttons/menu.js @@ -64,9 +64,6 @@ class Menu extends Widget { this.parseValues() - this.parentScroll = [0,0] - - if (this.getProp('doubleTap')) { doubletab(this.widget, (e)=>{ diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index fb6d112d..12ad15f3 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -54,6 +54,7 @@ class Widget extends EventEmitter { 'Insert icons using the prefix ^ followed by the icon\'s name : ^play, ^pause, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)' ]}, visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'}, + // interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'}, _geometry:'geometry', @@ -174,7 +175,6 @@ class Widget extends EventEmitter { this.errors.id = 'There can only be one root' } - this.disabledProps = [] // this.mathjsDeprecationWarned = false // cache precision @@ -281,8 +281,6 @@ class Widget extends EventEmitter { } - getSplit() {} - checkLinkedProps(propNames) { // Dynamic props cache check @@ -440,7 +438,7 @@ class Widget extends EventEmitter { var variables = {}, defaultScope = this.constructor.parsersContexts[propName] || {}, - mathscope = context || {}, + jsScope = context || {}, varnumber = 999 if (typeof propValue == 'string') { @@ -548,7 +546,7 @@ class Widget extends EventEmitter { varnumber-- variables[varname] = r - mathscope[varname] = r + jsScope[varname] = r return varname @@ -588,7 +586,7 @@ class Widget extends EventEmitter { varnumber-- variables[varname] = r - mathscope[varname] = r + jsScope[varname] = r return varname }) @@ -597,12 +595,21 @@ class Widget extends EventEmitter { propValue = propValue.replace(/#\{(?:[^{}]|\{[^{}]*\})*\}/g, (m)=>{ // one bracket nesting allowed, if we need two: #\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\} - //TODO: js one-liner + var code = m.substr(2, m.length - 3).trim() + + if (!this.parsers[code]) this.parsers[code] = evaljs('return ' + code, defaultScope) + + let r = this.parsers[code](jsScope) + + if (r === undefined) r = '' + + return typeof r !== 'string' ? JSON.stringify(r) : r - return '' }) } catch (err) { - console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err) + var stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '', + line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : '' + console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err + line) } try { @@ -610,7 +617,7 @@ class Widget extends EventEmitter { if (!this.parsers[code]) this.parsers[code] = evaljs(code, defaultScope) - let r = this.parsers[code](mathscope) + let r = this.parsers[code](jsScope) if (r === undefined) r = '' @@ -794,9 +801,6 @@ class Widget extends EventEmitter { address: propName == 'address' ? oldPropValue : this.getProp('address') } data[propName] = this.getProp(propName) - if (propName === 'address' && this.getSplit()) { - data['split'] = this.getSplit() - } widgetManager.registerWidget(this, data, oldData) return @@ -931,13 +935,20 @@ class Widget extends EventEmitter { if (styles.includes('color')) { // color - this.container.style.setProperty('--color-widget', this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '') - this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '') - this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '') - this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '') - this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '') - this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '') - this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') + for (var cssvar of ['color-widget', 'color-fill', 'color-stroke', 'alpha-stroke', 'alpha-fill-on', 'alpha-fill-off']) { + var val = this.getProp(cssvar.replace(/\-([a-z])/g, (a,s)=>s.toUpperCase())) + this.container.style.setProperty('--' + cssvar, val !== undefined && val != 'auto' ? val : '') + } + this.container.style.setProperty('--widget-padding', this.getProp('padding') !== undefined && this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') + + + // this.container.style.setProperty('--color-widget', this.getProp('colorWidget') && this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '') + // this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '') + // this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '') + // this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '') + // this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '') + // this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '') + // this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '') } diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index ee46e385..e08496a6 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -6,7 +6,7 @@ var Container = require('../common/container'), {diff, diffToWidget} = require('../../editor/diff'), html = require('nanohtml') -var excludedCloneClasses = ['widget', 'absolute-position', 'ui-resizable', 'ui-draggable', 'not-editable', 'editing'] +var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing'] class Clone extends Container() { @@ -28,7 +28,12 @@ class Clone extends Container() { props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'}, - }, ['label', 'color', 'linkId', '_value', 'default', 'value', '_osc', 'precision', 'address', 'preArgs', 'target', 'bypass']) + }, [ + '_style', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn', 'padding', + 'label', 'color', 'linkId', + '_value', 'default', 'value', + '_osc', 'precision', 'address', 'preArgs', 'target', 'bypass' + ]) } diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js index 2131948e..87ebe664 100644 --- a/src/client/widgets/containers/modal.js +++ b/src/client/widgets/containers/modal.js @@ -45,8 +45,6 @@ class Modal extends Panel { super(options) - this.disabledProps = [] - this.popup = html`