@inkbar/svelte 0.3.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 +17 -12
- package/dist/components/InkAnnotation.svelte +0 -12
- package/dist/components/InkAnnotation.svelte.d.ts.map +1 -1
- package/dist/components/InkColorMenu.svelte +247 -0
- package/dist/components/InkColorMenu.svelte.d.ts +35 -0
- package/dist/components/InkColorMenu.svelte.d.ts.map +1 -0
- package/dist/components/InkHighlightMenu.svelte +175 -0
- package/dist/components/InkHighlightMenu.svelte.d.ts +16 -0
- package/dist/components/InkHighlightMenu.svelte.d.ts.map +1 -0
- package/dist/components/InkLineStyleMenu.svelte +141 -0
- package/dist/components/InkLineStyleMenu.svelte.d.ts +15 -0
- package/dist/components/InkLineStyleMenu.svelte.d.ts.map +1 -0
- package/dist/components/InkRoot.svelte +90 -3
- package/dist/components/InkRoot.svelte.d.ts +27 -2
- package/dist/components/InkRoot.svelte.d.ts.map +1 -1
- package/dist/components/InkShapeMenu.svelte +161 -0
- package/dist/components/InkShapeMenu.svelte.d.ts +15 -0
- package/dist/components/InkShapeMenu.svelte.d.ts.map +1 -0
- package/dist/components/InkSignatureDialog.svelte +70 -0
- package/dist/components/InkSignatureDialog.svelte.d.ts +22 -0
- package/dist/components/InkSignatureDialog.svelte.d.ts.map +1 -0
- package/dist/components/InkSignatureMenu.svelte +267 -0
- package/dist/components/InkSignatureMenu.svelte.d.ts +18 -0
- package/dist/components/InkSignatureMenu.svelte.d.ts.map +1 -0
- package/dist/components/InkTextStyleMenu.svelte +225 -0
- package/dist/components/InkTextStyleMenu.svelte.d.ts +15 -0
- package/dist/components/InkTextStyleMenu.svelte.d.ts.map +1 -0
- package/dist/components/{InkNotePopover.svelte → InkThreadPopover.svelte} +44 -32
- package/dist/components/InkThreadPopover.svelte.d.ts +9 -0
- package/dist/components/InkThreadPopover.svelte.d.ts.map +1 -0
- package/dist/components/InkToolButton.svelte +23 -7
- package/dist/components/InkToolButton.svelte.d.ts.map +1 -1
- package/dist/components/InkViewport.svelte +26 -2
- package/dist/components/InkViewport.svelte.d.ts.map +1 -1
- package/dist/components/SignatureForm.svelte +219 -0
- package/dist/components/SignatureForm.svelte.d.ts +10 -0
- package/dist/components/SignatureForm.svelte.d.ts.map +1 -0
- package/dist/components/ThreadForm.svelte +4 -2
- package/dist/components/ThreadForm.svelte.d.ts +1 -0
- package/dist/components/ThreadForm.svelte.d.ts.map +1 -1
- package/dist/components/child-snippet.d.ts +8 -0
- package/dist/components/child-snippet.d.ts.map +1 -1
- package/dist/components/child-snippet.js +15 -0
- 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 +21 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/hooks/useAnnotations.svelte.d.ts +1333 -578
- package/dist/hooks/useAnnotations.svelte.d.ts.map +1 -1
- package/dist/hooks/useAnnotations.svelte.js +1 -7
- package/dist/hooks/useToolOptions.svelte.d.ts +11 -0
- package/dist/hooks/useToolOptions.svelte.d.ts.map +1 -0
- package/dist/hooks/useToolOptions.svelte.js +19 -0
- package/dist/hooks/useToolStyle.svelte.d.ts +33 -0
- package/dist/hooks/useToolStyle.svelte.d.ts.map +1 -0
- package/dist/hooks/useToolStyle.svelte.js +33 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/package.json +5 -5
- package/dist/components/InkNotePopover.svelte.d.ts +0 -9
- package/dist/components/InkNotePopover.svelte.d.ts.map +0 -1
- 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":"popover-focus.d.ts","sourceRoot":"","sources":["../../src/lib/components/popover-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"popover-focus.d.ts","sourceRoot":"","sources":["../../src/lib/components/popover-focus.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAA;AAKzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/C,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;IACzC,mGAAmG;IACnG,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IACvC;;;;;;;;OAQG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;IAChF,6CAA6C;IAC7C,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,4FAA4F;IAC5F,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAA;CACrE;AAED,8GAA8G;AAC9G,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAE9D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CAiDlE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createFocusReturn, shouldKeepOpenOnAnnotation, } from '@inkbar/core/dom';
|
|
2
|
+
import { flushSync } from 'svelte';
|
|
2
3
|
import { peekActivated } from '../context.js';
|
|
3
4
|
/** Bits UI's `onInteractOutside` handler: a press that will activate an annotation keeps the popover open. */
|
|
4
5
|
export function keepOpenOnAnnotation(event) {
|
|
@@ -16,8 +17,10 @@ export function keepOpenOnAnnotation(event) {
|
|
|
16
17
|
* close reaches the planner one microtask late, and only when no open was reported after it.
|
|
17
18
|
*
|
|
18
19
|
* This relies on Bits UI reporting a remount as a close and then an open within one synchronous
|
|
19
|
-
* call (observed in bits-ui 2.19.5, `FocusScope.mount`).
|
|
20
|
-
*
|
|
20
|
+
* call (observed in bits-ui 2.19.5, `FocusScope.mount`). The unit case 'a close followed by an
|
|
21
|
+
* open in the same tick moves no focus and uses up the removal plan' pins the planner's side, and
|
|
22
|
+
* the browser case 'a popover opened without passing focus through the annotation takes focus'
|
|
23
|
+
* checks that an open moves focus straight into the popover.
|
|
21
24
|
*
|
|
22
25
|
* A close that is superseded this way moves no focus, but it still uses up whatever
|
|
23
26
|
* `beforeRemove` planned for it, so the plan cannot leak into a later close. A close that is
|
|
@@ -35,7 +38,25 @@ export function useFocusReturn(ctx) {
|
|
|
35
38
|
/** Open and close reports so far, so a deferred close can tell what followed it. */
|
|
36
39
|
let opens = 0;
|
|
37
40
|
let closes = 0;
|
|
41
|
+
/** A press closed the popover, and the planner answers that close without moving focus. */
|
|
42
|
+
let pressed = false;
|
|
38
43
|
return {
|
|
44
|
+
onPressOutside(event, inside, close) {
|
|
45
|
+
const target = event.target;
|
|
46
|
+
if (event.button !== 0 || !(target instanceof Element))
|
|
47
|
+
return;
|
|
48
|
+
if (target.closest(inside) || shouldKeepOpenOnAnnotation(target))
|
|
49
|
+
return;
|
|
50
|
+
const scroll = target.closest('[data-ink-scroll]');
|
|
51
|
+
if (!scroll || !ctx.rootEl?.contains(scroll))
|
|
52
|
+
return;
|
|
53
|
+
pressed = true;
|
|
54
|
+
close();
|
|
55
|
+
flushSync();
|
|
56
|
+
},
|
|
57
|
+
onPressEnd() {
|
|
58
|
+
pressed = false;
|
|
59
|
+
},
|
|
39
60
|
beforeRemove: (anchor, prefer) => planner.beforeRemove(anchor, prefer),
|
|
40
61
|
onOpenAutoFocus() {
|
|
41
62
|
opens += 1;
|
|
@@ -50,7 +71,7 @@ export function useFocusReturn(ctx) {
|
|
|
50
71
|
if (close !== closes)
|
|
51
72
|
return;
|
|
52
73
|
// An open followed: the popover is open, so only the plan is cleared.
|
|
53
|
-
discarding = opens !== opensBefore;
|
|
74
|
+
discarding = opens !== opensBefore || pressed;
|
|
54
75
|
try {
|
|
55
76
|
planner.onCloseAutoFocus(event, anchor);
|
|
56
77
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Annotation, InkDocument, InkStatus, PdfAssets } from '@inkbar/core';
|
|
2
|
-
import type { ToolController, ToolId, Viewport, ZoomValue } from '@inkbar/core/dom';
|
|
1
|
+
import type { Annotation, InkDocument, InkStatus, PdfAssets, SignatureLibrary } from '@inkbar/core';
|
|
2
|
+
import type { DecorateAnnotation, Tool, ToolController, ToolId, ToolOptions, ToolStyle, Viewport, ZoomValue } from '@inkbar/core/dom';
|
|
3
3
|
export type { InkStatus };
|
|
4
4
|
/** Undo and redo for the current document, whichever mode its annotations are in. */
|
|
5
5
|
export interface InkHistory {
|
|
@@ -33,6 +33,20 @@ export interface InkContext {
|
|
|
33
33
|
/** Desired tool; InkViewport applies it to the controller. */
|
|
34
34
|
readonly tool: ToolId;
|
|
35
35
|
setTool(id: ToolId): void;
|
|
36
|
+
/** Host tools from InkRoot's `tools` prop; InkViewport registers them. */
|
|
37
|
+
readonly hostTools: Tool[] | undefined;
|
|
38
|
+
/** InkRoot's `decorateAnnotation` prop. InkViewport re-applies decorations when it changes. */
|
|
39
|
+
readonly decorateAnnotation: DecorateAnnotation | undefined;
|
|
40
|
+
/** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */
|
|
41
|
+
readonly fonts: readonly string[];
|
|
42
|
+
/** The tools' options for InkRoot's life, so they persist across documents. */
|
|
43
|
+
readonly toolOptions: ToolOptions;
|
|
44
|
+
/** The saved signatures, from InkRoot's `signatures` store (memory by default). */
|
|
45
|
+
readonly signatures: SignatureLibrary;
|
|
46
|
+
/** The fonts a typed signature offers: InkRoot's `signatureFonts`, else `SIGNATURE_FONTS`. */
|
|
47
|
+
readonly signatureFonts: readonly string[];
|
|
48
|
+
/** The open document's tool style; `null` while no document is open. */
|
|
49
|
+
readonly toolStyle: ToolStyle | null;
|
|
36
50
|
/** Desired zoom and page from the host's props; InkViewport applies and reports back. */
|
|
37
51
|
readonly zoomModel: ZoomValue | undefined;
|
|
38
52
|
readonly pageModel: number | undefined;
|
|
@@ -40,6 +54,11 @@ export interface InkContext {
|
|
|
40
54
|
reportPage(p: number): void;
|
|
41
55
|
/** Last activated annotation (Enter, click with the note tool, etc.). Popovers key off this. */
|
|
42
56
|
readonly activated: string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Activates annotation `id`, or clears the activation with `null`. This is the context's
|
|
59
|
+
* own: unlike core's `Viewer.setActivated`, it calls InkRoot's `onActivate` for an id, and
|
|
60
|
+
* it does not check that the id is in the document.
|
|
61
|
+
*/
|
|
43
62
|
setActivated(id: string | null): void;
|
|
44
63
|
readonly history: InkHistory;
|
|
45
64
|
readonly rootEl: HTMLElement | null;
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/lib/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/lib/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EACjB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,kBAAkB,EAClB,IAAI,EACJ,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IAC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