@jaxzhou/dsh-file-explorer 0.1.3 → 0.1.5

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 CHANGED
@@ -20,11 +20,14 @@ dsh --profile web
20
20
 
21
21
  ## Demo
22
22
 
23
- [![The Files tab beside Chat and Trajectory: a workspace tree on the left, and
24
- on the right a preview that highlights source, renders Markdown and JSON, and
25
- offers a Rendered/Source toggle](media/demo.gif)](media/demo.mp4)
23
+ [![The Files tab beside Chat and Trajectory: a workspace tree on the left, and a
24
+ rendered Markdown document on the right whose toolbar carries Copy, Source and
25
+ Export PDF](media/demo.gif)](media/demo.mp4)
26
26
 
27
- *30 seconds — click for the full-quality MP4.*
27
+ *15 seconds — click for the full-quality MP4.* A primary-school maths workspace: a
28
+ lesson document rendered with its tables, the **Source** toggle showing the
29
+ Markdown behind it, a second document open beside it in its own tab, and **Export
30
+ PDF**, which hands the page to the browser's print dialog.
28
31
 
29
32
  ## What you get
30
33
 
@@ -41,8 +44,8 @@ The right pane picks each tab's body from the file:
41
44
 
42
45
  | Category | Preview |
43
46
  |---|---|
44
- | **Markdown** | Rendered GFM — headings, tables, task lists, quotes, math, footnotes, highlighted code fences — with a **Source** toggle, and **Export PDF** |
45
- | **HTML** | Drawn as a page in a sandboxed frame: the file's own CSS applies, and its scripts run in an opaque origin that cannot reach this application. With a **Source** toggle, and **Export PDF** |
47
+ | **Markdown** | Rendered GFM — headings, tables, task lists, quotes, math, footnotes, images referenced beside the file, highlighted code fences — with a **Source** toggle and an **Export** menu |
48
+ | **HTML** | Drawn as a page in a sandboxed frame: the file's own CSS applies, and its scripts run in an opaque origin that cannot reach this application. With a **Source** toggle and an **Export** menu |
46
49
  | **JSON** | A collapsible tree with per-value copy, and the same toggle |
47
50
  | **Source code** | Syntax highlighting, line numbers, and a copy button for 24 grammars: TypeScript/JavaScript, shell, Python, Ruby, Go, Rust, Java, C, C++, C#, Kotlin, Swift, PHP, YAML, TOML, INI, HTML, CSS, SCSS, Less, SQL, XML, Lua, MDX |
48
51
  | **Images** | PNG, JPEG, GIF, WebP, AVIF, BMP, ICO and SVG, drawn to the pane. An SVG goes through `<img>`, so its scripts never run |
@@ -51,10 +54,18 @@ The right pane picks each tab's body from the file:
51
54
  Text previews wrap at their spaces and keep every word whole; an image reads its
52
55
  complete bytes. Every text body carries a **Copy** control in the pane's toolbar,
53
56
  which copies the file's own text — a rendered Markdown document copies its
54
- Markdown source. A rendered Markdown or HTML file also carries **Export PDF**,
55
- which hands the page to the browser's print dialog: every browser offers "Save as
56
- PDF" there, and its own layout engine keeps the text as text rather than
57
- rasterising the page the way a canvas-based PDF library would.
57
+ Markdown source.
58
+
59
+ A rendered Markdown or HTML document also carries **Export**, which **downloads a
60
+ file directly** — no print dialog — in either of two formats:
61
+
62
+ | Format | What it is |
63
+ |---|---|
64
+ | **PDF** | A picture of the page, laid out as A4 and sliced to fit. The text in it is not selectable. That is deliberate: a text-mode PDF of a Chinese document would need a CJK font embedded in the plugin, which is megabytes for a preview tool |
65
+ | **Word** (`.docx`) | A real Word document: headings, lists, tables, code and images, with the text still text — editable, searchable, and rendered with Word's own fonts. Chinese included |
66
+
67
+ A document's own local assets come with it: the images a Markdown file references
68
+ beside it, and the images and stylesheets an HTML file links to.
58
69
 
