paseo-omni-reader 0.1.1 → 0.1.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/OVERVIEW.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Omni Reader provides read-only workspace previews for Markdown, PDF, Word, Excel and PowerPoint. Open files in the main panel or on the side using Paseo’s **Open location** settings. The plugin also renders LaTeX in streaming assistant replies. Use **Restore original reply** to switch back to Paseo’s Markdown.
4
4
 
5
- Use Paseo 0.17.5 or newer on the daemon and client. The plugin supports browser, desktop, iOS and Android clients. If Paseo asks which Markdown viewer to use, choose Omni Reader and remember the choice. A Git installation requires Node.js 22 or newer and npm on the daemon host. The plugin builds its rendering worker from locked dependencies during installation.
5
+ Use Paseo 0.17.5 or newer on the daemon and client. The plugin supports browser, desktop, iOS and Android clients. If Paseo asks which Markdown viewer to use, choose Omni Reader and remember the choice.
6
6
 
7
- Inline fractions get room for the numerator and denominator. Standalone equations are centered. Both follow Paseo’s chat content font size, with separate size presets from 50% to 200% in the plugin settings. Hover for LaTeX or click to copy in a browser. Touch and hold any formula in the native app to show or copy its LaTeX. Failed formulas keep their source and offer a retry.
7
+ Inline fractions get room for the numerator and denominator. Standalone equations are centered. Both follow Paseo’s chat content font size, with separate size presets from 50% to 200% in the plugin settings. Hover for LaTeX or click to copy in a browser. On mobile, tap a formula to preview it and copy its LaTeX. The preview includes a **Copy LaTeX source** button. Failed formulas keep their source and offer a retry.
8
8
 
9
9
  Markdown supports the same LaTeX as chat, a source view, and loading large files as you read. PDF and formatted Office pages scroll vertically. At 100%, an entire page fits the viewport by width or height. Use the toolbar or focus the preview and press `+`, `-`, or `0`. PDFs can be up to 128 MiB. For Office files up to 24 MiB, LibreOffice on the Paseo host renders formatted Word pages, Excel print layouts and PowerPoint slides. Excel also opens in a scrollable read-only worksheet grid that works without LibreOffice.
10
10
 
package/OVERVIEW.zh-CN.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Omni Reader 为工作区中的 Markdown、PDF、Word、Excel 和 PowerPoint 提供只读预览。文件可按 Paseo 的「打开位置」设置在主面板或侧边打开。插件也会在流式助手回复中渲染 LaTeX。点击**还原原始回复**可切回 Paseo 的 Markdown。
4
4
 
5
- 守护进程和客户端均需 Paseo 0.17.5 或更新版本,支持浏览器、桌面客户端、iOS 和 Android。如果 Paseo 询问 Markdown 的打开方式,选择 Omni Reader 并记住。通过 Git 安装时,守护进程主机需有 Node.js 22 或更新版本及 npm。插件在安装时根据锁定的依赖构建渲染进程。
5
+ 守护进程和客户端均需 Paseo 0.17.5 或更新版本,支持浏览器、桌面客户端、iOS 和 Android。如果 Paseo 询问 Markdown 的打开方式,选择 Omni Reader 并记住。
6
6
 
7
- 行内分数按分子和分母所需的高度排版,独立公式居中。聊天中的两种公式均跟随 Paseo 的内容字号,插件设置可分别选择 50% 至 200% 的字号档位。浏览器中悬停可看 LaTeX 原文,点击可复制。原生 App 中长按任意公式即可显示或复制 LaTeX。渲染失败时会保留源码并提供重试。
7
+ 行内分数按分子和分母所需的高度排版,独立公式居中。聊天中的两种公式均跟随 Paseo 的内容字号,插件设置可分别选择 50% 至 200% 的字号档位。浏览器中悬停可看 LaTeX 原文,点击可复制。手机上点按公式即可预览并复制 LaTeX,预览中也有**复制 LaTeX 原文**按钮。渲染失败时会保留源码并提供重试。
8
8
 
9
9
  Markdown 可显示与聊天相同的 LaTeX、切换源码,并随阅读加载大文件。PDF 和带排版的 Office 预览可连续上下滚动。100% 时整页按宽度或高度适配。使用工具栏缩放,也可点击预览后按 `+`、`-` 或 `0`。PDF 预览上限为 128 MiB。在 Paseo 主机安装 LibreOffice 后,最大 24 MiB 的 Office 文件可按 Word 页面、Excel 打印版式和 PowerPoint 幻灯片预览。Excel 还提供无需 LibreOffice 的可滚动只读工作表网格。
10
10
 
package/README.md CHANGED
@@ -10,17 +10,15 @@ Omni Reader adds LaTeX to streaming assistant replies and read-only previews for
10
10
 
11
11
  ## What you can read
12
12
 
