From e98f270690c74d5cf76c37d47816a398fa997c08 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 8 May 2021 12:42:50 +0200 Subject: [PATCH] matrix: advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket --- CHANGELOG.md | 1 + src/client/widgets/containers/matrix.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df669fe..c9f35532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - widgets - script: bypass keyboard shortcuts already used by the editor if it is enabled - matrix: removed ambiguous `start` property + - matrix: advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket - text: add `soft` mode for the `wrap` property ## 1.9.6 diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index 9a8baeac..839b6eb7 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -19,9 +19,10 @@ class Matrix extends Panel { quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, props: {type: 'object', value: {}, help: [ 'Defines a set of property to override the widgets\' defaults.', - 'JS{{}} and #{} blocks in this field are resolved with an extra variable representing each widget\'s index: `$` (e.g. `#{$}`)', - 'Advanced syntax blocks (@{}, OSC{}, JS{{}} and #{}) are resolved at the matrix\' scope (ie @{this.variables} returns the matrix\' variables property)', - 'Note: by default, the widgets inherit from the matrix\' `id` and osc properties (`id` and `address` are appended with `/$`)' + 'JS{} and #{} blocks in this field are resolved with an extra variable representing each widget\'s index: `$` (e.g. `#{$}`)', + 'Advanced syntax blocks (@{}, OSC{}, JS{}, VAR{} and #{}) are resolved at the matrix\' scope (ie @{this.variables} returns the matrix\' variables property)', + 'Advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket.', + 'Note: unless overridden, children inherit from the matrix\' `id` and osc properties (`id` and `address` are appended with `/$`)' ]}, }, style: { @@ -70,6 +71,8 @@ class Matrix extends Panel { Object.assign(data, props) } + data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{')) + var widget = parser.parse({ data: data, parentNode: this.widget, @@ -129,6 +132,8 @@ class Matrix extends Panel { data = {} } + data = JSON.parse(JSON.stringify(data).replace(/(JS|#|OSC|@|VAR)_\{/g, '$1{')) + if (typeof oldPropValue === 'object' && oldPropValue !== null) { // if an overridden default props is removed, set it back to default let overriddenDefaults,