59
70
  ## Requirements
60
71
 
@@ -137,12 +148,20 @@ restart the profile.
137
148
  an older tab stays open and reads again when you return to it.
138
149
  - **One root.** The tree is rooted at the session's working directory, and the
139
150
  Host refuses directory listings outside the workspace root.
140
- - **Markdown has no workspace vocabulary.** Relative image paths and file
141
- mentions stay inert; only absolute `http(s)` images load.
151
+ - **Markdown pulls in the images beside it.** A destination relative to the document
152
+ is read through the same workspace reader the file itself came from — up to 24
153
+ images per document and 8 MiB each. A file mention in inline code, a remote URL,
154
+ and an absolute path are left to the renderer's own rules: the first stays inert,
155
+ the second loads directly, and the third is not fetched.
142
156
  - **HTML previews do not resolve relative assets.** A page drawn from a Blob
143
157
  document has no base to resolve its own `style.css` or images against, so only
144
- absolute URLs load there too. An export prints the page as it renders without
145
- its scripts, which a static PDF has no use for anyway.
158
+ absolute URLs load there. **An export does resolve them** — the file it writes is
159
+ read from a copy that has been made to stand alone — so a document can export
160
+ with pictures it does not show in the preview.
161
+ - **A PDF's text is a picture.** Nothing in it can be selected or searched. Export
162
+ Word instead when the text has to stay text.
163
+ - **Long documents are cut at 60 PDF pages**, and an image past 8 MiB is left out;
164
+ both are stated here because a silent cut reads as a complete export.
146
165
 
147
166
  ## Contributing
148
167
 
package/README.zh.md CHANGED
@@ -20,10 +20,12 @@ dsh --profile web
20
20
 
21
21
  ## 演示
22
22
 
23
- [![文件标签与对话、轨迹并列:左侧是工作区目录树,右侧是预览——可高亮源码、渲染
24
- Markdown 与 JSON,并提供「预览/源码」切换](media/demo.gif)](media/demo.mp4)
23
+ [![文件标签与对话、轨迹并列:左侧是工作区目录树,右侧是渲染后的 Markdown 文档,
24
+ 工具栏上带复制、源码与导出 PDF](media/demo.gif)](media/demo.mp4)
25
25
 
26
- *30 秒录屏 —— 点击可打开完整画质的 MP4。*
26
+ *15 秒录屏 —— 点击可打开完整画质的 MP4。* 一个小数学工作区:渲染后的讲义文档
27
+ (含表格)、切到 **源码** 看它背后的 Markdown、在旁边用另一个标签打开第二份文档,
28
+ 最后用 **导出 PDF** 把页面交给浏览器的打印对话框。
27
29
 
28
30
  ## 能做什么
29
31
 
