docblocks-react-ui 0.1.1 → 0.2.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/CHANGELOG.md +170 -0
- package/README.md +79 -11
- package/dist/{Editor-CiJY5R4v.mjs → Editor-YAlRhGNW.mjs} +2862 -499
- package/dist/{index-D6_ysSmQ.d.mts → index-DOKS86aH.d.mts} +85 -7
- package/dist/index.d.mts +54 -8
- package/dist/index.mjs +134 -24
- package/dist/mermaid/index.mjs +5 -4
- package/dist/pdf/index.d.mts +1 -1
- package/dist/pdf/index.mjs +8 -7
- package/dist/styles.css +14 -0
- package/package.json +4 -17
- package/dist/Editor-DT7RkRXf.d.mts +0 -32
- package/dist/Skeleton-D922Ths5.mjs +0 -13
- package/dist/motion/index.d.mts +0 -8
- package/dist/motion/index.mjs +0 -1009
|
@@ -669,12 +669,11 @@ interface UseDatabaseTable {
|
|
|
669
669
|
rowId: string;
|
|
670
670
|
cells: Record<string, unknown>;
|
|
671
671
|
}>): Promise<void>;
|
|
672
|
-
/** The mixed paste
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
* created rows' ids. */
|
|
672
|
+
/** The mixed paste: the visible rows' updates (from the active row down)
|
|
673
|
+
* + the overflow's creates — ONE `batchRows` (one transaction, one undo
|
|
674
|
+
* entry; the inverse = the updates' restore + the created rows'
|
|
675
|
+
* deletion). The updates stand the optimistic apply; the creates stand
|
|
676
|
+
* over the post-commit refresh. Returns the created rows' ids. */
|
|
678
677
|
pasteRows(input: {
|
|
679
678
|
updates: Array<{
|
|
680
679
|
rowId: string;
|
|
@@ -718,6 +717,85 @@ interface UseDatabaseTable {
|
|
|
718
717
|
*/
|
|
719
718
|
declare function useDatabaseTable(bridge: DatabaseBridge, tableId: string, filter?: DatabaseFilterPayload): UseDatabaseTable;
|
|
720
719
|
//#endregion
|
|
720
|
+
//#region src/database/standalone/models.d.ts
|
|
721
|
+
/**
|
|
722
|
+
* The database table's view settings — the standalone's `DatabaseTable`
|
|
723
|
+
* stand over the block's view attrs: the `filter`, the `columnOrder`, the
|
|
724
|
+
* `hiddenColumns`, the `columnWidths`, and the legacy `name` (the display
|
|
725
|
+
* stands the bridge's table name, as over the block — the `name` attr is
|
|
726
|
+
* the persistence's parity, not a display override). The schema's
|
|
727
|
+
* `views` / `viewType` attrs stand out of the UI's v1 (the view's kinds
|
|
728
|
+
* are unrendered).
|
|
729
|
+
*/
|
|
730
|
+
interface DatabaseTableView {
|
|
731
|
+
/** The display name's legacy parity (the bridge's table name stands the display). */
|
|
732
|
+
name?: string;
|
|
733
|
+
/** The applied filter (the block's `filter` attr's payload shape). */
|
|
734
|
+
filter?: DatabaseFilterPayload;
|
|
735
|
+
/** The visible columns' order (the drag's committed stand). */
|
|
736
|
+
columnOrder?: string[];
|
|
737
|
+
/** The hidden columns' ids (the column menu's toggle stand). */
|
|
738
|
+
hiddenColumns?: string[];
|
|
739
|
+
/** The columns' widths (px, over the `columnOrder` positions). */
|
|
740
|
+
columnWidths?: number[];
|
|
741
|
+
}
|
|
742
|
+
/** The `useTableList`'s return: the catalog's read projection + the create / rename's mutations. */
|
|
743
|
+
interface UseTableList {
|
|
744
|
+
/** The catalog's tables (the system tables stand absent); `null` until the first successful read. */
|
|
745
|
+
tables: TableRef[] | null;
|
|
746
|
+
/** The catalog read's in-flight stand. */
|
|
747
|
+
loading: boolean;
|
|
748
|
+
/** The catalog read's last error (the `BridgeError` stand — the create / rename's failures stand their promises' rejects). */
|
|
749
|
+
error: BridgeError | null;
|
|
750
|
+
/** The catalog's re-read (the manual's stand — the contract's catalog stands no push). */
|
|
751
|
+
refresh: () => Promise<void>;
|
|
752
|
+
/** The `createTable`'s mutation (the fresh's `operationId` per op; rejects with the `BridgeError`). Resolves the created table's ref. */
|
|
753
|
+
create: (name: string) => Promise<TableRef>;
|
|
754
|
+
/** The `renameTable`'s mutation (the fresh's `operationId` per op; rejects with the `BridgeError`). */
|
|
755
|
+
rename: (tableId: string, name: string) => Promise<void>;
|
|
756
|
+
}
|
|
757
|
+
//#endregion
|
|
758
|
+
//#region src/database/standalone/DatabaseTable.d.ts
|
|
759
|
+
interface DatabaseTableProps {
|
|
760
|
+
/** The consumer's bridge (the table's truth). */
|
|
761
|
+
bridge: DatabaseBridge;
|
|
762
|
+
/** The bridge's table id (the `TableRef.id` over the `listTables`'s catalog). */
|
|
763
|
+
tableId: string;
|
|
764
|
+
/** The read-only's stand: the grid's data stands rendered, the editing's paths stand off (the block's read-only's parity). */
|
|
765
|
+
readOnly?: boolean;
|
|
766
|
+
/** The initial view's state (the consumer's persistence's seed; the mount's stand only — the controlled's mode stands absent). */
|
|
767
|
+
view?: Partial<DatabaseTableView>;
|
|
768
|
+
/** The view's change's hook (the persistence's stand; the patch = the changed's attrs only). */
|
|
769
|
+
onViewChange?: (patch: Partial<DatabaseTableView>) => void;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* The standalone's database table: the live grid over the bridge's table
|
|
773
|
+
* id — the same `useDatabaseTable`'s data stand as the document block
|
|
774
|
+
* (the schema + the rows + the live events + the optimistic cell's layer),
|
|
775
|
+
* rendered outside any document (the consumer's own page / panel). The
|
|
776
|
+
* view's settings stand the internal's state (seeded from the `view`
|
|
777
|
+
* prop) + the consumer's persistence over the `onViewChange`'s patch
|
|
778
|
+
* (one patch per change, as the block's `updateBlock` stand). The i18n's
|
|
779
|
+
* scope stands self-contained (the package's instance — the same's stand
|
|
780
|
+
* as the consumer-placed components).
|
|
781
|
+
*/
|
|
782
|
+
declare function DatabaseTable({ bridge, tableId, readOnly, view, onViewChange }: DatabaseTableProps): import("react").JSX.Element;
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/database/standalone/use-table-list.d.ts
|
|
785
|
+
/**
|
|
786
|
+
* The table catalog's hook (the standalone's stand): the consumer's
|
|
787
|
+
* `DatabaseBridge`'s catalog read (`listTables` — the system tables stand
|
|
788
|
+
* absent) + the `createTable` / `renameTable` mutations (the fresh's
|
|
789
|
+
* `operationId` per op over `newMutationContext`). The catalog's truth
|
|
790
|
+
* stands in the bridge — the hook's state is the read projection,
|
|
791
|
+
* re-read over the own's successful mutations (the auto's stand) + the
|
|
792
|
+
* manual's `refresh` (the contract's catalog stands no push — the
|
|
793
|
+
* per-table's events stand over the `useDatabaseTable`'s subscription).
|
|
794
|
+
* The create / rename's failures stand their promises' rejects (the
|
|
795
|
+
* `BridgeError` stand) — the `error` state is the catalog read's own.
|
|
796
|
+
*/
|
|
797
|
+
declare function useTableList(bridge: DatabaseBridge): UseTableList;
|
|
798
|
+
//#endregion
|
|
721
799
|
//#region src/canvas/clipboard.d.ts
|
|
722
800
|
/** The one copied canvas item (the deep data; the ids stand the originals). */
|
|
723
801
|
type ClipboardItem = {
|
|
@@ -1072,4 +1150,4 @@ declare const DEFAULT_EMBED_SANDBOX = "allow-scripts allow-forms allow-popups";
|
|
|
1072
1150
|
/** Read the per-instance editor context; throws outside an EditorProvider. */
|
|
1073
1151
|
declare function useEditorContext(): EditorContextValue;
|
|
1074
1152
|
//#endregion
|
|
1075
|
-
export {
|
|
1153
|
+
export { SortInput as $, BridgeValueInput as A, MutationContext as B, emptyFilter as C, BridgeColumn as D, BatchOp as E, DomainEvent as F, ProtocolCapability as G, OperationStatus as H, FilterConditionInput as I, QueryOperator as J, ProtocolDescriptor as K, FilterInput as L, CellValueParse as M, Column as N, BridgeColumnAnnotation as O, DatabaseBridge as P, RowWire as Q, Id as R, UseDatabaseTable as S, FilterBuilder as T, PageQuery as U, MutationReceipt as V, PageSnapshot as W, Revision as X, QuerySemantics as Y, RowPage as Z, DatabaseTableView as _, BlobSubtype as _t, EditorContextValue as a, TableEvent as at, DatabaseTablePhase as b, EmbedSandboxPolicy as c, BRIDGE_ERROR_CODES as ct, PdfPreview as d, isBridgeError as dt, SubscriptionHandle as et, PdfPreviewProps as f, isBridgeErrorCode as ft, DatabaseTableProps as g, BlobStore as gt, DatabaseTable as h, BlobRef as ht, AccessLevel as i, TableEnvelopeBase as it, CellMap as j, BridgeTableDescription as k, MentionEntry as l, BridgeError as lt, useTableList as m, BlobMeta as mt, DEFAULT_EMBED_SANDBOX as n, SubscriptionStatus as nt, EditorMode as o, TableRef as ot, SyncEmbedResolver as p, toBridgeError as pt, ProtocolLimits as q, EditorProvider as r, TableDescription as rt, EditorProviderProps as s, TableSnapshot as st, useEditorContext as t, SubscriptionObserver as tt, MentionProvider as u, BridgeErrorCode as ut, UseTableList as v, blobSubtypeOf as vt, filterIsComplete as w, DatabaseTableRow as x, useDatabaseTable as y, createMemoryBlobStore as yt, IsoInstant as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { n as BlockRendererMap, r as BlockRendererProps, t as BlockRenderer } from "./index-YJcgf8Hh.mjs";
|
|
2
|
-
import { n as
|
|
3
|
-
import { $ as TableEnvelopeBase, A as DomainEvent, B as ProtocolCapability, C as BridgeColumnAnnotation, D as CellValueParse, E as CellMap, F as MutationContext, G as Revision, H as ProtocolLimits, I as MutationReceipt, J as SortInput, K as RowPage, L as OperationStatus, M as FilterInput, N as Id, O as Column, P as IsoInstant, Q as TableDescription, R as PageQuery, S as BridgeColumn, T as BridgeValueInput, U as QueryOperator, V as ProtocolDescriptor, W as QuerySemantics, X as SubscriptionObserver, Y as SubscriptionHandle, Z as SubscriptionStatus, _ as UseDatabaseTable, a as EditorContextValue, at as BridgeErrorCode, b as FilterBuilder, c as EmbedSandboxPolicy, ct as toBridgeError, d as PdfPreview, dt as BlobStore, et as TableEvent, f as PdfPreviewProps, ft as BlobSubtype, g as DatabaseTableRow, h as DatabaseTablePhase, i as AccessLevel, it as BridgeError, j as FilterConditionInput, k as DatabaseBridge, l as MentionEntry, lt as BlobMeta, m as useDatabaseTable, mt as createMemoryBlobStore, n as DEFAULT_EMBED_SANDBOX, nt as TableSnapshot, o as EditorMode, ot as isBridgeError, p as SyncEmbedResolver, pt as blobSubtypeOf, q as RowWire, r as EditorProvider, rt as BRIDGE_ERROR_CODES, s as EditorProviderProps, st as isBridgeErrorCode, t as useEditorContext, tt as TableRef, u as MentionProvider, ut as BlobRef, v as emptyFilter, w as BridgeTableDescription, x as BatchOp, y as filterIsComplete, z as PageSnapshot } from "./index-D6_ysSmQ.mjs";
|
|
2
|
+
import { $ as SortInput, A as BridgeValueInput, B as MutationContext, C as emptyFilter, D as BridgeColumn, E as BatchOp, F as DomainEvent, G as ProtocolCapability, H as OperationStatus, I as FilterConditionInput, J as QueryOperator, K as ProtocolDescriptor, L as FilterInput, M as CellValueParse, N as Column, O as BridgeColumnAnnotation, P as DatabaseBridge, Q as RowWire, R as Id, S as UseDatabaseTable, T as FilterBuilder, U as PageQuery, V as MutationReceipt, W as PageSnapshot, X as Revision, Y as QuerySemantics, Z as RowPage, _ as DatabaseTableView, _t as BlobSubtype, a as EditorContextValue, at as TableEvent, b as DatabaseTablePhase, c as EmbedSandboxPolicy, ct as BRIDGE_ERROR_CODES, d as PdfPreview, dt as isBridgeError, et as SubscriptionHandle, f as PdfPreviewProps, ft as isBridgeErrorCode, g as DatabaseTableProps, gt as BlobStore, h as DatabaseTable, ht as BlobRef, i as AccessLevel, it as TableEnvelopeBase, j as CellMap, k as BridgeTableDescription, l as MentionEntry, lt as BridgeError, m as useTableList, mt as BlobMeta, n as DEFAULT_EMBED_SANDBOX, nt as SubscriptionStatus, o as EditorMode, ot as TableRef, p as SyncEmbedResolver, pt as toBridgeError, q as ProtocolLimits, r as EditorProvider, rt as TableDescription, s as EditorProviderProps, st as TableSnapshot, t as useEditorContext, tt as SubscriptionObserver, u as MentionProvider, ut as BridgeErrorCode, v as UseTableList, vt as blobSubtypeOf, w as filterIsComplete, x as DatabaseTableRow, y as useDatabaseTable, yt as createMemoryBlobStore, z as IsoInstant } from "./index-DOKS86aH.mjs";
|
|
4
3
|
import * as React from "react";
|
|
5
4
|
import { ComponentType, ReactNode } from "react";
|
|
6
5
|
import { Block, BlockId, BlockType, Doc, DocMeta, PresenceState, Selection, SelectionView, SyncEmbedRef, TextRun } from "docblocks-core";
|
|
@@ -14,6 +13,41 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
|
14
13
|
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
15
14
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
16
15
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
16
|
+
//#region src/Editor.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* The document's view mode: the page flow (the root's children in reading
|
|
19
|
+
* order) or the canvas (the page as a miniature rectangle plus the surface
|
|
20
|
+
* elements on one canvas). View state — switching writes nothing to the
|
|
21
|
+
* data (like the selection).
|
|
22
|
+
*/
|
|
23
|
+
type EditorView = "page" | "canvas";
|
|
24
|
+
interface EditorProps {
|
|
25
|
+
view?: EditorView;
|
|
26
|
+
/** The format toolbar's color palette (the default six colors). */
|
|
27
|
+
formatPalette?: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The document's editor: the root is the editor's focus/keyboard scope
|
|
31
|
+
* (the undo/redo hotkeys only fire for keys targeted inside it), and the
|
|
32
|
+
* root block context is provided for every entry (the entry list's
|
|
33
|
+
* siblings, and the entry root's sequence container as the gestures'
|
|
34
|
+
* command parent — a subtree entry root is a page block, structurally
|
|
35
|
+
* childless, so its commands target the container of its sequence, not
|
|
36
|
+
* itself).
|
|
37
|
+
*
|
|
38
|
+
* The `view` prop selects the rendering: "page" (default) is the flat page
|
|
39
|
+
* sequence — every page block is its own `Reorder.Item` row (the nesting is
|
|
40
|
+
* the block's `indent` attr; a list item's marker is a rendered label per
|
|
41
|
+
* row), the top-level rows render through `AnimatePresence` (`sync`), and
|
|
42
|
+
* the drag-reorder is pure framer `Reorder` (one drag = one range move of
|
|
43
|
+
* the dragged block's derived subtree — see the `motion` segment);
|
|
44
|
+
* "canvas" renders the document's page as a page miniature and the
|
|
45
|
+
* root-level surfaces' elements on one canvas (see CanvasView). The
|
|
46
|
+
* `formatPalette` prop overrides the floating format toolbar's color
|
|
47
|
+
* palette.
|
|
48
|
+
*/
|
|
49
|
+
declare function Editor({ view, formatPalette }: EditorProps): import("react").JSX.Element;
|
|
50
|
+
//#endregion
|
|
17
51
|
//#region src/database/bridge/annotation.d.ts
|
|
18
52
|
/** The standard PostgreSQL type names per operator / input group. The contract
|
|
19
53
|
* is type-agnostic — this is the package's DEFAULT catalog; a non-standard
|
|
@@ -61,13 +95,17 @@ declare function isDatabaseBridge(candidate: unknown): candidate is DatabaseBrid
|
|
|
61
95
|
declare function validateProtocolDescriptor(descriptor: ProtocolDescriptor): Set<ProtocolCapability>;
|
|
62
96
|
//#endregion
|
|
63
97
|
//#region src/database/use-database-table/utils.d.ts
|
|
64
|
-
/** The cell-value equality (null / undefined stand as the empty cell).
|
|
98
|
+
/** The cell-value equality (null / undefined stand as the empty cell).
|
|
99
|
+
* The composite value (the multi-select's array) stands the element-wise
|
|
100
|
+
* stand: the same content over a fresh array instance is NOT a change
|
|
101
|
+
* (the identity stand would commit the no-op and push the undo entry). */
|
|
65
102
|
declare function cellValueEqual(current: unknown, next: unknown): boolean;
|
|
66
103
|
/** The write's context: the fresh client-issued operation id (a UUID,
|
|
67
104
|
* unique within the retention) + the issue time. Every user action stands
|
|
68
105
|
* a fresh `operationId` — the id is never reused across logical
|
|
69
|
-
* operations
|
|
70
|
-
*
|
|
106
|
+
* operations. The lost response's reconciliation (the write's fate) is
|
|
107
|
+
* the consumer's stand over the bridge's `getOperationStatus`; the UI's
|
|
108
|
+
* convergence is the rebaseline (the next snapshot / the envelope). */
|
|
71
109
|
declare function newMutationContext(): MutationContext;
|
|
72
110
|
//#endregion
|
|
73
111
|
//#region src/canvas/text-fonts.d.ts
|
|
@@ -112,7 +150,9 @@ declare const SHAPE_FONT_OPTIONS: readonly [{
|
|
|
112
150
|
declare const SHAPE_FONT_STACKS: Record<string, string>;
|
|
113
151
|
//#endregion
|
|
114
152
|
//#region src/DocHeader.d.ts
|
|
115
|
-
|
|
153
|
+
/** The header's props (the consumer's state: the doc's stand, the view and
|
|
154
|
+
* the mode's switchers — the consumer owns the view / the mode's state). */
|
|
155
|
+
interface DocHeaderProps {
|
|
116
156
|
/** The headless document (the consumer's own stand: the live doc over the editor's stand, the published snapshot over the viewer's stand — the reader's browser never holds the live document). */
|
|
117
157
|
doc?: Doc;
|
|
118
158
|
view: EditorView;
|
|
@@ -125,7 +165,13 @@ declare function DocHeader({ doc, view, onViewChange, accessLevel, mode, onModeC
|
|
|
125
165
|
onModeChange?: (mode: EditorMode) => void;
|
|
126
166
|
/** The published snapshot (the meta's source over the published's stand; the "Published"'s option stands disabled over its absence). */
|
|
127
167
|
publishedDoc?: Doc | null;
|
|
128
|
-
}
|
|
168
|
+
}
|
|
169
|
+
/** The header's i18n scope: the package's instance stands the provider's seat
|
|
170
|
+
* over the panel (the consumer places the header outside the editor — the
|
|
171
|
+
* editor's own scope never reaches it). A consumer-wrapped subtree stands
|
|
172
|
+
* the same instance nested — the provider is a plain context, the render
|
|
173
|
+
* is unchanged. */
|
|
174
|
+
declare function DocHeader(props: DocHeaderProps): import("react").JSX.Element;
|
|
129
175
|
//#endregion
|
|
130
176
|
//#region src/hooks.d.ts
|
|
131
177
|
/** The headless document owned by the nearest EditorProvider. */
|
|
@@ -385,4 +431,4 @@ declare function TooltipContent({ className, sideOffset, children, ...props }: R
|
|
|
385
431
|
//#region src/shared/ui/cn.d.ts
|
|
386
432
|
declare function cn(...inputs: ClassValue[]): string;
|
|
387
433
|
//#endregion
|
|
388
|
-
export { type AccessLevel, Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, type BatchOp, type BlobMeta, type BlobRef, type BlobStore, type BlobSubtype, type BlockRenderer, type BlockRendererMap, type BlockRendererProps, type BridgeColumn, type BridgeColumnAnnotation, BridgeError, type BridgeErrorCode, type BridgeTableDescription, type BridgeValueInput, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellMap, type CellValueParse, Checkbox, type Column, DEFAULT_EMBED_SANDBOX, type DatabaseBridge, type DatabaseTablePhase, type DatabaseTableRow, DocHeader, type DomainEvent, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, type EditorContextValue, type EditorMode, EditorProvider, type EditorProviderProps, type EditorView, type EmbedSandboxPolicy, FORMAT_PALETTE, FilterBuilder, type FilterConditionInput, type FilterInput, type FormatMark, type Id, Input, type IsoInstant, Label, MONO_FONT_STACK, type MentionEntry, type MentionProvider, type MutationContext, type MutationReceipt, type OperationStatus, PROTOCOL_VERSION, type PageQuery, type PageSnapshot, type PdfPreview, type PdfPreviewProps, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, type ProtocolCapability, type ProtocolDescriptor, type ProtocolLimits, type QueryOperator, type QuerySemantics, type Revision, type RowPage, type RowWire, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, type SortInput, type SubscriptionHandle, type SubscriptionObserver, type SubscriptionStatus, type SyncEmbedRef, type SyncEmbedResolver, TEXT_TYPES, type TableDescription, type TableEnvelopeBase, type TableEvent, type TableRef, type TableSnapshot, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, type UseDatabaseTable, badgeVariants, blobSubtypeOf, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, useSelection, useSelectionView, useText, validateProtocolDescriptor };
|
|
434
|
+
export { type AccessLevel, Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, type BatchOp, type BlobMeta, type BlobRef, type BlobStore, type BlobSubtype, type BlockRenderer, type BlockRendererMap, type BlockRendererProps, type BridgeColumn, type BridgeColumnAnnotation, BridgeError, type BridgeErrorCode, type BridgeTableDescription, type BridgeValueInput, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellMap, type CellValueParse, Checkbox, type Column, DEFAULT_EMBED_SANDBOX, type DatabaseBridge, DatabaseTable, type DatabaseTablePhase, type DatabaseTableProps, type DatabaseTableRow, type DatabaseTableView, DocHeader, type DomainEvent, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, type EditorContextValue, type EditorMode, EditorProvider, type EditorProviderProps, type EditorView, type EmbedSandboxPolicy, FORMAT_PALETTE, FilterBuilder, type FilterConditionInput, type FilterInput, type FormatMark, type Id, Input, type IsoInstant, Label, MONO_FONT_STACK, type MentionEntry, type MentionProvider, type MutationContext, type MutationReceipt, type OperationStatus, PROTOCOL_VERSION, type PageQuery, type PageSnapshot, type PdfPreview, type PdfPreviewProps, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, type ProtocolCapability, type ProtocolDescriptor, type ProtocolLimits, type QueryOperator, type QuerySemantics, type Revision, type RowPage, type RowWire, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, type SortInput, type SubscriptionHandle, type SubscriptionObserver, type SubscriptionStatus, type SyncEmbedRef, type SyncEmbedResolver, TEXT_TYPES, type TableDescription, type TableEnvelopeBase, type TableEvent, type TableRef, type TableSnapshot, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, type UseDatabaseTable, type UseTableList, badgeVariants, blobSubtypeOf, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as PopoverHeader, A as SelectTrigger, At as isBridgeErrorCode, B as DropdownMenuRadioGroup, Bt as useMeta, C as SelectContent, Ct as BASELINE_CAPABILITIES, D as SelectScrollDownButton, Dt as BRIDGE_ERROR_CODES, E as SelectLabel, Et as validateProtocolDescriptor, F as DropdownMenuContent, Ft as columnAnnotation, G as DropdownMenuSubContent, H as DropdownMenuSeparator, Ht as useSelection, I as DropdownMenuGroup, It as ScrollArea, J as Separator, Jt as createMemoryBlobStore, K as DropdownMenuSubTrigger, Kt as renderRuns, L as DropdownMenuItem, Lt as Input, M as Label, Mt as conditionMatches, N as DropdownMenu, Nt as parseCellValue, O as SelectScrollUpButton, Ot as BridgeError, P as DropdownMenuCheckboxItem, Pt as TEXT_TYPES, Q as PopoverDescription, R as DropdownMenuLabel, Rt as useBlock, S as Select, St as AlertTitle, T as SelectItem, Tt as isDatabaseBridge, U as DropdownMenuShortcut, Ut as useSelectionView, V as DropdownMenuRadioItem, Vt as usePresence, W as DropdownMenuSub, Wt as useText, X as PopoverAnchor, Y as Popover, Z as PopoverContent, _ as FilterBuilder, _t as BareSelect, a as SHAPE_FONT_STACKS, at as CardAction, b as Skeleton, bt as Alert, ct as CardFooter, d as useEditorContext, dt as Pen, et as PopoverTitle, f as DEFAULT_EMBED_SANDBOX, ft as Eye, g as newMutationContext, gt as buttonVariants, h as cellValueEqual, ht as Button, i as SHAPE_FONT_OPTIONS, it as Card, j as SelectValue, jt as toBridgeError, k as SelectSeparator, kt as isBridgeError, l as markToggleAction, lt as CardHeader, m as useDatabaseTable, mt as BookOpen, nt as DocblocksI18nProvider, o as FORMAT_PALETTE, ot as CardContent, p as GridBody, q as DropdownMenuTrigger, qt as blobSubtypeOf, rt as Checkbox, st as CardDescription, t as Editor, tt as PopoverTrigger, u as EditorProvider, ut as CardTitle, v as emptyFilter, vt as Badge, w as SelectGroup, wt as PROTOCOL_VERSION, x as SegmentSelector, xt as AlertDescription, y as filterIsComplete, yt as badgeVariants, z as DropdownMenuPortal, zt as useDoc } from "./Editor-YAlRhGNW.mjs";
|
|
2
2
|
import { c as cn, o as preventDefault } from "./constants-D4FTL0ph.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
8
8
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
@@ -211,14 +211,20 @@ const AVATAR_EMOJI = [
|
|
|
211
211
|
* content is portaled outside the editor root, where the `--docblocks-*`
|
|
212
212
|
* tokens are not mapped).
|
|
213
213
|
*/
|
|
214
|
-
|
|
214
|
+
/** The picker's i18n scope: the package's instance stands the provider's seat
|
|
215
|
+
* over the picker (it stands also outside the editor's scope). */
|
|
216
|
+
function EmojiPicker(props) {
|
|
217
|
+
return /* @__PURE__ */ jsx(DocblocksI18nProvider, { children: /* @__PURE__ */ jsx(EmojiPickerInner, { ...props }) });
|
|
218
|
+
}
|
|
219
|
+
function EmojiPickerInner({ selected, onPick, onClear }) {
|
|
220
|
+
const { t } = useTranslation("editor");
|
|
215
221
|
const pickEmoji = (emoji) => () => onPick(emoji);
|
|
216
222
|
return /* @__PURE__ */ jsxs("div", {
|
|
217
223
|
"data-slot": "docblocks/emoji-picker",
|
|
218
224
|
className: "flex w-52 flex-col gap-2",
|
|
219
225
|
children: [/* @__PURE__ */ jsx("div", {
|
|
220
226
|
role: "group",
|
|
221
|
-
"aria-label": "
|
|
227
|
+
"aria-label": t("shared.emojiPickerGroup"),
|
|
222
228
|
className: "grid grid-cols-6 gap-1",
|
|
223
229
|
children: AVATAR_EMOJI.map(({ emoji, label }) => {
|
|
224
230
|
const isSelected = selected === emoji;
|
|
@@ -246,7 +252,7 @@ function EmojiPicker({ selected, onPick, onClear }) {
|
|
|
246
252
|
"data-slot": "docblocks/emoji-picker-clear",
|
|
247
253
|
className: "\n -mx-1 h-auto px-2 py-1 text-left text-xs font-normal text-muted-foreground transition-colors\n focus-visible:ring-0 focus-visible:outline-1 focus-visible:outline-ring\n ",
|
|
248
254
|
onClick: onClear,
|
|
249
|
-
children: "
|
|
255
|
+
children: t("shared.removeAvatar")
|
|
250
256
|
})]
|
|
251
257
|
});
|
|
252
258
|
}
|
|
@@ -374,6 +380,101 @@ function TooltipContent({ className, sideOffset = 0, children, ...props }) {
|
|
|
374
380
|
}) });
|
|
375
381
|
}
|
|
376
382
|
//#endregion
|
|
383
|
+
//#region src/database/standalone/DatabaseTable.tsx
|
|
384
|
+
/** The stable absent-seed's stand (the `view` prop's absent stand). */
|
|
385
|
+
const EMPTY_VIEW = {};
|
|
386
|
+
/**
|
|
387
|
+
* The standalone's database table: the live grid over the bridge's table
|
|
388
|
+
* id — the same `useDatabaseTable`'s data stand as the document block
|
|
389
|
+
* (the schema + the rows + the live events + the optimistic cell's layer),
|
|
390
|
+
* rendered outside any document (the consumer's own page / panel). The
|
|
391
|
+
* view's settings stand the internal's state (seeded from the `view`
|
|
392
|
+
* prop) + the consumer's persistence over the `onViewChange`'s patch
|
|
393
|
+
* (one patch per change, as the block's `updateBlock` stand). The i18n's
|
|
394
|
+
* scope stands self-contained (the package's instance — the same's stand
|
|
395
|
+
* as the consumer-placed components).
|
|
396
|
+
*/
|
|
397
|
+
function DatabaseTable({ bridge, tableId, readOnly = false, view, onViewChange }) {
|
|
398
|
+
const [viewState, setViewState] = useState(view ?? EMPTY_VIEW);
|
|
399
|
+
const viewRef = useRef(viewState);
|
|
400
|
+
viewRef.current = viewState;
|
|
401
|
+
const handleViewChange = useCallback((patch) => {
|
|
402
|
+
const typed = patch;
|
|
403
|
+
setViewState((current) => ({
|
|
404
|
+
...current,
|
|
405
|
+
...typed
|
|
406
|
+
}));
|
|
407
|
+
if (onViewChange !== void 0) onViewChange(typed);
|
|
408
|
+
}, [onViewChange]);
|
|
409
|
+
return /* @__PURE__ */ jsx(DocblocksI18nProvider, { children: /* @__PURE__ */ jsx(GridBody, {
|
|
410
|
+
bridge,
|
|
411
|
+
tableId,
|
|
412
|
+
filter: viewState.filter,
|
|
413
|
+
columnOrder: viewState.columnOrder,
|
|
414
|
+
hiddenColumns: viewState.hiddenColumns,
|
|
415
|
+
columnWidths: viewState.columnWidths,
|
|
416
|
+
onViewChange: handleViewChange,
|
|
417
|
+
readColumnOrder: () => viewRef.current.columnOrder,
|
|
418
|
+
readOnly
|
|
419
|
+
}) });
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/database/standalone/use-table-list.ts
|
|
423
|
+
/**
|
|
424
|
+
* The table catalog's hook (the standalone's stand): the consumer's
|
|
425
|
+
* `DatabaseBridge`'s catalog read (`listTables` — the system tables stand
|
|
426
|
+
* absent) + the `createTable` / `renameTable` mutations (the fresh's
|
|
427
|
+
* `operationId` per op over `newMutationContext`). The catalog's truth
|
|
428
|
+
* stands in the bridge — the hook's state is the read projection,
|
|
429
|
+
* re-read over the own's successful mutations (the auto's stand) + the
|
|
430
|
+
* manual's `refresh` (the contract's catalog stands no push — the
|
|
431
|
+
* per-table's events stand over the `useDatabaseTable`'s subscription).
|
|
432
|
+
* The create / rename's failures stand their promises' rejects (the
|
|
433
|
+
* `BridgeError` stand) — the `error` state is the catalog read's own.
|
|
434
|
+
*/
|
|
435
|
+
function useTableList(bridge) {
|
|
436
|
+
const [tables, setTables] = useState(null);
|
|
437
|
+
const [loading, setLoading] = useState(true);
|
|
438
|
+
const [error, setError] = useState(null);
|
|
439
|
+
const bridgeRef = useRef(bridge);
|
|
440
|
+
bridgeRef.current = bridge;
|
|
441
|
+
const readSeq = useRef(0);
|
|
442
|
+
const refresh = useCallback(async () => {
|
|
443
|
+
const seq = ++readSeq.current;
|
|
444
|
+
setLoading(true);
|
|
445
|
+
try {
|
|
446
|
+
const list = await bridgeRef.current.listTables();
|
|
447
|
+
if (seq !== readSeq.current) return;
|
|
448
|
+
setTables(list);
|
|
449
|
+
setError(null);
|
|
450
|
+
} catch (error) {
|
|
451
|
+
if (seq !== readSeq.current) return;
|
|
452
|
+
setTables(null);
|
|
453
|
+
setError(toBridgeError(error));
|
|
454
|
+
} finally {
|
|
455
|
+
if (seq === readSeq.current) setLoading(false);
|
|
456
|
+
}
|
|
457
|
+
}, []);
|
|
458
|
+
useEffect(() => {
|
|
459
|
+
refresh();
|
|
460
|
+
}, [refresh]);
|
|
461
|
+
return {
|
|
462
|
+
tables,
|
|
463
|
+
loading,
|
|
464
|
+
error,
|
|
465
|
+
refresh,
|
|
466
|
+
create: useCallback(async (name) => {
|
|
467
|
+
const receipt = await bridgeRef.current.createTable({ name }, newMutationContext());
|
|
468
|
+
await refresh();
|
|
469
|
+
return receipt.result;
|
|
470
|
+
}, [refresh]),
|
|
471
|
+
rename: useCallback(async (tableId, name) => {
|
|
472
|
+
await bridgeRef.current.renameTable(tableId, { name }, newMutationContext());
|
|
473
|
+
await refresh();
|
|
474
|
+
}, [refresh])
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
377
478
|
//#region src/DocHeader.tsx
|
|
378
479
|
/**
|
|
379
480
|
* The document's header panel — a consumer-placed component (outside the
|
|
@@ -436,7 +537,16 @@ function InlineEditInput({ initial, ariaLabel, slot, className, onCommit, onCanc
|
|
|
436
537
|
onKeyDown: onInputKeyDown
|
|
437
538
|
});
|
|
438
539
|
}
|
|
439
|
-
|
|
540
|
+
/** The header's i18n scope: the package's instance stands the provider's seat
|
|
541
|
+
* over the panel (the consumer places the header outside the editor — the
|
|
542
|
+
* editor's own scope never reaches it). A consumer-wrapped subtree stands
|
|
543
|
+
* the same instance nested — the provider is a plain context, the render
|
|
544
|
+
* is unchanged. */
|
|
545
|
+
function DocHeader(props) {
|
|
546
|
+
return /* @__PURE__ */ jsx(DocblocksI18nProvider, { children: /* @__PURE__ */ jsx(DocHeaderInner, { ...props }) });
|
|
547
|
+
}
|
|
548
|
+
function DocHeaderInner({ doc, view, onViewChange, accessLevel = "editor", mode = "edit", onModeChange, publishedDoc }) {
|
|
549
|
+
const { t } = useTranslation("editor");
|
|
440
550
|
const effectiveMode = accessLevel === "viewer" ? "published" : mode;
|
|
441
551
|
const viewMode = effectiveMode !== "edit";
|
|
442
552
|
const snapshot = effectiveMode === "published" ? accessLevel === "viewer" ? doc ?? null : publishedDoc ?? null : null;
|
|
@@ -490,16 +600,16 @@ function DocHeader({ doc, view, onViewChange, accessLevel = "editor", mode = "ed
|
|
|
490
600
|
/* @__PURE__ */ jsx(SegmentSelector, {
|
|
491
601
|
options: [{
|
|
492
602
|
value: "page",
|
|
493
|
-
label: "
|
|
603
|
+
label: t("docHeader.pageView"),
|
|
494
604
|
icon: /* @__PURE__ */ jsx(SquareText, { className: "size-4" })
|
|
495
605
|
}, {
|
|
496
606
|
value: "canvas",
|
|
497
|
-
label: "
|
|
607
|
+
label: t("docHeader.canvasView"),
|
|
498
608
|
icon: /* @__PURE__ */ jsx(Network, { className: "size-4" })
|
|
499
609
|
}],
|
|
500
610
|
value: view,
|
|
501
611
|
onChange: switchView,
|
|
502
|
-
ariaLabel: "
|
|
612
|
+
ariaLabel: t("docHeader.documentViewAria"),
|
|
503
613
|
slot: "docblocks/doc-header-view",
|
|
504
614
|
pillSlot: "docblocks/doc-header-view-pill",
|
|
505
615
|
buttonAttrName: "doc-header-view-button"
|
|
@@ -508,31 +618,31 @@ function DocHeader({ doc, view, onViewChange, accessLevel = "editor", mode = "ed
|
|
|
508
618
|
options: [
|
|
509
619
|
{
|
|
510
620
|
value: "edit",
|
|
511
|
-
label: "
|
|
621
|
+
label: t("docHeader.editMode"),
|
|
512
622
|
icon: /* @__PURE__ */ jsx(Pen, { className: "size-4" })
|
|
513
623
|
},
|
|
514
624
|
{
|
|
515
625
|
value: "view",
|
|
516
|
-
label: "
|
|
626
|
+
label: t("docHeader.viewMode"),
|
|
517
627
|
icon: /* @__PURE__ */ jsx(Eye, { className: "size-4" })
|
|
518
628
|
},
|
|
519
629
|
{
|
|
520
630
|
value: "published",
|
|
521
|
-
label: "
|
|
631
|
+
label: t("docHeader.published"),
|
|
522
632
|
icon: /* @__PURE__ */ jsx(BookOpen, { className: "size-4" }),
|
|
523
633
|
disabled: publishedDoc === null || publishedDoc === void 0
|
|
524
634
|
}
|
|
525
635
|
],
|
|
526
636
|
value: effectiveMode,
|
|
527
637
|
onChange: switchMode,
|
|
528
|
-
ariaLabel: "
|
|
638
|
+
ariaLabel: t("docHeader.documentModeAria"),
|
|
529
639
|
slot: "docblocks/doc-header-mode",
|
|
530
640
|
pillSlot: "docblocks/doc-header-mode-pill",
|
|
531
641
|
buttonAttrName: "doc-header-mode-button"
|
|
532
642
|
}) : null,
|
|
533
643
|
viewMode ? /* @__PURE__ */ jsx("span", {
|
|
534
644
|
"data-slot": "docblocks/doc-header-avatar",
|
|
535
|
-
"aria-label": "
|
|
645
|
+
"aria-label": t("docHeader.documentAvatarAria"),
|
|
536
646
|
className: cn("flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full text-base font-normal", displayMeta.avatar ? "bg-muted" : "border border-dashed border-input text-muted-foreground"),
|
|
537
647
|
children: displayMeta.avatar ?? ""
|
|
538
648
|
}) : /* @__PURE__ */ jsxs(Popover, {
|
|
@@ -545,8 +655,8 @@ function DocHeader({ doc, view, onViewChange, accessLevel = "editor", mode = "ed
|
|
|
545
655
|
variant: "ghost",
|
|
546
656
|
size: "icon",
|
|
547
657
|
"data-slot": "docblocks/doc-header-avatar",
|
|
548
|
-
"aria-label": "
|
|
549
|
-
title: "
|
|
658
|
+
"aria-label": t("docHeader.editAvatarAria"),
|
|
659
|
+
title: t("docHeader.editAvatar"),
|
|
550
660
|
className: cn("size-8 shrink-0 overflow-hidden rounded-full text-base font-normal", liveMeta.avatar ? "bg-muted" : "border border-dashed border-input text-muted-foreground"),
|
|
551
661
|
children: liveMeta.avatar ? liveMeta.avatar : "+"
|
|
552
662
|
})
|
|
@@ -564,30 +674,30 @@ function DocHeader({ doc, view, onViewChange, accessLevel = "editor", mode = "ed
|
|
|
564
674
|
}),
|
|
565
675
|
titleEditing && !viewMode ? /* @__PURE__ */ jsx(InlineEditInput, {
|
|
566
676
|
initial: liveMeta.title,
|
|
567
|
-
ariaLabel: "
|
|
677
|
+
ariaLabel: t("docHeader.documentTitleAria"),
|
|
568
678
|
slot: "docblocks/doc-header-title-edit",
|
|
569
679
|
className: "\n h-auto min-w-0 flex-1 border-0 bg-background p-0 text-lg font-semibold shadow-none\n focus-visible:ring-0\n dark:bg-transparent\n ",
|
|
570
680
|
onCommit: commitTitleEdit,
|
|
571
681
|
onCancel: cancelTitleEdit
|
|
572
682
|
}) : viewMode ? /* @__PURE__ */ jsx("span", {
|
|
573
683
|
"data-slot": "docblocks/doc-header-title",
|
|
574
|
-
"aria-label": "
|
|
684
|
+
"aria-label": t("docHeader.documentTitleAria"),
|
|
575
685
|
className: "min-w-0 flex-1 truncate text-left text-lg font-semibold",
|
|
576
686
|
children: displayMeta.title || /* @__PURE__ */ jsx("span", {
|
|
577
687
|
className: "text-muted-foreground",
|
|
578
|
-
children: "
|
|
688
|
+
children: t("common:untitled")
|
|
579
689
|
})
|
|
580
690
|
}) : /* @__PURE__ */ jsx(Button, {
|
|
581
691
|
type: "button",
|
|
582
692
|
variant: "ghost",
|
|
583
693
|
"data-slot": "docblocks/doc-header-title",
|
|
584
|
-
"aria-label": "
|
|
585
|
-
title: "
|
|
694
|
+
"aria-label": t("docHeader.editTitleAria"),
|
|
695
|
+
title: t("docHeader.editTitle"),
|
|
586
696
|
onClick: beginTitleEdit,
|
|
587
697
|
className: "h-auto min-w-0 flex-1 truncate text-left text-lg font-semibold",
|
|
588
698
|
children: liveMeta.title || /* @__PURE__ */ jsx("span", {
|
|
589
699
|
className: "text-muted-foreground",
|
|
590
|
-
children: "
|
|
700
|
+
children: t("common:untitled")
|
|
591
701
|
})
|
|
592
702
|
})
|
|
593
703
|
]
|
|
@@ -638,4 +748,4 @@ const UI_FONT_STACK = "'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif
|
|
|
638
748
|
*/
|
|
639
749
|
const MONO_FONT_STACK = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace";
|
|
640
750
|
//#endregion
|
|
641
|
-
export { Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, BridgeError, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DEFAULT_EMBED_SANDBOX, DocHeader, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, EditorProvider, FORMAT_PALETTE, FilterBuilder, Input, Label, MONO_FONT_STACK, PROTOCOL_VERSION, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, TEXT_TYPES, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, badgeVariants, blobSubtypeOf, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, useSelection, useSelectionView, useText, validateProtocolDescriptor };
|
|
751
|
+
export { Alert, AlertDescription, AlertTitle, BASELINE_CAPABILITIES, BRIDGE_ERROR_CODES, Badge, BareSelect, BridgeError, Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, DEFAULT_EMBED_SANDBOX, DatabaseTable, DocHeader, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Editor, EditorProvider, FORMAT_PALETTE, FilterBuilder, Input, Label, MONO_FONT_STACK, PROTOCOL_VERSION, Popover, PopoverAnchor, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, SHAPE_FONT_OPTIONS, SHAPE_FONT_STACKS, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, TEXT_TYPES, Tabs, TabsContent, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UI_FONT_ID, UI_FONT_STACK, badgeVariants, blobSubtypeOf, buttonVariants, cellValueEqual, cn, columnAnnotation, conditionMatches, createMemoryBlobStore, emptyFilter, filterIsComplete, isBridgeError, isBridgeErrorCode, isDatabaseBridge, markToggleAction, newMutationContext, parseCellValue, renderRuns, toBridgeError, useBlock, useDatabaseTable, useDoc, useEditorContext, useMeta, usePresence, useSelection, useSelectionView, useTableList, useText, validateProtocolDescriptor };
|
package/dist/mermaid/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Gt as INLINE_CODE_CLASS, St as AlertTitle, b as Skeleton, bt as Alert, c as textOf, d as useEditorContext, ft as Eye, n as childrenSlot, pt as CodeXml, r as CodeHeader, s as TextBlock, x as SegmentSelector, xt as AlertDescription } from "../Editor-YAlRhGNW.mjs";
|
|
2
2
|
import { n as TriangleAlert } from "../constants-D4FTL0ph.mjs";
|
|
3
3
|
import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
|
|
4
|
-
import { t as Skeleton } from "../Skeleton-D922Ths5.mjs";
|
|
5
4
|
import { useEffect, useRef, useState } from "react";
|
|
6
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
7
|
import mermaid from "mermaid";
|
|
8
8
|
//#region src/mermaid/mermaid-config.ts
|
|
9
9
|
/** The mermaid renderer's config stand (the v1 security + behavior stand —
|
|
@@ -44,7 +44,7 @@ function safeId(id) {
|
|
|
44
44
|
return id.replace(/[^a-zA-Z0-9_-]/g, "");
|
|
45
45
|
}
|
|
46
46
|
//#endregion
|
|
47
|
-
//#region src/mermaid/
|
|
47
|
+
//#region src/mermaid/use-container-theme.ts
|
|
48
48
|
/** The editor's theme for one ref'd element, reactive to a theme flip:
|
|
49
49
|
* a single MutationObserver watches the `class` attribute of the
|
|
50
50
|
* element's ancestor chain (collected on mount — the preview's branch
|
|
@@ -93,6 +93,7 @@ function useContainerTheme(ref) {
|
|
|
93
93
|
/** A unique mermaid render id per attempt (mermaid requires one per render). */
|
|
94
94
|
let renderSeq = 0;
|
|
95
95
|
function MermaidDiagram({ id, text }) {
|
|
96
|
+
const { t } = useTranslation("blocks");
|
|
96
97
|
const containerRef = useRef(null);
|
|
97
98
|
const theme = useContainerTheme(containerRef);
|
|
98
99
|
const [state, setState] = useState({
|
|
@@ -165,7 +166,7 @@ function MermaidDiagram({ id, text }) {
|
|
|
165
166
|
className: "absolute inset-0 flex items-center justify-center gap-2",
|
|
166
167
|
children: [/* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }), /* @__PURE__ */ jsx("span", {
|
|
167
168
|
"data-slot": "docblocks/mermaid-loading",
|
|
168
|
-
children: "rendering
|
|
169
|
+
children: t("code.rendering")
|
|
169
170
|
})]
|
|
170
171
|
})]
|
|
171
172
|
});
|
package/dist/pdf/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as PdfPreviewProps } from "../index-
|
|
1
|
+
import { f as PdfPreviewProps } from "../index-DOKS86aH.mjs";
|
|
2
2
|
//#region src/pdf/PdfFirstPage.d.ts
|
|
3
3
|
declare function PdfFirstPage({ id, url, name }: PdfPreviewProps): import("react").JSX.Element;
|
|
4
4
|
//#endregion
|
package/dist/pdf/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { a as isSafeDownloadHref, c as cn, n as TriangleAlert, t as isEmbeddable
|
|
|
2
2
|
import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
5
6
|
import { GlobalWorkerOptions, RenderingCancelledException, getDocument } from "pdfjs-dist";
|
|
6
7
|
//#region src/pdf/pdf-worker.ts
|
|
7
8
|
/** The pdfjs-dist worker wiring (the side-effect): the worker file is
|
|
@@ -22,6 +23,9 @@ import { GlobalWorkerOptions, RenderingCancelledException, getDocument } from "p
|
|
|
22
23
|
const WORKER_URL = new URL(`./pdf.worker.min.mjs`, import.meta.url);
|
|
23
24
|
GlobalWorkerOptions.workerSrc = WORKER_URL.toString();
|
|
24
25
|
const WASM_URL = new URL("./", WORKER_URL).toString();
|
|
26
|
+
if (typeof window !== "undefined") fetch(WORKER_URL, { method: "HEAD" }).catch(() => {
|
|
27
|
+
console.warn("docblocks: the pdf worker's asset is unreachable over this entry — the pdf preview stands the native viewer's fallback (the worker's load fails). The dist/pdf/ directory must stand served as static assets next to the subpath's entry.");
|
|
28
|
+
});
|
|
25
29
|
//#endregion
|
|
26
30
|
//#region src/pdf/PdfFirstPage.tsx
|
|
27
31
|
/** The first-page preview of one `pdf`-subtype image block: fetch the
|
|
@@ -33,6 +37,7 @@ const WASM_URL = new URL("./", WORKER_URL).toString();
|
|
|
33
37
|
* so a torn-down preview leaves no network request or pdf.js worker
|
|
34
38
|
* behind. */
|
|
35
39
|
function PdfFirstPage({ id, url, name }) {
|
|
40
|
+
const { t } = useTranslation("blocks");
|
|
36
41
|
const canvasRef = useRef(null);
|
|
37
42
|
const loadingTaskRef = useRef(null);
|
|
38
43
|
const renderTaskRef = useRef(null);
|
|
@@ -111,13 +116,9 @@ function PdfFirstPage({ id, url, name }) {
|
|
|
111
116
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
112
117
|
"data-slot": "docblocks/image-pdf-error",
|
|
113
118
|
className: "\n mb-2 flex items-center gap-2 rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color) bg-(--muted) px-3 py-2 text-sm text-(--muted-foreground)\n ",
|
|
114
|
-
children: [/* @__PURE__ */ jsx(TriangleAlert, { className: "size-4 shrink-0" }), /* @__PURE__ */
|
|
119
|
+
children: [/* @__PURE__ */ jsx(TriangleAlert, { className: "size-4 shrink-0" }), /* @__PURE__ */ jsx("span", {
|
|
115
120
|
className: "min-w-0 flex-1 truncate",
|
|
116
|
-
children:
|
|
117
|
-
"PDF preview unavailable (",
|
|
118
|
-
error,
|
|
119
|
-
"). Showing the built-in viewer."
|
|
120
|
-
]
|
|
121
|
+
children: t("code.pdfPreviewUnavailable", { error })
|
|
121
122
|
})]
|
|
122
123
|
}), isEmbeddablePdfUrl(url) ? /* @__PURE__ */ jsx("iframe", {
|
|
123
124
|
"data-slot": "docblocks/image-pdf",
|
|
@@ -155,7 +156,7 @@ function PdfFirstPage({ id, url, name }) {
|
|
|
155
156
|
className: "flex h-48 w-full items-center justify-center gap-2 text-sm text-(--muted-foreground)",
|
|
156
157
|
children: [/* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" }), /* @__PURE__ */ jsx("span", {
|
|
157
158
|
"data-slot": "docblocks/image-pdf-loading",
|
|
158
|
-
children: "
|
|
159
|
+
children: t("code.pdfLoading")
|
|
159
160
|
})]
|
|
160
161
|
})]
|
|
161
162
|
});
|