1
0
Fork 0

Move to new Uppy handling in discourse/discourse

Dieser Commit ist enthalten in:
Angus McLeod 2023-03-15 10:26:46 +01:00
Ursprung 0e70a5a221
Commit 6a4063951e

Datei anzeigen

@ -29,6 +29,7 @@ export default ComposerEditor.extend({
draftStatus: "null", draftStatus: "null",
replyPlaceholder: alias("field.translatedPlaceholder"), replyPlaceholder: alias("field.translatedPlaceholder"),
wizardEventFieldId: null, wizardEventFieldId: null,
composerEventPrefix: "wizard-editor",
@on("didInsertElement") @on("didInsertElement")
_composerEditorInit() { _composerEditorInit() {
@ -77,24 +78,11 @@ export default ComposerEditor.extend({
$input.on("scroll", this._throttledSyncEditorAndPreviewScroll); $input.on("scroll", this._throttledSyncEditorAndPreviewScroll);
this._bindUploadTarget(); this._bindUploadTarget();
const wizardEventNames = ["insert-text", "replace-text"]; const field = this.field;
const eventPrefix = this.eventPrefix; this.editorInputClass = `.${dasherize(field.type)}-${dasherize(field.id)} .d-editor-input`;
this.appEvents.reopen({
trigger(name, ...args) {
let eventParts = name.split(":");
let currentEventPrefix = eventParts[0];
let currentEventName = eventParts[1];
if ( this._uppyInstance.on('file-added', (file) => {
currentEventPrefix !== "wizard-editor" && this.session.set("wizardEventFieldId", field.id);
wizardEventNames.some((wen) => wen === currentEventName)
) {
let wizardEventName = name.replace(eventPrefix, "wizard-editor");
return this._super(wizardEventName, ...args);
} else {
return this._super(name, ...args);
}
},
}); });
}, },