@inkbar/svelte 0.4.0 → 0.6.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 +23 -7
- package/dist/components/InkAnnotation.svelte +0 -12
- package/dist/components/InkAnnotation.svelte.d.ts.map +1 -1
- package/dist/components/InkColorMenu.svelte +13 -19
- package/dist/components/InkColorMenu.svelte.d.ts +2 -0
- package/dist/components/InkColorMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkCommand.svelte +63 -0
- package/dist/components/InkCommand.svelte.d.ts +17 -0
- package/dist/components/InkCommand.svelte.d.ts.map +1 -0
- package/dist/components/InkHighlightMenu.svelte +15 -13
- package/dist/components/InkLineStyleMenu.svelte +7 -17
- package/dist/components/InkLineStyleMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkRoot.svelte +111 -3
- package/dist/components/InkRoot.svelte.d.ts +14 -1
- package/dist/components/InkRoot.svelte.d.ts.map +1 -1
- package/dist/components/InkShapeMenu.svelte +10 -13
- package/dist/components/InkShapeMenu.svelte.d.ts.map +1 -1
- package/dist/components/InkSignatureMenu.svelte +10 -13
- 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/InkToolButton.svelte +11 -3
- package/dist/components/InkToolButton.svelte.d.ts.map +1 -1
- package/dist/components/InkViewport.svelte +32 -2
- package/dist/components/InkViewport.svelte.d.ts.map +1 -1
- package/dist/components/menu-open-focus.d.ts +12 -0
- package/dist/components/menu-open-focus.d.ts.map +1 -0
- package/dist/components/menu-open-focus.js +35 -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 +22 -4
- 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/hooks/useCommand.svelte.d.ts +23 -0
- package/dist/hooks/useCommand.svelte.d.ts.map +1 -0
- package/dist/hooks/useCommand.svelte.js +44 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -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,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,8 +1,11 @@
|
|
|
1
|
-
import type { Annotation, InkDocument, InkStatus, PdfAssets, SignatureLibrary } from '@inkbar/core';
|
|
2
|
-
import type { Tool, ToolController, ToolId, ToolOptions, ToolStyle, Viewport, ZoomValue } from '@inkbar/core/dom';
|
|
1
|
+
import type { Annotation, InkDocument, InkStatus, PdfAssets, PluginHistory, SignatureLibrary, Writable } from '@inkbar/core';
|
|
2
|
+
import type { DecorateAnnotation, PluginHost, Tool, ToolController, ToolId, ToolOptions, ToolStyle, Viewport, ZoomValue } from '@inkbar/core/dom';
|
|
3
3
|
export type { InkStatus };
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Undo and redo for the current document, whichever mode its annotations are in. `track` and
|
|
6
|
+
* `react` (from `PluginHistory`) reach the same history, so plugin stores undo with the edits.
|
|
7
|
+
*/
|
|
8
|
+
export interface InkHistory extends PluginHistory {
|
|
6
9
|
readonly canUndo: boolean;
|
|
7
10
|
readonly canRedo: boolean;
|
|
8
11
|
undo(): void;
|
|
@@ -27,6 +30,14 @@ export interface InkContext {
|
|
|
27
30
|
readonly status: InkStatus;
|
|
28
31
|
readonly annotations: readonly Annotation[];
|
|
29
32
|
readonly selection: readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* The plugins from InkRoot's `plugins` prop, set up once the root has mounted and kept for
|
|
35
|
+
* its life; `null` before that, and on the server. InkViewport hands it to the engine;
|
|
36
|
+
* InkCommand places its commands.
|
|
37
|
+
*/
|
|
38
|
+
readonly pluginHost: PluginHost | null;
|
|
39
|
+
/** InkViewport's scroll element while it is mounted: the plugins' `root`. */
|
|
40
|
+
readonly viewportEl: Writable<HTMLElement | null>;
|
|
30
41
|
/** Set by InkViewport once it has built its viewport and tool controller. */
|
|
31
42
|
readonly viewport: Viewport | null;
|
|
32
43
|
readonly tools: ToolController | null;
|
|
@@ -35,6 +46,8 @@ export interface InkContext {
|
|
|
35
46
|
setTool(id: ToolId): void;
|
|
36
47
|
/** Host tools from InkRoot's `tools` prop; InkViewport registers them. */
|
|
37
48
|
readonly hostTools: Tool[] | undefined;
|
|
49
|
+
/** InkRoot's `decorateAnnotation` prop. InkViewport re-applies decorations when it changes. */
|
|
50
|
+
readonly decorateAnnotation: DecorateAnnotation | undefined;
|
|
38
51
|
/** The font families text boxes offer: InkRoot's `fonts`, else `FONT_FAMILIES`. */
|
|
39
52
|
readonly fonts: readonly string[];
|
|
40
53
|
/** The tools' options for InkRoot's life, so they persist across documents. */
|
|
@@ -52,6 +65,11 @@ export interface InkContext {
|
|
|
52
65
|
reportPage(p: number): void;
|
|
53
66
|
/** Last activated annotation (Enter, click with the note tool, etc.). Popovers key off this. */
|
|
54
67
|
readonly activated: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Activates annotation `id`, or clears the activation with `null`. This is the context's
|
|
70
|
+
* own: unlike core's `Viewer.setActivated`, it calls InkRoot's `onActivate` for an id, and
|
|
71
|
+
* it does not check that the id is in the document.
|
|
72
|
+
*/
|
|
55
73
|
setActivated(id: string | null): void;
|
|
56
74
|
readonly history: InkHistory;
|
|
57
75
|
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,EACV,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,
|
|
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,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACT,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EACV,IAAI,EACJ,cAAc,EACd,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EAAE,SAAS,EAAE,CAAA;AAEzB;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,IAAI,IAAI,IAAI,CAAA;IACZ,IAAI,IAAI,IAAI,CAAA;IACZ,KAAK,IAAI,IAAI,CAAA;IACb;;;;;OAKG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;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