mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: d-editor
wasn't properly debouncing updates
This commit is contained in:
parent
afe9f90f2b
commit
fa27f0a2ea
@ -1,6 +1,6 @@
|
|||||||
/*global Mousetrap:true */
|
/*global Mousetrap:true */
|
||||||
import loadScript from 'discourse/lib/load-script';
|
import loadScript from 'discourse/lib/load-script';
|
||||||
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
|
import { default as computed, on, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
import { showSelector } from "discourse/lib/emoji/emoji-toolbar";
|
import { showSelector } from "discourse/lib/emoji/emoji-toolbar";
|
||||||
|
|
||||||
// Our head can be a static string or a function that returns a string
|
// Our head can be a static string or a function that returns a string
|
||||||
@ -201,14 +201,12 @@ export default Ember.Component.extend({
|
|||||||
return toolbar;
|
return toolbar;
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed('ready', 'value')
|
_updatePreview() {
|
||||||
preview(ready, value) {
|
const value = this.get('value');
|
||||||
if (!ready) { return; }
|
|
||||||
|
|
||||||
const markdownOptions = this.get('markdownOptions') || {};
|
const markdownOptions = this.get('markdownOptions') || {};
|
||||||
markdownOptions.sanitize = true;
|
markdownOptions.sanitize = true;
|
||||||
|
|
||||||
const text = Discourse.Dialect.cook(value || "", markdownOptions);
|
this.set('preview', Discourse.Dialect.cook(value || "", markdownOptions));
|
||||||
Ember.run.scheduleOnce('afterRender', () => {
|
Ember.run.scheduleOnce('afterRender', () => {
|
||||||
if (this._state !== "inDOM") { return; }
|
if (this._state !== "inDOM") { return; }
|
||||||
const $preview = this.$('.d-editor-preview');
|
const $preview = this.$('.d-editor-preview');
|
||||||
@ -216,8 +214,12 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
this.sendAction('previewUpdated', $preview);
|
this.sendAction('previewUpdated', $preview);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
return text ? text : "";
|
@observes('ready', 'value')
|
||||||
|
_watchForChanges() {
|
||||||
|
if (!this.get('ready')) { return; }
|
||||||
|
Ember.run.debounce(this, this._updatePreview, 30);
|
||||||
},
|
},
|
||||||
|
|
||||||
_applyEmojiAutocomplete() {
|
_applyEmojiAutocomplete() {
|
||||||
|
Loading…
Reference in New Issue
Block a user