@datalking/begonia-browser-sdk 0.2.0 → 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/browser-command-table-state.d.ts +5 -0
- package/dist/browser-command-types.d.ts +3 -1
- package/dist/browser-comment-range-point.d.ts +56 -0
- package/dist/browser-editor-comments-controller.d.ts +2 -1
- package/dist/browser-editor-context-menu-open-at.d.ts +15 -0
- package/dist/browser-editor-contracts.d.ts +6 -0
- package/dist/browser-editor-domain-types.d.ts +48 -1
- package/dist/browser-editor-host.d.ts +0 -2
- package/dist/browser-editor-selection-geometry.d.ts +135 -1
- package/dist/browser-editor-types-controller.d.ts +46 -1
- package/dist/browser-editor-types-shared.d.ts +17 -0
- package/dist/browser-editor-viewport/browser-editor-viewport-bounds.d.ts +1 -1
- package/dist/browser-editor-viewport-session-state-types.d.ts +15 -0
- package/dist/browser-history-shortcut.d.ts +31 -0
- package/dist/browser-image-command-types.d.ts +28 -0
- package/dist/browser-insert-command-types.d.ts +5 -0
- package/dist/browser-page-review-target.d.ts +44 -0
- package/dist/browser-paginated-preview-editor-binding.d.ts +76 -1
- package/dist/browser-paginated-preview-key-selection.d.ts +48 -0
- package/dist/browser-paginated-preview-position-hit.d.ts +28 -0
- package/dist/browser-table-target-resolution.d.ts +59 -0
- package/dist/command.js +5 -5
- package/dist/editor.d.ts +8 -0
- package/dist/editor.js +5 -4
- package/dist/header-footer/header-footer-band-geometry.d.ts +70 -0
- package/dist/header-footer/header-footer-band-press.d.ts +51 -0
- package/dist/header-footer/header-footer-edit-state.d.ts +44 -0
- package/dist/header-footer/header-footer-edit-target.d.ts +54 -0
- package/dist/header-footer/header-footer-editing-controller.d.ts +133 -0
- package/dist/header-footer/header-footer-exit-press.d.ts +54 -0
- package/dist/header-footer/header-footer-slot.d.ts +38 -0
- package/dist/header-footer/header-footer-story-blocks.d.ts +71 -0
- package/dist/header-footer/section-header-footer-links.d.ts +60 -0
- package/dist/header-footer/section-header-footer-variants.d.ts +55 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +60 -5
- package/dist/ooxml.js +4 -4
- package/dist/paginated-editing/index.d.ts +7 -0
- package/dist/paginated-editing/paginated-caret-reveal.d.ts +51 -0
- package/dist/paginated-editing/paginated-column-keyboard.d.ts +50 -0
- package/dist/paginated-editing/paginated-editing-session.d.ts +8 -0
- package/dist/paginated-editing/paginated-editing-types.d.ts +169 -0
- package/dist/paginated-editing/paginated-ime-caret-measure.d.ts +26 -0
- package/dist/paginated-editing/paginated-input-anchor.d.ts +116 -0
- package/dist/paginated-editing/paginated-input-bridge.d.ts +169 -0
- package/dist/paginated-editing/paginated-table-boundary-keyboard.d.ts +24 -0
- package/dist/paginated-editing/paginated-table-boundary-keys.d.ts +33 -0
- package/dist/paginated-preview-selection-table/preview-selection-table-exit.d.ts +61 -0
- package/dist/paginated-preview-selection-table/preview-selection-table-resolve.d.ts +7 -2
- package/dist/preview.js +1 -1
- package/dist/theme/theme-tokens.d.ts +35 -1
- package/dist/theme.js +1 -1
- package/dist/v1.d.ts +6 -0
- package/dist/v1.js +9 -9
- package/package.json +14 -14
|
@@ -1,15 +1,79 @@
|
|
|
1
|
-
import type { EditorLayoutAdapter, LayoutProjection, LayoutProjectionOptions } from '@datalking/begonia-layout-contracts';
|
|
1
|
+
import type { EditorLayoutAdapter, LayoutProjection, LayoutProjectionOptions, PageMargins, PageProjection, PageSize } from '@datalking/begonia-layout-contracts';
|
|
2
2
|
import type { BrowserPaginatedPreviewSelectionActions } from './browser-paginated-preview-selection-actions.ts';
|
|
3
3
|
import type { BrowserEditorState } from './browser-editor-types-state.ts';
|
|
4
4
|
import type { BrowserEditorZoomViewportMetrics, BrowserPreviewNavigationRequest, BrowserPreviewNavigationRequestInput, BrowserViewStatePatch } from './browser-editor-types-shared.ts';
|
|
5
|
+
/**
|
|
6
|
+
* Page geometry owned by one document section.
|
|
7
|
+
*
|
|
8
|
+
* Sections exist because Word lets a document change its page setup partway
|
|
9
|
+
* through - a landscape page inside a portrait report, a two-column appendix
|
|
10
|
+
* after a single-column body. Everything here is therefore per-section rather
|
|
11
|
+
* than per-document.
|
|
12
|
+
*/
|
|
13
|
+
export interface BrowserPreviewSectionMetadata {
|
|
14
|
+
sectionIndex: number;
|
|
15
|
+
sectionId: string;
|
|
16
|
+
pageNumberStart: number;
|
|
17
|
+
pageCount: number;
|
|
18
|
+
pageSize: PageSize;
|
|
19
|
+
margins: PageMargins;
|
|
20
|
+
columnCount: number;
|
|
21
|
+
columnWidths: readonly number[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Where the last pointer press asked for the caret to be painted.
|
|
25
|
+
*
|
|
26
|
+
* A collapsed offset at a soft wrap, a column break or a page break belongs to
|
|
27
|
+
* two line boxes. The press itself decides which one paints the caret: near the
|
|
28
|
+
* end of a line stays on that line, near the start of the next opens the next
|
|
29
|
+
* one. The offset never changes; only the painted side does.
|
|
30
|
+
*/
|
|
31
|
+
export interface BrowserPaginatedPreviewPointerCaretOrigin {
|
|
32
|
+
/** Projection page the pointer was on. */
|
|
33
|
+
pageNumber: number;
|
|
34
|
+
/** Pointer x in projection space, the same space line boxes use. */
|
|
35
|
+
x: number;
|
|
36
|
+
/** Pointer y in projection space. */
|
|
37
|
+
y: number;
|
|
38
|
+
/**
|
|
39
|
+
* Editor selection offset the press produced.
|
|
40
|
+
*
|
|
41
|
+
* A stale press must not bias a caret it did not place, so the origin only
|
|
42
|
+
* applies while the selection still sits at this offset. Keyboard input
|
|
43
|
+
* clears it outright, which keeps navigation on the structural side.
|
|
44
|
+
*/
|
|
45
|
+
selectionOffset: number;
|
|
46
|
+
}
|
|
5
47
|
export interface BrowserPaginatedPreviewEditorBinding {
|
|
6
48
|
readLayoutAdapter(): EditorLayoutAdapter<unknown> | null;
|
|
7
49
|
readLayoutSource(): unknown | null;
|
|
8
50
|
readDocumentSize?(): number | null;
|
|
9
51
|
getResolvedProjection?(): LayoutProjection | null;
|
|
52
|
+
/**
|
|
53
|
+
* Pages of the current layout, for pagination UI that needs the page list
|
|
54
|
+
* itself rather than a single lookup.
|
|
55
|
+
*
|
|
56
|
+
* Returns an empty list until a projection has been resolved, so a caller can
|
|
57
|
+
* render page chrome before the first layout pass without special-casing
|
|
58
|
+
* null.
|
|
59
|
+
*/
|
|
60
|
+
getPages?(): readonly PageProjection[];
|
|
61
|
+
/**
|
|
62
|
+
* Per-section page geometry, in document order.
|
|
63
|
+
*
|
|
64
|
+
* A Word document may switch page size, orientation, margins or column count
|
|
65
|
+
* partway through, so a host drawing page chrome cannot assume one geometry
|
|
66
|
+
* for the whole document. Each entry carries the geometry its section's pages
|
|
67
|
+
* actually use, which is what superdoc exposes via getLayoutSnapshot().
|
|
68
|
+
*
|
|
69
|
+
* Empty until a projection has been resolved.
|
|
70
|
+
*/
|
|
71
|
+
getSectionMetadata?(): readonly BrowserPreviewSectionMetadata[];
|
|
10
72
|
getResolvedProjectionGeometryOptions?(): BrowserPaginatedPreviewProjectionGeometryOptions | null;
|
|
11
73
|
setResolvedProjection?(projection: LayoutProjection | null, geometryOptions?: BrowserPaginatedPreviewProjectionGeometryOptions | null): void;
|
|
12
74
|
subscribeResolvedProjection?(listener: (projection: LayoutProjection | null) => void): () => void;
|
|
75
|
+
getPointerCaretOrigin?(): BrowserPaginatedPreviewPointerCaretOrigin | null;
|
|
76
|
+
setPointerCaretOrigin?(origin: BrowserPaginatedPreviewPointerCaretOrigin | null): void;
|
|
13
77
|
selection?: BrowserPaginatedPreviewSelectionActions<unknown>;
|
|
14
78
|
getState(): BrowserEditorState | null;
|
|
15
79
|
subscribe(listener: (state: BrowserEditorState) => void): () => void;
|
|
@@ -23,6 +87,17 @@ export interface BrowserPaginatedPreviewProjectionGeometryOptions {
|
|
|
23
87
|
measurementEpoch?: LayoutProjectionOptions['measurementEpoch'];
|
|
24
88
|
}
|
|
25
89
|
export declare function readBrowserPaginatedPreviewDocument(binding: BrowserPaginatedPreviewEditorBinding | null | undefined): unknown;
|
|
90
|
+
/**
|
|
91
|
+
* Do two layout sources describe the same document?
|
|
92
|
+
*
|
|
93
|
+
* The same ProseMirror document can be reached through more than one accessor
|
|
94
|
+
* (the surface document, the preview binding's layout source, a projected
|
|
95
|
+
* document, ...). Each call may hand back a distinct-but-equal node instance, so
|
|
96
|
+
* layer identity checks must compare structure, not references. Reference
|
|
97
|
+
* equality stays first because it is both the common case and the cheap one.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isSameLayoutDocument(left: unknown, right: unknown): boolean;
|
|
26
100
|
export declare function readBrowserPaginatedPreviewDocumentSize(binding: BrowserPaginatedPreviewEditorBinding | null | undefined): number | null;
|
|
27
101
|
export declare function readBrowserPaginatedPreviewResolvedProjection(binding: BrowserPaginatedPreviewEditorBinding | null | undefined): LayoutProjection | null;
|
|
28
102
|
export declare function readBrowserPaginatedPreviewResolvedProjectionGeometryOptions(binding: BrowserPaginatedPreviewEditorBinding | null | undefined): BrowserPaginatedPreviewProjectionGeometryOptions | null;
|
|
103
|
+
export declare function readBrowserPaginatedPreviewPointerCaretOrigin(binding: BrowserPaginatedPreviewEditorBinding | null | undefined): BrowserPaginatedPreviewPointerCaretOrigin | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { LayoutProjection, LayoutProjectionOptions, LayoutTextMeasure } from '@datalking/begonia-layout-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* What a keydown means to a paginated preview.
|
|
4
|
+
*
|
|
5
|
+
* The preview paints its own pages and is not contenteditable, so the browser's
|
|
6
|
+
* native caret never sees the layout: pressing Down in a paginated document
|
|
7
|
+
* cannot be left to the browser, because there is no native caret to move and no
|
|
8
|
+
* native notion of where a line ends. This is the layer that decides which keys
|
|
9
|
+
* the preview handles and what selection they produce.
|
|
10
|
+
*
|
|
11
|
+
* `null` means "not mine" - the caller must not call `preventDefault`, because an
|
|
12
|
+
* unhandled key still has a default the user may want: an arrow key scrolls the
|
|
13
|
+
* page, and Ctrl+F opens find.
|
|
14
|
+
*/
|
|
15
|
+
export interface PaginatedPreviewKeySelectionInput {
|
|
16
|
+
projection: LayoutProjection;
|
|
17
|
+
anchor: number;
|
|
18
|
+
head: number;
|
|
19
|
+
key: string;
|
|
20
|
+
shiftKey?: boolean | null;
|
|
21
|
+
altKey?: boolean | null;
|
|
22
|
+
ctrlKey?: boolean | null;
|
|
23
|
+
metaKey?: boolean | null;
|
|
24
|
+
measureText?: LayoutTextMeasure;
|
|
25
|
+
measurementEpoch?: LayoutProjectionOptions['measurementEpoch'];
|
|
26
|
+
}
|
|
27
|
+
export interface PaginatedPreviewKeySelectionResult {
|
|
28
|
+
anchor: number;
|
|
29
|
+
head: number;
|
|
30
|
+
from: number;
|
|
31
|
+
to: number;
|
|
32
|
+
empty: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The selection a navigation key produces, or `null` if this layer does not
|
|
36
|
+
* handle the key.
|
|
37
|
+
*
|
|
38
|
+
* Alt-modified keys are declined: Alt+Up moves a block in Word, which is an edit
|
|
39
|
+
* and not caret motion, and answering it here would move the caret where the
|
|
40
|
+
* caller meant to restructure the document. Ctrl+Home and Ctrl+End are accepted
|
|
41
|
+
* for the opposite reason - jumping to the start or end of a document is still
|
|
42
|
+
* caret motion, so declining them would leave the keys doing nothing.
|
|
43
|
+
*
|
|
44
|
+
* Every accepted path ends in the same place: a landing offset, folded into a
|
|
45
|
+
* selection by `toSelection`. Having one fold rather than one per branch is what
|
|
46
|
+
* keeps Shift meaning the same thing for all five keys.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolvePaginatedPreviewKeySelection(input: PaginatedPreviewKeySelectionInput): PaginatedPreviewKeySelectionResult | null;
|
|
@@ -11,7 +11,21 @@ export interface BrowserPaginatedPreviewSelectionAnchor {
|
|
|
11
11
|
resolvedSelectionPos?: number | null;
|
|
12
12
|
resolvedSelectionRange?: PreviewTextSelectionRange | null;
|
|
13
13
|
resolvedSelectionClickCount?: number | null;
|
|
14
|
+
/**
|
|
15
|
+
* A press in the paper right of a table's last row when the document has no
|
|
16
|
+
* text after the table. The surface has to insert an empty paragraph at this
|
|
17
|
+
* position before applying `resolvedSelectionPos`.
|
|
18
|
+
*/
|
|
19
|
+
resolvedTableExitInsertAt?: number | null;
|
|
14
20
|
target?: EventTarget | null;
|
|
21
|
+
/**
|
|
22
|
+
* Pointer position in viewport coordinates.
|
|
23
|
+
*
|
|
24
|
+
* The browser's own caret APIs answer in viewport space, so a DOM-first
|
|
25
|
+
* resolver needs the raw coordinates rather than the projection-space ones.
|
|
26
|
+
*/
|
|
27
|
+
clientX?: number | null;
|
|
28
|
+
clientY?: number | null;
|
|
15
29
|
}
|
|
16
30
|
export interface BrowserPaginatedPreviewPositionHitEvent {
|
|
17
31
|
projection: LayoutProjection;
|
|
@@ -27,5 +41,19 @@ export interface BrowserPaginatedPreviewPositionHitEvent {
|
|
|
27
41
|
resolvedSelectionPos?: number | null;
|
|
28
42
|
resolvedSelectionRange?: PreviewTextSelectionRange | null;
|
|
29
43
|
resolvedSelectionClickCount?: number | null;
|
|
44
|
+
/**
|
|
45
|
+
* A press in the paper right of a table's last row when the document has no
|
|
46
|
+
* text after the table. The surface has to insert an empty paragraph at this
|
|
47
|
+
* position before applying `resolvedSelectionPos`.
|
|
48
|
+
*/
|
|
49
|
+
resolvedTableExitInsertAt?: number | null;
|
|
30
50
|
target?: EventTarget | null;
|
|
51
|
+
/**
|
|
52
|
+
* Pointer position in viewport coordinates.
|
|
53
|
+
*
|
|
54
|
+
* The browser's own caret APIs answer in viewport space, so a DOM-first
|
|
55
|
+
* resolver needs the raw coordinates rather than the projection-space ones.
|
|
56
|
+
*/
|
|
57
|
+
clientX?: number | null;
|
|
58
|
+
clientY?: number | null;
|
|
31
59
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
type EditorState = any;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Which table cell the caret is in, in the terms the table facade speaks.
|
|
5
|
+
*
|
|
6
|
+
* Two vocabularies meet here. ProseMirror knows the caret only as a position and
|
|
7
|
+
* can tell us the chain of indexes from the document root; the table facade
|
|
8
|
+
* addresses cells by *logical* row and column, which differ from the physical
|
|
9
|
+
* ones as soon as a cell spans. Rather than re-deriving the grid — and getting
|
|
10
|
+
* it wrong for a row that a vertical merge consumes — the physical doc path is
|
|
11
|
+
* matched against the records the facade already built, which carry both
|
|
12
|
+
* coordinates and the spans.
|
|
13
|
+
*/
|
|
14
|
+
export interface BrowserTableTarget {
|
|
15
|
+
/** Doc path of the table node, as `documentApi.tables` expects it. */
|
|
16
|
+
tablePath: number[];
|
|
17
|
+
/** Doc path of the cell holding the caret. */
|
|
18
|
+
cellPath: number[];
|
|
19
|
+
rowIndex: number;
|
|
20
|
+
columnIndex: number;
|
|
21
|
+
rowCount: number;
|
|
22
|
+
columnCount: number;
|
|
23
|
+
colSpan: number;
|
|
24
|
+
rowSpan: number;
|
|
25
|
+
}
|
|
26
|
+
export interface BrowserTableRecordLike {
|
|
27
|
+
path: readonly number[];
|
|
28
|
+
rowCount: number;
|
|
29
|
+
columnCount: number;
|
|
30
|
+
rows: readonly {
|
|
31
|
+
cells: readonly {
|
|
32
|
+
path: readonly number[];
|
|
33
|
+
rowIndex: number;
|
|
34
|
+
columnIndex: number;
|
|
35
|
+
colSpan: number;
|
|
36
|
+
rowSpan: number;
|
|
37
|
+
}[];
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the caret's table cell, or null when the caret is outside a table.
|
|
42
|
+
*
|
|
43
|
+
* The lookup is by path rather than by index arithmetic because a table record's
|
|
44
|
+
* `cells` are the *physical* cells of its row: a row whose first column is
|
|
45
|
+
* covered by a vertical merge simply has fewer of them. Counting to the caret
|
|
46
|
+
* would land on the wrong cell there.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveBrowserTableTarget(state: EditorState, tables: readonly BrowserTableRecordLike[]): BrowserTableTarget | null;
|
|
49
|
+
/**
|
|
50
|
+
* The rectangle a selection covers inside one table, in logical coordinates.
|
|
51
|
+
*
|
|
52
|
+
* Returns null unless both ends of the selection are in the same table, because
|
|
53
|
+
* a merge across two tables has no meaning and the facade would reject it with a
|
|
54
|
+
* less useful message than "select one cell".
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveBrowserTableSelectionRange(state: EditorState, tables: readonly BrowserTableRecordLike[]): {
|
|
57
|
+
start: BrowserTableTarget;
|
|
58
|
+
end: BrowserTableTarget;
|
|
59
|
+
} | null;
|