Skip to content

Commit 90e4036

Browse files
committed
COMPATIBILITY: composer upload and text manipulation has been refactored again
1 parent 4e4a9c7 commit 90e4036

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

assets/javascripts/discourse/components/custom-wizard-composer-editor.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ export default class CustomWizardComposerEditor extends ComposerEditor {
2626

2727
init() {
2828
super.init(...arguments);
29-
this.fileUploadElementId = `file-uploader-${dasherize(this.field.id)}`;
30-
this.editorInputClass = `.${dasherize(this.field.type)}-${dasherize(
29+
this.uppyComposerUpload.fileUploadElementId = `file-uploader-${dasherize(
3130
this.field.id
32-
)} .d-editor-input`;
31+
)}`;
32+
this.uppyComposerUpload.editorInputClass = `.${dasherize(
33+
this.field.type
34+
)}-${dasherize(this.field.id)} .d-editor-input`;
35+
this.uppyComposerUpload.composerModel = this.composer;
3336
}
3437

3538
@discourseComputed
@@ -92,7 +95,9 @@ export default class CustomWizardComposerEditor extends ComposerEditor {
9295
@action
9396
showUploadModal() {
9497
this.session.set("wizardEventFieldId", this.field.id);
95-
document.getElementById(this.fileUploadElementId).click();
98+
document
99+
.getElementById(this.uppyComposerUpload.fileUploadElementId)
100+
.click();
96101
}
97102

98103
_uploadDropTargetOptions() {

assets/javascripts/discourse/components/custom-wizard-field-composer.js.es6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default Component.extend({
1212
"showPreview:show-preview:hide-preview",
1313
],
1414

15-
didInsertElement() {
15+
init() {
16+
this._super(...arguments);
1617
this.set(
1718
"composer",
1819
EmberObject.create({

assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ export default {
7575
this.session.wizardEventFieldId === this.fieldId &&
7676
this.element
7777
) {
78-
this.insertText(text, options);
78+
this.textManipulation.insertText(text, options);
7979
}
8080
},
8181

8282
_wizardReplaceText(oldVal, newVal, opts = {}) {
8383
if (this.session.wizardEventFieldId === this.fieldId) {
84-
this.replaceText(oldVal, newVal, opts);
84+
this.textManipulation.replaceText(oldVal, newVal, opts);
8585
}
8686
},
8787
});

assets/javascripts/discourse/templates/components/custom-wizard-composer-editor.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<input
2222
type="file"
23-
id={{this.fileUploadElementId}}
23+
id={{this.uppyComposerUpload.fileUploadElementId}}
2424
class="wizard-composer-upload"
2525
accept={{this.allowedFileTypes}}
2626
multiple

0 commit comments

Comments
 (0)