matrix: advanced syntax blocks can be passed to children without being resolved at the matrix\' scope by adding an underscore before the opening bracket

This commit is contained in:
bordun 2021-05-08 12:42:50 +02:00
parent 6a2b69bad7
commit e98f270690
2 changed files with 9 additions and 3 deletions

View file

@ -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

View file

@ -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,