Skip to content

Commit

Permalink
Merge branch 'release/1.0.2' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Nov 4, 2022
2 parents 21f99d7 + d6f782f commit f4bc04b
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## 1.0.2 - 2022.11.04
### Added
* Added support for `monacoOptions.theme` set to `auto` automatically setting the theme to match the browser's dark mode setting

## 1.0.1 - 2022.11.02
### Added
* Added a JSON icon
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ Regardless of the macro used, an Asset Bundle containing the necessary CSS & Jav

### In Frontend Templates

Code Editor works in frontend templates, for every language except `twig`.

If you plan to use `twig` as the language for Code Editor in your frontend templates, you'll need to specifically enable it.
Code Editor also works in frontend templates, but you'll need to specifically enable it.

Do so by copying the `config.php` file to the Craft CMS `config/` directory, renaming the file to `codeeditor.php` in the process, then set the `allowFrontendAccess` setting to `true`:

Expand Down Expand Up @@ -153,7 +151,15 @@ Create your own `<textarea>` element and include the necessary JavaScript, passi
{{ codeEditor.includeJs("myCodeEditor") }}
```

Enabling the `allowFrontendAccess` setting allows access to the `codeeditor/autocomplete/index` endpoint, and add the `code-editor/templates` directory to the template roots.
Enabling the `allowFrontendAccess` setting allows access to the `codeeditor/autocomplete/index` endpoint, and add the `codeeditor/templates` directory to the template roots.

The following `monacoOptions` allow you to make the field read-only (though the user can still interact with the code):
```json
{
"domReadOnly": true,
"readOnly": true
}
```

### Additional Options

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-code-editor",
"description": "Provides a code editor field with Twig & Craft API autocomplete",
"type": "yii2-extension",
"version": "1.0.1",
"version": "1.0.2",
"keywords": [
"code",
"editor",
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/dist/css.worker.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/css.worker.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/web/assets/dist/css/vendors.css

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/css/vendors.css.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/editor.worker.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/editor.worker.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/html.worker.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/html.worker.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions src/web/assets/dist/js/code-editor.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/js/code-editor.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/js/code-editor.js.map

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/js/code-editor.js.map.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/js/runtime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/web/assets/dist/js/vendors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/web/assets/dist/js/vendors.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/web/assets/dist/json.worker.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/json.worker.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions src/web/assets/dist/report-legacy.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/dist/ts.worker.js

Large diffs are not rendered by default.

Binary file modified src/web/assets/dist/ts.worker.js.gz
Binary file not shown.
6 changes: 5 additions & 1 deletion src/web/assets/src/js/code-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ function setMonacoEditorLanguage(editor: monaco.editor.IStandaloneCodeEditor, la
* @param {string | undefined} theme - the editor theme
*/
function setMonacoEditorTheme(editor: monaco.editor.IStandaloneCodeEditor, theme: string | undefined): void {
const editorTheme = theme ?? 'vs';
let editorTheme = theme ?? 'vs';
if (editorTheme === 'auto') {
const mediaQueryObj = window.matchMedia('(prefers-color-scheme: dark)');
editorTheme = mediaQueryObj.matches ? 'vs-dark' : 'vs';
}
editor.updateOptions({theme: editorTheme});
}

Expand Down

0 comments on commit f4bc04b

Please sign in to comment.