@tooee/renderers 0.2.4 → 0.3.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/dist/code-blocks.d.ts +6 -6
- package/dist/code-blocks.d.ts.map +1 -1
- package/dist/code-blocks.js +52 -42
- package/dist/code-blocks.js.map +1 -1
- package/dist/{CodeView.d.ts → code-view.d.ts} +3 -3
- package/dist/code-view.d.ts.map +1 -0
- package/dist/{CodeView.js → code-view.js} +5 -5
- package/dist/code-view.js.map +1 -0
- package/dist/{CommandPalette.d.ts → command-palette.d.ts} +2 -2
- package/dist/command-palette.d.ts.map +1 -0
- package/dist/{CommandPalette.js → command-palette.js} +27 -24
- package/dist/command-palette.js.map +1 -0
- package/dist/{ContextMenu.d.ts → context-menu.d.ts} +2 -2
- package/dist/context-menu.d.ts.map +1 -0
- package/dist/{ContextMenu.js → context-menu.js} +24 -14
- package/dist/context-menu.js.map +1 -0
- package/dist/{DecorationLayer.d.ts → decoration-layer.d.ts} +2 -2
- package/dist/decoration-layer.d.ts.map +1 -0
- package/dist/decoration-layer.js +2 -0
- package/dist/decoration-layer.js.map +1 -0
- package/dist/{DocumentBindings.d.ts → document-bindings.d.ts} +4 -4
- package/dist/document-bindings.d.ts.map +1 -0
- package/dist/document-bindings.js +2 -0
- package/dist/document-bindings.js.map +1 -0
- package/dist/index.d.ts +16 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/markdown-blocks.d.ts +9 -13
- package/dist/markdown-blocks.d.ts.map +1 -1
- package/dist/markdown-blocks.js +98 -79
- package/dist/markdown-blocks.js.map +1 -1
- package/dist/{MarkdownView.d.ts → markdown-view.d.ts} +13 -13
- package/dist/markdown-view.d.ts.map +1 -0
- package/dist/markdown-view.js +455 -0
- package/dist/markdown-view.js.map +1 -0
- package/dist/mermaid.d.ts +6 -6
- package/dist/mermaid.d.ts.map +1 -1
- package/dist/mermaid.js +56 -26
- package/dist/mermaid.js.map +1 -1
- package/dist/parsers.d.ts +5 -5
- package/dist/parsers.d.ts.map +1 -1
- package/dist/parsers.js +64 -44
- package/dist/parsers.js.map +1 -1
- package/dist/{RowDocumentRenderable.d.ts → row-document-renderable.d.ts} +15 -11
- package/dist/row-document-renderable.d.ts.map +1 -0
- package/dist/{RowDocumentRenderable.js → row-document-renderable.js} +110 -62
- package/dist/row-document-renderable.js.map +1 -0
- package/dist/row-document.d.ts +1 -1
- package/dist/row-document.d.ts.map +1 -1
- package/dist/row-document.js +1 -1
- package/dist/row-document.js.map +1 -1
- package/dist/source.d.ts +6 -6
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +35 -26
- package/dist/source.js.map +1 -1
- package/dist/table-types.d.ts.map +1 -1
- package/dist/{Table.d.ts → table.d.ts} +6 -6
- package/dist/table.d.ts.map +1 -0
- package/dist/{Table.js → table.js} +65 -35
- package/dist/table.js.map +1 -0
- package/dist/text-table.d.ts.map +1 -1
- package/dist/text-table.js.map +1 -1
- package/dist/use-gutter-palette.d.ts +3 -0
- package/dist/use-gutter-palette.d.ts.map +1 -0
- package/dist/{useGutterPalette.js → use-gutter-palette.js} +4 -4
- package/dist/use-gutter-palette.js.map +1 -0
- package/package.json +5 -5
- package/src/code-blocks.tsx +122 -106
- package/src/{CodeView.tsx → code-view.tsx} +19 -14
- package/src/command-palette.tsx +163 -0
- package/src/context-menu.tsx +157 -0
- package/src/decoration-layer.ts +11 -0
- package/src/document-bindings.ts +16 -0
- package/src/index.ts +24 -23
- package/src/markdown-blocks.ts +178 -138
- package/src/markdown-view.tsx +853 -0
- package/src/mermaid.ts +122 -70
- package/src/parsers.ts +141 -103
- package/src/row-document-renderable.ts +672 -0
- package/src/row-document.ts +4 -4
- package/src/source.ts +92 -72
- package/src/table-types.ts +4 -4
- package/src/table.tsx +346 -0
- package/src/text-table.ts +4 -4
- package/src/use-gutter-palette.ts +15 -0
- package/dist/CodeView.d.ts.map +0 -1
- package/dist/CodeView.js.map +0 -1
- package/dist/CommandPalette.d.ts.map +0 -1
- package/dist/CommandPalette.js.map +0 -1
- package/dist/ContextMenu.d.ts.map +0 -1
- package/dist/ContextMenu.js.map +0 -1
- package/dist/DecorationLayer.d.ts.map +0 -1
- package/dist/DecorationLayer.js +0 -2
- package/dist/DecorationLayer.js.map +0 -1
- package/dist/DocumentBindings.d.ts.map +0 -1
- package/dist/DocumentBindings.js +0 -2
- package/dist/DocumentBindings.js.map +0 -1
- package/dist/MarkdownView.d.ts.map +0 -1
- package/dist/MarkdownView.js +0 -360
- package/dist/MarkdownView.js.map +0 -1
- package/dist/RowDocumentRenderable.d.ts.map +0 -1
- package/dist/RowDocumentRenderable.js.map +0 -1
- package/dist/Table.d.ts.map +0 -1
- package/dist/Table.js.map +0 -1
- package/dist/useGutterPalette.d.ts +0 -3
- package/dist/useGutterPalette.d.ts.map +0 -1
- package/dist/useGutterPalette.js.map +0 -1
- package/src/CommandPalette.tsx +0 -147
- package/src/ContextMenu.tsx +0 -132
- package/src/DecorationLayer.ts +0 -11
- package/src/DocumentBindings.ts +0 -16
- package/src/MarkdownView.tsx +0 -738
- package/src/RowDocumentRenderable.ts +0 -593
- package/src/Table.tsx +0 -300
- package/src/useGutterPalette.ts +0 -15
package/dist/code-blocks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode, RefObject } from "react";
|
|
2
2
|
import type { ResolvedTheme } from "@tooee/themes";
|
|
3
3
|
import type { MouseEvent, SyntaxStyle, TextBufferRenderable } from "@opentui/core";
|
|
4
4
|
import type { Tokens } from "marked";
|
|
@@ -8,7 +8,7 @@ import type { Tokens } from "marked";
|
|
|
8
8
|
* Matches common Markdown behavior (marked may include extra info-string
|
|
9
9
|
* content after the language).
|
|
10
10
|
*/
|
|
11
|
-
export declare
|
|
11
|
+
export declare const getFenceType: (info?: string) => string;
|
|
12
12
|
/**
|
|
13
13
|
* Opt-in horizontal panning hooks for wide block content. Attach `register`
|
|
14
14
|
* as a ref and `onMouseScroll` as the `onMouseScroll` handler on the block's
|
|
@@ -57,11 +57,11 @@ export type CodeBlockRenderer = (props: CodeBlockRendererProps) => ReactNode;
|
|
|
57
57
|
* The standard bordered-box chrome used by built-in code and mermaid blocks.
|
|
58
58
|
* Custom renderers can wrap their content in this to match the default look.
|
|
59
59
|
*/
|
|
60
|
-
export declare
|
|
60
|
+
export declare const CodeBlockChrome: ({ theme, indent, children, }: {
|
|
61
61
|
theme: ResolvedTheme;
|
|
62
62
|
indent: number;
|
|
63
63
|
children?: ReactNode;
|
|
64
|
-
})
|
|
64
|
+
}) => ReactNode;
|
|
65
65
|
/**
|
|
66
66
|
* The default syntax-highlighted code block. Also used as the fallback when
|
|
67
67
|
* a custom renderer returns `null` or throws.
|
|
@@ -82,7 +82,7 @@ export declare const DEFAULT_CODE_BLOCK_RENDERERS: Record<string, CodeBlockRende
|
|
|
82
82
|
* syntax-highlighted code block when there is no match, the renderer
|
|
83
83
|
* returns `null`, or the renderer throws.
|
|
84
84
|
*/
|
|
85
|
-
export declare
|
|
85
|
+
export declare const CodeBlock: ({ token, blockIndex, theme, syntax, indent, hScrollableBlocksRef, renderers, }: {
|
|
86
86
|
token: Tokens.Code;
|
|
87
87
|
blockIndex: number;
|
|
88
88
|
theme: ResolvedTheme;
|
|
@@ -90,5 +90,5 @@ export declare function CodeBlock({ token, blockIndex, theme, syntax, indent, hS
|
|
|
90
90
|
indent: number;
|
|
91
91
|
hScrollableBlocksRef?: RefObject<Map<number, TextBufferRenderable>>;
|
|
92
92
|
renderers?: Record<string, CodeBlockRenderer>;
|
|
93
|
-
})
|
|
93
|
+
}) => ReactNode;
|
|
94
94
|
//# sourceMappingURL=code-blocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-blocks.d.ts","sourceRoot":"","sources":["../src/code-blocks.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code-blocks.d.ts","sourceRoot":"","sources":["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2BtC,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,iBA0CtC,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAE1E,CAAC;AA4DF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GAAsB,gFAQzC;IACD,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC/C,KAAG,SA0BH,CAAC"}
|
package/dist/code-blocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
|
-
import { useCallback,
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
3
|
import { renderMermaidForTerminal } from "./mermaid.js";
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Public custom code block renderer API
|
|
@@ -10,25 +10,25 @@ import { renderMermaidForTerminal } from "./mermaid.js";
|
|
|
10
10
|
* Matches common Markdown behavior (marked may include extra info-string
|
|
11
11
|
* content after the language).
|
|
12
12
|
*/
|
|
13
|
-
export function getFenceType(info) {
|
|
14
|
-
return (info ?? "").trim().split(/\s+/)[0]?.toLowerCase() ?? "";
|
|
15
|
-
}
|
|
13
|
+
export const getFenceType = function getFenceType(info) {
|
|
14
|
+
return (info ?? "").trim().split(/\s+/u)[0]?.toLowerCase() ?? "";
|
|
15
|
+
};
|
|
16
16
|
/**
|
|
17
17
|
* The standard bordered-box chrome used by built-in code and mermaid blocks.
|
|
18
18
|
* Custom renderers can wrap their content in this to match the default look.
|
|
19
19
|
*/
|
|
20
|
-
export function CodeBlockChrome({ theme, indent, children, }) {
|
|
20
|
+
export const CodeBlockChrome = function CodeBlockChrome({ theme, indent, children, }) {
|
|
21
21
|
return (_jsx("box", { style: {
|
|
22
|
-
|
|
23
|
-
marginBottom: 1,
|
|
24
|
-
marginLeft: 1 + indent,
|
|
25
|
-
marginRight: 1,
|
|
22
|
+
backgroundColor: theme.backgroundElement,
|
|
26
23
|
border: true,
|
|
27
24
|
borderColor: theme.border,
|
|
28
|
-
backgroundColor: theme.backgroundElement,
|
|
29
25
|
flexDirection: "column",
|
|
26
|
+
marginBottom: 1,
|
|
27
|
+
marginLeft: 1 + indent,
|
|
28
|
+
marginRight: 1,
|
|
29
|
+
marginTop: 0,
|
|
30
30
|
}, children: children }));
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
// Default renderer (syntax-highlighted code block)
|
|
34
34
|
// ---------------------------------------------------------------------------
|
|
@@ -37,12 +37,13 @@ export function CodeBlockChrome({ theme, indent, children, }) {
|
|
|
37
37
|
* a custom renderer returns `null` or throws.
|
|
38
38
|
*/
|
|
39
39
|
export const defaultCodeBlockRenderer = ({ text, info, theme, syntax, indent, hScroll, }) => {
|
|
40
|
+
const { register, onMouseScroll: handleMouseScroll } = hScroll;
|
|
40
41
|
const lineCount = text.split("\n").length;
|
|
41
42
|
// Code lines never wrap (wrapMode "none") — wide code blocks and ASCII
|
|
42
43
|
// diagrams pan horizontally via the renderable's own viewport (`scrollX`)
|
|
43
44
|
// instead of word-wrapping into an unreadable mess. Blocks that fit render
|
|
44
45
|
// exactly as before, with scrollX clamped to 0.
|
|
45
|
-
return (_jsx(CodeBlockChrome, { theme: theme, indent: indent, children: _jsx("code", { ref:
|
|
46
|
+
return (_jsx(CodeBlockChrome, { theme: theme, indent: indent, children: _jsx("code", { ref: register, content: text, filetype: info, syntaxStyle: syntax, wrapMode: "none", onMouseScroll: handleMouseScroll, style: { height: lineCount } }) }));
|
|
46
47
|
};
|
|
47
48
|
// ---------------------------------------------------------------------------
|
|
48
49
|
// Built-in mermaid renderer
|
|
@@ -53,20 +54,22 @@ export const defaultCodeBlockRenderer = ({ text, info, theme, syntax, indent, hS
|
|
|
53
54
|
* the diagram cannot be rendered. Registered by default under "mermaid";
|
|
54
55
|
* user entries for "mermaid" override it.
|
|
55
56
|
*/
|
|
56
|
-
export const mermaidCodeBlockRenderer = ({ text, theme, indent, hScroll }) => {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
border: theme.border,
|
|
60
|
-
line: theme.textMuted,
|
|
61
|
-
arrow: theme.accent,
|
|
57
|
+
export const mermaidCodeBlockRenderer = ({ text, theme, indent, hScroll, }) => {
|
|
58
|
+
const { register, onMouseScroll: handleMouseScroll } = hScroll;
|
|
59
|
+
const mermaidTheme = {
|
|
62
60
|
accent: theme.accent,
|
|
61
|
+
arrow: theme.accent,
|
|
63
62
|
bg: theme.backgroundElement,
|
|
63
|
+
border: theme.border,
|
|
64
64
|
corner: theme.borderActive,
|
|
65
|
+
fg: theme.markdownText,
|
|
65
66
|
junction: theme.borderSubtle,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
line: theme.textMuted,
|
|
68
|
+
};
|
|
69
|
+
const result = renderMermaidForTerminal(text, { mode: "ansi", theme: mermaidTheme });
|
|
70
|
+
if (!result.ok) {
|
|
69
71
|
return null;
|
|
72
|
+
}
|
|
70
73
|
const lineCount = result.text.split("\n").length;
|
|
71
74
|
// Diagram lines never wrap (wrapMode "none"). Wide diagrams pan via the
|
|
72
75
|
// text renderable's own viewport (`scrollX`), which the native renderer
|
|
@@ -75,7 +78,7 @@ export const mermaidCodeBlockRenderer = ({ text, theme, indent, hScroll }) => {
|
|
|
75
78
|
// misplaces fg colors at some offsets (each fully clipped style chunk after
|
|
76
79
|
// the first bleeds a phantom column into view). Diagrams that fit render
|
|
77
80
|
// exactly as before, with scrollX clamped to 0.
|
|
78
|
-
return (_jsx(CodeBlockChrome, { theme: theme, indent: indent, children: _jsx("text", { ref:
|
|
81
|
+
return (_jsx(CodeBlockChrome, { theme: theme, indent: indent, children: _jsx("text", { ref: register, content: result.content, wrapMode: "none", onMouseScroll: handleMouseScroll, style: { fg: theme.markdownText, height: lineCount } }) }));
|
|
79
82
|
};
|
|
80
83
|
/** Built-in code block renderers, merged under user-provided entries. */
|
|
81
84
|
export const DEFAULT_CODE_BLOCK_RENDERERS = {
|
|
@@ -97,30 +100,36 @@ export const DEFAULT_CODE_BLOCK_RENDERERS = {
|
|
|
97
100
|
* stopped, so plain vertical wheel keeps bubbling to the surrounding
|
|
98
101
|
* row-document.
|
|
99
102
|
*/
|
|
100
|
-
function useHScrollableBlock(blockIndex, hScrollableBlocksRef) {
|
|
103
|
+
const useHScrollableBlock = function useHScrollableBlock(blockIndex, hScrollableBlocksRef) {
|
|
101
104
|
const nodeRef = useRef(null);
|
|
102
105
|
const register = useCallback((node) => {
|
|
103
106
|
nodeRef.current = node;
|
|
104
107
|
const map = hScrollableBlocksRef?.current;
|
|
105
|
-
if (!map)
|
|
108
|
+
if (!map) {
|
|
106
109
|
return;
|
|
107
|
-
|
|
110
|
+
}
|
|
111
|
+
if (node) {
|
|
108
112
|
map.set(blockIndex, node);
|
|
109
|
-
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
110
115
|
map.delete(blockIndex);
|
|
116
|
+
}
|
|
111
117
|
}, [hScrollableBlocksRef, blockIndex]);
|
|
112
118
|
const handleMouseScroll = useCallback((event) => {
|
|
113
119
|
const node = nodeRef.current;
|
|
114
|
-
if (!node || !event.scroll || !event.modifiers.shift)
|
|
120
|
+
if (!node || !event.scroll || !event.modifiers.shift) {
|
|
115
121
|
return;
|
|
122
|
+
}
|
|
116
123
|
const { direction, delta } = event.scroll;
|
|
117
|
-
if (direction === "up")
|
|
124
|
+
if (direction === "up") {
|
|
118
125
|
node.scrollX -= delta;
|
|
119
|
-
|
|
126
|
+
}
|
|
127
|
+
else if (direction === "down") {
|
|
120
128
|
node.scrollX += delta;
|
|
129
|
+
}
|
|
121
130
|
}, []);
|
|
122
|
-
return {
|
|
123
|
-
}
|
|
131
|
+
return { handleMouseScroll, register };
|
|
132
|
+
};
|
|
124
133
|
// ---------------------------------------------------------------------------
|
|
125
134
|
// Dispatching block component
|
|
126
135
|
// ---------------------------------------------------------------------------
|
|
@@ -130,32 +139,33 @@ function useHScrollableBlock(blockIndex, hScrollableBlocksRef) {
|
|
|
130
139
|
* syntax-highlighted code block when there is no match, the renderer
|
|
131
140
|
* returns `null`, or the renderer throws.
|
|
132
141
|
*/
|
|
133
|
-
export function CodeBlock({ token, blockIndex, theme, syntax, indent, hScrollableBlocksRef, renderers, }) {
|
|
142
|
+
export const CodeBlock = function CodeBlock({ token, blockIndex, theme, syntax, indent, hScrollableBlocksRef, renderers, }) {
|
|
134
143
|
const { register, handleMouseScroll } = useHScrollableBlock(blockIndex, hScrollableBlocksRef);
|
|
135
144
|
const rendererProps = {
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
blockIndex,
|
|
146
|
+
hScroll: { onMouseScroll: handleMouseScroll, register },
|
|
147
|
+
indent,
|
|
138
148
|
info: token.lang ?? "",
|
|
139
|
-
|
|
149
|
+
lang: getFenceType(token.lang),
|
|
140
150
|
syntax,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
hScroll: { register, onMouseScroll: handleMouseScroll },
|
|
151
|
+
text: token.text,
|
|
152
|
+
theme,
|
|
144
153
|
};
|
|
145
|
-
const custom = rendererProps.lang
|
|
154
|
+
const custom = rendererProps.lang === "" ? undefined : renderers?.[rendererProps.lang];
|
|
155
|
+
// oxlint-disable-next-line no-use-before-define -- Deferred(lint-sweep): preserve deliberate top-down custom renderer organization
|
|
146
156
|
if (custom && custom !== defaultCodeBlockRenderer) {
|
|
147
157
|
// Keyed by fence type so a type change remounts the custom renderer
|
|
148
158
|
// (renderers may use hooks; see CodeBlockRenderer docs).
|
|
149
159
|
return (_jsx(CustomCodeBlock, { renderer: custom, rendererProps: rendererProps }, rendererProps.lang));
|
|
150
160
|
}
|
|
151
161
|
return defaultCodeBlockRenderer(rendererProps);
|
|
152
|
-
}
|
|
162
|
+
};
|
|
153
163
|
/**
|
|
154
164
|
* Invokes a custom renderer, falling back to the default code block when it
|
|
155
165
|
* returns `null` or throws. Isolated in its own component so renderer hooks
|
|
156
166
|
* have a stable home that remounts when the fence type changes.
|
|
157
167
|
*/
|
|
158
|
-
function CustomCodeBlock({ renderer, rendererProps, }) {
|
|
168
|
+
const CustomCodeBlock = function CustomCodeBlock({ renderer, rendererProps, }) {
|
|
159
169
|
let node = null;
|
|
160
170
|
try {
|
|
161
171
|
node = renderer(rendererProps);
|
|
@@ -164,5 +174,5 @@ function CustomCodeBlock({ renderer, rendererProps, }) {
|
|
|
164
174
|
node = null;
|
|
165
175
|
}
|
|
166
176
|
return node ?? defaultCodeBlockRenderer(rendererProps);
|
|
167
|
-
}
|
|
177
|
+
};
|
|
168
178
|
//# sourceMappingURL=code-blocks.js.map
|
package/dist/code-blocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-blocks.js","sourceRoot":"","sources":["../src/code-blocks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"code-blocks.js","sourceRoot":"","sources":["../src/code-blocks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAK5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,8EAA8E;AAC9E,wCAAwC;AACxC,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,YAAY,CAAC,IAAa;IAC7D,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAA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eAAe,CAAC,EAC/C,QAAQ,EACR,aAAa,GAId;IACC,IAAI,IAAI,GAAc,IAAI,CAAC;IAC3B,IAAI,CAAC;QACH,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,IAAI,wBAAwB,CAAC,aAAa,CAAC,CAAC;AACzD,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DocumentBindings } from "./
|
|
1
|
+
import type { DocumentBindings } from "./document-bindings.js";
|
|
2
2
|
import "./row-document.js";
|
|
3
3
|
interface CodeViewProps {
|
|
4
4
|
content: string;
|
|
@@ -16,6 +16,6 @@ interface CodeViewProps {
|
|
|
16
16
|
*/
|
|
17
17
|
document?: DocumentBindings;
|
|
18
18
|
}
|
|
19
|
-
export declare
|
|
19
|
+
export declare const CodeView: ({ content, language, showLineNumbers, document, }: CodeViewProps) => React.ReactNode;
|
|
20
20
|
export {};
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=code-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-view.d.ts","sourceRoot":"","sources":["../src/code-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,mBAAmB,CAAC;AAE3B,UAAU,aAAa;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;OASG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAED,eAAO,MAAM,QAAQ,GAAqB,mDAKvC,aAAa,KAAG,KAAK,CAAC,SAiBxB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@opentui/react/jsx-runtime";
|
|
2
2
|
import { useTheme } from "@tooee/themes";
|
|
3
|
-
import { DEFAULT_SIGN_COLUMN_WIDTH } from "./
|
|
4
|
-
import { useGutterPalette } from "./
|
|
3
|
+
import { DEFAULT_SIGN_COLUMN_WIDTH } from "./row-document-renderable.js";
|
|
4
|
+
import { useGutterPalette } from "./use-gutter-palette.js";
|
|
5
5
|
import "./row-document.js";
|
|
6
|
-
export function CodeView({ content, language, showLineNumbers = true, document }) {
|
|
6
|
+
export const CodeView = function CodeView({ content, language, showLineNumbers = true, document, }) {
|
|
7
7
|
const { syntax } = useTheme();
|
|
8
8
|
const palette = useGutterPalette();
|
|
9
9
|
return (_jsx("row-document", { ref: document?.ref, showLineNumbers: showLineNumbers, palette: palette, decorations: document?.decorations, signColumnWidth: DEFAULT_SIGN_COLUMN_WIDTH, style: { flexGrow: 1 }, onMouseDown: document?.onMouseDown, children: _jsx("code", { content: content, filetype: language, syntaxStyle: syntax }) }));
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=code-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-view.js","sourceRoot":"","sources":["../src/code-view.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,mBAAmB,CAAC;AAmB3B,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,QAAQ,CAAC,EACxC,OAAO,EACP,QAAQ,EACR,eAAe,GAAG,IAAI,EACtB,QAAQ,GACM;IACd,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,OAAO,CACL,uBACE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,QAAQ,EAAE,WAAW,EAClC,eAAe,EAAE,yBAAyB,EAC1C,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,EACtB,WAAW,EAAE,QAAQ,EAAE,WAAW,YAElC,eAAM,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAI,GACtD,CAChB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -10,6 +10,6 @@ interface CommandPaletteProps {
|
|
|
10
10
|
onSelect: (commandId: string) => void;
|
|
11
11
|
onClose: () => void;
|
|
12
12
|
}
|
|
13
|
-
export declare
|
|
13
|
+
export declare const CommandPalette: ({ commands, onSelect, onClose, }: CommandPaletteProps) => React.ReactNode;
|
|
14
14
|
export {};
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=command-palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../src/command-palette.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,GAA2B,kCAInD,mBAAmB,KAAG,KAAK,CAAC,SA2I9B,CAAC"}
|
|
@@ -3,25 +3,27 @@ import { useState, useMemo, useCallback } from "react";
|
|
|
3
3
|
import { useCommand } from "@tooee/commands";
|
|
4
4
|
import { useTheme, CloseButton } from "@tooee/themes";
|
|
5
5
|
import { fuzzyMatch } from "@tooee/fuzzy";
|
|
6
|
-
export function CommandPalette({ commands, onSelect, onClose }) {
|
|
6
|
+
export const CommandPalette = function CommandPalette({ commands, onSelect, onClose, }) {
|
|
7
7
|
const { theme } = useTheme();
|
|
8
8
|
const [filter, setFilter] = useState("");
|
|
9
9
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
10
10
|
const filtered = useMemo(() => {
|
|
11
|
-
if (!filter)
|
|
11
|
+
if (!filter) {
|
|
12
12
|
return commands;
|
|
13
|
+
}
|
|
13
14
|
const results = [];
|
|
14
15
|
for (const entry of commands) {
|
|
15
16
|
const score = fuzzyMatch(filter, entry.title);
|
|
16
|
-
if (score !== null)
|
|
17
|
+
if (score !== null) {
|
|
17
18
|
results.push({ entry, score });
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
results.sort((a, b) => b.score - a.score);
|
|
20
22
|
return results.map((r) => r.entry);
|
|
21
23
|
}, [commands, filter]);
|
|
22
24
|
const handleSelect = useCallback(() => {
|
|
23
25
|
const item = filtered[activeIndex];
|
|
24
|
-
if (item) {
|
|
26
|
+
if (item !== undefined) {
|
|
25
27
|
onSelect(item.id);
|
|
26
28
|
}
|
|
27
29
|
}, [filtered, activeIndex, onSelect]);
|
|
@@ -32,47 +34,48 @@ export function CommandPalette({ commands, onSelect, onClose }) {
|
|
|
32
34
|
setActiveIndex((i) => Math.min(filtered.length - 1, i + 1));
|
|
33
35
|
}, [filtered.length]);
|
|
34
36
|
useCommand({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
handler: onClose,
|
|
38
|
+
hidden: true,
|
|
37
39
|
hotkey: "Escape",
|
|
40
|
+
id: "command-palette:close",
|
|
38
41
|
modes: ["insert", "cursor"],
|
|
39
|
-
|
|
40
|
-
handler: onClose,
|
|
42
|
+
title: "Close command palette",
|
|
41
43
|
});
|
|
42
44
|
useCommand({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
handler: handleSelect,
|
|
46
|
+
hidden: true,
|
|
45
47
|
hotkey: "Enter",
|
|
48
|
+
id: "command-palette:select",
|
|
46
49
|
modes: ["insert", "cursor"],
|
|
47
|
-
|
|
48
|
-
handler: handleSelect,
|
|
50
|
+
title: "Run selected command",
|
|
49
51
|
});
|
|
50
52
|
useCommand({
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
handler: moveUp,
|
|
54
|
+
hidden: true,
|
|
53
55
|
hotkey: "up",
|
|
56
|
+
id: "command-palette:move-up",
|
|
54
57
|
modes: ["insert", "cursor"],
|
|
55
|
-
|
|
56
|
-
handler: moveUp,
|
|
58
|
+
title: "Move up",
|
|
57
59
|
});
|
|
58
60
|
useCommand({
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
handler: moveDown,
|
|
62
|
+
hidden: true,
|
|
61
63
|
hotkey: "down",
|
|
64
|
+
id: "command-palette:move-down",
|
|
62
65
|
modes: ["insert", "cursor"],
|
|
63
|
-
|
|
64
|
-
handler: moveDown,
|
|
66
|
+
title: "Move down",
|
|
65
67
|
});
|
|
66
68
|
return (_jsxs("box", { position: "absolute", left: "20%", right: "20%", top: 2, maxHeight: "60%", flexDirection: "column", backgroundColor: theme.backgroundPanel, border: true, borderColor: theme.border, children: [_jsxs("box", { flexDirection: "row", paddingLeft: 1, paddingRight: 1, height: 1, children: [_jsx("text", { content: ":", fg: theme.accent }), _jsx("input", { focused: true, placeholder: "Filter commands...", onSubmit: handleSelect, onInput: (value) => {
|
|
67
69
|
setFilter(value);
|
|
68
70
|
setActiveIndex(0);
|
|
69
71
|
}, backgroundColor: "transparent", focusedBackgroundColor: "transparent", textColor: theme.text, placeholderColor: theme.textMuted, cursorColor: theme.accent, style: { flexGrow: 1 } }), _jsx("text", { content: ` ${filtered.length}`, fg: theme.textMuted }), _jsx(CloseButton, { onClose: onClose })] }), _jsx("box", { height: 1, width: "100%", backgroundColor: theme.border }), _jsx("scrollbox", { focused: false, style: { flexGrow: 1 }, children: filtered.map((entry, i) => (_jsxs("box", { flexDirection: "row", paddingLeft: 1, paddingRight: 1, height: 1, backgroundColor: i === activeIndex ? theme.backgroundElement : undefined, onMouseDown: (event) => {
|
|
70
72
|
// Left-click runs the entry — same code path as Enter.
|
|
71
|
-
if (event.button !== 0)
|
|
73
|
+
if (event.button !== 0) {
|
|
72
74
|
return;
|
|
75
|
+
}
|
|
73
76
|
event.preventDefault();
|
|
74
77
|
event.stopPropagation();
|
|
75
78
|
onSelect(entry.id);
|
|
76
|
-
}, children: [_jsx("text", { content: entry.title, fg: theme.text, style: { flexGrow: 1 } }), entry.hotkey && _jsx("text", { content: entry.hotkey, fg: theme.textMuted }), entry.category && _jsx("text", { content: ` ${entry.category}`, fg: theme.textMuted })] }, entry.id))) })] }));
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=
|
|
79
|
+
}, children: [_jsx("text", { content: entry.title, fg: theme.text, style: { flexGrow: 1 } }), (entry.hotkey?.length ?? 0) > 0 && (_jsx("text", { content: entry.hotkey, fg: theme.textMuted })), (entry.category?.length ?? 0) > 0 && (_jsx("text", { content: ` ${entry.category}`, fg: theme.textMuted }))] }, entry.id))) })] }));
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=command-palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.js","sourceRoot":"","sources":["../src/command-palette.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgB1C,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,cAAc,CAAC,EACpD,QAAQ,EACR,QA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), click selects.
|
|
21
21
|
*/
|
|
22
|
-
export declare
|
|
22
|
+
export declare const ContextMenu: ({ entries, x, y, onSelect, onClose, }: ContextMenuProps) => React.ReactNode;
|
|
23
23
|
export {};
|
|
24
|
-
//# sourceMappingURL=
|
|
24
|
+
//# sourceMappingURL=context-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.d.ts","sourceRoot":"","sources":["../src/context-menu.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,gBAAgB;IACxB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,sEAAsE;IACtE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAwB,uCAM7C,gBAAgB,KAAG,KAAK,CAAC,SAuH3B,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useState, useCallback } from "react";
|
|
|
3
3
|
import { useKeyboard, useTerminalDimensions } from "@opentui/react";
|
|
4
4
|
import { useTheme } from "@tooee/themes";
|
|
5
5
|
const MIN_WIDTH = 16;
|
|
6
|
-
const
|
|
6
|
+
const HORIZONTAL_PADDING = 2;
|
|
7
7
|
const BORDER = 2;
|
|
8
8
|
/**
|
|
9
9
|
* A positioned, keyboard-navigable mini action menu shown on right-click.
|
|
@@ -13,14 +13,15 @@ const BORDER = 2;
|
|
|
13
13
|
* additive: j/k + arrows move, Enter invokes, Escape closes (handled by the
|
|
14
14
|
* overlay layer), click selects.
|
|
15
15
|
*/
|
|
16
|
-
export function ContextMenu({ entries, x, y, onSelect, onClose }) {
|
|
16
|
+
export const ContextMenu = function ContextMenu({ entries, x, y, onSelect, onClose, }) {
|
|
17
17
|
const { theme } = useTheme();
|
|
18
18
|
const { width: termWidth, height: termHeight } = useTerminalDimensions();
|
|
19
19
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
20
20
|
const select = useCallback((index) => {
|
|
21
21
|
const entry = entries[index];
|
|
22
|
-
if (entry)
|
|
22
|
+
if (entry !== undefined) {
|
|
23
23
|
onSelect(entry.id);
|
|
24
|
+
}
|
|
24
25
|
}, [entries, onSelect]);
|
|
25
26
|
useKeyboard((key) => {
|
|
26
27
|
if (key.name === "up" || key.raw === "k") {
|
|
@@ -39,29 +40,38 @@ export function ContextMenu({ entries, x, y, onSelect, onClose }) {
|
|
|
39
40
|
});
|
|
40
41
|
// Size the panel from its contents (terminal cell width, not code units,
|
|
41
42
|
// so wide glyphs like CJK and emoji are counted correctly).
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
let longest = 0;
|
|
44
|
+
const entryCount = entries.length;
|
|
45
|
+
for (let index = 0; index < entryCount; index += 1) {
|
|
46
|
+
if (index in entries) {
|
|
47
|
+
const entry = entries[index];
|
|
48
|
+
const width = Bun.stringWidth(entry.title) +
|
|
49
|
+
(entry.hotkey !== undefined && entry.hotkey !== "" ? Bun.stringWidth(entry.hotkey) + 2 : 0);
|
|
50
|
+
longest = Math.max(longest, width);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
46
53
|
const innerWidth = Math.max(MIN_WIDTH, longest);
|
|
47
|
-
const panelWidth = innerWidth +
|
|
54
|
+
const panelWidth = innerWidth + HORIZONTAL_PADDING + BORDER;
|
|
48
55
|
const panelHeight = Math.max(1, entries.length) + BORDER;
|
|
49
56
|
// Clamp on-screen: flip left/up when the anchor is near the right/bottom edge.
|
|
50
57
|
let left = x;
|
|
51
|
-
if (left + panelWidth > termWidth)
|
|
58
|
+
if (left + panelWidth > termWidth) {
|
|
52
59
|
left = Math.max(0, termWidth - panelWidth);
|
|
60
|
+
}
|
|
53
61
|
let top = y;
|
|
54
|
-
if (top + panelHeight > termHeight)
|
|
62
|
+
if (top + panelHeight > termHeight) {
|
|
55
63
|
top = Math.max(0, termHeight - panelHeight);
|
|
64
|
+
}
|
|
56
65
|
return (_jsxs("box", { position: "absolute", left: 0, top: 0, width: termWidth, height: termHeight, children: [_jsx("box", { position: "absolute", left: 0, top: 0, width: termWidth, height: termHeight, backgroundColor: "transparent", onMouseDown: (event) => {
|
|
57
66
|
event.preventDefault();
|
|
58
67
|
onClose();
|
|
59
68
|
} }), _jsx("box", { position: "absolute", left: left, top: top, width: panelWidth, flexDirection: "column", backgroundColor: theme.backgroundPanel, border: true, borderColor: theme.borderActive, children: entries.length === 0 ? (_jsx("box", { height: 1, paddingLeft: 1, paddingRight: 1, children: _jsx("text", { content: "No actions", fg: theme.textMuted }) })) : (entries.map((entry, i) => (_jsxs("box", { flexDirection: "row", height: 1, paddingLeft: 1, paddingRight: 1, backgroundColor: i === activeIndex ? theme.backgroundElement : undefined, onMouseDown: (event) => {
|
|
60
|
-
if (event.button !== 0)
|
|
69
|
+
if (event.button !== 0) {
|
|
61
70
|
return;
|
|
71
|
+
}
|
|
62
72
|
event.preventDefault();
|
|
63
73
|
event.stopPropagation();
|
|
64
74
|
onSelect(entry.id);
|
|
65
|
-
}, children: [_jsx("text", { content: entry.title, fg: i === activeIndex ? theme.primary : theme.text, style: { flexGrow: 1 } }), entry.hotkey && _jsx("text", { content: ` ${entry.hotkey}`, fg: theme.textMuted })] }, entry.id)))) })] }));
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=
|
|
75
|
+
}, children: [_jsx("text", { content: entry.title, fg: i === activeIndex ? theme.primary : theme.text, style: { flexGrow: 1 } }), (entry.hotkey?.length ?? 0) > 0 && (_jsx("text", { content: ` ${entry.hotkey}`, fg: theme.textMuted }))] }, entry.id)))) })] }));
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=context-menu.js.map
|
|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AAC;AACJ,CAAC,CAAC"}
|
|
@@ -9,6 +9,6 @@ export interface RowDecoration {
|
|
|
9
9
|
}
|
|
10
10
|
export interface DecorationLayer {
|
|
11
11
|
readonly priority: number;
|
|
12
|
-
forVisibleRows(from: number, to: number)
|
|
12
|
+
forVisibleRows: (from: number, to: number) => Iterable<RowDecoration>;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=decoration-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoration-layer.d.ts","sourceRoot":"","sources":["../src/decoration-layer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,QAAQ,CAAC,aAAa,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decoration-layer.js","sourceRoot":"","sources":["../src/decoration-layer.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
2
|
import type { MouseEvent } from "@opentui/core";
|
|
3
|
-
import type { DecorationLayer } from "./
|
|
4
|
-
import type { RowDocumentRenderable } from "./
|
|
3
|
+
import type { DecorationLayer } from "./decoration-layer.js";
|
|
4
|
+
import type { RowDocumentRenderable } from "./row-document-renderable.js";
|
|
5
5
|
/**
|
|
6
6
|
* The narrow projection a row renderer needs from a document controller:
|
|
7
7
|
* geometry access, the layers to paint, and the bound mouse handler. Renderers
|
|
@@ -11,6 +11,6 @@ import type { RowDocumentRenderable } from "./RowDocumentRenderable.js";
|
|
|
11
11
|
export interface DocumentBindings {
|
|
12
12
|
ref: RefObject<RowDocumentRenderable | null>;
|
|
13
13
|
decorations: readonly DecorationLayer[];
|
|
14
|
-
onMouseDown(event: MouseEvent)
|
|
14
|
+
onMouseDown: (event: MouseEvent) => void;
|
|
15
15
|
}
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=document-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-bindings.d.ts","sourceRoot":"","sources":["../src/document-bindings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,SAAS,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;IAC7C,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;IACxC,WAAW,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-bindings.js","sourceRoot":"","sources":["../src/document-bindings.ts"],"names":[],"mappings":""}
|