@embedpdf-editor/vue3-chapter-viewer 0.2.0 → 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/README.md +221 -395
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +110 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4225 -1466
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AnnotationCapability } from '@embedpdf/plugin-annotation';
|
|
2
|
+
import { AnnotationTransferItem } from '@embedpdf/plugin-annotation';
|
|
2
3
|
import { BasePlugin } from '@embedpdf/core';
|
|
3
4
|
import { BasePluginConfig } from '@embedpdf/core';
|
|
4
5
|
import { ChapterTreeNode } from '../vue/chapter-tree';
|
|
@@ -22,8 +23,23 @@ import { ToolbarSchema } from '@embedpdf/plugin-ui';
|
|
|
22
23
|
import { UISchema } from '@embedpdf/plugin-ui';
|
|
23
24
|
import { useCapability } from '@embedpdf/core/vue';
|
|
24
25
|
import { usePdfiumEngine } from '@embedpdf/engines/vue';
|
|
26
|
+
import { useRegistry } from '@embedpdf/core/vue';
|
|
25
27
|
|
|
26
|
-
declare const
|
|
28
|
+
declare const __VLS_base: DefineComponent<ChapterPdfViewerProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ChapterPdfViewerProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
29
|
+
|
|
30
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
31
|
+
|
|
32
|
+
declare type __VLS_Slots = {} & {
|
|
33
|
+
prepend?: (props: typeof __VLS_9) => any;
|
|
34
|
+
} & {
|
|
35
|
+
default?: (props: typeof __VLS_11) => any;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
declare type __VLS_WithSlots<T, S> = T & {
|
|
39
|
+
new (): {
|
|
40
|
+
$slots: S;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
27
43
|
|
|
28
44
|
/** 对当前选区应用 PDF 划线/高亮,支持按类型自定义颜色、粗细与偏移 */
|
|
29
45
|
export declare function applySelectionMarkup(documentId: string, kind: SelectionMarkupKind, annotation: AnnotationCapability, selection: SelectionCapability, styles?: MarkupStylesConfig): boolean;
|
|
@@ -61,6 +77,37 @@ export declare class CallbackPasswordProvider implements IPasswordProvider {
|
|
|
61
77
|
resolvePassword(chapter: ChapterDescriptor, attempt: number): Promise<string | null>;
|
|
62
78
|
}
|
|
63
79
|
|
|
80
|
+
/** 归档文件格式版本 */
|
|
81
|
+
export declare const CHAPTER_ANNOTATIONS_ARCHIVE_VERSION: 1;
|
|
82
|
+
|
|
83
|
+
/** 全书按 chapterId 分组的归档 */
|
|
84
|
+
export declare interface ChapterAnnotationsArchive {
|
|
85
|
+
version: typeof CHAPTER_ANNOTATIONS_ARCHIVE_VERSION;
|
|
86
|
+
exportedAt: string;
|
|
87
|
+
chapters: Record<string, Omit<ChapterAnnotationsSnapshot, 'chapterId'>>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export declare function chapterAnnotationsArchiveToJson(archive: ChapterAnnotationsArchive): string;
|
|
91
|
+
|
|
92
|
+
declare type ChapterAnnotationsContentFlags = {
|
|
93
|
+
/** 默认 true */
|
|
94
|
+
bookmarks?: boolean;
|
|
95
|
+
/** 默认 true */
|
|
96
|
+
notes?: boolean;
|
|
97
|
+
/** 默认 true;对应 @embedpdf/plugin-annotation 的 export/import */
|
|
98
|
+
markup?: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** 单章用户标注快照 */
|
|
102
|
+
export declare interface ChapterAnnotationsSnapshot {
|
|
103
|
+
chapterId: string;
|
|
104
|
+
bookmarks?: ParagraphBookmark[];
|
|
105
|
+
notes?: NoteAnchor[];
|
|
106
|
+
markup?: SerializableAnnotationTransferItem[];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare function chapterAnnotationsSnapshotToJson(snapshot: ChapterAnnotationsSnapshot): string;
|
|
110
|
+
|
|
64
111
|
export declare interface ChapterDescriptor {
|
|
65
112
|
/** 业务唯一 ID;同时复用作 documentManager 的 documentId */
|
|
66
113
|
chapterId: string;
|
|
@@ -312,7 +359,7 @@ export declare interface ChapterViewerOptions {
|
|
|
312
359
|
}
|
|
313
360
|
|
|
314
361
|
declare interface ChapterViewerZoomConfig {
|
|
315
|
-
/** 是否启用
|
|
362
|
+
/** 是否启用 Ctrl+滚轮 / 双指捏合等交互缩放,默认 true;为 false 时仍可用 pageWidth / initial 设置版面宽度 */
|
|
316
363
|
enabled?: boolean;
|
|
317
364
|
min?: number;
|
|
318
365
|
max?: number;
|
|
@@ -398,6 +445,13 @@ export declare const DEFAULT_CHAPTER_VIEWER_CONFIG: ChapterViewerConfig;
|
|
|
398
445
|
/** 默认全开的功能配置(内部规范化结果) */
|
|
399
446
|
export declare const DEFAULT_CHAPTER_VIEWER_FEATURES: ChapterViewerFeaturesConfig;
|
|
400
447
|
|
|
448
|
+
export declare function downloadChapterAnnotationsArchive(archive: ChapterAnnotationsArchive, filename?: string): void;
|
|
449
|
+
|
|
450
|
+
export declare function downloadChapterAnnotationsSnapshot(snapshot: ChapterAnnotationsSnapshot, filename?: string): void;
|
|
451
|
+
|
|
452
|
+
/** 触发浏览器下载 JSON 文件(仅浏览器环境) */
|
|
453
|
+
export declare function downloadJsonFile(filename: string, json: string): void;
|
|
454
|
+
|
|
401
455
|
/** 与 snippet 主工具栏 mode tabs 对齐的编辑模式 */
|
|
402
456
|
declare type EditorModeId = 'view' | 'annotate' | 'shapes' | 'insert' | 'form' | 'redact';
|
|
403
457
|
|
|
@@ -406,6 +460,22 @@ declare const editorSecondaryToolbars: Record<string, ToolbarSchema>;
|
|
|
406
460
|
|
|
407
461
|
export { EmbedPDF }
|
|
408
462
|
|
|
463
|
+
/**
|
|
464
|
+
* 导出 manifest 中全部章节(按 chapterId 存 JSON 对象)。
|
|
465
|
+
*/
|
|
466
|
+
export declare function exportAllChapterAnnotations(registry: PluginRegistry, manifest: ChapterManifest, options?: ExportChapterAnnotationsOptions): Promise<ChapterAnnotationsArchive>;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* 导出单章用户标注(书签、笔记、划词划线)。
|
|
470
|
+
* `chapterId` 与章节 documentId 一致。
|
|
471
|
+
*/
|
|
472
|
+
export declare function exportChapterAnnotations(registry: PluginRegistry, chapterId: string, options?: ExportChapterAnnotationsOptions): Promise<ChapterAnnotationsSnapshot>;
|
|
473
|
+
|
|
474
|
+
export declare type ExportChapterAnnotationsOptions = ChapterAnnotationsContentFlags & {
|
|
475
|
+
/** 导出前确保章节 PDF 已加载(划线需要),默认 true */
|
|
476
|
+
ensureChapterLoaded?: boolean;
|
|
477
|
+
};
|
|
478
|
+
|
|
409
479
|
declare interface HoverBookmarkUiConfig {
|
|
410
480
|
/** 悬停行末「添加书签」自定义图标;无背景 */
|
|
411
481
|
renderAddIcon?: () => unknown;
|
|
@@ -425,6 +495,29 @@ export declare interface IChapterPdfLoader {
|
|
|
425
495
|
loadPdf(chapter: ChapterDescriptor): Promise<ChapterPdfPayload>;
|
|
426
496
|
}
|
|
427
497
|
|
|
498
|
+
/**
|
|
499
|
+
* 导入单章快照。
|
|
500
|
+
*/
|
|
501
|
+
export declare function importChapterAnnotations(registry: PluginRegistry, snapshot: ChapterAnnotationsSnapshot, options?: ImportChapterAnnotationsOptions): Promise<void>;
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* 导入全书归档(仅处理 archive.chapters 中存在的 chapterId)。
|
|
505
|
+
*/
|
|
506
|
+
export declare function importChapterAnnotationsArchive(registry: PluginRegistry, archive: ChapterAnnotationsArchive, options?: ImportChapterAnnotationsOptions): Promise<void>;
|
|
507
|
+
|
|
508
|
+
export declare type ImportChapterAnnotationsOptions = ChapterAnnotationsContentFlags & {
|
|
509
|
+
/**
|
|
510
|
+
* replace:先清空该章对应数据再写入;
|
|
511
|
+
* merge:划线/笔记/书签与现有合并(书签按 anchor 去重)。
|
|
512
|
+
*/
|
|
513
|
+
mode?: 'replace' | 'merge';
|
|
514
|
+
/** 导入前确保章节已加载,默认 true */
|
|
515
|
+
ensureChapterLoaded?: boolean;
|
|
516
|
+
/** 导入完成后回调,便于写入 localStorage / 后端 */
|
|
517
|
+
persistNotes?: (allNotes: NoteAnchor[]) => void | Promise<void>;
|
|
518
|
+
persistBookmarks?: (allBookmarks: ParagraphBookmark[]) => void | Promise<void>;
|
|
519
|
+
};
|
|
520
|
+
|
|
428
521
|
/**
|
|
429
522
|
* 章节加密的抽象接口:当某章节首次或重试加载因密码失败时,
|
|
430
523
|
* `ChapterManagerPlugin` 会向 provider 询问密码。
|
|
@@ -628,6 +721,10 @@ declare interface ParagraphBookmarkPluginConfig extends BasePluginConfig {
|
|
|
628
721
|
hover?: HoverBookmarkUiConfig_2;
|
|
629
722
|
}
|
|
630
723
|
|
|
724
|
+
export declare function parseChapterAnnotationsArchiveJson(json: string): ChapterAnnotationsArchive;
|
|
725
|
+
|
|
726
|
+
export declare function parseChapterAnnotationsSnapshotJson(json: string): ChapterAnnotationsSnapshot;
|
|
727
|
+
|
|
631
728
|
export declare interface PdfChapterEditorBookmarksConfig {
|
|
632
729
|
callbacks: NonNullable<ParagraphBookmarkPluginConfig['callbacks']>;
|
|
633
730
|
}
|
|
@@ -667,10 +764,21 @@ declare interface SelectionToolbarExtraAction {
|
|
|
667
764
|
order?: number;
|
|
668
765
|
}
|
|
669
766
|
|
|
767
|
+
/** JSON 中可存储的划线(stamp 的 ArrayBuffer 转为 base64) */
|
|
768
|
+
export declare interface SerializableAnnotationTransferItem {
|
|
769
|
+
annotation: AnnotationTransferItem['annotation'];
|
|
770
|
+
ctx?: {
|
|
771
|
+
dataBase64?: string;
|
|
772
|
+
mimeType?: string;
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
|
|
670
776
|
export { useCapability }
|
|
671
777
|
|
|
672
778
|
export { usePdfiumEngine }
|
|
673
779
|
|
|
780
|
+
export { useRegistry }
|
|
781
|
+
|
|
674
782
|
/**
|
|
675
783
|
* 一个虚拟页位的解析结果。`localPageIndex` 是 owner 章节 PDF 内的 0-based 索引。
|
|
676
784
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,QAAQ,EACR,aAAa,GACd,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,qCAAqC,EACrC,6BAA6B,EAC7B,2BAA2B,EAC3B,+BAA+B,EAC/B,aAAa,EACb,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,E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