@@ -37,8 +39,8 @@ Markdown 与 JSON,并提供「预览/源码」切换](media/demo.gif)](media/d
37
39
 
38
40
  | 类别 | 预览 |
39
41
  |---|---|
40
- | **Markdown** | 直接渲染为 GFM —— 标题、表格、任务列表、引用、公式、脚注、高亮的代码围栏 —— 并带 **源码** 切换与 **导出 PDF** |
41
- | **HTML** | 在沙箱 iframe 中当作页面绘制:文件自己的 CSS 生效,其脚本运行在不透明源(opaque origin)里,无法触达本应用。带 **源码** 切换与 **导出 PDF** |
42
+ | **Markdown** | 直接渲染为 GFM —— 标题、表格、任务列表、引用、公式、脚注、引用文件旁的图片、高亮的代码围栏 —— 并带 **源码** 切换与 **导出** 菜单 |
43
+ | **HTML** | 在沙箱 iframe 中当作页面绘制:文件自己的 CSS 生效,其脚本运行在不透明源(opaque origin)里,无法触达本应用。带 **源码** 切换与 **导出** 菜单 |
42
44
  | **JSON** | 可折叠树,每个值可单独复制,同样带 **源码** 切换 |
43
45
  | **源码** | 24 种语法的语法高亮、行号与复制按钮:TypeScript/JavaScript、shell、Python、Ruby、Go、Rust、Java、C、C++、C#、Kotlin、Swift、PHP、YAML、TOML、INI、HTML、CSS、SCSS、Less、SQL、XML、Lua、MDX |
44
46
  | **图片** | PNG、JPEG、GIF、WebP、AVIF、BMP、ICO、SVG,自动适配窗格。SVG 经 `<img>` 绘制,其中的脚本不会执行 |
@@ -46,9 +48,18 @@ Markdown 与 JSON,并提供「预览/源码」切换](media/demo.gif)](media/d
46
48
 
47
49
  文本预览在空格处折行、保持单词完整;图片读取完整字节。每一种文本预览在窗格工具栏
48
50
  里都有 **复制** 按钮,复制的是文件自身的文本——渲染态的 Markdown 复制的是它的
49
- Markdown 源码。渲染态的 Markdown 与 HTML 还带 **导出 PDF**:它把页面交给浏览器的
50
- 打印对话框,那里每个浏览器都提供「另存为 PDF」,而排版由浏览器自己的引擎完成
51
- ——文字仍是文字,不像基于 canvas 的 PDF 库那样把整页栅格化。
51
+ Markdown 源码。
52
+
53
+ 渲染态的 Markdown 与 HTML 还带 **导出** 菜单,**直接下载文件**(不走打印对话框),
54
+ 两种格式:
55
+
56
+ | 格式 | 说明 |
57
+ |---|---|
58
+ | **PDF** | 页面的图像:按 A4 排版并分页切分。其中的文字**不可选中**。这是刻意的:中文文档若用文本模式生成 PDF,就必须在插件里内嵌 CJK 字体——对一个预览工具来说是好几 MB |
59
+ | **Word**(`.docx`) | 真正的 Word 文档:标题、列表、表格、代码与图片都在,文字仍是文字——可编辑、可搜索,中文交给 Word 自己的字体渲染 |
60
+
61
+ 文档自带的本地资源会一起带上:Markdown 文件旁边引用的图片,以及 HTML 文件链接的
62
+ 图片与样式表。
52
63
 
53
64
  ## 环境要求
54
65
 
@@ -122,11 +133,17 @@ profile。
122
133
  回到它时会重新读取。
123
134
  - **单一根目录**:目录树以会话工作目录为根,Host 本身也拒绝读取工作区根之外的
124
135
  目录列表。
125
- - **Markdown 不解析工作区词汇**:相对图片路径与文件提及保持原样,只有绝对
126
- `http(s)` 图片会加载。
136
+ - **Markdown 会读入它旁边的图片**:相对文档的图片路径会通过与文件本身相同的
137
+ 工作区读取通道加载——上限为每篇 24 张、单张 8 MiB。行内代码里的文件提及、远程
138
+ URL、绝对路径则交给渲染器自己的规则:第一个保持原样,第二个直接加载,第三个
139
+ 不会去读。
127
140
  - **HTML 预览不解析相对资源**:由 Blob 文档绘制出的页面没有可用来解析自身
128
- `style.css` 或图片的 base,所以同样只有绝对 URL 能加载。导出时按渲染结果打印,
129
- 且不带脚本——静态 PDF 本来也用不上脚本。
141
+ `style.css` 或图片的 base,所以预览里只有绝对 URL 能加载。**导出时会解析**——
142
+ 写出的文件来自一份被补齐成自包含的副本——所以可能有「预览里看不到图,导出里
143
+ 有图」的情况。
144
+ - **PDF 里的文字是图像**,无法选中或搜索。需要文字可编辑时请导出 Word。
145
+ - **超长文档会在 60 页 PDF 处截断**,单张超过 8 MiB 的图片会被跳过;写在这里是因为
146
+ 静默截断会被误认为完整导出。
130
147
 
131
148
  ## 参与开发
132
149