איפה הקוד שמכניס את תיאור הקובץ שהועלה לעורך?

סיכום מבוסס בינה מלאכותית

Understanding Upload Event Code in Discourse

JQ331 is trying to understand how Discourse inserts the file reference text into the composer editor’s textarea when a file is uploaded. The text typically reads: [File Name|attachment](upload://file_id) (size).

After reviewing composer-editor.js and uploads.js, JQ331 is still unsure where the code that registers the upload event and inserts this text is located. pfaffman asked for more context on what JQ331 wants to achieve, and JQ331 clarified that the goal is to understand the underlying code, with a potential use case of changing the default text.

Hi All. I am experimenting with the text that is displayed in the composer editor’s textarea when a file is uploaded. And I’m trying to figure out how the code works. When a user hits upload, and uploads a file (‘Cool-File.txt’), where is the code that puts the reference into the d-editor textarea?

For example, the text in the textarea that would read:
[Cool-File.txt|attachment](upload://8htnahUHYHnB11M.txt) (21.1 KB)

Where is the code that registers the upload event and inserts this text?


I’ve taken a look through the composer-editor.js methods like “getUploadMarkdown(upload)”, and the related methods like “attachmentMarkdown(upload)” in uploads.js. But changing these doesn’t seem to change anything.

Can you say more about what you want to do? I don’t know whether you might do it in a theme component or if you’d need a plugin.

The goal is just to understand where in the discourse code the code is that puts that text into the text area.

If it’s helpful to have a specific use case, how about: how would you change that text to something else?

If it makes a difference whether I’m doing a plug-in or theme component, I’m fine doing either.