@inkbar/svelte 0.4.0 → 0.5.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 +3 -5
- package/dist/components/InkAnnotation.svelte +0 -12
- package/dist/components/InkAnnotation.svelte.d.ts.map +1 -1
- package/dist/components/InkColorMenu.svelte +6 -1
- package/dist/components/InkColorMenu.svelte.d.ts +2 -0
- package/dist/components/InkColorMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkHighlightMenu.svelte +9 -0
- package/dist/components/InkHighlightMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkRoot.svelte +14 -1
- package/dist/components/InkRoot.svelte.d.ts +8 -1
- package/dist/components/InkRoot.svelte.d.ts.map +1 -1
- package/dist/components/InkShapeMenu.svelte +4 -0
- package/dist/components/InkShapeMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkSignatureMenu.svelte +4 -0
- package/dist/components/InkSignatureMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkThreadPopover.svelte +7 -0
- package/dist/components/InkThreadPopover.svelte.d.ts.map +1 -1
- package/dist/components/InkViewport.svelte +19 -2
- package/dist/components/InkViewport.svelte.d.ts.map +1 -1
- package/dist/components/popover-focus.d.ts +16 -2
- package/dist/components/popover-focus.d.ts.map +1 -1
- package/dist/components/popover-focus.js +24 -3
- package/dist/context.d.ts +8 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks/useAnnotations.svelte.d.ts +795 -1258
- package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -1
- package/dist/hooks/useAnnotations.svelte.js +1 -7
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/package.json +5 -5
- package/dist/components/InkSuggestionCard.svelte +0 -121
- package/dist/components/InkSuggestionCard.svelte.d.ts +0 -9
- package/dist/components/InkSuggestionCard.svelte.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnnotations.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useAnnotations.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEhF,wBAAgB,cAAc
|
|
1
|
+
{"version":3,"file":"useAnnotations.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/hooks/useAnnotations.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEhF,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBACf,MAAM,SAAS,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAC9B,MAAM;kBACL,MAAM,EAAE;EAEzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { repliesTo } from '@inkbar/core';
|
|
2
2
|
import { useInkContext } from '../context.js';
|
|
3
3
|
export function useAnnotations() {
|
|
4
4
|
const ctx = useInkContext('useAnnotations()');
|
|
@@ -23,11 +23,5 @@ export function useAnnotations() {
|
|
|
23
23
|
update: (id, patch) => store()?.update(id, patch),
|
|
24
24
|
remove: (id) => store()?.remove(id) ?? false,
|
|
25
25
|
select: (ids) => store()?.select(ids),
|
|
26
|
-
/** Keeps a suggested redaction as the user's own, in the default redaction colour. */
|
|
27
|
-
accept: (id) => {
|
|
28
|
-
const s = store();
|
|
29
|
-
return s ? acceptSuggestion(s, id) : undefined;
|
|
30
|
-
},
|
|
31
|
-
dismiss: (id) => store()?.remove(id) ?? false,
|
|
32
26
|
};
|
|
33
27
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { useInkContext } from './context.js';
|
|
|
3
3
|
export type { InkContext, InkHistory, InkStatus } from './context.js';
|
|
4
4
|
export { useReadable } from './use-readable.svelte.js';
|
|
5
5
|
export type { ReadableRef } from './use-readable.svelte.js';
|
|
6
|
-
export type { AnnotationSlotProps, AnnotationState, ThreadPopoverSlotProps,
|
|
7
|
-
export type {
|
|
6
|
+
export type { AnnotationSlotProps, AnnotationState, ThreadPopoverSlotProps, } from '@inkbar/core/dom';
|
|
7
|
+
export type { AnnotationDecoration, DecorateAnnotation } from '@inkbar/core/dom';
|
|
8
8
|
export { useDocument } from './hooks/useDocument.svelte.js';
|
|
9
9
|
export { useAnnotations } from './hooks/useAnnotations.svelte.js';
|
|
10
10
|
export { useTool } from './hooks/useTool.svelte.js';
|
|
@@ -65,6 +65,4 @@ export type { InkPageButtonProps } from './components/page-button.js';
|
|
|
65
65
|
export type { ChildSnippet } from './components/child-snippet.js';
|
|
66
66
|
export { default as InkThreadPopover } from './components/InkThreadPopover.svelte';
|
|
67
67
|
export type { InkThreadPopoverProps } from './components/InkThreadPopover.svelte';
|
|
68
|
-
export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
|
|
69
|
-
export type { InkSuggestionCardProps } from './components/InkSuggestionCard.svelte';
|
|
70
68
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB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IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC1E,YAAY,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iCAAiC,CAAA;AACxE,YAAY,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACrE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAClF,YAAY,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -35,4 +35,3 @@ export { default as InkPageCount } from './components/InkPageCount.svelte';
|
|
|
35
35
|
export { default as InkPrevPage } from './components/InkPrevPage.svelte';
|
|
36
36
|
export { default as InkNextPage } from './components/InkNextPage.svelte';
|
|
37
37
|
export { default as InkThreadPopover } from './components/InkThreadPopover.svelte';
|
|
38
|
-
export { default as InkSuggestionCard } from './components/InkSuggestionCard.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkbar/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Svelte 5 components and hooks for Inkbar, the browser PDF viewer and editor.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://inkbar.dev",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inkbar/icons": "^0.
|
|
29
|
+
"@inkbar/icons": "^0.5.0",
|
|
30
30
|
"@internationalized/date": "^3.12.4",
|
|
31
31
|
"bits-ui": "^2.19.5",
|
|
32
32
|
"esm-env": "^1.2.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@inkbar/core": "^0.
|
|
35
|
+
"@inkbar/core": "^0.5.0",
|
|
36
36
|
"svelte": "^5.46.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@inkbar/core": "0.
|
|
39
|
+
"@inkbar/core": "0.5.0",
|
|
40
40
|
"@inkbar/fixtures": "0.0.0",
|
|
41
|
-
"@inkbar/theme": "0.
|
|
41
|
+
"@inkbar/theme": "0.5.0",
|
|
42
42
|
"@sveltejs/package": "^3.0.0",
|
|
43
43
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
|
44
44
|
"@vitest/browser-playwright": "^5.0.4",
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import type { SuggestionCardSlotProps } from '@inkbar/core/dom'
|
|
3
|
-
import type { Snippet } from 'svelte'
|
|
4
|
-
|
|
5
|
-
export interface InkSuggestionCardProps {
|
|
6
|
-
children?: Snippet<[SuggestionCardSlotProps]> | undefined
|
|
7
|
-
}
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<script lang="ts">
|
|
11
|
-
/*
|
|
12
|
-
* Review card for a suggested redaction: opens when the activated annotation, or the only
|
|
13
|
-
* selected one, is a redaction with `origin: 'suggested'`. Locked suggestions cannot be
|
|
14
|
-
* dismissed, so they get no Dismiss button. A press on the overlay selects and activates, so a
|
|
15
|
-
* click opens it whatever the tool. Closing clears `activated` and the selection.
|
|
16
|
-
*/
|
|
17
|
-
import { confidenceBucket } from '@inkbar/core'
|
|
18
|
-
import { Popover } from 'bits-ui'
|
|
19
|
-
|
|
20
|
-
import { useInkContext } from '../context.js'
|
|
21
|
-
import { useAnnotations } from '../hooks/useAnnotations.svelte.js'
|
|
22
|
-
|
|
23
|
-
import { useAnnotationElement } from './annotation-element.svelte.js'
|
|
24
|
-
import { keepOpenOnAnnotation, useFocusReturn } from './popover-focus.js'
|
|
25
|
-
|
|
26
|
-
import type { ConfidenceBucket, RedactAnnotation } from '@inkbar/core'
|
|
27
|
-
|
|
28
|
-
let { children }: InkSuggestionCardProps = $props()
|
|
29
|
-
|
|
30
|
-
const ctx = useInkContext('InkSuggestionCard')
|
|
31
|
-
const store = useAnnotations()
|
|
32
|
-
|
|
33
|
-
function suggestion(id: string | null | undefined): RedactAnnotation | null {
|
|
34
|
-
const a = id ? store.annotations.find((x) => x.id === id) : undefined
|
|
35
|
-
return a?.type === 'redact' && a.origin === 'suggested' ? a : null
|
|
36
|
-
}
|
|
37
|
-
// The activated annotation when it is a suggestion; otherwise the only selected one (a
|
|
38
|
-
// marquee selects without activating).
|
|
39
|
-
const target = $derived(
|
|
40
|
-
suggestion(ctx.activated) ??
|
|
41
|
-
(store.selection.length === 1 ? suggestion(store.selection[0]) : null)
|
|
42
|
-
)
|
|
43
|
-
const anchorRef = useAnnotationElement(
|
|
44
|
-
() => ctx.rootEl,
|
|
45
|
-
() => target?.id ?? null
|
|
46
|
-
)
|
|
47
|
-
const anchor = $derived(anchorRef.current)
|
|
48
|
-
const focusReturn = useFocusReturn(ctx)
|
|
49
|
-
const open = $derived(target !== null && anchor !== null)
|
|
50
|
-
const bucket = $derived<ConfidenceBucket | undefined>(
|
|
51
|
-
target?.suggestion ? confidenceBucket(target.suggestion.confidence) : undefined
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
function close(): void {
|
|
55
|
-
ctx.setActivated(null)
|
|
56
|
-
store.select([])
|
|
57
|
-
}
|
|
58
|
-
function accept(): void {
|
|
59
|
-
if (target) store.accept(target.id)
|
|
60
|
-
close()
|
|
61
|
-
}
|
|
62
|
-
/** Locked annotations cannot be removed: dismissing one does nothing and keeps the card. */
|
|
63
|
-
function dismiss(): void {
|
|
64
|
-
if (!target || target.locked) return
|
|
65
|
-
focusReturn.beforeRemove(anchor, '[data-origin="suggested"]')
|
|
66
|
-
store.dismiss(target.id)
|
|
67
|
-
close()
|
|
68
|
-
}
|
|
69
|
-
function onOpenChange(next: boolean): void {
|
|
70
|
-
if (!next) close()
|
|
71
|
-
}
|
|
72
|
-
</script>
|
|
73
|
-
|
|
74
|
-
<Popover.Root bind:open={() => open, onOpenChange}>
|
|
75
|
-
<Popover.Portal>
|
|
76
|
-
{#if target && anchor}
|
|
77
|
-
<Popover.Content
|
|
78
|
-
class="ink-suggestion-card"
|
|
79
|
-
data-ink-suggestion-card=""
|
|
80
|
-
role="dialog"
|
|
81
|
-
side="bottom"
|
|
82
|
-
sideOffset={6}
|
|
83
|
-
collisionPadding={8}
|
|
84
|
-
aria-label="Suggested redaction"
|
|
85
|
-
customAnchor={anchor}
|
|
86
|
-
onInteractOutside={keepOpenOnAnnotation}
|
|
87
|
-
onOpenAutoFocus={focusReturn.onOpenAutoFocus}
|
|
88
|
-
onCloseAutoFocus={(e) => focusReturn.onCloseAutoFocus(e, anchor)}
|
|
89
|
-
>
|
|
90
|
-
{#if children}
|
|
91
|
-
{@render children({
|
|
92
|
-
annotation: target,
|
|
93
|
-
suggestion: target.suggestion,
|
|
94
|
-
bucket,
|
|
95
|
-
accept,
|
|
96
|
-
dismiss,
|
|
97
|
-
close,
|
|
98
|
-
})}
|
|
99
|
-
{:else}
|
|
100
|
-
<p class="ink-suggestion-reason">
|
|
101
|
-
<strong>{target.suggestion?.reason ?? 'Suggested redaction'}</strong>
|
|
102
|
-
{#if bucket}
|
|
103
|
-
<span class="ink-suggestion-confidence" data-confidence={bucket}>
|
|
104
|
-
{bucket} confidence
|
|
105
|
-
</span>
|
|
106
|
-
{/if}
|
|
107
|
-
</p>
|
|
108
|
-
{#if target.suggestion?.explanation}
|
|
109
|
-
<p class="ink-suggestion-explanation">{target.suggestion.explanation}</p>
|
|
110
|
-
{/if}
|
|
111
|
-
<div class="ink-suggestion-actions">
|
|
112
|
-
<button type="button" onclick={accept}>Accept</button>
|
|
113
|
-
{#if !target.locked}
|
|
114
|
-
<button type="button" onclick={dismiss}>Dismiss</button>
|
|
115
|
-
{/if}
|
|
116
|
-
</div>
|
|
117
|
-
{/if}
|
|
118
|
-
</Popover.Content>
|
|
119
|
-
{/if}
|
|
120
|
-
</Popover.Portal>
|
|
121
|
-
</Popover.Root>
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SuggestionCardSlotProps } from '@inkbar/core/dom';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
export interface InkSuggestionCardProps {
|
|
4
|
-
children?: Snippet<[SuggestionCardSlotProps]> | undefined;
|
|
5
|
-
}
|
|
6
|
-
declare const InkSuggestionCard: import("svelte").Component<InkSuggestionCardProps, {}, "">;
|
|
7
|
-
type InkSuggestionCard = ReturnType<typeof InkSuggestionCard>;
|
|
8
|
-
export default InkSuggestionCard;
|
|
9
|
-
//# sourceMappingURL=InkSuggestionCard.svelte.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InkSuggestionCard.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/InkSuggestionCard.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,uBAAuB,CAAC,CAAC,GAAG,SAAS,CAAA;CAC1D;AAwHH,QAAA,MAAM,iBAAiB,4DAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
|