@tooee/view 0.1.22 → 0.2.1
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
|
@@ -1,66 +1,38 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useViewCommandContext } from "../../hooks/useViewCommandContext.js";
|
|
9
|
-
import { actionsToContextMenuEntries, useContextMenu, useCopy, useNavigation } from "@tooee/shell";
|
|
10
|
-
import { useSearch } from "@tooee/search";
|
|
11
|
-
import { useMarkState } from "../../hooks/useMarkState.js";
|
|
12
|
-
import { useViewCommands } from "../../hooks/useViewCommands.js";
|
|
13
|
-
import { SubviewLayout } from "../SubviewLayout.js";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import { MarkdownView, flattenMarkdown, getFlatBlockText, } from "@tooee/renderers";
|
|
4
|
+
import { useCommand } from "@tooee/commands";
|
|
5
|
+
import { actionsToContextMenuEntries, useDocumentController, } from "@tooee/shell";
|
|
6
|
+
import { useContentCommands } from "../../hooks/useContentCommands.js";
|
|
7
|
+
import { ViewScreen } from "../ViewScreen.js";
|
|
14
8
|
/** Columns moved per h/l press when scrolling a wide block horizontally. */
|
|
15
9
|
const BLOCK_HSCROLL_STEP = 4;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Blocks are the row unit. `getFlatBlockText` keeps search/copy in step with the
|
|
12
|
+
* source mapping (notably for synthetic bullet rows), and `getSource` projects
|
|
13
|
+
* each block's Markdown provenance onto the controller's anchors.
|
|
14
|
+
*/
|
|
15
|
+
const MARKDOWN_BLOCK_ADAPTER = {
|
|
16
|
+
getText: (block) => getFlatBlockText(block),
|
|
17
|
+
getSource: (block) => block.source,
|
|
18
|
+
};
|
|
19
|
+
export function MarkdownSubview({ content, codeBlockRenderers, decorations, actions, ...screen }) {
|
|
22
20
|
const textContent = content.markdown;
|
|
23
21
|
const lineCount = useMemo(() => textContent.split("\n").length, [textContent]);
|
|
24
|
-
const blocks = useMemo(() =>
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
const blocks = useMemo(() => flattenMarkdown(content.markdown), [content.markdown]);
|
|
23
|
+
const { showLineNumbers } = useContentCommands({ content, textContent });
|
|
24
|
+
const contextMenu = useMemo(() => actionsToContextMenuEntries(actions), [actions]);
|
|
25
|
+
const document = useDocumentController({
|
|
26
|
+
rows: blocks,
|
|
27
|
+
adapter: MARKDOWN_BLOCK_ADAPTER,
|
|
27
28
|
multiSelect: true,
|
|
29
|
+
decorations,
|
|
30
|
+
contextMenu,
|
|
28
31
|
});
|
|
29
|
-
const search = useSearch({
|
|
30
|
-
match: (query) => {
|
|
31
|
-
const lowerQuery = query.toLowerCase();
|
|
32
|
-
return blocks.flatMap((block, index) => {
|
|
33
|
-
const { token } = block;
|
|
34
|
-
const raw = "raw" in token && typeof token.raw === "string" ? token.raw : "";
|
|
35
|
-
return raw.toLowerCase().includes(lowerQuery) ? [index] : [];
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
onJump: nav.setCursor,
|
|
39
|
-
});
|
|
40
|
-
useCopy({
|
|
41
|
-
getRowText: (index) => {
|
|
42
|
-
const block = blocks[index];
|
|
43
|
-
if (!block)
|
|
44
|
-
return "";
|
|
45
|
-
const { token } = block;
|
|
46
|
-
return "raw" in token && typeof token.raw === "string" ? token.raw : "";
|
|
47
|
-
},
|
|
48
|
-
cursor: nav.cursor,
|
|
49
|
-
selection: nav.selection,
|
|
50
|
-
toggledIndices: nav.toggledIndices,
|
|
51
|
-
});
|
|
52
|
-
const layoutNav = { ...nav, ...search };
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (nav.cursor !== null) {
|
|
55
|
-
docRef.current?.scrollToRow(nav.cursor, "nearest");
|
|
56
|
-
}
|
|
57
|
-
}, [nav.cursor]);
|
|
58
|
-
// Horizontal panning for wide blocks (mermaid diagrams and code blocks).
|
|
59
|
-
// Blocks that can overflow horizontally register their text-buffer
|
|
60
|
-
// renderable by block index; h/l in cursor mode pans the block under the
|
|
61
|
-
// nav cursor via `scrollX` (the setter clamps to the content width).
|
|
62
32
|
const hScrollableBlocksRef = useRef(new Map());
|
|
63
|
-
const cursorScrollable = () =>
|
|
33
|
+
const cursorScrollable = () => document.activeIndex !== null
|
|
34
|
+
? hScrollableBlocksRef.current.get(document.activeIndex)
|
|
35
|
+
: undefined;
|
|
64
36
|
useCommand({
|
|
65
37
|
id: "block-scroll-left",
|
|
66
38
|
title: "Scroll block left",
|
|
@@ -85,56 +57,10 @@ export function MarkdownSubview({ content, codeBlockRenderers, providerMarks, us
|
|
|
85
57
|
target.scrollX += BLOCK_HSCROLL_STEP;
|
|
86
58
|
},
|
|
87
59
|
});
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const setCursor = nav.setCursor;
|
|
94
|
-
const openContextMenu = contextMenu.open;
|
|
95
|
-
const handleRowClick = useCallback((index) => {
|
|
96
|
-
if (hasModalOverlay)
|
|
97
|
-
return;
|
|
98
|
-
setCursor(index);
|
|
99
|
-
}, [hasModalOverlay, setCursor]);
|
|
100
|
-
const handleRowContextMenu = useCallback((index, x, y) => {
|
|
101
|
-
if (hasModalOverlay)
|
|
102
|
-
return;
|
|
103
|
-
setCursor(index);
|
|
104
|
-
openContextMenu(x, y, menuEntries, invoke);
|
|
105
|
-
}, [hasModalOverlay, setCursor, openContextMenu, menuEntries, invoke]);
|
|
106
|
-
const { themeName, showLineNumbers } = useViewCommands({ content, textContent, actions });
|
|
107
|
-
const markState = useMarkState({
|
|
108
|
-
nav,
|
|
109
|
-
search,
|
|
110
|
-
theme,
|
|
111
|
-
providerMarks,
|
|
112
|
-
userMarks,
|
|
113
|
-
});
|
|
114
|
-
useViewCommandContext({
|
|
115
|
-
content,
|
|
116
|
-
nav,
|
|
117
|
-
reload,
|
|
118
|
-
providerMarks,
|
|
119
|
-
userMarks,
|
|
120
|
-
setMarkSet,
|
|
121
|
-
clearMarkNamespace,
|
|
122
|
-
clearAllUserMarks,
|
|
123
|
-
});
|
|
124
|
-
const extraStatusItems = useMemo(() => {
|
|
125
|
-
const selectionCount = nav.selection != null ? nav.selection.end - nav.selection.start + 1 : 0;
|
|
126
|
-
const toggledCount = nav.toggledIndices.size;
|
|
127
|
-
const selectionItems = toggledCount > 0
|
|
128
|
-
? [{ label: "Selected:", value: String(toggledCount) }]
|
|
129
|
-
: selectionCount > 0
|
|
130
|
-
? [{ label: "Selected:", value: String(selectionCount) }]
|
|
131
|
-
: [];
|
|
132
|
-
return [
|
|
133
|
-
{ label: "Format:", value: content.format },
|
|
134
|
-
{ label: "Lines:", value: String(lineCount) },
|
|
135
|
-
...selectionItems,
|
|
136
|
-
];
|
|
137
|
-
}, [content.format, lineCount, nav.selection, nav.toggledIndices]);
|
|
138
|
-
return (_jsx(SubviewLayout, { content: content, nav: layoutNav, streaming: streaming, themeName: themeName, extraStatusItems: extraStatusItems, children: _jsx(MarkdownView, { content: content.markdown, showLineNumbers: showLineNumbers, marks: markState, docRef: docRef, hScrollableBlocksRef: hScrollableBlocksRef, codeBlockRenderers: codeBlockRenderers, onRowClick: handleRowClick, onRowContextMenu: handleRowContextMenu }) }));
|
|
60
|
+
const statusItems = useMemo(() => [
|
|
61
|
+
{ label: "Format:", value: content.format },
|
|
62
|
+
{ label: "Lines:", value: String(lineCount) },
|
|
63
|
+
], [content.format, lineCount]);
|
|
64
|
+
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(MarkdownView, { content: content.markdown, blocks: blocks, showLineNumbers: showLineNumbers, document: document, hScrollableBlocksRef: hScrollableBlocksRef, codeBlockRenderers: codeBlockRenderers }) }));
|
|
139
65
|
}
|
|
140
66
|
//# sourceMappingURL=MarkdownSubview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/MarkdownSubview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"MarkdownSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/MarkdownSubview.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,EACL,YAAY,EACZ,eAAe,EACf,gBAAgB,GAGjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,GAEtB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAQ7C,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAE5B;;;;GAIG;AACH,MAAM,sBAAsB,GAAkC;IAC5D,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC;IAC3C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM;CACnC,CAAA;AAED,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,GAAG,MAAM,EACY;IACrB,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAA;IACpC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAA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AG,gBAAgB,EAAE,CAAA;YACjC,IAAI,MAAM;gBAAE,MAAM,CAAC,OAAO,IAAI,kBAAkB,CAAA;QAClD,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,WAAW,GAAG,OAAO,CACzB,GAAG,EAAE,CAAC;QACJ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;QAC3C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE;KAC9C,EACD,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAC5B,CAAA;IAED,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,QAAQ,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,KACpB,MAAM,YAEV,KAAC,YAAY,IACX,OAAO,EAAE,OAAO,CAAC,QAAQ,EACzB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,QAAQ,EAAE,QAAQ,EAClB,oBAAoB,EAAE,oBAAoB,EAC1C,kBAAkB,EAAE,kBAAkB,GACtC,GACS,CACd,CAAA;AACH,CAAC"}
|
|
@@ -3,6 +3,6 @@ import type { SubviewProps } from "./types.js";
|
|
|
3
3
|
interface TableSubviewProps extends SubviewProps {
|
|
4
4
|
content: TableContent;
|
|
5
5
|
}
|
|
6
|
-
export declare function TableSubview({ content,
|
|
6
|
+
export declare function TableSubview({ content, decorations, actions, ...screen }: TableSubviewProps): import("react").ReactNode;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=TableSubview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/TableSubview.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableSubview.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/TableSubview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,UAAU,iBAAkB,SAAQ,YAAY;IAC9C,OAAO,EAAE,YAAY,CAAA;CACtB;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,iBAAiB,6BA0C3F"}
|
|
@@ -1,132 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo } from "react";
|
|
3
3
|
import { Table } from "@tooee/renderers";
|
|
4
|
-
import {
|
|
5
|
-
import { useCommandContext } from "@tooee/commands";
|
|
6
|
-
import { useHasModalOverlay } from "@tooee/overlays";
|
|
7
|
-
import { useViewCommandContext } from "../../hooks/useViewCommandContext.js";
|
|
8
|
-
import { actionsToContextMenuEntries, useContextMenu, useCopy, useNavigation } from "@tooee/shell";
|
|
9
|
-
import { useSearch } from "@tooee/search";
|
|
4
|
+
import { actionsToContextMenuEntries, useDocumentController } from "@tooee/shell";
|
|
10
5
|
import { getTextContent } from "../../types.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
export function TableSubview({ content, providerMarks, userMarks, setMarkSet, clearMarkNamespace, clearAllUserMarks, reload, streaming, actions, }) {
|
|
15
|
-
const { theme } = useTheme();
|
|
16
|
-
const docRef = useRef(null);
|
|
6
|
+
import { useContentCommands } from "../../hooks/useContentCommands.js";
|
|
7
|
+
import { ViewScreen } from "../ViewScreen.js";
|
|
8
|
+
export function TableSubview({ content, decorations, actions, ...screen }) {
|
|
17
9
|
const textContent = useMemo(() => getTextContent(content), [content]);
|
|
18
|
-
const
|
|
19
|
-
const {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const { showLineNumbers } = useContentCommands({ content, textContent });
|
|
11
|
+
const { columns, rows } = content;
|
|
12
|
+
const adapter = useMemo(() => ({
|
|
13
|
+
getText: (row) => columns.map((column) => stringifyRowCell(row[column.key])).join("\t"),
|
|
14
|
+
}), [columns]);
|
|
15
|
+
const contextMenu = useMemo(() => actionsToContextMenuEntries(actions), [actions]);
|
|
16
|
+
const document = useDocumentController({
|
|
17
|
+
rows,
|
|
18
|
+
adapter,
|
|
23
19
|
multiSelect: true,
|
|
20
|
+
decorations,
|
|
21
|
+
contextMenu,
|
|
24
22
|
});
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
onJump: nav.setCursor,
|
|
33
|
-
});
|
|
34
|
-
useCopy({
|
|
35
|
-
getRowText: (index) => content.columns
|
|
36
|
-
.map((column) => stringifyRowCell(content.rows[index]?.[column.key]))
|
|
37
|
-
.join("\t"),
|
|
38
|
-
cursor: nav.cursor,
|
|
39
|
-
selection: nav.selection,
|
|
40
|
-
toggledIndices: nav.toggledIndices,
|
|
41
|
-
});
|
|
42
|
-
const layoutNav = { ...nav, ...search };
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (nav.cursor !== null) {
|
|
45
|
-
docRef.current?.scrollToRow(nav.cursor, "nearest");
|
|
46
|
-
}
|
|
47
|
-
}, [nav.cursor]);
|
|
48
|
-
const { themeName, showLineNumbers } = useViewCommands({ content, textContent, actions });
|
|
49
|
-
const markState = useMarkState({
|
|
50
|
-
nav,
|
|
51
|
-
search,
|
|
52
|
-
theme,
|
|
53
|
-
providerMarks,
|
|
54
|
-
userMarks,
|
|
55
|
-
});
|
|
56
|
-
function getActiveRow() {
|
|
57
|
-
if (nav.cursor === null)
|
|
58
|
-
return undefined;
|
|
59
|
-
return content.rows[nav.cursor];
|
|
60
|
-
}
|
|
61
|
-
function getSelectedRows() {
|
|
62
|
-
if (nav.toggledIndices.size) {
|
|
63
|
-
return Array.from(nav.toggledIndices)
|
|
64
|
-
.map((i) => content.rows[i])
|
|
65
|
-
.filter(Boolean);
|
|
66
|
-
}
|
|
67
|
-
if (nav.selection) {
|
|
68
|
-
const start = nav.selection.start;
|
|
69
|
-
const end = nav.selection.end;
|
|
70
|
-
return content.rows.slice(start, end + 1);
|
|
71
|
-
}
|
|
72
|
-
return [];
|
|
73
|
-
}
|
|
74
|
-
useViewCommandContext({
|
|
75
|
-
content,
|
|
76
|
-
nav,
|
|
77
|
-
reload,
|
|
78
|
-
providerMarks,
|
|
79
|
-
userMarks,
|
|
80
|
-
setMarkSet,
|
|
81
|
-
clearMarkNamespace,
|
|
82
|
-
clearAllUserMarks,
|
|
83
|
-
extras: {
|
|
84
|
-
activeRow: getActiveRow(),
|
|
85
|
-
selectedRows: getSelectedRows(),
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
// Row-scoped context-menu entries come from the app-provided actions.
|
|
89
|
-
const menuEntries = useMemo(() => actionsToContextMenuEntries(actions), [actions]);
|
|
90
|
-
// Row mouse handlers stand down while a modal overlay (theme picker, command
|
|
91
|
-
// palette, Ask/Choose overlays, the context menu itself) is up: centered
|
|
92
|
-
// overlays leave clickable margins around them, and mouse events route
|
|
93
|
-
// through the hit-grid, bypassing command-surface arbitration. Memoized so
|
|
94
|
-
// Table's rowElements memo keeps doing its job.
|
|
95
|
-
const setCursor = nav.setCursor;
|
|
96
|
-
const openContextMenu = contextMenu.open;
|
|
97
|
-
const handleRowClick = useCallback((index) => {
|
|
98
|
-
if (hasModalOverlay)
|
|
99
|
-
return;
|
|
100
|
-
setCursor(index);
|
|
101
|
-
}, [hasModalOverlay, setCursor]);
|
|
102
|
-
const handleRowContextMenu = useCallback((index, x, y) => {
|
|
103
|
-
if (hasModalOverlay)
|
|
104
|
-
return;
|
|
105
|
-
setCursor(index);
|
|
106
|
-
openContextMenu(x, y, menuEntries, invoke);
|
|
107
|
-
}, [hasModalOverlay, setCursor, openContextMenu, menuEntries, invoke]);
|
|
108
|
-
const extraStatusItems = useMemo(() => {
|
|
109
|
-
const selectionCount = nav.selection != null ? nav.selection.end - nav.selection.start + 1 : 0;
|
|
110
|
-
const toggledCount = nav.toggledIndices.size;
|
|
111
|
-
const selectionItems = toggledCount > 0
|
|
112
|
-
? [{ label: "Selected:", value: String(toggledCount) }]
|
|
113
|
-
: selectionCount > 0
|
|
114
|
-
? [{ label: "Selected:", value: String(selectionCount) }]
|
|
115
|
-
: [];
|
|
116
|
-
return [
|
|
117
|
-
{ label: "Format:", value: content.format },
|
|
118
|
-
{ label: "Rows:", value: String(content.rows.length) },
|
|
119
|
-
{ label: "Cols:", value: String(content.columns.length) },
|
|
120
|
-
...selectionItems,
|
|
121
|
-
];
|
|
122
|
-
}, [
|
|
123
|
-
content.format,
|
|
124
|
-
content.rows.length,
|
|
125
|
-
content.columns.length,
|
|
126
|
-
nav.selection,
|
|
127
|
-
nav.toggledIndices,
|
|
128
|
-
]);
|
|
129
|
-
return (_jsx(SubviewLayout, { content: content, nav: layoutNav, streaming: streaming, themeName: themeName, extraStatusItems: extraStatusItems, children: _jsx(Table, { columns: content.columns, rows: content.rows, showLineNumbers: showLineNumbers, marks: markState, docRef: docRef, onRowClick: handleRowClick, onRowContextMenu: handleRowContextMenu }) }));
|
|
23
|
+
const statusItems = useMemo(() => [
|
|
24
|
+
{ label: "Format:", value: content.format },
|
|
25
|
+
{ label: "Rows:", value: String(rows.length) },
|
|
26
|
+
{ label: "Cols:", value: String(columns.length) },
|
|
27
|
+
], [content.format, rows.length, columns.length]);
|
|
28
|
+
return (_jsx(ViewScreen, { content: content, controller: document, actions: actions, statusItems: statusItems, ...screen, children: _jsx(Table, { columns: columns, rows: rows, showLineNumbers: showLineNumbers, document: document }) }));
|
|
130
29
|
}
|
|
131
30
|
function stringifyRowCell(value) {
|
|
132
31
|
if (value == null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableSubview.js","sourceRoot":"","sources":["../../../src/components/subviews/TableSubview.tsx"],"names":[],"mappings":";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@@ -2,6 +2,5 @@ export { MarkdownSubview } from "./MarkdownSubview.js";
|
|
|
2
2
|
export { CodeSubview } from "./CodeSubview.js";
|
|
3
3
|
export { TableSubview } from "./TableSubview.js";
|
|
4
4
|
export { CustomSubview } from "./CustomSubview.js";
|
|
5
|
-
export { SubviewLayout } from "../SubviewLayout.js";
|
|
6
5
|
export type { SubviewProps } from "./types.js";
|
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -2,5 +2,4 @@ export { MarkdownSubview } from "./MarkdownSubview.js";
|
|
|
2
2
|
export { CodeSubview } from "./CodeSubview.js";
|
|
3
3
|
export { TableSubview } from "./TableSubview.js";
|
|
4
4
|
export { CustomSubview } from "./CustomSubview.js";
|
|
5
|
-
export { SubviewLayout } from "../SubviewLayout.js";
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/subviews/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/subviews/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { MarkSet } from "@tooee/marks";
|
|
2
2
|
import type { ActionDefinition } from "@tooee/commands";
|
|
3
|
+
import type { DecorationLayer } from "@tooee/renderers";
|
|
3
4
|
import type { AnyContent } from "../../types.js";
|
|
4
5
|
export interface SubviewProps {
|
|
5
6
|
content: AnyContent;
|
|
7
|
+
/**
|
|
8
|
+
* Provider and user mark sets as decoration layers. They compose with the
|
|
9
|
+
* interaction layers (search, selection, cursor) the controller generates.
|
|
10
|
+
*/
|
|
11
|
+
decorations: DecorationLayer[];
|
|
6
12
|
providerMarks: MarkSet[];
|
|
7
13
|
userMarks: MarkSet[];
|
|
8
14
|
setMarkSet: (set: MarkSet) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/subviews/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAA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|
|
|
1
|
-
import type { ContentProvider } from "./types.js";
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import type { ContentFormat, ContentProvider } from "./types.js";
|
|
2
|
+
export interface CreateProviderOptions {
|
|
3
|
+
renderer?: ContentFormat;
|
|
4
|
+
}
|
|
5
|
+
export declare function createFileProvider(filePath: string, options?: CreateProviderOptions): ContentProvider;
|
|
6
|
+
export declare function createStdinProvider(options?: CreateProviderOptions): ContentProvider;
|
|
4
7
|
export declare function createTableFileProvider(filePath: string): ContentProvider;
|
|
5
8
|
export declare function createTableStdinProvider(): ContentProvider;
|
|
6
9
|
//# sourceMappingURL=default-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"default-provider.d.ts","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEzE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,aAAa,CAAA;CACzB;AAmED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,qBAA0B,GAClC,eAAe,CAYjB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,qBAA0B,GAAG,eAAe,CAQxF;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAEzE;AAED,wBAAgB,wBAAwB,IAAI,eAAe,CAE1D"}
|
package/dist/default-provider.js
CHANGED
|
@@ -41,56 +41,46 @@ function detectFormat(filePath) {
|
|
|
41
41
|
return { format: "code", language };
|
|
42
42
|
return { format: "text" };
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
function contentFromText(text, format, title, language) {
|
|
45
|
+
switch (format) {
|
|
46
|
+
case "markdown":
|
|
47
|
+
return { format: "markdown", markdown: text, title };
|
|
48
|
+
case "code":
|
|
49
|
+
return { format: "code", code: text, language, title };
|
|
50
|
+
case "table": {
|
|
51
|
+
const parsed = parseAuto(text);
|
|
52
|
+
return { format: "table", columns: parsed.columns, rows: parsed.rows, title };
|
|
53
|
+
}
|
|
54
|
+
case "text":
|
|
55
|
+
default:
|
|
56
|
+
return { format: "text", text, title };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function createFileProvider(filePath, options = {}) {
|
|
45
60
|
return {
|
|
46
61
|
async load() {
|
|
47
|
-
const
|
|
62
|
+
const detected = detectFormat(filePath);
|
|
63
|
+
const format = options.renderer ?? detected.format;
|
|
48
64
|
const title = filePath.split("/").pop();
|
|
49
65
|
const file = Bun.file(filePath);
|
|
50
|
-
if (format === "table") {
|
|
51
|
-
const text = await file.text();
|
|
52
|
-
const parsed = parseAuto(text);
|
|
53
|
-
return { format: "table", columns: parsed.columns, rows: parsed.rows, title };
|
|
54
|
-
}
|
|
55
66
|
const text = await file.text();
|
|
56
|
-
|
|
57
|
-
case "markdown":
|
|
58
|
-
return { format: "markdown", markdown: text, title };
|
|
59
|
-
case "code":
|
|
60
|
-
return { format: "code", code: text, language, title };
|
|
61
|
-
case "text":
|
|
62
|
-
default:
|
|
63
|
-
return { format: "text", text, title };
|
|
64
|
-
}
|
|
67
|
+
return contentFromText(text, format, title, detected.language);
|
|
65
68
|
},
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
|
-
export function createStdinProvider() {
|
|
71
|
+
export function createStdinProvider(options = {}) {
|
|
69
72
|
return {
|
|
70
73
|
async load() {
|
|
71
74
|
const text = await new Response(Bun.stdin.stream()).text();
|
|
72
|
-
|
|
75
|
+
const format = options.renderer ?? "markdown";
|
|
76
|
+
return contentFromText(text, format, "stdin");
|
|
73
77
|
},
|
|
74
78
|
};
|
|
75
79
|
}
|
|
76
80
|
export function createTableFileProvider(filePath) {
|
|
77
|
-
return {
|
|
78
|
-
async load() {
|
|
79
|
-
const title = filePath.split("/").pop();
|
|
80
|
-
const file = Bun.file(filePath);
|
|
81
|
-
const text = await file.text();
|
|
82
|
-
const parsed = parseAuto(text);
|
|
83
|
-
return { format: "table", columns: parsed.columns, rows: parsed.rows, title };
|
|
84
|
-
},
|
|
85
|
-
};
|
|
81
|
+
return createFileProvider(filePath, { renderer: "table" });
|
|
86
82
|
}
|
|
87
83
|
export function createTableStdinProvider() {
|
|
88
|
-
return {
|
|
89
|
-
async load() {
|
|
90
|
-
const text = await new Response(Bun.stdin.stream()).text();
|
|
91
|
-
const parsed = parseAuto(text);
|
|
92
|
-
return { format: "table", columns: parsed.columns, rows: parsed.rows, title: "stdin" };
|
|
93
|
-
},
|
|
94
|
-
};
|
|
84
|
+
return createStdinProvider({ renderer: "table" });
|
|
95
85
|
}
|
|
96
86
|
//# sourceMappingURL=default-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"default-provider.js","sourceRoot":"","sources":["../src/default-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAO5C,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,EAAE,CAAA;IACpD,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;IAEnC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IACzC,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;IAElD,MAAM,YAAY,GAAG,IAAI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QAAQ,IAAI,UAAU,CAAA;YAC7C,OAAO,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/C,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,OAAO,kBAAkB,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,wBAAwB;IACtC,OAAO,mBAAmB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { useContentLoader } from "./useContentLoader.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { createViewCommandContext, useProvideViewCommandContext, useViewCommandContext, } from "./useViewCommandContext.js";
|
|
2
|
+
export { useContentCommands } from "./useContentCommands.js";
|
|
3
|
+
export { createViewCommandContext, useProvideViewCommandContext } from "./useViewCommandContext.js";
|
|
5
4
|
export type { CreateViewCommandContextOptions, ProvideViewCommandContextOptions, ViewCommandContext, } from "./useViewCommandContext.js";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AACnG,YAAY,EACV,+BAA+B,EAC/B,gCAAgC,EAChC,kBAAkB,GACnB,MAAM,4BAA4B,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useContentLoader } from "./useContentLoader.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export { createViewCommandContext, useProvideViewCommandContext, useViewCommandContext, } from "./useViewCommandContext.js";
|
|
2
|
+
export { useContentCommands } from "./useContentCommands.js";
|
|
3
|
+
export { createViewCommandContext, useProvideViewCommandContext } from "./useViewCommandContext.js";
|
|
5
4
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AnyContent } from "../types.js";
|
|
2
|
+
interface UseContentCommandsParams {
|
|
3
|
+
content: AnyContent | null;
|
|
4
|
+
textContent: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The commands a content viewer owns on top of `DocumentScreen`: copying the
|
|
8
|
+
* whole document and toggling the line-number gutter. Theme, quit, actions and
|
|
9
|
+
* every row-level command belong to the document controller and its screen.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useContentCommands({ content, textContent }: UseContentCommandsParams): {
|
|
12
|
+
showLineNumbers: boolean;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=useContentCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContentCommands.d.ts","sourceRoot":"","sources":["../../src/hooks/useContentCommands.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,UAAU,wBAAwB;IAChC,OAAO,EAAE,UAAU,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,wBAAwB;;EAapF"}
|