diff --git a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 index e74cbc77..1aae6351 100644 --- a/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 +++ b/assets/javascripts/wizard/components/wizard-composer-editor.js.es6 @@ -1,5 +1,5 @@ import ComposerEditor from "discourse/components/composer-editor"; -import { default as computed, on } from "discourse-common/utils/decorators"; +import { default as discourseComputed, on } from "discourse-common/utils/decorators"; import { findRawTemplate } from "discourse-common/lib/raw-templates"; import { throttle } from "@ember/runloop"; import { scheduleOnce, next } from "@ember/runloop"; @@ -14,9 +14,8 @@ import { validateUploadedFiles, getUploadMarkdown } from "discourse/lib/uploads"; -import { - cacheShortUploadUrl, -} from "pretty-text/upload-short-url"; +import { cacheShortUploadUrl } from "pretty-text/upload-short-url"; +import { alias } from "@ember/object/computed"; const uploadMarkdownResolvers = []; @@ -34,6 +33,7 @@ export default ComposerEditor.extend({ uploadIcon: "upload", popupMenuOptions: [], draftStatus: "null", + replyPlaceholder: alias("field.placeholder"), @on("didInsertElement") _composerEditorInit() { @@ -66,6 +66,13 @@ export default ComposerEditor.extend({ this._bindUploadTarget(); }, + @discourseComputed + allowedFileTypes() { + return this.siteSettings.authorized_extensions.split('|') + .map(ext => "." + ext) + .join(',') + }, + _setUploadPlaceholderSend() { if (!this.composer.get("reply")) { this.composer.set("reply", ""); @@ -157,7 +164,7 @@ export default ComposerEditor.extend({ this._setUploadPlaceholderSend(data); this.appEvents.trigger("wizard-editor:insert-text", { - fieldId: this.fieldId, + fieldId: this.field.id, text: this.uploadPlaceholder }); @@ -181,7 +188,7 @@ export default ComposerEditor.extend({ cacheShortUploadUrl(upload.short_url, upload); this.appEvents.trigger( "wizard-editor:replace-text", { - fieldId: this.fieldId, + fieldId: this.field.id, oldVal: this.uploadPlaceholder.trim(), newVal: markdown } @@ -208,7 +215,7 @@ export default ComposerEditor.extend({ if (removePlaceholder) { this.appEvents.trigger( "wizard-editor:replace-text", { - fieldId: this.fieldId, + fieldId: this.field.id, oldVal: this.uploadPlaceholder, newVal: "" } @@ -240,7 +247,7 @@ export default ComposerEditor.extend({ this.appEvents.trigger( "wizard-editor:replace-text", { - fieldId: this.fieldId, + fieldId: this.field.id, oldVal: matchingPlaceholder[index], newVal: replacement, options: { @@ -295,7 +302,7 @@ export default ComposerEditor.extend({ addLink(linkName, linkUrl) { let link = `[${linkName}](${linkUrl})`; this.appEvents.trigger("wizard-editor:insert-text", { - fieldId: this.fieldId, + fieldId: this.field.id, text: link }); this.set("showHyperlinkBox", false); diff --git a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs index 068e6a56..5e6cdb7f 100644 --- a/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs +++ b/assets/javascripts/wizard/templates/components/wizard-composer-editor.hbs @@ -12,7 +12,7 @@ loading=composer.loading showLink=showLink wizardComposerEvents=true - fieldId=fieldId + fieldId=field.id disabled=disableTextarea outletArgs=(hash composer=composer editorType="composer")}} @@ -20,6 +20,7 @@ class="wizard-composer-upload hidden-upload-field" disabled=isUploading type="file" + accept=allowedFileTypes multiple=true}} {{#if showHyperlinkBox}} diff --git a/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs b/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs index d2306616..db6f52cc 100644 --- a/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs +++ b/assets/javascripts/wizard/templates/components/wizard-field-composer.hbs @@ -1,6 +1,5 @@ {{wizard-composer-editor - replyPlaceholder=field.placeholder - fieldId=field.id + field=field composer=composer groupsMentioned=(action "groupsMentioned") cannotSeeMention=(action "cannotSeeMention")