Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(clipper): extract pages with Defuddle (closes #2621)
Elian Doran79ae4989f7b2
diff --git a/.claude/skills/developing-web-clipper/SKILL.md b/.claude/skills/developing-web-clipper/SKILL.mdindex ef754a1e45..668aa172b9 100644--- a/.claude/skills/developing-web-clipper/SKILL.md+++ b/.claude/skills/developing-web-clipper/SKILL.md@@ -1,6 +1,6 @@---name: developing-web-clipper-description: Use when working on Trilium's browser extension, the web clipper (`apps/web-clipper`, built with WXT for Chrome MV3 and Firefox MV2) — its background script, content script (selection, screenshots, toasts), the injected Readability script, the Preact popup and options page, `wxt.config.ts` (manifest, keyboard `commands`, the Firefox sources zip), or the server side it talks to (`apps/server/src/routes/api/clipper.ts`, `/api/login/token`, the desktop port). Covers the message protocol between the extension's parts, how it finds and authenticates to Trilium, the compatibility rule with older Trilium versions, styling the pages in the Next theme from the client's own stylesheets, running and building it, the `fakeBrowser` spec patterns and the 100% coverage gate, and the traps already hit (undeclared commands, image placeholders, `$&` in `replaceAll()` replacements, `javascript:` links, the sources zip).+description: Use when working on Trilium's browser extension, the web clipper (`apps/web-clipper`, built with WXT for Chrome MV3 and Firefox MV2) — its background script, content script (selection, screenshots, toasts), the injected Defuddle script, the Preact popup and options page, `wxt.config.ts` (manifest, keyboard `commands`, the Firefox sources zip), or the server side it talks to (`apps/server/src/routes/api/clipper.ts`, `/api/login/token`, the desktop port). Covers the message protocol between the extension's parts, how it finds and authenticates to Trilium, the compatibility rule with older Trilium versions, styling the pages in the Next theme from the client's own stylesheets, running and building it, the `fakeBrowser` spec patterns and the 100% coverage gate, and the traps already hit (undeclared commands, image placeholders, `$&` in `replaceAll()` replacements, `javascript:` links, the sources zip).---# Developing the web clipper@@ -18,7 +18,7 @@ repository.| `entrypoints/background/index.ts` | service worker (MV3) / background page (MV2) | context menus, keyboard commands, every save, image download, toasts || `entrypoints/background/trilium_server_facade.ts` | background | finds Trilium, authenticates, `callService()` || `entrypoints/content/index.ts` | every page (`<all_urls>`) | selection, page description, crop overlay, toast UI |-| `entrypoints/readability/index.ts` | the tab, injected on demand | Readability extraction of the whole page; its `main()` value is the `executeScript()` result |+| `entrypoints/readable-page/index.ts` | the tab, injected on demand | Defuddle extraction of the whole page; its `main()` value is the `executeScript()` result || `entrypoints/popup/main.tsx` | the toolbar popup | Preact `Popup`: capture buttons, link-with-note form, connection status || `entrypoints/options/main.tsx` | the options page | Preact `Options`: desktop port, server login || `entrypoints/offscreen/` | MV3 only (Chrome) | crops screenshots on a canvas, since an MV3 service worker has no DOM |@@ -39,8 +39,8 @@ Everything goes through `browser.runtime.sendMessage` / `browser.tabs.sendMessag- **background → offscreen:** `{ type: "CROP_IMAGE" }`, the one message keyed by `type`.The readable page is not a message: the popup and the background call `extractReadablePage(tabId)`-(`utils.ts`), which injects `/readability.js` with `browser.scripting.executeScript()` (the-`scripting` permission, in both builds), so Readability stays out of the content script that loads+(`utils.ts`), which injects `/readable-page.js` with `browser.scripting.executeScript()` (the+`scripting` permission, in both builds), so Defuddle stays out of the content script that loadson every page. Specs mock it with `Object.assign(fakeBrowser, { scripting: { executeScript } })`,answering `[ { result: page } ]`.@@ -101,8 +101,20 @@ against older versions of the other.** Prefer changes that need nothing new from`new URL("")` throws, so `saveTabs()` filters them out.- `fetchImage()` rejects a non-OK response and a non-image `Content-Type` — otherwise an error pagegets saved as the "image".-- Readability is `@mozilla/readability`, installed from npm; Firefox+- The page is extracted with `defuddle`, installed from npm and pinned; Firefoxreview flags its `innerHTML` use, which the README explains to the reviewer.+ - `new Defuddle(document, { url })` takes the **live** document: it clones it itself, leaves+ the page unchanged, and reads computed styles and image sizes from the original, which a copy+ made with `cloneNode()` does not have. `url` makes links and images absolute.+ - Its HTML is parsed with `DOMParser`, a document that loads no image and runs no code, before+ `getImages()` swaps the sources for placeholders.+ - A page without an article comes back as `<body></body>`, which `readPage()` turns into+ `undefined` (the popup's bookmark mode). Defuddle finds an article on more pages than+ Readability did, home pages included.+ - Use `parse()`, never `parseAsync()`: the async extractors fetch third-party APIs.+ - **happy-dom drops lazy images** (`data-src` behind a `data:image/svg+xml` placeholder) that+ Chromium and linkedom promote to `src`; test such Defuddle behavior in a real browser, not+ in a spec.## The popup and options page: Preact in the Next themediff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.htmlindex 847306ca62..db98c6aeca 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html@@ -54,9 +54,9 @@menu, screenshots and images included, get the description as the pagegives it. Each clipping that brings a description updates the label.</p><p>The popup opens on the selection if there is one, otherwise on the article.- On a page with no article (Readability cannot find one) and no selection,- it opens on <em>Bookmark</em> and says the page has no article. The keyboard- shortcuts and the context menu still save right away, without a preview.</p>+ On a page with no article and no selection, it opens on <em>Bookmark</em> and+ says the page has no article. The keyboard shortcuts and the context menu+ still save right away, without a preview.</p></li><li><p>Pages the extension cannot access (the browser's own pages, the extensiondiff --git a/apps/web-clipper/README.md b/apps/web-clipper/README.mdindex fa085ea5b7..1f7cdc5768 100644--- a/apps/web-clipper/README.md+++ b/apps/web-clipper/README.md@@ -6,7 +6,7 @@ The Web Clipper is an extension for the Trilium Notes application, an open-sourcThe source is extracted from the official monorepo, where it can be found under `apps/web-clipper`. The only change made to the provided source code is to have `tsconfig.base.json` in the same directory as the Web Clipper. The submitted source code is a snapshot of the following commit: [https://github.com/TriliumNext/Trilium/commit/1cf93ff0dec89ee1a80654934cb30fad74920043](https://github.com/TriliumNext/Trilium/commit/1cf93ff0dec89ee1a80654934cb30fad74920043)-There are some warnings regarding the use of `innerHTML`. They come from `@mozilla/readability`, Mozilla's own article extraction library behind Firefox's Reader View, which the extension installs unmodified from npm.+There are some warnings regarding the use of `innerHTML`. They come from [`defuddle`](https://github.com/kepano/defuddle), the article extraction library behind the Obsidian Web Clipper, which the extension installs unmodified from npm. It runs only when the user opens the popup or saves a page, and it removes scripts, event handler attributes and `javascript:` URLs from the article it returns.## Building from sourcediff --git a/apps/web-clipper/entrypoints/background/index.spec.ts b/apps/web-clipper/entrypoints/background/index.spec.tsindex 03b7fea9ab..8aae6e7e0e 100644--- a/apps/web-clipper/entrypoints/background/index.spec.ts+++ b/apps/web-clipper/entrypoints/background/index.spec.ts@@ -56,7 +56,7 @@ let tabs: Tab[];let tabMessageHandler: (message: { name: string }) => unknown;const tabsSendMessage = vi.fn((_tabId: number, message: { name: string }) => Promise.resolve(tabMessageHandler(message)));-/** What `readability.js` returns in the active tab; no article unless a test says so. */+/** What `readable-page.js` returns in the active tab; no article unless a test says so. */let readablePage: unknown;const executeScript = vi.fn(async () => [ { result: readablePage } ]);const contextMenusCreate = vi.fn();@@ -284,7 +284,7 @@ describe("background", () => {await sendRuntimeMessage({ name: "save-whole-page" });expect(executeScript).toHaveBeenCalledTimes(3);- expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readability.js" ] });+ expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readable-page.js" ] });expect(facade.callService).toHaveBeenCalledTimes(3);expect(facade.callService).toHaveBeenLastCalledWith("POST", "notes", page);expect(await lastToast()).toMatchObject({ noteId: "saved" });diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsxindex c8063d6014..1796c3e59a 100644--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx@@ -27,7 +27,7 @@ const PAGE = {clipType: "page",labels: { publishedDate: "2024-05-01" }};-/** What `readability.js` returns in the tab, as `browser.scripting.executeScript()` answers. */+/** What `readable-page.js` returns in the tab, as `browser.scripting.executeScript()` answers. */const executeScript = vi.fn(async (): Promise<unknown> => [ { result: PAGE } ]);const tabsQuery = vi.fn(async (): Promise<{ id?: number, title?: string, url?: string }[]> => [ { id: 7 } ]);const SELECTION = {@@ -207,7 +207,7 @@ describe("popup", () => {it("previews the readable page with its title, source and date", () => {expect(tabsQuery).toHaveBeenCalledWith({ active: true, currentWindow: true });- expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readability.js" ] });+ expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readable-page.js" ] });expect(cardParts()).toEqual([ "page-heading", "clip-mode", "page-body", "btn btn-primary primary-action" ]);expect(modes()).toEqual([ [ "Page", "true" ], [ "Bookmark", "false" ] ]);diff --git a/apps/web-clipper/entrypoints/readability/index.spec.ts b/apps/web-clipper/entrypoints/readability/index.spec.tsdeleted file mode 100644index 8b876a7d35..0000000000--- a/apps/web-clipper/entrypoints/readability/index.spec.ts+++ /dev/null@@ -1,83 +0,0 @@-import { Readability } from "@mozilla/readability";-import type { Window as HappyDOMWindow } from "happy-dom";-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";--import type { ReadablePage } from "@/utils";--import readability from "./index";--const PARAGRAPH = "Trilium is a hierarchical note taking application with focus on "- + "building large personal knowledge bases. It supports rich text, code, canvas and many "- + "other note types, scripting and sync. ";--describe("readable page", () => {- beforeEach(() => {- (window as unknown as HappyDOMWindow).happyDOM.setURL("https://example.com/blog/post.html?id=1#comments");- document.head.innerHTML = "<title> Post title </title>";- document.body.innerHTML = "";- });-- afterEach(() => {- vi.restoreAllMocks();- });-- it("returns the readable article with its publication dates as labels", () => {- document.head.innerHTML = `- <title>Article title</title>- <meta property="article:published_time" content="2026-01-02T10:00:00Z">- <meta property="article:modified_time" content="2026-02-03T10:00:00Z">- <meta property="og:description" content="About the article">`;- document.body.innerHTML = `- <nav><a href="/">Home</a></nav>- <article>- <h1>Article title</h1>- <p>${PARAGRAPH.repeat(3)}<a href="/docs">Docs</a>- <a href="mailto:[email protected]">Jane</a></p>- <p>${PARAGRAPH.repeat(3)}</p>- <img src="figure.png">- <p>${PARAGRAPH.repeat(3)}</p>- </article>`;-- const page = readPage();-- expect(page).toMatchObject({- title: "Article title",- pageUrl: "https://example.com/blog/post.html?id=1",- clipType: "page",- labels: {- pageDescription: "About the article",- publishedDate: "2026-01-02",- modifiedDate: "2026-02-03"- },- images: [ {- imageId: expect.any(String),- src: "https://example.com/blog/figure.png"- } ]- });- expect(page?.content).toContain(`src="${page?.images[0]?.imageId}"`);- expect(page?.content).toContain("href=\"https://example.com/docs\"");- expect(page?.content).toContain("href=\"mailto:[email protected]\"");- expect(page?.content).not.toContain("Home");- expect(document.querySelector("nav")).not.toBeNull();- });-- it("adds no labels without dates, and titles an untitled article after the document", () => {- document.body.innerHTML = `<article><p>${PARAGRAPH.repeat(5)}</p></article>`;- expect(readPage()?.labels).toEqual({});-- const content = document.createElement("div");- vi.spyOn(Readability.prototype, "parse")- .mockReturnValue({ title: null, content } as unknown as ReturnType<Readability["parse"]>);- expect(readPage()?.title).toBe("Post title");- });-- it("returns nothing when Readability finds no article", () => {- vi.spyOn(Document.prototype, "cloneNode")- .mockReturnValue(document.implementation.createHTMLDocument(""));- expect(readPage()).toBeUndefined();- });-});--function readPage() {- return readability.main() as ReadablePage | undefined;-}diff --git a/apps/web-clipper/entrypoints/readability/index.ts b/apps/web-clipper/entrypoints/readability/index.tsdeleted file mode 100644index a2ee3ae862..0000000000--- a/apps/web-clipper/entrypoints/readability/index.ts+++ /dev/null@@ -1,65 +0,0 @@-import { Readability } from "@mozilla/readability";--import {- descriptionLabels, getImages, getPageLocationOrigin, makeLinksAbsolute, type ReadablePage-} from "@/utils";--/**- * Extracts the readable page. `extractReadablePage()` injects it into the tab only when a page is- * read, so Readability does not load with the content script on every page. The value `main()`- * returns is the result of `executeScript()`.- */-export default defineUnlistedScript(readPage);--function readPage(): ReadablePage | undefined {- // Readability changes the document it parses, so it reads a copy of the page.- const documentCopy = document.cloneNode(true) as Document;- const article = new Readability(documentCopy, {- // Returns the content as an element rather than as HTML.- serializer: (node) => node as HTMLElement- }).parse();-- if (!article?.content) {- return undefined;- }-- const body = article.content;- makeLinksAbsolute(body);- const images = getImages(body);-- const labels = descriptionLabels();- const { publishedDate, modifiedDate } = getDocumentDates();- if (publishedDate) {- labels['publishedDate'] = publishedDate.toISOString().substring(0, 10);- }- if (modifiedDate) {- labels['modifiedDate'] = modifiedDate.toISOString().substring(0, 10);- }-- return {- title: article.title ?? document.title,- content: body.innerHTML,- images,- pageUrl: getPageLocationOrigin() + location.pathname + location.search,- clipType: 'page',- labels- };-}--function getDocumentDates() {- let publishedDate: Date | null = null;- let modifiedDate: Date | null = null;-- const articlePublishedTime = document.querySelector("meta[property='article:published_time']")?.getAttribute('content');- if (articlePublishedTime) {- publishedDate = new Date(articlePublishedTime);- }-- const articleModifiedTime = document.querySelector("meta[property='article:modified_time']")?.getAttribute('content');- if (articleModifiedTime) {- modifiedDate = new Date(articleModifiedTime);- }-- // TODO: if we didn't get dates from meta, then try to get them from JSON-LD- return { publishedDate, modifiedDate };-}diff --git a/apps/web-clipper/entrypoints/readable-page/index.spec.ts b/apps/web-clipper/entrypoints/readable-page/index.spec.tsnew file mode 100644index 0000000000..9c85df2b5c--- /dev/null+++ b/apps/web-clipper/entrypoints/readable-page/index.spec.ts@@ -0,0 +1,94 @@+import type { Window as HappyDOMWindow } from "happy-dom";+import { beforeEach, describe, expect, it } from "vitest";++import type { ReadablePage } from "@/utils";++import readablePage from "./index";++const PARAGRAPH = "Trilium is a hierarchical note taking application with focus on "+ + "building large personal knowledge bases. It supports rich text, code, canvas and many "+ + "other note types, scripting and sync. ";++describe("readable page", () => {+ beforeEach(() => {+ (window as unknown as HappyDOMWindow).happyDOM.setURL("https://example.com/blog/post.html?id=1#comments");+ document.head.innerHTML = "<title>Post title</title>";+ document.body.innerHTML = "";+ });++ it("returns the article with absolute links, image placeholders and its dates as labels", () => {+ document.head.innerHTML = `+ <title>Article title</title>+ <meta property="article:published_time" content="2026-01-02T10:00:00Z">+ <meta property="article:modified_time" content="2026-02-03T10:00:00Z">+ <meta property="og:description" content="About the article">+ <script>window.tracked = true;</script>`;+ document.body.innerHTML = `+ <nav><a href="/">Home</a> <a href="/archive">Archive</a></nav>+ <article>+ <h1>Article title</h1>+ <p>${PARAGRAPH.repeat(3)}<a href="/docs">Docs</a>+ <a href="mailto:[email protected]">Jane</a></p>+ <p>${PARAGRAPH.repeat(3)}</p>+ <img src="figure.png" width="600" height="400">+ <img src="figure.png" width="600" height="400">+ <p onclick="alert(1)">${PARAGRAPH.repeat(3)}</p>+ </article>`;+ const pageBefore = document.documentElement.outerHTML;++ const page = readPage();++ expect(page).toMatchObject({+ title: "Article title",+ pageUrl: "https://example.com/blog/post.html?id=1",+ clipType: "page",+ labels: {+ pageDescription: "About the article",+ publishedDate: "2026-01-02",+ modifiedDate: "2026-02-03"+ },+ images: [ {+ imageId: expect.stringMatching(/^[A-Za-z0-9]{20}$/),+ src: "https://example.com/blog/figure.png"+ } ]+ });+ expect(page?.content.match(/<img [^>]*>/g)).toEqual([+ expect.stringContaining(`src="${page?.images[0]?.imageId}"`),+ expect.stringContaining(`src="${page?.images[0]?.imageId}"`)+ ]);+ expect(page?.content).toContain("href=\"https://example.com/docs\"");+ expect(page?.content).toContain("href=\"mailto:[email protected]\"");+ expect(page?.content).not.toContain("Archive");+ expect(page?.content).not.toContain("onclick");+ expect(document.documentElement.outerHTML).toBe(pageBefore);+ });++ it("dates the article from its structured data, and leaves out a date it cannot read", () => {+ const article = `<article><p>${PARAGRAPH.repeat(5)}</p></article>`;+ const structuredData = (datePublished: string) => `<script type="application/ld+json">${JSON.stringify({+ "@context": "https://schema.org", "@type": "NewsArticle", headline: "Post title", datePublished+ })}</script>`;++ document.head.innerHTML = `<title>Post title</title>${structuredData("2025-12-24T08:00:00Z")}+ <meta property="article:published_time" content="">`;+ document.body.innerHTML = article;+ expect(readPage()?.labels).toEqual({ publishedDate: "2025-12-24" });++ document.head.innerHTML = `<title>Post title</title>${structuredData("next week")}+ <meta property="article:modified_time" content="not a date">`;+ document.body.innerHTML = article;+ expect(readPage()?.labels).toEqual({});+ });++ it("keeps an article that is only a picture, and returns nothing for a page without one", () => {+ document.body.innerHTML = `<article><img src="photo.jpg" width="800" height="600"></article>`;+ expect(readPage()?.images.map(({ src }) => src)).toEqual([ "https://example.com/blog/photo.jpg" ]);++ document.body.innerHTML = "<nav><a href=\"/\">Home</a> <a href=\"/archive\">Archive</a></nav>";+ expect(readPage()).toBeUndefined();+ });+});++function readPage() {+ return readablePage.main() as ReadablePage | undefined;+}diff --git a/apps/web-clipper/entrypoints/readable-page/index.ts b/apps/web-clipper/entrypoints/readable-page/index.tsnew file mode 100644index 0000000000..99f362dfba--- /dev/null+++ b/apps/web-clipper/entrypoints/readable-page/index.ts@@ -0,0 +1,53 @@+import Defuddle from "defuddle";++import { descriptionLabels, getImages, getPageLocationOrigin, type ReadablePage } from "@/utils";++/**+ * Extracts the readable page with Defuddle. `extractReadablePage()` injects it into the tab only+ * when a page is read, so Defuddle does not load with the content script on every page. The value+ * `main()` returns is the result of `executeScript()`.+ */+export default defineUnlistedScript(readPage);++function readPage(): ReadablePage | undefined {+ // `parse()` works on a copy of the document and reads styles and image sizes from the page,+ // so it is given the live document.+ const article = new Defuddle(document, { url: location.href }).parse();++ // A document of its own loads none of the article's images and runs none of its code.+ const body = new DOMParser().parseFromString(article.content, "text/html").body;+ if (!body.textContent.trim() && !body.querySelector("img")) {+ return undefined;+ }++ const images = getImages(body);++ const labels = descriptionLabels();+ const publishedDate = isoDate(metaContent("article:published_time") || article.published);+ if (publishedDate) {+ labels['publishedDate'] = publishedDate;+ }+ const modifiedDate = isoDate(metaContent("article:modified_time"));+ if (modifiedDate) {+ labels['modifiedDate'] = modifiedDate;+ }++ return {+ title: article.title,+ content: body.innerHTML,+ images,+ pageUrl: getPageLocationOrigin() + location.pathname + location.search,+ clipType: 'page',+ labels+ };+}++function metaContent(property: string) {+ return document.querySelector(`meta[property='${property}']`)?.getAttribute("content") ?? undefined;+}++/** The day of `value` as `YYYY-MM-DD`, or `undefined` when it is missing or not a date. */+function isoDate(value: string | undefined) {+ const date = new Date(value ?? "");+ return Number.isNaN(date.getTime()) ? undefined : date.toISOString().substring(0, 10);+}diff --git a/apps/web-clipper/package.json b/apps/web-clipper/package.jsonindex 19574b6722..b64a1aa582 100644--- a/apps/web-clipper/package.json+++ b/apps/web-clipper/package.json@@ -25,7 +25,7 @@},"dependencies": {"@boxicons/js": "1.0.1",- "@mozilla/readability": "0.6.0",+ "defuddle": "0.19.5","preact": "11.0.0"}}diff --git a/apps/web-clipper/utils.spec.ts b/apps/web-clipper/utils.spec.tsindex f5f68794eb..d25028a255 100644--- a/apps/web-clipper/utils.spec.ts+++ b/apps/web-clipper/utils.spec.ts@@ -46,7 +46,7 @@ describe("extractReadablePage", () => {Reflect.deleteProperty(fakeBrowser, "scripting");});- it("runs the readability script in the tab and returns its result", async () => {+ it("runs the readable-page script in the tab and returns its result", async () => {const page = { title: "Article", content: "<p>Body</p>" };const executeScript = vi.fn().mockResolvedValueOnce([ { result: page } ])@@ -55,7 +55,7 @@ describe("extractReadablePage", () => {Object.assign(fakeBrowser, { scripting: { executeScript } });expect(await extractReadablePage(7)).toBe(page);- expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readability.js" ] });+ expect(executeScript).toHaveBeenCalledWith({ target: { tabId: 7 }, files: [ "/readable-page.js" ] });expect(await extractReadablePage(7)).toBeUndefined();expect(await extractReadablePage(7)).toBeUndefined();});diff --git a/apps/web-clipper/utils.ts b/apps/web-clipper/utils.tsindex 7297d4327a..3d60d00510 100644--- a/apps/web-clipper/utils.ts+++ b/apps/web-clipper/utils.ts@@ -3,7 +3,7 @@ export type Rect = { x: number, y: number, width: number, height: number };/** An image of a clipping; the clipping's `content` references it by `imageId`. */export type ClippedImage = { imageId: string, src: string };-/** The readable version of a page, as `entrypoints/readability/index.ts` extracts it. */+/** The readable version of a page, as `entrypoints/readable-page/index.ts` extracts it. */export interface ReadablePage {title: string;content: string;@@ -14,14 +14,14 @@ export interface ReadablePage {}/**- * Runs `entrypoints/readability/index.ts` in the tab and returns the page it read, or `undefined`+ * Runs `entrypoints/readable-page/index.ts` in the tab and returns the page it read, or `undefined`* when the page has no article. Throws where the extension cannot run scripts, such as browser* pages.*/export async function extractReadablePage(tabId: number): Promise<ReadablePage | undefined> {const [ injection ] = await browser.scripting.executeScript({target: { tabId },- files: [ "/readability.js" ]+ files: [ "/readable-page.js" ]});return (injection?.result ?? undefined) as ReadablePage | undefined;}diff --git a/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md b/docs/User Guide/User Guide/Installation & Setup/Web Clipper.mdindex 74bbd74f3c..746e6e0274 100644--- a/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md+++ b/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md@@ -37,7 +37,7 @@ Clicking the extension's button in the browser toolbar opens its popup:The description, marked by the <span class="tn-icon bx bx-align-left"></span> icon, comes from the page's `description` meta tag, or the one it gives social sites. It can be edited or cleared before saving, or written in when the page has none, and is saved in the `#pageDescription` label of the note. Clippings saved with the keyboard shortcuts or the context menu, screenshots and images included, get the description as the page gives it. Each clipping that brings a description updates the label.- The popup opens on the selection if there is one, otherwise on the article. On a page with no article (Readability cannot find one) and no selection, it opens on _Bookmark_ and says the page has no article. The keyboard shortcuts and the context menu still save right away, without a preview.+ The popup opens on the selection if there is one, otherwise on the article. On a page with no article and no selection, it opens on _Bookmark_ and says the page has no article. The keyboard shortcuts and the context menu still save right away, without a preview.* Pages the extension cannot access (the browser's own pages, the extension stores, and pages that were open before the extension was installed until they are reloaded) cannot be saved or captured, so the popup says so in place of the preview, and only _Tabs_ remains available there.* Below the preview, a row of buttons offers the other actions: _Crop_ (a screenshot of an area you select), _Screenshot_ (of the visible part of the page) and _Tabs_ (saves the links of every tab in the current window as a list). Hovering over a button shows its full name and, if it has one, its keyboard shortcut.* If the current page was already clipped, a notice at the top offers to open the note in Trilium.diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3185c108f0..1d81dba04e 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1027,9 +1027,9 @@ importers:'@boxicons/js':specifier: 1.0.1version: 1.0.1- '@mozilla/readability':- specifier: 0.6.0- version: 0.6.0+ defuddle:+ specifier: 0.19.5+ version: 0.19.5preact:specifier: 11.0.0version: 11.0.0([email protected])@@ -3470,10 +3470,6 @@ packages:'@cfworker/json-schema':optional: true- '@mozilla/[email protected]':- resolution: {integrity: sha512-juG5VWh4qAivzTAeMzvY9xs9HY5rAcr2E4I7tiSSCokRFi7XIZCAu92ZkSTsIj1OPceCifL3cpfteP3pDT9/QQ==}- engines: {node: '>=14.0.0'}-'@napi-rs/[email protected]':resolution: {integrity: sha512-0sDMvme+7fj6bHERUaBs5SvEyWaORc91VUkaB4RrtG7p6dBrBNGy1of8cyEKDxygd1FlHtW+Thunj8lSixzY7A==}engines: {node: '>= 10'}@@ -6859,6 +6855,10 @@ packages:resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==}+ resolution: {integrity: sha512-WpgFv5TWA8s8bWRXMb+tosdEbdeZwgrKYw+BQiuTQfQc4XdCm69Yq/76Lzgvr0ALC1VxZcMWwjNGGgIstcxUtw==}+ hasBin: true+resolution: {integrity: sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==}@@ -8938,6 +8938,9 @@ packages:resolution: {integrity: sha512-aa6AU2Pcx0VP/XWnh8IGL0SYSgQHDT6Ucror2j2mXeFAlN3ahaNs8EZtG1YiticMkSLj3Gt6VPFfZogt7G5iFQ==}+ resolution: {integrity: sha512-gQ0uK3zqB8HwlfaXJkEL5rgaZNbKUiBMmBP/B/W+b+t6KcseLSuYb1b0BjLgS9ZiQa24ePkqTX8/6FaQuDL7wQ==}+resolution: {integrity: sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==}@@ -10825,6 +10828,10 @@ packages:resolution: {integrity: sha512-eYE6iEI62Ni1H8oIa7KlDU6uQBtqr4Eajni3wX7rpfXD8ysFx8z0+dri+KWEPWpBsxXfxu58x/0jvTVT1ekOSg==}+ resolution: {integrity: sha512-aPkDDgunanpLNL0ql32HbolqLep+w8DRcVXRql7rWrMt/PhczdLgL4UBYYVU3BYjCNjkGq4EqwIicu/zWr1iOg==}+ engines: {node: '>=18.13.0'}+resolution: {integrity: sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==}engines: {node: '>=6.0.0'}@@ -14658,8 +14665,6 @@ snapshots:transitivePeerDependencies:- supports-color- '@mozilla/[email protected]': {}-'@napi-rs/[email protected]':optional: true@@ -18672,6 +18677,17 @@ snapshots:+ dependencies:+ commander: 12.1.0+ mathml-to-latex: 1.8.0+ optionalDependencies:+ linkedom: 0.18.13+ temml: 0.13.5+ turndown: 7.2.4+ transitivePeerDependencies:+ - canvas+dependencies:robust-predicates: 3.0.3@@ -21112,6 +21128,10 @@ snapshots:+ dependencies:+ '@xmldom/xmldom': 0.9.12+dependencies:'@types/mdast': 4.0.4@@ -23451,6 +23471,9 @@ snapshots:- bare-abort-controller- react-native-b4a+ optional: true+dependencies:mkdirp: 0.5.6