docblocks-react-ui 0.13.0 → 0.15.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 +81 -0
- package/dist/{Editor-dcSgC9ho.mjs → Editor-BF7wBMcp.mjs} +760 -600
- package/dist/{index-BA6ZzJK8.d.mts → index-C3vzW1Mv.d.mts} +181 -148
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +74 -18
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +31 -2
- package/package.json +1 -1
|
@@ -2,6 +2,32 @@ import { n as BlockRendererMap } from "./index-YJcgf8Hh.mjs";
|
|
|
2
2
|
import { ComponentType, ReactNode } from "react";
|
|
3
3
|
import { AttributeType, Block, BlockContent, BlockId, BlockType, CanvasTextAttrs, Change, ConnectorAttrs, DatabaseFilterPayload, Doc, DocAttributeValue, DocMeta, Geometry, MentionKind, MentionMark, PresenceSelection, PresenceState, Selection, SelectionView, ShapeAttrs, SyncEmbedRef, SyncProvider } from "docblocks-core";
|
|
4
4
|
import { StoreApi } from "zustand/vanilla";
|
|
5
|
+
//#region src/editor-provider/models/attributes.d.ts
|
|
6
|
+
/** The props an attribute-value renderer receives (the `renderAttribute` provider prop). */
|
|
7
|
+
interface RenderAttributeProps {
|
|
8
|
+
/** The attribute's key (the preset key or the custom key). */
|
|
9
|
+
key: string;
|
|
10
|
+
/** The attribute's current value (`undefined` when unset). */
|
|
11
|
+
value: DocAttributeValue | undefined;
|
|
12
|
+
/** The write commit (one `setAttribute`). */
|
|
13
|
+
onChange: (value: DocAttributeValue) => void;
|
|
14
|
+
/** The removal commit (one `removeAttribute`). */
|
|
15
|
+
onRemove: () => void;
|
|
16
|
+
/** The read-only stand (the view / published's modes): display-only. */
|
|
17
|
+
readOnly: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** The consumer's per-key attribute-value renderer (the `renderAttribute` provider prop): the value zone of a named row (a preset or a custom key); `null` / the absent stand the built-in editor. */
|
|
20
|
+
type RenderAttribute = (props: RenderAttributeProps) => ReactNode;
|
|
21
|
+
/** The props an attribute type-picker receives (the `attributeTypePicker` provider prop). */
|
|
22
|
+
interface AttributeTypePickerProps {
|
|
23
|
+
/** The selected type (the panel's pick — the default `"string"` over the add's popover). */
|
|
24
|
+
value: AttributeType;
|
|
25
|
+
/** Commits the type pick (the built-in picker's enum is `ATTRIBUTE_TYPES`). */
|
|
26
|
+
onChange: (type: AttributeType) => void;
|
|
27
|
+
}
|
|
28
|
+
/** The consumer's replacement of the default type picker (the `attributeTypePicker` provider prop): the custom-attribute's add popover's type selection. The built-in's enum (`ATTRIBUTE_TYPES`) is the shared vocabulary. */
|
|
29
|
+
type AttributeTypePicker = ComponentType<AttributeTypePickerProps>;
|
|
30
|
+
//#endregion
|
|
5
31
|
//#region src/blob-store.d.ts
|
|
6
32
|
/**
|
|
7
33
|
* The blob bridge: the library does not own storage. Documents hold only an
|
|
@@ -802,6 +828,40 @@ declare function DatabaseTable({ bridge, tableId, readOnly, view, onViewChange,
|
|
|
802
828
|
*/
|
|
803
829
|
declare function useTableList(bridge: DatabaseBridge): UseTableList;
|
|
804
830
|
//#endregion
|
|
831
|
+
//#region src/canvas/clipboard/models.d.ts
|
|
832
|
+
/** The one copied canvas item (the deep data; the ids stand the originals). */
|
|
833
|
+
type ClipboardItem = {
|
|
834
|
+
type: "shape";
|
|
835
|
+
attrs?: ShapeAttrs;
|
|
836
|
+
geometry?: Geometry;
|
|
837
|
+
} | {
|
|
838
|
+
type: "connector";
|
|
839
|
+
attrs: ConnectorAttrs;
|
|
840
|
+
geometry?: Geometry;
|
|
841
|
+
} | {
|
|
842
|
+
type: "canvas-text";
|
|
843
|
+
attrs?: CanvasTextAttrs;
|
|
844
|
+
content?: BlockContent;
|
|
845
|
+
geometry?: Geometry;
|
|
846
|
+
} | {
|
|
847
|
+
type: "group";
|
|
848
|
+
attrs: {
|
|
849
|
+
members: BlockId[];
|
|
850
|
+
title?: string;
|
|
851
|
+
};
|
|
852
|
+
geometry?: Geometry;
|
|
853
|
+
};
|
|
854
|
+
/** The deep copy of the copied canvas items (the ids stand the originals). */
|
|
855
|
+
interface CanvasClipboard {
|
|
856
|
+
/** The copied items with the original ids (top-level + the containers' transitive members). */
|
|
857
|
+
entries: {
|
|
858
|
+
id: BlockId;
|
|
859
|
+
item: ClipboardItem;
|
|
860
|
+
}[];
|
|
861
|
+
/** The top-level ids (the selection order) — the paste's selection stand. */
|
|
862
|
+
ids: BlockId[];
|
|
863
|
+
}
|
|
864
|
+
//#endregion
|
|
805
865
|
//#region src/presence/models.d.ts
|
|
806
866
|
/** The local selection's sharing grant: no sharing, sharing over the whole
|
|
807
867
|
* room (plaintext), or a targeted user-id list (encrypted per target). */
|
|
@@ -846,40 +906,6 @@ interface PresenceIdentity {
|
|
|
846
906
|
name?: string;
|
|
847
907
|
}
|
|
848
908
|
//#endregion
|
|
849
|
-
//#region src/canvas/clipboard/models.d.ts
|
|
850
|
-
/** The one copied canvas item (the deep data; the ids stand the originals). */
|
|
851
|
-
type ClipboardItem = {
|
|
852
|
-
type: "shape";
|
|
853
|
-
attrs?: ShapeAttrs;
|
|
854
|
-
geometry?: Geometry;
|
|
855
|
-
} | {
|
|
856
|
-
type: "connector";
|
|
857
|
-
attrs: ConnectorAttrs;
|
|
858
|
-
geometry?: Geometry;
|
|
859
|
-
} | {
|
|
860
|
-
type: "canvas-text";
|
|
861
|
-
attrs?: CanvasTextAttrs;
|
|
862
|
-
content?: BlockContent;
|
|
863
|
-
geometry?: Geometry;
|
|
864
|
-
} | {
|
|
865
|
-
type: "group";
|
|
866
|
-
attrs: {
|
|
867
|
-
members: BlockId[];
|
|
868
|
-
title?: string;
|
|
869
|
-
};
|
|
870
|
-
geometry?: Geometry;
|
|
871
|
-
};
|
|
872
|
-
/** The deep copy of the copied canvas items (the ids stand the originals). */
|
|
873
|
-
interface CanvasClipboard {
|
|
874
|
-
/** The copied items with the original ids (top-level + the containers' transitive members). */
|
|
875
|
-
entries: {
|
|
876
|
-
id: BlockId;
|
|
877
|
-
item: ClipboardItem;
|
|
878
|
-
}[];
|
|
879
|
-
/** The top-level ids (the selection order) — the paste's selection stand. */
|
|
880
|
-
ids: BlockId[];
|
|
881
|
-
}
|
|
882
|
-
//#endregion
|
|
883
909
|
//#region src/state/models.d.ts
|
|
884
910
|
/**
|
|
885
911
|
* The slash File command's upload stand: the block the skeleton stands on
|
|
@@ -998,28 +1024,7 @@ interface EditorActions {
|
|
|
998
1024
|
/** The per-instance vanilla store created by `createEditorStore`. */
|
|
999
1025
|
type EditorStore = StoreApi<EditorState & EditorActions>;
|
|
1000
1026
|
//#endregion
|
|
1001
|
-
//#region src/editor-provider/models.d.ts
|
|
1002
|
-
/**
|
|
1003
|
-
* Resolves a sync-embed ref to the master doc the consumer holds; null when
|
|
1004
|
-
* the master is unknown to the consumer (the block renders its broken state).
|
|
1005
|
-
*/
|
|
1006
|
-
type SyncEmbedResolver = (ref: SyncEmbedRef) => Doc | null;
|
|
1007
|
-
/** The embed sandbox policy: the iframe's `sandbox` value for a given embed
|
|
1008
|
-
* src; `null` stands no sandbox (a fully trusted embed, the old behavior). */
|
|
1009
|
-
type EmbedSandboxPolicy = (src: string) => string | null;
|
|
1010
|
-
/** The props a PDF first-page preview renderer receives (the `pdfPreview` provider prop). */
|
|
1011
|
-
interface PdfPreviewProps {
|
|
1012
|
-
/** The block's id — the renderer stamps it on its root, like the other block renderers. */
|
|
1013
|
-
id: BlockId;
|
|
1014
|
-
/** The owning block type (file for new PDFs, image for legacy PDF blocks). */
|
|
1015
|
-
blockType: "file" | "image";
|
|
1016
|
-
/** The library-owned object URL for the PDF bytes. */
|
|
1017
|
-
url: string;
|
|
1018
|
-
/** The store's authoritative display name. */
|
|
1019
|
-
name: string;
|
|
1020
|
-
}
|
|
1021
|
-
/** A PDF first-page preview renderer: a component over a resolved `pdf` blob. */
|
|
1022
|
-
type PdfPreview = ComponentType<PdfPreviewProps>;
|
|
1027
|
+
//#region src/editor-provider/models/mentions.d.ts
|
|
1023
1028
|
/** A mention search result: the stable target id + the display label. */
|
|
1024
1029
|
interface MentionEntry {
|
|
1025
1030
|
id: string;
|
|
@@ -1074,6 +1079,18 @@ interface MentionInteractions {
|
|
|
1074
1079
|
*/
|
|
1075
1080
|
renderEmptyState?: (query: string) => ReactNode | null;
|
|
1076
1081
|
}
|
|
1082
|
+
//#endregion
|
|
1083
|
+
//#region src/editor-provider/models/modes.d.ts
|
|
1084
|
+
/** The access stand: the consumer's user access level and the document
|
|
1085
|
+
* mode (consumer session state, never document data). */
|
|
1086
|
+
/** The consumer's user access level: the available document modes. "viewer" is locked to the published's view (the current state is never rendered); "editor" (the default) may edit and view. Session state — not document data, never on the wire. */
|
|
1087
|
+
type AccessLevel = "viewer" | "editor";
|
|
1088
|
+
/** The document's mode (consumer-controlled view state, like the page/canvas `view`): "edit" (the default) is the live document editable; "view" is the live document read-only (the current state, still syncing) with its text selectable and copyable; "published" is the `publishedDoc`'s snapshot read-only (static) with no selection and no copy. */
|
|
1089
|
+
type EditorMode = "edit" | "view" | "published";
|
|
1090
|
+
//#endregion
|
|
1091
|
+
//#region src/editor-provider/models/panels.d.ts
|
|
1092
|
+
/** The document-attributes panel's consumer-owned contracts: the tags,
|
|
1093
|
+
* the description, and the cover preset gallery. */
|
|
1077
1094
|
/**
|
|
1078
1095
|
* A consumer-owned tag entry (the consumer's tag catalog): the stable id
|
|
1079
1096
|
* (the removal / the event's identity) + the display label (the default
|
|
@@ -1164,44 +1181,23 @@ interface CoverPresetSets {
|
|
|
1164
1181
|
/** The centering mode's preset's file ids; `[]` / the absent stands no grid over the centering's stand. */
|
|
1165
1182
|
center?: readonly string[];
|
|
1166
1183
|
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
/** The
|
|
1172
|
-
|
|
1173
|
-
/** The
|
|
1174
|
-
|
|
1175
|
-
/** The
|
|
1176
|
-
|
|
1177
|
-
/** The
|
|
1178
|
-
|
|
1179
|
-
}
|
|
1180
|
-
/** The consumer's per-key attribute-value renderer (the `renderAttribute` provider prop): the value zone of a named row (a preset or a custom key); `null` / the absent stand the built-in editor. */
|
|
1181
|
-
type RenderAttribute = (props: RenderAttributeProps) => ReactNode;
|
|
1182
|
-
/** The props an attribute type-picker receives (the `attributeTypePicker` provider prop). */
|
|
1183
|
-
interface AttributeTypePickerProps {
|
|
1184
|
-
/** The selected type (the panel's pick — the default `"string"` over the add's popover). */
|
|
1185
|
-
value: AttributeType;
|
|
1186
|
-
/** Commits the type pick (the built-in picker's enum is `ATTRIBUTE_TYPES`). */
|
|
1187
|
-
onChange: (type: AttributeType) => void;
|
|
1188
|
-
}
|
|
1189
|
-
/** The consumer's replacement of the default type picker (the `attributeTypePicker` provider prop): the custom-attribute's add popover's type selection. The built-in's enum (`ATTRIBUTE_TYPES`) is the shared vocabulary. */
|
|
1190
|
-
type AttributeTypePicker = ComponentType<AttributeTypePickerProps>;
|
|
1191
|
-
/** The per-instance selection view; null before the mount effect ran and after unmount. */
|
|
1192
|
-
interface SelectionRef {
|
|
1193
|
-
view: SelectionView | null;
|
|
1194
|
-
/**
|
|
1195
|
-
* The history reseat's window end (the epoch ms): the undo/redo's remount
|
|
1196
|
-
* stands the engine's transient selection loss, and the gesture-time and
|
|
1197
|
-
* event-based mappings' none push stands the remount's residue over the
|
|
1198
|
-
* window (not the user's clear — the real clear stands the explicit
|
|
1199
|
-
* paths: the Escape, the editor's outside's focus).
|
|
1200
|
-
*/
|
|
1201
|
-
reseatUntil: {
|
|
1202
|
-
current: number;
|
|
1203
|
-
};
|
|
1184
|
+
//#endregion
|
|
1185
|
+
//#region src/editor-provider/models/pdf.d.ts
|
|
1186
|
+
/** The props a PDF first-page preview renderer receives (the `pdfPreview` provider prop). */
|
|
1187
|
+
interface PdfPreviewProps {
|
|
1188
|
+
/** The block's id — the renderer stamps it on its root, like the other block renderers. */
|
|
1189
|
+
id: BlockId;
|
|
1190
|
+
/** The owning block type (file for new PDFs, image for legacy PDF blocks). */
|
|
1191
|
+
blockType: "file" | "image";
|
|
1192
|
+
/** The library-owned object URL for the PDF bytes. */
|
|
1193
|
+
url: string;
|
|
1194
|
+
/** The store's authoritative display name. */
|
|
1195
|
+
name: string;
|
|
1204
1196
|
}
|
|
1197
|
+
/** A PDF first-page preview renderer: a component over a resolved `pdf` blob. */
|
|
1198
|
+
type PdfPreview = ComponentType<PdfPreviewProps>;
|
|
1199
|
+
//#endregion
|
|
1200
|
+
//#region src/editor-provider/models/presence.d.ts
|
|
1205
1201
|
/**
|
|
1206
1202
|
* The local user's presence identity and the selection-sharing cipher
|
|
1207
1203
|
* (consumer session state — never document data). Without `userId` the
|
|
@@ -1223,10 +1219,34 @@ interface PresenceConfig {
|
|
|
1223
1219
|
*/
|
|
1224
1220
|
crypto?: PresenceCrypto;
|
|
1225
1221
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
/** The
|
|
1229
|
-
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region src/editor-provider/models/selection.d.ts
|
|
1224
|
+
/** The per-instance selection view; null before the mount effect ran and after unmount. */
|
|
1225
|
+
interface SelectionRef {
|
|
1226
|
+
view: SelectionView | null;
|
|
1227
|
+
/**
|
|
1228
|
+
* The history reseat's window end (the epoch ms): the undo/redo's remount
|
|
1229
|
+
* stands the engine's transient selection loss, and the gesture-time and
|
|
1230
|
+
* event-based mappings' none push stands the remount's residue over the
|
|
1231
|
+
* window (not the user's clear — the real clear stands the explicit
|
|
1232
|
+
* paths: the Escape, the editor's outside's focus).
|
|
1233
|
+
*/
|
|
1234
|
+
reseatUntil: {
|
|
1235
|
+
current: number;
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
//#endregion
|
|
1239
|
+
//#region src/editor-provider/models/sync-embed.d.ts
|
|
1240
|
+
/**
|
|
1241
|
+
* Resolves a sync-embed ref to the master doc the consumer holds; null when
|
|
1242
|
+
* the master is unknown to the consumer (the block renders its broken state).
|
|
1243
|
+
*/
|
|
1244
|
+
type SyncEmbedResolver = (ref: SyncEmbedRef) => Doc | null;
|
|
1245
|
+
/** The embed sandbox policy: the iframe's `sandbox` value for a given embed
|
|
1246
|
+
* src; `null` stands no sandbox (a fully trusted embed, the old behavior). */
|
|
1247
|
+
type EmbedSandboxPolicy = (src: string) => string | null;
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region src/editor-provider/models/context.d.ts
|
|
1230
1250
|
/** Per-instance editor context: the store, the doc, the selection handle, and the customization values. */
|
|
1231
1251
|
interface EditorContextValue {
|
|
1232
1252
|
store: EditorStore;
|
|
@@ -1280,15 +1300,9 @@ interface EditorContextValue {
|
|
|
1280
1300
|
/** The presence identity + cipher (the provider's `presence` prop); null when none was supplied (the legacy's anonymous stand). */
|
|
1281
1301
|
presence: PresenceConfig | null;
|
|
1282
1302
|
}
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
* Required over the editor's stand. Over the `viewer`'s stand the doc IS
|
|
1287
|
-
* the published snapshot — the consumer passes only the stand the reader
|
|
1288
|
-
* may see (the live document never reaches the reader's browser); an
|
|
1289
|
-
* absent stand over the viewer renders the not-published placeholder.
|
|
1290
|
-
*/
|
|
1291
|
-
doc?: Doc;
|
|
1303
|
+
//#endregion
|
|
1304
|
+
//#region src/editor-provider/models/props-access.d.ts
|
|
1305
|
+
interface EditorProviderAccessProps {
|
|
1292
1306
|
/**
|
|
1293
1307
|
* Optional user access level: "viewer" locks the render to the
|
|
1294
1308
|
* published's view (the `mode`'s stand is ignored — the current state is
|
|
@@ -1315,6 +1329,34 @@ interface EditorProviderProps {
|
|
|
1315
1329
|
* snapshot is a consumer remount over a `key` change.
|
|
1316
1330
|
*/
|
|
1317
1331
|
publishedDoc?: Doc | null;
|
|
1332
|
+
/**
|
|
1333
|
+
* Optional presence identity + the selection-sharing cipher (consumer
|
|
1334
|
+
* session state, never document data): the local user's stable `userId`
|
|
1335
|
+
* (the addressable identity on the wire), the optional roster label, and
|
|
1336
|
+
* the optional `PresenceCrypto` cipher (without it a targeted grant
|
|
1337
|
+
* degrades to "off" / "everyone": the hook's setter stands a no-op over
|
|
1338
|
+
* a targeted grant without the identity or the cipher). With the prop
|
|
1339
|
+
* the selection sharing grant is session state
|
|
1340
|
+
* driven through `usePresenceSharing()` (the default "off" — the
|
|
1341
|
+
* privacy stand); without it the provider keeps the legacy stand (the
|
|
1342
|
+
* anonymous plaintext selection — always shared over the room).
|
|
1343
|
+
*
|
|
1344
|
+
* Like the other customization values, the value is read per render:
|
|
1345
|
+
* pass a stable reference.
|
|
1346
|
+
*/
|
|
1347
|
+
presence?: PresenceConfig;
|
|
1348
|
+
}
|
|
1349
|
+
//#endregion
|
|
1350
|
+
//#region src/editor-provider/models/props-base.d.ts
|
|
1351
|
+
interface EditorProviderBaseProps {
|
|
1352
|
+
/**
|
|
1353
|
+
* The headless document to render and edit; must not change after mount.
|
|
1354
|
+
* Required over the editor's stand. Over the `viewer`'s stand the doc IS
|
|
1355
|
+
* the published snapshot — the consumer passes only the stand the reader
|
|
1356
|
+
* may see (the live document never reaches the reader's browser); an
|
|
1357
|
+
* absent stand over the viewer renders the not-published placeholder.
|
|
1358
|
+
*/
|
|
1359
|
+
doc?: Doc;
|
|
1318
1360
|
/** Optional sync transport for presence (awareness); the doc's own changes are always tracked. */
|
|
1319
1361
|
provider?: SyncProvider;
|
|
1320
1362
|
/**
|
|
@@ -1348,6 +1390,35 @@ interface EditorProviderProps {
|
|
|
1348
1390
|
* none inherits the enclosing bridge.
|
|
1349
1391
|
*/
|
|
1350
1392
|
databaseBridge?: DatabaseBridge;
|
|
1393
|
+
/**
|
|
1394
|
+
* Optional PDF first-page preview renderer for file blocks and legacy PDF
|
|
1395
|
+
* image blocks. The component receives the library-owned object URL and the
|
|
1396
|
+
* store's authoritative metadata. Without it the native iframe stands.
|
|
1397
|
+
*
|
|
1398
|
+
* Like `blockRenderers`, the value is read per render into the provider
|
|
1399
|
+
* context: pass a stable reference (the component is module-level). A
|
|
1400
|
+
* nested provider that supplies none inherits the enclosing one.
|
|
1401
|
+
*/
|
|
1402
|
+
pdfPreview?: PdfPreview;
|
|
1403
|
+
/**
|
|
1404
|
+
* Optional entry-list root: render the entry list of this block instead
|
|
1405
|
+
* of the document root (the subtree view — the block itself plus its own
|
|
1406
|
+
* subtree). Defaults to the document root: behavior unchanged.
|
|
1407
|
+
*
|
|
1408
|
+
* Like `doc`, the value must not change after mount.
|
|
1409
|
+
*/
|
|
1410
|
+
rootBlockId?: BlockId;
|
|
1411
|
+
/**
|
|
1412
|
+
* The command palette placeholder override, shown while the caret sits in
|
|
1413
|
+
* an empty text block. The default comes from the editor locale. A nested
|
|
1414
|
+
* provider that supplies none inherits the enclosing override.
|
|
1415
|
+
*/
|
|
1416
|
+
commandPalettePlaceholder?: string;
|
|
1417
|
+
children: ReactNode;
|
|
1418
|
+
}
|
|
1419
|
+
//#endregion
|
|
1420
|
+
//#region src/editor-provider/models/props-customization.d.ts
|
|
1421
|
+
interface EditorProviderCustomizationProps {
|
|
1351
1422
|
/**
|
|
1352
1423
|
* Optional resolver of a sync-embed's ref to the master Doc (the consumer
|
|
1353
1424
|
* holds the master in its own store); without it the built-in renderer
|
|
@@ -1359,16 +1430,6 @@ interface EditorProviderProps {
|
|
|
1359
1430
|
* sync-embed inside a rendered master must resolve too).
|
|
1360
1431
|
*/
|
|
1361
1432
|
syncEmbedResolver?: SyncEmbedResolver;
|
|
1362
|
-
/**
|
|
1363
|
-
* Optional PDF first-page preview renderer for file blocks and legacy PDF
|
|
1364
|
-
* image blocks. The component receives the library-owned object URL and the
|
|
1365
|
-
* store's authoritative metadata. Without it the native iframe stands.
|
|
1366
|
-
*
|
|
1367
|
-
* Like `blockRenderers`, the value is read per render into the provider
|
|
1368
|
-
* context: pass a stable reference (the component is module-level). A
|
|
1369
|
-
* nested provider that supplies none inherits the enclosing one.
|
|
1370
|
-
*/
|
|
1371
|
-
pdfPreview?: PdfPreview;
|
|
1372
1433
|
/**
|
|
1373
1434
|
* Optional mention search provider: the user / document catalog behind the
|
|
1374
1435
|
* `@` mention trigger in page text blocks. Without it the `@` stays plain
|
|
@@ -1488,39 +1549,11 @@ interface EditorProviderProps {
|
|
|
1488
1549
|
* inherits the enclosing policy.
|
|
1489
1550
|
*/
|
|
1490
1551
|
embedSandbox?: EmbedSandboxPolicy;
|
|
1491
|
-
/**
|
|
1492
|
-
* Optional entry-list root: render the entry list of this block instead
|
|
1493
|
-
* of the document root (the subtree view — the block itself plus its own
|
|
1494
|
-
* subtree). Defaults to the document root: behavior unchanged.
|
|
1495
|
-
*
|
|
1496
|
-
* Like `doc`, the value must not change after mount.
|
|
1497
|
-
*/
|
|
1498
|
-
rootBlockId?: BlockId;
|
|
1499
|
-
/**
|
|
1500
|
-
* The command palette placeholder override, shown while the caret sits in
|
|
1501
|
-
* an empty text block. The default comes from the editor locale. A nested
|
|
1502
|
-
* provider that supplies none inherits the enclosing override.
|
|
1503
|
-
*/
|
|
1504
|
-
commandPalettePlaceholder?: string;
|
|
1505
|
-
/**
|
|
1506
|
-
* Optional presence identity + the selection-sharing cipher (consumer
|
|
1507
|
-
* session state, never document data): the local user's stable `userId`
|
|
1508
|
-
* (the addressable identity on the wire), the optional roster label, and
|
|
1509
|
-
* the optional `PresenceCrypto` cipher (without it a targeted grant
|
|
1510
|
-
* degrades to "off" / "everyone": the hook's setter stands a no-op over
|
|
1511
|
-
* a targeted grant without the identity or the cipher). With the prop
|
|
1512
|
-
* the selection sharing grant is session state
|
|
1513
|
-
* driven through `usePresenceSharing()` (the default "off" — the
|
|
1514
|
-
* privacy stand); without it the provider keeps the legacy stand (the
|
|
1515
|
-
* anonymous plaintext selection — always shared over the room).
|
|
1516
|
-
*
|
|
1517
|
-
* Like the other customization values, the value is read per render:
|
|
1518
|
-
* pass a stable reference.
|
|
1519
|
-
*/
|
|
1520
|
-
presence?: PresenceConfig;
|
|
1521
|
-
children: ReactNode;
|
|
1522
1552
|
}
|
|
1523
1553
|
//#endregion
|
|
1554
|
+
//#region src/editor-provider/models/props.d.ts
|
|
1555
|
+
interface EditorProviderProps extends EditorProviderBaseProps, EditorProviderCustomizationProps, EditorProviderAccessProps {}
|
|
1556
|
+
//#endregion
|
|
1524
1557
|
//#region src/editor-provider/EditorProvider.d.ts
|
|
1525
1558
|
/**
|
|
1526
1559
|
* The provider's entry: resolves the viewer's top-level stand before the
|
|
@@ -1552,4 +1585,4 @@ declare const DEFAULT_EMBED_SANDBOX = "allow-scripts allow-same-origin allow-for
|
|
|
1552
1585
|
/** Read the per-instance editor context; throws outside an EditorProvider. */
|
|
1553
1586
|
declare function useEditorContext(): EditorContextValue;
|
|
1554
1587
|
//#endregion
|
|
1555
|
-
export {
|
|
1588
|
+
export { MutationReceipt as $, UseTableList as A, AttributeTypePicker as At, BridgeColumnAnnotation as B, PresencePeer as C, isBridgeError as Ct, DatabaseTable as D, BlobRef as Dt, useTableList as E, BlobMeta as Et, emptyFilter as F, Column as G, BridgeValueInput as H, filterIsComplete as I, FilterConditionInput as J, DatabaseBridge as K, FilterBuilder as L, DatabaseTablePhase as M, RenderAttribute as Mt, DatabaseTableRow as N, RenderAttributeProps as Nt, DatabaseTableProps as O, BlobStore as Ot, UseDatabaseTable as P, MutationContext as Q, BatchOp as R, PresenceIdentity as S, BridgeErrorCode as St, PresenceSharingMode as T, toBridgeError as Tt, CellMap as U, BridgeTableDescription as V, CellValueParse as W, Id as X, FilterInput as Y, IsoInstant as Z, EditorMode as _, TableEvent as _t, EditorContextValue as a, ProtocolLimits as at, MentionProvider as b, BRIDGE_ERROR_CODES as bt, SelectionRef as c, Revision as ct, PdfPreviewProps as d, SortInput as dt, OperationStatus as et, CoverPresetSets as f, SubscriptionHandle as ft, AccessLevel as g, TableEnvelopeBase as gt, DocTags as h, TableDescription as ht, EditorProviderProps as i, ProtocolDescriptor as it, useDatabaseTable as j, AttributeTypePickerProps as jt, DatabaseTableView as k, createMemoryBlobStore as kt, PresenceConfig as l, RowPage as lt, DocTag as m, SubscriptionStatus as mt, DEFAULT_EMBED_SANDBOX as n, PageSnapshot as nt, EmbedSandboxPolicy as o, QueryOperator as ot, DocDescription as p, SubscriptionObserver as pt, DomainEvent as q, EditorProvider as r, ProtocolCapability as rt, SyncEmbedResolver as s, QuerySemantics as st, useEditorContext as t, PageQuery as tt, PdfPreview as u, RowWire as ut, MentionEntry as v, TableRef as vt, PresenceSharing as w, isBridgeErrorCode as wt, PresenceCrypto as x, BridgeError as xt, MentionInteractions as y, TableSnapshot as yt, BridgeColumn as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as BlockRendererMap, r as BlockRendererProps, t as BlockRenderer } from "./index-YJcgf8Hh.mjs";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as MutationReceipt, A as UseTableList, At as AttributeTypePicker, B as BridgeColumnAnnotation, C as PresencePeer, Ct as isBridgeError, D as DatabaseTable, Dt as BlobRef, E as useTableList, Et as BlobMeta, F as emptyFilter, G as Column, H as BridgeValueInput, I as filterIsComplete, J as FilterConditionInput, K as DatabaseBridge, L as FilterBuilder, M as DatabaseTablePhase, Mt as RenderAttribute, N as DatabaseTableRow, Nt as RenderAttributeProps, O as DatabaseTableProps, Ot as BlobStore, P as UseDatabaseTable, Q as MutationContext, R as BatchOp, S as PresenceIdentity, St as BridgeErrorCode, T as PresenceSharingMode, Tt as toBridgeError, U as CellMap, V as BridgeTableDescription, W as CellValueParse, X as Id, Y as FilterInput, Z as IsoInstant, _ as EditorMode, _t as TableEvent, a as EditorContextValue, at as ProtocolLimits, b as MentionProvider, bt as BRIDGE_ERROR_CODES, c as SelectionRef, ct as Revision, d as PdfPreviewProps, dt as SortInput, et as OperationStatus, f as CoverPresetSets, ft as SubscriptionHandle, g as AccessLevel, gt as TableEnvelopeBase, h as DocTags, ht as TableDescription, i as EditorProviderProps, it as ProtocolDescriptor, j as useDatabaseTable, jt as AttributeTypePickerProps, k as DatabaseTableView, kt as createMemoryBlobStore, l as PresenceConfig, lt as RowPage, m as DocTag, mt as SubscriptionStatus, n as DEFAULT_EMBED_SANDBOX, nt as PageSnapshot, o as EmbedSandboxPolicy, ot as QueryOperator, p as DocDescription, pt as SubscriptionObserver, q as DomainEvent, r as EditorProvider, rt as ProtocolCapability, s as SyncEmbedResolver, st as QuerySemantics, t as useEditorContext, tt as PageQuery, u as PdfPreview, ut as RowWire, v as MentionEntry, vt as TableRef, w as PresenceSharing, wt as isBridgeErrorCode, x as PresenceCrypto, xt as BridgeError, y as MentionInteractions, yt as TableSnapshot, z as BridgeColumn } from "./index-C3vzW1Mv.mjs";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { AttributeType, Block, BlockId, BlockType, Doc, DocMeta, MentionKind, MentionMark, PresenceState, Selection, SelectionView, SyncEmbedRef, TextRun, TypedAttributeValue } from "docblocks-core";
|
|
@@ -356,7 +356,7 @@ declare function AlertDescription({ className, ...props }: React$1.ComponentProp
|
|
|
356
356
|
//#endregion
|
|
357
357
|
//#region src/shared/ui/Badge.d.ts
|
|
358
358
|
declare const badgeVariants: (props?: ({
|
|
359
|
-
variant?: "default" | "
|
|
359
|
+
variant?: "default" | "custom" | "secondary" | "destructive" | "outline" | null | undefined;
|
|
360
360
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
361
361
|
declare function Badge({ className, variant, asChild, ...props }: React$1.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
362
362
|
asChild?: boolean;
|
|
@@ -367,7 +367,7 @@ declare function BareSelect({ className, children, ...props }: React$1.Component
|
|
|
367
367
|
//#endregion
|
|
368
368
|
//#region src/shared/ui/Button.d.ts
|
|
369
369
|
declare const buttonVariants: (props?: ({
|
|
370
|
-
variant?: "link" | "default" | "
|
|
370
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
371
371
|
size?: "default" | "icon" | "sm" | "lg" | "xl" | null | undefined;
|
|
372
372
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
373
373
|
declare function Button({ className, variant, size, asChild, type, ...props }: React$1.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as DropdownMenuSubContent, $t as Eye, A as SelectGroup, At as Skeleton, B as Input, Bt as useBlock, C as FilterBuilder, Ct as isBridgeError, D as ScrollArea, Dt as parseCellValue, E as SegmentSelector, Et as conditionMatches, F as SelectSeparator, Ft as CardFooter, G as DropdownMenuItem, Gt as useSelection, H as DropdownMenuCheckboxItem, Ht as useMeta, I as SelectTrigger, It as CardHeader, J as DropdownMenuRadioGroup, Jt as DocblocksI18nProvider, K as DropdownMenuLabel, Kt as useSelectionView, L as SelectValue, Lt as CardTitle, M as SelectLabel, Mt as CardAction, N as SelectScrollDownButton, Nt as CardContent, O as Select, Ot as TEXT_TYPES, P as SelectScrollUpButton, Pt as CardDescription, Q as DropdownMenuSub, Qt as Pen, R as Label, Rt as Badge, S as newMutationContext, St as BridgeError, T as filterIsComplete, Tt as toBridgeError, U as DropdownMenuContent, Ut as usePresence, V as DropdownMenu, Vt as useDoc, W as DropdownMenuGroup, Wt as usePresenceSharing, X as DropdownMenuSeparator, Xt as renderRuns, Y as DropdownMenuRadioItem, Z as DropdownMenuShortcut, _ as mapFrontmatter, _t as BASELINE_CAPABILITIES, a as DEFAULT_EMBED_SANDBOX, at as PopoverContent, b as useDatabaseTable, bt as validateProtocolDescriptor, c as SHAPE_FONT_OPTIONS, ct as PopoverTitle, d as FORMAT_PALETTE, dt as Button, et as DropdownMenuSubTrigger, ft as buttonVariants, g as mdToBlocks, gt as AlertTitle, h as insertNative, ht as AlertDescription, i as useEditorContext, it as PopoverAnchor, j as SelectItem, jt as Card, k as SelectContent, kt as columnAnnotation, l as SHAPE_FONT_STACKS, lt as PopoverTrigger, m as htmlToBlocks, mt as Alert, n as useCoverAverageColor, nn as createMemoryBlobStore, nt as Separator, ot as PopoverDescription, p as markToggleAction, pt as BareSelect, q as DropdownMenuPortal, qt as useText, r as EditorProvider, rt as Popover, st as PopoverHeader, t as Editor, tn as BookOpen, tt as DropdownMenuTrigger, ut as Checkbox, v as parseFrontmatter, vt as PROTOCOL_VERSION, w as emptyFilter, wt as isBridgeErrorCode, x as cellValueEqual, xt as BRIDGE_ERROR_CODES, y as GridBody, yt as isDatabaseBridge, z as InlineEditInput, zt as badgeVariants } from "./Editor-
|
|
1
|
+
import { $ as DropdownMenuSubContent, $t as Eye, A as SelectGroup, At as Skeleton, B as Input, Bt as useBlock, C as FilterBuilder, Ct as isBridgeError, D as ScrollArea, Dt as parseCellValue, E as SegmentSelector, Et as conditionMatches, F as SelectSeparator, Ft as CardFooter, G as DropdownMenuItem, Gt as useSelection, H as DropdownMenuCheckboxItem, Ht as useMeta, I as SelectTrigger, It as CardHeader, J as DropdownMenuRadioGroup, Jt as DocblocksI18nProvider, K as DropdownMenuLabel, Kt as useSelectionView, L as SelectValue, Lt as CardTitle, M as SelectLabel, Mt as CardAction, N as SelectScrollDownButton, Nt as CardContent, O as Select, Ot as TEXT_TYPES, P as SelectScrollUpButton, Pt as CardDescription, Q as DropdownMenuSub, Qt as Pen, R as Label, Rt as Badge, S as newMutationContext, St as BridgeError, T as filterIsComplete, Tt as toBridgeError, U as DropdownMenuContent, Ut as usePresence, V as DropdownMenu, Vt as useDoc, W as DropdownMenuGroup, Wt as usePresenceSharing, X as DropdownMenuSeparator, Xt as renderRuns, Y as DropdownMenuRadioItem, Z as DropdownMenuShortcut, _ as mapFrontmatter, _t as BASELINE_CAPABILITIES, a as DEFAULT_EMBED_SANDBOX, at as PopoverContent, b as useDatabaseTable, bt as validateProtocolDescriptor, c as SHAPE_FONT_OPTIONS, ct as PopoverTitle, d as FORMAT_PALETTE, dt as Button, et as DropdownMenuSubTrigger, ft as buttonVariants, g as mdToBlocks, gt as AlertTitle, h as insertNative, ht as AlertDescription, i as useEditorContext, it as PopoverAnchor, j as SelectItem, jt as Card, k as SelectContent, kt as columnAnnotation, l as SHAPE_FONT_STACKS, lt as PopoverTrigger, m as htmlToBlocks, mt as Alert, n as useCoverAverageColor, nn as createMemoryBlobStore, nt as Separator, ot as PopoverDescription, p as markToggleAction, pt as BareSelect, q as DropdownMenuPortal, qt as useText, r as EditorProvider, rt as Popover, st as PopoverHeader, t as Editor, tn as BookOpen, tt as DropdownMenuTrigger, ut as Checkbox, v as parseFrontmatter, vt as PROTOCOL_VERSION, w as emptyFilter, wt as isBridgeErrorCode, x as cellValueEqual, xt as BRIDGE_ERROR_CODES, y as GridBody, yt as isDatabaseBridge, z as InlineEditInput, zt as badgeVariants } from "./Editor-BF7wBMcp.mjs";
|
|
2
2
|
import { a as preventDefault, s as cn } from "./constants-D8PSgkwi.mjs";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
package/dist/mermaid/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as Eye, At as Skeleton, E as SegmentSelector, Yt as INLINE_CODE_CLASS, Zt as RotateCcw, dt as Button, en as CodeXml, f as textOf, gt as AlertTitle, ht as AlertDescription, i as useEditorContext, mt as Alert, o as childrenSlot, s as CodeHeader, u as TextBlock } from "../Editor-
|
|
1
|
+
import { $t as Eye, At as Skeleton, E as SegmentSelector, Yt as INLINE_CODE_CLASS, Zt as RotateCcw, dt as Button, en as CodeXml, f as textOf, gt as AlertTitle, ht as AlertDescription, i as useEditorContext, mt as Alert, o as childrenSlot, s as CodeHeader, u as TextBlock } from "../Editor-BF7wBMcp.mjs";
|
|
2
2
|
import { a as preventDefault, d as Minus, f as LoaderCircle, l as TriangleAlert, r as clamp, u as Plus } from "../constants-D8PSgkwi.mjs";
|
|
3
3
|
import { t as Maximize } from "../Maximize-BBHnCDWL.mjs";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -266,11 +266,30 @@ function MermaidViewport({ id, block, children }) {
|
|
|
266
266
|
const [view, setView] = useState(() => viewOfAttrs(block.attrs?.zoom, block.attrs?.panX, block.attrs?.panY));
|
|
267
267
|
const viewRef = useRef(view);
|
|
268
268
|
viewRef.current = view;
|
|
269
|
+
const explicitViewRef = useRef(block.attrs?.zoom != null || block.attrs?.panX != null || block.attrs?.panY != null);
|
|
270
|
+
const persistGateRef = useRef(false);
|
|
271
|
+
/** The explicit gesture's stand: the view is the user's (the load-time fit stops re-applying) and the write-back opens. */
|
|
272
|
+
const markExplicit = () => {
|
|
273
|
+
explicitViewRef.current = true;
|
|
274
|
+
persistGateRef.current = true;
|
|
275
|
+
};
|
|
269
276
|
const [height, setHeight] = useState(block.attrs?.height ?? null);
|
|
270
277
|
const heightRef = useRef(height);
|
|
271
278
|
heightRef.current = height;
|
|
272
279
|
const panSession = useRef(null);
|
|
273
280
|
const resizeSession = useRef(null);
|
|
281
|
+
/** The fit's view over the measured's boxes (the scale's min, the no-upscale's cap, the centering). */
|
|
282
|
+
const fitViewOf = () => {
|
|
283
|
+
const rect = wrapperRef.current?.getBoundingClientRect();
|
|
284
|
+
const content = measureContent(layerRef.current);
|
|
285
|
+
if (rect === void 0 || rect.width <= 0 || rect.height <= 0 || content.w <= 0 || content.h <= 0) return null;
|
|
286
|
+
const scale = clamp(Math.min(rect.width / content.w, rect.height / content.h, 1), VIEWPORT_MIN_SCALE, VIEWPORT_MAX_SCALE);
|
|
287
|
+
return {
|
|
288
|
+
scale,
|
|
289
|
+
x: (rect.width - content.w * scale) / 2,
|
|
290
|
+
y: (rect.height - content.h * scale) / 2
|
|
291
|
+
};
|
|
292
|
+
};
|
|
274
293
|
/** The clamped view over the measured's boxes (the gesture's helper). */
|
|
275
294
|
const clampView = (next) => {
|
|
276
295
|
const rect = wrapperRef.current?.getBoundingClientRect();
|
|
@@ -280,6 +299,38 @@ function MermaidViewport({ id, block, children }) {
|
|
|
280
299
|
...clampPan(next.scale, next.x, next.y, rect?.width ?? 0, rect?.height ?? 0, content.w, content.h)
|
|
281
300
|
};
|
|
282
301
|
};
|
|
302
|
+
/**
|
|
303
|
+
* The geometry's stand: the mount's wrapper / layer boxes are not final
|
|
304
|
+
* (the page's layout settles post-mount) and the diagram's svg lands
|
|
305
|
+
* AFTER the mount (mermaid renders async), so the mount-time measure
|
|
306
|
+
* reads the loading skeleton's box. Over the settled boxes:
|
|
307
|
+
* - no explicit view yet (nothing persisted, no gesture): the load-time
|
|
308
|
+
* default stands — the FIT (the whole diagram in the frame, centered,
|
|
309
|
+
* capped at 100%);
|
|
310
|
+
* - an explicit view stands (the reload's restore, a gesture, a peer's
|
|
311
|
+
* write): the pan re-clamps into the box (the view never lands
|
|
312
|
+
* unclamped).
|
|
313
|
+
* The observer stands both when the boxes change (the svg's appearance,
|
|
314
|
+
* the consumer's re-layout) and on its initial observe; none of it
|
|
315
|
+
* touches the wire (see the persist gate).
|
|
316
|
+
*/
|
|
317
|
+
useEffect(() => {
|
|
318
|
+
const wrapper = wrapperRef.current;
|
|
319
|
+
const layer = layerRef.current;
|
|
320
|
+
if (wrapper === null || layer === null) return;
|
|
321
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
322
|
+
const settle = () => {
|
|
323
|
+
const current = viewRef.current;
|
|
324
|
+
const next = explicitViewRef.current ? clampView(current) : fitViewOf();
|
|
325
|
+
if (next === null) return;
|
|
326
|
+
if (next.scale === current.scale && next.x === current.x && next.y === current.y) return;
|
|
327
|
+
setView(next);
|
|
328
|
+
};
|
|
329
|
+
const observer = new ResizeObserver(settle);
|
|
330
|
+
observer.observe(wrapper);
|
|
331
|
+
observer.observe(layer);
|
|
332
|
+
return () => observer.disconnect();
|
|
333
|
+
}, []);
|
|
283
334
|
useEffect(() => {
|
|
284
335
|
const wrapper = wrapperRef.current;
|
|
285
336
|
if (wrapper === null) return;
|
|
@@ -305,6 +356,7 @@ function MermaidViewport({ id, block, children }) {
|
|
|
305
356
|
}
|
|
306
357
|
if (next === null) return;
|
|
307
358
|
event.preventDefault();
|
|
359
|
+
markExplicit();
|
|
308
360
|
setView(next);
|
|
309
361
|
};
|
|
310
362
|
wrapper.addEventListener("wheel", onWheel, { passive: false });
|
|
@@ -316,6 +368,7 @@ function MermaidViewport({ id, block, children }) {
|
|
|
316
368
|
if (wrapper === null) return;
|
|
317
369
|
const rect = wrapper.getBoundingClientRect();
|
|
318
370
|
const content = measureContent(layerRef.current);
|
|
371
|
+
markExplicit();
|
|
319
372
|
setView((v) => {
|
|
320
373
|
const nextScale = clamp(v.scale * step, VIEWPORT_MIN_SCALE, VIEWPORT_MAX_SCALE);
|
|
321
374
|
if (nextScale === v.scale) return v;
|
|
@@ -328,7 +381,10 @@ function MermaidViewport({ id, block, children }) {
|
|
|
328
381
|
};
|
|
329
382
|
const zoomIn = () => zoomBy(VIEWPORT_ZOOM_STEP);
|
|
330
383
|
const zoomOut = () => zoomBy(1 / VIEWPORT_ZOOM_STEP);
|
|
331
|
-
const resetView = () =>
|
|
384
|
+
const resetView = () => {
|
|
385
|
+
markExplicit();
|
|
386
|
+
setView(clampView(VIEWPORT_IDENTITY));
|
|
387
|
+
};
|
|
332
388
|
const atIdentity = (() => {
|
|
333
389
|
const rect = wrapperRef.current?.getBoundingClientRect();
|
|
334
390
|
const content = measureContent(layerRef.current);
|
|
@@ -336,24 +392,19 @@ function MermaidViewport({ id, block, children }) {
|
|
|
336
392
|
return view.scale === VIEWPORT_IDENTITY.scale && view.x === clamped.x && view.y === clamped.y;
|
|
337
393
|
})();
|
|
338
394
|
/**
|
|
339
|
-
* The fit's stand (the default's restore for
|
|
340
|
-
* scale's min over the width / height's ratio,
|
|
341
|
-
* diagram's stand the natural's size — no
|
|
342
|
-
* visible viewport's box (the clipped
|
|
343
|
-
* stand (the error / loading's
|
|
395
|
+
* The fit's stand (the load-time default and the toolbar's restore for
|
|
396
|
+
* the large diagram): the scale's min over the width / height's ratio,
|
|
397
|
+
* capped at 1 (the small diagram's stand the natural's size — no
|
|
398
|
+
* upscaling), centered over the visible viewport's box (the clipped
|
|
399
|
+
* stand included). The no-content's stand (the error / loading's
|
|
400
|
+
* states): the no-op. The button's press stands the explicit view (the
|
|
401
|
+
* persisted write follows).
|
|
344
402
|
*/
|
|
345
403
|
const fitView = () => {
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (rect.width <= 0 || rect.height <= 0 || content.w <= 0 || content.h <= 0) return;
|
|
351
|
-
const scale = clamp(Math.min(rect.width / content.w, rect.height / content.h, 1), VIEWPORT_MIN_SCALE, VIEWPORT_MAX_SCALE);
|
|
352
|
-
setView({
|
|
353
|
-
scale,
|
|
354
|
-
x: (rect.width - content.w * scale) / 2,
|
|
355
|
-
y: (rect.height - content.h * scale) / 2
|
|
356
|
-
});
|
|
404
|
+
const next = fitViewOf();
|
|
405
|
+
if (next === null) return;
|
|
406
|
+
markExplicit();
|
|
407
|
+
setView(next);
|
|
357
408
|
};
|
|
358
409
|
/**
|
|
359
410
|
* The persisted view's write (the debounce over the gesture's bursts):
|
|
@@ -369,6 +420,8 @@ function MermaidViewport({ id, block, children }) {
|
|
|
369
420
|
* no wire update).
|
|
370
421
|
*/
|
|
371
422
|
useEffect(() => {
|
|
423
|
+
if (!persistGateRef.current) return;
|
|
424
|
+
persistGateRef.current = false;
|
|
372
425
|
const clamped = clampView(view);
|
|
373
426
|
const zoom = roundViewValue(clamped.scale, 2);
|
|
374
427
|
const x = roundViewValue(clamped.x, 1);
|
|
@@ -411,9 +464,11 @@ function MermaidViewport({ id, block, children }) {
|
|
|
411
464
|
x: block.attrs?.panX ?? 0,
|
|
412
465
|
y: block.attrs?.panY ?? 0
|
|
413
466
|
};
|
|
467
|
+
const persisted = block.attrs?.zoom != null || block.attrs?.panX != null || block.attrs?.panY != null;
|
|
414
468
|
const clamped = clampView(target);
|
|
415
469
|
const v = viewRef.current;
|
|
416
470
|
if (clamped.scale === v.scale && clamped.x === v.x && clamped.y === v.y) return;
|
|
471
|
+
if (persisted) explicitViewRef.current = true;
|
|
417
472
|
setView(clamped);
|
|
418
473
|
}, [block.attrs]);
|
|
419
474
|
/** The remote's stand over the height (the panes' shared stand over the
|
|
@@ -442,6 +497,7 @@ function MermaidViewport({ id, block, children }) {
|
|
|
442
497
|
const dy = event.clientY - session.lastY;
|
|
443
498
|
session.lastX = event.clientX;
|
|
444
499
|
session.lastY = event.clientY;
|
|
500
|
+
markExplicit();
|
|
445
501
|
setView((v) => clampView({
|
|
446
502
|
scale: v.scale,
|
|
447
503
|
x: v.x + dx,
|
package/dist/pdf/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as PdfPreviewProps } from "../index-C3vzW1Mv.mjs";
|
|
2
2
|
//#region src/pdf/PdfFirstPage.d.ts
|
|
3
3
|
declare function PdfFirstPage({ id, blockType, url, name }: PdfPreviewProps): import("react").JSX.Element;
|
|
4
4
|
//#endregion
|