@docx-editor.dev/core 0.0.1 → 2.1.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/LICENSE +201 -0
- package/README.md +91 -2
- package/THIRD_PARTY_NOTICES.md +18 -0
- package/dist/automation.cjs +1 -0
- package/dist/automation.d.cts +74 -0
- package/dist/automation.d.ts +74 -0
- package/dist/automation.js +1 -0
- package/dist/binding.cjs +1 -0
- package/dist/binding.d.cts +88 -0
- package/dist/binding.d.ts +88 -0
- package/dist/binding.js +1 -0
- package/dist/chunk-2DTQDAN7.js +2 -0
- package/dist/chunk-3JKQE4QJ.cjs +2 -0
- package/dist/chunk-4WWEDTTE.js +2 -0
- package/dist/chunk-6WIIHJFY.js +1 -0
- package/dist/chunk-7VQ7YLW3.cjs +1 -0
- package/dist/chunk-BS554B6D.cjs +2 -0
- package/dist/chunk-BZK64YU3.cjs +10 -0
- package/dist/chunk-CZFUMACF.cjs +12 -0
- package/dist/chunk-GQQOL4PV.js +1 -0
- package/dist/chunk-HBL3NNH5.cjs +1 -0
- package/dist/chunk-JQFDLZXQ.cjs +2 -0
- package/dist/chunk-O2WQY7IT.cjs +5 -0
- package/dist/chunk-PC76F2HR.cjs +1 -0
- package/dist/chunk-QRAUDDVY.js +2 -0
- package/dist/chunk-REZUWYB7.js +1 -0
- package/dist/chunk-STCITBJK.js +12 -0
- package/dist/chunk-TBBXCC7D.js +5 -0
- package/dist/chunk-TSXT537P.cjs +12 -0
- package/dist/chunk-WOGYVM3W.js +12 -0
- package/dist/chunk-Y7TA7TPF.js +10 -0
- package/dist/content-control-walk-CbTqHq6O.d.cts +56 -0
- package/dist/content-control-walk-D06GijR0.d.ts +56 -0
- package/dist/contracts/document.cjs +1 -0
- package/dist/contracts/document.d.cts +246 -0
- package/dist/contracts/document.d.ts +246 -0
- package/dist/contracts/document.js +0 -0
- package/dist/contracts/editor.cjs +1 -0
- package/dist/contracts/editor.d.cts +11 -0
- package/dist/contracts/editor.d.ts +11 -0
- package/dist/contracts/editor.js +1 -0
- package/dist/contracts/interaction.cjs +1 -0
- package/dist/contracts/interaction.d.cts +11 -0
- package/dist/contracts/interaction.d.ts +11 -0
- package/dist/contracts/interaction.js +0 -0
- package/dist/contracts/modules.cjs +1 -0
- package/dist/contracts/modules.d.cts +117 -0
- package/dist/contracts/modules.d.ts +117 -0
- package/dist/contracts/modules.js +1 -0
- package/dist/contracts/types.cjs +1 -0
- package/dist/contracts/types.d.cts +452 -0
- package/dist/contracts/types.d.ts +452 -0
- package/dist/contracts/types.js +0 -0
- package/dist/custom-node-writes-YqISlSRl.d.cts +885 -0
- package/dist/custom-node-writes-ttKuYd0M.d.ts +885 -0
- package/dist/editor-B93PggnR.d.cts +1690 -0
- package/dist/editor-CFsSrxGR.d.ts +1690 -0
- package/dist/editor.cjs +1 -0
- package/dist/editor.css +7106 -0
- package/dist/editor.d.cts +271 -0
- package/dist/editor.d.ts +271 -0
- package/dist/editor.js +1 -0
- package/dist/hf-references-BdjsQNE_.d.ts +71 -0
- package/dist/hf-references-CgEOSw3i.d.cts +71 -0
- package/dist/image-resources-C_YnqPhn.d.ts +203 -0
- package/dist/image-resources-DwpNnTg3.d.cts +203 -0
- package/dist/index-BjZelfWL.d.cts +2532 -0
- package/dist/index-DP1yJJ3R.d.ts +2532 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +1 -0
- package/dist/layout.cjs +1 -0
- package/dist/layout.d.cts +2366 -0
- package/dist/layout.d.ts +2366 -0
- package/dist/layout.js +1 -0
- package/dist/note-nodes-BPSTVDMr.d.ts +108 -0
- package/dist/note-nodes-C6DLxlvj.d.cts +108 -0
- package/dist/ooxml-package-CR5us6ad.d.cts +354 -0
- package/dist/ooxml-package-D_CtywTW.d.ts +354 -0
- package/dist/ooxml-tree-BU0e3DVi.d.cts +871 -0
- package/dist/ooxml-tree-BU0e3DVi.d.ts +871 -0
- package/dist/output.cjs +1 -0
- package/dist/output.d.cts +158 -0
- package/dist/output.d.ts +158 -0
- package/dist/output.js +1 -0
- package/dist/protocol-BWVA3Q1p.d.ts +1255 -0
- package/dist/protocol-FAz_nPm_.d.cts +1255 -0
- package/dist/review-reads-CsoXSvUg.d.ts +401 -0
- package/dist/review-reads-qW0jvdF1.d.cts +401 -0
- package/dist/review-support-D64Wu236.d.cts +358 -0
- package/dist/review-support-nsLXC9jf.d.ts +358 -0
- package/dist/revision-projection-72ZApe-g.d.cts +84 -0
- package/dist/revision-projection-DHAkcD_L.d.ts +84 -0
- package/dist/semantic-cell-selection-D_8RbPII.d.ts +427 -0
- package/dist/semantic-cell-selection-DwLB71fF.d.cts +427 -0
- package/dist/semantic-interaction-CXH2wFqi.d.ts +187 -0
- package/dist/semantic-interaction-DqcEonqD.d.cts +187 -0
- package/dist/semantic-paint-drawings-B5Wk2so5.d.ts +21 -0
- package/dist/semantic-paint-drawings-x8g44lD_.d.cts +21 -0
- package/dist/semantic-records-COVFW5aS.d.cts +1505 -0
- package/dist/semantic-records-zTC0_1zi.d.ts +1505 -0
- package/dist/shaped-measurer-AFnFxoot.d.cts +613 -0
- package/dist/shaped-measurer-CZXL-a6v.d.ts +613 -0
- package/dist/store.cjs +1 -0
- package/dist/store.d.cts +2153 -0
- package/dist/store.d.ts +2153 -0
- package/dist/store.js +1 -0
- package/dist/tree-op-types-DWLCllG7.d.ts +1486 -0
- package/dist/tree-op-types-UOXlRUqQ.d.cts +1486 -0
- package/dist/tree-session-BtVFXsF6.d.ts +580 -0
- package/dist/tree-session-DxIOHUOD.d.cts +580 -0
- package/dist/tree-store-B1lEkdXc.d.cts +273 -0
- package/dist/tree-store-BscFPB7x.d.ts +273 -0
- package/package.json +110 -8
- package/index.js +0 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { T as TextMeasurer, S as SemanticLayout, B as BlockFragmentRecord, C as ContentControlBoundaryRecord, a as StyleSpanRecord } from './semantic-records-COVFW5aS.cjs';
|
|
2
|
+
|
|
3
|
+
/** A caret position in the model. */
|
|
4
|
+
interface SemanticPosition {
|
|
5
|
+
readonly paragraphId: string;
|
|
6
|
+
readonly offset: number;
|
|
7
|
+
}
|
|
8
|
+
/** A caret position with the geometry that renders it. */
|
|
9
|
+
interface CaretGeometry {
|
|
10
|
+
readonly position: SemanticPosition;
|
|
11
|
+
/** Page-relative, in the same coordinate space as the line boxes. */
|
|
12
|
+
readonly x: number;
|
|
13
|
+
readonly y: number;
|
|
14
|
+
readonly height: number;
|
|
15
|
+
readonly lineId: string;
|
|
16
|
+
readonly pageIndex: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A selection as two semantic positions — never as DOM nodes.
|
|
20
|
+
*
|
|
21
|
+
* `anchor` is where the selection started and `head` is where it currently ends, so `head` before
|
|
22
|
+
* `anchor` is an ordinary backwards selection rather than an error. Collapsed when the two are
|
|
23
|
+
* equal, which is what a caret is.
|
|
24
|
+
*/
|
|
25
|
+
interface SemanticSelection {
|
|
26
|
+
readonly anchor: SemanticPosition;
|
|
27
|
+
readonly head: SemanticPosition;
|
|
28
|
+
}
|
|
29
|
+
/** One painted selection rectangle, in page-relative layout points. */
|
|
30
|
+
interface SelectionRect {
|
|
31
|
+
readonly pageIndex: number;
|
|
32
|
+
readonly x: number;
|
|
33
|
+
readonly y: number;
|
|
34
|
+
readonly width: number;
|
|
35
|
+
readonly height: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Every caret stop in the document body, in reading order.
|
|
39
|
+
*
|
|
40
|
+
* One per character boundary on every line, plus the line end. Derived rather than stored,
|
|
41
|
+
* so a stop can never survive the content it described. Ownership of a position SHARED by
|
|
42
|
+
* two lines is decided here exactly as `caretAt` decides it. Furniture stories use
|
|
43
|
+
* {@link caretStopsForBlocks} so open header/footer navigation never walks body stops.
|
|
44
|
+
*/
|
|
45
|
+
declare function caretStops(layout: SemanticLayout, measurer?: TextMeasurer): CaretGeometry[];
|
|
46
|
+
/**
|
|
47
|
+
* Caret stops for one story's block fragments (header/footer), in reading order.
|
|
48
|
+
*
|
|
49
|
+
* Coordinates stay story-relative — the same space `hitTestFragments` and furniture paint
|
|
50
|
+
* use — so arrow motion follows tab-stop geometry and projected field atoms without mixing
|
|
51
|
+
* body sheet offsets.
|
|
52
|
+
*/
|
|
53
|
+
declare function caretStopsForBlocks(layout: SemanticLayout, pageIndex: number, fragments: readonly BlockFragmentRecord[], measurer?: TextMeasurer): CaretGeometry[];
|
|
54
|
+
/**
|
|
55
|
+
* How caret geometry is resolved.
|
|
56
|
+
*
|
|
57
|
+
* `preferPage` disambiguates a paragraph that paints on SEVERAL pages — a shared header appears
|
|
58
|
+
* once per page, and without a preference the caret could be placed on any of its copies.
|
|
59
|
+
*/
|
|
60
|
+
interface CaretAtOptions {
|
|
61
|
+
readonly measurer?: TextMeasurer;
|
|
62
|
+
/**
|
|
63
|
+
* Prefer geometry from this sheet when the same paragraph paints on multiple pages
|
|
64
|
+
* (shared header/footer copies).
|
|
65
|
+
*/
|
|
66
|
+
readonly preferredPageIndex?: number;
|
|
67
|
+
}
|
|
68
|
+
/** Geometry for one model position, or null when it is not laid out. */
|
|
69
|
+
declare function caretAt(layout: SemanticLayout, position: SemanticPosition, measurerOrOptions?: TextMeasurer | CaretAtOptions): CaretGeometry | null;
|
|
70
|
+
/**
|
|
71
|
+
* The caret position nearest a point, in PAGE-CONTENT coordinates.
|
|
72
|
+
*
|
|
73
|
+
* Never returns null for a point inside the document: a click in the margin, past the end of
|
|
74
|
+
* a line, or below the last line still has an obvious intended caret, and refusing to answer
|
|
75
|
+
* would make those clicks do nothing.
|
|
76
|
+
*
|
|
77
|
+
* The rules live in `semantic-hit-test.ts`, which answers with the cell address and the
|
|
78
|
+
* on-glyphs flag a pointer controller needs too; this keeps the geometry-only shape for
|
|
79
|
+
* callers that want nothing else.
|
|
80
|
+
*/
|
|
81
|
+
declare function hitTestSemantic(layout: SemanticLayout, point: {
|
|
82
|
+
readonly x: number;
|
|
83
|
+
readonly y: number;
|
|
84
|
+
readonly pageIndex?: number;
|
|
85
|
+
}): CaretGeometry | null;
|
|
86
|
+
/**
|
|
87
|
+
* Innermost content-control boundary at a page-content point, or null outside every control.
|
|
88
|
+
*
|
|
89
|
+
* Prefers the deepest nesting depth when nested boundaries share geometry.
|
|
90
|
+
*/
|
|
91
|
+
declare function contentControlAtSemantic(layout: SemanticLayout, point: {
|
|
92
|
+
readonly x: number;
|
|
93
|
+
readonly y: number;
|
|
94
|
+
readonly pageIndex?: number;
|
|
95
|
+
}): ContentControlBoundaryRecord | null;
|
|
96
|
+
/** Layout-published content-control boundaries in document order. */
|
|
97
|
+
declare function contentControlsInLayout(layout: SemanticLayout): readonly ContentControlBoundaryRecord[];
|
|
98
|
+
/** The rectangles covering a selection, one per line it spans. */
|
|
99
|
+
declare function selectionRects(layout: SemanticLayout, selection: SemanticSelection): SelectionRect[];
|
|
100
|
+
/** A model range to highlight, and the key the caller knows it by. */
|
|
101
|
+
interface KeyedRange {
|
|
102
|
+
readonly key: string;
|
|
103
|
+
readonly from: SemanticPosition;
|
|
104
|
+
readonly to: SemanticPosition;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Rectangles for MANY ranges in ONE pass over the lines.
|
|
108
|
+
*
|
|
109
|
+
* Not `selectionRects` in a loop. That walks every page, fragment and line per range, and a
|
|
110
|
+
* contract with two hundred comments would re-walk the whole document two hundred times on
|
|
111
|
+
* every layout — the highlight would cost more than the layout it decorates. One pass tests
|
|
112
|
+
* each line against every range instead, which is the same work a single selection does.
|
|
113
|
+
*/
|
|
114
|
+
declare function keyedRangeRects(layout: SemanticLayout, ranges: readonly KeyedRange[],
|
|
115
|
+
/**
|
|
116
|
+
* Pages to measure, or every page when absent.
|
|
117
|
+
*
|
|
118
|
+
* A band that is not on screen is not painted, so measuring it is pure cost — and it is
|
|
119
|
+
* cost paid per keystroke, because an edit republishes the layout. Bounding this to the
|
|
120
|
+
* materialized pages is what keeps typing in a heavily reviewed document as fast as
|
|
121
|
+
* typing in a clean one.
|
|
122
|
+
*/
|
|
123
|
+
pages?: ReadonlySet<number>): Map<string, SelectionRect[]>;
|
|
124
|
+
/** Paragraph ids in document order, deduplicated across fragments. */
|
|
125
|
+
declare function documentOrder(layout: SemanticLayout): string[];
|
|
126
|
+
/**
|
|
127
|
+
* One caret movement, in Word's own vocabulary.
|
|
128
|
+
*
|
|
129
|
+
* Visual rather than logical where the two differ: `left` means left on screen, which in
|
|
130
|
+
* right-to-left text is forward through the string.
|
|
131
|
+
*/
|
|
132
|
+
type NavigationCommand = 'left' | 'right' | 'up' | 'down' | 'wordLeft' | 'wordRight' | 'lineStart' | 'lineEnd' | 'documentStart' | 'documentEnd' | 'pageUp' | 'pageDown';
|
|
133
|
+
/**
|
|
134
|
+
* The text of one paragraph, read back from the layout records.
|
|
135
|
+
*
|
|
136
|
+
* Word boundaries need characters, and the records carry them: every span holds the text it
|
|
137
|
+
* was laid out from, keyed by the source range it covers. Reading them back keeps word
|
|
138
|
+
* motion in the interaction lane instead of making it a second consumer of the model.
|
|
139
|
+
*/
|
|
140
|
+
declare function paragraphTextFromLayout(layout: SemanticLayout, paragraphId: string): string;
|
|
141
|
+
/**
|
|
142
|
+
* The next word boundary from `offset`, in `direction`.
|
|
143
|
+
*
|
|
144
|
+
* Word-LEFT skips any whitespace immediately behind the caret and then the word behind that,
|
|
145
|
+
* which is what every editor does and what makes repeated presses walk words rather than
|
|
146
|
+
* alternate between a word and the space before it. Word-RIGHT stops at the END of the
|
|
147
|
+
* current word, then skips the following whitespace on the next press.
|
|
148
|
+
*/
|
|
149
|
+
declare function wordBoundary(text: string, offset: number, direction: -1 | 1): number;
|
|
150
|
+
/**
|
|
151
|
+
* How a caret move resolves.
|
|
152
|
+
*
|
|
153
|
+
* Story-scoped stops are REQUIRED when navigating inside an open header or footer: the body's
|
|
154
|
+
* stops describe a different story, and moving through them would walk the caret out of the
|
|
155
|
+
* furniture the user is editing.
|
|
156
|
+
*/
|
|
157
|
+
interface MoveCaretOptions {
|
|
158
|
+
/**
|
|
159
|
+
* Precomputed stops for the active story. Open header/footer navigation MUST pass
|
|
160
|
+
* story-scoped stops from {@link caretStopsForBlocks}; body keeps the default.
|
|
161
|
+
*/
|
|
162
|
+
readonly stops?: readonly CaretGeometry[];
|
|
163
|
+
readonly measurer?: TextMeasurer;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Move a caret.
|
|
167
|
+
*
|
|
168
|
+
* Vertical movement keeps a DESIRED X so a caret travelling through short lines returns to
|
|
169
|
+
* its original column rather than collapsing to the end of the shortest one. The caller
|
|
170
|
+
* threads that value; passing null starts a fresh vertical run from the current position.
|
|
171
|
+
*/
|
|
172
|
+
declare function moveCaret(layout: SemanticLayout, position: SemanticPosition, command: NavigationCommand, desiredX?: number | null, options?: MoveCaretOptions): {
|
|
173
|
+
position: SemanticPosition;
|
|
174
|
+
desiredX: number | null;
|
|
175
|
+
} | null;
|
|
176
|
+
/**
|
|
177
|
+
* The anchor an IME composition is attached to.
|
|
178
|
+
*
|
|
179
|
+
* Composition needs a position that survives the intermediate transactions it produces, so
|
|
180
|
+
* it is expressed in model coordinates and re-resolved against each new layout rather than
|
|
181
|
+
* cached as geometry.
|
|
182
|
+
*/
|
|
183
|
+
declare function compositionAnchor(layout: SemanticLayout, position: SemanticPosition): CaretGeometry | null;
|
|
184
|
+
/** The style spans a selection touches, for reporting active formatting. */
|
|
185
|
+
declare function spansInSelection(layout: SemanticLayout, selection: SemanticSelection): StyleSpanRecord[];
|
|
186
|
+
|
|
187
|
+
export { type CaretGeometry as C, type KeyedRange as K, type MoveCaretOptions as M, type NavigationCommand as N, type SemanticPosition as S, type SemanticSelection as a, type CaretAtOptions as b, type SelectionRect as c, caretAt as d, caretStops as e, caretStopsForBlocks as f, compositionAnchor as g, contentControlAtSemantic as h, contentControlsInLayout as i, documentOrder as j, hitTestSemantic as k, keyedRangeRects as l, moveCaret as m, spansInSelection as n, paragraphTextFromLayout as p, selectionRects as s, wordBoundary as w };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { V as ValidatedImageBytesHandle, R as RenderableImageMime } from './image-resources-C_YnqPhn.js';
|
|
2
|
+
|
|
3
|
+
/** Host port for safe blob URLs — only called for {@link ImageResourceState.kind} `ready`. */
|
|
4
|
+
interface PaintImageUrlPort {
|
|
5
|
+
create(handle: ValidatedImageBytesHandle, mime: RenderableImageMime): string;
|
|
6
|
+
revoke(url: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** Localized refusal labels; adapters supply i18n-backed implementations. */
|
|
9
|
+
interface DrawingPaintStrings {
|
|
10
|
+
readonly unsupportedFormat: (format: string) => string;
|
|
11
|
+
readonly nonPictureGraphic: (kind: string) => string;
|
|
12
|
+
readonly missingResource: string;
|
|
13
|
+
readonly externalResource: string;
|
|
14
|
+
readonly invalidResource: string;
|
|
15
|
+
readonly contentMismatch: string;
|
|
16
|
+
readonly decodeFailed: string;
|
|
17
|
+
readonly resourceLimit: string;
|
|
18
|
+
readonly pendingResource: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type { DrawingPaintStrings as D, PaintImageUrlPort as P };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { V as ValidatedImageBytesHandle, R as RenderableImageMime } from './image-resources-DwpNnTg3.cjs';
|
|
2
|
+
|
|
3
|
+
/** Host port for safe blob URLs — only called for {@link ImageResourceState.kind} `ready`. */
|
|
4
|
+
interface PaintImageUrlPort {
|
|
5
|
+
create(handle: ValidatedImageBytesHandle, mime: RenderableImageMime): string;
|
|
6
|
+
revoke(url: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** Localized refusal labels; adapters supply i18n-backed implementations. */
|
|
9
|
+
interface DrawingPaintStrings {
|
|
10
|
+
readonly unsupportedFormat: (format: string) => string;
|
|
11
|
+
readonly nonPictureGraphic: (kind: string) => string;
|
|
12
|
+
readonly missingResource: string;
|
|
13
|
+
readonly externalResource: string;
|
|
14
|
+
readonly invalidResource: string;
|
|
15
|
+
readonly contentMismatch: string;
|
|
16
|
+
readonly decodeFailed: string;
|
|
17
|
+
readonly resourceLimit: string;
|
|
18
|
+
readonly pendingResource: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type { DrawingPaintStrings as D, PaintImageUrlPort as P };
|