Frameworks
Angular
@dorvyn/angular gives the editor's elements Angular inputs, and the editor and its state as signals. It works with Angular 20, 21 and 22, in standalone components or NgModules.
Install#
npm install @dorvyn/angularThe full editor#
import { CUSTOM_ELEMENTS_SCHEMA, Component } from "@angular/core";
import { DORVYN_DIRECTIVES } from "@dorvyn/angular";
@Component({
selector: "app-editor",
imports: [...DORVYN_DIRECTIVES],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<dorvyn-editor dorvynServerUrl="/api/dorvyn" dorvynAutosaveKey="my-doc" style="display: block; height: 100vh"></dorvyn-editor>
`,
})
export class EditorComponent {}CUSTOM_ELEMENTS_SCHEMA lets Angular accept the dorvyn-* tags. dorvynServerUrl is your server's Dorvyn routes (strict mode). Angular apps usually talk to an API server of their own. Add the route there (Express, NestJS, Fastify: see Strict mode), and if it's on another address, proxy it (proxy.conf.json in development) so the editor calls it on your app's own origin.
For development with a publishable key: [dorvynLicense]="key".
Your own layout#
<dorvyn-editor dorvynServerUrl="/api/dorvyn" #ed="dorvynEditor">
<button dorvynCommand="bold" #b="dorvynCommand" [class.on]="b.active()" [disabled]="!b.enabled()">B</button>
<span>{{ ed.state()?.words ?? 0 }} words</span>
<dorvyn-ribbon tabs="home,insert"></dorvyn-ribbon>
<div style="display: flex; height: 600px">
<dorvyn-document style="display: flex; flex: 1"></dorvyn-document>
<dorvyn-panes style="width: 280px"></dorvyn-panes>
</div>
<dorvyn-dialogs></dorvyn-dialogs>
<dorvyn-context-menu></dorvyn-context-menu>
</dorvyn-editor>Inputs#
| Input | What it does |
|---|---|
dorvynServerUrl | Your server's Dorvyn routes (strict mode) |
dorvynLicense | A publishable key. Empty waits, so the key can come later |
dorvynAutosaveKey | Keep drafts in the browser under this name |
dorvynLogo, dorvynLogoDark | Your logo on the full editor's File button and screen |
dorvynTheme | 'light' or 'dark', until the person picks one |
dorvynAnimations | false: no animations until the person turns them on |
dorvynDocument | A <dorvyn-document> outside the element, or its id |
dorvynApi, dorvynExportUrl, dorvynEngineUrl | Only for a self-hosted export service or engine (Options) |
dorvynOptions | Anything else: onSave, drafts, edition, fetch (Options) |
They're read when the editor starts. To start it again with other settings, remove the element and add it back (for example with @if).
The editor and its state#
#ed="dorvynEditor" gives the template the directive:
ed.editor(): the editor (a signal;nulluntil it's ready).ed.state(): its whole state (a signal).ed.select(pick, fallback): a signal of one part of the state, updated only when that part changes. Use it in components for anything you show often.
import { Component, computed, viewChild } from "@angular/core";
import { DorvynEditorDirective } from "@dorvyn/angular";
export class EditorComponent {
readonly ed = viewChild.required(DorvynEditorDirective);
readonly words = computed(() => this.ed().state()?.words ?? 0);
async insertClause() {
await this.ed().editor()?.commands.run("symbol", "§");
}
}dorvynCommand on any button runs the command on click and keeps the cursor in the document. #b="dorvynCommand" gives you b.active() and b.enabled().
Events#
The editor's events are DOM events on the element:
<dorvyn-editor
dorvynServerUrl="/api/dorvyn"
(dorvyn-change)="queueSave($any($event).detail.document)"
(dorvyn-notice)="toast($any($event).detail.message)"
(dorvyn-error)="report($any($event).detail)"
(dorvyn-open)="onOpen($any($event).detail)"
></dorvyn-editor>All of them are in Events and license states.
Saving to your own store#
options = {
onSave: async (doc: EditorDocument) => {
await firstValueFrom(this.http.put(`/api/documents/${this.id}`, doc));
},
};<dorvyn-editor dorvynServerUrl="/api/dorvyn" [dorvynOptions]="options"></dorvyn-editor>More in Opening and saving documents.
Server-side rendering#
With Angular SSR the element renders empty at its size and starts in the browser. There's nothing to configure.