diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d2ce057..3f8518d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - inspector - color picker: inline picker widget (no longer in a modal); show color changes on the fly + - code editor: validate input with `cmd+enter` instead of `ctrl+enter` on Mac - scripting - `screen.height` and `screen.width` always returns the current screen dimensions diff --git a/resources/docs/docs/user-interface/editor.md b/resources/docs/docs/user-interface/editor.md index 63be76ed..406ee1a2 100644 --- a/resources/docs/docs/user-interface/editor.md +++ b/resources/docs/docs/user-interface/editor.md @@ -40,7 +40,7 @@ Selected widget's properties are displayed and can be modified in the inspector. - Properties are written in JSON, with some flexibility brought by the [JSON5](https://github.com/json5/json5) format. For example, double quotes around object keys are not mandatory. - Clicking on a property name spawns a help modal window -Some properties (for example `script`) have a special code editor with syntax hilighting and many keyboard shortcuts (available by clicking on the "Help" button). In this properties, pressing `enter` will not submit pending changes and instead insert a new line at the cursor position (as you would expect in a regular editor). To submit pending changes, press `ctrl+enter` or click outside the editor. +Some properties (for example `onValue`) have a special code editor with syntax hilighting and many keyboard shortcuts (available by clicking on the "Help" button). In this properties, pressing `enter` will not submit pending changes and instead insert a new line at the cursor position (as you would expect in a regular editor). To submit pending changes, press ++ctrl+enter++ (or ++cmd+enter== on Mac) or click outside the editor. ## Project tree diff --git a/src/client/ui/ui-code-editor.js b/src/client/ui/ui-code-editor.js index 75157b92..d77ae67c 100644 --- a/src/client/ui/ui-code-editor.js +++ b/src/client/ui/ui-code-editor.js @@ -8,7 +8,8 @@ var UiModal = require('./ui-modal'), scriptGlobals = ScriptVm.globals, editors = {}, editorModes = { javascript: require('brace/mode/javascript') - } + }, + codeEditorModKey = (navigator.platform || '').match('Mac') ? 'Cmd' : 'Ctrl' class CodeEditor { @@ -252,7 +253,7 @@ class CodeEditor { Command - Ctrl-Entersave + ${codeEditorModKey}-Entersave ${keybindings.map(k=>html`${k.key}${k.command}`)} diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index 20d349ab..f4e137f7 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -7,8 +7,8 @@ var UiWidget = require('./ui-widget'), html = require('nanohtml'), raw = require('nanohtml/raw'), fastdom = require('fastdom'), - getCodeEditor = require('./ui-code-editor') - + getCodeEditor = require('./ui-code-editor'), + codeEditorModKey = (navigator.platform || '').match('Mac') ? 'metaKey' : 'ctrlKey' class UiInspector extends UiWidget { @@ -268,7 +268,7 @@ class UiInspector extends UiWidget { if (event.keyCode === 13 && ((!event.shiftKey && !event.target._ace) || - (event.ctrlKey && event.target._ace)) + (event[codeEditorModKey] && event.target._ace)) ) { event.preventDefault()