Skip to the content

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#

AttributeReactAngularWhat it is
server-urlserverUrldorvynServerUrlYour server's Dorvyn routes, for example /api/dorvyn (strict mode)
licenselicensedorvynLicenseA 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#

AttributeReactAngularWhat it is
autosave-keyautosaveKeydorvynAutosaveKeyKeep 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)#

AttributeReactAngularWhat it is
logologodorvynLogoAn image address for the File button and File screen, in the light theme
logo-darklogoDarkdorvynLogoDarkThe same, for the dark theme (default: logo)
themethemedorvynThemelight 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#

AttributeReactAngularWhat it is
documentdorvynDocumentThe 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):

OptionTypeWhat 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
draftsDraftStoreWhere drafts are kept. Default: the browser's IndexedDB
edition{ watermark?, maxFileBytes?, headerFooterLocked? }Restrictions for a demo of your own (A demo of your own)
fetchtypeof fetchThe 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 } | falseWhere the engine comes from (below). false: no engine, so nothing opens and nothing is editable (for code that needs only commands and state)
JavaScript
const element = document.querySelector("dorvyn-editor");
element.editorOptions = { onSave: (doc) => save(doc) };   // before it starts
element.setAttribute("server-url", "/api/dorvyn");         // now it starts

Serving 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):

  1. 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):

    Terminal
    curl -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.

  2. Tell the editor where it is:

    • in strict mode, on your server: dorvynRoutes({ engine: { url: "https://app.example.com/dorvyn/engine.wasm" } }) or DORVYN_ENGINE_URL, so the page needs no setting;
    • with a key in the page: the engine-url attribute (engineUrl, dorvynEngineUrl).

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#

AttributeReactAngularWhat it is
export-urlexportUrldorvynExportUrlYour 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.