@embedpdf-editor/vue3-chapter-viewer 0.3.1 → 0.3.3

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
@@ -243,6 +243,83 @@ usePdfiumEngine({ wasmUrl: '/assets/pdfium.wasm', worker: true });
243
243
 
244
244
  使用 `worker: true` 时,部署环境需要允许 worker 加载 wasm。若只在 worker 模式失败,可先用 `worker: false` 定位资源或响应头问题。
245
245
 
246
+ ## `features` 自定义:划线样式、删除菜单、图标
247
+
248
+ 与 React 包相同,通过 `options.features` 配置。类型见 `@embedpdf-editor/vue3-chapter-viewer`(来自 `chapter-viewer`)。
249
+
250
+ ### 划线颜色、粗细与位置
251
+
252
+ ```ts
253
+ features: {
254
+ markup: {
255
+ styles: {
256
+ highlight: { color: '#fef08a', opacity: 0.45 },
257
+ underline: { color: '#dc2626', thickness: 1.5, offsetY: 2.5 },
258
+ squiggly: { color: '#dc2626', thickness: 1.5, offsetY: 4 },
259
+ strikeout: { color: '#64748b', offsetY: 0 },
260
+ },
261
+ },
262
+ },
263
+ ```
264
+
265
+ `offsetY` 为 PDF 点、正值向下;波浪线默认 `4`,减轻盖住字形。`markup: false` 关闭划线。
266
+
267
+ ### 点击已有划线:删除
268
+
269
+ 选中高亮/下划线/波浪线/删除线后,默认在标注下方显示「删除」。可自定义:
270
+
271
+ ```ts
272
+ import { h } from 'vue';
273
+
274
+ features: {
275
+ markup: {
276
+ annotationMenu: {
277
+ renderMenu: ({ onDelete }) =>
278
+ h('button', { type: 'button', onClick: onDelete }, '移除'),
279
+ },
280
+ },
281
+ },
282
+ ```
283
+
284
+ `PdfChapterViewport` 上传 `annotation-selection-menu` 时宿主优先,未渲染时再回退默认删除菜单。
285
+
286
+ ### 笔记、书签图标
287
+
288
+ ```ts
289
+ import { h } from 'vue';
290
+
291
+ features: {
292
+ notes: {
293
+ marker: {
294
+ renderIcon: () => h('img', { src: '/icons/note.svg', width: 20, height: 20 }),
295
+ iconSize: 22,
296
+ renderMenuActions: ({ onEdit, onDelete }) =>
297
+ h('div', [
298
+ h('button', { onClick: onEdit }, '编辑'),
299
+ h('button', { onClick: onDelete }, '删除'),
300
+ ]),
301
+ },
302
+ },
303
+ bookmarks: {
304
+ marker: { renderIcon: () => h('img', { src: '/icons/bookmark.svg' }) },
305
+ hover: { renderAddIcon: () => h('span', '+') },
306
+ },
307
+ },
308
+ ```
309
+
310
+ ### 选区工具栏
311
+
312
+ ```ts
313
+ features: {
314
+ selectionToolbar: {
315
+ hiddenBuiltinActions: ['strikeout'],
316
+ extraActions: [{ id: 'cite', label: '引用', order: 10 }],
317
+ },
318
+ },
319
+ ```
320
+
321
+ 配合 `ChapterPdfViewer` 的 `@extra-selection-action` 或 `build-selection-menu`。
322
+
246
323
  ## 进阶组合
247
324
 
248
325
  内置 `ChapterPdfViewer` 已完成插件注册和章节视口渲染。需要插入自定义 shell、目录、工具栏或直接访问 registry 时,可以使用低层组合: