| null>(null);
+async function oneNoteDone(id: string) {
+ await spaces.loadTree(props.id);
+ router.push({ name: "page", params: { id } });
+}
+
// The whole space as a zip: one file per page, folders for subpages.
const exporting = ref(false);
async function exportSpace(format: "markdown" | "html") {
@@ -184,12 +192,30 @@ async function newPage() {
>
{{ $t(importing ? "space.importing" : "space.import") }}
+
+ {{ $t("onenote.button") }}
+
{{ $t("app.newPage") }}
+
-chrome.zip Chrome Web Store, Edge Add-ons
+// docwell-web-clipper--firefox.zip addons.mozilla.org
+// docwell-web-clipper--source.zip the source AMO asks for, since dist/ is built
+//
+// Run `npm run package -w @docwell/web-clipper` (it builds first). Uses only
+// Node's own modules: the zips are written by hand with zlib's deflate.
+
+import { deflateRawSync } from "node:zlib";
+import { mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
+import { dirname, join, relative, resolve, sep } from "node:path";
+import { fileURLToPath } from "node:url";
+
+const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
+const dist = join(root, "dist");
+const out = join(root, "release");
+
+const crcTable = new Uint32Array(256).map((_, n) => {
+ let c = n;
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
+ return c >>> 0;
+});
+function crc32(buf) {
+ let c = 0xffffffff;
+ for (const b of buf) c = crcTable[(c ^ b) & 0xff] ^ (c >>> 8);
+ return (c ^ 0xffffffff) >>> 0;
+}
+
+// A fixed time, so the same files make the same zip.
+const DOS_TIME = 0;
+const DOS_DATE = ((2024 - 1980) << 9) | (1 << 5) | 1;
+
+/** Writes files ({name, data}) as a zip. */
+function zip(path, files) {
+ const parts = [];
+ const central = [];
+ let offset = 0;
+ for (const { name, data } of files) {
+ const nameBuf = Buffer.from(name, "utf8");
+ const packed = deflateRawSync(data, { level: 9 });
+ const stored = packed.length >= data.length;
+ const body = stored ? data : packed;
+ const crc = crc32(data);
+ const local = Buffer.alloc(30);
+ local.writeUInt32LE(0x04034b50, 0);
+ local.writeUInt16LE(20, 4);
+ local.writeUInt16LE(0x0800, 6); // UTF-8 names
+ local.writeUInt16LE(stored ? 0 : 8, 8);
+ local.writeUInt16LE(DOS_TIME, 10);
+ local.writeUInt16LE(DOS_DATE, 12);
+ local.writeUInt32LE(crc, 14);
+ local.writeUInt32LE(body.length, 18);
+ local.writeUInt32LE(data.length, 22);
+ local.writeUInt16LE(nameBuf.length, 26);
+ local.writeUInt16LE(0, 28);
+ parts.push(local, nameBuf, body);
+ const entry = Buffer.alloc(46);
+ entry.writeUInt32LE(0x02014b50, 0);
+ entry.writeUInt16LE(20, 4);
+ entry.writeUInt16LE(20, 6);
+ entry.writeUInt16LE(0x0800, 8);
+ entry.writeUInt16LE(stored ? 0 : 8, 10);
+ entry.writeUInt16LE(DOS_TIME, 12);
+ entry.writeUInt16LE(DOS_DATE, 14);
+ entry.writeUInt32LE(crc, 16);
+ entry.writeUInt32LE(body.length, 20);
+ entry.writeUInt32LE(data.length, 24);
+ entry.writeUInt16LE(nameBuf.length, 28);
+ entry.writeUInt32LE(offset, 42);
+ central.push(entry, nameBuf);
+ offset += local.length + nameBuf.length + body.length;
+ }
+ const centralBuf = Buffer.concat(central);
+ const end = Buffer.alloc(22);
+ end.writeUInt32LE(0x06054b50, 0);
+ end.writeUInt16LE(files.length, 8);
+ end.writeUInt16LE(files.length, 10);
+ end.writeUInt32LE(centralBuf.length, 12);
+ end.writeUInt32LE(offset, 16);
+ writeFileSync(path, Buffer.concat([...parts, centralBuf, end]));
+ console.log(`${relative(root, path)} (${files.length} files)`);
+}
+
+/** Every file under dir, as zip names relative to base. */
+function walk(dir, base, skip = () => false) {
+ const files = [];
+ for (const entry of readdirSync(dir).sort()) {
+ const full = join(dir, entry);
+ const name = relative(base, full).split(sep).join("/");
+ if (skip(name)) continue;
+ if (statSync(full).isDirectory()) files.push(...walk(full, base, skip));
+ else files.push({ name, data: readFileSync(full) });
+ }
+ return files;
+}
+
+const manifest = JSON.parse(readFileSync(join(dist, "manifest.json"), "utf8"));
+const version = manifest.version;
+mkdirSync(out, { recursive: true });
+const built = walk(dist, dist).filter((f) => f.name !== "manifest.json");
+const withManifest = (m) => [{ name: "manifest.json", data: Buffer.from(JSON.stringify(m, null, 2) + "\n") }, ...built];
+
+// Chrome and Edge do not know Firefox's settings and warn about them.
+const chrome = { ...manifest };
+delete chrome.browser_specific_settings;
+zip(join(out, `docwell-web-clipper-${version}-chrome.zip`), withManifest(chrome));
+zip(join(out, `docwell-web-clipper-${version}-firefox.zip`), withManifest(manifest));
+
+// AMO reviews the code the extension is built from: this folder as
+// Web-Clipper/, next to the repository files its build reads. It builds on
+// its own: cd Web-Clipper && npm install && npm run build.
+const repo = resolve(root, "..");
+const source = walk(root, root, (n) => /^(node_modules|dist|release)(\/|$)/.test(n)).map((f) => ({
+ ...f,
+ name: `Web-Clipper/${f.name}`,
+}));
+for (const f of ["tsconfig.base.json", "LICENSE"]) source.push({ name: f, data: readFileSync(join(repo, f)) });
+zip(join(out, `docwell-web-clipper-${version}-source.zip`), source);
diff --git a/Web-Clipper/store/PRIVACY.md b/Web-Clipper/store/PRIVACY.md
new file mode 100644
index 0000000..4b91b40
--- /dev/null
+++ b/Web-Clipper/store/PRIVACY.md
@@ -0,0 +1,24 @@
+# Docwell Web Clipper — privacy policy
+
+The Docwell Web Clipper is a browser extension that saves web pages to a Docwell server that you choose. It is published by the operator of that listing and is free software (AGPL-3.0); its source is in the Docwell repository, in `Web-Clipper/`.
+
+## What the extension handles
+
+- **The page you clip.** Only when you click the clipper's button, it reads the current tab's HTML, address, title and your selection. It turns them into Markdown inside the extension and sends that to your Docwell server as a new page. It reads nothing on pages you do not clip, and nothing in the background.
+- **Your settings.** The address of your Docwell server, your Docwell API token, and the workspace and space you picked are stored in the browser's extension storage on this device.
+
+## Where it goes
+
+Clips and requests go only to the Docwell server you entered in the options, over the connection that server offers (use `https://`). The extension sends nothing to the extension's publisher or to any other party, has no analytics or tracking, and loads no code from elsewhere.
+
+What happens to a clip on your Docwell server is up to whoever runs that server; ask them for their privacy policy.
+
+## Your control
+
+- Remove a clip by deleting its page in Docwell.
+- Revoke the extension's access by deleting its API token in Docwell (*Account settings → API tokens*).
+- Remove the stored settings by removing the extension from the browser.
+
+## Contact
+
+Questions about this policy go to the publisher shown on the extension's store listing.
diff --git a/Web-Clipper/store/STORE.md b/Web-Clipper/store/STORE.md
new file mode 100644
index 0000000..cb95b79
--- /dev/null
+++ b/Web-Clipper/store/STORE.md
@@ -0,0 +1,73 @@
+# Publishing the Docwell Web Clipper
+
+The packages come from one command:
+
+```sh
+npm run package -w @docwell/web-clipper
+```
+
+It builds the extension and writes three files to `Web-Clipper/release/`:
+
+| File | For |
+|---|---|
+| `docwell-web-clipper--chrome.zip` | Chrome Web Store and Microsoft Edge Add-ons |
+| `docwell-web-clipper--firefox.zip` | addons.mozilla.org (AMO) |
+| `docwell-web-clipper--source.zip` | AMO's "source code" upload (the extension is built with Vite) |
+
+Raise `version` in `public/manifest.json` (and `package.json`) before each new upload; the stores refuse a version they already have.
+
+## Chrome Web Store
+
+1. Sign in at with the account that will own the listing (a one-time developer registration fee applies).
+2. **New item** → upload the `-chrome.zip`.
+3. **Store listing:** paste the texts below, pick the category *Productivity → Tools* (or *Workflow & Planning*), upload the 128×128 icon (`public/icons/icon-128.png`) and at least one screenshot of 1280×800 or 640×400 (the popup over an article, and the options page, work well).
+4. **Privacy:** single purpose and permission justifications below; data use: the extension handles *website content* only to send it to the server the user configured, and sells or shares nothing. Link the privacy policy: publish `store/PRIVACY.md` somewhere public (the Docwell docs site, a repository page) and paste its address.
+5. Submit for review. Unlisted is fine if only your organization should find it.
+
+## Microsoft Edge Add-ons
+
+1. Sign in at (registration is free).
+2. **Create new extension** → upload the same `-chrome.zip`.
+3. Fill in the same texts, category *Productivity*, the privacy policy address, and screenshots (1280×800).
+
+## Firefox (addons.mozilla.org)
+
+1. Sign in at → **Submit a New Add-on**.
+2. Choose **On this site** (listed) or **On your own** (self-distributed, signed but not listed), and upload the `-firefox.zip`. The add-on id is `web-clipper@docwell.app` (in `public/manifest.json`); change it before the first upload if you publish under your own name.
+3. When asked whether the code is generated, answer yes and upload the `-source.zip`. Build instructions for the reviewer:
+
+ > Node 22 or later. Unzip, then `cd Web-Clipper && npm install && npm run build`. The extension is in `Web-Clipper/dist/`; it matches the uploaded package except for the source-path comments Vite writes at the top of each bundled module.
+
+4. Fill in the listing texts, category *Other* or *Feeds, News & Blogging*, and the privacy policy.
+
+## Listing texts
+
+**Name:** Docwell Web Clipper
+
+**Summary (max. 132 characters):** Save articles, pages and selections to your own Docwell server as new pages, with their links and pictures.
+
+**Description:**
+
+> Docwell Web Clipper saves what you are reading to Docwell, the open-source, self-hosted knowledge base.
+>
+> • Clip the article on a page: the clipper finds the main text (with Mozilla's Readability) and leaves menus, ads and sidebars out.
+> • Clip only what you selected, or the whole page.
+> • Links, pictures, code blocks and tables come along, under a note saying where the clip came from and when.
+> • Pick the space each clip goes to, and edit its title first.
+>
+> The clipper talks only to the Docwell server you connect it to, with a personal API token. It reads a page only when you click its button, and turns it into Markdown inside the extension before sending it.
+>
+> You need a Docwell server and an account on it. Docwell is free software (AGPL-3.0).
+
+**Single purpose:** Save the web page the user is viewing, or the part they selected, as a new page on the user's own Docwell server.
+
+**Permission justifications:**
+
+| Permission | Why |
+|---|---|
+| `activeTab` | Reads the page in the current tab, and only when the user clicks the clipper's button. |
+| `scripting` | Runs the function that returns the page's HTML and the selection from that tab. |
+| `storage` | Keeps the server address, API token and chosen space on this device. |
+| Optional host access (`https://*/*`, `http://*/*`) | Asked for one origin only, the Docwell server the user enters in the options, so the clipper can send clips to it. No other site is requested. |
+
+**Remote code:** none; everything the extension runs is in the package.
diff --git a/api/openapi.yaml b/api/openapi.yaml
index 865a8c1..ee35b7f 100644
--- a/api/openapi.yaml
+++ b/api/openapi.yaml
@@ -2619,6 +2619,182 @@ paths:
schema: { $ref: "#/components/schemas/Collection" }
"403": { $ref: "#/components/responses/Error" }
"404": { $ref: "#/components/responses/Error" }
+ /api/v1/integrations:
+ get:
+ operationId: getIntegrations
+ tags: [integrations]
+ summary: Which outside services this server can reach for people
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/Integrations" }
+ /api/v1/oauth/{provider}/callback:
+ parameters:
+ - { name: provider, in: path, required: true, schema: { type: string, enum: [google, microsoft] } }
+ get:
+ operationId: oauthCallback
+ tags: [integrations]
+ summary: Where Google and Microsoft send the browser back after a sign-in
+ description: >-
+ Register {DOCWELL_PUBLIC_URL}/api/v1/oauth/google/callback and
+ {DOCWELL_PUBLIC_URL}/api/v1/oauth/microsoft/callback as redirect URIs of the OAuth apps.
+ The signed state says who signed in and why; the browser is sent on to the web app.
+ parameters:
+ - { name: state, in: query, schema: { type: string } }
+ - { name: code, in: query, schema: { type: string } }
+ - { name: error, in: query, schema: { type: string } }
+ responses:
+ "302": { description: On to the web app }
+ /api/v1/calendars/google/connect:
+ get:
+ operationId: connectGoogleCalendar
+ tags: [calendars]
+ summary: Where to send the browser to connect a Google account's calendars (read-only)
+ description: Needs DOCWELL_GOOGLE_CLIENT_ID and DOCWELL_GOOGLE_CLIENT_SECRET. Afterwards the browser returns to account settings.
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ConnectURL" }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/onenote/connect:
+ get:
+ operationId: connectOneNote
+ tags: [integrations]
+ summary: Where to send the browser to sign in to Microsoft and import OneNote notebooks into a space
+ description: Needs DOCWELL_MICROSOFT_CLIENT_ID and DOCWELL_MICROSOFT_CLIENT_SECRET. The browser returns to the space with ?onenote=.
+ security: [{ bearer: [] }]
+ parameters:
+ - { name: space, in: query, required: true, schema: { type: string } }
+ - { name: parent, in: query, schema: { type: string } }
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ConnectURL" }
+ "400": { $ref: "#/components/responses/Error" }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/onenote/connections/{id}:
+ parameters:
+ - { name: id, in: path, required: true, schema: { type: string } }
+ get:
+ operationId: getOneNoteConnection
+ tags: [integrations]
+ summary: The signed-in Microsoft account and its notebooks (a connection lasts an hour)
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/OneNoteConnection" }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/onenote/connections/{id}/import:
+ parameters:
+ - { name: id, in: path, required: true, schema: { type: string } }
+ post:
+ operationId: importOneNoteNotebook
+ tags: [integrations]
+ summary: Start importing a notebook into a space (editor); it runs in the background
+ description: >-
+ The notebook, its section groups and sections become pages; each OneNote page a page under
+ its section (subpages under their parent page), with pictures and attached files as
+ attachments. At most 2000 pages and 512 MB of files.
+ security: [{ bearer: [] }]
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema:
+ type: object
+ required: [notebook, space]
+ properties:
+ notebook: { type: string }
+ space: { type: string }
+ parent: { type: string }
+ responses:
+ "202":
+ description: Started
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/OneNoteJob" }
+ "400": { $ref: "#/components/responses/Error" }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/onenote/jobs/{id}:
+ parameters:
+ - { name: id, in: path, required: true, schema: { type: string } }
+ get:
+ operationId: getOneNoteJob
+ tags: [integrations]
+ summary: How a OneNote import is going
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/OneNoteJob" }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/readwise:
+ get:
+ operationId: getReadwise
+ tags: [integrations]
+ summary: The caller's Readwise sync (connected false when there is none)
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ReadwiseConnection" }
+ put:
+ operationId: saveReadwise
+ tags: [integrations]
+ summary: Connect Readwise, or change where highlights go
+ description: >-
+ The token (readwise.io/access_token) is checked with Readwise and sealed. Every hour new
+ books get a page under a "Readwise" page in the space, and new highlights are added to
+ the end of their book's page. Choosing another space starts over there.
+ security: [{ bearer: [] }]
+ requestBody:
+ required: true
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ReadwiseInput" }
+ responses:
+ "200":
+ description: OK
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ReadwiseConnection" }
+ "400": { $ref: "#/components/responses/Error" }
+ delete:
+ operationId: deleteReadwise
+ tags: [integrations]
+ summary: Disconnect Readwise (the pages stay)
+ security: [{ bearer: [] }]
+ responses:
+ "204": { description: Disconnected }
+ "404": { $ref: "#/components/responses/Error" }
+ /api/v1/readwise/sync:
+ post:
+ operationId: syncReadwise
+ tags: [integrations]
+ summary: Add new Readwise highlights now
+ security: [{ bearer: [] }]
+ responses:
+ "200":
+ description: The sync with its result
+ content:
+ application/json:
+ schema: { $ref: "#/components/schemas/ReadwiseConnection" }
+ "404": { $ref: "#/components/responses/Error" }
/api/v1/calendars:
get:
operationId: listCalendars
@@ -2691,7 +2867,7 @@ paths:
post:
operationId: refreshCalendar
tags: [calendars]
- summary: Read a calendar from its source now (events are otherwise kept for 15 minutes)
+ summary: Read a calendar from its source and store its events now (otherwise every 15 minutes)
security: [{ bearer: [] }]
responses:
"200":
@@ -2706,8 +2882,10 @@ paths:
tags: [calendars]
summary: The caller's events between two days, from their enabled calendars
description: >-
+ Read from the stored copy the calendars.sync job keeps (every 15 minutes, 90 days back
+ and 400 days ahead), so it answers at once and still shows events when a source is down.
Repeating events are expanded, changed and cancelled occurrences applied. All-day events
- come first. A calendar that cannot be read is left out (its lastError says why).
+ come first.
security: [{ bearer: [] }]
parameters:
- { name: from, in: query, required: true, schema: { type: string, format: date } }
@@ -4584,13 +4762,67 @@ components:
What a value looks like: text and link a string, number a number, checkbox a
boolean, date "YYYY-MM-DD", select an option id, multi_select a list of option
ids, member a list of user ids.
+ Integrations:
+ type: object
+ required: [google, microsoft, readwise]
+ properties:
+ google: { type: boolean, description: People can connect Google Calendar }
+ microsoft: { type: boolean, description: People can import OneNote notebooks }
+ readwise: { type: boolean }
+ ConnectURL:
+ type: object
+ required: [url]
+ properties:
+ url: { type: string, description: Where to send the browser }
+ OneNoteNotebook:
+ type: object
+ required: [id, name, modified]
+ properties:
+ id: { type: string }
+ name: { type: string }
+ modified: { type: string }
+ OneNoteConnection:
+ type: object
+ required: [account, notebooks]
+ properties:
+ account: { type: string, description: The Microsoft account signed in }
+ notebooks: { type: array, items: { $ref: "#/components/schemas/OneNoteNotebook" } }
+ OneNoteJob:
+ type: object
+ required: [id, notebook, status, pages, error, created]
+ properties:
+ id: { type: string }
+ notebook: { type: string }
+ status: { type: string, enum: [running, done, failed] }
+ pages: { type: integer, description: OneNote pages read so far }
+ error: { type: string }
+ created: { type: array, items: { $ref: "#/components/schemas/Page" }, description: The pages made at the top }
+ ReadwiseConnection:
+ type: object
+ required: [connected, workspace, space, parent, enabled, lastSync, lastError, highlights, books]
+ properties:
+ connected: { type: boolean }
+ workspace: { type: string }
+ space: { type: string }
+ parent: { type: string, description: The "Readwise" page books go under }
+ enabled: { type: boolean }
+ lastSync: { type: string }
+ lastError: { type: string }
+ highlights: { type: integer }
+ books: { type: integer }
+ ReadwiseInput:
+ type: object
+ properties:
+ token: { type: string, maxLength: 200, description: Empty keeps the stored one }
+ space: { type: string }
+ enabled: { type: boolean }
CalendarAccount:
type: object
required: [id, name, kind, url, username, hasPassword, color, enabled, lastSync, lastError, events, created]
properties:
id: { type: string }
name: { type: string }
- kind: { type: string, enum: [ics, caldav] }
+ kind: { type: string, enum: [ics, caldav, google], description: "google accounts are connected with /calendars/google/connect" }
url: { type: string }
username: { type: string }
hasPassword: { type: boolean }