@tooee/view 0.1.22 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -12
- package/dist/View.d.ts.map +1 -1
- package/dist/View.js +5 -1
- package/dist/View.js.map +1 -1
- package/dist/components/ViewScreen.d.ts +28 -0
- package/dist/components/ViewScreen.d.ts.map +1 -0
- package/dist/components/ViewScreen.js +29 -0
- package/dist/components/ViewScreen.js.map +1 -0
- package/dist/components/subviews/CodeSubview.d.ts +1 -1
- package/dist/components/subviews/CodeSubview.d.ts.map +1 -1
- package/dist/components/subviews/CodeSubview.js +20 -89
- package/dist/components/subviews/CodeSubview.js.map +1 -1
- package/dist/components/subviews/CustomSubview.d.ts +1 -1
- package/dist/components/subviews/CustomSubview.d.ts.map +1 -1
- package/dist/components/subviews/CustomSubview.js +19 -94
- package/dist/components/subviews/CustomSubview.js.map +1 -1
- package/dist/components/subviews/MarkdownSubview.d.ts +1 -1
- package/dist/components/subviews/MarkdownSubview.d.ts.map +1 -1
- package/dist/components/subviews/MarkdownSubview.js +32 -106
- package/dist/components/subviews/MarkdownSubview.js.map +1 -1
- package/dist/components/subviews/TableSubview.d.ts +1 -1
- package/dist/components/subviews/TableSubview.d.ts.map +1 -1
- package/dist/components/subviews/TableSubview.js +22 -123
- package/dist/components/subviews/TableSubview.js.map +1 -1
- package/dist/components/subviews/index.d.ts +0 -1
- package/dist/components/subviews/index.d.ts.map +1 -1
- package/dist/components/subviews/index.js +0 -1
- package/dist/components/subviews/index.js.map +1 -1
- package/dist/components/subviews/types.d.ts +6 -0
- package/dist/components/subviews/types.d.ts.map +1 -1
- package/dist/default-provider.d.ts +6 -3
- package/dist/default-provider.d.ts.map +1 -1
- package/dist/default-provider.js +24 -34
- package/dist/default-provider.js.map +1 -1
- package/dist/hooks/index.d.ts +2 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useContentCommands.d.ts +15 -0
- package/dist/hooks/useContentCommands.d.ts.map +1 -0
- package/dist/hooks/useContentCommands.js +21 -0
- package/dist/hooks/useContentCommands.js.map +1 -0
- package/dist/hooks/useViewCommandContext.d.ts +10 -42
- package/dist/hooks/useViewCommandContext.d.ts.map +1 -1
- package/dist/hooks/useViewCommandContext.js +3 -30
- package/dist/hooks/useViewCommandContext.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +15 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +14 -14
- package/src/View.tsx +6 -1
- package/src/components/ViewScreen.tsx +76 -0
- package/src/components/subviews/CodeSubview.tsx +30 -120
- package/src/components/subviews/CustomSubview.tsx +32 -123
- package/src/components/subviews/MarkdownSubview.tsx +49 -130
- package/src/components/subviews/TableSubview.tsx +36 -164
- package/src/components/subviews/index.ts +0 -1
- package/src/components/subviews/types.ts +6 -0
- package/src/default-provider.ts +37 -34
- package/src/hooks/index.ts +2 -7
- package/src/hooks/useContentCommands.ts +29 -0
- package/src/hooks/useViewCommandContext.ts +13 -81
- package/src/index.ts +1 -1
- package/src/types.ts +15 -16
- package/dist/components/SubviewLayout.d.ts +0 -16
- package/dist/components/SubviewLayout.d.ts.map +0 -1
- package/dist/components/SubviewLayout.js +0 -18
- package/dist/components/SubviewLayout.js.map +0 -1
- package/dist/hooks/useMarkState.d.ts +0 -14
- package/dist/hooks/useMarkState.d.ts.map +0 -1
- package/dist/hooks/useMarkState.js +0 -71
- package/dist/hooks/useMarkState.js.map +0 -1
- package/dist/hooks/useViewCommands.d.ts +0 -13
- package/dist/hooks/useViewCommands.d.ts.map +0 -1
- package/dist/hooks/useViewCommands.js +0 -20
- package/dist/hooks/useViewCommands.js.map +0 -1
- package/src/components/SubviewLayout.tsx +0 -48
- package/src/hooks/useMarkState.ts +0 -100
- package/src/hooks/useViewCommands.ts +0 -36
package/README.md
CHANGED
|
@@ -4,11 +4,42 @@ Terminal content viewer for markdown, code, text, and tables.
|
|
|
4
4
|
|
|
5
5
|
Part of the [Tooee](https://github.com/gingerhendrix/tooee) monorepo. See the main repo for documentation.
|
|
6
6
|
|
|
7
|
+
## Command context
|
|
8
|
+
|
|
9
|
+
A `View` screen publishes two command-context slices.
|
|
10
|
+
|
|
11
|
+
`ctx.document` is the generic row-document contract from `@tooee/shell`, owned by
|
|
12
|
+
the document controller: `rowCount`, `cursor`, `activeKey`, `activeRow`,
|
|
13
|
+
`selection`, `selectedRows` and `toggledIndices`. Every row document has it, so
|
|
14
|
+
row actions read the cursor from there:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
handler: (ctx) => open(ctx.document?.activeRow)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`ctx.view` is content-only — what the viewer knows and the controller does not:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
interface ViewCommandContext {
|
|
24
|
+
content: AnyContent
|
|
25
|
+
format: string
|
|
26
|
+
title?: string
|
|
27
|
+
data?: unknown
|
|
28
|
+
reload: () => void
|
|
29
|
+
marks: {
|
|
30
|
+
setMarkSet(set: MarkSet): void
|
|
31
|
+
clearNamespace(namespace: string): void
|
|
32
|
+
clearAll(): void
|
|
33
|
+
userMarks: MarkSet[]
|
|
34
|
+
providerMarks: MarkSet[]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
7
39
|
## Headless view command context
|
|
8
40
|
|
|
9
41
|
Custom surfaces that behave like a view, but do not render the built-in `View`
|
|
10
|
-
component, can publish the
|
|
11
|
-
`useProvideViewCommandContext`:
|
|
42
|
+
component, can publish the `ctx.view` slice with `useProvideViewCommandContext`:
|
|
12
43
|
|
|
13
44
|
```tsx
|
|
14
45
|
import { useProvideViewCommandContext } from "@tooee/view"
|
|
@@ -16,18 +47,42 @@ import { useProvideViewCommandContext } from "@tooee/view"
|
|
|
16
47
|
useProvideViewCommandContext({
|
|
17
48
|
format: "stream-dashboard",
|
|
18
49
|
title: "Stream Dashboard",
|
|
19
|
-
nav,
|
|
20
50
|
data: { rowCount: rows.length },
|
|
21
|
-
extras: { activeRow, rowCount: rows.length },
|
|
22
51
|
})
|
|
23
52
|
```
|
|
24
53
|
|
|
25
|
-
The hook
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
The hook fills safe defaults for headless surfaces: synthetic custom content,
|
|
55
|
+
empty marks, and a no-op reload. Row state comes from `useDocumentController`,
|
|
56
|
+
whose `DocumentScreen` provides `ctx.document` — do not synthesize it here.
|
|
57
|
+
|
|
58
|
+
For tests or non-React integrations, `createViewCommandContext({ ... })` creates
|
|
59
|
+
the same object shape directly.
|
|
60
|
+
|
|
61
|
+
## Custom renderers
|
|
62
|
+
|
|
63
|
+
A custom renderer receives the content and the host's document controller. Its
|
|
64
|
+
rows are the content's plain-text lines — the unit navigation, search and copy
|
|
65
|
+
work in.
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
const KanbanRenderer: ContentRenderer = ({ content, document }) => (
|
|
69
|
+
<box onMouseDown={() => document.selectRow(0)}>
|
|
70
|
+
<text content={`cursor: ${document.activeIndex}`} />
|
|
71
|
+
</box>
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
A renderer that owns a `<row-document>` binds the controller directly — it
|
|
76
|
+
satisfies `DocumentBindings`, the same `{ ref, decorations, onMouseDown }` the
|
|
77
|
+
built-in `CodeView`, `MarkdownView` and `Table` renderers take:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<row-document
|
|
81
|
+
ref={document.ref}
|
|
82
|
+
decorations={document.decorations}
|
|
83
|
+
onMouseDown={document.onMouseDown}
|
|
84
|
+
>
|
|
85
|
+
```
|
|
30
86
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
the `mode` value; prefer the hook in React so mode cannot go stale.
|
|
87
|
+
`selectRow` stands down while a modal overlay is open, so it can be wired
|
|
88
|
+
unconditionally.
|
package/dist/View.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../src/View.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAmB,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AASxF,UAAU,SAAS;IACjB,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CACvD;AAED,wBAAgB,IAAI,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"View.d.ts","sourceRoot":"","sources":["../src/View.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAmB,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AASxF,UAAU,SAAS;IACjB,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CACvD;AAED,wBAAgB,IAAI,CAAC,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,SAAS,6BA0E1F"}
|
package/dist/View.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import { useTheme } from "@tooee/themes";
|
|
4
4
|
import { isCustomContent } from "./types.js";
|
|
5
5
|
import { useContentLoader } from "./hooks/useContentLoader.js";
|
|
@@ -22,6 +22,9 @@ export function View({ contentProvider, actions, renderers, codeBlockRenderers }
|
|
|
22
22
|
const clearAllUserMarks = useCallback(() => {
|
|
23
23
|
setUserMarks([]);
|
|
24
24
|
}, []);
|
|
25
|
+
// Mark sets are decoration layers; the controller composes them with the
|
|
26
|
+
// interaction layers it generates, ordered by each set's own priority.
|
|
27
|
+
const decorations = useMemo(() => [...providerMarks, ...userMarks], [providerMarks, userMarks]);
|
|
25
28
|
if (error) {
|
|
26
29
|
return (_jsx("box", { style: { flexDirection: "column" }, children: _jsx("text", { content: `Error: ${error}`, fg: theme.error }) }));
|
|
27
30
|
}
|
|
@@ -29,6 +32,7 @@ export function View({ contentProvider, actions, renderers, codeBlockRenderers }
|
|
|
29
32
|
return (_jsx("box", { children: _jsx("text", { content: "Loading...", fg: theme.textMuted }) }));
|
|
30
33
|
}
|
|
31
34
|
const shared = {
|
|
35
|
+
decorations,
|
|
32
36
|
providerMarks,
|
|
33
37
|
userMarks,
|
|
34
38
|
setMarkSet,
|
package/dist/View.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"View.js","sourceRoot":"","sources":["../src/View.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"View.js","sourceRoot":"","sources":["../src/View.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EA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U;YACb,OAAO,CACL,KAAC,eAAe,IAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,KAAM,MAAM,GAAI,CAC1F,CAAA;QACH,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,KAAC,WAAW,IAAC,OAAO,EAAE,OAAO,KAAM,MAAM,GAAI,CAAA;QACtD,KAAK,OAAO;YACV,OAAO,KAAC,YAAY,IAAC,OAAO,EAAE,OAAO,KAAM,MAAM,GAAI,CAAA;IACzD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ActionDefinition } from "@tooee/commands";
|
|
3
|
+
import type { StatusBarItem } from "@tooee/layout";
|
|
4
|
+
import type { MarkSet } from "@tooee/marks";
|
|
5
|
+
import { type DocumentController } from "@tooee/shell";
|
|
6
|
+
import type { AnyContent } from "../types.js";
|
|
7
|
+
export interface ViewScreenProps<T> {
|
|
8
|
+
content: AnyContent;
|
|
9
|
+
controller: DocumentController<T>;
|
|
10
|
+
streaming: boolean;
|
|
11
|
+
actions?: ActionDefinition[];
|
|
12
|
+
/** Content-shaped status (format, line/row counts), rendered before Mode. */
|
|
13
|
+
statusItems?: StatusBarItem[];
|
|
14
|
+
reload: () => void;
|
|
15
|
+
providerMarks: MarkSet[];
|
|
16
|
+
userMarks: MarkSet[];
|
|
17
|
+
setMarkSet: (set: MarkSet) => void;
|
|
18
|
+
clearMarkNamespace: (namespace: string) => void;
|
|
19
|
+
clearAllUserMarks: () => void;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The chrome every subview shares: `DocumentScreen` for the row-document half
|
|
24
|
+
* (theme/quit commands, actions, `ctx.document`, layout, standard status) plus
|
|
25
|
+
* the content-only `ctx.view` slice that viewers contribute on top.
|
|
26
|
+
*/
|
|
27
|
+
export declare function ViewScreen<T>({ content, controller, streaming, actions, statusItems, reload, providerMarks, userMarks, setMarkSet, clearMarkNamespace, clearAllUserMarks, children, }: ViewScreenProps<T>): ReactNode;
|
|
28
|
+
//# sourceMappingURL=ViewScreen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewScreen.d.ts","sourceRoot":"","sources":["../../src/components/ViewScreen.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,OAAO,EAAE,UAAU,CAAA;IACnB,UAAU,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAA;IACjC,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,6EAA6E;IAC7E,WAAW,CAAC,EAAE,aAAa,EAAE,CAAA;IAC7B,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,aAAa,EAAE,OAAO,EAAE,CAAA;IACxB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IAClC,kBAAkB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/C,iBAAiB,EAAE,MAAM,IAAI,CAAA;IAC7B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,EAC5B,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,MAAM,EACN,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,EAAE,eAAe,CAAC,CAAC,CAAC,aAiCpB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
+
import { DocumentScreen } from "@tooee/shell";
|
|
3
|
+
import { useProvideViewCommandContext } from "../hooks/useViewCommandContext.js";
|
|
4
|
+
/**
|
|
5
|
+
* The chrome every subview shares: `DocumentScreen` for the row-document half
|
|
6
|
+
* (theme/quit commands, actions, `ctx.document`, layout, standard status) plus
|
|
7
|
+
* the content-only `ctx.view` slice that viewers contribute on top.
|
|
8
|
+
*/
|
|
9
|
+
export function ViewScreen({ content, controller, streaming, actions, statusItems, reload, providerMarks, userMarks, setMarkSet, clearMarkNamespace, clearAllUserMarks, children, }) {
|
|
10
|
+
useProvideViewCommandContext({
|
|
11
|
+
content,
|
|
12
|
+
reload,
|
|
13
|
+
marks: {
|
|
14
|
+
setMarkSet,
|
|
15
|
+
clearNamespace: clearMarkNamespace,
|
|
16
|
+
clearAll: clearAllUserMarks,
|
|
17
|
+
userMarks,
|
|
18
|
+
providerMarks,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const items = [
|
|
22
|
+
...(statusItems ?? []),
|
|
23
|
+
...(streaming ? [{ label: "Status:", value: "streaming" }] : []),
|
|
24
|
+
];
|
|
25
|
+
return (_jsx(DocumentScreen, { controller: controller, titleBar: content.title
|
|
26
|
+
? { title: content.title, subtitle: content.format }
|
|
27
|
+
: { title: content.format }, statusItems: items, actions: actions, context: { kind: content.format, title: content.title, reload }, children: children }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ViewScreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewScreen.js","sourceRoot":"","sources":["../../src/components/ViewScreen.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,cAAc,EAA2B,MAAM,cAAc,CAAA;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAA;AAmBhF;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAI,EAC5B,OAAO,EACP,UAAU,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,MAAM,EACN,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACW;IACnB,4BAA4B,CAAC;QAC3B,OAAO;QACP,MAAM;QACN,KAAK,EAAE;YACL,UAAU;YACV,cAAc,EAAE,kBAAkB;YAClC,QAAQ,EAAE,iBAAiB;YAC3B,SAAS;YACT,aAAa;SACd;KACF,CAAC,CAAA;IAEF,MAAM,KAAK,GAAoB;QAC7B,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QACtB,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACjE,CAAA;IAED,OAAO,CACL,KAAC,cAAc,IACb,UAAU,EAAE,UAAU,EACtB,QAAQ,EACN,OAAO,CAAC,KAAK;YACX,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE;YACpD,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,EAE/B,WAAW,EAAE,KAAK,EAClB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,YAE9D,QAAQ,GACM,CAClB,CAAA;AACH,CAAC"}
|
|
@@ -3,6 +3,6 @@ import type { SubviewProps } from "./types.js";
|
|
|
3
3
|
interface CodeSubviewProps extends SubviewProps {
|
|
4
4
|
content: CodeContent | TextContent;
|
|
5
5
|
}
|
|
6
|
-
export declare function CodeSubview({ content,
|
|
6
|
+
export declare function CodeSubview({ content, decorations, actions, ...screen }: CodeSubviewProps): import("react").ReactNode;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=CodeSubview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/CodeSubview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/CodeSubview.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,OAAO,EAAE,WAAW,GAAG,WAAW,CAAA;CACnC;AAED,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,gBAAgB,6BAwCzF"}
|
|
@@ -1,95 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { CodeView } from "@tooee/renderers";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { actionsToContextMenuEntries, useContextMenu, useCopy, useNavigation } from "@tooee/shell";
|
|
9
|
-
import { findMatchingLines, useSearch } from "@tooee/search";
|
|
10
|
-
import { useMarkState } from "../../hooks/useMarkState.js";
|
|
11
|
-
import { useViewCommands } from "../../hooks/useViewCommands.js";
|
|
12
|
-
import { SubviewLayout } from "../SubviewLayout.js";
|
|
13
|
-
export function CodeSubview({ content, providerMarks, userMarks, setMarkSet, clearMarkNamespace, clearAllUserMarks, reload, streaming, actions, }) {
|
|
14
|
-
const { theme } = useTheme();
|
|
15
|
-
const docRef = useRef(null);
|
|
16
|
-
const hasModalOverlay = useHasModalOverlay();
|
|
17
|
-
const contextMenu = useContextMenu();
|
|
18
|
-
const { invoke } = useCommandContext();
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { CodeView, sourceLines, sourceLineAdapter } from "@tooee/renderers";
|
|
4
|
+
import { actionsToContextMenuEntries, useDocumentController } from "@tooee/shell";
|
|
5
|
+
import { useContentCommands } from "../../hooks/useContentCommands.js";
|
|
6
|
+
import { ViewScreen } from "../ViewScreen.js";
|
|
7
|
+
export function CodeSubview({ content, decorations, actions, ...screen }) {
|
|
19
8
|
const textContent = content.format === "code" ? content.code : content.text;
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
9
|
+
// One navigation row per physical source line; row index is the source line.
|
|
10
|
+
const lineRows = useMemo(() => sourceLines(textContent), [textContent]);
|
|
11
|
+
const { showLineNumbers } = useContentCommands({ content, textContent });
|
|
12
|
+
const contextMenu = useMemo(() => actionsToContextMenuEntries(actions), [actions]);
|
|
13
|
+
const document = useDocumentController({
|
|
14
|
+
rows: lineRows,
|
|
15
|
+
adapter: sourceLineAdapter,
|
|
24
16
|
multiSelect: true,
|
|
17
|
+
decorations,
|
|
18
|
+
contextMenu,
|
|
25
19
|
});
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
getRowText: (index) => lines[index] ?? "",
|
|
32
|
-
cursor: nav.cursor,
|
|
33
|
-
selection: nav.selection,
|
|
34
|
-
toggledIndices: nav.toggledIndices,
|
|
35
|
-
});
|
|
36
|
-
const layoutNav = { ...nav, ...search };
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (nav.cursor !== null) {
|
|
39
|
-
docRef.current?.scrollToRow(nav.cursor, "nearest");
|
|
40
|
-
}
|
|
41
|
-
}, [nav.cursor]);
|
|
42
|
-
const { themeName, showLineNumbers } = useViewCommands({ content, textContent, actions });
|
|
43
|
-
const markState = useMarkState({
|
|
44
|
-
nav,
|
|
45
|
-
search,
|
|
46
|
-
theme,
|
|
47
|
-
providerMarks,
|
|
48
|
-
userMarks,
|
|
49
|
-
});
|
|
50
|
-
useViewCommandContext({
|
|
51
|
-
content,
|
|
52
|
-
nav,
|
|
53
|
-
reload,
|
|
54
|
-
providerMarks,
|
|
55
|
-
userMarks,
|
|
56
|
-
setMarkSet,
|
|
57
|
-
clearMarkNamespace,
|
|
58
|
-
clearAllUserMarks,
|
|
59
|
-
});
|
|
60
|
-
const text = content.format === "code" ? content.code : content.text;
|
|
61
|
-
const menuEntries = useMemo(() => actionsToContextMenuEntries(actions), [actions]);
|
|
62
|
-
// Left-click selects the clicked line; right-click selects it and opens the
|
|
63
|
-
// same app-provided action menu as table rows. Both stand down while a modal
|
|
64
|
-
// overlay is up (theme picker, command palette, Ask/Choose), matching the
|
|
65
|
-
// keyboard stand-down and avoiding covered-app mutations.
|
|
66
|
-
const setCursor = nav.setCursor;
|
|
67
|
-
const openContextMenu = contextMenu.open;
|
|
68
|
-
const handleRowClick = useCallback((index) => {
|
|
69
|
-
if (hasModalOverlay)
|
|
70
|
-
return;
|
|
71
|
-
setCursor(index);
|
|
72
|
-
}, [hasModalOverlay, setCursor]);
|
|
73
|
-
const handleRowContextMenu = useCallback((index, x, y) => {
|
|
74
|
-
if (hasModalOverlay)
|
|
75
|
-
return;
|
|
76
|
-
setCursor(index);
|
|
77
|
-
openContextMenu(x, y, menuEntries, invoke);
|
|
78
|
-
}, [hasModalOverlay, setCursor, openContextMenu, menuEntries, invoke]);
|
|
79
|
-
const extraStatusItems = useMemo(() => {
|
|
80
|
-
const selectionCount = nav.selection != null ? nav.selection.end - nav.selection.start + 1 : 0;
|
|
81
|
-
const toggledCount = nav.toggledIndices.size;
|
|
82
|
-
const selectionItems = toggledCount > 0
|
|
83
|
-
? [{ label: "Selected:", value: String(toggledCount) }]
|
|
84
|
-
: selectionCount > 0
|
|
85
|
-
? [{ label: "Selected:", value: String(selectionCount) }]
|
|
86
|
-
: [];
|
|
87
|
-
return [
|
|
88
|
-
{ label: "Format:", value: content.format },
|
|
89
|
-
{ label: "Lines:", value: String(lineCount) },
|
|
90
|
-
...selectionItems,
|
|
91
|
-
];
|
|
92
|
-
}, [content.format, lineCount, nav.selection, nav.toggledIndices]);
|
|
93
|
-
return (_jsx(SubviewLayout, { content: content, nav: layoutNav, streaming: streaming, themeName: themeName, extraStatusItems: extraStatusItems, children: _jsx(CodeView, { content: text, language: content.format === "code" ? content.language : undefined, showLineNumbers: showLineNumbers, marks: markState, docRef: docRef, onRowClick: handleRowClick, onRowContextMenu: handleRowContextMenu }) }));
|
|
20
|
+
const statusItems = useMemo(() => [
|
|
21
|
+
{ label: "Format:", value: content.format },
|
|
22
|
+
{ label: "Lines:", value: String(lineRows.length) },
|
|
23
|
+
], [content.format, lineRows.length]);
|
|
24
|
+
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(CodeView, { content: textContent, language: content.format === "code" ? content.language : undefined, showLineNumbers: showLineNumbers, document: document }) }));
|
|
94
25
|
}
|
|
95
26
|
//# sourceMappingURL=CodeSubview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/CodeSubview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CodeSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/CodeSubview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAsB,MAAM,kBAAkB,CAAA;AAC/F,OAAO,EAAE,2BAA2B,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AAEjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE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AW,EACpB,QAAQ,EAAE,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAClE,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,GAClB,GACS,CACd,CAAA;AACH,CAAC"}
|
|
@@ -4,6 +4,6 @@ interface CustomSubviewProps extends SubviewProps {
|
|
|
4
4
|
content: CustomContent;
|
|
5
5
|
renderers?: Record<string, ContentRenderer>;
|
|
6
6
|
}
|
|
7
|
-
export declare function CustomSubview({ content,
|
|
7
|
+
export declare function CustomSubview({ content, decorations, actions, renderers, ...screen }: CustomSubviewProps): import("react").ReactNode;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=CustomSubview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/CustomSubview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CustomSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/CustomSubview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,kBAAmB,SAAQ,YAAY;IAC/C,OAAO,EAAE,aAAa,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC5C;AAED,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,WAAW,EACX,OAAO,EACP,SAAS,EACT,GAAG,MAAM,EACV,EAAE,kBAAkB,6BAwCpB"}
|
|
@@ -1,102 +1,27 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { CodeView } from "@tooee/renderers";
|
|
4
|
-
import {
|
|
5
|
-
import { useHasModalOverlay } from "@tooee/overlays";
|
|
6
|
-
import { useViewCommandContext } from "../../hooks/useViewCommandContext.js";
|
|
7
|
-
import { useCopy, useNavigation } from "@tooee/shell";
|
|
8
|
-
import { findMatchingLines, useSearch } from "@tooee/search";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { CodeView, sourceLines, sourceLineAdapter } from "@tooee/renderers";
|
|
4
|
+
import { useDocumentController } from "@tooee/shell";
|
|
9
5
|
import { getTextContent } from "../../types.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export function CustomSubview({ content, providerMarks, userMarks, setMarkSet, clearMarkNamespace, clearAllUserMarks, reload, streaming, actions, renderers, }) {
|
|
14
|
-
const { theme } = useTheme();
|
|
15
|
-
const docRef = useRef(null);
|
|
16
|
-
const hasModalOverlay = useHasModalOverlay();
|
|
6
|
+
import { useContentCommands } from "../../hooks/useContentCommands.js";
|
|
7
|
+
import { ViewScreen } from "../ViewScreen.js";
|
|
8
|
+
export function CustomSubview({ content, decorations, actions, renderers, ...screen }) {
|
|
17
9
|
const textContent = useMemo(() => getTextContent(content), [content]);
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
// Fallback rows are source lines; row index is the source line.
|
|
11
|
+
const lineRows = useMemo(() => sourceLines(textContent), [textContent]);
|
|
12
|
+
useContentCommands({ content, textContent });
|
|
13
|
+
// Custom content has no action rows of its own, so no context menu is bound.
|
|
14
|
+
const document = useDocumentController({
|
|
15
|
+
rows: lineRows,
|
|
16
|
+
adapter: sourceLineAdapter,
|
|
22
17
|
multiSelect: true,
|
|
18
|
+
decorations,
|
|
23
19
|
});
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
useCopy({
|
|
29
|
-
getRowText: (index) => lines[index] ?? "",
|
|
30
|
-
cursor: nav.cursor,
|
|
31
|
-
selection: nav.selection,
|
|
32
|
-
toggledIndices: nav.toggledIndices,
|
|
33
|
-
});
|
|
34
|
-
const layoutNav = { ...nav, ...search };
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (nav.cursor !== null) {
|
|
37
|
-
docRef.current?.scrollToRow(nav.cursor, "nearest");
|
|
38
|
-
}
|
|
39
|
-
}, [nav.cursor]);
|
|
40
|
-
const { themeName } = useViewCommands({ content, textContent, actions });
|
|
41
|
-
const markState = useMarkState({
|
|
42
|
-
nav,
|
|
43
|
-
search,
|
|
44
|
-
theme,
|
|
45
|
-
providerMarks,
|
|
46
|
-
userMarks,
|
|
47
|
-
});
|
|
48
|
-
useViewCommandContext({
|
|
49
|
-
content,
|
|
50
|
-
nav,
|
|
51
|
-
reload,
|
|
52
|
-
providerMarks,
|
|
53
|
-
userMarks,
|
|
54
|
-
setMarkSet,
|
|
55
|
-
clearMarkNamespace,
|
|
56
|
-
clearAllUserMarks,
|
|
57
|
-
});
|
|
58
|
-
const extraStatusItems = useMemo(() => {
|
|
59
|
-
const selectionCount = nav.selection != null ? nav.selection.end - nav.selection.start + 1 : 0;
|
|
60
|
-
const toggledCount = nav.toggledIndices.size;
|
|
61
|
-
const selectionItems = toggledCount > 0
|
|
62
|
-
? [{ label: "Selected:", value: String(toggledCount) }]
|
|
63
|
-
: selectionCount > 0
|
|
64
|
-
? [{ label: "Selected:", value: String(selectionCount) }]
|
|
65
|
-
: [];
|
|
66
|
-
return [
|
|
67
|
-
{ label: "Format:", value: content.format },
|
|
68
|
-
{ label: "Lines:", value: String(lineCount) },
|
|
69
|
-
...selectionItems,
|
|
70
|
-
];
|
|
71
|
-
}, [content.format, lineCount, nav.selection, nav.toggledIndices]);
|
|
72
|
-
// Left-click selection for custom renderers. The framework does not own the
|
|
73
|
-
// renderer's markup, so it cannot map clicks to rows itself; instead it hands
|
|
74
|
-
// the renderer this callback (the mouse equivalent of the keyboard cursor
|
|
75
|
-
// move) to call from its own handlers. Guarded like the built-in views so a
|
|
76
|
-
// click never mutates the covered app while a modal overlay is up.
|
|
77
|
-
const setCursor = nav.setCursor;
|
|
78
|
-
const handleSelectRow = useCallback((index) => {
|
|
79
|
-
if (hasModalOverlay)
|
|
80
|
-
return;
|
|
81
|
-
setCursor(index);
|
|
82
|
-
}, [hasModalOverlay, setCursor]);
|
|
20
|
+
const statusItems = useMemo(() => [
|
|
21
|
+
{ label: "Format:", value: content.format },
|
|
22
|
+
{ label: "Lines:", value: String(lineRows.length) },
|
|
23
|
+
], [content.format, lineRows.length]);
|
|
83
24
|
const customRenderer = renderers?.[content.format];
|
|
84
|
-
|
|
85
|
-
const cursorLine = nav.cursor ?? undefined;
|
|
86
|
-
const selectionStart = nav.selection?.start ?? undefined;
|
|
87
|
-
const selectionEnd = nav.selection?.end ?? undefined;
|
|
88
|
-
return (_jsx(SubviewLayout, { content: content, nav: layoutNav, streaming: streaming, themeName: themeName, extraStatusItems: extraStatusItems, children: customRenderer({
|
|
89
|
-
content,
|
|
90
|
-
lineCount,
|
|
91
|
-
cursor: cursorLine,
|
|
92
|
-
selectionStart,
|
|
93
|
-
selectionEnd,
|
|
94
|
-
marks: markState,
|
|
95
|
-
onSelectRow: handleSelectRow,
|
|
96
|
-
}) }));
|
|
97
|
-
}
|
|
98
|
-
// No renderer for this custom format -- fall back to text
|
|
99
|
-
const text = getTextContent(content);
|
|
100
|
-
return (_jsx(SubviewLayout, { content: content, nav: layoutNav, streaming: streaming, themeName: themeName, extraStatusItems: extraStatusItems, children: _jsx(CodeView, { content: text, showLineNumbers: false, marks: markState, docRef: docRef }) }));
|
|
25
|
+
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: customRenderer ? (customRenderer({ content, document })) : (_jsx(CodeView, { content: textContent, showLineNumbers: false, document: document })) }));
|
|
101
26
|
}
|
|
102
27
|
//# sourceMappingURL=CustomSubview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/CustomSubview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,CAAC,MAAM,CAAC,EAAE;KACpD,EACD,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAClC,CAAA;IAED,MAAM,cAAc,GAAG,SAAS,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAElD,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,QAAQ,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,KACpB,MAAM,YAET,cAAc,CAAC,CAAC,CAAC,CAChB,cAAc,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CACtC,CAAC,CAAC,CAAC,CACF,KAAC,QAAQ,IAAC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAI,CAC/E,GACU,CACd,CAAA;AACH,CAAC"}
|
|
@@ -5,6 +5,6 @@ interface MarkdownSubviewProps extends SubviewProps {
|
|
|
5
5
|
content: MarkdownContent;
|
|
6
6
|
codeBlockRenderers?: Record<string, CodeBlockRenderer>;
|
|
7
7
|
}
|
|
8
|
-
export declare function MarkdownSubview({ content, codeBlockRenderers,
|
|
8
|
+
export declare function MarkdownSubview({ content, codeBlockRenderers, decorations, actions, ...screen }: MarkdownSubviewProps): import("react").ReactNode;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=MarkdownSubview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/MarkdownSubview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarkdownSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/MarkdownSubview.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,iBAAiB,EAEvB,MAAM,kBAAkB,CAAA;AAOzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAGrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,oBAAqB,SAAQ,YAAY;IACjD,OAAO,EAAE,eAAe,CAAA;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;CACvD;AAeD,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,GAAG,MAAM,EACV,EAAE,oBAAoB,6BAsEtB"}
|