@fiduswriter/dav
v0.2.8
Published
DAV/WebDAV file store and editor adapter for embedding the Fidus Writer editor in Nextcloud, opencloud and other WebDAV-based hosts
Maintainers
Readme
@fiduswriter/dav — DAV/WebDAV adapter for the Fidus Writer editor
This repository is the storage adapter that lets the Fidus Writer editor
run against documents stored as .fidus files on a DAV/WebDAV server —
Nextcloud, opencloud, ownCloud or any generic WebDAV host. It is published on
npm as @fiduswriter/dav and is the piece that the
fiduswriter-nextcloud
app builds on. It deliberately contains no editor code itself and no Fidus
Writer server backend: it only turns "a .fidus file somewhere on a DAV
server" into a running editor and back.
Fidus Writer is an online collaborative editor especially made for academics who need to use citations and/or formulas. The editor focuses on the content rather than the layout, so that with the same text, you can later on publish it in multiple ways: on a website, as a printed book, or as an ebook.
What this package does
- Loads a
.fidusfile from a DAV server: Fetches the container, validates its MIME type and schema version, migrates older document versions and hands the editor everything it needs — document content, bibliography, and images as ready-to-display data URLs — through the@fiduswriter/editorstatic bootstrapping API. - Saves the editor state back to a
.fidusfile: Re-serializes the document, comments, bibliography and images into a byte-exact.fiduscontainer (including any embedded document template) andPUTs it to the server with anIf-Matchetag, so concurrent edits are detected rather than silently overwritten. - Handles conflicts: When the server rejects a save because the file
changed elsewhere, it returns a 409 so the editor's built-in merge kicks in
— the third-party changes are reconstructed from the last confirmed state
(server-provided covering steps when available, otherwise with
recreateTransform) and the local changes are rebased on top, then the save is retried. A cheap etag probe lets each editor periodically pick up changes made by others even without local edits. The check/save cadence is adaptive — frequent while editing, slower while idle or blurred, paused while the tab is hidden or offline, with an immediate check on return — and can be tuned per host through thesavePollingmount option. - Supports concurrent editors: The default concurrency model is
optimistic (
If-Matchetags plus the merge above), so several users may edit the same.fidusfile at the same time. An exclusive session lock (Nextcloud Files lock / WebDAVLOCK) is available through thelockFile: truemount option for hosts that explicitly want single-editor enforcement — it blocks the other sessions' saves, so it is off by default. - Switches storage backends behind one interface: A
NextcloudStore(Nextcloud WebDAV + thefiles_lockOCS API) and aWebdavStore(generic WebDAV withIf-Match/LOCK) both implement the same smallDavFileStoreinterface, which makes porting to other DAV systems a matter of adding another implementation. - Boots the whole editor for you:
mountFidusEditoris a single high-level entry point that takes a store and a file id, loads the document, starts the editor in direct-save mode with autosave and the 409 merge wired up, and reports save status to the host page.
Quick start (development)
Development uses pnpm and installs the published @fiduswriter/editor,
@fiduswriter/document, @fiduswriter/image-manager and fwtoolkit
packages from the npm registry:
pnpm install
pnpm run build
pnpm testWhen testing unpublished changes from a sibling checkout, link it temporarily
with pnpm link ../fiduswriter-editor-ts and restore the registry-only
lockfile before committing.
The test suite covers .fidus round-trips (content, bibliography, images and
embedded templates), the conflict path and the store implementations.
License
All of Fidus Writer's original code is licensed under the GNU AFFERO GENERAL PUBLIC LICENSE, for details see LICENSE. Some third party libraries are licensed under other, compatible open source libraries. Licensing information is included in those files.
