I need something about macro plug-ins

Big guys,my current macro plug-in objects are like this.TIM%E5%9B%BE%E7%89%8720181220145431 They are all input boxes on the plug-in properties panel to input parameters, but I want to add an object that can be selected as a file, select the local TXT file, and then read the contents of the txt file to display on the panel. What should I do?

You should first think about how the macro will be called from wiki syntax, because whatever pickers you may use to select the macro parameter values, those values will be saved as wiki syntax in the end. If what you had in mind is:

{{myMacro path="client/path/to/file.txt" /}}

then it can’t work because the macro is rendered on the server and so the path needs to be on the server also. The server (where XWiki runs) can’t access the files from client machine (when the Web browser runs). Thus you need to upload the file on the server if you want to read its content. Best is to attach the file to a wiki page and then use:

{{myMacro attachment="Some.Page@file.txt" /}}

That is: use an attachment reference to specify the file. With this, you should be able to hook an attachment picker for this parameter in order to make the selection of the attachment easier for simple users. But you still need to upload the file first.

Hello, first of all, thank you for your reply. I see what you mean. However, I still don’t know how the attachment selector attached to XWiki should render it as an object. As you said, how to hook an attachment selector for this parameter? Do you have any relevant documents? If so, please let me know. Thank you.

In the latest version of XWiki you can associate a Java type to a macro parameter (from the object editor) and then you can associate a “displayer” for this Java type (a Velocity template that is executed when we need to edit the macro parameter). Check for instance the default displayers https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwiki-platform-web/src/main/webapp/templates/html_displayer . This needs CKEditor Integration v1.30 though, that will be released soon.