In combination with DS Server, you can create a desktop application to edit documents using the HTML5-based document editor with local file access.
The following sample shows how to integrate DS Server into an Electron desktop application.
Create your free DS Server trial token here:
Creating the Project
Create a folder for your project and install Electron there:
mkdir my-electron-app && cd my-electron-app
npm init -y
npm i --save-dev electron
Create the Main Script File
Open the project folder in VS Code or your favorite editor:
In the root of your application, create a file named main.js and add the following content:
The main script defines the entry point of your Electron application that runs the Main process. In this sample, it also contains the application menu definitions. A File menu is added to load a local document into TX Text Control.
In the root of your application, create a file named index.html and add the following content:
In line 32 and 33, add your private DS Server OAuth credentials.
Open the package.json file and replace is with the following content:
Adding Text Control Script Files
Create a folder in the root of your project named textcontrol.
In that new folder, create a file named fileHandler.js and add the following content:
In that new folder, create a file named txtextcontrol-ds-1.0.0.js. Using a browser, navigate to the following URL and copy the content into the newly created file:
Starting the Application
In the command line console, start the application by typing the following command:
A new native application is started with the TX Text Control (DS Server) document editor. Using the application menu File -> Load, you can open local documents (DOC, DOCX, RTF, HTML and TX):
The application is also displayed in the native Windows task bar:
Package the Application
The application can be packaged and deployed using Electron Forge. It creates an executable application and a setup the fetches used packages during the installation.
Use the following commands to install Electron Forge in your app folder:
npm install --save-dev @electron-forge/cli
npx electron-forge import
Use the following command to create the distributable:
npm run make
You can test this on your own by downloading the sample application from our GitHub account.