@tooee/view 0.10.0 → 0.10.2
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 +7 -19
- package/dist/components/diff-file-picker.d.ts +1 -1
- package/dist/components/diff-file-picker.d.ts.map +1 -1
- package/dist/components/subviews/code-subview.d.ts +1 -1
- package/dist/components/subviews/code-subview.d.ts.map +1 -1
- package/dist/components/subviews/code-subview.js +1 -1
- package/dist/components/subviews/code-subview.js.map +1 -1
- package/dist/components/subviews/custom-subview.d.ts +1 -1
- package/dist/components/subviews/custom-subview.d.ts.map +1 -1
- package/dist/components/subviews/custom-subview.js +2 -2
- package/dist/components/subviews/custom-subview.js.map +1 -1
- package/dist/components/subviews/diff-subview.d.ts +1 -1
- package/dist/components/subviews/diff-subview.d.ts.map +1 -1
- package/dist/components/subviews/diff-subview.js +3 -3
- package/dist/components/subviews/diff-subview.js.map +1 -1
- package/dist/components/subviews/image-subview.d.ts +1 -1
- package/dist/components/subviews/image-subview.d.ts.map +1 -1
- package/dist/components/subviews/image-subview.js +2 -2
- package/dist/components/subviews/image-subview.js.map +1 -1
- package/dist/components/subviews/markdown-subview.d.ts +1 -1
- package/dist/components/subviews/markdown-subview.d.ts.map +1 -1
- package/dist/components/subviews/markdown-subview.js +2 -2
- package/dist/components/subviews/markdown-subview.js.map +1 -1
- package/dist/components/subviews/table-subview.d.ts +1 -1
- package/dist/components/subviews/table-subview.d.ts.map +1 -1
- package/dist/components/subviews/table-subview.js +2 -2
- package/dist/components/subviews/table-subview.js.map +1 -1
- package/dist/components/subviews/types.d.ts +1 -1
- package/dist/components/subviews/types.d.ts.map +1 -1
- package/dist/components/view-screen.d.ts +1 -1
- package/dist/components/view-screen.d.ts.map +1 -1
- package/dist/components/view-screen.js.map +1 -1
- package/dist/content-loader-store.d.ts.map +1 -1
- package/dist/content-loader-store.js.map +1 -1
- package/dist/default-provider.d.ts.map +1 -1
- package/dist/default-provider.js +1 -1
- package/dist/default-provider.js.map +1 -1
- package/dist/directory-provider.d.ts.map +1 -1
- package/dist/directory-provider.js.map +1 -1
- package/dist/directory-view.d.ts.map +1 -1
- package/dist/directory-view.js +4 -4
- package/dist/directory-view.js.map +1 -1
- package/dist/hooks/use-content-commands.d.ts.map +1 -1
- package/dist/hooks/use-content-commands.js +2 -2
- package/dist/hooks/use-content-commands.js.map +1 -1
- package/dist/hooks/use-content-document.d.ts.map +1 -1
- package/dist/hooks/use-content-document.js.map +1 -1
- package/dist/hooks/use-content-loader.d.ts +1 -1
- package/dist/hooks/use-content-loader.d.ts.map +1 -1
- package/dist/hooks/use-content-loader.js +1 -1
- package/dist/hooks/use-content-loader.js.map +1 -1
- package/dist/hooks/use-view-command-context.d.ts.map +1 -1
- package/dist/hooks/use-view-command-context.js.map +1 -1
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +2 -2
- package/dist/launch.js.map +1 -1
- package/dist/link-handlers.d.ts.map +1 -1
- package/dist/link-handlers.js.map +1 -1
- package/dist/markdown-links.d.ts.map +1 -1
- package/dist/markdown-links.js.map +1 -1
- package/dist/standalone-router.d.ts.map +1 -1
- package/dist/standalone-router.js +3 -3
- package/dist/standalone-router.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/view.d.ts +1 -1
- package/dist/view.d.ts.map +1 -1
- package/dist/view.js +5 -5
- package/dist/view.js.map +1 -1
- package/package.json +22 -22
- package/src/components/diff-file-picker.tsx +2 -2
- package/src/components/subviews/code-subview.tsx +5 -4
- package/src/components/subviews/custom-subview.tsx +5 -4
- package/src/components/subviews/diff-subview.tsx +13 -12
- package/src/components/subviews/image-subview.tsx +5 -4
- package/src/components/subviews/markdown-subview.tsx +6 -5
- package/src/components/subviews/table-subview.tsx +6 -5
- package/src/components/subviews/types.ts +2 -1
- package/src/components/view-screen.tsx +2 -1
- package/src/content-loader-store.ts +6 -5
- package/src/default-provider.ts +7 -5
- package/src/directory-provider.ts +3 -2
- package/src/directory-view.tsx +8 -7
- package/src/hooks/use-content-commands.ts +3 -2
- package/src/hooks/use-content-document.ts +2 -1
- package/src/hooks/use-content-loader.ts +5 -4
- package/src/hooks/use-view-command-context.ts +4 -3
- package/src/launch.tsx +7 -6
- package/src/link-handlers.ts +3 -1
- package/src/markdown-links.ts +2 -1
- package/src/standalone-router.tsx +10 -8
- package/src/types.ts +4 -4
- package/src/view.tsx +10 -9
package/src/default-provider.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import { isDiffPatch } from "@tooee/diff";
|
|
4
|
+
import { parseAuto } from "@tooee/renderers";
|
|
5
|
+
|
|
4
6
|
import type { Content, ContentFormat, ContentProvider } from "./types.js";
|
|
5
7
|
|
|
6
8
|
export interface CreateProviderOptions {
|
|
@@ -78,7 +80,7 @@ const contentFromText = function contentFromText(
|
|
|
78
80
|
text: string,
|
|
79
81
|
format: ContentFormat,
|
|
80
82
|
title: string | undefined,
|
|
81
|
-
language?: string
|
|
83
|
+
language?: string
|
|
82
84
|
): Content {
|
|
83
85
|
switch (format) {
|
|
84
86
|
case "markdown": {
|
|
@@ -108,7 +110,7 @@ const contentFromText = function contentFromText(
|
|
|
108
110
|
|
|
109
111
|
export const createFileProvider = function createFileProvider(
|
|
110
112
|
filePath: string,
|
|
111
|
-
options: CreateProviderOptions = {}
|
|
113
|
+
options: CreateProviderOptions = {}
|
|
112
114
|
): ContentProvider {
|
|
113
115
|
return {
|
|
114
116
|
async load(): Promise<Content> {
|
|
@@ -137,7 +139,7 @@ export const createFileProvider = function createFileProvider(
|
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
export const createStdinProvider = function createStdinProvider(
|
|
140
|
-
options: CreateProviderOptions = {}
|
|
142
|
+
options: CreateProviderOptions = {}
|
|
141
143
|
): ContentProvider {
|
|
142
144
|
return {
|
|
143
145
|
async load(): Promise<Content> {
|
|
@@ -149,7 +151,7 @@ export const createStdinProvider = function createStdinProvider(
|
|
|
149
151
|
};
|
|
150
152
|
|
|
151
153
|
export const createTableFileProvider = function createTableFileProvider(
|
|
152
|
-
filePath: string
|
|
154
|
+
filePath: string
|
|
153
155
|
): ContentProvider {
|
|
154
156
|
return createFileProvider(filePath, { renderer: "table" });
|
|
155
157
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { readdirSync, statSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
import { createFileProvider } from "./default-provider.js";
|
|
5
|
+
import type { ContentProvider } from "./types.js";
|
|
5
6
|
|
|
6
7
|
const SUPPORTED_EXTENSIONS = new Set([
|
|
7
8
|
"md",
|
|
@@ -78,7 +79,7 @@ export const listDirectoryFiles = function listDirectoryFiles(dirPath: string):
|
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
export const createDirectoryFileProvider = function createDirectoryFileProvider(
|
|
81
|
-
filePath: string
|
|
82
|
+
filePath: string
|
|
82
83
|
): ContentProvider {
|
|
83
84
|
return createFileProvider(filePath);
|
|
84
85
|
};
|
package/src/directory-view.tsx
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { useState, useMemo } from "react";
|
|
2
1
|
import { useCommand } from "@tooee/commands";
|
|
3
2
|
import type { ActionDefinition } from "@tooee/commands";
|
|
4
|
-
import {
|
|
3
|
+
import { useState, useMemo } from "react";
|
|
4
|
+
import type { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
import { ViewState } from "./components/view-state.js";
|
|
7
|
+
import { createFileProvider } from "./default-provider.js";
|
|
5
8
|
import { listDirectoryFiles } from "./directory-provider.js";
|
|
6
9
|
import type { DirectoryEntry } from "./directory-provider.js";
|
|
7
10
|
import type { AnyContent, ContentProvider } from "./types.js";
|
|
8
|
-
import {
|
|
9
|
-
import { ViewState } from "./components/view-state.js";
|
|
10
|
-
import type { ReactNode } from "react";
|
|
11
|
+
import { View } from "./view.js";
|
|
11
12
|
|
|
12
13
|
const createDirectoryFileProvider = function createDirectoryFileProvider(
|
|
13
14
|
entry: DirectoryEntry,
|
|
14
15
|
index: number,
|
|
15
|
-
total: number
|
|
16
|
+
total: number
|
|
16
17
|
): ContentProvider {
|
|
17
18
|
const inner = createFileProvider(entry.path);
|
|
18
19
|
return {
|
|
@@ -47,7 +48,7 @@ export const DirectoryView = function DirectoryView({
|
|
|
47
48
|
files.length > 0
|
|
48
49
|
? createDirectoryFileProvider(files[currentIndex], currentIndex, files.length)
|
|
49
50
|
: null,
|
|
50
|
-
[files, currentIndex]
|
|
51
|
+
[files, currentIndex]
|
|
51
52
|
);
|
|
52
53
|
|
|
53
54
|
useCommand({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { useCopyCommand, useToggleLineNumbersCommand } from "@tooee/shell";
|
|
3
1
|
import { useConfig } from "@tooee/config";
|
|
2
|
+
import { useCopyCommand, useToggleLineNumbersCommand } from "@tooee/shell";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
|
|
4
5
|
import type { AnyContent } from "../types.js";
|
|
5
6
|
|
|
6
7
|
interface UseContentCommandsParams {
|
|
@@ -3,6 +3,7 @@ import type { StatusBarItem } from "@tooee/layout";
|
|
|
3
3
|
import type { DecorationLayer } from "@tooee/renderers";
|
|
4
4
|
import { useDocumentController } from "@tooee/shell";
|
|
5
5
|
import type { DocumentController, DocumentRowAdapter } from "@tooee/shell";
|
|
6
|
+
|
|
6
7
|
import type { AnyContent } from "../types.js";
|
|
7
8
|
import { useContentCommands } from "./use-content-commands.js";
|
|
8
9
|
|
|
@@ -33,7 +34,7 @@ export const useContentDocument = function useContentDocument<T>(
|
|
|
33
34
|
rows: readonly T[],
|
|
34
35
|
adapter: DocumentRowAdapter<T>,
|
|
35
36
|
{ actions, content, decorations, textContent }: ContentDocumentProps,
|
|
36
|
-
options: ContentDocumentOptions<T
|
|
37
|
+
options: ContentDocumentOptions<T>
|
|
37
38
|
): ContentDocumentResult<T> {
|
|
38
39
|
const { showLineNumbers } = useContentCommands({ content, textContent });
|
|
39
40
|
const document = useDocumentController<T>({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo } from "react";
|
|
2
|
-
import { useSelector } from "@xstate/store-react";
|
|
3
|
-
import type { AnyContent, ContentProvider } from "../types.js";
|
|
4
1
|
import type { MarkSet } from "@tooee/marks";
|
|
2
|
+
import { useSelector } from "@xstate/store-react";
|
|
3
|
+
import { useCallback, useEffect, useMemo } from "react";
|
|
4
|
+
|
|
5
5
|
import type { ContentLoaderStatus } from "../content-loader-store.js";
|
|
6
6
|
import {
|
|
7
7
|
createContentLoaderStore,
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
selectStatus,
|
|
15
15
|
selectStreaming,
|
|
16
16
|
} from "../content-loader-store.js";
|
|
17
|
+
import type { AnyContent, ContentProvider } from "../types.js";
|
|
17
18
|
|
|
18
19
|
/** Reactive state exposed by the content provider loader. */
|
|
19
20
|
export interface ContentLoaderState {
|
|
@@ -26,7 +27,7 @@ export interface ContentLoaderState {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export const useContentLoader = function useContentLoader(
|
|
29
|
-
contentProvider: ContentProvider
|
|
30
|
+
contentProvider: ContentProvider
|
|
30
31
|
): ContentLoaderState {
|
|
31
32
|
const store = useMemo(createContentLoaderStore, []);
|
|
32
33
|
const loadSeq = useSelector(store, (snapshot) => selectLoadSeq(snapshot.context));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useProvideCommandContextKey } from "@tooee/commands";
|
|
2
2
|
import type { MarkSet } from "@tooee/marks";
|
|
3
|
+
|
|
3
4
|
import type { AnyContent } from "../types.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -56,7 +57,7 @@ type ViewCommandContextInput =
|
|
|
56
57
|
|
|
57
58
|
/** Resolve the hook's public eager-or-lazy option union at its boundary. */
|
|
58
59
|
const resolveViewCommandContextOptions = function resolveViewCommandContextOptions(
|
|
59
|
-
options: ViewCommandContextInput
|
|
60
|
+
options: ViewCommandContextInput
|
|
60
61
|
): ProvideViewCommandContextOptions {
|
|
61
62
|
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- public hook boundary distinguishes the documented lazy options callback from eager options
|
|
62
63
|
return typeof options === "function" ? options() : options;
|
|
@@ -96,9 +97,9 @@ export const createViewCommandContext = function createViewCommandContext({
|
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
export const useProvideViewCommandContext = function useProvideViewCommandContext(
|
|
99
|
-
options: ViewCommandContextInput
|
|
100
|
+
options: ViewCommandContextInput
|
|
100
101
|
): void {
|
|
101
102
|
useProvideCommandContextKey("view", () =>
|
|
102
|
-
createViewCommandContext(resolveViewCommandContextOptions(options))
|
|
103
|
+
createViewCommandContext(resolveViewCommandContextOptions(options))
|
|
103
104
|
);
|
|
104
105
|
};
|
package/src/launch.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { launchCli, runCliSession } from "@tooee/shell";
|
|
2
1
|
import type { ActionDefinition } from "@tooee/commands";
|
|
3
2
|
import type { CodeBlockRenderer } from "@tooee/renderers";
|
|
4
3
|
import { Outlet, RouterProvider } from "@tooee/router";
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
4
|
+
import { launchCli, runCliSession } from "@tooee/shell";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
|
|
7
7
|
import { DirectoryView } from "./directory-view.js";
|
|
8
|
+
import type { LinkHandler } from "./link-handlers.js";
|
|
9
|
+
import { createStandaloneRouter } from "./standalone-router.js";
|
|
8
10
|
import type { ContentProvider, ContentRenderer } from "./types.js";
|
|
9
|
-
import type { ReactNode } from "react";
|
|
10
11
|
|
|
11
12
|
export interface ViewLaunchOptions {
|
|
12
13
|
contentProvider: ContentProvider;
|
|
@@ -44,12 +45,12 @@ export const launch = async function launch(options: ViewLaunchOptions): Promise
|
|
|
44
45
|
{
|
|
45
46
|
stdinPolicy: "tty-if-piped",
|
|
46
47
|
stdoutPolicy: "tty-if-redirected",
|
|
47
|
-
}
|
|
48
|
+
}
|
|
48
49
|
);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
export const launchDirectory = async function launchDirectory(
|
|
52
|
-
options: DirectoryLaunchOptions
|
|
53
|
+
options: DirectoryLaunchOptions
|
|
53
54
|
): Promise<void> {
|
|
54
55
|
await launchCli(<DirectoryView dirPath={options.dirPath} actions={options.actions} />, {
|
|
55
56
|
stdoutPolicy: "tty-if-redirected",
|
package/src/link-handlers.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
|
|
2
3
|
import type { CommandContext } from "@tooee/commands";
|
|
3
4
|
import type { NavigateHandle, RouteDefinition } from "@tooee/router";
|
|
5
|
+
|
|
4
6
|
import { resolveMarkdownLink } from "./markdown-links.js";
|
|
5
7
|
|
|
6
8
|
export interface LinkTarget {
|
|
@@ -44,7 +46,7 @@ export const localFileLinkHandler: LinkHandler = function localFileLinkHandler(l
|
|
|
44
46
|
export const runLinkHandlers = function runLinkHandlers(
|
|
45
47
|
handlers: readonly LinkHandler[],
|
|
46
48
|
link: LinkTarget,
|
|
47
|
-
context: LinkHandlerContext
|
|
49
|
+
context: LinkHandlerContext
|
|
48
50
|
): boolean {
|
|
49
51
|
for (const handler of handlers) {
|
|
50
52
|
// oxlint-disable-next-line typescript/no-unnecessary-boolean-literal-compare -- preserve exact-true consumption for JavaScript callers too
|
package/src/markdown-links.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { statSync } from "node:fs";
|
|
2
2
|
import nodePath from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
4
5
|
import { Lexer } from "marked";
|
|
5
6
|
import type { Token, Tokens } from "marked";
|
|
6
7
|
|
|
@@ -14,7 +15,7 @@ export type LinkResolution =
|
|
|
14
15
|
export const resolveMarkdownLink = function resolveMarkdownLink(
|
|
15
16
|
href: string,
|
|
16
17
|
baseDir: string,
|
|
17
|
-
currentPath?: string
|
|
18
|
+
currentPath?: string
|
|
18
19
|
): LinkResolution {
|
|
19
20
|
try {
|
|
20
21
|
const decoded = decodeURIComponent(href);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
4
3
|
import { useChooseDialog } from "@tooee/choose";
|
|
5
4
|
import { useCommand } from "@tooee/commands";
|
|
6
5
|
import type { CommandContext } from "@tooee/commands";
|
|
@@ -13,13 +12,16 @@ import {
|
|
|
13
12
|
useRouterCommands,
|
|
14
13
|
} from "@tooee/router";
|
|
15
14
|
import type { Codec, RouteDefinition, RouterInstance } from "@tooee/router";
|
|
16
|
-
|
|
15
|
+
/* oxlint-disable no-use-before-define -- the screen closes over the route initialized before router startup */
|
|
16
|
+
import { useMemo } from "react";
|
|
17
|
+
import type { ReactNode } from "react";
|
|
18
|
+
|
|
17
19
|
import { createFileProvider } from "./default-provider.js";
|
|
20
|
+
import type { ViewLaunchOptions } from "./launch.js";
|
|
18
21
|
import { runLinkHandlers } from "./link-handlers.js";
|
|
19
22
|
import { markdownLinks } from "./markdown-links.js";
|
|
20
23
|
import type { MarkdownLink } from "./markdown-links.js";
|
|
21
24
|
import { getTextContent } from "./types.js";
|
|
22
|
-
import type { ViewLaunchOptions } from "./launch.js";
|
|
23
25
|
import { View } from "./view.js";
|
|
24
26
|
|
|
25
27
|
const documentParams: Codec<{ path?: string }> = {
|
|
@@ -45,7 +47,7 @@ interface StandaloneRouter {
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export const createStandaloneRouter = function createStandaloneRouter(
|
|
48
|
-
options: ViewLaunchOptions
|
|
50
|
+
options: ViewLaunchOptions
|
|
49
51
|
): StandaloneRouter {
|
|
50
52
|
const DocumentScreen = function DocumentScreen(): ReactNode {
|
|
51
53
|
useRouterCommands();
|
|
@@ -56,7 +58,7 @@ export const createStandaloneRouter = function createStandaloneRouter(
|
|
|
56
58
|
const provider = useMemo(
|
|
57
59
|
() =>
|
|
58
60
|
documentPath === undefined ? options.contentProvider : createFileProvider(documentPath),
|
|
59
|
-
[documentPath]
|
|
61
|
+
[documentPath]
|
|
60
62
|
);
|
|
61
63
|
const activate = (href: string, command: CommandContext): boolean => {
|
|
62
64
|
if (options.filePath === undefined) {
|
|
@@ -67,7 +69,7 @@ export const createStandaloneRouter = function createStandaloneRouter(
|
|
|
67
69
|
return runLinkHandlers(
|
|
68
70
|
options.linkHandlers ?? [],
|
|
69
71
|
{ baseDir: path.dirname(currentPath), currentPath, href },
|
|
70
|
-
{ command, documentRoute, navigate }
|
|
72
|
+
{ command, documentRoute, navigate }
|
|
71
73
|
);
|
|
72
74
|
};
|
|
73
75
|
useCommand({
|
package/src/types.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import type { ImageFit, ImageRenderProtocol, ImageSource } from "@opentui/core";
|
|
3
2
|
import type { CommandContext } from "@tooee/commands";
|
|
3
|
+
import type { MarkSet } from "@tooee/marks";
|
|
4
4
|
import { formatTableCell } from "@tooee/renderers";
|
|
5
5
|
import type { ColumnDef, SourceLineRow, TableRow } from "@tooee/renderers";
|
|
6
6
|
import type { DocumentController } from "@tooee/shell";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
8
|
|
|
9
9
|
// === Built-in content types ===
|
|
10
10
|
|
|
@@ -149,7 +149,7 @@ export const isBuiltinContent = function isBuiltinContent(content: AnyContent):
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
export const isCustomContent = function isCustomContent(
|
|
152
|
-
content: AnyContent
|
|
152
|
+
content: AnyContent
|
|
153
153
|
): content is CustomContent {
|
|
154
154
|
return !BUILTIN_FORMATS.has(content.format);
|
|
155
155
|
};
|
|
@@ -186,7 +186,7 @@ export const getTextContent = function getTextContent(content: AnyContent): stri
|
|
|
186
186
|
case "table": {
|
|
187
187
|
const headers = content.columns.map((column) => column.header ?? column.key);
|
|
188
188
|
const rowLines = content.rows.map((row) =>
|
|
189
|
-
content.columns.map((column) => formatTableCell(row[column.key])).join("\t")
|
|
189
|
+
content.columns.map((column) => formatTableCell(row[column.key])).join("\t")
|
|
190
190
|
);
|
|
191
191
|
return [headers.join("\t"), ...rowLines].join("\n");
|
|
192
192
|
}
|
package/src/view.tsx
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from "react";
|
|
2
|
-
import { useTheme } from "@tooee/themes";
|
|
3
1
|
import type { ActionDefinition } from "@tooee/commands";
|
|
2
|
+
import { DIFF_CODE_BLOCK_RENDERERS } from "@tooee/diff";
|
|
4
3
|
import type { MarkSet } from "@tooee/marks";
|
|
5
4
|
import type { CodeBlockRenderer } from "@tooee/renderers";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
9
|
-
|
|
10
|
-
import { ViewState } from "./components/view-state.js";
|
|
5
|
+
import { useTheme } from "@tooee/themes";
|
|
6
|
+
import { useCallback, useMemo, useState } from "react";
|
|
7
|
+
import type { ReactNode } from "react";
|
|
8
|
+
|
|
11
9
|
import {
|
|
12
10
|
MarkdownSubview,
|
|
13
11
|
CodeSubview,
|
|
@@ -16,7 +14,10 @@ import {
|
|
|
16
14
|
DiffSubview,
|
|
17
15
|
CustomSubview,
|
|
18
16
|
} from "./components/subviews/index.js";
|
|
19
|
-
import
|
|
17
|
+
import { ViewState } from "./components/view-state.js";
|
|
18
|
+
import { useContentLoader } from "./hooks/use-content-loader.js";
|
|
19
|
+
import { isCustomContent } from "./types.js";
|
|
20
|
+
import type { ContentProvider, ContentRenderer, MarkdownLinkActivateHandler } from "./types.js";
|
|
20
21
|
|
|
21
22
|
interface ViewProps {
|
|
22
23
|
contentProvider: ContentProvider;
|
|
@@ -66,7 +67,7 @@ export const View = function View({
|
|
|
66
67
|
// registers its own renderer for those types.
|
|
67
68
|
const mergedCodeBlockRenderers = useMemo(
|
|
68
69
|
() => ({ ...DIFF_CODE_BLOCK_RENDERERS, ...codeBlockRenderers }),
|
|
69
|
-
[codeBlockRenderers]
|
|
70
|
+
[codeBlockRenderers]
|
|
70
71
|
);
|
|
71
72
|
|
|
72
73
|
if ((error?.length ?? 0) > 0) {
|