DEV: Move composer-editor upload functions into mixin (PR #13923)

This PR moves all the upload related functions into a new ComposerUpload mixin that is extended by the composer-editor component. This is being done so I can introduce a ComposerUploadUppy mixin that overrides functions in the regular ComposerUpload mixin, via a new composer-editor-uppy component that inherits from ComposerEditor. The proposed structure, which will be in the next PR, looks like this:

composer-editor-uppy

import ComposerEditor from "discourse/components/composer-editor"
import ComposerUploadUppy from "discourse/mixins/composer-upload-uppy"

export default ComposerEditor.extend(ComposerUploadUppy, {
  layoutName: "components/composer-editor"
});

This way the new composer-editor is a dumb component purely used for testing uppy safely, and within the template for composer.hbs we do this:

{{#if useExperimentalComposerUploader}}
  {{composer-editor-uppy ...}}
{{else}}
  {{composer-editor ...}}
{{/if}}

This is the only way I can think to do it, because it is not possible to access the site settings when the component is first declared I can’t do something like:

const uploaderMixin = this.siteSettings.use_experimental_uploader?
ComposerUploaderUppy : ComposerUploader;

Component.extend(uploaderMixin, {});

An additional change in this PR is explicitly passing in these four plugin data structures to the composer-editor Component, rather than relying on JS closures which the mixin cannot do:

  • uploadMarkdownResolvers
  • uploadProcessorActions
  • uploadProcessorQueue
  • uploadHandlers

GitHub

I checked to see if this would impact any plugins or themes and I couldn’t see anything that would be affected. Even with reopen, this change shouldn’t break anything because all the functions moved to the mixin are still technically part of the ComposerEditor class.