13
- - **Assistant replies.** Complete formulas render during streaming. Inline fractions have room to show their numerator and denominator, and standalone equations are centered. Tables size their columns to their content and center when they fit. Wide tables and long code scroll horizontally. Hover to see LaTeX or click to copy in a browser. Touch and hold any formula in the native app to see or copy its source. Use **Restore original reply** below an enhanced reply to return to Paseo’s Markdown. **Resume rendering** appears in the same spot. Paseo provides the turn footer in both views. Inline and display formulas follow Paseo’s content font size. Choose a separate size preset from 50% to 200% for each in the plugin settings.
14
- - **Workspace files.** Open Markdown, `.pdf`, `.docx`, `.xlsx`, and `.pptx` from chat links or the file tree. Paseo’s **Open location** settings let you choose the main panel or side pane separately for chat links and file tree selections. Phones use Paseo’s file preview sheet. Markdown uses the same formula settings as chat, supports preview/source switching, and loads large documents as you read.
13
+ - **Assistant replies.** Complete formulas render during streaming. Inline fractions have room to show their numerator and denominator, and standalone equations are centered. Tables size their columns to their content and center when they fit. Wide tables and long code scroll horizontally. Hover to see LaTeX or click to copy in a browser. On mobile, tap a formula to preview it and copy its LaTeX. Use **Copy LaTeX source** in the preview to copy it again. Use **Restore original reply** below an enhanced reply to return to Paseo’s Markdown. **Resume rendering** appears in the same spot. Paseo provides the turn footer in both views. Inline and display formulas follow Paseo’s content font size. Choose a separate size preset from 50% to 200% for each in the plugin settings.
14
+ - **Workspace files.** Open Markdown, `.pdf`, `.docx`, `.xlsx`, and `.pptx` from chat links or the file tree. Paseo’s **Open location** settings let you choose the main panel or side pane separately for chat links and file tree selections. Phones use Paseo’s file preview sheet. Markdown uses the same formula settings as chat, supports preview/source switching, and loads large documents as you read. On desktop, rendered Markdown follows Paseo’s **Appearance → Content width** setting.
15
15
  - **Continuous pages.** PDF and formatted Office pages stack vertically. At 100%, each entire page fits the preview with either its width or height filling the available space. Drag the zoom slider or enter a percentage from 25% to 400%. Hover over toolbar icons for labels. Scroll with the mouse wheel and drag to pan. Click the preview and press `+`, `-`, or `0` to zoom in, zoom out, or fit the page. On native clients, pinch to zoom and pan with one finger.
16
16
  - **Excel worksheets.** Read sheets in a scrollable grid with row and column headings, workbook tabs, merged cells, and basic cell styling. Columns expand to fit their contents and long text wraps onto taller rows. Pinch to zoom and drag with one finger on a phone. Use **Print layout** to view the formatted print output and charts when LibreOffice is available on the Paseo host.
17
17
  - **External editing.** In Paseo Desktop, **Open externally** opens the original file in the system’s default app when the workspace is on the local daemon. Browsers and remote desktop workspaces download a copy. On iOS and Android, the action hands a copy to the system share sheet. On Android builds where sharing is unavailable, use **Download** from Paseo’s file menu.
18
18
 
19
- | PDF reader | PowerPoint preview |
19
+ | Markdown and formula settings | PDF and Office previews |
20
20
  | --- | --- |
21
- | ![Landscape PDF survey plate followed by a portrait page in continuous view](assets/pdf-en.png) | ![PowerPoint slide with a line chart, slide navigation and zoom controls](assets/powerpoint-en.png) |
22
-
23
- See the [Excel worksheet with wrapped notes](assets/excel-zh-CN.png), [Markdown preview with formulas and code](assets/markdown-zh-CN.png), [Simplified Chinese chat example](assets/chat-zh-CN.png), and [bilingual formula size settings](assets/settings-zh-CN.png).
21
+ | ![Rendered Markdown with LaTeX and separate inline and display formula size controls](assets/markdown-en.png) | ![PDF survey map, formatted Word page, Excel worksheet with wrapped notes, and PowerPoint line chart](assets/documents-en.png) |
24
22
 
25
23
  ## Install from GitHub
26
24
 
package/README.zh-CN.md CHANGED
@@ -6,21 +6,19 @@
6
6
 
7
7
  Omni Reader 是 Paseo 阅览增强插件。它为流式聊天加入 LaTeX 排版,也为工作区里的 Markdown、PDF、Word、Excel 和 PowerPoint 提供只读预览。
8
8
 
9
- ![Paseo 中文回复中的行内分数、公式表格、居中公式和文件链接](assets/chat-zh-CN.png)
9
+ ![Paseo 英文回复中的行内分数、公式表格、居中公式和文件链接](assets/cover-en.png)
10
10
 
11
11
  ## 阅览体验
12
12
 
13
- - **聊天公式。** 流式回复中的公式闭合后即可渲染。行内分数按分子和分母所需的高度排版,独立公式居中。表格按内容调整列宽,放得下时居中,宽表格和长代码各自横向滚动。浏览器悬停看 LaTeX 原文,点击复制。原生 App 长按任意公式即可查看或复制。点击回复下方的**还原原始回复**可切回 Paseo 的 Markdown,同一位置会显示**恢复增强渲染**。两种视图都使用 Paseo 的回合页脚。行内和独立公式都跟随 Paseo 的内容字号,在插件设置中可分别选择 50% 至 200% 的字号档位。
14
- - **工作区文件。** 从聊天链接或文件树打开 Markdown、`.pdf`、`.docx`、`.xlsx` 和 `.pptx`。在 Paseo 的「打开位置」里,可分别设置聊天链接和文件树打开在主面板还是侧边。手机使用 Paseo 的文件预览窗口。Markdown 使用与聊天相同的公式设置,可切换预览和源码,长文档按需加载。
13
+ - **聊天公式。** 流式回复中的公式闭合后即可渲染。行内分数按分子和分母所需的高度排版,独立公式居中。表格按内容调整列宽,放得下时居中,宽表格和长代码各自横向滚动。浏览器悬停看 LaTeX 原文,点击复制。手机上点按公式即可预览并复制 LaTeX,也可点预览里的**复制 LaTeX 原文**再次复制。点击回复下方的**还原原始回复**可切回 Paseo 的 Markdown,同一位置会显示**恢复增强渲染**。两种视图都使用 Paseo 的回合页脚。行内和独立公式都跟随 Paseo 的内容字号,在插件设置中可分别选择 50% 至 200% 的字号档位。
14
+ - **工作区文件。** 从聊天链接或文件树打开 Markdown、`.pdf`、`.docx`、`.xlsx` 和 `.pptx`。在 Paseo 的「打开位置」里,可分别设置聊天链接和文件树打开在主面板还是侧边。手机使用 Paseo 的文件预览窗口。Markdown 使用与聊天相同的公式设置,可切换预览和源码,长文档按需加载。桌面端的 Markdown 排版宽度跟随 Paseo 的「外观 → 内容宽度」。
15
15
  - **连续页面。** PDF 和带排版的 Office 预览按页上下排列。100% 时每页完整显示,宽度或高度贴合可用区域。拖动滑杆或输入 25% 至 400% 的百分比可调整缩放,鼠标悬停工具栏图标可查看提示。滚轮上下滚动,按住左键拖动平移。点击预览后按 `+`、`-`、`0` 放大、缩小或恢复适合页面。原生 App 支持双指缩放和单指平移。
