From 97fccdc7f5b55a2d838ac5e8a33ea89650d26d19 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Sat, 26 Feb 2022 08:45:26 +0100 Subject: [PATCH] editor: code editor for css/html --- CHANGELOG.md | 3 +++ src/client/ui/ui-code-editor.js | 4 +++- src/client/widgets/common/widget.js | 4 ++-- src/client/widgets/containers/patchbay.js | 14 +++++++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6a1447b..fabdcdae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - bug fixes - prevent flickering on canvas based widgets when they are recreated +- editor + - added code editor for `html` and `css` properties + ## 1.15.0 - bug fixes diff --git a/src/client/ui/ui-code-editor.js b/src/client/ui/ui-code-editor.js index d77ae67c..27f788cd 100644 --- a/src/client/ui/ui-code-editor.js +++ b/src/client/ui/ui-code-editor.js @@ -7,7 +7,9 @@ var UiModal = require('./ui-modal'), ScriptVm = require('../widgets/scripts/script-vm'), scriptGlobals = ScriptVm.globals, editors = {}, editorModes = { - javascript: require('brace/mode/javascript') + javascript: require('brace/mode/javascript'), + css: require('brace/mode/css'), + html: require('brace/mode/html'), }, codeEditorModKey = (navigator.platform || '').match('Mac') ? 'Cmd' : 'Ctrl' diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index aa1545f2..2f930503 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -84,7 +84,7 @@ class Widget extends EventEmitter { alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'}, lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, - html: {type: 'string', value: '', help: [ + html: {type: 'string', value: '', editor: 'html', syntaxChecker: false, help: [ 'Custom html content to be inserted in the widget (before the widget\'s content). Elements are all unstyled by default, `css` should be used to customize their appearance.', 'The code is automatically wrapped in <div class="html"></div>', 'Allowed HTML tags:', @@ -95,7 +95,7 @@ class Widget extends EventEmitter { '  <*>: class, style, title, name', '  <img>: src, width, height', ]}, - css: {type: 'string', value: '', help: [ + css: {type: 'string', value: '', editor: 'css', syntaxChecker: false, help: [ 'CSS rules. See documentation.', 'Some style-related properties can be set or read from css using css variables:', ...Class.cssVariables.map(x=>'- `' + x.css + '`: `' + x.js + '`') diff --git a/src/client/widgets/containers/patchbay.js b/src/client/widgets/containers/patchbay.js index 824b3697..e5519a2e 100644 --- a/src/client/widgets/containers/patchbay.js +++ b/src/client/widgets/containers/patchbay.js @@ -73,13 +73,7 @@ class PatchBay extends Container(Canvas) { static defaults() { - return super.defaults().extend({ - style: { - css: {type: 'string', value: '', help: [ - 'The inputs/ouputs width can be adjusted by using the `.nodes` selector:', - '`.nodes { width: 25% }`', - ]} - }, + var defaults = super.defaults().extend({ class_specific: { inputs: {type: 'array|object', value: ['input_1', 'input_2'], help: [ '- `Array` of input names : `[\'input_1\', \'input_2\']`', @@ -94,6 +88,12 @@ class PatchBay extends Container(Canvas) { } }) + defaults.style.css.help.concat( + 'The inputs/ouputs width can be adjusted by using the `.nodes` selector:', + '`.nodes { width: 25% }`', + ) + + return defaults } static normalizeArrayObject(obj) {