defuss-shadcn / Application / Scaffolds / scaffold-notes
Notes & Docs
A Notion-style workspace as a clickdummy - "Folio". Click into any page and write: / inserts a block, #, - or [] and a space turn the line into a heading, a bullet or a to-do, selecting text shows a format bar, and the ⋮⋮ handle drags a block. Open the Product Roadmap for a database with table, board and gallery views. Every edit is kept in your browser, ⌘K finds a section by its words and by its meaning, and the workspace menu backs everything up into one file and imports it again. Every control is a shipped component. Part of the Application Scaffolds.
On this page (2)
§Notes and docs
The whole workspace in one source. Pages are routes (#/pages/roadmap…) of defuss-dom-router; the language switch in the sidebar translates the shell with defuss-i18n; the database views and the toggles are CSS state; blocks are contenteditable elements with a data-type, so turning a line into a heading or a to-do is one attribute and a prefix element. Every edit is saved with defuss-storage (OPFS - full screen keeps it across reloads, this preview has no storage), ⌘K searches every section with defuss-search: keywords at once, by meaning once the two models are loaded (Settings). The workspace menu backs the pages and the search index up into one file and imports it again.
§How it works
A page, not a component: it composes the library and keeps its own glue small - the block editor is the one part that needs real script.
- Shell - the Sidebar holds two Tree Views (Favorites, Private pages; a page with sub-pages is a branch), search and new-page actions and the Trash Popover; the top bar has a Breadcrumb, Share (a Popover with a Switch), favorite and a Dropdown of page options - font, small text and full width as radio and checkbox items, copy link, move to trash.
- Routing - defuss-dom-router in hash mode: every page is
#/pages/:slug(a new page too - the route reads the slug when it is opened),#/the first one. The commit shows the page's<article>and the wiring selects it in the tree; a script navigates by changing the hash (a new page, a branch row, the trash), which the router follows. Inside the docs preview the same routes match the frame's hash. See Client-side Routing. - Translation - defuss-i18n: the language switch at the foot of the sidebar translates the shell - the sidebar, the workspace menu, the palette, the trash and every label - between English and German. The pages are your content and stay as written. See Translation.
- Pages - every page is an
<article>with an id. Its title, icon (an emoji Popover) and name stay in step across the tree, the breadcrumb and the Command palette (⌘K). New pages are stamped from a<template>. - Templates - a new page starts empty, as a to-do list, meeting notes, a roadmap, a wiki page, a journal entry, an onboarding checklist or a project brief - from the starter under its title or from the palette's "New from a template". A template is data in the page script: an icon, a title, a cover and full width where it wants them, and its blocks, built by the same functions the slash menu uses. A template's roadmap is a database of its own beside the sample's.
- Blocks - each block is a
contenteditableelement with adata-type: Enter splits, Backspace at the start merges or turns the block back into text, arrows move between blocks, markdown shortcuts convert. Numbered lists count with CSS counters, to-dos strike through with:has(:checked). - Slash and block menus - the Context Menu, opened at the caret through its State API: type to filter, arrows and Enter to pick. The ⋮⋮ handle opens Turn into / Duplicate / Delete, and drags the block with native drag and drop.
- Component blocks - the slash menu also inserts blocks made of components: hints (an Alert in four tones - note, tip, warning, caution - whose text you write like any other block), an image (upload a file, embed a link or pick a photo; an upload is scaled to 1600 px and kept as a WebP data URL, the caption is its alt text), a table (the Table with editable cells; Enter moves one row down, the last row grows), milestones (a horizontal Timeline whose dots mark a milestone reached) and a roadmap database. A component block turns into no text type; a database is not duplicated, since its items are one of a kind.
- Format bar - the Toolbar in a manual popover above the selection: bold, italic, underline and strikethrough through the browser's editing commands, inline code and highlight by wrapping the range.
- Database - a roadmap is one set of items in three views: a Table with Select status pills, a board you drag cards across, a gallery with covers. Opening an item shows it in a Sheet; every edit reaches all three views. A page may hold several databases: an item's id is unique in the workspace, so it names its database, and a card only moves between the columns of its own board.
- Storage - defuss-storage keeps the workspace in a folder of the browser's origin private file system (its directory adapter, on the page itself). The workspace is the markup of the parts a reader changes - the pages, both sidebars' trees, the palette's page list and the trash - with live form values written as attributes and the components' runtime marks taken out, so every component starts again on it. A change is saved 0.6 s after the last one, into two files in turn, each with its generation: storage files have no atomic replace, and a write cut short leaves the other one whole. Until the stored workspace is in place the pages stay hidden (3 s at most), but the menu already works: the router starts first, and the restored pages show the address the reader went to meanwhile. If the storage module has not loaded after 10 s, the visit goes on with the sample, keeps nothing and says so. Two tabs that edit at once overwrite each other's saves - the last one wins. The docs preview is a sandboxed frame without storage: it keeps the files in memory and says so at the foot of the sidebar; the full-screen app keeps them across reloads.
- Search - defuss-search ranks one document per section of a page (a heading starts one) and per roadmap item. Keywords work at once: BM25 over an English and a German analyzer, the title three times the text, prefix and fuzzy matching on the last word. Search by meaning is the lexical-semantic strategy with both models of defuss-vectorsearch: Winzling-embed turns every section and query into a vector, and the hits of both sources are fused and reordered by the ColBERT reranker (the reranked preset). The models' pinned files download once as Brotli from Hugging Face (about 34 MB with ONNX Runtime's WASM), are checked against their SHA-256 and are kept in the same storage. They download on a click in the palette or in Settings - nobody gets 34 MB unasked - and once the full-screen app keeps them they load by themselves (the preview keeps nothing, so there they come on a click each time). A vector is kept under a hash of its text, so an edit embeds only the sections it changed. Each hit shows whether keywords, meaning or both found it; a click opens the page at its section.
- Backups - the workspace menu (and Settings) writes one file,
folio-backup-<date>.json.br: the workspace and its search index - the lexical index, its documents and every vector - as JSON, Brotli-compressed with defuss-brotli (its compressor's WASM loads with the first backup). Import decodes it, and also takes an uncompressed.json. Import reads such a file back, after asking, and nothing is embedded again; a backup is treated as foreign markup, so scripts, frames, event attributes and script URLs are removed before it is shown. Reset brings back the sample workspace. - Full screen - app-notes.html is generated from this page's example at build time.
Comments, ideas or improvements? Edit this page's source on GitHub