@inkbar/react 0.1.1 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["AnnotationSlotProps","AnnotationSlotProps","AnnotationSlotProps","NotePopoverSlotProps","SuggestionCardSlotProps"],"sources":["../src/context.ts","../src/use-readable.ts","../src/hooks/useDocument.ts","../src/hooks/useAnnotations.ts","../src/hooks/useTool.ts","../src/hooks/useSelection.ts","../src/hooks/useZoom.ts","../src/hooks/usePage.ts","../src/hooks/useHistory.ts","../src/hooks/useEmbedded.ts","../src/components/InkRoot.tsx","../src/components/InkViewport.tsx","../src/components/InkPage.tsx","../src/components/InkAnnotation.tsx","../src/components/InkToolbar.tsx","../src/components/InkToolButton.tsx","../src/components/zoom-button.ts","../src/components/InkZoomIn.tsx","../src/components/InkZoomOut.tsx","../src/components/InkZoomSelect.tsx","../src/components/InkPageInput.tsx","../src/components/InkPageCount.tsx","../src/compositions/DefaultToolbar.tsx","../src/components/InkNotePopover.tsx","../src/components/InkSuggestionCard.tsx"],"mappings":";;;;;UAQiB;EACf;EACA;EACA;EACA;EACA;;;;;;;EAOA,QAAQ;;UAGO;EACf,QAAQ;EACR,UAAU;;EAEV,QAAQ;EACR,sBAAsB;EACtB;;EAEA,UAAU;EACV,OAAO;;EAEP,MAAM;EACN,UAAU,IAAI;;EAEd,WAAW;EACX;EACA,aAAa,GAAG;EAChB,aAAa;;EAEb;EACA,eAAe;EACf,SAAS;EACT,QAAQ;EACR,cAAc,UAAU,iBAAiB,OAAO;;;;;;wBASlC,cAAc,mBAAmB;;;;;;;;wBC5CjC,YAAY,GAAG,UAAU,SAAS,uBAAuB,UAAU,IAAI;;;wBCHvE;;;;;;;;EAYgB,oBAAA,MAAA,6BAA2B,OAAS,yCAAa;;;;wBCbjE;EAcG,MAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B;wBAIc,gBAAgB,cAAc,QAAQ,qCAAkB,IAAA;;;KCF5D,oBAAoB,KAC9B;wBAIc,eACd,WACA,WAAW,kBACR,QACF,oCAAiB,IAAA;;;wBCjBJ,eAAe,cAAc,QAAQ,mDAAgC,IAAA;;;UCoBpE;EACf;EACA;EACA,WAAW;;wBAKG,iBACd,OACA,WACA,YACC,sCAAmB,IAAA;;;UCNL;EACf,aAAa,OAAOC,2BAAyB;;wBAG/B,iBAAiB,YAAY,sCAAmB,IAAA;;;UChB/C;EACf,aAAa,OAAOC,8BAA4B;;wBAGlC,oBAAoB,YAAY,yCAAsB,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":["AnnotationSlotProps","AnnotationSlotProps","AnnotationSlotProps","NotePopoverSlotProps","SuggestionCardSlotProps"],"sources":["../src/context.ts","../src/use-readable.ts","../src/hooks/useDocument.ts","../src/hooks/useAnnotations.ts","../src/hooks/useTool.ts","../src/hooks/useSelection.ts","../src/hooks/useZoom.ts","../src/hooks/usePage.ts","../src/hooks/useHistory.ts","../src/hooks/useEmbedded.ts","../src/components/InkRoot.tsx","../src/components/InkViewport.tsx","../src/components/InkPage.tsx","../src/components/InkAnnotation.tsx","../src/components/InkToolbar.tsx","../src/components/InkIcon.tsx","../src/components/InkToolButton.tsx","../src/components/InkToolbarSeparator.tsx","../src/components/history-button.ts","../src/components/InkUndo.tsx","../src/components/InkRedo.tsx","../src/components/zoom-button.ts","../src/components/InkZoomIn.tsx","../src/components/InkZoomOut.tsx","../src/components/InkZoomSelect.tsx","../src/components/InkPageInput.tsx","../src/components/InkPageCount.tsx","../src/components/page-button.ts","../src/components/InkPrevPage.tsx","../src/components/InkNextPage.tsx","../src/components/InkNotePopover.tsx","../src/components/InkSuggestionCard.tsx"],"mappings":";;;;;;;UAQiB;EACf;EACA;EACA;EACA;EACA;;;;;;;EAOA,QAAQ;;UAGO;EACf,QAAQ;EACR,UAAU;;EAEV,QAAQ;EACR,sBAAsB;EACtB;;EAEA,UAAU;EAC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nBlE,wBAAwB,KAAK;;EAE5C;EACA;EACA;;wBAGc,aACd,OACA,SACA,WACA,aACG,QACF,kCAAe,IAAA;;;UCVD;EACf,MAAM;EACN;;wBAWc,UAAU,MAAM,QAAa,+BAAY,IAAA;;;UCFxC,2BAA2B,KAC1C;EAGA,MAAM;EACN;EACA;EACA,WAAW,cAAc;IAAS;IAAiB;QAAoB;;wBAGzD,gBACd,MACA,OACA,SACA,WACA,UACA,YACG,QACF,qCAAkB,IAAA;;;KClCT,2BAA2B;;;;;wBAMvB,sBAAsB,cAAc,QAAQ,2CAAwB,IAAA;;;;UCPnE,8BAA8B;EAC7C;;;;wBCMc,UACd,SACA,WACA,UACA,UACA,YACG,QACF,wCAAqB,IAAA;;;wBCPR,UACd,SACA,WACA,UACA,UACA,YACG,QACF,wCAAqB,IAAA;;;;UCdP,2BAA2B;EAC1C;;;;wBCMc,YACd,SACA,WACA,UACA,YACG,QACF,qCAAkB,IAAA;;;wBCNL,aACd,SACA,WACA,UACA,YACG,QACF,qCAAkB,IAAA;;;;KCKT,qBAAqB,KAC/B,gCAAgC,OAAO;wBAezB,gBAAgB,cAAc,QAAQ,qCAAkB,IAAA;;;KCxB5D,oBAAoB,KAC9B;wBAIc,eACd,WACA,WAAW,kBACR,QACF,oCAAiB,IAAA;;;wBCjBJ,eAAe,cAAc,QAAQ,mDAAgC,IAAA;;;;UCFpE,2BAA2B;EAC1C;;;;wBCMc,cACd,SACA,WACA,UACA,UACA,YACG,QACF,qCAAkB,IAAA;;;wBCPL,cACd,SACA,WACA,UACA,UACA,YACG,QACF,qCAAkB,IAAA;;;UCcJ;EACf,aAAa,OAAOC,2BAAyB;;wBAG/B,iBAAiB,YAAY,sCAAmB,IAAA;;;UChB/C;EACf,aAAa,OAAOC,8BAA4B;;wBAGlC,oBAAoB,YAAY,yCAAsB,IAAA"}
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client";
2
- import { createContext, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
+ import { createContext, createElement, useCallback, useContext, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { InkError, acceptSuggestion, confidenceBucket, createSnapshotHistory, isAbandonedNote, openDocument, repliesTo, threadOf, threadRoot } from "@inkbar/core";
4
4
  import { TOOL_LABELS, ZOOM_LEVELS, createFocusReturn, cssVariableDefaults, mountViewer, observeAnnotationElement, shouldKeepOpenOnAnnotation } from "@inkbar/core/dom";
5
- import { Popover, Slot, Toolbar } from "radix-ui";
5
+ import { Popover, Select, Slot, Toolbar } from "radix-ui";
6
6
  import { createPortal, flushSync } from "react-dom";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
- import { Hand, Highlighter, MessageSquare, MousePointer2, Square, ZoomIn, ZoomOut } from "lucide-react";
8
+ import { Check, ChevronDown, ChevronLeft, ChevronRight, Hand, Highlighter, ICON_ATTRIBUTES, MessageSquare, MousePointer2, Redo2, Square, Undo2, ZoomIn, ZoomOut } from "@inkbar/icons";
9
9
  //#region src/context.ts
10
10
  const InkContextObject = createContext(null);
11
11
  /**
@@ -746,7 +746,32 @@ function InkToolbar({ label = "Document tools", asChild = false, className, chil
746
746
  });
747
747
  }
748
748
  //#endregion
749
+ //#region src/components/InkIcon.tsx
750
+ /** `stroke-width` to `strokeWidth`: React names SVG attributes in camelCase. */
751
+ const camel = (name) => name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
752
+ const SVG_ATTRIBUTES = Object.fromEntries(Object.entries(ICON_ATTRIBUTES).map(([k, v]) => [camel(k), v]));
753
+ function InkIcon({ icon, size = 18 }) {
754
+ return /* @__PURE__ */ jsx("svg", {
755
+ ...SVG_ATTRIBUTES,
756
+ width: size,
757
+ height: size,
758
+ className: "ink-icon",
759
+ "aria-hidden": "true",
760
+ children: icon.map(([tag, attrs], i) => createElement(tag, {
761
+ key: i,
762
+ ...attrs
763
+ }))
764
+ });
765
+ }
766
+ //#endregion
749
767
  //#region src/components/InkToolButton.tsx
768
+ const ICONS = {
769
+ view: Hand,
770
+ select: MousePointer2,
771
+ highlight: Highlighter,
772
+ "redact-area": Square,
773
+ note: MessageSquare
774
+ };
750
775
  function InkToolButton({ tool, label, asChild = false, className, children, onClick, ...rest }) {
751
776
  const { tool: current, setTool } = useTool();
752
777
  const active = current === tool;
@@ -768,7 +793,60 @@ function InkToolButton({ tool, label, asChild = false, className, children, onCl
768
793
  children: typeof children === "function" ? children({
769
794
  active,
770
795
  label: name
771
- }) : children ?? name
796
+ }) : children ?? /* @__PURE__ */ jsx(InkIcon, { icon: ICONS[tool] })
797
+ });
798
+ }
799
+ //#endregion
800
+ //#region src/components/InkToolbarSeparator.tsx
801
+ /**
802
+ * A divider between groups of controls in a horizontal toolbar. Not focusable. A plain div
803
+ * rather than Radix's separator, which reads as horizontal inside a horizontal toolbar.
804
+ */
805
+ function InkToolbarSeparator({ className, ...rest }) {
806
+ return /* @__PURE__ */ jsx("div", {
807
+ role: "separator",
808
+ "aria-orientation": "vertical",
809
+ className: cx("ink-toolbar-separator", className),
810
+ "data-ink-toolbar-separator": "",
811
+ ...rest
812
+ });
813
+ }
814
+ //#endregion
815
+ //#region src/components/InkUndo.tsx
816
+ function InkUndo({ asChild = false, className, children, disabled, onClick, ...rest }) {
817
+ const { canUndo, undo } = useHistory();
818
+ return /* @__PURE__ */ jsx(Toolbar.Button, {
819
+ asChild,
820
+ className: cx("ink-undo", className),
821
+ "data-ink-undo": "",
822
+ "aria-label": "Undo",
823
+ title: "Undo",
824
+ ...rest,
825
+ disabled: disabled === true || !canUndo,
826
+ onClick: (e) => {
827
+ onClick?.(e);
828
+ if (!e.defaultPrevented) undo();
829
+ },
830
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: Undo2 })
831
+ });
832
+ }
833
+ //#endregion
834
+ //#region src/components/InkRedo.tsx
835
+ function InkRedo({ asChild = false, className, children, disabled, onClick, ...rest }) {
836
+ const { canRedo, redo } = useHistory();
837
+ return /* @__PURE__ */ jsx(Toolbar.Button, {
838
+ asChild,
839
+ className: cx("ink-redo", className),
840
+ "data-ink-redo": "",
841
+ "aria-label": "Redo",
842
+ title: "Redo",
843
+ ...rest,
844
+ disabled: disabled === true || !canRedo,
845
+ onClick: (e) => {
846
+ onClick?.(e);
847
+ if (!e.defaultPrevented) redo();
848
+ },
849
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: Redo2 })
772
850
  });
