The editor
Options and attributes
Every setting the editor takes: as an attribute on <dorvyn-editor>, a React or Next.js prop, an Angular input, and in editorOptions (options, dorvynOptions) for what attributes can't carry.
Settings are read when the editor starts. The editor starts as soon as it has a license or a server-url, so set everything else first, or with it.
Licensing#
| Attribute | React | Angular | What it is |
|---|---|---|---|
server-url | serverUrl | dorvynServerUrl | Your server's Dorvyn routes, for example /api/dorvyn (strict mode) |
license | license | dorvynLicense | A publishable key (dvn_pk_live_…, dvn_pk_test_…). Empty waits for one. Also the element's license property, which isn't written into the page's HTML |
Use one or the other. With both, the key is used.
Drafts#
| Attribute | React | Angular | What it is |
|---|---|---|---|
autosave-key | autosaveKey | dorvynAutosaveKey | Keep a draft in the browser under this name, and open it again on the next visit. Use one per document (doc-42). Empty or absent: no drafts |
Drafts are kept in the person's own browser (IndexedDB, or localStorage where IndexedDB isn't available), compressed, and never sent anywhere. See Opening and saving documents.
Appearance (the full editor)#
| Attribute | React | Angular | What it is |
|---|---|---|---|
logo | logo | dorvynLogo | An image address for the File button and File screen, in the light theme |
logo-dark | logoDark | dorvynLogoDark | The same, for the dark theme (default: logo) |
theme | theme | dorvynTheme | light or dark, until the person chooses one. Default: their system's |
animations="off" | animations={false} | [dorvynAnimations]="false" | No animations on the File screen and theme changes, until the person turns them on in Options |
More in Theming and branding.
Layout#
| Attribute | React | Angular | What it is |
|---|---|---|---|
document | dorvynDocument | The id of a <dorvyn-document> elsewhere on the page (Angular: the element or its id) |
Options in code#
These go in editorOptions (HTML), options (React, Next.js) or dorvynOptions (Angular):
| Option | Type | What it is |
|---|---|---|
onSave | (document: EditorDocument) => void | Promise<void> | Save and Ctrl+S give you the document instead of downloading a .docx. Throw (or reject) to tell the person saving failed. React and Next.js also have it as a prop |
drafts | DraftStore | Where drafts are kept. Default: the browser's IndexedDB |
edition | { watermark?, maxFileBytes?, headerFooterLocked? } | Restrictions for a demo of your own (A demo of your own) |
fetch | typeof fetch | The editor's requests go through it: add an auth header for your route, or credentials: "include" (Strict mode) |
getGrant | (request) => Promise<{ grant, exp }> | Get grants your own way instead of server-url: call your server, return what requestGrant gave it, unchanged. Renewals call it again |
engine | { url?: string } | false | Where the engine comes from (below). false: no engine, so nothing opens and nothing is editable (for code that needs only commands and state) |
const element = document.querySelector("dorvyn-editor");
element.editorOptions = { onSave: (doc) => save(doc) }; // before it starts
element.setAttribute("server-url", "/api/dorvyn"); // now it startsServing the engine yourself#
By default the engine (a WebAssembly file) comes from Dorvyn's CDN, and the SDK checks that it's exactly the engine built for this version of the SDK before starting it. To serve it from your own site instead (for an offline network, or a strict CSP):
Download the engine for the SDK version you installed, and put it on your site unchanged. Its address on the CDN is
engineUrl()from@dorvyn/core(installed with the SDK):Terminalcurl -o public/dorvyn/engine.wasm "$(node --input-type=module -e "import { engineUrl } from '@dorvyn/core'; console.log(engineUrl())")"Do it in your build, so every SDK update brings its own engine. Serve it with
content-type: application/wasm.Tell the editor where it is:
- in strict mode, on your server:
dorvynRoutes({ engine: { url: "https://app.example.com/dorvyn/engine.wasm" } })orDORVYN_ENGINE_URL, so the page needs no setting; - with a key in the page: the
engine-urlattribute (engineUrl,dorvynEngineUrl).
- in strict mode, on your server:
The SDK checks the file the same way wherever it's served from. A file that doesn't match its SDK version is refused, and state.engine becomes "failed".
Self-hosted export#
| Attribute | React | Angular | What it is |
|---|---|---|---|
export-url | exportUrl | dorvynExportUrl | Your own export service's address, with a key in the page. In strict mode, set DORVYN_EXPORT_URL on your server instead |
See Self-hosted export.