@linloir/limr 0.1.0 → 1.0.0
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.en.md +123 -0
- package/README.md +63 -138
- package/dist/base.css +10 -7
- package/dist/{chunk-65V5OZ4G.js → chunk-3ILUZKDB.js} +77 -17
- package/dist/chunk-3ILUZKDB.js.map +1 -0
- package/dist/{chunk-ETHLPBKQ.js → chunk-N77VD2YR.js} +96 -51
- package/dist/chunk-N77VD2YR.js.map +1 -0
- package/dist/{chunk-7JF5HHVF.js → chunk-TTISGBST.js} +14 -1
- package/dist/{chunk-7JF5HHVF.js.map → chunk-TTISGBST.js.map} +1 -1
- package/dist/core/index.d.ts +6 -3
- package/dist/core/index.js +3 -1
- package/dist/extensions/index.d.ts +2 -2
- package/dist/extensions/index.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +5 -3
- package/dist/styles.css +10 -7
- package/dist/{translations-BliabrPd.d.ts → translations-DHnYMg4h.d.ts} +11 -3
- package/docs/README.md +13 -0
- package/docs/api.md +5 -158
- package/docs/assets/rendered.svg +9 -0
- package/docs/assets/source.svg +9 -0
- package/docs/en/README.md +26 -0
- package/docs/en/ai-skills.md +57 -0
- package/docs/en/annotations.md +84 -0
- package/docs/en/api.md +107 -0
- package/docs/en/architecture.md +33 -0
- package/docs/en/extensions.md +159 -0
- package/docs/en/getting-started.md +67 -0
- package/docs/en/integration.md +130 -0
- package/docs/en/modules.md +80 -0
- package/docs/en/performance.md +53 -0
- package/docs/en/plugin-packages.md +68 -0
- package/docs/en/styles.md +80 -0
- package/docs/en/syntax.md +352 -0
- package/docs/extensions.md +5 -306
- package/docs/implementation.md +5 -76
- package/docs/performance.md +5 -81
- package/docs/screenshots/blocks.png +0 -0
- package/docs/screenshots/dark.png +0 -0
- package/docs/screenshots/desktop.png +0 -0
- package/docs/screenshots/plugin-mobile.png +0 -0
- package/docs/styles.md +5 -100
- package/docs/visual-upgrade.md +5 -145
- package/docs/zh-CN/README.md +26 -0
- package/docs/zh-CN/ai-skills.md +57 -0
- package/docs/zh-CN/annotations.md +84 -0
- package/docs/zh-CN/api.md +107 -0
- package/docs/zh-CN/architecture.md +33 -0
- package/docs/zh-CN/extensions.md +159 -0
- package/docs/zh-CN/getting-started.md +67 -0
- package/docs/zh-CN/integration.md +130 -0
- package/docs/zh-CN/modules.md +80 -0
- package/docs/zh-CN/performance.md +53 -0
- package/docs/zh-CN/plugin-packages.md +68 -0
- package/docs/zh-CN/styles.md +80 -0
- package/docs/zh-CN/syntax.md +352 -0
- package/examples/notes.tsx +18 -11
- package/examples/packages/paper-theme/index.css +25 -0
- package/examples/packages/paper-theme/package.json +7 -0
- package/examples/packages/reading-tools/index.d.ts +2 -0
- package/examples/packages/reading-tools/index.js +25 -0
- package/examples/packages/reading-tools/package.json +16 -0
- package/package.json +9 -5
- package/skills/limr-plugin-development/SKILL.md +22 -0
- package/skills/limr-plugin-development/agents/openai.yaml +4 -0
- package/skills/limr-plugin-development/assets/plugin-template/README.md +30 -0
- package/skills/limr-plugin-development/assets/plugin-template/package.json +36 -0
- package/skills/limr-plugin-development/assets/plugin-template/src/index.tsx +50 -0
- package/skills/limr-plugin-development/assets/plugin-template/src/styles.css +9 -0
- package/skills/limr-plugin-development/assets/plugin-template/tsconfig.json +20 -0
- package/skills/limr-plugin-development/assets/plugin-template/tsup.config.ts +8 -0
- package/skills/limr-plugin-development/references/contract.md +45 -0
- package/skills/limr-use/SKILL.md +23 -0
- package/skills/limr-use/agents/openai.yaml +4 -0
- package/skills/limr-use/references/integration.md +41 -0
- package/skills/limr-use/references/syntax.md +17 -0
- package/dist/chunk-65V5OZ4G.js.map +0 -1
- package/dist/chunk-ETHLPBKQ.js.map +0 -1
package/README.en.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# LiMR
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@linloir/limr)
|
|
4
|
+
|
|
5
|
+
[简体中文](README.md) · **English**
|
|
6
|
+
|
|
7
|
+
**Linloir’s limr Is a Markdown Renderer.** A React Markdown renderer for long documents and streaming output. Body text, navigation, reference cards, selections, and highlights share one document state, and can also be composed into your own interface.
|
|
8
|
+
|
|
9
|
+
[Live Playground](https://linloir.github.io/LiMR/) · [English docs](docs/en/README.md) · [中文文档](docs/zh-CN/README.md) · [AI Skills](docs/en/ai-skills.md)
|
|
10
|
+
|
|
11
|
+
## Install and use
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install @linloir/limr
|
|
15
|
+
# or pnpm add @linloir/limr
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { Reader } from '@linloir/limr';
|
|
20
|
+
import '@linloir/limr/styles.css';
|
|
21
|
+
import '@linloir/limr/math.css';
|
|
22
|
+
|
|
23
|
+
const source = '# Start reading\n\nSupports **Markdown** and $E = mc^2$.';
|
|
24
|
+
|
|
25
|
+
export default function Article() {
|
|
26
|
+
return <Reader source={source} />;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Requires React / React DOM **18.3 or 19**, Node.js **20+**, and an ESM-capable build tool. Interactive features target modern browsers; Node SSR is supported. UI labels default to English; pass the exported `chinese` locale for Chinese labels. Import `math.css` when using formulas.
|
|
31
|
+
|
|
32
|
+
Render just the body, or a growing response:
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Markdown } from '@linloir/limr';
|
|
36
|
+
|
|
37
|
+
export function Answer({ text, generating }: { text: string; generating: boolean }) {
|
|
38
|
+
return <Markdown source={text} streaming={generating} followOutput />;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`source` is the complete accumulated string. Set `streaming` to `false` when generation ends. `followOutput` is off by default and pauses when the reader scrolls up. `Markdown` does not include navigation, a sidebar, or a selection toolbar.
|
|
43
|
+
|
|
44
|
+
## Capabilities
|
|
45
|
+
|
|
46
|
+
| Scenario | Features |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| Reading | CommonMark, GFM tables/tasks/footnotes, math, Shiki code highlighting |
|
|
49
|
+
| Rich content | Images, figure groups, captions, video, definitions, exercises, further reading, citations, original/translated/parallel text |
|
|
50
|
+
| Interaction | Responsive contents, desktop annotation sidebar, narrow-screen overlays, copying, four highlight styles |
|
|
51
|
+
| Integration | Controlled annotations, original UTF-16 offsets, isolated readers, nested scroll containers, SSR |
|
|
52
|
+
| Extensions | Custom syntax, React renderers, annotation types, selection actions, parameters, CSS theme packages |
|
|
53
|
+
|
|
54
|
+
The default content annotation type is `citation`; `highlight` provides persistent highlighting. Notes, questions, and chat annotations belong to application plugins. The default `question()` extension renders exercises in the document. See the [syntax reference](docs/en/syntax.md).
|
|
55
|
+
|
|
56
|
+
```markdown
|
|
57
|
+
<definition title="Definition">
|
|
58
|
+
|
|
59
|
+
Use **Markdown** inside custom blocks.
|
|
60
|
+
|
|
61
|
+
</definition>
|
|
62
|
+
|
|
63
|
+
This passage has a source<ref id="paper" />.
|
|
64
|
+
|
|
65
|
+
<citation id="paper" title="Reference" url="https://example.com/paper" summary="Short summary" />
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Composition and extensions
|
|
69
|
+
|
|
70
|
+
`Reader` provides a complete layout. Use `DocumentProvider` with `Markdown`, `TableOfContents`, `AnnotationSidebar`, `AnnotationOverlay`, and `SelectionToolbar` for your own layout. See [application integration](docs/en/integration.md).
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { Reader, defineBlock } from '@linloir/limr';
|
|
74
|
+
|
|
75
|
+
const plugins = [defineBlock({
|
|
76
|
+
name: 'notice',
|
|
77
|
+
component: ({ children }) => <aside className="notice">{children}</aside>,
|
|
78
|
+
})];
|
|
79
|
+
|
|
80
|
+
export function Notice() {
|
|
81
|
+
return <Reader source={'<notice>\n\n**Custom content**\n\n</notice>'} plugins={plugins} />;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`plugins` appends to the defaults. `extensions` replaces the entire list; `extensions={[]}` uses basic CommonMark. Replace a named extension explicitly with `replaceExtension()`. Keep configuration references stable.
|
|
86
|
+
|
|
87
|
+
Plugins can own the complete card UI (`overlay.Card`), collapsed sidebar summary (`sidebar.Preview`), async loading, and selection actions. Use the [plugin development Skill](skills/limr-plugin-development/SKILL.md) or [package guide](docs/en/plugin-packages.md) to build an installable extension and add it through `plugins`. Examples cover [notes](examples/notes.tsx), a [streaming assistant](examples/assistant.tsx), a [standalone plugin](examples/packages/reading-tools/index.js), and a [CSS theme](examples/packages/paper-theme/index.css). The `@limr-example/*` packages are unpublished local examples.
|
|
88
|
+
|
|
89
|
+
## AI Skills
|
|
90
|
+
|
|
91
|
+
| Skill | Purpose |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| [limr-use](skills/limr-use/SKILL.md) | Integrate LiMR, author content, configure interaction, and install existing plugins |
|
|
94
|
+
| [limr-plugin-development](skills/limr-plugin-development/SKILL.md) | Build standalone module packages with a TypeScript / ESM / CSS starter and validation guidance |
|
|
95
|
+
|
|
96
|
+
Skills ship in the npm package and can also be downloaded from this repository. Copy the entire skill directory to keep references and templates together. See [download, installation, and invocation](docs/en/ai-skills.md) for Codex project and user scopes.
|
|
97
|
+
|
|
98
|
+
## Styles and runtime
|
|
99
|
+
|
|
100
|
+
- `styles.css` includes light/dark styling and local Maple code fonts. `styles/base.css` provides the same styling without loading Maple. Font assets remain in the npm download. Choose one stylesheet.
|
|
101
|
+
- `appearance` scopes CSS themes across the reader and portalled controls. Applications or system fonts supply body typography.
|
|
102
|
+
- Code highlighting and math load on demand. Video loads near the viewport by default, with a click-to-load option. Remote media may contact its source site.
|
|
103
|
+
- The full DOM remains available for browser search, native selection, and printing. Streaming appends reuse stable blocks and finish with a full parse; not every edit is incremental.
|
|
104
|
+
- Unregistered HTML is displayed as text. Markdown-supplied JavaScript expressions are never executed. Custom renderers own their data and remote requests.
|
|
105
|
+
|
|
106
|
+
See [styles and fonts](docs/en/styles.md), [API](docs/en/api.md), and [performance and limits](docs/en/performance.md).
|
|
107
|
+
|
|
108
|
+
## Local development
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
pnpm install
|
|
112
|
+
pnpm dev
|
|
113
|
+
pnpm check
|
|
114
|
+
pnpm test:docs
|
|
115
|
+
pnpm exec playwright install chromium
|
|
116
|
+
pnpm test:browser
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Local development uses Python 3 to generate downloadable Skill archives. The header switches between Playground and LiMR-rendered, bilingual Docs.
|
|
120
|
+
|
|
121
|
+
The local Playground runs at `http://127.0.0.1:4173`. Use `@linloir/limr/core` for parsing without React/DOM. Other entry points are `@linloir/limr/react` and `@linloir/limr/extensions`.
|
|
122
|
+
|
|
123
|
+
[MIT License](LICENSE). Developed with Codex.
|
package/README.md
CHANGED
|
@@ -1,198 +1,123 @@
|
|
|
1
1
|
# LiMR
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@linloir/limr)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**简体中文** · [English](README.en.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Linloir’s limr Is a Markdown Renderer.** 面向长文阅读和流式输出的 React Markdown 渲染器。正文、目录、引用卡片、选区和高亮共享文档状态,也可以拆开组合到自己的界面中。
|
|
8
|
+
|
|
9
|
+
[在线 Playground](https://linloir.github.io/LiMR/) · [中文文档](docs/zh-CN/README.md) · [English docs](docs/en/README.md) · [AI Skills](docs/zh-CN/ai-skills.md)
|
|
10
|
+
|
|
11
|
+
## 安装与使用
|
|
8
12
|
|
|
9
13
|
```sh
|
|
10
|
-
|
|
14
|
+
npm install @linloir/limr
|
|
15
|
+
# 或 pnpm add @linloir/limr
|
|
11
16
|
```
|
|
12
17
|
|
|
13
18
|
```tsx
|
|
14
|
-
import { Reader } from '@linloir/limr';
|
|
19
|
+
import { Reader, chinese } from '@linloir/limr';
|
|
15
20
|
import '@linloir/limr/styles.css';
|
|
16
|
-
import '@linloir/limr/math.css';
|
|
21
|
+
import '@linloir/limr/math.css';
|
|
22
|
+
|
|
23
|
+
const source = '# 开始阅读\n\n支持 **Markdown** 与 $E = mc^2$。';
|
|
17
24
|
|
|
18
|
-
|
|
25
|
+
export default function Article() {
|
|
26
|
+
return <Reader source={source} locale={chinese} />;
|
|
27
|
+
}
|
|
19
28
|
```
|
|
20
29
|
|
|
21
|
-
需要 React 18.3
|
|
30
|
+
需要 React / React DOM **18.3 或 19**、Node.js **20+** 和支持 ESM 的构建工具。交互功能面向现代浏览器;支持 Node SSR。默认界面语言为英文,中文界面传入 `chinese`。`math.css` 在使用公式时引入。
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
只显示正文,或显示持续生成的回答:
|
|
24
33
|
|
|
25
34
|
```tsx
|
|
26
35
|
import { Markdown } from '@linloir/limr';
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
export function Answer({ text, generating }: { text: string; generating: boolean }) {
|
|
38
|
+
return <Markdown source={text} streaming={generating} followOutput />;
|
|
39
|
+
}
|
|
31
40
|
```
|
|
32
41
|
|
|
33
|
-
`followOutput`
|
|
42
|
+
`source` 是累计的完整字符串,生成结束时把 `streaming` 设为 `false`。`followOutput` 默认关闭;开启后在读者向上滚动时暂停跟随。`Markdown` 不自带目录、侧栏或选区工具栏。
|
|
34
43
|
|
|
35
|
-
##
|
|
44
|
+
## 支持什么
|
|
36
45
|
|
|
37
|
-
|
|
|
46
|
+
| 场景 | 能力 |
|
|
38
47
|
| --- | --- |
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
| `AnnotationOverlay` | 鼠标预览、点击/触摸展开、键盘退出和焦点恢复 |
|
|
45
|
-
| `SelectionToolbar` | 独立的选区操作和自定义 UI 槽位 |
|
|
46
|
-
| `AnnotationMarkdown` | 在卡片内复用渲染能力,隔离文档和选区作用域 |
|
|
48
|
+
| 文档阅读 | CommonMark、GFM 表格/任务列表/脚注、数学公式、Shiki 代码高亮 |
|
|
49
|
+
| 富内容 | 图片与图组、图注、视频、释义、练习题、拓展阅读、引用、原文/译文/对照 |
|
|
50
|
+
| 阅读交互 | 响应式目录、桌面标注侧栏、窄屏浮层、复制、四种高亮样式 |
|
|
51
|
+
| 应用集成 | 受控标注、原始 UTF-16 坐标、多个独立阅读器、内部滚动容器、SSR |
|
|
52
|
+
| 扩展 | 自定义语法、React 渲染组件、标注类型、选区动作、参数与 CSS 主题包 |
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
<DocumentProvider source={markdown}>
|
|
52
|
-
<div className="reading-columns">
|
|
53
|
-
<TableOfContents />
|
|
54
|
-
<Markdown />
|
|
55
|
-
<AnnotationSidebar />
|
|
56
|
-
</div>
|
|
57
|
-
<AnnotationOverlay />
|
|
58
|
-
<SelectionToolbar actions={actions} />
|
|
59
|
-
</DocumentProvider>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
`reading-columns` 的样式由应用提供。对齐侧栏和正文应位于**同一个滚动容器**,侧栏保持正常文档流中的相对定位。窗口滚动无需配置;内部滚动容器用 `scrollRoot={element}` 指定。常规布局直接用 `Reader` 即可。详见 [组合和布局约定](docs/api.md#布局和定位)。
|
|
63
|
-
|
|
64
|
-
## 默认能力与扩展
|
|
65
|
-
|
|
66
|
-
默认包含 GFM、公式、代码高亮、响应式图片/图组与图注、视频、释义、问题正文区块、拓展阅读、ref 引用和分段译文。每一种特殊语法都是使用公开接口实现的独立模块。`translations` 支持原文、译文与对照,可通过 `parameters.translationMode` 统一控制;[图组与译文语法](docs/extensions.md#图片与论文图组)包含完整示例。
|
|
67
|
-
|
|
68
|
-
**默认角注只有 citation/ref;高亮单独提供。** 提问、注记、聊天等应用角注由插件注册。`question()` 是问题正文区块,与问答角注无关。
|
|
69
|
-
|
|
70
|
-
```tsx
|
|
71
|
-
import { standard, defineBlock, replaceExtension, codeHighlight } from '@linloir/limr';
|
|
72
|
-
|
|
73
|
-
const extensions = [
|
|
74
|
-
...replaceExtension(standard(), codeHighlight({ languages: ['typescript', 'python'] })),
|
|
75
|
-
defineBlock({
|
|
76
|
-
name: 'notice',
|
|
77
|
-
component: ({ children }) => <aside className="notice">{children}</aside>,
|
|
78
|
-
}),
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
<Reader source={'<notice>\n\n**自定义内容**\n\n</notice>'} extensions={extensions} />
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
同一模块也支持 `:::notice` 指令语法。`extensions` 是完整的扩展列表;传入 `[]` 得到基础 CommonMark。可以用 `.filter()` 移除默认模块,或 `replaceExtension()` 替换同名模块。保持配置引用稳定,例如在模块外定义或使用 `useMemo`。
|
|
85
|
-
|
|
86
|
-
安装第三方扩展时,用 `plugins` **追加**到默认模块;样式包通过 CSS 导入和 `appearance` 选择:
|
|
87
|
-
|
|
88
|
-
```tsx
|
|
89
|
-
import { readingTools } from '@limr-example/reading-tools';
|
|
90
|
-
import '@linloir/limr/styles.css';
|
|
91
|
-
import '@limr-example/paper-theme';
|
|
92
|
-
|
|
93
|
-
const plugins = [readingTools()];
|
|
94
|
-
<Reader source={markdown} plugins={plugins} appearance="paper" />
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
这里的两个 `@limr-example` 包是仓库内的可打包示例,尚未发布。实际社区包可以使用同样的结构。见 [扩展打包](docs/extensions.md#作为独立包分发) 和 [样式指南](docs/styles.md)。
|
|
98
|
-
|
|
99
|
-
常用标签:
|
|
54
|
+
默认内容标注类型是 `citation`;`highlight` 是内置持久高亮。笔记、提问和聊天标注由应用插件提供,`question()` 则是默认的练习题正文模块。完整写法见[语法手册](docs/zh-CN/syntax.md)。
|
|
100
55
|
|
|
101
56
|
```markdown
|
|
102
57
|
<definition title="定义">
|
|
103
58
|
|
|
104
|
-
|
|
59
|
+
在特殊区块中继续使用 **Markdown**。
|
|
105
60
|
|
|
106
61
|
</definition>
|
|
107
62
|
|
|
108
|
-
|
|
63
|
+
这段内容有参考来源<ref id="paper" />。
|
|
109
64
|
|
|
110
|
-
<citation id="paper" title="
|
|
65
|
+
<citation id="paper" title="参考资料" url="https://example.com/paper" summary="简短摘要" />
|
|
111
66
|
```
|
|
112
67
|
|
|
113
|
-
|
|
68
|
+
## 组合与扩展
|
|
114
69
|
|
|
115
|
-
|
|
70
|
+
`Reader` 提供完整布局;自定义布局可用 `DocumentProvider` 组合 `Markdown`、`TableOfContents`、`AnnotationSidebar`、`AnnotationOverlay` 和 `SelectionToolbar`。详见[项目集成](docs/zh-CN/integration.md)。
|
|
116
71
|
|
|
117
72
|
```tsx
|
|
118
|
-
import { Reader,
|
|
73
|
+
import { Reader, defineBlock } from '@linloir/limr';
|
|
119
74
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
copyText({ label: '复制 Markdown', format: 'syntax' }),
|
|
125
|
-
deleteAnnotations(),
|
|
126
|
-
];
|
|
75
|
+
const plugins = [defineBlock({
|
|
76
|
+
name: 'notice',
|
|
77
|
+
component: ({ children }) => <aside className="notice">{children}</aside>,
|
|
78
|
+
})];
|
|
127
79
|
|
|
128
|
-
|
|
80
|
+
export function Notice() {
|
|
81
|
+
return <Reader source={'<notice>\n\n**自定义内容**\n\n</notice>'} plugins={plugins} />;
|
|
82
|
+
}
|
|
129
83
|
```
|
|
130
84
|
|
|
131
|
-
|
|
85
|
+
`plugins` 追加到默认扩展;`extensions` 替换整个扩展列表,`extensions={[]}` 使用基础 CommonMark。同名扩展使用 `replaceExtension()` 显式替换。配置应保持引用稳定。
|
|
132
86
|
|
|
133
|
-
|
|
87
|
+
插件可以拥有完整卡片 UI(`overlay.Card`)、侧栏摘要(`sidebar.Preview`)、异步加载和选区操作。使用 [AI 插件开发 Skill](skills/limr-plugin-development/SKILL.md) 或[独立插件包指南](docs/zh-CN/plugin-packages.md)创建可安装的包,再通过 `plugins` 引入。仓库提供[笔记](examples/notes.tsx)、[流式助手](examples/assistant.tsx)、[独立插件](examples/packages/reading-tools/index.js)和 [CSS 主题](examples/packages/paper-theme/index.css)示例;`@limr-example/*` 是未发布的本地示例包。
|
|
134
88
|
|
|
135
|
-
|
|
89
|
+
## AI Skills
|
|
136
90
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
91
|
+
| Skill | 用途 |
|
|
92
|
+
| --- | --- |
|
|
93
|
+
| [limr-use](skills/limr-use/SKILL.md) | 指导 AI 在项目中接入 LiMR、编写内容、配置交互和引入已有插件 |
|
|
94
|
+
| [limr-plugin-development](skills/limr-plugin-development/SKILL.md) | 指导 AI 开发独立模块包,附带 TypeScript / ESM / CSS 模板及验证步骤 |
|
|
140
95
|
|
|
141
|
-
-
|
|
142
|
-
- 自定义 transform 默认按全文处理。只有声明 `scope: 'local'` 且满足局部性约定的模块才参与尾部增量解析。
|
|
143
|
-
- 代码高亮接近视口时加载 Shiki、所需语言和主题;流式代码暂停更新后才重新高亮。公式按需加载 KaTeX。视频点击播放前不请求播放器。
|
|
144
|
-
- 角注数据在卡片显示时才加载,同一阅读器内请求复用、取消和有限缓存;不同阅读器资源隔离。
|
|
145
|
-
- 不注入第三方 CDN。默认样式附带本地 Maple Mono NF CN 代码字体,按字形范围加载 WOFF2 子集,加载前使用系统等宽字体。正文衬线字体使用应用/系统回退,Playground 自行提供 Noto Serif SC。可使用不带字体的 `@linloir/limr/styles/base.css`。缓存和覆盖方式见 [样式指南](docs/styles.md)。
|
|
146
|
-
- 默认保留完整 DOM,支持原生查找、选择和打印;不使用会破坏这些行为的默认虚拟列表。
|
|
96
|
+
Skills 随 npm 包分发,也可以从仓库下载。复制完整目录即可保留引用文件和模板;[下载、安装与调用说明](docs/zh-CN/ai-skills.md)包含 Codex 项目级与用户级配置。
|
|
147
97
|
|
|
148
|
-
|
|
98
|
+
## 样式与运行方式
|
|
149
99
|
|
|
150
|
-
|
|
100
|
+
- `styles.css` 包含默认浅色/深色样式和本地 Maple 代码字体;`styles/base.css` 提供相同样式但不加载 Maple。字体资产仍包含在 npm 包中。两者选一即可。
|
|
101
|
+
- `appearance` 为 CSS 主题提供作用域,也会传播到 portal 中的工具栏和浮层。正文中文字体由应用或系统提供。
|
|
102
|
+
- 代码高亮和公式按需加载。视频默认接近视口时加载,可以配置为点击加载;远程媒体仍可能访问其来源站点。
|
|
103
|
+
- 保留全文 DOM,支持浏览器查找、原生选择与打印。流式追加复用稳定区块,结束时完整解析;并非所有编辑都能局部解析。
|
|
104
|
+
- 未注册的 HTML 显示为原文,Markdown 中的 JavaScript 表达式不执行。自定义组件负责自己的数据和远程请求。
|
|
151
105
|
|
|
152
|
-
|
|
106
|
+
详见[样式与字体](docs/zh-CN/styles.md)、[API](docs/zh-CN/api.md)和[性能与限制](docs/zh-CN/performance.md)。
|
|
153
107
|
|
|
154
|
-
|
|
108
|
+
## 本地开发
|
|
155
109
|
|
|
156
110
|
```sh
|
|
157
111
|
pnpm install
|
|
158
112
|
pnpm dev
|
|
159
113
|
pnpm check
|
|
114
|
+
pnpm test:docs
|
|
160
115
|
pnpm exec playwright install chromium
|
|
161
116
|
pnpm test:browser
|
|
162
|
-
NODE_ENV=production pnpm bench
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### npm 发布
|
|
166
|
-
|
|
167
|
-
`pnpm test:package` 会构建并打包当前版本,在独立的 React 18/19 项目中验证类型、SSR、浏览器交互及样式资源,然后将通过验证的安装包保存到 `artifacts/`。
|
|
168
|
-
|
|
169
|
-
```sh
|
|
170
|
-
pnpm check
|
|
171
|
-
pnpm test:package
|
|
172
|
-
npm login --auth-type=web --registry=https://registry.npmjs.org
|
|
173
|
-
npm publish ./artifacts/linloir-limr-0.1.0.tgz --access public --registry=https://registry.npmjs.org
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
发布账号需要拥有 `@linloir` scope 的权限并完成 npm 要求的双重认证。后续发布先更新 `package.json` 的版本,再重新打包,并将命令中的文件名替换为新版本。
|
|
177
|
-
|
|
178
|
-
### GitHub Pages 预览
|
|
179
|
-
|
|
180
|
-
`main` 保存源码,独立的 `pages` 分支保存 Playground 构建后的静态产物,通过 SSH 推送到 GitHub。`pages` 分支由构建生成,无需手工合并源码。预览地址为 <https://linloir.github.io/LiMR/>。
|
|
181
|
-
|
|
182
|
-
首次部署在仓库 **Settings → Pages → Build and deployment** 中设置 **Source: Deploy from a branch**、**Branch: pages**、目录 **/(root)**,然后保存。后续推送 `pages` 分支会更新站点。
|
|
183
|
-
|
|
184
|
-
本地检查与线上相同的 `/LiMR/` 路径:
|
|
185
|
-
|
|
186
|
-
```sh
|
|
187
|
-
pnpm build:playground
|
|
188
|
-
pnpm preview:playground
|
|
189
|
-
# 打开 http://127.0.0.1:4173/LiMR/
|
|
190
117
|
```
|
|
191
118
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
其他入口:`@linloir/limr/core`(无 React/DOM 运行时依赖)、`@linloir/limr/react`、`@linloir/limr/extensions`。详细 props、hooks、受控状态和主题配置见 [API 指南](docs/api.md)。
|
|
119
|
+
本地开发需要 Python 3 生成 Skill 下载归档。标题栏可切换 Docs / Playground,Docs 由 LiMR 渲染,可切换语言。
|
|
195
120
|
|
|
196
|
-
|
|
121
|
+
本地 Playground 位于 `http://127.0.0.1:4173`。纯解析场景使用 `@linloir/limr/core`,不依赖 React/DOM;其他入口为 `@linloir/limr/react` 和 `@linloir/limr/extensions`。
|
|
197
122
|
|
|
198
|
-
Developed with Codex.
|
|
123
|
+
[MIT License](LICENSE). Developed with Codex.
|
package/dist/base.css
CHANGED
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
.limr-highlight[data-hidden] { background: transparent; text-decoration: none; }
|
|
83
83
|
.limr-paint-background { background: color-mix(in srgb, var(--limr-highlight) 30%, transparent); }
|
|
84
84
|
.limr-paint-background:is([data-hovered],[data-active]) { background: color-mix(in srgb, var(--limr-highlight) 48%, transparent); }
|
|
85
|
+
.limr-paint-background[data-reference] { background: color-mix(in srgb, var(--limr-highlight) 18%, transparent); }
|
|
85
86
|
.limr-highlight-layer .limr-paint-rect:is([data-hovered],[data-active]):not(.limr-paint-background) { background-color: color-mix(in srgb, var(--limr-highlight) 14%, transparent); }
|
|
86
87
|
.limr-highlight { cursor: pointer; }
|
|
87
88
|
.limr-paint-selection { background: var(--limr-selection, #667eea4d); z-index: 1; }
|
|
@@ -318,9 +319,9 @@
|
|
|
318
319
|
.limr-sidebar-card { color: var(--limr-annotation-text, var(--limr-text, #1a1a1a)); min-width: 0; transition: top var(--limr-motion-slow) var(--limr-ease), border-color var(--limr-motion) var(--limr-ease), background-color var(--limr-motion) var(--limr-ease); }
|
|
319
320
|
.limr-sidebar-card:not([data-default-card]),.limr-sidebar-card-body { border-inline-start: 2px solid var(--limr-annotation-border, var(--limr-annotation-color, var(--limr-border-strong, #d5d0c8))); background: var(--limr-background, #fffefa); padding: var(--limr-sidebar-padding-block, .65rem) var(--limr-sidebar-padding-inline, 10px) calc(var(--limr-sidebar-padding-block, .65rem) + 2px); }
|
|
320
321
|
.limr-sidebar-card[data-locked] { z-index: 1; transition-property: border-color, background-color; }
|
|
321
|
-
.limr-sidebar[data-resizing] > .limr-sidebar-card { transition-property: border-color, background-color; }
|
|
322
|
+
.limr-sidebar:is([data-resizing],[data-releasing]) > .limr-sidebar-card { transition-property: border-color, background-color; }
|
|
322
323
|
.limr-sidebar-card[data-default-card] { display: flex; flex-direction: column; }
|
|
323
|
-
.limr-sidebar-card[data-default-card]
|
|
324
|
+
.limr-sidebar-card[data-default-card] { max-height: var(--limr-sidebar-card-height, none); }
|
|
324
325
|
.limr-sidebar-card-body { display: flex; flex-direction: column; min-height: 0; transition: border-color var(--limr-motion) var(--limr-ease), background-color var(--limr-motion) var(--limr-ease); }
|
|
325
326
|
.limr-sidebar-card-body > .limr-collapse { min-height: 0; }
|
|
326
327
|
/* Preview and details trade height; fading both can leave a blank card when
|
|
@@ -408,11 +409,12 @@
|
|
|
408
409
|
.limr-tool-icon :where(*) { max-inline-size: 100% !important; max-block-size: 100% !important; min-inline-size: 0 !important; min-block-size: 0 !important; }
|
|
409
410
|
.limr-tool-icon :where(svg,img) { display: block; width: 100% !important; height: 100% !important; object-fit: contain; flex: none; }
|
|
410
411
|
.limr-tool-icon :where(div,span,i,b,strong,em) { display: inline-flex; align-items: center; justify-content: center; font-size: inherit !important; line-height: 1 !important; }
|
|
411
|
-
|
|
412
|
+
/* Only the actions determine toolbar width. Panel contents cannot enlarge it. */
|
|
413
|
+
.limr-toolbar-panel { display: flex; contain: inline-size; min-width: 0; min-height: 0; align-self: stretch; max-height: var(--limr-toolbar-panel-height, 260px); overflow: hidden; text-align: start; margin-top: 4px; border-top: 1px solid var(--limr-toolbar-border, var(--limr-border, #e5e2dc)); animation: limr-tool-float 300ms cubic-bezier(.16,1,.3,1) both, limr-tool-fade 220ms ease 35ms both; }
|
|
412
414
|
.limr-toolbar-panel .limr-overlay-content { padding: 10px 9px 4px; scroll-padding-block: 8px; }
|
|
413
|
-
.limr-toolbar-panel .limr-overlay-scroll
|
|
415
|
+
.limr-toolbar-panel .limr-overlay-scroll { width: 100%; min-width: 0; }
|
|
416
|
+
.limr-toolbar-panel .limr-overlay-scroll-inner { width: 100%; min-width: 0; overflow-wrap: anywhere; }
|
|
414
417
|
.limr-toolbar-panel :where(input,textarea,select,img) { max-width: 100%; }
|
|
415
|
-
.limr-selection-toolbar[data-expanded] .limr-toolbar-surface { min-width: min(calc(var(--limr-toolbar-panel-width, 246px) + 30px), calc(100vw - 20px)); }
|
|
416
418
|
[data-placement^='top'] .limr-toolbar-panel { order: -1; border-top: 0; border-bottom: 1px solid var(--limr-toolbar-border, var(--limr-border, #e5e2dc)); margin-top: 0; margin-bottom: 4px; }
|
|
417
419
|
.limr-toolbar-swatch { position: relative; width: 24px; height: 24px; margin: 3px 12px 3px 5px; padding: 0; border: 1px solid color-mix(in srgb, var(--swatch) 60%, transparent); border-radius: var(--limr-toolbar-swatch-radius, 4px); background: color-mix(in srgb, var(--swatch) 30%, transparent); transition: scale 240ms var(--limr-ease); --limr-highlight: var(--swatch); }
|
|
418
420
|
.limr-toolbar-swatch:hover { scale: 1.07; }
|
|
@@ -429,8 +431,9 @@
|
|
|
429
431
|
.limr-color-swatch[aria-pressed='true'] { outline-color: var(--swatch); }
|
|
430
432
|
.limr-color-swatch svg { width: 15px; height: 15px; color: var(--limr-text, #3d3a36); opacity: 0; }
|
|
431
433
|
.limr-color-swatch[aria-pressed='true'] svg { opacity: 1; }
|
|
432
|
-
.limr-highlight-styles { display:
|
|
433
|
-
.limr-highlight-styles button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px
|
|
434
|
+
.limr-highlight-styles { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: flex-start; gap: 5px; }
|
|
435
|
+
.limr-highlight-styles button { display: flex; flex: 0 0 auto; min-width: 48px; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; font-size: 11px; white-space: nowrap; }
|
|
436
|
+
.limr-highlight-style-label { text-align: center; }
|
|
434
437
|
.limr-highlight-styles button svg { width: 21px; height: 21px; }
|
|
435
438
|
.limr-highlight-styles [aria-pressed='true'] { color: var(--limr-toolbar-accent, var(--limr-accent, #8a7865)); border-color: currentColor; }
|
|
436
439
|
.limr-action-error { display: block; max-width: 300px; padding: .5rem; color: #b45858; }
|