Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/editor/csl/assets/*.csl text eol=lf
src/editor/csl/assets/*.xml text eol=lf
src/editor/csl/assets/*.json text eol=lf
public/third-party/*.txt text eol=lf
public/typst-fonts/LICENSE-* -whitespace
33 changes: 27 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 三平台冒烟 CI:install → typecheck → lint → test → build → cargo check
# 三平台 CI:install → typecheck → lint → test → build → 独立 Unix 负控 + 全目标生产 cargo test
# 供应链约定:仅 actions/* 官方 action,且按完整 commit SHA 锁定;
# pnpm 经 corepack(与本地 packageManager 字段一致)、Rust 经 runner 自带 rustup,零第三方 action。
name: CI
Expand All @@ -16,6 +16,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Expand All @@ -26,10 +27,10 @@ jobs:
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev

- name: Setup Node 22
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
node-version-file: .node-version

- name: Activate pnpm via corepack
run: |
Expand All @@ -51,10 +52,30 @@ jobs:
run: pnpm lint

- name: Test
run: pnpm test
timeout-minutes: 15
run: pnpm test:ci

- name: Build
run: pnpm build

- name: Cargo check
run: cargo check --manifest-path src-tauri/Cargo.toml
- name: Unix permission negative control (isolated legacy strategy)
if: ${{ !cancelled() && runner.os != 'Windows' }}
timeout-minutes: 3
run: node scripts/acceptance/run-unix-negative.mjs

- name: Cargo tests (all production targets, serial)
if: ${{ !cancelled() }}
timeout-minutes: 25
# --all-targets typechecks and builds the application binary as well as the tested library.
# A separate cargo check would rebuild dependency metadata before this code-generation build.
# The wrapper preserves the hard timeout, process cleanup and Unix production assertion.
# Runs even if the separate negative fixture fails; no production assertion is skipped.
run: node scripts/acceptance/run-rust.mjs

- name: Upload acceptance evidence
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4; same locked SHA as release.yml
with:
name: inkstream-acceptance-${{ matrix.os }}
path: coverage/acceptance/
if-no-files-found: error
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
# 草稿 Release 一次性创建(job 永远跑,建 Release 步骤仅 tag push)。bundle 依赖它,杜绝并发建 Release 竞态。
create-release:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Create draft release (tag push only)
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -40,6 +41,7 @@ jobs:

bundle:
needs: create-release
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -67,10 +69,10 @@ jobs:
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev

- name: Setup Node 22
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
node-version-file: .node-version

- name: Activate pnpm via corepack
run: |
Expand Down Expand Up @@ -141,6 +143,7 @@ jobs:

latest-json:
needs: bundle
timeout-minutes: 5
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
## 特性

- **单一内核编辑器**:整个应用就一个 CodeMirror 6 实例,纯文本始终是文档的依据。Source 和 Live Preview 随时切换,光标所在行自动展开源码,支持 11 种语言高亮。
- **本机项目档案**:`Ctrl+Alt+P` 打开左侧档案,管理名称、封面、收藏和内容目录。每个项目记住标签、光标与布局;独立草稿也会暂存在本机。切换前保存失败会留在原项目。详见[项目与恢复](docs/projects.md)。
- **三类数学块**:math 走 KaTeX,typst 走 typst.ts(wasm 实时 SVG),latex 走 MathJax。都是懒加载,首屏不碰 wasm 和字体。
- **双向链接知识网络**:`[[wiki-link]]` 全语法(`|别名`、`#标题`、`^块`),SQLite FTS5 全库索引,中文按三字分词;反链面板还会列出未链接的提及。
- **双向链接知识网络**:`[[wiki-link]]` 支持别名、标题与块定位,SQLite FTS5 索引保存在本机应用数据目录,并支持一至两个字符的短词查找;反链面板列出有上下文的未链接提及。
- **知识图谱**:`Ctrl+G` 打开全库 Graph View,d3-force 力导加 Canvas2D 自绘,布局放到 Worker 里跑。可缩放、拖拽、点击跳转、邻域高亮;右栏能看当前文件的局部图谱。
- **git 原生**:基于 libgit2 的完整命令集,自绘三栏 git-graph(图谱、提交详情、文件 diff)。支持远程 clone / fetch / push / pull 和 SSH 签名提交。
- **句级 diff 与三向合并**:中英混排按句子比较,看的是「哪句话改了」而不是「哪行变了」。合并冲突可以逐句采纳本方或对方。
Expand All @@ -68,7 +69,7 @@
- **文件导出**:一键把当前文档导出成 HTML、PDF、DOCX,全本地转换;可加一行自定义水印(默认关)。装了 pandoc 还能导出 ODT、LaTeX、EPUB 等。
- **沉浸阅读模式**:打开 txt、docx、epub、pdf 全屏阅读,自动认出小说还是文献并换排版,三套配色护眼。PDF 逐页懒渲染,编辑器不卸载,随时切回来。
- **应用内自动更新**:启动时静默检查新版本,一键下载并重启升级,更新包经签名验证。
- **简易模式**:一键收起全部高级功能,也不在工作区建 `.inkstream` 索引库,给轻度用户最干净的纯文本编辑。
- **简易模式**:一键收起高级功能并关闭索引,保留写作、项目档案和草稿恢复。所有模式都不向内容目录写入新的项目元数据或索引库。
- **中文优先**:中文输入法全程不被预览打断,中英混合字数统计,中文模糊搜索。

## 下载安装
Expand Down Expand Up @@ -110,7 +111,7 @@

## 从源码构建

环境要求:**Node 22(LTS)· Rust stable(rustup)· pnpm 11.5.2**(经 corepack 激活)。
环境要求:**Node 24(见 `.node-version`)· Rust stable(rustup)· pnpm 11.5.2**(经 corepack 激活)。

```bash
corepack enable
Expand All @@ -119,7 +120,7 @@ pnpm tauri dev # 开发模式启动桌面应用
pnpm tauri build # 打包本平台安装包(产物在 src-tauri/target/release/bundle/)
```

三道门:`pnpm typecheck && pnpm lint && pnpm test`。Linux 构建需先安装 webkit2gtk 等系统依赖(清单见 [.github/workflows/ci.yml](./.github/workflows/ci.yml));三平台安装包经 [.github/workflows/release.yml](./.github/workflows/release.yml) 在 CI 同时构建。
本地检查:`pnpm typecheck`、`pnpm lint`、`pnpm test:ci`、`pnpm build`。`test:ci` 串行执行全部前端测试,保留每项测试的原有时限,记录进程清理与结果,避免大文档测试和其他 jsdom 实例争用资源。原生测试运行 `node scripts/acceptance/run-rust.mjs`。Linux 构建需先安装 webkit2gtk 等系统依赖(清单见 [.github/workflows/ci.yml](./.github/workflows/ci.yml));三平台安装包经 [.github/workflows/release.yml](./.github/workflows/release.yml) 在 CI 同时构建。

## 路线图

Expand Down
29 changes: 29 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Third-party notices

InkStream's own code is licensed as described in `LICENSE`. The components below retain their respective licenses.

## citeproc-js 2.4.63

Copyright © 2009–2019 Frank Bennett. InkStream uses the CPAL-1.0-or-later licensing option offered by the original author. The processor is used without source modifications.

- Original source distribution: https://registry.npmjs.org/citeproc/-/citeproc-2.4.63.tgz
- Upstream project: https://github.com/Juris-M/citeproc-js
- Documentation: https://citeproc-js.readthedocs.io/
- Original notice: `public/third-party/citeproc-LICENSE.txt`
- Full CPAL 1.0 text: `public/third-party/CPAL-1.0.txt`

The source distribution remains available under its original licensing terms, independently of InkStream's own license. The package integrity is fixed in `pnpm-lock.yaml`.

## Citation Style Language styles and locales

The bundled GB/T 7714-2015 numeric, APA 7, NLM citation-sequence styles and English/Chinese locales are licensed under CC BY-SA 3.0. Original author, contributor and translator metadata remains in the unmodified XML files.

- Citation Style Language project: https://citationstyles.org/
- Styles: https://github.com/citation-style-language/styles
- Locales: https://github.com/citation-style-language/locales
- Exact revisions, source URLs, byte lengths and SHA-256: `src/editor/csl/assets/sources.json`
- Full license: `public/third-party/CC-BY-SA-3.0.txt`

## Typst preview fonts

Font sources, copyright, exact versions, hashes and their respective OFL/GUST/LPPL notices are distributed in `public/typst-fonts/ASSETS.md` and the adjacent license files.
10 changes: 10 additions & 0 deletions docs/diff-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ InkStream 的版本对比和冲突解决可以按句子来看,而不只是按
2. 在左栏点选一个提交,中栏会列出该提交改动的文件。
3. 点中栏里的某个文件,右栏就会显示这次改动的对比内容。

## 比较两个分支的完整正文

在 Git Graph 顶部打开「分支比较」,选择基线分支和目标分支,再点「比较完整正文」。左侧按页列出变更文件,右侧完整显示两个版本,包括没有变化的上下文。可以反向比较,或用「定位当前文档」查看正在编辑的文件;能找到唯一对应文字时,会定位到编辑时的段落。

普通文档会按句标出差异,可用「上一处/下一处」跳转。两侧均可选择、复制和查找,不能直接编辑;回到编辑器后,原正文、未保存修改、选区和撤销历史仍在。比较不会切换分支或写入 Git 工作树。

比较开始时固定两侧提交;分支之后移动不会改变正在阅读的版本。新增或删除文件会明确显示某一侧没有文件。内容完全相同的改名合并为一项;改名同时编辑的文件按新增和删除分别列出。

大文档或句子较多时,界面会暂停句级高亮并保留完整正文。单侧超过 100 MiB、二进制或非 UTF-8 文件会给出无法显示的原因,不以截断内容代替全文。

## 行 diff 与句 diff 切换

右栏顶部有一个「行 / 句」切换按钮,对应两种看法:
Expand Down
36 changes: 36 additions & 0 deletions docs/equations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 公式编号与引用

在学术工具栏点击“公式编号”,或执行命令“学术:公式编号”。当前 Markdown 文档会启用公式编号,并为尚无标签的块公式补充唯一标签。再次执行会保留已有标签;这次操作可单步撤销。

编号适用于 `$$…$$`、`math` / `latex` / `typst` 代码围栏以及 `:::typst`。每个块算一个公式,按文档顺序从 1 编号。数字在预览和导出时计算,不写入 LaTeX 或 Typst 源码。插入、删除或移动公式后,编号和不带别名的引用会随顺序更新。

编号状态和标签保存在 Markdown 中,例如:

````markdown
<!-- equation-numbering -->

```latex
E=mc^2
```
<!-- equation:energy -->

见 [[#eq:energy]]。
````

`energy` 是稳定标签;即使公式变为第 3 个,引用仍写 `[[#eq:energy]]`,显示为“式(3)”。Live Preview 中 Ctrl/Cmd+点击引用,或聚焦引用后按 Enter,可跳到当前文档中的公式源码。带 wiki 别名时显示用户指定的别名,目标仍由标签确定。

标签应紧随对应公式,中间只留空白。可使用字母(含中文)、数字、下划线、点和连字符,最长 80 个字符。重复、非法、孤立或未闭合的公式块会阻止批量编号并给出提示。重命名标签时,应同步修改引用;未解析引用会明确显示,不能跳到一个猜测目标。

新插入的公式会参与编号;再次点击“公式编号”可为其生成引用标签。用公式上的删除按钮删除时,关联标签会一起删除。在 Source 模式手动移动公式时,应把紧随其后的标签一起移动。

HTML 导出使用相同的文档序与标签,生成编号和本页引用链接;合法编号及 bibliography 注释不会出现在正文。普通或未知 HTML 仍转义。数学内容沿用现有导出能力:`math` / `$$` 可使用数学渲染器,LaTeX 与 Typst 围栏保留源码,此功能不等同于整篇学术文档编译。

大文档的基础编辑档暂停完整编号扫描和 Live Preview。需要新增编号标签时,先显式启用完整排版;基础档不会因点击编号而自动切换模式或改写文档。显式 HTML 导出仍按导出文档内容计算已有编号。

## 导出 LaTeX 公式 PDF 片段

将光标放入一个 `latex` 代码围栏,点击学术工具栏“公式 PDF”,或执行“学术:导出公式 PDF 片段”。文件菜单的“导出为 → 公式 PDF 片段…”调用同一动作;公式悬浮工具栏也有“导出公式 PDF”按钮。双栏编辑模式下导出的是正在编辑的公式。

片段以 12pt 数学字号和四周 8pt 留白输出,保留公式矢量图形。应用先转换当前公式,再让你选择 `.pdf` 保存位置;保存取消不写文件。编译期间编辑、切换或关闭文档会取消旧公式导出,失败时可重试。基础编辑档需要先显式启用完整排版。

此入口支持 MathJax 的 LaTeX 数学表达式及已加载的 `base`、`ams`、`newcommand` 扩展;它不执行完整 TeX 文档、任意宏包或外部文件。公式错误会给出原因,不能作为成功的 PDF 保存。公式标签和文档编号不改变片段源码。文件菜单原有的“PDF…”仍用于整篇文档的系统打印。
20 changes: 12 additions & 8 deletions docs/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ GitHub 登录入口在「设置 ▸ 账户」分区。
1. 按 `Ctrl+,` 打开设置,或从命令面板(`Ctrl+Shift+P`)执行「视图:设置」。
2. 在左侧分类中点「账户」。

登录有两种方式:
登录有三种方式:

- 个人访问令牌(PAT):在输入框粘贴形如 `ghp_...` 的令牌,点「登录」。令牌需包含 repo 权限,可在 GitHub ▸ Settings ▸ Developer settings ▸ Personal access tokens 创建。
- 本机 gh CLI 登录:若 InkStream 检测到你已通过 `gh` 命令行工具在 github.com 登录,账户分区会出现「用本机 gh CLI 一键登录」按钮,点一下就行,不用手动粘贴令牌。
- 浏览器登录:点「通过浏览器登录 GitHub」,在固定的 GitHub 验证页面输入应用显示的验证码,并确认授权。等待期间可以取消或重新获取验证码;关闭账户设置会取消该页面的设备登录。
- 个人访问令牌(PAT):填写令牌后点「使用 PAT 登录」。访问私有仓库时需授予对应仓库权限;经典 PAT 通常需要 `repo` 权限。
- 本机 gh CLI:若本机 `gh` 已在 github.com 登录,可点「使用本机 gh CLI 登录」。InkStream 只读取现有令牌,不修改 gh 的登录账户。

登录成功后,账户分区显示「已登录」并提供「登出」按钮。登录后通过 HTTPS 推送、拉取、克隆会自动带上令牌。
浏览器登录需要 GitHub OAuth App 的公开 Client ID,并在该 App 设置中启用 Device Flow。发布版本可在构建时通过 `INKSTREAM_GITHUB_CLIENT_ID` 配置;若当前版本没有配置,浏览器登录按钮会暂时禁用,也可填写自己注册的 OAuth App Client ID。客户端不需要也不接受 Client Secret。具体流程见 [GitHub Device Flow 官方说明](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow)。

注意事项:
登录成功后,账户分区显示「已登录」并提供「登出 GitHub」按钮。浏览器登录会显示刚验证的 GitHub 用户名。设备码、访问令牌和刷新令牌均由原生端处理;界面只接收验证码、状态和用户名。凭据与过期信息保存在本机系统凭据库的同一条目中,旧版本保存的 PAT/gh 令牌可以继续使用。

- 令牌只保存在本机操作系统凭据库(如 Windows 凭据管理器),不会上传,也不会回显到界面。
- 如果你偏好用 SSH 同步而非令牌,可改在「设置 ▸ Git ▸ 远程方式」选择「SSH」。
对于 GitHub 返回的有过期时间的 OAuth 令牌,GitHub API 与 HTTPS Git 操作会在使用前按需刷新。授权被撤销或刷新令牌已过期时,应用会要求重新登录;网络失败时不会把已过期令牌交给 Git。切换 PAT、gh 或登出会取消旧的设备授权和刷新请求,迟到结果不能覆盖新的账户选择。

GitHub 账户仅用于通过准入检查的 github.com HTTPS 地址;本地、SSH、自定义地址等方式按「Git ▸ 远程方式」处理。SSH 需要仓库的 SSH remote URL 与本机密钥。点「登出 GitHub」会删除 InkStream 保存的本机凭据;如需在 GitHub 服务端撤销 OAuth App 授权,可在 GitHub 的 Applications 设置中操作。

## 打开 Git Graph 与切换标签

Expand All @@ -30,7 +32,7 @@ GitHub 的 PR / Issues 视图位于 Git Graph 页面内。
- 按 `Ctrl+Shift+G` 打开 Git Graph,或从命令面板执行「Git Graph」。
- 仅在当前工作区是 git 仓库时可用;否则会提示「当前工作区不是 git 仓库」。

Git Graph 顶部有四个标签:图谱、分支、PR、Issues。点「PR」或「Issues」即可进入对应视图。
Git Graph 顶部可切换图谱、分支、暂存记录、PR 与 Issues。点「PR」或「Issues」即可进入对应视图。

提示:`Ctrl+G` 打开的是知识图谱(双向链接网络),与 Git Graph 不是同一个功能,请勿混用。

Expand Down Expand Up @@ -66,6 +68,8 @@ Git Graph 顶部有四个标签:图谱、分支、PR、Issues。点「PR」或
- 请求修改:要求作者修改(必须填写评语)。
- 评论:仅留言、不表态(必须填写评语)。

PR 详情中的“代码审阅讨论”按文件位置列出原评论和回复,可展开上下文,再回复对应讨论。旧版本位置会单独标注;读取或发送失败时显示原因,保留尚未发送的文字。切换 PR 后,旧请求不会覆盖新 PR 的讨论或输入。该回复入口使用 PR review comment 线程,与下方普通评论区分开。

## Issue

在 Git Graph 顶部切到「Issues」标签:
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ InkStream(墨流)各功能的使用指南。每篇都从用户视角讲怎

- [编辑器与实时预览](./editor.md):单内核、Source ↔ Live Preview 切换(Ctrl+E)、光标行展开、richtext 工具栏
- [三模式与工作区](./modes.md):Standard / Academic / Creative 切换、打开文件夹、文件树 CRUD、非工作区文件、自动保存
- [项目与恢复](./projects.md):本机项目档案、每项目会话、独立草稿、备份恢复与材质设置
- [快捷键与命令面板](./shortcuts.md):Ctrl+Shift+P 命令面板、快捷键表、F11 Focus Mode
- [简易模式](./simple-mode.md):轻度用户的精简界面、关闭高级功能、不创建 .inkstream 索引库
- [简易模式](./simple-mode.md):精简界面与高级功能开关

## 写作能力

Expand Down
Loading
Loading