773
851
  }
774
852
  //#endregion
@@ -786,7 +864,7 @@ function InkZoomIn({ asChild = false, className, children, onClick, ...rest }) {
786
864
  onClick?.(e);
787
865
  if (!e.defaultPrevented) zoomIn();
788
866
  },
789
- children: children ?? "+"
867
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: ZoomIn })
790
868
  });
791
869
  }
792
870
  //#endregion
@@ -804,48 +882,90 @@ function InkZoomOut({ asChild = false, className, children, onClick, ...rest })
804
882
  onClick?.(e);
805
883
  if (!e.defaultPrevented) zoomOut();
806
884
  },
807
- children: children ?? "−"
885
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: ZoomOut })
808
886
  });
809
887
  }
810
888
  //#endregion
811
889
  //#region src/components/InkZoomSelect.tsx
812
890
  const CUSTOM = "custom:";
813
891
  const level = (z) => ZOOM_LEVELS.find((l) => Math.abs(l - z) < .001);
892
+ const percent = (z) => `${Math.round(z * 100)}%`;
893
+ const FITS = [{
894
+ value: "fit-width",
895
+ label: "Fit width"
896
+ }, {
897
+ value: "fit-page",
898
+ label: "Fit page"
899
+ }];
900
+ function Item({ value, label }) {
901
+ return /* @__PURE__ */ jsxs(Select.Item, {
902
+ value,
903
+ className: "ink-select-item",
904
+ "data-ink-select-item": "",
905
+ children: [/* @__PURE__ */ jsx(Select.ItemText, { children: label }), /* @__PURE__ */ jsx(Select.ItemIndicator, {
906
+ className: "ink-select-indicator",
907
+ children: /* @__PURE__ */ jsx(InkIcon, {
908
+ icon: Check,
909
+ size: 16
910
+ })
911
+ })]
912
+ });
913
+ }
814
914
  function InkZoomSelect({ className, ...rest }) {
815
915
  const { zoom, scale, setZoom } = useZoom();
816
916
  /** A numeric zoom that is not one of the levels (zoom in and out multiply). */
817
917
  const custom = typeof zoom === "number" && level(zoom) === void 0 ? zoom : null;
818
918
  const value = typeof zoom !== "number" ? zoom : custom === null ? String(level(zoom)) : `${CUSTOM}${zoom}`;
819
- function onChange(e) {
820
- const v = e.target.value;
919
+ /** The levels, with a custom zoom in its place among them. */
920
+ const levels = ZOOM_LEVELS.map((l) => ({
921
+ z: l,
922
+ value: String(l),
923
+ label: percent(l)
924
+ }));
925
+ if (custom !== null) levels.push({
926
+ z: custom,
927
+ value: `${CUSTOM}${custom}`,
928
+ label: percent(scale)
929
+ });
930
+ levels.sort((a, b) => a.z - b.z);
931
+ function onValueChange(v) {
932
+ if (v === value) return;
821
933
  const next = v === "fit-width" || v === "fit-page" ? v : Number(v.replace(CUSTOM, ""));
822
934
  setZoom(next);
823
935
  }
824
- return /* @__PURE__ */ jsxs("select", {
825
- className: cx("ink-zoom-select", className),
826
- "data-ink-zoom-select": "",
827
- "aria-label": "Zoom",
936
+ return /* @__PURE__ */ jsxs(Select.Root, {
828
937
  value,
829
- onChange,
830
- ...rest,
831
- children: [
832
- /* @__PURE__ */ jsx("option", {
833
- value: "fit-width",
834
- children: "Fit width"
835
- }),
836
- /* @__PURE__ */ jsx("option", {
837
- value: "fit-page",
838
- children: "Fit page"
839
- }),
840
- ZOOM_LEVELS.map((l) => /* @__PURE__ */ jsxs("option", {
841
- value: String(l),
842
- children: [Math.round(l * 100), "%"]
843
- }, l)),
844
- custom !== null ? /* @__PURE__ */ jsxs("option", {
845
- value: `${CUSTOM}${custom}`,
846
- children: [Math.round(scale * 100), "%"]
847
- }) : null
848
- ]
938
+ onValueChange,
939
+ children: [/* @__PURE__ */ jsxs(Select.Trigger, {
940
+ className: cx("ink-zoom-select ink-select-trigger", className),
941
+ "data-ink-zoom-select": "",
942
+ "aria-label": "Zoom",
943
+ ...rest,
944
+ children: [/* @__PURE__ */ jsx(Select.Value, { className: "ink-select-value" }), /* @__PURE__ */ jsx(Select.Icon, {
945
+ className: "ink-select-icon",
946
+ children: /* @__PURE__ */ jsx(InkIcon, {
947
+ icon: ChevronDown,
948
+ size: 16
949
+ })
950
+ })]
951
+ }), /* @__PURE__ */ jsx(Select.Portal, { children: /* @__PURE__ */ jsx(Select.Content, {
952
+ className: "ink-select-content",
953
+ "data-ink-select-content": "",
954
+ position: "popper",
955
+ side: "top",
956
+ sideOffset: 4,
957
+ children: /* @__PURE__ */ jsxs(Select.Viewport, { children: [
958
+ FITS.map((o) => /* @__PURE__ */ jsx(Item, {
959
+ value: o.value,
960
+ label: o.label
961
+ }, o.value)),
962
+ /* @__PURE__ */ jsx(Select.Separator, { className: "ink-select-separator" }),
963
+ levels.map((o) => /* @__PURE__ */ jsx(Item, {
964
+ value: o.value,
965
+ label: o.label
966
+ }, o.value))
967
+ ] })
968
+ }) })]
849
969
  });
850
970
  }
851
971
  //#endregion
@@ -911,83 +1031,41 @@ function InkPageCount({ className, ...rest }) {
911
1031
  });
912
1032
  }
913
1033
  //#endregion
914
- //#region src/compositions/DefaultToolbar.tsx
915
- const ICON = 18;
916
- function DefaultToolbar({ label = "Document tools", className, children }) {
917
- return /* @__PURE__ */ jsxs(InkToolbar, {
918
- label,
919
- className: cx("ink-default-toolbar", className),
920
- "data-ink-default-toolbar": "",
921
- children: [
922
- /* @__PURE__ */ jsxs("div", {
923
- className: "ink-toolbar-group",
924
- "data-ink-toolbar-group": "tools",
925
- role: "group",
926
- "aria-label": "Tools",
927
- children: [
928
- /* @__PURE__ */ jsx(InkToolButton, {
929
- tool: "view",
930
- children: /* @__PURE__ */ jsx(Hand, {
931
- size: ICON,
932
- "aria-hidden": "true"
933
- })
934
- }),
935
- /* @__PURE__ */ jsx(InkToolButton, {
936
- tool: "select",
937
- children: /* @__PURE__ */ jsx(MousePointer2, {
938
- size: ICON,
939
- "aria-hidden": "true"
940
- })
941
- }),
942
- /* @__PURE__ */ jsx(InkToolButton, {
943
- tool: "highlight",
944
- children: /* @__PURE__ */ jsx(Highlighter, {
945
- size: ICON,
946
- "aria-hidden": "true"
947
- })
948
- }),
949
- /* @__PURE__ */ jsx(InkToolButton, {
950
- tool: "redact-area",
951
- children: /* @__PURE__ */ jsx(Square, {
952
- size: ICON,
953
- "aria-hidden": "true"
954
- })
955
- }),
956
- /* @__PURE__ */ jsx(InkToolButton, {
957
- tool: "note",
958
- children: /* @__PURE__ */ jsx(MessageSquare, {
959
- size: ICON,
960
- "aria-hidden": "true"
961
- })
962
- })
963
- ]
964
- }),
965
- /* @__PURE__ */ jsxs("div", {
966
- className: "ink-toolbar-group",
967
- "data-ink-toolbar-group": "zoom",
968
- role: "group",
969
- "aria-label": "Zoom",
970
- children: [
971
- /* @__PURE__ */ jsx(InkZoomOut, { children: /* @__PURE__ */ jsx(ZoomOut, {
972
- size: ICON,
973
- "aria-hidden": "true"
974
- }) }),
975
- /* @__PURE__ */ jsx(InkZoomSelect, {}),
976
- /* @__PURE__ */ jsx(InkZoomIn, { children: /* @__PURE__ */ jsx(ZoomIn, {
977
- size: ICON,
978
- "aria-hidden": "true"
979
- }) })
980
- ]
981
- }),
982
- /* @__PURE__ */ jsxs("div", {
983
- className: "ink-toolbar-group",
984
- "data-ink-toolbar-group": "page",
985
- role: "group",
986
- "aria-label": "Page",
987
- children: [/* @__PURE__ */ jsx(InkPageInput, {}), /* @__PURE__ */ jsx(InkPageCount, {})]
988
- }),
989
- children
990
- ]
1034
+ //#region src/components/InkPrevPage.tsx
1035
+ function InkPrevPage({ asChild = false, className, children, disabled, onClick, ...rest }) {
1036
+ const { current, previous } = usePage();
1037
+ return /* @__PURE__ */ jsx(Toolbar.Button, {
1038
+ asChild,
1039
+ className: cx("ink-prev-page", className),
1040
+ "data-ink-prev-page": "",
1041
+ "aria-label": "Previous page",
1042
+ title: "Previous page",
1043
+ disabled: disabled === true || current <= 0,
1044
+ ...rest,
1045
+ onClick: (e) => {
1046
+ onClick?.(e);
1047
+ if (!e.defaultPrevented) previous();
1048
+ },
1049
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: ChevronLeft })
1050
+ });
1051
+ }
1052
+ //#endregion
1053
+ //#region src/components/InkNextPage.tsx
1054
+ function InkNextPage({ asChild = false, className, children, disabled, onClick, ...rest }) {
1055
+ const { current, count, next } = usePage();
1056
+ return /* @__PURE__ */ jsx(Toolbar.Button, {
1057
+ asChild,
1058
+ className: cx("ink-next-page", className),
1059
+ "data-ink-next-page": "",
1060
+ "aria-label": "Next page",
1061
+ title: "Next page",
1062
+ disabled: disabled === true || current >= count - 1,
1063
+ ...rest,
1064
+ onClick: (e) => {
1065
+ onClick?.(e);
1066
+ if (!e.defaultPrevented) next();
1067
+ },
1068
+ children: children ?? /* @__PURE__ */ jsx(InkIcon, { icon: ChevronRight })
991
1069
  });
992
1070
  }
993
1071
  //#endregion
@@ -1028,7 +1106,7 @@ function InkNotePopover({ children }) {
1028
1106
  const { annotations, add, update, remove } = useAnnotations();
1029
1107
  const note = useMemo(() => {
1030
1108
  const a = ctx.activated ? annotations.find((x) => x.id === ctx.activated) : void 0;
1031
- return a?.type === "note" ? threadRoot(annotations, a) : null;
1109
+ return a?.type === "text" ? threadRoot(annotations, a) : null;
1032
1110
  }, [annotations, ctx.activated]);
1033
1111
  const anchor = useAnnotationElement(ctx.rootEl, note?.id ?? null);
1034
1112
  const anchorRef = useMemo(() => ({ current: anchor }), [anchor]);
@@ -1070,7 +1148,7 @@ function InkNotePopover({ children }) {
1070
1148
  if (!root || !contents) return;
1071
1149
  written.current.add(root.id);
1072
1150
  add({
1073
- type: "note",
1151
+ type: "text",
1074
1152
  page: root.page,
1075
1153
  rect: root.rect,
1076
1154
  contents,
@@ -1275,6 +1353,6 @@ function InkSuggestionCard({ children }) {
1275
1353
  });
1276
1354
  }
1277
1355
  //#endregion
1278
- export { DefaultToolbar, InkAnnotation, InkNotePopover, InkPage, InkPageCount, InkPageInput, InkRoot, InkSuggestionCard, InkToolButton, InkToolbar, InkViewport, InkZoomIn, InkZoomOut, InkZoomSelect, useAnnotations, useDocument, useEmbedded, useHistory, useInkContext, usePage, useReadable, useSelection, useTool, useZoom };
1356
+ export { InkAnnotation, InkIcon, InkNextPage, InkNotePopover, InkPage, InkPageCount, InkPageInput, InkPrevPage, InkRedo, InkRoot, InkSuggestionCard, InkToolButton, InkToolbar, InkToolbarSeparator, InkUndo, InkViewport, InkZoomIn, InkZoomOut, InkZoomSelect, useAnnotations, useDocument, useEmbedded, useHistory, useInkContext, usePage, useReadable, useSelection, useTool, useZoom };
1279
1357
 
1280
1358
  //# sourceMappingURL=index.mjs.map