0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00

Add authorized_extensions support to wizard composer

Dieser Commit ist enthalten in:
Angus McLeod 2020-10-06 20:30:24 +11:00
Ursprung fc5279cd0a
Commit 96e85bb2b3
3 geänderte Dateien mit 19 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -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}}

Datei anzeigen

@ -1,6 +1,5 @@
{{wizard-composer-editor
replyPlaceholder=field.placeholder
fieldId=field.id
field=field
composer=composer
groupsMentioned=(action "groupsMentioned")
cannotSeeMention=(action "cannotSeeMention")