@embedpdf-editor/chapter-snippet 0.3.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 CloudPDF
4
+ Copyright (c) 2026 xiaoliuing
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ This package includes software derived from EmbedPDF
2
+ (https://github.com/embedpdf/embed-pdf-viewer).
3
+
4
+ Copyright (c) 2025 CloudPDF
5
+ Copyright (c) 2026 xiaoliuing
6
+
7
+ See LICENSE for the full MIT License text.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # @embedpdf-editor/chapter-snippet
2
+
3
+ 章节 PDF 阅读器独立运行时(Preact + Web Component),供 **Vue 2.6** 等宿主通过薄包装挂载,无需引入 Vue 3。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pnpm add @embedpdf-editor/chapter-snippet
9
+ ```
10
+
11
+ ## 快速开始
12
+
13
+ ```js
14
+ import ChapterEmbedPDF, { createChapterViewerEditorOptions } from '@embedpdf-editor/chapter-snippet';
15
+
16
+ const container = ChapterEmbedPDF.init({
17
+ type: 'container',
18
+ target: document.getElementById('viewer'),
19
+ wasmUrl: '/pdfium.wasm',
20
+ worker: true,
21
+ editorInput: createChapterViewerEditorOptions({ manifest, bookmarks, notes }),
22
+ });
23
+
24
+ container.addEventListener('chapter-note-request-create', (e) => {
25
+ console.log(e.detail);
26
+ });
27
+ ```
28
+
29
+ ## WASM / Worker
30
+
31
+ 构建产物 `dist/` 包含:
32
+
33
+ - `embedpdf-chapter.js` — 主入口(ESM)
34
+ - `pdfium.wasm` — 需与 JS 同域可访问,或通过 `wasmUrl` 指定
35
+
36
+ 开发服务器需设置 COOP/COEP(SharedArrayBuffer):
37
+
38
+ ```
39
+ Cross-Origin-Opener-Policy: same-origin
40
+ Cross-Origin-Embedder-Policy: require-corp
41
+ ```
42
+
43
+ ## CustomEvent
44
+
45
+ | 事件名 | 说明 |
46
+ |--------|------|
47
+ | `chapter-note-request-create` | 划词创建笔记 |
48
+ | `chapter-note-request-edit` | 编辑笔记 |
49
+ | `chapter-selection-extra-action` | 划词工具栏扩展动作 |
50
+ | `chapter-viewer-ready` | 引擎就绪,`detail.registry` |
51
+
52
+ 常量:`CHAPTER_SNIPPET_EVENTS`
53
+
54
+ ## Vue 2.6
55
+
56
+ ```js
57
+ import ChapterEmbedPDF, { createChapterViewerEditorOptions } from '@embedpdf-editor/chapter-snippet';
58
+ ```
59
+
60
+ Demo:`examples/chapter-viewer-demo-vue2`。Vite 需 `optimizeDeps.exclude: ['@embedpdf-editor/chapter-snippet', '@embedpdf/engines']`,并将 `pdfium.wasm` 放到站点根路径。
61
+
62
+ 也可使用 `@embedpdf-editor/vue2-chapter-viewer` 薄包装(内部同样 `import` 本包)。
63
+
64
+ ## 与 vue3-chapter-viewer 差异
65
+
66
+ - 渲染在 Shadow DOM 内的 Preact 岛,宿主仅负责配置与弹窗
67
+ - 不依赖 `@embedpdf-editor/editor-engine/vue`(Vue 3)
68
+ - 能力集与 `DEFAULT_CHAPTER_VIEWER_FEATURES` 对齐