16
16
  - **Excel 工作表。** 在网格中双向滚动,按底部标签切换工作表。网格显示行号和列标,保留合并单元格和基础样式。列宽随内容扩展,长文本换行并增加行高。手机上可双指缩放、单指平移。在 Paseo 主机安装 LibreOffice 后,可切换到「打印版式」查看图表和打印效果。
17
17
  - **外部编辑。** 在 Paseo 桌面客户端中,本机守护进程上的文件可通过「在外部打开」交给系统默认应用打开原件。浏览器和桌面端的远程工作区下载副本。iOS 和 Android 通过系统分享交给其他 App。Android 系统分享不可用时,可从 Paseo 文件菜单下载副本。
18
18
 
19
- | PDF 阅读器 | PowerPoint 预览 |
19
+ | Markdown 与公式字号 | PDF 与 Office 预览 |
20
20
  | --- | --- |
21
- | ![连续滚动中的横版 PDF 航拍图与下一张竖版页面](assets/pdf-en.png) | ![PowerPoint 幻灯片中的折线图、页码和缩放控件](assets/powerpoint-en.png) |
22
-
23
- 查看[自动换行的 Excel 备注](assets/excel-zh-CN.png)、[带公式和代码的 Markdown 预览](assets/markdown-zh-CN.png)和[双语公式字号设置](assets/settings-zh-CN.png)。
21
+ | ![渲染后的 Markdown 文档,以及分别设置行内和独立公式字号的选项](assets/markdown-en.png) | ![PDF 航拍图、Word 排版页面、带换行备注的 Excel 工作表和 PowerPoint 折线图](assets/documents-en.png) |
24
22
 
25
23
  ## 从 GitHub 安装
26
24
 
Binary file
Binary file
Binary file
@@ -18,16 +18,17 @@ type ReaderTab = PluginFilePanelProps["tab"] & {
18
18
 
19
19
  type Presentation = "initial" | "fullScreen" | "desktop" | "embedded" | "ignored";
20
20
 
21
- const claimReaderOpen = createReaderOpenGate();
21
+ const readerOpenGate = createReaderOpenGate();
22
22
 
23
- function DesktopReaderBody({ children }: { children: ReactNode }) {
23
+ function DesktopReaderBody({ active, children }: { active: boolean; children: ReactNode }) {
24
24
  const [shown, setShown] = useState(false);
25
25
  useEffect(() => {
26
+ if (!active || shown) return;
26
27
  let frame = requestAnimationFrame(() => {
27
28
  frame = requestAnimationFrame(() => setShown(true));
28
29
  });
29
30
  return () => cancelAnimationFrame(frame);
30
- }, []);
31
+ }, [active, shown]);
31
32
  return shown ? children : <Loading />;
32
33
  }
33
34
 
