Annotate Wikipedia articles with the same keys as nodes
An article's text is drawn from its sanitised HTML as selectable text (articleText.ts): paragraphs, list items and quotes with their inline elements; a formula is one unit; tables and preformatted blocks are shown but carry no offsets. The selection ladder, Tab, Enter, e d y x c :, D and the rest go through the same store paths as on a node; a note on article words is a note (Enter steps into it; c, f, u, the editor and history work on it as on any other) and shows wherever the article is opened, in the library's own note style. Detached annotations are listed at the top of their section with a link to the old revision. Keys that only make sense on a node say why in the status line. Tab on a link now selects its words, so Esc widens before h leaves, as in a node. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
f63fc10dc0
commit
2c1ee048a4
18 files changed
+1134
-126
No files matched your search
+3
-3
@@ -12,7 +12,7 @@ import { store, type Pending } from "./store";
|
||||
// ---- inline text ----
|
||||
|
||||
/** A note as the renderer sees it: one in the document, or one still being written. */
|
||||
interface VNote {
|
||||
export interface VNote {
|
||||
key: string;
|
||||
id?: NodeId;
|
||||
form: Form;
|
||||
@@ -155,7 +155,7 @@ function Writing({ text }: { text: string }) {
|
||||
|
||||
const LENS_LABEL: Record<string, string> = { elaborate: "", define: "definition", why: "why", example: "example", challenge: "objection" };
|
||||
|
||||
function NoteView({ v, inNote }: { v: VNote; inNote: boolean }) {
|
||||
export function NoteView({ v, inNote }: { v: VNote; inNote: boolean }) {
|
||||
const snap = store.snap;
|
||||
const focused = !!v.id && store.focus.node === v.id;
|
||||
const st = v.id ? staleness(snap, v.id) : null;
|
||||
@@ -434,7 +434,7 @@ export function TopMatter({ id }: { id: NodeId }) {
|
||||
// the page should open on the outline, so it is folded until asked for. Other text is plain.
|
||||
const prompt = !library && docOf(snap, id) === id && kids.some((k) => snap.nodes[k].anchors.length > 0);
|
||||
const folded = prompt && !store.unfolded.has(id) && !(focused && store.focus.grain !== "node") && store.edit?.node !== id;
|
||||
const count = library ? Object.keys(snap.nodes).length - 1 : descendants(snap, id).length;
|
||||
const count = library ? kids.reduce((n, d) => n + 1 + descendants(snap, d).length, 0) : descendants(snap, id).length;
|
||||
return (
|
||||
<>
|
||||
{crumbs.length > 0 && (
|
||||
|
||||
Reference in new issue
Block a user