editor: 2 spaces indent; add editor without syntax checking for containter.props

This commit is contained in:
jean-emmanuel 2021-12-17 09:26:20 +01:00
parent 7dcf4afe52
commit 80c0f40106
4 changed files with 16 additions and 10 deletions

View file

@ -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`<div id="#editor${name}"></div>`
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}
}])
}

View file

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

View file

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

View file

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