0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-14 05:52:52 +01:00
discourse-custom-wizard/assets/javascripts/wizard/components/wizard-composer-editor.js.es6
2020-02-05 17:58:35 +11:00

69 Zeilen
Kein EOL
2 KiB
JavaScript

import ComposerEditor from 'discourse/components/composer-editor';
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
import { findRawTemplate } from "discourse/lib/raw-templates";
import { throttle } from "@ember/runloop";
import { scheduleOnce } from "@ember/runloop";
import { safariHacksDisabled } from "discourse/lib/utilities";
export default ComposerEditor.extend({
classNameBindings: ['fieldClass'],
allowUpload: false,
showLink: false,
topic: null,
showToolbar: true,
focusTarget: "reply",
canWhisper: false,
lastValidatedAt: 'lastValidatedAt',
uploadIcon: "upload",
popupMenuOptions: [],
draftStatus: 'null',
@on("didInsertElement")
_composerEditorInit() {
const $input = $(this.element.querySelector(".d-editor-input"));
const $preview = $(this.element.querySelector(".d-editor-preview-wrapper"));
if (this.siteSettings.enable_mentions) {
$input.autocomplete({
template: findRawTemplate("user-selector-autocomplete"),
dataSource: term => this.userSearchTerm.call(this, term),
key: "@",
transformComplete: v => v.username || v.name,
afterComplete() {
// ensures textarea scroll position is correct
scheduleOnce("afterRender", () => $input.blur().focus());
}
});
}
if (this._enableAdvancedEditorPreviewSync()) {
this._initInputPreviewSync($input, $preview);
} else {
$input.on("scroll", () =>
throttle(this, this._syncEditorAndPreviewScroll, $input, $preview, 20)
);
}
this._bindUploadTarget();
},
_bindUploadTarget() {
},
_unbindUploadTarget() {
},
actions: {
extraButtons(toolbar) {
if (this.allowUpload && this.uploadIcon && !this.site.mobileView) {
toolbar.addButton({
id: "upload",
group: "insertions",
icon: this.uploadIcon,
title: "upload",
sendAction: this.showUploadModal
});
}
}
}
})