@embedpdf/svelte 0.0.0-stage → 3.0.0-next.16
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 +192 -0
- package/README.md +312 -2
- package/dist/actions/readers.svelte.d.ts +29 -0
- package/dist/actions/readers.svelte.js +55 -0
- package/dist/actions.d.ts +13 -0
- package/dist/actions.js +13 -0
- package/dist/anchored/Anchored.svelte +24 -0
- package/dist/anchored/Anchored.svelte.d.ts +4 -0
- package/dist/anchored/PlacedAnchored.svelte +97 -0
- package/dist/anchored/PlacedAnchored.svelte.d.ts +4 -0
- package/dist/anchored/context.d.ts +31 -0
- package/dist/anchored/context.js +36 -0
- package/dist/anchored/props.d.ts +29 -0
- package/dist/anchored/props.js +1 -0
- package/dist/anchored.d.ts +12 -0
- package/dist/anchored.js +2 -0
- package/dist/annotation/AnnotationChrome.svelte +173 -0
- package/dist/annotation/AnnotationChrome.svelte.d.ts +11 -0
- package/dist/annotation/AnnotationDraftMenu.svelte +27 -0
- package/dist/annotation/AnnotationDraftMenu.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationFrame.svelte +46 -0
- package/dist/annotation/AnnotationFrame.svelte.d.ts +15 -0
- package/dist/annotation/AnnotationLayer.svelte +241 -0
- package/dist/annotation/AnnotationLayer.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationLook.svelte +67 -0
- package/dist/annotation/AnnotationLook.svelte.d.ts +21 -0
- package/dist/annotation/AnnotationMenu.svelte +47 -0
- package/dist/annotation/AnnotationMenu.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationRotationBadge.svelte +52 -0
- package/dist/annotation/AnnotationRotationBadge.svelte.d.ts +4 -0
- package/dist/annotation/AnnotationScene.svelte +27 -0
- package/dist/annotation/AnnotationScene.svelte.d.ts +7 -0
- package/dist/annotation/FreeTextBox.svelte +51 -0
- package/dist/annotation/FreeTextBox.svelte.d.ts +9 -0
- package/dist/annotation/NativeDrawing.svelte +61 -0
- package/dist/annotation/NativeDrawing.svelte.d.ts +10 -0
- package/dist/annotation/StampGhost.svelte +79 -0
- package/dist/annotation/StampGhost.svelte.d.ts +7 -0
- package/dist/annotation/chrome-paint.svelte.d.ts +30 -0
- package/dist/annotation/chrome-paint.svelte.js +27 -0
- package/dist/annotation/props.d.ts +181 -0
- package/dist/annotation/props.js +1 -0
- package/dist/annotation/readers.svelte.d.ts +59 -0
- package/dist/annotation/readers.svelte.js +136 -0
- package/dist/annotation/state.d.ts +18 -0
- package/dist/annotation/state.js +20 -0
- package/dist/annotation/text-box.svelte.d.ts +28 -0
- package/dist/annotation/text-box.svelte.js +87 -0
- package/dist/annotation.d.ts +32 -0
- package/dist/annotation.js +31 -0
- package/dist/attachment/readers.d.ts +23 -0
- package/dist/attachment/readers.js +21 -0
- package/dist/attachment.d.ts +13 -0
- package/dist/attachment.js +14 -0
- package/dist/commands/readers.svelte.d.ts +50 -0
- package/dist/commands/readers.svelte.js +83 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.js +9 -0
- package/dist/form/ButtonControl.svelte +38 -0
- package/dist/form/ButtonControl.svelte.d.ts +11 -0
- package/dist/form/ComboControl.svelte +52 -0
- package/dist/form/ComboControl.svelte.d.ts +11 -0
- package/dist/form/FieldPictures.svelte +145 -0
- package/dist/form/FieldPictures.svelte.d.ts +3 -0
- package/dist/form/FormFocusRing.svelte +25 -0
- package/dist/form/FormFocusRing.svelte.d.ts +8 -0
- package/dist/form/FormLayer.svelte +98 -0
- package/dist/form/FormLayer.svelte.d.ts +3 -0
- package/dist/form/ListControl.svelte +49 -0
- package/dist/form/ListControl.svelte.d.ts +11 -0
- package/dist/form/NativeListBox.svelte +57 -0
- package/dist/form/NativeListBox.svelte.d.ts +4 -0
- package/dist/form/SignatureControl.svelte +53 -0
- package/dist/form/SignatureControl.svelte.d.ts +11 -0
- package/dist/form/TextControl.svelte +107 -0
- package/dist/form/TextControl.svelte.d.ts +11 -0
- package/dist/form/ToggleControl.svelte +50 -0
- package/dist/form/ToggleControl.svelte.d.ts +11 -0
- package/dist/form/WidgetBox.svelte +82 -0
- package/dist/form/WidgetBox.svelte.d.ts +15 -0
- package/dist/form/props.d.ts +21 -0
- package/dist/form/props.js +1 -0
- package/dist/form/readers.svelte.d.ts +46 -0
- package/dist/form/readers.svelte.js +52 -0
- package/dist/form/widget.d.ts +16 -0
- package/dist/form/widget.js +20 -0
- package/dist/form.d.ts +11 -0
- package/dist/form.js +12 -0
- package/dist/history/readers.d.ts +22 -0
- package/dist/history/readers.js +21 -0
- package/dist/history.d.ts +10 -0
- package/dist/history.js +11 -0
- package/dist/i18n/readers.svelte.d.ts +32 -0
- package/dist/i18n/readers.svelte.js +30 -0
- package/dist/i18n.d.ts +8 -0
- package/dist/i18n.js +9 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/interaction/PagePointerSource.svelte +37 -0
- package/dist/interaction/PagePointerSource.svelte.d.ts +3 -0
- package/dist/interaction/readers.svelte.d.ts +26 -0
- package/dist/interaction/readers.svelte.js +47 -0
- package/dist/interaction.d.ts +11 -0
- package/dist/interaction.js +13 -0
- package/dist/link/LinkLayer.svelte +164 -0
- package/dist/link/LinkLayer.svelte.d.ts +4 -0
- package/dist/link/props.d.ts +17 -0
- package/dist/link/props.js +1 -0
- package/dist/link/readers.svelte.d.ts +18 -0
- package/dist/link/readers.svelte.js +38 -0
- package/dist/link.d.ts +11 -0
- package/dist/link.js +11 -0
- package/dist/measurement/readers.d.ts +44 -0
- package/dist/measurement/readers.js +46 -0
- package/dist/measurement.d.ts +12 -0
- package/dist/measurement.js +13 -0
- package/dist/metadata/readers.d.ts +22 -0
- package/dist/metadata/readers.js +22 -0
- package/dist/metadata.d.ts +12 -0
- package/dist/metadata.js +13 -0
- package/dist/outline/readers.d.ts +26 -0
- package/dist/outline/readers.js +22 -0
- package/dist/outline.d.ts +12 -0
- package/dist/outline.js +13 -0
- package/dist/page-edit/readers.d.ts +17 -0
- package/dist/page-edit/readers.js +18 -0
- package/dist/page-edit.d.ts +12 -0
- package/dist/page-edit.js +13 -0
- package/dist/page-view/PageView.svelte +192 -0
- package/dist/page-view/PageView.svelte.d.ts +4 -0
- package/dist/page-view/props.d.ts +32 -0
- package/dist/page-view/props.js +1 -0
- package/dist/page-view.d.ts +8 -0
- package/dist/page-view.js +7 -0
- package/dist/redaction/readers.d.ts +37 -0
- package/dist/redaction/readers.js +38 -0
- package/dist/redaction.d.ts +12 -0
- package/dist/redaction.js +13 -0
- package/dist/render/RenderLayer.svelte +116 -0
- package/dist/render/RenderLayer.svelte.d.ts +4 -0
- package/dist/render/TileImage.svelte +65 -0
- package/dist/render/TileImage.svelte.d.ts +11 -0
- package/dist/render/TilePlane.svelte +88 -0
- package/dist/render/TilePlane.svelte.d.ts +7 -0
- package/dist/render/props.d.ts +16 -0
- package/dist/render/props.js +1 -0
- package/dist/render/readers.svelte.d.ts +9 -0
- package/dist/render/readers.svelte.js +13 -0
- package/dist/render.d.ts +10 -0
- package/dist/render.js +10 -0
- package/dist/runtime/DocumentGate.svelte +26 -0
- package/dist/runtime/DocumentGate.svelte.d.ts +4 -0
- package/dist/runtime/DocumentScope.svelte +14 -0
- package/dist/runtime/DocumentScope.svelte.d.ts +4 -0
- package/dist/runtime/KernelProvider.svelte +33 -0
- package/dist/runtime/KernelProvider.svelte.d.ts +4 -0
- package/dist/runtime/SvgShapes.svelte +30 -0
- package/dist/runtime/SvgShapes.svelte.d.ts +8 -0
- package/dist/runtime/Viewer.svelte +130 -0
- package/dist/runtime/Viewer.svelte.d.ts +4 -0
- package/dist/runtime/binding.svelte.d.ts +33 -0
- package/dist/runtime/binding.svelte.js +71 -0
- package/dist/runtime/capability-handle.d.ts +6 -0
- package/dist/runtime/capability-handle.js +71 -0
- package/dist/runtime/dev.d.ts +10 -0
- package/dist/runtime/dev.js +23 -0
- package/dist/runtime/documents.svelte.d.ts +34 -0
- package/dist/runtime/documents.svelte.js +49 -0
- package/dist/runtime/page-layers.svelte.d.ts +20 -0
- package/dist/runtime/page-layers.svelte.js +40 -0
- package/dist/runtime/page.d.ts +10 -0
- package/dist/runtime/page.js +23 -0
- package/dist/runtime/props.d.ts +63 -0
- package/dist/runtime/props.js +1 -0
- package/dist/runtime/readers.svelte.d.ts +47 -0
- package/dist/runtime/readers.svelte.js +122 -0
- package/dist/runtime/state.svelte.d.ts +35 -0
- package/dist/runtime/state.svelte.js +90 -0
- package/dist/runtime/theme.d.ts +12 -0
- package/dist/runtime/theme.js +15 -0
- package/dist/runtime/values.svelte.d.ts +28 -0
- package/dist/runtime/values.svelte.js +51 -0
- package/dist/runtime.d.ts +26 -0
- package/dist/runtime.js +25 -0
- package/dist/search/SearchLayer.svelte +94 -0
- package/dist/search/SearchLayer.svelte.d.ts +4 -0
- package/dist/search/props.d.ts +11 -0
- package/dist/search/props.js +1 -0
- package/dist/search/readers.svelte.d.ts +41 -0
- package/dist/search/readers.svelte.js +40 -0
- package/dist/search.d.ts +11 -0
- package/dist/search.js +11 -0
- package/dist/selection/SelectionClipboard.svelte +35 -0
- package/dist/selection/SelectionClipboard.svelte.d.ts +4 -0
- package/dist/selection/SelectionHandles.svelte +192 -0
- package/dist/selection/SelectionHandles.svelte.d.ts +4 -0
- package/dist/selection/SelectionLayer.svelte +67 -0
- package/dist/selection/SelectionLayer.svelte.d.ts +3 -0
- package/dist/selection/SelectionMenu.svelte +36 -0
- package/dist/selection/SelectionMenu.svelte.d.ts +4 -0
- package/dist/selection/props.d.ts +26 -0
- package/dist/selection/props.js +1 -0
- package/dist/selection/readers.svelte.d.ts +31 -0
- package/dist/selection/readers.svelte.js +26 -0
- package/dist/selection.d.ts +16 -0
- package/dist/selection.js +18 -0
- package/dist/shell/readers.svelte.d.ts +40 -0
- package/dist/shell/readers.svelte.js +40 -0
- package/dist/shell/surface-focus.svelte.d.ts +16 -0
- package/dist/shell/surface-focus.svelte.js +33 -0
- package/dist/shell.d.ts +12 -0
- package/dist/shell.js +11 -0
- package/dist/signature/readers.svelte.d.ts +43 -0
- package/dist/signature/readers.svelte.js +46 -0
- package/dist/signature.d.ts +15 -0
- package/dist/signature.js +16 -0
- package/dist/stage/PageSurface.svelte +126 -0
- package/dist/stage/PageSurface.svelte.d.ts +18 -0
- package/dist/stage/Scrollbar.svelte +148 -0
- package/dist/stage/Scrollbar.svelte.d.ts +4 -0
- package/dist/stage/Stage.svelte +181 -0
- package/dist/stage/Stage.svelte.d.ts +4 -0
- package/dist/stage/StageScope.svelte +14 -0
- package/dist/stage/StageScope.svelte.d.ts +9 -0
- package/dist/stage/props.d.ts +71 -0
- package/dist/stage/props.js +1 -0
- package/dist/stage/readers.svelte.d.ts +39 -0
- package/dist/stage/readers.svelte.js +84 -0
- package/dist/stage/stage-scope.d.ts +18 -0
- package/dist/stage/stage-scope.js +35 -0
- package/dist/stage/two-way.svelte.d.ts +13 -0
- package/dist/stage/two-way.svelte.js +26 -0
- package/dist/stage.d.ts +17 -0
- package/dist/stage.js +15 -0
- package/dist/stamp/readers.svelte.d.ts +50 -0
- package/dist/stamp/readers.svelte.js +76 -0
- package/dist/stamp.d.ts +16 -0
- package/dist/stamp.js +18 -0
- package/dist/toolbar/DefaultCollapsed.svelte +39 -0
- package/dist/toolbar/DefaultCollapsed.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultCommand.svelte +33 -0
- package/dist/toolbar/DefaultCommand.svelte.d.ts +8 -0
- package/dist/toolbar/DefaultGroupTrigger.svelte +39 -0
- package/dist/toolbar/DefaultGroupTrigger.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultOverflowMenu.svelte +106 -0
- package/dist/toolbar/DefaultOverflowMenu.svelte.d.ts +9 -0
- package/dist/toolbar/DefaultOverflowTrigger.svelte +25 -0
- package/dist/toolbar/DefaultOverflowTrigger.svelte.d.ts +7 -0
- package/dist/toolbar/Measured.svelte +46 -0
- package/dist/toolbar/Measured.svelte.d.ts +11 -0
- package/dist/toolbar/NativeSlotSocket.svelte +43 -0
- package/dist/toolbar/NativeSlotSocket.svelte.d.ts +11 -0
- package/dist/toolbar/Toolbar.svelte +314 -0
- package/dist/toolbar/Toolbar.svelte.d.ts +4 -0
- package/dist/toolbar/paint.d.ts +3 -0
- package/dist/toolbar/paint.js +9 -0
- package/dist/toolbar/props.d.ts +48 -0
- package/dist/toolbar/props.js +1 -0
- package/dist/toolbar/strip.svelte.d.ts +14 -0
- package/dist/toolbar/strip.svelte.js +35 -0
- package/dist/toolbar/views.d.ts +14 -0
- package/dist/toolbar/views.js +1 -0
- package/dist/toolbar.d.ts +16 -0
- package/dist/toolbar.js +12 -0
- package/dist/view-manager/readers.d.ts +19 -0
- package/dist/view-manager/readers.js +17 -0
- package/dist/view-manager.d.ts +11 -0
- package/dist/view-manager.js +12 -0
- package/package.json +207 -3
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The links on one page: one absolutely placed `<a>` per clickable area. Real anchors on purpose:
|
|
3
|
+
a website gets an `href`, so a middle click, "copy link", the status-bar preview and keyboard
|
|
4
|
+
focus work as in any page. A click or a key follows the link through the plugin's `activate()`,
|
|
5
|
+
so every way of following one fires `onActivated`; the plugin opens websites through the opener
|
|
6
|
+
this binding registers.
|
|
7
|
+
|
|
8
|
+
The layer stands down while the active tool doesn't enable `link-nav`: the annotation layer
|
|
9
|
+
owns links then (select, move, resize). While a tool can edit annotations, a link attached to
|
|
10
|
+
another annotation is that annotation's, and its anchor stands down too.
|
|
11
|
+
-->
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import { ActionsToken, createHoverPump } from '@embedpdf/plugin-actions/contract';
|
|
14
|
+
import { InteractionToken } from '@embedpdf/plugin-interaction/contract/host';
|
|
15
|
+
import { LinkToken, type Link } from '@embedpdf/plugin-link';
|
|
16
|
+
import { LinkToken as LinkHostToken } from '@embedpdf/plugin-link/contract/host';
|
|
17
|
+
import {
|
|
18
|
+
hoverLink,
|
|
19
|
+
isModifiedClick,
|
|
20
|
+
isolatePointerDown,
|
|
21
|
+
linkActivateContextOf,
|
|
22
|
+
linkAnchorOf,
|
|
23
|
+
navigableLinksOf,
|
|
24
|
+
sendLinkEvent,
|
|
25
|
+
type LinkAnchorEvent,
|
|
26
|
+
} from '@embedpdf/web';
|
|
27
|
+
import { usePage } from '../runtime/page.js';
|
|
28
|
+
import {
|
|
29
|
+
shallowArray,
|
|
30
|
+
useCapability,
|
|
31
|
+
useOptionalCapability,
|
|
32
|
+
useOptionalSelector,
|
|
33
|
+
} from '../runtime/readers.svelte.js';
|
|
34
|
+
import { stageTokenOf } from '../stage/stage-scope.js';
|
|
35
|
+
import type { LinkLayerProps } from './props.js';
|
|
36
|
+
import { useUriOpener } from './readers.svelte.js';
|
|
37
|
+
|
|
38
|
+
const NO_LINKS: readonly Link[] = Object.freeze([]);
|
|
39
|
+
|
|
40
|
+
let { link: drawLink }: LinkLayerProps = $props();
|
|
41
|
+
|
|
42
|
+
const page = usePage();
|
|
43
|
+
// The API for following a link (a handle: always this document's), and the plugin's own object
|
|
44
|
+
// for the reads here, which then wake nothing but a new document.
|
|
45
|
+
const links = useCapability(LinkToken);
|
|
46
|
+
const capability = useOptionalCapability(LinkToken);
|
|
47
|
+
useUriOpener();
|
|
48
|
+
// A page destination moves the view this page is shown in.
|
|
49
|
+
const stage = useOptionalCapability(stageTokenOf());
|
|
50
|
+
// The links' own /AA events (enter, exit, down, up, focus, blur) can only fire from here: while
|
|
51
|
+
// a link navigates, its pixels are these anchors. One hover pump per layer; crossing layers
|
|
52
|
+
// still orders Exit before Enter, since both sides submit in DOM event order.
|
|
53
|
+
const actions = useOptionalCapability(ActionsToken);
|
|
54
|
+
const pump = $derived(actions.current ? createHoverPump(actions.current.dispatch) : null);
|
|
55
|
+
|
|
56
|
+
const items = useOptionalSelector(
|
|
57
|
+
LinkToken,
|
|
58
|
+
(lens) => lens.listLinks(page.ref),
|
|
59
|
+
NO_LINKS,
|
|
60
|
+
shallowArray,
|
|
61
|
+
);
|
|
62
|
+
const engaged = useOptionalSelector(LinkHostToken, (lens) => lens.isNavigationEngaged(), false);
|
|
63
|
+
// One owner per pixel: while the active tool can edit annotations, a link attached to another
|
|
64
|
+
// annotation belongs to it, and its anchor stands down. Standalone links navigate under any
|
|
65
|
+
// tool that enables `link-nav`.
|
|
66
|
+
const editEnabled = useOptionalSelector(
|
|
67
|
+
InteractionToken,
|
|
68
|
+
(interaction) => interaction.activeToolEnables('annotation-edit'),
|
|
69
|
+
false,
|
|
70
|
+
);
|
|
71
|
+
const visible = $derived(
|
|
72
|
+
engaged.current && items.current.length > 0
|
|
73
|
+
? navigableLinksOf(items.current, editEnabled.current)
|
|
74
|
+
: NO_LINKS,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
$effect(() => {
|
|
78
|
+
const lens = capability.current;
|
|
79
|
+
const ref = page.ref;
|
|
80
|
+
if (!lens) return;
|
|
81
|
+
void lens.ensureLoaded(ref);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/** Follow `item` through the plugin, which moves the view or opens a website. */
|
|
85
|
+
function follow(item: Link) {
|
|
86
|
+
links.activate(item, linkActivateContextOf(item, page.ref, stage.current));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The link's own /AA event for a press, a release or focus, with the actions plugin. */
|
|
90
|
+
function notify(item: Link, event: LinkAnchorEvent) {
|
|
91
|
+
sendLinkEvent(actions.current, item, page.ref, event);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function onClick(href: string | null, item: Link, event: MouseEvent) {
|
|
95
|
+
// A modified click on a real `href` keeps the browser's own behavior (a background tab, a
|
|
96
|
+
// new window). Every other click follows the link through the plugin.
|
|
97
|
+
if (href && isModifiedClick(event)) return;
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
follow(item);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function onKeyDown(item: Link, event: KeyboardEvent) {
|
|
103
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
follow(item);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A press inside a link must not reach the Stage (it would start the active tool's gesture, or
|
|
110
|
+
* end an edit as a click outside). Svelte hands `onpointerdown` to the root, after the Stage
|
|
111
|
+
* saw the press, so the press stops on a native listener on the anchor, which also sends the
|
|
112
|
+
* link's "mouse down" action.
|
|
113
|
+
*/
|
|
114
|
+
const isolate = (item: () => Link) => (element: HTMLElement) =>
|
|
115
|
+
isolatePointerDown(element, () => notify(item(), 'mouseDown'));
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
{#if visible.length > 0}
|
|
119
|
+
<div style="position: absolute; inset: 0; pointer-events: none">
|
|
120
|
+
{#each visible as item (item.id)}
|
|
121
|
+
{@const { box, href, label } = linkAnchorOf(
|
|
122
|
+
item,
|
|
123
|
+
page.transform,
|
|
124
|
+
(link) => capability.current?.getLabel(link) ?? '',
|
|
125
|
+
)}
|
|
126
|
+
<!-- Its box, its label, and a native `href` only for a website with nothing chained after
|
|
127
|
+
it. -->
|
|
128
|
+
<!-- The layer's own anchor; a `link` snippet draws around it. -->
|
|
129
|
+
{#snippet native()}
|
|
130
|
+
<!-- `role` stays: an anchor without `href` (a page destination) has no role of its own. -->
|
|
131
|
+
<!-- svelte-ignore a11y_no_redundant_roles -->
|
|
132
|
+
<a
|
|
133
|
+
{@attach isolate(() => item)}
|
|
134
|
+
href={href ?? undefined}
|
|
135
|
+
target="_blank"
|
|
136
|
+
rel="noopener noreferrer"
|
|
137
|
+
role="link"
|
|
138
|
+
tabindex="0"
|
|
139
|
+
title={label}
|
|
140
|
+
aria-label={label}
|
|
141
|
+
onclick={(event) => onClick(href, item, event)}
|
|
142
|
+
onkeydown={(event) => onKeyDown(item, event)}
|
|
143
|
+
onpointerenter={() => hoverLink(pump, item, page.ref)}
|
|
144
|
+
onpointerleave={() => pump?.hover(null)}
|
|
145
|
+
onpointerup={() => notify(item, 'mouseUp')}
|
|
146
|
+
onfocus={() => notify(item, 'focus')}
|
|
147
|
+
onblur={() => notify(item, 'blur')}
|
|
148
|
+
style:position="absolute"
|
|
149
|
+
style:left="{box.left}px"
|
|
150
|
+
style:top="{box.top}px"
|
|
151
|
+
style:width="{box.width}px"
|
|
152
|
+
style:height="{box.height}px"
|
|
153
|
+
style:cursor="pointer"
|
|
154
|
+
style:pointer-events="auto"
|
|
155
|
+
></a>
|
|
156
|
+
{/snippet}
|
|
157
|
+
{#if drawLink}
|
|
158
|
+
{@render drawLink({ link: item, native })}
|
|
159
|
+
{:else}
|
|
160
|
+
{@render native()}
|
|
161
|
+
{/if}
|
|
162
|
+
{/each}
|
|
163
|
+
</div>
|
|
164
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The props of `<LinkLayer>`. */
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { Link } from '@embedpdf/plugin-link';
|
|
4
|
+
/** What the `link` snippet receives for each link. */
|
|
5
|
+
export interface LinkRenderProps {
|
|
6
|
+
/** The link: its `id`, its `bounds` on the page and its `target`. */
|
|
7
|
+
link: Link;
|
|
8
|
+
/** The layer's own clickable area, `{@render native()}`: wrap it to keep what a click does. */
|
|
9
|
+
native: Snippet;
|
|
10
|
+
}
|
|
11
|
+
export interface LinkLayerProps {
|
|
12
|
+
/**
|
|
13
|
+
* Draw each link yourself, usually around `{@render native()}`. To leave a link as it is,
|
|
14
|
+
* render only `native` for it.
|
|
15
|
+
*/
|
|
16
|
+
link?: Snippet<[props: LinkRenderProps]>;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EventHook } from '@embedpdf/core';
|
|
2
|
+
import type { LinkCapability } from '@embedpdf/plugin-link';
|
|
3
|
+
/**
|
|
4
|
+
* Hand the link plugin this binding's website opener (`openExternalUri`) while the component
|
|
5
|
+
* lives: an allowed address opens in a new tab, anything else is refused and the plugin reports
|
|
6
|
+
* it. Registered again for each document.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useUriOpener(): void;
|
|
9
|
+
/**
|
|
10
|
+
* The link API (`listLinks()`, `activate()`, …) for app code. While a component uses it,
|
|
11
|
+
* `activate()` opens a website in a new tab.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useLink(): LinkCapability;
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to one link event while the component lives:
|
|
16
|
+
* `useLinkEvent((link) => link.onActivated, handler)`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useLinkEvent<T>(select: (link: LinkCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The link plugin's readers: `useLink()` (the API) and `useLinkEvent()`, and the website opener
|
|
3
|
+
* this binding hands the plugin while a link component is mounted.
|
|
4
|
+
*/
|
|
5
|
+
import { untrack } from 'svelte';
|
|
6
|
+
import { LinkToken } from '@embedpdf/plugin-link';
|
|
7
|
+
import { LinkToken as LinkHostToken } from '@embedpdf/plugin-link/contract/host';
|
|
8
|
+
import { openExternalUri } from '@embedpdf/web';
|
|
9
|
+
import { useCapability, useCapabilityEvent, useOptionalCapability, } from '../runtime/readers.svelte.js';
|
|
10
|
+
/**
|
|
11
|
+
* Hand the link plugin this binding's website opener (`openExternalUri`) while the component
|
|
12
|
+
* lives: an allowed address opens in a new tab, anything else is refused and the plugin reports
|
|
13
|
+
* it. Registered again for each document.
|
|
14
|
+
*/
|
|
15
|
+
export function useUriOpener() {
|
|
16
|
+
const host = useOptionalCapability(LinkHostToken);
|
|
17
|
+
$effect(() => {
|
|
18
|
+
const current = host.current;
|
|
19
|
+
if (!current)
|
|
20
|
+
return;
|
|
21
|
+
return untrack(() => current.registerUriOpener(openExternalUri));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The link API (`listLinks()`, `activate()`, …) for app code. While a component uses it,
|
|
26
|
+
* `activate()` opens a website in a new tab.
|
|
27
|
+
*/
|
|
28
|
+
export function useLink() {
|
|
29
|
+
useUriOpener();
|
|
30
|
+
return useCapability(LinkToken);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Subscribe to one link event while the component lives:
|
|
34
|
+
* `useLinkEvent((link) => link.onActivated, handler)`.
|
|
35
|
+
*/
|
|
36
|
+
export function useLinkEvent(select, handler) {
|
|
37
|
+
useCapabilityEvent(LinkToken, select, handler);
|
|
38
|
+
}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/link — following links.
|
|
3
|
+
*
|
|
4
|
+
* `<LinkLayer>` puts a real anchor over each link on a page (draw around it with its `link`
|
|
5
|
+
* snippet); `useLink()` is the plugin's API and opens websites while it's in use, and
|
|
6
|
+
* `useLinkEvent()` its events.
|
|
7
|
+
*/
|
|
8
|
+
export * from '@embedpdf/plugin-link';
|
|
9
|
+
export { default as LinkLayer } from './link/LinkLayer.svelte';
|
|
10
|
+
export type { LinkLayerProps, LinkRenderProps } from './link/props.js';
|
|
11
|
+
export { useLink, useLinkEvent } from './link/readers.svelte.js';
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/link — following links.
|
|
3
|
+
*
|
|
4
|
+
* `<LinkLayer>` puts a real anchor over each link on a page (draw around it with its `link`
|
|
5
|
+
* snippet); `useLink()` is the plugin's API and opens websites while it's in use, and
|
|
6
|
+
* `useLinkEvent()` its events.
|
|
7
|
+
*/
|
|
8
|
+
// Registration travels with the UI.
|
|
9
|
+
export * from '@embedpdf/plugin-link';
|
|
10
|
+
export { default as LinkLayer } from './link/LinkLayer.svelte';
|
|
11
|
+
export { useLink, useLinkEvent } from './link/readers.svelte.js';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The measurement plugin's readers: `useMeasurement()` (the API), `useMeasurementState()`,
|
|
3
|
+
* `useMeasurementSettings()`, `useMeasurementEvent()`, and one per page scale and one per
|
|
4
|
+
* measurement, so a template updates only for its own page or measurement. Every one works before
|
|
5
|
+
* a document opens.
|
|
6
|
+
*/
|
|
7
|
+
import type { EventHook, PageRef } from '@embedpdf/core';
|
|
8
|
+
import type { AnnotationRef, MeasurementCapability, MeasurementReadout, MeasurementUnavailable, PageScale } from '@embedpdf/plugin-measurement';
|
|
9
|
+
import { type CurrentValue, type MaybeGetter } from '../runtime/values.svelte.js';
|
|
10
|
+
/**
|
|
11
|
+
* The measurement API (scales, calibration, readouts, creating measurements) of the nearest
|
|
12
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document every method throws
|
|
13
|
+
* `not-ready`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useMeasurement(): MeasurementCapability;
|
|
16
|
+
/** Subscribe to one measurement event while the component lives: `useMeasurementEvent((measurement) => measurement.onScaleChanged, handler)`. */
|
|
17
|
+
export declare function useMeasurementEvent<T>(select: (measurement: MeasurementCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
18
|
+
/**
|
|
19
|
+
* The measurement state: whether a scale change runs, the calibration request waiting for its
|
|
20
|
+
* length, and the last change's reports (the page's State table, declared once in
|
|
21
|
+
* `measurementState`), as a reactive object (`state.calibrationRequest`). With a selector, the
|
|
22
|
+
* value it picks as `{ current }`. Empty without a document.
|
|
23
|
+
*/
|
|
24
|
+
export declare const useMeasurementState: import("../index.js").StateReader<{
|
|
25
|
+
busy: boolean;
|
|
26
|
+
calibrationRequest: import("@embedpdf/plugin-measurement").CalibrationRequest | null;
|
|
27
|
+
lastReports: readonly import("@embedpdf/plugin-measurement").ScaleChangeReport[];
|
|
28
|
+
}>;
|
|
29
|
+
/** The measurement settings (`defaultScale`, `presets`), with or without a document. */
|
|
30
|
+
export declare const useMeasurementSettings: import("../index.js").SettingsReader<import("@embedpdf/plugin-measurement").MeasurementSettings & object>;
|
|
31
|
+
/**
|
|
32
|
+
* A page's measurement scale (its ref or its index; a function to follow a prop) as
|
|
33
|
+
* `{ current }`: for a scale bar or a "1:100" badge. Accepts `null` (no current page) and answers
|
|
34
|
+
* `null` then, so chrome can stay mounted without inventing a page.
|
|
35
|
+
*/
|
|
36
|
+
export declare function usePageScale(page: MaybeGetter<PageRef | number>): CurrentValue<PageScale>;
|
|
37
|
+
export declare function usePageScale(page: MaybeGetter<PageRef | number | null>): CurrentValue<PageScale | null>;
|
|
38
|
+
/**
|
|
39
|
+
* A measurement's `{ kind, value, label }` as `{ current }`, or `{ unavailable }` with why there's
|
|
40
|
+
* none. A measurement that changes is a function: `useMeasurementReadout(() => annotation)`.
|
|
41
|
+
* Readouts are reference-stable in the plugin, so the value changes only when the measurement's
|
|
42
|
+
* does.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useMeasurementReadout(ref: MaybeGetter<AnnotationRef>): CurrentValue<MeasurementReadout | MeasurementUnavailable>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { MeasurementToken, measurementState, NO_PAGE_SCALE, NO_READOUT, } from '@embedpdf/plugin-measurement';
|
|
2
|
+
import { documentScopeOf } from '../runtime/binding.svelte.js';
|
|
3
|
+
import { useCapability, useCapabilityEvent, useKernelValue, useOptionalSelector, } from '../runtime/readers.svelte.js';
|
|
4
|
+
import { settingsReader, stateReader } from '../runtime/state.svelte.js';
|
|
5
|
+
import { valueOf } from '../runtime/values.svelte.js';
|
|
6
|
+
/**
|
|
7
|
+
* The measurement API (scales, calibration, readouts, creating measurements) of the nearest
|
|
8
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document every method throws
|
|
9
|
+
* `not-ready`.
|
|
10
|
+
*/
|
|
11
|
+
export function useMeasurement() {
|
|
12
|
+
return useCapability(MeasurementToken);
|
|
13
|
+
}
|
|
14
|
+
/** Subscribe to one measurement event while the component lives: `useMeasurementEvent((measurement) => measurement.onScaleChanged, handler)`. */
|
|
15
|
+
export function useMeasurementEvent(select, handler) {
|
|
16
|
+
useCapabilityEvent(MeasurementToken, select, handler);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The measurement state: whether a scale change runs, the calibration request waiting for its
|
|
20
|
+
* length, and the last change's reports (the page's State table, declared once in
|
|
21
|
+
* `measurementState`), as a reactive object (`state.calibrationRequest`). With a selector, the
|
|
22
|
+
* value it picks as `{ current }`. Empty without a document.
|
|
23
|
+
*/
|
|
24
|
+
export const useMeasurementState = stateReader(measurementState);
|
|
25
|
+
/** The measurement settings (`defaultScale`, `presets`), with or without a document. */
|
|
26
|
+
export const useMeasurementSettings = settingsReader(MeasurementToken);
|
|
27
|
+
export function usePageScale(page) {
|
|
28
|
+
const scoped = documentScopeOf();
|
|
29
|
+
// Scales are reference-stable in the plugin, so the value changes only when this page's does.
|
|
30
|
+
return useKernelValue((kernel) => {
|
|
31
|
+
const wanted = valueOf(page);
|
|
32
|
+
if (wanted === null)
|
|
33
|
+
return null;
|
|
34
|
+
return (kernel.tryCapability(MeasurementToken, scoped() ?? undefined)?.getPageScale(wanted) ??
|
|
35
|
+
NO_PAGE_SCALE);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A measurement's `{ kind, value, label }` as `{ current }`, or `{ unavailable }` with why there's
|
|
40
|
+
* none. A measurement that changes is a function: `useMeasurementReadout(() => annotation)`.
|
|
41
|
+
* Readouts are reference-stable in the plugin, so the value changes only when the measurement's
|
|
42
|
+
* does.
|
|
43
|
+
*/
|
|
44
|
+
export function useMeasurementReadout(ref) {
|
|
45
|
+
return useOptionalSelector(MeasurementToken, (measurement) => measurement.getReadout(valueOf(ref)), NO_READOUT);
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/measurement — distances, perimeters and areas in the page's scale.
|
|
3
|
+
*
|
|
4
|
+
* Measuring rides the annotation plugin (the `distance`, `perimeter` and `area` tools draw on its
|
|
5
|
+
* `<AnnotationLayer>`); these readers surface the scale, the calibration and the readouts:
|
|
6
|
+
*
|
|
7
|
+
* const measurement = useMeasurement();
|
|
8
|
+
* const scale = usePageScale(0); // scale.current: the cover's
|
|
9
|
+
* const readout = useMeasurementReadout(() => annotation); // readout.current.label
|
|
10
|
+
*/
|
|
11
|
+
export * from '@embedpdf/plugin-measurement';
|
|
12
|
+
export { useMeasurement, useMeasurementEvent, useMeasurementReadout, useMeasurementSettings, useMeasurementState, usePageScale, } from './measurement/readers.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/measurement — distances, perimeters and areas in the page's scale.
|
|
3
|
+
*
|
|
4
|
+
* Measuring rides the annotation plugin (the `distance`, `perimeter` and `area` tools draw on its
|
|
5
|
+
* `<AnnotationLayer>`); these readers surface the scale, the calibration and the readouts:
|
|
6
|
+
*
|
|
7
|
+
* const measurement = useMeasurement();
|
|
8
|
+
* const scale = usePageScale(0); // scale.current: the cover's
|
|
9
|
+
* const readout = useMeasurementReadout(() => annotation); // readout.current.label
|
|
10
|
+
*/
|
|
11
|
+
// Registration travels with the UI.
|
|
12
|
+
export * from '@embedpdf/plugin-measurement';
|
|
13
|
+
export { useMeasurement, useMeasurementEvent, useMeasurementReadout, useMeasurementSettings, useMeasurementState, usePageScale, } from './measurement/readers.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The metadata's readers: the API, the state declared once in `metadataState`, and its events. */
|
|
2
|
+
import type { EventHook } from '@embedpdf/core';
|
|
3
|
+
import type { MetadataCapability } from '@embedpdf/plugin-metadata';
|
|
4
|
+
/**
|
|
5
|
+
* The metadata API (`update`, `custom.update`, `refresh`, `canUpdate`) of the nearest
|
|
6
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
|
|
7
|
+
* throws `not-ready`. `canUpdate()` is a read, so `disabled={!metadata.canUpdate()}` updates by
|
|
8
|
+
* itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useMetadata(): MetadataCapability;
|
|
11
|
+
/**
|
|
12
|
+
* The standard fields, your own fields and their load state (the page's State table, declared
|
|
13
|
+
* once in `metadataState`), as a reactive object: `state.metadata?.title`. With a selector, the
|
|
14
|
+
* value it picks as `{ current }`, which changes only when that value does.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useMetadataState: import("../index.js").StateReader<{
|
|
17
|
+
metadata: import("@embedpdf/core").DocumentMetadata | null;
|
|
18
|
+
custom: import("@embedpdf/core").CustomMetadata | null;
|
|
19
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
20
|
+
}>;
|
|
21
|
+
/** Subscribe to one metadata event while the component lives: `useMetadataEvent((metadata) => metadata.onUpdated, handler)`. */
|
|
22
|
+
export declare function useMetadataEvent<T>(select: (metadata: MetadataCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MetadataToken, metadataState } from '@embedpdf/plugin-metadata';
|
|
2
|
+
import { useCapability, useCapabilityEvent } from '../runtime/readers.svelte.js';
|
|
3
|
+
import { stateReader } from '../runtime/state.svelte.js';
|
|
4
|
+
/**
|
|
5
|
+
* The metadata API (`update`, `custom.update`, `refresh`, `canUpdate`) of the nearest
|
|
6
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
|
|
7
|
+
* throws `not-ready`. `canUpdate()` is a read, so `disabled={!metadata.canUpdate()}` updates by
|
|
8
|
+
* itself.
|
|
9
|
+
*/
|
|
10
|
+
export function useMetadata() {
|
|
11
|
+
return useCapability(MetadataToken);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The standard fields, your own fields and their load state (the page's State table, declared
|
|
15
|
+
* once in `metadataState`), as a reactive object: `state.metadata?.title`. With a selector, the
|
|
16
|
+
* value it picks as `{ current }`, which changes only when that value does.
|
|
17
|
+
*/
|
|
18
|
+
export const useMetadataState = stateReader(metadataState);
|
|
19
|
+
/** Subscribe to one metadata event while the component lives: `useMetadataEvent((metadata) => metadata.onUpdated, handler)`. */
|
|
20
|
+
export function useMetadataEvent(select, handler) {
|
|
21
|
+
useCapabilityEvent(MetadataToken, select, handler);
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/metadata — the document's properties and your own fields.
|
|
3
|
+
*
|
|
4
|
+
* The plugin keeps the metadata live off the document's event stream, so the state follows your
|
|
5
|
+
* own edits and other sessions':
|
|
6
|
+
*
|
|
7
|
+
* const metadata = useMetadata();
|
|
8
|
+
* const state = useMetadataState(); // state.metadata, state.custom, state.status
|
|
9
|
+
* await metadata.update({ title: 'New title' }); // resolves once the state shows it
|
|
10
|
+
*/
|
|
11
|
+
export * from '@embedpdf/plugin-metadata';
|
|
12
|
+
export { useMetadata, useMetadataEvent, useMetadataState } from './metadata/readers.js';
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/metadata — the document's properties and your own fields.
|
|
3
|
+
*
|
|
4
|
+
* The plugin keeps the metadata live off the document's event stream, so the state follows your
|
|
5
|
+
* own edits and other sessions':
|
|
6
|
+
*
|
|
7
|
+
* const metadata = useMetadata();
|
|
8
|
+
* const state = useMetadataState(); // state.metadata, state.custom, state.status
|
|
9
|
+
* await metadata.update({ title: 'New title' }); // resolves once the state shows it
|
|
10
|
+
*/
|
|
11
|
+
// Registration travels with the UI.
|
|
12
|
+
export * from '@embedpdf/plugin-metadata';
|
|
13
|
+
export { useMetadata, useMetadataEvent, useMetadataState } from './metadata/readers.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The outline's readers: the API, the state declared once in `outlineState`, and its events. */
|
|
2
|
+
import type { EventHook } from '@embedpdf/core';
|
|
3
|
+
import type { OutlineCapability } from '@embedpdf/plugin-outline';
|
|
4
|
+
/**
|
|
5
|
+
* The outline API (expand, select, activate, create, update, move, delete) of the nearest
|
|
6
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
|
|
7
|
+
* throws `not-ready`. `canEdit()` is a read, so `disabled={!outline.canEdit()}` updates by itself.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useOutline(): OutlineCapability;
|
|
10
|
+
/**
|
|
11
|
+
* The outline's items, the rows a tree view shows, the item for where the view is reading, the
|
|
12
|
+
* selection, the load state and whether you may edit it (the page's State table, declared once in
|
|
13
|
+
* `outlineState`), as a reactive object: `state.rows`. With a selector, the value it picks as
|
|
14
|
+
* `{ current }`, which changes only when that value does.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useOutlineState: import("../index.js").StateReader<{
|
|
17
|
+
items: readonly import("@embedpdf/plugin-outline").OutlineItem<import("@embedpdf/core").PageDestination>[];
|
|
18
|
+
rows: readonly import("@embedpdf/plugin-outline").OutlineRow[];
|
|
19
|
+
current: import("@embedpdf/plugin-outline").OutlineItemRef | null;
|
|
20
|
+
selected: readonly import("@embedpdf/plugin-outline").OutlineItemRef[];
|
|
21
|
+
status: import("@embedpdf/core").ResourceStatus;
|
|
22
|
+
incomplete: boolean;
|
|
23
|
+
canEdit: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/** Subscribe to one outline event while the component lives: `useOutlineEvent((outline) => outline.onChanged, handler)`. */
|
|
26
|
+
export declare function useOutlineEvent<T>(select: (outline: OutlineCapability) => EventHook<T>, handler: (event: T) => void): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OutlineToken, outlineState } from '@embedpdf/plugin-outline';
|
|
2
|
+
import { useCapability, useCapabilityEvent } from '../runtime/readers.svelte.js';
|
|
3
|
+
import { stateReader } from '../runtime/state.svelte.js';
|
|
4
|
+
/**
|
|
5
|
+
* The outline API (expand, select, activate, create, update, move, delete) of the nearest
|
|
6
|
+
* `<DocumentScope>`'s document, else the active one. Outside a ready document, every method
|
|
7
|
+
* throws `not-ready`. `canEdit()` is a read, so `disabled={!outline.canEdit()}` updates by itself.
|
|
8
|
+
*/
|
|
9
|
+
export function useOutline() {
|
|
10
|
+
return useCapability(OutlineToken);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The outline's items, the rows a tree view shows, the item for where the view is reading, the
|
|
14
|
+
* selection, the load state and whether you may edit it (the page's State table, declared once in
|
|
15
|
+
* `outlineState`), as a reactive object: `state.rows`. With a selector, the value it picks as
|
|
16
|
+
* `{ current }`, which changes only when that value does.
|
|
17
|
+
*/
|
|
18
|
+
export const useOutlineState = stateReader(outlineState);
|
|
19
|
+
/** Subscribe to one outline event while the component lives: `useOutlineEvent((outline) => outline.onChanged, handler)`. */
|
|
20
|
+
export function useOutlineEvent(select, handler) {
|
|
21
|
+
useCapabilityEvent(OutlineToken, select, handler);
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/outline — the document's outline (its bookmarks).
|
|
3
|
+
*
|
|
4
|
+
* Reading the state reads the outline; the plugin keeps it live off the document's event stream,
|
|
5
|
+
* and shows your own edits at once:
|
|
6
|
+
*
|
|
7
|
+
* const outline = useOutline();
|
|
8
|
+
* const state = useOutlineState(); // state.rows, state.current, state.canEdit
|
|
9
|
+
* outline.activate(row.item.ref); // goes where the item goes, as a click does
|
|
10
|
+
*/
|
|
11
|
+
export * from '@embedpdf/plugin-outline';
|
|
12
|
+
export { useOutline, useOutlineEvent, useOutlineState } from './outline/readers.js';
|
package/dist/outline.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/outline — the document's outline (its bookmarks).
|
|
3
|
+
*
|
|
4
|
+
* Reading the state reads the outline; the plugin keeps it live off the document's event stream,
|
|
5
|
+
* and shows your own edits at once:
|
|
6
|
+
*
|
|
7
|
+
* const outline = useOutline();
|
|
8
|
+
* const state = useOutlineState(); // state.rows, state.current, state.canEdit
|
|
9
|
+
* outline.activate(row.item.ref); // goes where the item goes, as a click does
|
|
10
|
+
*/
|
|
11
|
+
// Registration travels with the UI.
|
|
12
|
+
export * from '@embedpdf/plugin-outline';
|
|
13
|
+
export { useOutline, useOutlineEvent, useOutlineState } from './outline/readers.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PageEditCapability } from '@embedpdf/plugin-page-edit';
|
|
2
|
+
/**
|
|
3
|
+
* The page edits of the nearest `<DocumentScope>`'s document, else the active one. Outside a
|
|
4
|
+
* ready document, every method throws `not-ready`. `canEdit()` and `canExtract()` are reads, so
|
|
5
|
+
* `disabled={!pageEdit.canEdit()}` updates by itself.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePageEdit(): PageEditCapability;
|
|
8
|
+
/**
|
|
9
|
+
* The selected pages and whether you may edit and copy pages (the page's State table, declared
|
|
10
|
+
* once in `pageEditState`), as a reactive object: `state.selected`. With a selector, the value it
|
|
11
|
+
* picks as `{ current }`, which changes only when that value does.
|
|
12
|
+
*/
|
|
13
|
+
export declare const usePageEditState: import("../index.js").StateReader<{
|
|
14
|
+
selected: readonly import("@embedpdf/core").PageRef[];
|
|
15
|
+
canEdit: boolean;
|
|
16
|
+
canExtract: boolean;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The page edits' readers: the API, and the state declared once in `pageEditState`. The pages are the document's. */
|
|
2
|
+
import { PageEditToken, pageEditState } from '@embedpdf/plugin-page-edit';
|
|
3
|
+
import { useCapability } from '../runtime/readers.svelte.js';
|
|
4
|
+
import { stateReader } from '../runtime/state.svelte.js';
|
|
5
|
+
/**
|
|
6
|
+
* The page edits of the nearest `<DocumentScope>`'s document, else the active one. Outside a
|
|
7
|
+
* ready document, every method throws `not-ready`. `canEdit()` and `canExtract()` are reads, so
|
|
8
|
+
* `disabled={!pageEdit.canEdit()}` updates by itself.
|
|
9
|
+
*/
|
|
10
|
+
export function usePageEdit() {
|
|
11
|
+
return useCapability(PageEditToken);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The selected pages and whether you may edit and copy pages (the page's State table, declared
|
|
15
|
+
* once in `pageEditState`), as a reactive object: `state.selected`. With a selector, the value it
|
|
16
|
+
* picks as `{ current }`, which changes only when that value does.
|
|
17
|
+
*/
|
|
18
|
+
export const usePageEditState = stateReader(pageEditState);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/page-edit — rotate, move, insert, delete and extract pages.
|
|
3
|
+
*
|
|
4
|
+
* The plugin turns a page relative to its rotation and resolves positions, so this is binding
|
|
5
|
+
* only. The pages themselves come from `usePageList()` (`@embedpdf/svelte/runtime`), which
|
|
6
|
+
* follows every edit:
|
|
7
|
+
*
|
|
8
|
+
* const pageEdit = usePageEdit();
|
|
9
|
+
* await pageEdit.rotateBy([page.ref], 90);
|
|
10
|
+
*/
|
|
11
|
+
export * from '@embedpdf/plugin-page-edit';
|
|
12
|
+
export { usePageEdit, usePageEditState } from './page-edit/readers.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @embedpdf/svelte/page-edit — rotate, move, insert, delete and extract pages.
|
|
3
|
+
*
|
|
4
|
+
* The plugin turns a page relative to its rotation and resolves positions, so this is binding
|
|
5
|
+
* only. The pages themselves come from `usePageList()` (`@embedpdf/svelte/runtime`), which
|
|
6
|
+
* follows every edit:
|
|
7
|
+
*
|
|
8
|
+
* const pageEdit = usePageEdit();
|
|
9
|
+
* await pageEdit.rotateBy([page.ref], 90);
|
|
10
|
+
*/
|
|
11
|
+
// Registration travels with the UI.
|
|
12
|
+
export * from '@embedpdf/plugin-page-edit';
|
|
13
|
+
export { usePageEdit, usePageEditState } from './page-edit/readers.js';
|