I am currently writing my first Nextcloud App, which is based on csv files (in a dedicated Nextcloud file directory). Those csv files will be analysed by my app, but I also want to enable the user of my application to easily edit those csv files.
I don’t want to reinvent the wheel in my app and therefore would like to open such files using collabora/Nextcloud-office similar as it is done in the files app.
I do have the file-ids already and thought there should be an api method to open the corresponding file, but I failed to find any information how. I read quite a bit of the files source code, but couldn’t find a proper path to use it directly (through OC, OCA). Also I was not able to figure out how I could route the user to collabora.
First, you must be aware what collabora is: It is an external software that provides support to libreoffice (sort of) to be accessible by web requests. It is not part of NC but an unrelated project.
There is an app (richdocuments) that establishes a connection between NC and collabora. If you want to read stuff, you should start there. Also, you might want to read about WOPI.
I hope this gives you the first starting point to find what you need.
thanks for your answer. You are right, richdocuments is the app my files are opened with. But since file opening is handled centrally by nextcloud, only the registration of the fileactions can be found in richdocuments.
The call I wanted to reproduce is implemented in the files app, from where the files are actually opened. In the end I only had to add a few lines of code. Most importantly, I had to dispatch the OCA.Viewer in my PageController, such that it can be call from the frontend.
I added those two lines
...
use OCA\Viewer\Event\LoadViewer; #new
...
public function index(): TemplateResponse {
$this->eventDispatcher->dispatchTyped(new LoadViewer()); #new
...
Now I can call
OCA.Viewer.open("/randomDirOfUser/aFile.csv") //this was not accessible in the apps fronted/browser console before
in the frontend to open the editor and will stay on the page.
Maybe my explanation helps somebody else at some point.