mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 09:57:25 +08:00
FEATURE: Use ACE for badge queries (#5269)
* FEATURE: Use ACE for badge queries * Forgot disabled * When disabled, cursor should be `not-allowed` * Tests + prefix custom attribute with `data-`
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
import loadScript from 'discourse/lib/load-script';
|
||||
import { observes } from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const LOAD_ASYNC = !Ember.Test;
|
||||
const LOAD_ASYNC = !Ember.testing;
|
||||
|
||||
export default Ember.Component.extend({
|
||||
mode: 'css',
|
||||
classNames: ['ace-wrapper'],
|
||||
_editor: null,
|
||||
_skipContentChangeEvent: null,
|
||||
disabled: false,
|
||||
|
||||
@observes('editorId')
|
||||
editorIdChanged() {
|
||||
@ -30,6 +31,24 @@ export default Ember.Component.extend({
|
||||
}
|
||||
},
|
||||
|
||||
@observes('disabled')
|
||||
disabledStateChanged() {
|
||||
this.changeDisabledState();
|
||||
},
|
||||
|
||||
changeDisabledState() {
|
||||
const editor = this._editor;
|
||||
if (editor) {
|
||||
const disabled = this.get('disabled');
|
||||
editor.setOptions({
|
||||
readOnly: disabled,
|
||||
highlightActiveLine: !disabled,
|
||||
highlightGutterLine: !disabled
|
||||
});
|
||||
editor.container.parentNode.setAttribute("data-disabled", disabled);
|
||||
}
|
||||
},
|
||||
|
||||
_destroyEditor: function() {
|
||||
if (this._editor) {
|
||||
this._editor.destroy();
|
||||
@ -76,6 +95,7 @@ export default Ember.Component.extend({
|
||||
|
||||
this.$().data('editor', editor);
|
||||
this._editor = editor;
|
||||
this.changeDisabledState();
|
||||
|
||||
$(window).off('ace:resize').on('ace:resize', ()=>{
|
||||
this.appEvents.trigger('ace:resize');
|
||||
|
Reference in New Issue
Block a user