Static Assets and Offline Hosting
The browser editor runs from files that your application serves itself: the script tx-sheet-control.min.js and the fonts folder with the font catalog catalog.json and the font files. It needs no CDN and no service of Text Control. A plain HTML, JavaScript, TypeScript or Angular application deploys these files itself and tells the editor where to find them; ASP.NET Core and Blazor applications serve them from their package, as ASP.NET Core Applications and Blazor Applications describe.
The Files to Deploy
| File or folder | Required | Purpose |
|---|---|---|
tx-sheet-control.min.js | Yes | The editor. It also contains the styles, which it installs inside the editor's Shadow DOM, and the English and German interface texts. |
fonts/catalog.json | Yes | The font catalog: the families and faces the editor can use, with the URLs of their files. |
fonts/*.ttf | Yes | The font files the catalog lists. |
fonts/*.txt, licenses/, LICENSE.txt | Keep with the files | The font licenses and third-party notices, which Included Fonts and Notices lists. |
tx-sheet-control.css | No | A copy of the styles that the script installs itself. |
languages/*.json | No | The interface texts as JSON files, a starting point for resources of your own. The editor does not load them. |
The files come from the browser folder of the download, or from the dist folder of the editor npm package, node_modules/@txtextcontrol/tx-sheet-control/dist. Both contain the same editor and the same fonts.
Point the Editor at the Font Catalog
The editor loads the catalog from the URL of its fontCatalogURL option, and each font file from the URL that the catalog lists for it:
const editor = new TXTextControl.TXSheetControl.Spreadsheet(host, {
license: licenseText,
fontCatalogURL: '/assets/sheet/fonts/catalog.json'
});
await editor.ready;
- The default URL. Without
fontCatalogURL, the editor requests/sheet-fonts/catalog.json, the value of defaultFontCatalogURL. Setting only fontBaseURL does not change it. - Relative URLs. A relative
fontCatalogURLresolves against the page. The font URLs in the catalog, such as./LiberationSans-Regular.ttf, resolve against the catalog, so keep the font files in the folder ofcatalog.json. - Errors. When the catalog cannot be loaded,
editor.readyrejects with "Could not load font catalog: HTTP 404", or the status code the server returned.
Use a Bundler or Angular
A bundler such as Vite or webpack includes the editor in your script bundle, but it does not copy the font folder. Copy node_modules/@txtextcontrol/tx-sheet-control/dist/fonts into the static files of your application in the build, for example to public/assets/sheet/fonts, and set fontCatalogURL to the URL of its catalog.json. In Angular, add the folder to the assets of the build configuration; the Angular tutorial shows the options.
Serve the Files Over HTTP
Serve the page and the files over HTTP or HTTPS. The editor loads the catalog and the fonts with requests, and a page opened as a local file:// URL stops with the error "A font catalog requires an HTTP or HTTPS URL."
- Another origin. When the catalog or the fonts come from another origin than the page, such as a CDN of your own, that server must allow the page's origin with CORS headers.
- Content security policy. A content security policy must allow the editor's inline styles and
data:images, the request for the catalog and the fonts, as Host Security and File Handling shows.
Plan Base Paths and Caching
- Virtual applications. A URL with a leading slash, such as
/assets/sheet/fonts/catalog.json, points at the root of the website. When the application runs below a path such as/reports/, include that path infontCatalogURL, or use a relative URL. - Caching. The font URLs in the supplied catalog end in
?v=and the SHA-256 hash of the file, such asLiberationSans-Regular.ttf?v=…. The URL changes when the file changes, so the font files can be cached for a long time. Cachecatalog.jsonfor a short time, or give its URL a version of your own, so that browsers see new fonts. - Updates. Replace the script and the font folder together with those of the new release. Do not mix files of different releases.
Host Without a Network Connection
The editor requests only the script, the catalog and the font files from the URLs you configure; it makes no other requests and checks the license without a network connection. To run the editor without internet access, serve these files from your application. Data providers of your application that read data over the network still need their own connection.
Next Steps
- Font Handling: see how the catalog and the font files work together.
- Custom Fonts: add fonts of your own to the catalog.
- Deployment Problems: fix catalog and font errors after the deployment.