-
-
Notifications
You must be signed in to change notification settings - Fork 233
Replace Ace Editor with Monaco Editor #801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+26,692
−4,349
Merged
Changes from 8 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
5e34057
Initial setup of Monaco build process
bennothommo 3e322f9
Delete workshop theme
bennothommo b570cc2
Initial compilation and setup of Monaco
bennothommo ebd0b3c
Further work on Monaco Editor support
bennothommo 7f3d723
Ignore Monaco dev module chunks
bennothommo 8f16865
Add configuration for indent guides and bracket colors
bennothommo aae1307
WIP preferences page update
bennothommo 83e4bf5
WIP preferences - add code minimap config, fix preview
bennothommo d0d2142
Add preferences page UI js to build process
bennothommo 9c37aae
Code cleanup, commenting and changing to US spelling
bennothommo 4cc0e64
Add word wrap, font size and tab size preferences
bennothommo d613773
Add rest of preferences, add bracket color and color picker preferences
bennothommo de77d63
Drop unneeded line
bennothommo a4a61b3
WIP themes
bennothommo 0678c3d
WIP themes
bennothommo 6c3fa79
Add ability to preview multiple languages in code editor settings, ad…
bennothommo 45f87e7
Add all available themes (only cut Crimson Editor)
bennothommo 83d40f6
Merge branch 'wip/monaco-editor' of github.com:wintercms/winter into …
bennothommo 448df5d
Increase size of code editor preview
bennothommo 0b44c31
Add listener for jQuery render to render widgets
bennothommo 968b212
Update Mix alias for code editor
bennothommo 51ef6e6
Add local event handler for widgets
bennothommo 432bccf
Convert editor preview on Preference page to actual widget, add local…
bennothommo 5b4691b
Fix "once" local events
bennothommo f5614b8
Optimise editor on resize and leaving/entering tab, add fullscreen
bennothommo d15c560
Allow ad-hoc Snowboard listeners to function even if no plugins are l…
bennothommo f1ac221
Fix code editor in CMS area, add ability for hidden code areas
bennothommo 0a3d2a3
Add more reliable method of retrieving widgets based on a given element
bennothommo f9cc262
Add content manipulation methods in editor
bennothommo c4eea51
Fix component placement and PHP highlighting in CMS pages
bennothommo 95ee826
Merge branch 'develop' into wip/monaco-editor
bennothommo a6d1500
Merge branch 'develop' into wip/monaco-editor
bennothommo 557572b
Allow code editor to work without status bar
bennothommo b9d74a7
Add wrap capability
bennothommo 8e140d2
WIP Markdown Editor rewrite
bennothommo f97fcb5
Recompile assets
bennothommo 1623f3c
Return selections after editor modification, small tweaks
bennothommo 4ee21ba
Merge remote-tracking branch 'origin/develop' into wip/monaco-editor
bennothommo 5a85172
WIP input tracking in Markdown Editor
bennothommo c7aceef
Merge branch 'develop' into wip/monaco-editor
bennothommo 59432f4
Remove call to Theme::getActiveTheme()
bennothommo e337006
Adding formatting wrap/unwrap. Add preview.
bennothommo da26b55
WIP add Italic format, improve configuration
bennothommo 0657457
Merge branch 'develop' into wip/monaco-editor
bennothommo f811640
Allow Stripe Loader to be disabled by Snowboard requests
bennothommo a6ba63f
WIP config options
bennothommo 369265b
WIP keybindings
bennothommo 730b716
Fix multiple backspace issue
bennothommo b140449
Merge branch 'develop' into wip/monaco-editor
bennothommo f8218bd
Merge branch 'develop' into wip/monaco-editor
bennothommo 18db19b
Merge branch 'develop' into wip/monaco-editor
bennothommo e66e433
After building Monaco bundle, remove inline Codicon font calls
bennothommo 09bd7fc
Update bundle, fix Italic detection in Markdown editor
bennothommo fdb60d4
Use in-bult VS theme for Markdown editor
bennothommo 1ed3b33
Only allow Markdown editor actions to fire if enabled
bennothommo 4c5be78
Allow selection of in-built Monaco themes
bennothommo fc6c6cd
Fix resize issues with code editor
bennothommo 3ba08c2
Allow editor to start from a certain line
bennothommo c6c253c
Round to nearest pixel
bennothommo 8fc63fc
Merge branch 'develop' into wip/monaco-editor
bennothommo b381e82
Prevent misclicking of outside elements when selecting code inside ed…
bennothommo 636e891
Fix reselection of text after changing bold status
bennothommo d326aef
WIP fixing reselection of text after bold/italitc toggle
bennothommo bbb2775
Merge branch 'develop' into wip/monaco-editor
bennothommo 6b4383a
Code quality fixes, discard repeated package registrations
bennothommo 9f2278f
Merge branch 'develop' into wip/monaco-editor
bennothommo 5e5fe05
Merge branch 'develop' into wip/monaco-editor
bennothommo 188ebb5
Add ability to modify CMS component templates inside Monaco
bennothommo d255e5f
Fix exception on AJAX requests made by widgets when template form is …
bennothommo c115dac
Remove old token expansion functionality
bennothommo bcb66a8
Update modules/backend/models/Preference.php
bennothommo 471c2fe
Merge branch 'develop' into wip/monaco-editor
LukeTowers 5bc3633
Fix issue with closing full screen mode on page with markdown editor …
LukeTowers 35a37d9
Add support for JSON themes
LukeTowers 4c5ce67
Darken the one dark pro theme background for readability
LukeTowers cc5cb68
Use asset URL for codeeditor assets
LukeTowers 536c274
Improve removal of inline codicon font-face
LukeTowers 164d8ea
Restore original ace-backed codeeditor for RichEditor to use
LukeTowers 0a18ddb
Cleanup
LukeTowers 1ccd5a2
Deconflict ace-codeeditor from monaco codeeditor
LukeTowers 70ddb83
Discard changes to modules/backend/formwidgets/markdowneditor/assets/…
LukeTowers 1881d3d
Discard changes to modules/backend/formwidgets/markdowneditor/partial…
LukeTowers 18af3ee
Discard changes to themes/demo/pages/ajax.htm
LukeTowers d154867
Restore Ace Editor for MarkdownEditor
LukeTowers adc5340
Move asset bundle registration to the boot() method
LukeTowers a799004
Fix styling issue with tab collapse icon on fancy layouts
LukeTowers 7d889d0
Improve codeeditor bundle loading
LukeTowers 71a2601
Tidying
LukeTowers 062218b
Add asset_url link tag to backend layouts to make Snowboard.url().ass…
LukeTowers 04e437a
Improve monaco asset loading to support cross origin asset URLs and r…
LukeTowers 8b3391a
Improve backwards compatibility for the codeeditor
LukeTowers b6cc244
Add setMarkers and setDecorations helper to the CodeEditor Snowboard …
LukeTowers 10c0d59
Compile assets
LukeTowers 3ebf35c
ONE FREAKING COMMA AND THE WORLD BLOWS UP
LukeTowers 29d89b9
Recompile assets
LukeTowers 4294755
Add docs for monaco powered codeeditor
LukeTowers 4f73c68
Move theme loading to directly in JS instead of over AJAX
LukeTowers f97b894
Update docs for the codeeditor
LukeTowers b1fa67e
Merge branch 'develop' into wip/monaco-editor
LukeTowers 293a9e6
Merge branch 'develop' into wip/monaco-editor
LukeTowers 9ca4018
Improve type hinting of CMS Index controller
LukeTowers 2709ec9
Fix incorrect codeeditor language being set for .txt & .js files in t…
LukeTowers ef51ab1
Remove console.log statements
LukeTowers cb90cf7
Remove broken updateFormEditorMode
LukeTowers 24e6c92
Coderabbit picky
LukeTowers a0dcd81
Add TODO for JS that might interact with ace
LukeTowers 40532d5
Add Monaco compatibility for the drag.value.js file
LukeTowers 88dc0ac
Improve CMS page handling of code sections
LukeTowers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,115 @@ | ||
| $(document).ready(function() { | ||
| ((Snowboard) => { | ||
| class Preferences extends Snowboard.Singleton { | ||
| construct() { | ||
| this.widget = null; | ||
| } | ||
|
|
||
| var editorEl = $('#editorpreferencesCodeeditor'), | ||
| editor = editorEl.codeEditor('getEditorObject'), | ||
| session = editor.getSession(), | ||
| renderer = editor.renderer | ||
| listens() { | ||
| return { | ||
| 'backend.widget.initialised': 'onWidgetInitialised', | ||
| }; | ||
| } | ||
|
|
||
| editorEl.height($('#editorSettingsForm').height() - 23) | ||
| onWidgetInitialised(element, widget) { | ||
| if (element === document.getElementById('editorpreferencesCodeeditor')) { | ||
| this.widget = widget; | ||
| this.enablePreferences(); | ||
| } | ||
| } | ||
|
|
||
| $('#Form-field-Preference-editor_theme').on('change', function() { | ||
| editorEl.codeEditor('setTheme', $(this).val()) | ||
| }) | ||
| enablePreferences() { | ||
| const checkboxes = { | ||
| show_gutter: 'showGutter', | ||
| highlight_active_line: 'highlightActiveLine', | ||
| use_hard_tabs: '!useSoftTabs', | ||
| display_indent_guides: 'displayIndentGuides', | ||
| show_invisibles: 'showInvisibles', | ||
| show_print_margin: 'showPrintMargin', | ||
| show_minimap: 'showMinimap', | ||
| }; | ||
|
|
||
| Object.entries(checkboxes).forEach(([key, value]) => { | ||
| document.getElementById(`Form-field-Preference-editor_${key}`).addEventListener('change', (event) => { | ||
| this.widget.setConfig( | ||
| value.replace(/^!/, ''), | ||
| /^!/.test(value) ? !event.target.checked : event.target.checked | ||
| ); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| $('#Form-field-Preference-editor_font_size').on('change', function() { | ||
| editor.setFontSize(parseInt($(this).val())) | ||
| }) | ||
| Snowboard.addPlugin('backend.preferences', Preferences); | ||
| })(window.Snowboard); | ||
|
|
||
| $('#Form-field-Preference-editor_word_wrap').on('change', function() { | ||
| editorEl.codeEditor('setWordWrap', $(this).val()) | ||
| }) | ||
| // $(document).ready(function() { | ||
|
|
||
| $('#Form-field-Preference-editor_code_folding').on('change', function() { | ||
| session.setFoldStyle($(this).val()) | ||
| }) | ||
| // var editorEl = $('#editorpreferencesCodeeditor'), | ||
| // editor = editorEl.codeEditor('getEditorObject'), | ||
| // session = editor.getSession(), | ||
| // renderer = editor.renderer | ||
|
|
||
| $('#Form-field-Preference-editor_autocompletion').on('change', function() { | ||
| editor.setOption('enableBasicAutocompletion', false) | ||
| editor.setOption('enableLiveAutocompletion', false) | ||
| // editorEl.height($('#editorSettingsForm').height() - 23) | ||
|
|
||
| var val = $(this).val() | ||
| if (val == 'basic') { | ||
| editor.setOption('enableBasicAutocompletion', true) | ||
| } | ||
| else if (val == 'live') { | ||
| editor.setOption('enableLiveAutocompletion', true) | ||
| } | ||
| }) | ||
| // $('#Form-field-Preference-editor_theme').on('change', function() { | ||
| // editorEl.codeEditor('setTheme', $(this).val()) | ||
| // }) | ||
|
|
||
| // $('#Form-field-Preference-editor_font_size').on('change', function() { | ||
| // editor.setFontSize(parseInt($(this).val())) | ||
| // }) | ||
|
|
||
| // $('#Form-field-Preference-editor_word_wrap').on('change', function() { | ||
| // editorEl.codeEditor('setWordWrap', $(this).val()) | ||
| // }) | ||
|
|
||
| // $('#Form-field-Preference-editor_code_folding').on('change', function() { | ||
| // session.setFoldStyle($(this).val()) | ||
| // }) | ||
|
|
||
| // $('#Form-field-Preference-editor_autocompletion').on('change', function() { | ||
| // editor.setOption('enableBasicAutocompletion', false) | ||
| // editor.setOption('enableLiveAutocompletion', false) | ||
|
|
||
| // var val = $(this).val() | ||
| // if (val == 'basic') { | ||
| // editor.setOption('enableBasicAutocompletion', true) | ||
| // } | ||
| // else if (val == 'live') { | ||
| // editor.setOption('enableLiveAutocompletion', true) | ||
| // } | ||
| // }) | ||
|
|
||
| // $('#Form-field-Preference-editor_tab_size').on('change', function() { | ||
| // session.setTabSize($(this).val()) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_tab_size').on('change', function() { | ||
| session.setTabSize($(this).val()) | ||
| }) | ||
| // $('#Form-field-Preference-editor_show_invisibles').on('change', function() { | ||
| // editor.setShowInvisibles($(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_show_invisibles').on('change', function() { | ||
| editor.setShowInvisibles($(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_enable_snippets').on('change', function() { | ||
| // editor.setOption('enableSnippets', $(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_enable_snippets').on('change', function() { | ||
| editor.setOption('enableSnippets', $(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_display_indent_guides').on('change', function() { | ||
| // editor.setDisplayIndentGuides($(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_display_indent_guides').on('change', function() { | ||
| editor.setDisplayIndentGuides($(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_show_print_margin').on('change', function() { | ||
| // editor.setShowPrintMargin($(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_show_print_margin').on('change', function() { | ||
| editor.setShowPrintMargin($(this).is(':checked')) | ||
| }) | ||
|
|
||
| $('#Form-field-Preference-editor_highlight_active_line').on('change', function() { | ||
| editor.setHighlightActiveLine($(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_highlight_active_line').on('change', function() { | ||
| // editor.setHighlightActiveLine($(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_use_hard_tabs').on('change', function() { | ||
| session.setUseSoftTabs(!$(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_use_hard_tabs').on('change', function() { | ||
| // session.setUseSoftTabs(!$(this).is(':checked')) | ||
| // }) | ||
|
|
||
| $('#Form-field-Preference-editor_show_gutter').on('change', function() { | ||
| renderer.setShowGutter($(this).is(':checked')) | ||
| }) | ||
| // $('#Form-field-Preference-editor_show_gutter').on('change', function() { | ||
| // renderer.setShowGutter($(this).is(':checked')) | ||
| // }) | ||
|
|
||
| }) | ||
| // }) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /** | ||
| * Backend widget handler. | ||
| * | ||
| * Handles the creation and disposal of widgets in the Backend. Widgets should include this as | ||
| * a dependency in order to be loaded and initialised after the handler, in order to correctly | ||
| * register. | ||
| * | ||
| * @copyright 2021 Winter. | ||
| * @author Ben Thomson <[email protected]> | ||
| */ | ||
| export default class WidgetHandler extends Snowboard.Singleton { | ||
| construct() { | ||
| this.registeredWidgets = []; | ||
| } | ||
|
|
||
| listens() { | ||
| return { | ||
| ready: 'onReady', | ||
| ajaxUpdate: 'onAjaxUpdate', | ||
| }; | ||
| } | ||
|
|
||
| register(control, widget, callback) { | ||
| this.registeredWidgets.push({ | ||
| control, | ||
| widget, | ||
| callback, | ||
| }); | ||
| } | ||
|
|
||
| unregister(control) { | ||
| this.registeredWidgets = this.registeredWidgets.filter((widget) => widget.control !== control); | ||
| } | ||
|
|
||
| onReady() { | ||
| this.initialiseWidgets(document.body); | ||
| } | ||
|
|
||
| onAjaxUpdate(element) { | ||
| this.initialiseWidgets(element); | ||
| } | ||
|
|
||
| initialiseWidgets(element) { | ||
bennothommo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this.registeredWidgets.forEach((widget) => { | ||
| const instances = element.querySelectorAll(`[data-control="${widget.control}"]`); | ||
|
|
||
| if (instances.length) { | ||
| instances.forEach((instance) => { | ||
| // Prevent double-widget initialisation | ||
| if (instance.dataset.widgetInitialised) { | ||
| return; | ||
| } | ||
|
|
||
| const widgetInstance = this.snowboard[widget.widget](instance); | ||
| instance.dataset.widget = widgetInstance; | ||
| instance.dataset.widgetInitialised = true; | ||
| this.snowboard.globalEvent('backend.widget.initialised', instance, widgetInstance); | ||
|
|
||
| instance.getWidget = function getWidget() { | ||
| return this.dataset.widget; | ||
| }; | ||
|
|
||
| if (typeof widget.callback === 'function') { | ||
| widget.callback(widgetInstance, instance); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 11 additions & 8 deletions
19
modules/backend/controllers/preferences/_field_editor_preview.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,25 @@ | ||
| <div | ||
| id="editorpreferencesCodeeditor" | ||
| class="field-codeeditor size-large layout-relative" | ||
| class="field-codeeditor size-large" | ||
| data-control="codeeditor" | ||
| data-font-size="<?= $model->editor_font_size ?>" | ||
| data-word-wrap="<?= $model->editor_word_wrap ?>" | ||
| data-code-folding="<?= $model->editor_code_folding ?>" | ||
| data-tab-size="<?= $model->editor_tab_size ?>" | ||
| data-theme="<?= $model->editor_theme ?>" | ||
| data-show-invisibles="<?= $model->editor_show_invisibles ?>" | ||
| data-highlight-active-line="<?= $model->editor_highlight_active_line ?>" | ||
| data-use-soft-tabs="<?= !$model->editor_use_hard_tabs ?>" | ||
| data-show-invisibles="<?= $model->editor_show_invisibles ? 'true' : 'false' ?>" | ||
| data-highlight-active-line="<?= $model->editor_highlight_active_line ? 'true' : 'false' ?>" | ||
| data-use-soft-tabs="<?= !$model->editor_use_hard_tabs ? 'true' : 'false' ?>" | ||
| data-autocompletion="<?= $model->editor_autocompletion ?>" | ||
| data-enable-snippets="<?= $model->editor_enable_snippets ?>" | ||
| data-display-indent-guides="<?= $model->editor_display_indent_guides ?>" | ||
| data-show-print-margin="<?= $model->editor_show_print_margin ?>" | ||
| data-display-indent-guides="<?= $model->editor_display_indent_guides ? 'true' : 'false' ?>" | ||
| data-show-print-margin="<?= $model->editor_show_print_margin ? 'true' : 'false' ?>" | ||
| data-show-gutter="<?= $model->editor_show_gutter ? 'true' : 'false' ?>" | ||
| data-show-minimap="<?= $model->editor_show_minimap ? 'true' : 'false' ?>" | ||
| data-language="css" | ||
| data-margin="0" | ||
| data-vendor-path="<?= Url::asset('/modules/backend/formwidgets/codeeditor/assets/vendor/ace') ?>/"> | ||
| <textarea name="editorpreferences_codeeditor"><?= e($this->makePartial('example_code')) ?></textarea> | ||
| data-vendor-path="<?= Url::asset('/modules/backend/formwidgets/codeeditor/assets/vendor/ace') ?>/" | ||
bennothommo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > | ||
| <div class="editor-container"></div> | ||
| <input type="hidden" name="editorpreferences_codeeditor" data-value-bag value="<?= e($this->makePartial('example_code')) ?>"> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 1 addition & 27 deletions
28
modules/backend/formwidgets/codeeditor/assets/css/codeeditor.css
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.