@datalking/begonia-react 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binding/BegoniaPdfViewer.d.ts +4 -1
- package/dist/binding/BrowserPaginatedEditorSurface.d.ts +44 -0
- package/dist/binding/HeaderFooterScratchMount.d.ts +25 -0
- package/dist/binding/PaginatedLayoutView.d.ts +21 -2
- package/dist/binding/PaginatedPageOverlayView.d.ts +44 -0
- package/dist/binding/VirtualPagedPreview.d.ts +38 -1
- package/dist/binding/begonia-theme-style.d.ts +12 -0
- package/dist/binding/browser-header-footer-bands.d.ts +98 -0
- package/dist/binding/browser-header-footer-format-bar.d.ts +21 -0
- package/dist/binding/browser-paginated-preview-drag-state.d.ts +2 -0
- package/dist/binding/headless.d.ts +1 -1
- package/dist/binding/index.d.ts +4 -0
- package/dist/binding/paginated-preview-doc-style.d.ts +40 -0
- package/dist/binding/paginated-preview-font-family.d.ts +19 -0
- package/dist/binding/paginated-scroll-axis-host.d.ts +32 -0
- package/dist/binding/preview-link-activation.d.ts +71 -0
- package/dist/binding/resolve-snapshot-comment-state.d.ts +32 -0
- package/dist/binding/use-browser-header-footer-editing.d.ts +114 -0
- package/dist/binding/use-header-footer-scratch-surface.d.ts +48 -0
- package/dist/binding/use-owned-destroyable.d.ts +9 -0
- package/dist/binding/use-undo-redo-hotkeys.d.ts +45 -0
- package/dist/binding/useVirtualPagedPreviewState.d.ts +13 -3
- package/dist/binding/v1.d.ts +16 -0
- package/dist/binding/virtual-paged-preview-comment-highlight.d.ts +33 -0
- package/dist/binding/virtual-paged-preview-drag-session.d.ts +1 -1
- package/dist/binding/virtual-paged-preview-interaction.d.ts +2 -2
- package/dist/binding/virtual-paged-preview-list-marker.d.ts +42 -0
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-text.d.ts +21 -6
- package/dist/binding/virtual-paged-preview-renderers/virtual-paged-preview-block-views.d.ts +18 -2
- package/dist/binding/virtual-paged-preview-review-attributes.d.ts +78 -0
- package/dist/binding/virtual-paged-preview-text-lines.d.ts +4 -0
- package/dist/chunk-LIAB6VEG.js +1 -0
- package/dist/editor-surface.css +457 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/v1.d.ts +4 -2
- package/dist/v1.js +1 -1
- package/package.json +19 -16
- package/dist/binding/paginated-preview-defaults.d.ts +0 -2
- package/dist/binding/virtual-paged-preview-table-metrics.d.ts +0 -1
- package/dist/chunk-IEHE33P5.js +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { PdfViewerController, PdfViewerPageFrame } from '@datalking/begonia-pdf-viewer';
|
|
3
|
+
import type { BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
3
4
|
export interface BegoniaPdfViewerProps {
|
|
4
5
|
controller: PdfViewerController;
|
|
5
6
|
height?: number | string;
|
|
@@ -7,7 +8,9 @@ export interface BegoniaPdfViewerProps {
|
|
|
7
8
|
pageGap?: number;
|
|
8
9
|
className?: string;
|
|
9
10
|
style?: CSSProperties;
|
|
11
|
+
/** Theme preset id, theme object, or token patch applied to this viewer. */
|
|
12
|
+
theme?: BegoniaThemeInput;
|
|
10
13
|
emptyLabel?: string;
|
|
11
14
|
renderPageOverlay?: (frame: PdfViewerPageFrame) => ReactNode;
|
|
12
15
|
}
|
|
13
|
-
export declare function BegoniaPdfViewer({ controller, height, scale, pageGap, className, style, emptyLabel, renderPageOverlay, }: BegoniaPdfViewerProps): import("react").JSX.Element;
|
|
16
|
+
export declare function BegoniaPdfViewer({ controller, height, scale, pageGap, className, style, theme, emptyLabel, renderPageOverlay, }: BegoniaPdfViewerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type BrowserEditorController } from '@datalking/begonia-browser/v1';
|
|
2
|
+
import { type BrowserPaginatedPreviewProps as BrowserPaginatedPreviewUiProps } from './BrowserPaginatedPreviewUi.tsx';
|
|
3
|
+
import { type BrowserHeaderFooterBandsProps } from './browser-header-footer-bands.tsx';
|
|
4
|
+
type PreviewPassthroughProps<TSource> = Omit<BrowserPaginatedPreviewUiProps<TSource>, 'editor' | 'renderPageOverlay' | 'onProjectionContextMenu' | 'onResolvedScrollHostChange' | 'onResolvedPreviewHostChange'>;
|
|
5
|
+
export interface BrowserPaginatedEditorSurfaceProps<TSource = unknown> extends PreviewPassthroughProps<TSource> {
|
|
6
|
+
editor: BrowserEditorController | null;
|
|
7
|
+
/** Ref callback from `useBrowserEditorController`; the hidden host attaches here. */
|
|
8
|
+
hostRef: (node: HTMLDivElement | null) => void;
|
|
9
|
+
/** Extra CSS classNames for the off-screen host wrapper. */
|
|
10
|
+
hostClassName?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Identifies this editor to its toolbar.
|
|
13
|
+
*
|
|
14
|
+
* The toolbar registers itself as editor chrome so a Bold press does not end
|
|
15
|
+
* the caret's life; this is what tells the overlay *which* editor that chrome
|
|
16
|
+
* belongs to. Pass the same value as `EditorToolbar`'s `surfaceId`, or leave
|
|
17
|
+
* both unset on a single-editor page.
|
|
18
|
+
*/
|
|
19
|
+
surfaceId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Header and footer bands, when the host offers them.
|
|
22
|
+
*
|
|
23
|
+
* Passed through rather than derived here: which slots a section enables is
|
|
24
|
+
* a document question, and the surface already has one job (mirroring the
|
|
25
|
+
* editing session's snapshot).
|
|
26
|
+
*/
|
|
27
|
+
headerFooter?: Omit<BrowserHeaderFooterBandsProps, 'frame' | 'scale'>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A paginated surface that is editable in place, like Word.
|
|
31
|
+
*
|
|
32
|
+
* The real ProseMirror host stays mounted but off-screen (see
|
|
33
|
+
* `resolvePaginatedEditingHostStyle` for why it cannot be `display:none`), and
|
|
34
|
+
* the paginated preview paints selection/caret on top of its own pages. All the
|
|
35
|
+
* geometry, focus, and reveal logic lives in the framework-agnostic
|
|
36
|
+
* `paginated-editing` session; this component only wires refs and mirrors one
|
|
37
|
+
* snapshot.
|
|
38
|
+
*
|
|
39
|
+
* The editor UI is created once and shared by the session and the preview: they
|
|
40
|
+
* must read the same preview binding, or the session would resolve caret
|
|
41
|
+
* geometry against a binding that never received a projection.
|
|
42
|
+
*/
|
|
43
|
+
export declare function BrowserPaginatedEditorSurface<TSource = unknown>({ editor, hostRef, hostClassName, surfaceId, ...previewProps }: BrowserPaginatedEditorSurfaceProps<TSource>): import("react").JSX.Element;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Puts the scratch editor's DOM inside the open band.
|
|
3
|
+
*
|
|
4
|
+
* The scratch view is built imperatively (ProseMirror needs a real element at
|
|
5
|
+
* construction time), so it exists before the band that should display it. This
|
|
6
|
+
* component adopts that element into the React tree for as long as the band is
|
|
7
|
+
* open: append on mount, remove on unmount.
|
|
8
|
+
*
|
|
9
|
+
* Moving the node rather than re-creating the view is what keeps the caret where
|
|
10
|
+
* the writer left it. A re-created view would restart the document at the top
|
|
11
|
+
* and lose the selection between two keystrokes.
|
|
12
|
+
*/
|
|
13
|
+
export interface HeaderFooterScratchMountProps {
|
|
14
|
+
mount: HTMLElement | null;
|
|
15
|
+
/**
|
|
16
|
+
* Focus the story once it is visible. Defaults to true.
|
|
17
|
+
*
|
|
18
|
+
* The controller focuses the view the moment the band opens, but the element
|
|
19
|
+
* is still parked off-screen at that point, and a browser will not put a caret
|
|
20
|
+
* into an element it cannot see. Focusing again here is what actually places
|
|
21
|
+
* it.
|
|
22
|
+
*/
|
|
23
|
+
autoFocus?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function HeaderFooterScratchMount({ mount, autoFocus, }: HeaderFooterScratchMountProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EditorLayoutAdapter, LayoutProjection, LayoutResolutionOptions, ResolvedLayoutProjection } from '@datalking/begonia-layout-contracts';
|
|
2
2
|
import { type VirtualPagedPreviewProps } from './VirtualPagedPreview.tsx';
|
|
3
3
|
import type { VirtualPagedPreviewPositionHitEvent } from './virtual-paged-preview-interaction.ts';
|
|
4
|
-
type PreviewProps = Pick<VirtualPagedPreviewProps, 'version' | 'measureText' | 'scrollHost' | 'height' | 'width' | 'scale' | 'pageGap' | 'windowPages' | 'overscan' | 'virtualize' | 'layoutMode' | 'flowMode' | 'anchorPageNumber' | 'initialViewportAnchor' | 'viewportRequestKey' | 'pinnedPageNumbers' | 'emptyLabel' | 'onViewportChange'>;
|
|
4
|
+
type PreviewProps = Pick<VirtualPagedPreviewProps, 'version' | 'measureText' | 'resolveCommentState' | 'scrollHost' | 'height' | 'width' | 'scale' | 'pageGap' | 'windowPages' | 'overscan' | 'virtualize' | 'layoutMode' | 'flowMode' | 'anchorPageNumber' | 'initialViewportAnchor' | 'viewportRequestKey' | 'pinnedPageNumbers' | 'theme' | 'emptyLabel' | 'onViewportChange' | 'renderPageOverlay' | 'onResolvedScrollHostChange' | 'onResolvedPreviewHostChange' | 'onProjectionContextMenu'>;
|
|
5
5
|
export type PaginatedLayoutViewProps<TSource = unknown> = PreviewProps & {
|
|
6
6
|
projection?: LayoutProjection | null;
|
|
7
7
|
adapter?: EditorLayoutAdapter<TSource>;
|
|
@@ -10,6 +10,25 @@ export type PaginatedLayoutViewProps<TSource = unknown> = PreviewProps & {
|
|
|
10
10
|
options?: LayoutResolutionOptions;
|
|
11
11
|
onLayoutChange?: (layout: ResolvedLayoutProjection | null) => void;
|
|
12
12
|
onProjectionPositionHit?: (event: VirtualPagedPreviewPositionHitEvent) => boolean | void;
|
|
13
|
+
/**
|
|
14
|
+
* Holds paginated layout back while an IME composition is in flight.
|
|
15
|
+
*
|
|
16
|
+
* A composition changes the document on every keystroke, and every change would
|
|
17
|
+
* otherwise rebuild the projection and re-render the mounted pages - work the
|
|
18
|
+
* composition does not need, because the surface paints the preedit itself. The
|
|
19
|
+
* single pass the commit needs is scheduled for after the frame that paints the
|
|
20
|
+
* committed text.
|
|
21
|
+
*/
|
|
22
|
+
deferLayout?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Reports that the single post-paint release has run.
|
|
25
|
+
*
|
|
26
|
+
* The projection that release produces may be identical to the previous one,
|
|
27
|
+
* in which case nothing else notifies the caller that the pass happened. This
|
|
28
|
+
* lets the surface retire its preedit stand-in on the release decision rather
|
|
29
|
+
* than on the arrival of a changed projection.
|
|
30
|
+
*/
|
|
31
|
+
onDeferralRelease?: () => void;
|
|
13
32
|
};
|
|
14
|
-
export declare function PaginatedLayoutView<TSource = unknown>({ projection, adapter, source, version, options, measureText, onLayoutChange, scrollHost, height, width, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, emptyLabel, onViewportChange, onProjectionPositionHit, }: PaginatedLayoutViewProps<TSource>): import("react").JSX.Element;
|
|
33
|
+
export declare function PaginatedLayoutView<TSource = unknown>({ projection, adapter, source, version, options, measureText, resolveCommentState, onLayoutChange, scrollHost, height, width, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, theme, emptyLabel, onViewportChange, renderPageOverlay, onResolvedScrollHostChange, onResolvedPreviewHostChange, onProjectionContextMenu, onProjectionPositionHit, deferLayout, onDeferralRelease, }: PaginatedLayoutViewProps<TSource>): import("react").JSX.Element;
|
|
15
34
|
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VirtualPageFrame } from '@datalking/begonia-layout-renderer';
|
|
2
|
+
import { type PaginatedOverlayModel } from '@datalking/begonia-layout-renderer';
|
|
3
|
+
export interface PaginatedPageOverlayViewProps {
|
|
4
|
+
frame: VirtualPageFrame;
|
|
5
|
+
scale: number;
|
|
6
|
+
overlay: PaginatedOverlayModel | null | undefined;
|
|
7
|
+
/** Projection flow mode of the preview this frame belongs to. */
|
|
8
|
+
flowMode?: 'paginated' | 'web';
|
|
9
|
+
/**
|
|
10
|
+
* True while an IME composition is active.
|
|
11
|
+
*
|
|
12
|
+
* The caret itself is not hidden any more once the ghost exists: the ghost
|
|
13
|
+
* owns it, and paints it after the preedit so the line reads as an insertion.
|
|
14
|
+
* Before the first preedit arrives the ordinary caret is still hidden, which
|
|
15
|
+
* keeps a composition from showing two carets.
|
|
16
|
+
*/
|
|
17
|
+
composing?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The IME preedit, or the text a commit has not yet been laid out into.
|
|
20
|
+
*
|
|
21
|
+
* Painted at the caret, in the caret line's own type, because the pages are
|
|
22
|
+
* deliberately not repaginated while a composition is in flight. Empty unless
|
|
23
|
+
* a composition is running or has just committed.
|
|
24
|
+
*/
|
|
25
|
+
compositionText?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the caret should be on screen.
|
|
28
|
+
*
|
|
29
|
+
* The caret is hidden rather than removed. Geometry readers - the caret
|
|
30
|
+
* reveal, the browser checks - look the element up by its attribute, and a
|
|
31
|
+
* caret that disappears from the DOM whenever focus moves would make every
|
|
32
|
+
* "where is the caret" question fail instead of answer "not visible".
|
|
33
|
+
*/
|
|
34
|
+
caretVisible?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Paints one page frame's selection boxes and caret.
|
|
38
|
+
*
|
|
39
|
+
* Deliberately dumb: every number arrives pre-resolved from
|
|
40
|
+
* `resolvePaginatedOverlayForFrame`, so this component only maps boxes to
|
|
41
|
+
* elements. Keeping the maths out of React is what makes the paginated surface
|
|
42
|
+
* reusable outside React.
|
|
43
|
+
*/
|
|
44
|
+
export declare function PaginatedPageOverlayView({ frame, scale, overlay, flowMode, composing, compositionText, caretVisible, }: PaginatedPageOverlayViewProps): import("react").JSX.Element | null;
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LayoutProjection, LayoutProjectionOptions } from '@datalking/begonia-layout-contracts';
|
|
3
3
|
import type { LayoutFlowMode, LayoutRenderMode, PageViewportAnchor, PageViewportMetrics, VirtualPageFrame } from '@datalking/begonia-layout-renderer';
|
|
4
|
+
import type { BegoniaThemeInput, PaginatedEditingScrollHost } from '@datalking/begonia-browser-sdk';
|
|
4
5
|
import type { VirtualPagedPreviewPositionHitEvent } from './virtual-paged-preview-interaction.ts';
|
|
6
|
+
import type { PreviewCommentStateResolver } from './virtual-paged-preview-comment-highlight.ts';
|
|
5
7
|
export interface VirtualPagedPreviewProps {
|
|
6
8
|
projection: LayoutProjection | null;
|
|
7
9
|
version?: number | string | null;
|
|
8
10
|
measureText?: LayoutProjectionOptions['measureText'];
|
|
9
11
|
measurementEpoch?: LayoutProjectionOptions['measurementEpoch'];
|
|
12
|
+
/**
|
|
13
|
+
* Comment thread state, used to tint commented runs.
|
|
14
|
+
*
|
|
15
|
+
* Defaults to "open" for every thread, so a host that does not model comment
|
|
16
|
+
* lifecycle still gets a visible highlight instead of nothing.
|
|
17
|
+
*/
|
|
18
|
+
resolveCommentState?: PreviewCommentStateResolver | null;
|
|
19
|
+
/**
|
|
20
|
+
* Draw non-printing formatting marks (¶, spaces, tabs).
|
|
21
|
+
*
|
|
22
|
+
* Purely decorative: the marks are absolutely positioned over text the
|
|
23
|
+
* paginator already laid out, so turning this on cannot change where a line
|
|
24
|
+
* breaks or how a page paginates.
|
|
25
|
+
*/
|
|
26
|
+
showFormattingMarks?: boolean;
|
|
27
|
+
/** Draw bookmark markers. Decoration only; never affects layout. */
|
|
28
|
+
showBookmarks?: boolean;
|
|
10
29
|
height?: number;
|
|
11
30
|
width?: number;
|
|
12
31
|
/**
|
|
@@ -25,9 +44,27 @@ export interface VirtualPagedPreviewProps {
|
|
|
25
44
|
initialViewportAnchor?: PageViewportAnchor | null;
|
|
26
45
|
viewportRequestKey?: string | number | null;
|
|
27
46
|
pinnedPageNumbers?: readonly number[];
|
|
47
|
+
/** Theme preset id, theme object, or token patch applied to this preview. */
|
|
48
|
+
theme?: BegoniaThemeInput;
|
|
28
49
|
emptyLabel?: string;
|
|
29
50
|
onViewportChange?: (state: PageViewportMetrics) => void;
|
|
30
51
|
renderPageOverlay?: (frame: VirtualPageFrame, scale: number) => ReactNode;
|
|
31
52
|
onProjectionPositionHit?: (event: VirtualPagedPreviewPositionHitEvent) => boolean | void;
|
|
53
|
+
/**
|
|
54
|
+
* Reports the element whose scroll position drives virtualization, so a
|
|
55
|
+
* consumer can reveal the caret without owning the scroll-host choice.
|
|
56
|
+
*/
|
|
57
|
+
onResolvedScrollHostChange?: (host: PaginatedEditingScrollHost | null) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Reports the element that holds the painted pages, so an overlay input
|
|
60
|
+
* bridge can route pointer and keyboard input without owning the preview's
|
|
61
|
+
* internal refs.
|
|
62
|
+
*/
|
|
63
|
+
onResolvedPreviewHostChange?: (host: HTMLElement | null) => void;
|
|
64
|
+
/** Right-click on page content, resolved to a document hit. */
|
|
65
|
+
onProjectionContextMenu?: (event: VirtualPagedPreviewPositionHitEvent, point: {
|
|
66
|
+
clientX: number;
|
|
67
|
+
clientY: number;
|
|
68
|
+
}) => boolean | void;
|
|
32
69
|
}
|
|
33
|
-
export declare function VirtualPagedPreview({ projection, version, measureText, measurementEpoch, height, width, scrollHost, scale, pageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, emptyLabel, onViewportChange, renderPageOverlay, onProjectionPositionHit, }: VirtualPagedPreviewProps): import("react").JSX.Element;
|
|
70
|
+
export declare function VirtualPagedPreview({ projection, version, measureText, measurementEpoch, resolveCommentState, showFormattingMarks, showBookmarks, height, width, scrollHost, scale, pageGap: requestedPageGap, windowPages, overscan, virtualize, layoutMode, flowMode, anchorPageNumber, initialViewportAnchor, viewportRequestKey, pinnedPageNumbers, theme, emptyLabel, onViewportChange, renderPageOverlay, onProjectionPositionHit, onResolvedScrollHostChange, onResolvedPreviewHostChange, onProjectionContextMenu, }: VirtualPagedPreviewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
3
|
+
export interface BegoniaThemeRootProps {
|
|
4
|
+
style: CSSProperties;
|
|
5
|
+
'data-begonia-theme'?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Root props for a themed component: the theme's `--ald-*` custom properties
|
|
9
|
+
* plus a `data-begonia-theme` marker. Without a `theme`, the base style is
|
|
10
|
+
* returned untouched so variables applied by a host keep working.
|
|
11
|
+
*/
|
|
12
|
+
export declare function begoniaThemeRootProps(theme: BegoniaThemeInput | null | undefined, baseStyle?: CSSProperties): BegoniaThemeRootProps;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { PageProjection } from '@datalking/begonia-layout-contracts';
|
|
3
|
+
import type { VirtualPageFrame } from '@datalking/begonia-layout-renderer';
|
|
4
|
+
import { type HeaderFooterKind } from '@datalking/begonia-browser-sdk';
|
|
5
|
+
/**
|
|
6
|
+
* The header and footer bands drawn over one page.
|
|
7
|
+
*
|
|
8
|
+
* The paginated overlay is deliberately `pointer-events: none`: it paints
|
|
9
|
+
* selection and caret boxes and must never intercept a click. A band is the
|
|
10
|
+
* opposite - it exists to be pressed - so it cannot live inside that overlay and
|
|
11
|
+
* gets its own hit surface with `pointer-events: auto` on the bands only.
|
|
12
|
+
*
|
|
13
|
+
* Two rules shape the behaviour, both taken from Word:
|
|
14
|
+
*
|
|
15
|
+
* 1. A band opens on a **double** press. A single press inside the page's
|
|
16
|
+
* header space is not a request to edit the header; treating it as one meant
|
|
17
|
+
* that any click near the top or bottom of a page silently swapped the story
|
|
18
|
+
* the caret belonged to.
|
|
19
|
+
* 2. The band covers the **whole** margin the page reserves for it, not just the
|
|
20
|
+
* lines the story occupies. The empty space above a header is part of the
|
|
21
|
+
* header, and a press in it has to land somewhere: covering only the painted
|
|
22
|
+
* text left the topmost strip of the page owned by nobody, so hovering there
|
|
23
|
+
* showed no band and double-pressing there did nothing at all.
|
|
24
|
+
*
|
|
25
|
+
* Geometry comes from the projection's own regions, so the band sits exactly
|
|
26
|
+
* where the layout reserved space. Nothing here measures text.
|
|
27
|
+
*/
|
|
28
|
+
/** Which slots one section enables, resolved per page. */
|
|
29
|
+
export interface HeaderFooterBandSlots {
|
|
30
|
+
header: boolean;
|
|
31
|
+
footer: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface HeaderFooterBandTarget {
|
|
34
|
+
kind: HeaderFooterKind;
|
|
35
|
+
/**
|
|
36
|
+
* The section being edited. The band only opens on pages of that section:
|
|
37
|
+
* a document with three sections draws three headers, and opening "the
|
|
38
|
+
* header" means the one belonging to the page the reader pressed.
|
|
39
|
+
*/
|
|
40
|
+
sectionIndex: number;
|
|
41
|
+
/** Refines further when a section enables more than one slot. */
|
|
42
|
+
slot?: 'default' | 'first' | 'even';
|
|
43
|
+
/**
|
|
44
|
+
* The page whose band hosts the editor, or null to host it on every page the
|
|
45
|
+
* target covers.
|
|
46
|
+
*
|
|
47
|
+
* A story belongs to a section, so every page in that section draws the same
|
|
48
|
+
* header; only one of them may host the editable view. Without this the
|
|
49
|
+
* scratch element is appended into every matching band, so all but the last
|
|
50
|
+
* are left with an empty box and the caret points at an element the writer
|
|
51
|
+
* cannot see.
|
|
52
|
+
*/
|
|
53
|
+
pageNumber?: number | null;
|
|
54
|
+
}
|
|
55
|
+
export interface BrowserHeaderFooterBandsProps {
|
|
56
|
+
frame: VirtualPageFrame;
|
|
57
|
+
scale: number;
|
|
58
|
+
/**
|
|
59
|
+
* Slots enabled for this page's section.
|
|
60
|
+
*
|
|
61
|
+
* A function of the page rather than a fixed pair, because a document with
|
|
62
|
+
* `titlePage` on section one and not on section two must offer the first-page
|
|
63
|
+
* header on one set of pages only.
|
|
64
|
+
*/
|
|
65
|
+
resolveSlots?: (page: PageProjection) => HeaderFooterBandSlots;
|
|
66
|
+
activeTarget?: HeaderFooterBandTarget | null;
|
|
67
|
+
/** True while the document is read-only, which makes the bands inert. */
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
onActivateBand?: (kind: HeaderFooterKind, page: PageProjection) => void;
|
|
70
|
+
/** Content rendered inside the open band - in practice the scratch editor. */
|
|
71
|
+
activeBandContent?: ReactNode;
|
|
72
|
+
/**
|
|
73
|
+
* Controls drawn beside the open story - in practice its format bar.
|
|
74
|
+
*
|
|
75
|
+
* The band owns the placement because only the band knows which edge of the
|
|
76
|
+
* page the story sits on: a header's bar belongs at its top, a footer's at its
|
|
77
|
+
* bottom, and either has to stay inside the strip the story occupies.
|
|
78
|
+
*/
|
|
79
|
+
activeBandToolbar?: ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* How close two presses must be to count as one double press, in
|
|
82
|
+
* milliseconds. Defaults to the platform's typical double-click speed.
|
|
83
|
+
*/
|
|
84
|
+
doublePressIntervalMs?: number;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether any band is currently hosting a story.
|
|
88
|
+
*
|
|
89
|
+
* The painted body caret has to go away while one is: the story is a second
|
|
90
|
+
* editing surface holding the real selection, so a body caret blinking in the
|
|
91
|
+
* middle of the page says "typing lands here" about a place where it will not.
|
|
92
|
+
* Kept as a separate question from `isBandOpen` because it needs no page: the
|
|
93
|
+
* caret is painted once per page, and each one asks the same question.
|
|
94
|
+
*/
|
|
95
|
+
export declare function isHeaderFooterBandOpen(headerFooter: {
|
|
96
|
+
activeTarget?: HeaderFooterBandTarget | null;
|
|
97
|
+
} | null | undefined): boolean;
|
|
98
|
+
export declare function BrowserHeaderFooterBands(props: BrowserHeaderFooterBandsProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HeaderFooterInlineFormatKey, HeaderFooterInlineFormatState, HeaderFooterParagraphAlignment } from '@datalking/begonia-browser-sdk';
|
|
2
|
+
export interface BrowserHeaderFooterFormatBarProps {
|
|
3
|
+
format: HeaderFooterInlineFormatState;
|
|
4
|
+
onToggle(key: HeaderFooterInlineFormatKey): void;
|
|
5
|
+
/** The caret paragraph's alignment, or null when several are selected. */
|
|
6
|
+
alignment?: HeaderFooterParagraphAlignment | null;
|
|
7
|
+
onAlignmentChange?(align: HeaderFooterParagraphAlignment): void;
|
|
8
|
+
/**
|
|
9
|
+
* The story selection's text colour, or null when it carries none.
|
|
10
|
+
*
|
|
11
|
+
* Omitted along with `onTextColorChange`, the bar stays a four-mark strip: a
|
|
12
|
+
* host whose story surface cannot colour text must not be shown a control
|
|
13
|
+
* that does nothing.
|
|
14
|
+
*/
|
|
15
|
+
textColor?: string | null;
|
|
16
|
+
/** Sets the story selection's text colour; null clears it. */
|
|
17
|
+
onTextColorChange?(color: string | null): void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
scale?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function BrowserHeaderFooterFormatBar(props: BrowserHeaderFooterFormatBarProps): import("react").JSX.Element;
|
|
@@ -9,7 +9,7 @@ export type { BindVirtualPagedPreviewWindowDragListenersInput, VirtualPagedPrevi
|
|
|
9
9
|
export { resolvePaginatedPreviewFlowMode, resolveRequestedPaginatedLayoutFlowMode, } from './paginated-layout-flow-mode.ts';
|
|
10
10
|
export { DEFAULT_VIRTUAL_PAGED_PREVIEW_SCALE, DEFAULT_WEB_FLOW_PAGE_HEIGHT_PX, WEB_VIRTUAL_PAGED_PREVIEW_HORIZONTAL_PADDING_PX, resolvePaginatedLayoutViewOptions, } from './paginated-layout-preview-options.ts';
|
|
11
11
|
export type { ResolvePaginatedLayoutViewOptionsInput } from './paginated-layout-preview-options.ts';
|
|
12
|
-
export { PREVIEW_TABLE_CELL_HORIZONTAL_PADDING, PREVIEW_TABLE_CELL_VERTICAL_PADDING, } from '
|
|
12
|
+
export { PREVIEW_TABLE_CELL_HORIZONTAL_PADDING, PREVIEW_TABLE_CELL_VERTICAL_PADDING, } from '@datalking/begonia-table-render';
|
|
13
13
|
export { resolveVirtualPagedPreviewRenderState } from './virtual-paged-preview-render-state.ts';
|
|
14
14
|
export type { VirtualPagedPreviewViewportResetReason, VirtualPagedPreviewRenderResolution, } from './virtual-paged-preview-render-state.ts';
|
|
15
15
|
export { cloneVirtualPagedPreviewMetrics, normalizeVirtualPagedPreviewPinnedPageIndexes, normalizeVirtualPagedPreviewRequestKey, resolveVirtualPagedPreviewHostMeasurement, resolveVirtualPagedPreviewResizeObserver, sameVirtualPagedPreviewMetrics, } from './virtual-paged-preview-viewport-state.ts';
|
package/dist/binding/index.d.ts
CHANGED
|
@@ -3,7 +3,11 @@ export type { BegoniaPdfViewerProps } from './BegoniaPdfViewer.tsx';
|
|
|
3
3
|
export { PaginatedLayoutView } from './PaginatedLayoutView.tsx';
|
|
4
4
|
export type { PaginatedLayoutViewProps } from './PaginatedLayoutView.tsx';
|
|
5
5
|
export { VirtualPagedPreview } from './VirtualPagedPreview.tsx';
|
|
6
|
+
export { PaginatedPageOverlayView } from './PaginatedPageOverlayView.tsx';
|
|
7
|
+
export type { PaginatedPageOverlayViewProps } from './PaginatedPageOverlayView.tsx';
|
|
6
8
|
export type { VirtualPagedPreviewProps } from './VirtualPagedPreview.tsx';
|
|
9
|
+
export { begoniaThemeRootProps } from './begonia-theme-style.ts';
|
|
10
|
+
export type { BegoniaThemeRootProps } from './begonia-theme-style.ts';
|
|
7
11
|
export { useBrowserEditorUi } from './use-browser-editor-ui.ts';
|
|
8
12
|
export type { BrowserEditorHostRef, UseBrowserEditorUiOptions, UseBrowserEditorUiResult, } from './use-browser-editor-ui.ts';
|
|
9
13
|
export { useEditorUiController } from './use-editor-ui-controller.ts';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual tokens shared by every begonia document surface.
|
|
3
|
+
*
|
|
4
|
+
* The paginated painter and the CSS-backed `.ald-editor` used to carry their own
|
|
5
|
+
* copies of these values, so the same document rendered at 16px in one surface
|
|
6
|
+
* and 18px in the other, and the two link colours disagreed outright. One token
|
|
7
|
+
* set means a change lands in both surfaces at once.
|
|
8
|
+
*
|
|
9
|
+
* These are *visual* defaults only. Anything the layout measured - block
|
|
10
|
+
* `top`, `left`, table row heights, cell padding - stays authoritative and is
|
|
11
|
+
* never overridden from here, because caret placement and hit testing are
|
|
12
|
+
* derived from those measurements.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Body text colour. Word's default is black; the older `#1f2937` read as slate.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DOC_TEXT_COLOR = "var(--ald-doc-text, #000000)";
|
|
18
|
+
/** Heading text colour, matching the body default unless the theme overrides it. */
|
|
19
|
+
export declare const DOC_HEADING_COLOR = "var(--ald-doc-heading, #000000)";
|
|
20
|
+
/**
|
|
21
|
+
* Link colour.
|
|
22
|
+
*
|
|
23
|
+
* Word's hyperlink blue. The paginated painter and `.ald-editor` previously
|
|
24
|
+
* used `#155e75` and `#0f766e`, so a link changed colour between surfaces.
|
|
25
|
+
*/
|
|
26
|
+
export declare const DOC_LINK_COLOR = "var(--ald-link, #0563c1)";
|
|
27
|
+
/** Document font stack, shared with the CSS surface. */
|
|
28
|
+
export declare const DOC_FONT_FAMILY = "var(--ald-font-doc, \"Aptos\", Calibri, \"Segoe UI\", sans-serif)";
|
|
29
|
+
/**
|
|
30
|
+
* Table border, shared so a table looks identical on both surfaces.
|
|
31
|
+
*/
|
|
32
|
+
export declare const DOC_TABLE_BORDER = "var(--ald-table-border, 1px solid rgba(0, 0, 0, 0.5))";
|
|
33
|
+
/**
|
|
34
|
+
* Header-row background tint.
|
|
35
|
+
*
|
|
36
|
+
* Word does not tint header rows by default, but begonia's default theme did and
|
|
37
|
+
* the paginated painter has always painted it. Keeping it as a token lets a
|
|
38
|
+
* theme opt out with `--ald-table-header-bg: transparent`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const DOC_TABLE_HEADER_BACKGROUND = "var(--ald-table-header-bg, rgba(226, 232, 240, 0.65))";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BegoniaThemeInput } from '@datalking/begonia-browser-sdk';
|
|
2
|
+
import type { LayoutProjectionOptions } from '@datalking/begonia-layout-contracts';
|
|
3
|
+
/**
|
|
4
|
+
* The document font used to paint paginated text must be the same font the
|
|
5
|
+
* layout measured with. The renderer paints with `--ald-font-doc` (which the
|
|
6
|
+
* theme sets), while the canvas measurer defaults to `"Times New Roman", serif`
|
|
7
|
+
* when no family is supplied. Measuring Times but painting Aptos produced line
|
|
8
|
+
* boxes wider than the slices the paginator reserved, so every block wrapped
|
|
9
|
+
* onto an extra line and the pages drifted out of alignment.
|
|
10
|
+
*
|
|
11
|
+
* Resolving the family once, from the theme, keeps measurement and painting in
|
|
12
|
+
* agreement.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolvePaginatedPreviewFontFamily(theme: BegoniaThemeInput | undefined): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Binds a measure function to the document font family, so every measurement
|
|
17
|
+
* request inherits the painted family unless a run overrides it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withMeasureFontFamily(measureText: LayoutProjectionOptions['measureText'], fontFamily: string | null): LayoutProjectionOptions['measureText'];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PaginatedEditingScrollHost } from '@datalking/begonia-browser-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* The axis a preview's pages advance along.
|
|
4
|
+
*
|
|
5
|
+
* Only `horizontal` advances sideways: its pages sit in a single row, so a caret on
|
|
6
|
+
* the next page is off the right edge and only `scrollLeft` brings it back.
|
|
7
|
+
* Vertical pages stack downwards and scroll on `scrollTop`.
|
|
8
|
+
*
|
|
9
|
+
* Book mode scrolls VERTICALLY, which is the counter-intuitive case and the one
|
|
10
|
+
* this file used to get wrong. A book is not a horizontal strip: pages pair into
|
|
11
|
+
* facing spreads, and consecutive SPREADS stack downward. The layout engine says
|
|
12
|
+
* so - `virtualization-book-axis` advances on `row.top`/`row.bottom`, and
|
|
13
|
+
* `book-frame-rows` derives each spread's `top` from its spread index - so only
|
|
14
|
+
* the two pages of one spread sit side by side, and the document grows down the
|
|
15
|
+
* page as a book does. Reporting 'horizontal' here made caret reveal scroll
|
|
16
|
+
* sideways to reach a page that is actually below the viewport, so the caret
|
|
17
|
+
* moved but never came into view.
|
|
18
|
+
*/
|
|
19
|
+
export type PaginatedPreviewScrollAxis = 'vertical' | 'horizontal';
|
|
20
|
+
export declare function resolvePaginatedPreviewScrollAxis(layoutMode: string | null | undefined): PaginatedPreviewScrollAxis;
|
|
21
|
+
/**
|
|
22
|
+
* Re-publishes a resolved scroll host with an explicit scroll axis.
|
|
23
|
+
*
|
|
24
|
+
* The preview's resolved host is a real element (or a window host) that knows
|
|
25
|
+
* how to scroll but not which axis the layout advances along: an element that
|
|
26
|
+
* happens to be wider than its viewport scrolls on both. Caret reveal has to
|
|
27
|
+
* pick one, so the axis is attached here where the layout mode is known.
|
|
28
|
+
*
|
|
29
|
+
* Wrappers are cached per host and axis, so re-publishing the same host from a
|
|
30
|
+
* re-render hands the consumer the same object and does not re-attach it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function withPaginatedPreviewScrollAxis(host: PaginatedEditingScrollHost | null | undefined, axis: PaginatedPreviewScrollAxis): PaginatedEditingScrollHost | null;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ctrl-click follows a link in the paginated view.
|
|
3
|
+
*
|
|
4
|
+
* The paginated surface paints text as inert spans so the pointer-hit pipeline
|
|
5
|
+
* owns selection - nothing inside a page frame is a real anchor. That is right
|
|
6
|
+
* for text, and wrong for links: the paint was already styled as a link (blue and
|
|
7
|
+
* underlined) and pressing it still just moved the caret, so the document LOOKED
|
|
8
|
+
* like it had working links and did not. superdoc and Word both open a link on
|
|
9
|
+
* ctrl/cmd-click, which is the gesture a reader arriving from either one tries
|
|
10
|
+
* first.
|
|
11
|
+
*
|
|
12
|
+
* Plain click keeps selecting, because selecting text across a link is an
|
|
13
|
+
* ordinary editing gesture and stealing it would make link-bearing paragraphs
|
|
14
|
+
* unselectable. The modifier is what distinguishes "edit this text" from "follow
|
|
15
|
+
* this reference".
|
|
16
|
+
*/
|
|
17
|
+
/** Where a preview link pointed, and how to follow it. */
|
|
18
|
+
export interface PreviewLinkTarget {
|
|
19
|
+
href: string;
|
|
20
|
+
/** True for `#bookmark` links, which scroll instead of opening a tab. */
|
|
21
|
+
isAnchor: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads the link a painted piece carries.
|
|
25
|
+
*
|
|
26
|
+
* Returns null for anything that is not a usable link, including an empty href
|
|
27
|
+
* and a bare fragment. A `#` with no name would otherwise scroll to the top of
|
|
28
|
+
* the page and look like the link worked.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readPreviewLinkTarget(span: {
|
|
31
|
+
href?: string | null;
|
|
32
|
+
} | null | undefined): PreviewLinkTarget | null;
|
|
33
|
+
/** True when the event asks to follow a link rather than to select text. */
|
|
34
|
+
export declare function isPreviewLinkFollowGesture(event: {
|
|
35
|
+
ctrlKey?: boolean;
|
|
36
|
+
metaKey?: boolean;
|
|
37
|
+
}): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The props that make a painted piece follow its link on ctrl/cmd-click.
|
|
40
|
+
*
|
|
41
|
+
* Returned as a spreadable object rather than applied inside each renderer, so
|
|
42
|
+
* both paint paths (measured lines and the unmeasured fallback) attach exactly
|
|
43
|
+
* the same behavior. There are two paths and only one of them is exercised by a
|
|
44
|
+
* typical document, which is how one of them can quietly lose link handling.
|
|
45
|
+
*/
|
|
46
|
+
export interface PreviewLinkSpanBinding {
|
|
47
|
+
/** Spread onto the piece's element. Never carries `style`. */
|
|
48
|
+
attributes: Record<string, unknown>;
|
|
49
|
+
/**
|
|
50
|
+
* Style additions the renderer must MERGE into its own style object.
|
|
51
|
+
*
|
|
52
|
+
* Kept separate on purpose: a `style` inside the spread would replace the
|
|
53
|
+
* piece's font, color, decoration and geometry wholesale, which paints the
|
|
54
|
+
* link as unformatted text - the very failure this module exists to fix.
|
|
55
|
+
*/
|
|
56
|
+
style: {
|
|
57
|
+
cursor: 'pointer';
|
|
58
|
+
pointerEvents: 'auto';
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export declare function previewLinkSpanBinding(span: {
|
|
62
|
+
href?: string | null;
|
|
63
|
+
} | null | undefined): PreviewLinkSpanBinding | null;
|
|
64
|
+
/**
|
|
65
|
+
* Follows a link.
|
|
66
|
+
*
|
|
67
|
+
* Split from the decision so the click handler stays pure and this stays
|
|
68
|
+
* testable: the only environment touch is here, and it is guarded, because the
|
|
69
|
+
* paginated preview also renders during SSR.
|
|
70
|
+
*/
|
|
71
|
+
export declare function followPreviewLink(target: PreviewLinkTarget): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PreviewCommentHighlightState } from './virtual-paged-preview-comment-highlight.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal shape of the editor snapshot this projection needs.
|
|
4
|
+
*
|
|
5
|
+
* Declared structurally rather than importing `BrowserEditorSessionSnapshot` so
|
|
6
|
+
* the function stays testable without building a whole session, and so the react
|
|
7
|
+
* package does not take a runtime dependency on the SDK just to read two fields.
|
|
8
|
+
*/
|
|
9
|
+
interface SnapshotCommentSource {
|
|
10
|
+
comments: {
|
|
11
|
+
items: readonly {
|
|
12
|
+
id: string;
|
|
13
|
+
resolved?: boolean | null;
|
|
14
|
+
deletedAt?: string | null;
|
|
15
|
+
}[];
|
|
16
|
+
activeCommentIds?: readonly string[] | null;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Comment state for the page, derived from the editor snapshot.
|
|
21
|
+
*
|
|
22
|
+
* The sidebar already knew which thread the user is reading; the page did not, so
|
|
23
|
+
* selecting a thread highlighted only the sidebar entry and the document gave no
|
|
24
|
+
* indication of where the thread sat. This projects the same snapshot onto the
|
|
25
|
+
* renderer: the active thread gets the strong tint, resolved threads fade, and
|
|
26
|
+
* everything else is open.
|
|
27
|
+
*
|
|
28
|
+
* `deletedAt` is treated as resolved rather than open: a deleted thread should
|
|
29
|
+
* not draw attention, but it still anchors text that has to remain findable.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveSnapshotCommentState(snapshot: SnapshotCommentSource | null | undefined, activeCommentId: string | null): (commentId: string) => PreviewCommentHighlightState;
|
|
32
|
+
export {};
|