From 80c0f40106efecce4552a90a94ab0f4bf9467048 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 17 Dec 2021 09:26:20 +0100 Subject: [PATCH] editor: 2 spaces indent; add editor without syntax checking for containter.props --- src/client/ui/ui-inspector-field.js | 20 +++++++++++++------- src/client/widgets/containers/clone.js | 2 +- src/client/widgets/containers/fragment.js | 2 +- src/client/widgets/containers/matrix.js | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/client/ui/ui-inspector-field.js b/src/client/ui/ui-inspector-field.js index 7e86be6a..7bff0cf0 100644 --- a/src/client/ui/ui-inspector-field.js +++ b/src/client/ui/ui-inspector-field.js @@ -13,12 +13,19 @@ var UiWidget = require('./ui-widget'), javascript: require('brace/mode/javascript') } -function createEditor(name, language) { +function createEditor(name, language, syntaxChecker) { var el = html`
` var editor = editors[name] = ace.edit(el) if (editorModes[language]) editor.getSession().setMode('ace/mode/' + language) - editor.setOption('autoScrollEditorIntoView', true) - editor.setOption('maxLines', 40) + editor.setOptions({ + autoScrollEditorIntoView: true, + fixedWidthGutter: true, + tabSize: 2, + maxLines: 30, + dragEnabled: false, + useWorker: syntaxChecker !== false + }) + editor.$blockScrolling = Infinity editor.commands.bindKeys({ 'ctrl-l': null, 'ctrl-f': null, 'ctrl-h': null, 'ctrl-,': null, @@ -26,13 +33,12 @@ function createEditor(name, language) { editor.renderer.setScrollMargin(4, 4, 0, 4) editor.element = el editor.element.classList.add('ace_dark') - editor.$mouseHandler.setOption('dragEnabled', false) editor.textarea = DOM.get(el, '.ace_text-input')[0] editor.textarea.name = name editor.textarea._ace = true editor.setHighlightActiveLine(false) editor.setHighlightGutterLine(false) - if (language === 'javascript') { + if (language === 'javascript' && syntaxChecker !== false) { editor.getSession().$worker.send('setOptions', [{ asi: true, // no semicolon esversion: 6, @@ -172,7 +178,7 @@ class UiInspectorField extends UiWidget { if (this.default.editor) { this.container.classList.add('has-editor') - if (!editors[this.name]) createEditor(this.name, this.default.editor) + if (!editors[this.name]) createEditor(this.name, this.default.editor, this.default.syntaxChecker) let editor = editors[this.name] input.style.display = 'none' input._ace_input = editor.textarea @@ -223,7 +229,7 @@ class UiInspectorField extends UiWidget { globals.JS = true globals.this = false - editor.getSession().$worker.send('changeOptions', [{ + if (this.default.syntaxChecker !== false) editor.getSession().$worker.send('changeOptions', [{ globals: {...scriptGlobals, ...globals} }]) } diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 38fc3aaa..d6fe17a0 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -22,7 +22,7 @@ class Clone extends Container() { class_specific: { widgetId: {type: 'string', value: '', help: '`id` of the widget to clone'}, - props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'}, + props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Cloned widget\'s properties to override'}, }, value: null, osc: null diff --git a/src/client/widgets/containers/fragment.js b/src/client/widgets/containers/fragment.js index 0aa3aa97..baf879e3 100644 --- a/src/client/widgets/containers/fragment.js +++ b/src/client/widgets/containers/fragment.js @@ -23,7 +23,7 @@ class Fragment extends Container() { class_specific: { file: {type: 'string', value: '', help: 'Fragment file path (relative to the session or theme file location by default, falling back to absolute path)'}, - props: {type: 'object', value: {}, help: 'Fragment widget\'s properties to override'}, + props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Fragment widget\'s properties to override'}, }, value: null, osc: null diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index 71305b36..055f9c09 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -17,7 +17,7 @@ class Matrix extends Panel { class_specific: { widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'}, quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, - props: {type: 'object', value: {}, help: [ + props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, 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{}, VAR{} and #{}) are resolved at the matrix\' scope (ie @{this.variables} returns the matrix\' variables property)',