So I need to create an Onlyoffice DocSpace plugin (and I use ONLYOFFICE to do this operation):
When I select a File into a Room of Docspace I need to see into right pannel of DocSpace (“Informations of File”) a table with fields related to that File (the File has an OlyOffice DocSpace ID, in the below example: fileID is 1527575. The fields al already stored in a Database MySQL and exposed with an API: https://tenca.it/API/apidocspace.php?fileId=1527575 fileId is the ID of that File into Onlyoffice DocSpace Room.
Look at the attached clip or on the youtube link below => The error is happening like this:
I also attached my part from index.ts
class SimplePlugin implements IPlugin, IApiPlugin, IInfoPanelPlugin, IEventListenerPlugin, IFilePlugin {
status: PluginStatus = PluginStatus.active;
origin = "";
proxy = "";
prefix = "";
infoPanelItems = new Map<string, IInfoPanelItem>();
constructor() {
const key = "info_plugin-File Info";
const infoPanelItem: IInfoPanelItem = {
key,
subMenu: {
name: "File Info",
onClick: async (fileId: number) => {
console.log("✅ onClick called with fileId:", fileId);
try {
const fields = [
["Corsista", 'Test'],
["Cod Fiscal (CF)", 'test'],
["Corso",'test'],
["Data Corso", 'test'],
["Data Scadenza", 'test'],
["ID File", 'test'],
["ID OnlyOffice", 'test'],
];
console.log(fields)
const children: Component[] = fields.map(([label, value]) => ({
component: Components.text,
props: {
text: `📌 Test Test`,
fontSize: "13px",
lineHeight: "20px",
noSelect: true,
} as IText,
}));
this.updateInfoPanelItem({
...infoPanelItem,
body: {
paddingProp: "20px",
displayProp: "flex",
flexDirection: "column",
children,
},
});
return {
message: `Data for #${fileId}`,
type: "info",
} as IMessage;
} catch (e) {
console.log(e)
return {
message: "❌ Error.",
type: "error",
} as IMessage;
}
},
},
body: {
paddingProp: "20px",
displayProp: "flex",
flexDirection: "column",
children: [
{
component: Components.text,
props: {
text: "🔄 Select a file to view the Mysql Data...",
fontSize: "13px",
},
},
],
},
onLoad: async () => ({
body: {
paddingProp: "20px",
displayProp: "flex",
flexDirection: "column",
children: [
{
component: Components.text,
props: {
text: "🔄 Waiting for files...",
fontSize: "13px",
},
},
],
},
}),
filesType: [FilesType.file],
};
this.addInfoPanelItem(infoPanelItem);
}
onLoadCallback = async () => {
console.log("✅ Plugin loaded");
};
// === Required methods ===
addInfoPanelItem = (item: IInfoPanelItem) => this.infoPanelItems.set(item.key, item);
updateInfoPanelItem = (item: IInfoPanelItem) => this.infoPanelItems.set(item.key, item);
getInfoPanelItems = () => this.infoPanelItems;
type or paste code here