@@ -60,10 +61,11 @@ export function fileReader(Reader: ComponentType<PluginFilePanelProps>) {
60
61
  const [nativeLayoutReady, setNativeLayoutReady] = useState(false);
61
62
  const [presentation, setPresentation] = useState<Presentation>("initial");
62
63
  const requestOpen = useCallback(() => {
63
- if (!claimReaderOpen(fileKey, owner)) return false;
64
+ if (!readerOpenGate.claim(fileKey, owner)) return false;
64
65
  setPresentation(native ? "fullScreen" : "desktop");
65
66
  return true;
66
67
  }, [fileKey, native, owner]);
68
+ useLayoutEffect(() => () => readerOpenGate.release(fileKey, owner), [fileKey, owner]);
67
69
  const canOpen = active !== false && (!native || active === true || nativeLayoutReady);
68
70
  useLayoutEffect(() => {
69
71
  if (presentation === "initial" && canOpen && !requestOpen()) setPresentation("ignored");
@@ -76,7 +78,11 @@ export function fileReader(Reader: ComponentType<PluginFilePanelProps>) {
76
78
  const fullScreen = presentation === "fullScreen" && active !== false;
77
79
  const awaitNativeLayout = native && active === undefined && presentation === "initial" && !nativeLayoutReady;
78
80
  const showClose = fullScreen || (!layout.compact && !!closeTab);
79
- const close = closeTab ?? (() => setPresentation("embedded"));
81
+ const close = () => {
82
+ readerOpenGate.release(fileKey, owner);
83
+ if (closeTab) closeTab();
84
+ else setPresentation("embedded");
85
+ };
80
86
  const header = (
81
87
  <View testID="omni-reader-header" style={{
82
88
  flexDirection: "row", alignItems: "center", gap: 8, minHeight: 32,
@@ -119,7 +125,7 @@ export function fileReader(Reader: ComponentType<PluginFilePanelProps>) {
119
125
  <View style={{ flex: 1, minHeight: 0, backgroundColor: theme.colors.surface0 }}>
120
126
  {header}
121
127
  {presentation === "desktop" && (
122
- <DesktopReaderBody key={file.path}>
128
+ <DesktopReaderBody key={file.path} active={active !== false}>
123
129
  <Reader {...props} />
124
130
  </DesktopReaderBody>
125
131
  )}
@@ -10,9 +10,11 @@ import { ExternalFileAction } from "./external-file";
10
10
  import { RichMarkdown } from "./markdown";
11
11
  import { messages } from "./messages";
12
12
  import { ReaderFlatList as FlatList, ReaderScrollView as ScrollView } from "./reader-scroll";
13
+ import { webReadingWidth } from "./web";
13
14
 
14
15
  const firstPage: { offset: number; revision?: string; fence?: Fence; table?: TableContinuation } = { offset: 0 };
15
- const readingStyle = { width: "100%", maxWidth: 850, alignSelf: "center" } as const;
16
+ const contentFrame = { width: "100%", alignSelf: "center", paddingHorizontal: 8 } as const;
17
+ const nativeReadingWidth = { maxWidth: 820 };
16
18
  type Page = RpcOutput<typeof readMarkdownPage>;
17
19
 
18
20
  export function MarkdownPanel(props: PluginFilePanelProps) {
@@ -41,9 +43,10 @@ export function MarkdownPanel(props: PluginFilePanelProps) {
41
43
  error={document.error} retry={t("retry")} onRetry={() => setAttempt((value) => value + 1)} />;
42
44
  const singlePage = platform !== "web" && rows.length === 1 && rows[0].nextOffset === null;
43
45
  const scrollKey = `${generation}:${attempt}`;
44
- const contentStyle = { paddingHorizontal: compact ? 14 : 24, paddingVertical: 16 };
46
+ const contentStyle = { paddingHorizontal: compact ? 12 : 16, paddingVertical: 16 };
47
+ const readingWidth = !source && (platform === "web" ? webReadingWidth : nativeReadingWidth);
45
48
  const renderPage = useCallback(({ item, index }: Pick<ListRenderItemInfo<Page>, "item" | "index">) => (
46
- <View style={[readingStyle, !source && index > 0 && { paddingTop: 12 }]}>
49
+ <View testID="omni-markdown-file-frame" style={[contentFrame, readingWidth, !source && index > 0 && { paddingTop: 12 }]}>
47
50
  {item.source.length === 0 && item.nextOffset === null && index === 0 ? (
48
51
  <Text style={{ color: theme.colors.foregroundMuted }}>{t("empty")}</Text>
49
52
  ) : source ? (
@@ -52,7 +55,7 @@ export function MarkdownPanel(props: PluginFilePanelProps) {
52
55
  }}>{item.nextOffset === null ? item.source : item.source.replace(/\r?\n$/, "")}</Text>
53
56
  ) : <RichMarkdown theme={theme} text={item.markdown} compact={compact} hostId={host.id} />}
54
57
  </View>
55
- ), [compact, host.id, source, t, theme]);
58
+ ), [compact, host.id, readingWidth, source, t, theme]);
56
59
 
57
60
  return (
58
61
  <View testID="omni-text-panel" style={{ flex: 1, minHeight: 0, backgroundColor: theme.colors.surface0 }}>
@@ -82,7 +85,7 @@ export function MarkdownPanel(props: PluginFilePanelProps) {
82
85
  contentContainerStyle={contentStyle}
83
86
  renderItem={renderPage}
84
87
  ListFooterComponent={
85
- <View style={[readingStyle, { alignItems: "flex-start", paddingTop: 8 }]}>
88
+ <View style={[contentFrame, readingWidth, { alignItems: "flex-start", paddingTop: 8 }]}>
86
89
  {error || (document.isFetchingNextPage ? <ActivityIndicator color={theme.colors.foregroundMuted} />
87
90
  : document.hasNextPage && <Control title={t("loadMore")} onPress={loadMore} theme={theme} compact={compact} />)}
88
91
  </View>
@@ -4,7 +4,7 @@ import {
4
4
  useRpc, useSettings, useTranslation, type PluginClientContext, type PluginTimelineItemProps,
5
5
  } from "@getpaseo/plugin/client";
6
6
  import { copyText, Icon, Markdown, StreamedText, useToast } from "@getpaseo/plugin/client/ui";
7
- import { Image, Modal, Platform, Pressable, ScrollView as NativeScrollView, Text, View, useWindowDimensions, type LayoutChangeEvent, type TextStyle } from "react-native";
7
+ import { Image, Modal, Platform, Pressable, SafeAreaView, ScrollView as NativeScrollView, Text, View, useWindowDimensions, type LayoutChangeEvent, type TextStyle } from "react-native";
8
8
  import { formulaImageUri, formulasPerRequest, markdownKind, messageSchema, renderFormulas, type Formula, type FormulaImage } from "../shared/contracts";
9
9
  import { findFormulas, formulaKey, formulaTitlePattern, markdownParser } from "../shared/markdown-math";
10
10
  import { inlineMathMarker, inlineMathReferenceFontSize, readingBlocks, type InlineMath, type ReadingBlock } from "../shared/reading-blocks";
@@ -17,7 +17,8 @@ import { ReaderScrollView as ScrollView } from "./reader-scroll";
17
17
  import { bindWebFormulas, webTableStyles } from "./web";
18
18
 
19
19
  const maxDistinctFormulas = 144;
20
- const inlineFormulaBaseScale = 0.51;
20
+ const inlineFormulaBaseScale = 0.5865;
21
+ const displayFormulaBaseScale = 0.85;
21
22
  const displayMathWebReferenceFontSize = 15;
22
23
 
23
24
  export function registerAssistantReading(client: PluginClientContext): () => void {
@@ -176,6 +177,9 @@ const TableBlock = memo(function TableBlock({ rows, theme, formulas, textScale,
176
177
  ) ?? [], [rows, formulas, textScale, web]);
177
178
  return (
178
179
  <ScrollView horizontal nestedScrollEnabled testID="omni-table-scroll"
180
+ keyboardShouldPersistTaps={web ? undefined : "always"}
181
+ decelerationRate={web ? undefined : "fast"}
182
+ bounces={web ? undefined : false}
179
183
  style={{ alignSelf: "center", flexGrow: 0, maxWidth: "100%" }}>
180
184
  <View style={{ borderWidth: 1, borderColor: theme.colors.border, borderRadius: 8, overflow: "hidden" }}>
181
185
  <View role={web ? "table" : undefined} style={web && webTableStyles.table}>
@@ -215,18 +219,20 @@ const TableBlock = memo(function TableBlock({ rows, theme, formulas, textScale,
215
219
  function useCopyFormula() {
216
220
  const { t } = useTranslation(messages);
217
221
  const toast = useToast();
218
- return async (tex: string) => {
222
+ return useCallback(async (tex: string, showToast = true) => {
219
223
  try {
220
224
  await copyText(tex);
221
- toast.show(t("copied"), { variant: "success" });
225
+ if (showToast) toast.show(t("copied"), { variant: "success" });
226
+ return true;
222
227
  } catch {
223
- toast.error(t("formulaCopyError"));
228
+ if (showToast) toast.error(t("formulaCopyError"));
229
+ return false;
224
230
  }
225
- };
231
+ }, [t, toast]);
226
232
  }
227
233
 
228
- function DisplayFormula({ block, theme, scale, onActions }: {
229
- block: Extract<ReadingBlock, { kind: "formula" }>; theme: Theme; scale: number; onActions?: (math: InlineMath) => void;
234
+ function DisplayFormula({ block, theme, scale, onCopy }: {
235
+ block: Extract<ReadingBlock, { kind: "formula" }>; theme: Theme; scale: number; onCopy?: (math: InlineMath) => void;
230
236
  }) {
231
237
  const { t } = useTranslation(messages);
232
238
  const copy = useCopyFormula();
@@ -242,13 +248,8 @@ function DisplayFormula({ block, theme, scale, onActions }: {
242
248
  <Pressable
243
249
  testID="omni-display-formula"
244
250
  accessibilityRole="button" accessibilityLabel={block.tex}
245
- accessibilityHint={t(onActions ? "formulaActionHint" : "copyFormula")}
246
- onPress={onActions ? undefined : () => { void copy(block.tex); }}
247
- onLongPress={onActions && (() => onActions(math))}
248
- accessibilityActions={onActions && [{ name: "activate", label: t("formulaActions") }]}
249
- onAccessibilityAction={onActions && (({ nativeEvent }) => {
250
- if (nativeEvent.actionName === "activate") onActions(math);
251
- })}
251
+ accessibilityHint={t(onCopy ? "formulaCopyHint" : "copyFormula")}
252
+ onPress={onCopy ? () => onCopy(math) : () => { void copy(block.tex); }}
252
253
  style={Platform.OS === "web" ? { cursor: "pointer" } : undefined}
253
254
  >
254
255
  <Image
@@ -264,51 +265,63 @@ function DisplayFormula({ block, theme, scale, onActions }: {
264
265
  );
265
266
  }
266
267
 
267
- function FormulaActions({ formula: { tex, image }, theme, compact, close }: {
268
- formula: InlineMath; theme: Theme; compact: boolean; close: () => void;
268
+ type FormulaSelection = { formula: InlineMath; status: "copying" | "copied" | "failed" };
269
+
270
+ function FormulaPreview({ selection, theme, copy, close }: {
271
+ selection: FormulaSelection; theme: Theme; copy: (formula: InlineMath) => void; close: () => void;
269
272
  }) {
270
273
  const { t } = useTranslation(messages);
271
- const copy = useCopyFormula();
272
- const [showSource, setShowSource] = useState(false);
274
+ const { formula: { tex, image }, status } = selection;
275
+ const [dismissedCopy, setDismissedCopy] = useState<FormulaSelection | null>(null);
276
+ useEffect(() => {
277
+ if (selection.status !== "copied") return;
278
+ const timer = setTimeout(() => setDismissedCopy(selection), 2200);
279
+ return () => clearTimeout(timer);
280
+ }, [selection]);
273
281
  const { height, width } = useWindowDimensions();
274
282
  const cardWidth = Math.min(400, width - 32);
275
- const previewScale = Math.min(1.6, height * 0.35 / image.height);
283
+ const previewScale = Math.min(1.6, (cardWidth - 32) / image.width, height * 0.35 / image.height);
276
284
  return (
277
285
  <Modal transparent animationType="fade" visible onRequestClose={close}
278
286
  supportedOrientations={["portrait", "landscape"]}>
279
- <View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
287
+ <View accessibilityViewIsModal onAccessibilityEscape={close}
288
+ style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
280
289
  <Pressable accessible={false} onPress={close}
281
290
  style={{ position: "absolute", inset: 0, backgroundColor: "rgba(0,0,0,0.45)" }} />
282
- <View accessibilityViewIsModal onAccessibilityEscape={close} style={{
283
- width: cardWidth, maxHeight: height * 0.8, borderRadius: 12, overflow: "hidden",
291
+ <View testID="omni-formula-preview" style={{
292
+ width: cardWidth, gap: 10, padding: 16, borderRadius: 12,
284
293
  backgroundColor: theme.colors.surface1, borderWidth: 1, borderColor: theme.colors.border,
285
294
  }}>
286
- <View style={{ flexDirection: "row", alignItems: "center", paddingLeft: 14, paddingRight: 3 }}>
287
- <Text accessibilityRole="header" style={{
288
- flex: 1, color: theme.colors.foreground, fontWeight: "600",
289
- }}>{t("formulaActions")}</Text>
290
- <Control icon="X" title={t("closeReader")} onPress={close} theme={theme} compact />
291
- </View>
292
- <NativeScrollView style={{ flexGrow: 0, flexShrink: 1 }} contentContainerStyle={{ gap: 8, padding: 12, paddingTop: 0 }}>
293
- <NativeScrollView horizontal nestedScrollEnabled testID="omni-formula-preview"
294
- style={{ flexGrow: 0 }}
295
- contentContainerStyle={{ flexGrow: 1, justifyContent: "center", alignItems: "center" }}>
296
- <Image accessible accessibilityLabel={tex} fadeDuration={0}
297
- source={{ uri: image.uris[0] }} resizeMode="contain"
298
- style={{ width: image.width * previewScale, height: image.height * previewScale }} />
299
- </NativeScrollView>
300
- <View style={{ flexDirection: "row", flexWrap: "wrap", justifyContent: "center", gap: 6 }}>
301
- <Control title={t("copyFormula")} theme={theme} compact={compact} onPress={() => { close(); void copy(tex); }} />
302
- <Control title={t(showSource ? "hideFormula" : "showFormula")} selected={showSource} theme={theme} compact={compact}
303
- onPress={() => setShowSource((current) => !current)} />
304
- </View>
305
- {showSource && (
306
- <Text selectable style={{
307
- color: theme.colors.foreground, fontFamily: "monospace", fontSize: 15, textAlign: "center",
308
- }}>{tex}</Text>
309
- )}
295
+ <Image accessible={false} fadeDuration={0} source={{ uri: image.uris[0] }} resizeMode="contain"
296
+ style={{ alignSelf: "center", width: image.width * previewScale, height: image.height * previewScale }} />
297
+ <NativeScrollView horizontal style={{ flexGrow: 0 }}
298
+ contentContainerStyle={{ flexGrow: 1, justifyContent: "center" }}>
299
+ <Text numberOfLines={1} accessibilityLabel={tex} style={{
300
+ color: theme.colors.foreground, fontFamily: "monospace", fontSize: 14,
301
+ }}>{tex.replace(/\r\n?|\n/g, " ")}</Text>
310
302
  </NativeScrollView>
303
+ {status === "failed" && (
304
+ <Text accessibilityRole="alert" style={{ color: theme.colors.foregroundMuted, textAlign: "center" }}>
305
+ {t("formulaCopyError")}
306
+ </Text>
307
+ )}
308
+ <View style={{ alignItems: "center" }}>
309
+ <Control title={t("copyFormula")}
310
+ theme={theme} compact disabled={status === "copying"} onPress={() => copy({ tex, image })} />
311
+ </View>
311
312
  </View>
313
+ {status === "copied" && dismissedCopy !== selection && (
314
+ <SafeAreaView pointerEvents="none" style={{ position: "absolute", top: 0, left: 0, right: 0 }}>
315
+ <View style={{
316
+ alignSelf: "center", marginTop: 12, borderRadius: 16, borderWidth: 1, borderColor: theme.colors.border,
317
+ paddingHorizontal: 12, paddingVertical: 8, flexDirection: "row", alignItems: "center", gap: 8,
318
+ backgroundColor: theme.colors.surface0,
319
+ }}>
320
+ <Icon name="CheckCircle2" size={18} color={theme.colors.accent} />
321
+ <Text accessibilityLiveRegion="polite" style={{ color: theme.colors.foreground }}>{t("copied")}</Text>
322
+ </View>
323
+ </SafeAreaView>
324
+ )}
312
325
  </View>
313
326
  </Modal>
314
327
  );
@@ -338,10 +351,19 @@ export const RichMarkdown = memo(function RichMarkdown({ text, theme, compact, h
338
351
  const measureContent = useCallback((event: LayoutChangeEvent) => measureFont("content", event), [measureFont]);
339
352
  const measureReference = useCallback((event: LayoutChangeEvent) => measureFont("reference", event), [measureFont]);
340
353
  const effectiveBodySize = bodySize * (native ? fontScale : 1);
341
- const displayScale = (Number(sizes?.displayFormulaSize ?? 100) / 100) * effectiveBodySize / bodyReferenceSize;
342
- const [selectedFormula, setSelectedFormula] = useState<InlineMath | null>(null);
354
+ const displayScale = displayFormulaBaseScale * (Number(sizes?.displayFormulaSize ?? 100) / 100)
355
+ * effectiveBodySize / bodyReferenceSize;
356
+ const [selectedFormula, setSelectedFormula] = useState<FormulaSelection | null>(null);
343
357
  const root = useRef<View>(null);
344
358
  const copy = useCopyFormula();
359
+ const showAndCopyFormula = useCallback((formula: InlineMath) => {
360
+ const selection: FormulaSelection = { formula, status: "copying" };
361
+ setSelectedFormula(selection);
362
+ void copy(formula.tex, false).then((copied) => {
363
+ setSelectedFormula((current) =>
364
+ current === selection ? { formula, status: copied ? "copied" : "failed" } : current);
365
+ });
366
+ }, [copy]);
345
367
  const webActions = useRef({ copy, colors: theme.colors });
346
368
  webActions.current = { copy, colors: theme.colors };
347
369
  useEffect(() => {
@@ -387,9 +409,9 @@ export const RichMarkdown = memo(function RichMarkdown({ text, theme, compact, h
387
409
  })), [color, formulas, hostId, platform, request]);
388
410
  const { blocks, nativeMath, retries, retrying } = useQueries({ queries, combine });
389
411
  const renderNative = useCallback((markdown: string) => (
390
- <NativeMarkdown text={markdown} formulas={nativeMath} theme={theme} onActions={setSelectedFormula}
412
+ <NativeMarkdown text={markdown} formulas={nativeMath} theme={theme} onCopy={showAndCopyFormula}
391
413
  bodySize={bodySize} fontScale={fontScale} />
392
- ), [bodySize, fontScale, nativeMath, theme]);
414
+ ), [bodySize, fontScale, nativeMath, showAndCopyFormula, theme]);
393
415
  return (
394
416
  <View ref={root} testID="omni-markdown" style={{ minWidth: 0, gap: compact ? 12 : 16 }}>
395
417
  {(nativeMath.length > 0 || blocks.some((block) => block.kind === "table" || block.kind === "formula")) && (
@@ -415,7 +437,7 @@ export const RichMarkdown = memo(function RichMarkdown({ text, theme, compact, h
415
437
  renderCell={native ? renderNative : undefined} />
416
438
  );
417
439
  return <DisplayFormula key={`${index}:${block.tex}`} block={block} theme={theme} scale={displayScale}
418
- onActions={native ? setSelectedFormula : undefined} />;
440
+ onCopy={native ? showAndCopyFormula : undefined} />;
419
441
  })}
420
442
  {retries.length > 0 && (
421
443
  <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 4 }}>
@@ -427,7 +449,8 @@ export const RichMarkdown = memo(function RichMarkdown({ text, theme, compact, h
427
449
  </View>
428
450
  )}
429
451
  {selectedFormula !== null && (
430
- <FormulaActions formula={selectedFormula} theme={theme} compact={compact} close={() => setSelectedFormula(null)} />
452
+ <FormulaPreview selection={selectedFormula} theme={theme}
453
+ copy={showAndCopyFormula} close={() => setSelectedFormula(null)} />
431
454
  )}
432
455
  </View>
433
456
  );
@@ -30,11 +30,8 @@ export const messages = defineTranslations({
30
30
  copyFilePath: "Copy workspace path",
31
31
  cancel: "Cancel",
32
32
  retry: "Retry",
33
- formulaActions: "LaTeX formula",
34
- formulaActionHint: "Touch and hold for LaTeX actions",
35
- showFormula: "Show LaTeX",
36
- hideFormula: "Hide LaTeX",
37
- copyFormula: "Copy LaTeX",
33
+ formulaCopyHint: "Tap to preview and copy LaTeX",
34
+ copyFormula: "Copy LaTeX source",
38
35
  formulaCopyError: "Couldn’t copy LaTeX.",
39
36
  formulaError: "Some formulas couldn’t be rendered.",
40
37
  retryRendering: "Retry formulas",
@@ -99,11 +96,8 @@ export const messages = defineTranslations({
99
96
  copyFilePath: "复制工作区路径",
100
97
  cancel: "取消",
101
98
  retry: "重试",
102
- formulaActions: "LaTeX 公式",
103
- formulaActionHint: "长按打开 LaTeX 选项",
104
- showFormula: "显示 LaTeX 原文",
105
- hideFormula: "隐藏 LaTeX 原文",
106
- copyFormula: "复制 LaTeX",
99
+ formulaCopyHint: "点按预览并复制 LaTeX",
100
+ copyFormula: "复制 LaTeX 原文",
107
101
  formulaCopyError: "无法复制 LaTeX。",
108
102
  formulaError: "部分公式未能渲染。",
109
103
  retryRendering: "重试公式渲染",
@@ -33,8 +33,8 @@ function breakableText(text: string) {
33
33
  return parts;
34
34
  }
35
35
 
36
- const InlineFormula = memo(function InlineFormula({ math, scrollWidth, textScale, onActions }: {
37
- math: InlineMath; scrollWidth?: number; textScale: number; onActions: (math: InlineMath) => void;
36
+ const InlineFormula = memo(function InlineFormula({ math, scrollWidth, textScale, onCopy }: {
37
+ math: InlineMath; scrollWidth?: number; textScale: number; onCopy: (math: InlineMath) => void;
38
38
  }) {
39
39
  const { t } = useTranslation(messages);
40
40
  const { image, tex } = math;
@@ -46,10 +46,8 @@ const InlineFormula = memo(function InlineFormula({ math, scrollWidth, textScale
46
46
  testID="omni-inline-math"
47
47
  accessibilityRole="button"
48
48
  accessibilityLabel={tex}
49
- accessibilityHint={t("formulaActionHint")}
50
- onLongPress={() => onActions(math)}
51
- accessibilityActions={[{ name: "activate", label: t("formulaActions") }]}
52
- onAccessibilityAction={({ nativeEvent }) => { if (nativeEvent.actionName === "activate") onActions(math); }}
49
+ accessibilityHint={t("formulaCopyHint")}
50
+ onPress={() => onCopy(math)}
53
51
  style={{ width, height, paddingTop: baseline * textScale }}
54
52
  >
55
53
  <Text allowFontScaling={false} importantForAccessibility="no" style={{ fontSize: 1, lineHeight: 1, color: "transparent" }}>{"\u200B"}</Text>
@@ -64,7 +62,7 @@ const InlineFormula = memo(function InlineFormula({ math, scrollWidth, textScale
64
62
  });
65
63
 
66
64
  function inlineRuns(tokens: Token[], formulas: InlineMath[], theme: Theme, maxWidth: number,
67
- onActions: (math: InlineMath) => void, fontSize: number, fontScale: number): ReactNode[] {
65
+ onCopy: (math: InlineMath) => void, fontSize: number, fontScale: number): ReactNode[] {
68
66
  const runs: ReactNode[] = [];
69
67
  const marks: string[] = [];
70
68
  const textScale = fontScale * fontSize / inlineMathReferenceFontSize;
@@ -109,7 +107,7 @@ function inlineRuns(tokens: Token[], formulas: InlineMath[], theme: Theme, maxWi
109
107
  addText(token.content.slice(offset, match.index));
110
108
  const math = formulas[Number(match[1])];
111
109
  if (math) runs.push(
112
- <InlineFormula key={runs.length} math={math} textScale={textScale} onActions={onActions}
110
+ <InlineFormula key={runs.length} math={math} textScale={textScale} onCopy={onCopy}
113
111
  scrollWidth={math.image.width * textScale > maxWidth ? maxWidth : undefined} />,
114
112
  );
115
113
  offset = match.index + match[0].length;
@@ -129,8 +127,8 @@ function inlineRuns(tokens: Token[], formulas: InlineMath[], theme: Theme, maxWi
129
127
  return runs;
130
128
  }
131
129
 
132
- function NativeBlock({ source, tokens, theme, formulas, onActions, bodySize, fontScale }: {
133
- source: string; tokens: Token[]; theme: Theme; formulas: InlineMath[]; onActions: (math: InlineMath) => void;
130
+ function NativeBlock({ source, tokens, theme, formulas, onCopy, bodySize, fontScale }: {
131
+ source: string; tokens: Token[]; theme: Theme; formulas: InlineMath[]; onCopy: (math: InlineMath) => void;
134
132
  bodySize: number; fontScale: number;
135
133
  }) {
136
134
  const [width, setWidth] = useState(0);
@@ -166,7 +164,7 @@ function NativeBlock({ source, tokens, theme, formulas, onActions, bodySize, fon
166
164
  {!!prefix && <Text style={{ color: theme.colors.foregroundMuted, fontSize, lineHeight: Math.round(fontSize * 1.5) }}>{prefix}</Text>}
167
165
  <View style={{ flex: 1, flexDirection: "row", flexWrap: "wrap", alignItems: "baseline", rowGap: 1 }}>
168
166
  {inlineRuns(token.children, formulas, theme,
169
- width ? Math.max(1, width - indent - (prefix ? 26 : 0)) : Infinity, onActions, fontSize, fontScale)}
167
+ width ? Math.max(1, width - indent - (prefix ? 26 : 0)) : Infinity, onCopy, fontSize, fontScale)}
170
168
  </View>
171
169
  </View>
172
170
  );
@@ -175,8 +173,8 @@ function NativeBlock({ source, tokens, theme, formulas, onActions, bodySize, fon
175
173
  );
176
174
  }
177
175
 
178
- export const NativeMarkdown = memo(function NativeMarkdown({ text, formulas, theme, onActions, bodySize, fontScale }: {
179
- text: string; formulas: InlineMath[]; theme: Theme; onActions: (math: InlineMath) => void;
176
+ export const NativeMarkdown = memo(function NativeMarkdown({ text, formulas, theme, onCopy, bodySize, fontScale }: {
177
+ text: string; formulas: InlineMath[]; theme: Theme; onCopy: (math: InlineMath) => void;
180
178
  bodySize: number; fontScale: number;
181
179
  }) {
182
180
  const sections = useMemo(() => {
@@ -203,7 +201,7 @@ export const NativeMarkdown = memo(function NativeMarkdown({ text, formulas, the
203
201
  <Fragment key={index}>
204
202
  {section.tokens ? (
205
203
  <NativeBlock source={text} tokens={section.tokens} theme={theme} formulas={formulas}
206
- onActions={onActions} bodySize={bodySize} fontScale={fontScale} />
204
+ onCopy={onCopy} bodySize={bodySize} fontScale={fontScale} />
207
205
  ) : <Markdown>{section.text}</Markdown>}
208
206
  </Fragment>
209
207
  ));
@@ -1,17 +1,22 @@
1
- const repeatOpenWindowMs = 800;
1
+ const repeatOpenWindowMs = 250;
2
2
 
3
3
  export function createReaderOpenGate(now = Date.now) {
4
4
  const recent = new Map<string, { owner: symbol; expiresAt: number }>();
5
5
 
6
- return (key: string, owner: symbol): boolean => {
7
- const time = now();
8
- for (const [recentKey, entry] of recent) {
9
- if (entry.expiresAt <= time) recent.delete(recentKey);
10
- }
11
- const opening = recent.get(key);
12
- if (opening) return opening.owner === owner;
6
+ return {
7
+ claim(key: string, owner: symbol): boolean {
8
+ const time = now();
9
+ for (const [recentKey, entry] of recent) {
10
+ if (entry.expiresAt <= time) recent.delete(recentKey);
11
+ }
12
+ const opening = recent.get(key);
13
+ if (opening) return opening.owner === owner;
13
14
 
14
- recent.set(key, { owner, expiresAt: time + repeatOpenWindowMs });
15
- return true;
15
+ recent.set(key, { owner, expiresAt: time + repeatOpenWindowMs });
16
+ return true;
17
+ },
18
+ release(key: string, owner: symbol) {
19
+ if (recent.get(key)?.owner === owner) recent.delete(key);
20
+ },
16
21
  };
17
22
  }
@@ -4,7 +4,7 @@ import { readerSettings } from "../shared/reader-settings";
4
4
  import { messages } from "./messages";
5
5
 
6
6
  const sizeFields = ["inlineFormulaSize", "displayFormulaSize"] as const;
7
- const sizePresets = ["50", "70", "85", "100", "115", "135", "160", "200"];
7
+ const sizePresets = ["50", "70", "85", "90", "100", "115", "125", "135", "160", "180", "200"];
8
8
  const presetOptions = sizePresets.map((value) => ({ value, label: `${value}%` }));
9
9
 
10
10
  export function ReaderSettings() {
package/client/web.ts CHANGED
@@ -5,6 +5,8 @@ import { inlineMathReferenceFontSize } from "../shared/reading-blocks";
5
5
  import type { Theme } from "./controls";
6
6
  import type { Contact, Point } from "./viewport-geometry";
7
7
 
8
+ export const webReadingWidth = { maxWidth: "var(--content-max-width, 820px)" } as unknown as ViewStyle;
9
+
8
10
  export const webTableStyles = {
9
11
  table: { display: "table", width: "max-content", borderSpacing: 0 },
10
12
  row: { display: "table-row" },
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "paseo-omni-reader",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "paseo-omni-reader",
9
- "version": "0.1.1",
9
+ "version": "0.1.2",
10
10
  "dependencies": {
11
11
  "@xmldom/xmldom": "0.9.12",
12
12
  "markdown-it": "15.0.3",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "paseo-omni-reader",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Read streaming LaTeX, preview workspace documents and spreadsheets, and zoom and pan PDFs in Paseo.",
5
5
  "repository": {
6
6
  "type": "git",
package/paseo-plugin.json CHANGED
@@ -5,12 +5,8 @@
5
5
  "icon": "assets/icon.png",
6
6
  "media": [
7
7
  "assets/cover-en.png",
8
- "assets/pdf-en.png",
9
- "assets/powerpoint-en.png",
10
- "assets/excel-zh-CN.png",
11
- "assets/markdown-zh-CN.png",
12
- "assets/chat-zh-CN.png",
13
- "assets/settings-zh-CN.png"
8
+ "assets/markdown-en.png",
9
+ "assets/documents-en.png"
14
10
  ],
15
11
  "translations": {
16
12
  "zh-CN": {
Binary file
Binary file
Binary file
package/assets/pdf-en.png DELETED
Binary file
Binary file
Binary file