postext 1.102.0 → 1.103.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/README.md +3 -0
- package/dist/__tests__/annotate/anchors.test.d.ts +2 -0
- package/dist/__tests__/annotate/anchors.test.d.ts.map +1 -0
- package/dist/__tests__/annotate/anchors.test.js +161 -0
- package/dist/__tests__/annotate/anchors.test.js.map +1 -0
- package/dist/__tests__/annotate/fontPx.test.d.ts +2 -0
- package/dist/__tests__/annotate/fontPx.test.d.ts.map +1 -0
- package/dist/__tests__/annotate/fontPx.test.js +25 -0
- package/dist/__tests__/annotate/fontPx.test.js.map +1 -0
- package/dist/__tests__/annotate/marks.test.d.ts +2 -0
- package/dist/__tests__/annotate/marks.test.d.ts.map +1 -0
- package/dist/__tests__/annotate/marks.test.js +205 -0
- package/dist/__tests__/annotate/marks.test.js.map +1 -0
- package/dist/__tests__/defaults/headingsBalancing.test.js +8 -0
- package/dist/__tests__/defaults/headingsBalancing.test.js.map +1 -1
- package/dist/__tests__/exports.test.js +8 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/geometry/rangeGeometry.test.d.ts +2 -0
- package/dist/__tests__/geometry/rangeGeometry.test.d.ts.map +1 -0
- package/dist/__tests__/geometry/rangeGeometry.test.js +167 -0
- package/dist/__tests__/geometry/rangeGeometry.test.js.map +1 -0
- package/dist/__tests__/paint/pageTransform.test.d.ts +2 -0
- package/dist/__tests__/paint/pageTransform.test.d.ts.map +1 -0
- package/dist/__tests__/paint/pageTransform.test.js +39 -0
- package/dist/__tests__/paint/pageTransform.test.js.map +1 -0
- package/dist/__tests__/pipeline/columns/shrinkListSpacing.test.d.ts +2 -0
- package/dist/__tests__/pipeline/columns/shrinkListSpacing.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/columns/shrinkListSpacing.test.js +91 -0
- package/dist/__tests__/pipeline/columns/shrinkListSpacing.test.js.map +1 -0
- package/dist/annotate/anchors.d.ts +70 -0
- package/dist/annotate/anchors.d.ts.map +1 -0
- package/dist/annotate/anchors.js +99 -0
- package/dist/annotate/anchors.js.map +1 -0
- package/dist/annotate/edits.d.ts +52 -0
- package/dist/annotate/edits.d.ts.map +1 -0
- package/dist/annotate/edits.js +84 -0
- package/dist/annotate/edits.js.map +1 -0
- package/dist/annotate/index.d.ts +17 -0
- package/dist/annotate/index.d.ts.map +1 -0
- package/dist/annotate/index.js +13 -0
- package/dist/annotate/index.js.map +1 -0
- package/dist/annotate/marks.d.ts +103 -0
- package/dist/annotate/marks.d.ts.map +1 -0
- package/dist/annotate/marks.js +398 -0
- package/dist/annotate/marks.js.map +1 -0
- package/dist/annotate/paint.d.ts +58 -0
- package/dist/annotate/paint.d.ts.map +1 -0
- package/dist/annotate/paint.js +130 -0
- package/dist/annotate/paint.js.map +1 -0
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +3 -0
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/checks/configWarnings/unknownKeys.js +1 -1
- package/dist/checks/configWarnings/unknownKeys.js.map +1 -1
- package/dist/defaults/structure/headings/defaults.d.ts +1 -0
- package/dist/defaults/structure/headings/defaults.d.ts.map +1 -1
- package/dist/defaults/structure/headings/defaults.js +1 -0
- package/dist/defaults/structure/headings/defaults.js.map +1 -1
- package/dist/defaults/structure/headings/resolve.d.ts.map +1 -1
- package/dist/defaults/structure/headings/resolve.js +1 -0
- package/dist/defaults/structure/headings/resolve.js.map +1 -1
- package/dist/defaults/structure/headings/strip.d.ts.map +1 -1
- package/dist/defaults/structure/headings/strip.js +5 -0
- package/dist/defaults/structure/headings/strip.js.map +1 -1
- package/dist/geometry/balloonText.d.ts +75 -0
- package/dist/geometry/balloonText.d.ts.map +1 -0
- package/dist/geometry/balloonText.js +266 -0
- package/dist/geometry/balloonText.js.map +1 -0
- package/dist/geometry/bandTitle.d.ts +53 -0
- package/dist/geometry/bandTitle.d.ts.map +1 -0
- package/dist/geometry/bandTitle.js +171 -0
- package/dist/geometry/bandTitle.js.map +1 -0
- package/dist/geometry/caret.d.ts +23 -0
- package/dist/geometry/caret.d.ts.map +1 -0
- package/dist/geometry/caret.js +62 -0
- package/dist/geometry/caret.js.map +1 -0
- package/dist/geometry/fontPx.d.ts +15 -0
- package/dist/geometry/fontPx.d.ts.map +1 -0
- package/dist/geometry/fontPx.js +38 -0
- package/dist/geometry/fontPx.js.map +1 -0
- package/dist/geometry/frameSpace.d.ts +31 -0
- package/dist/geometry/frameSpace.d.ts.map +1 -0
- package/dist/geometry/frameSpace.js +68 -0
- package/dist/geometry/frameSpace.js.map +1 -0
- package/dist/geometry/hitTest.d.ts +46 -0
- package/dist/geometry/hitTest.d.ts.map +1 -0
- package/dist/geometry/hitTest.js +162 -0
- package/dist/geometry/hitTest.js.map +1 -0
- package/dist/geometry/index.d.ts +25 -0
- package/dist/geometry/index.d.ts.map +1 -0
- package/dist/geometry/index.js +18 -0
- package/dist/geometry/index.js.map +1 -0
- package/dist/geometry/measureLanguage.d.ts +17 -0
- package/dist/geometry/measureLanguage.d.ts.map +1 -0
- package/dist/geometry/measureLanguage.js +116 -0
- package/dist/geometry/measureLanguage.js.map +1 -0
- package/dist/geometry/placement.d.ts +64 -0
- package/dist/geometry/placement.d.ts.map +1 -0
- package/dist/geometry/placement.js +158 -0
- package/dist/geometry/placement.js.map +1 -0
- package/dist/geometry/rangeGeometry.d.ts +147 -0
- package/dist/geometry/rangeGeometry.d.ts.map +1 -0
- package/dist/geometry/rangeGeometry.js +352 -0
- package/dist/geometry/rangeGeometry.js.map +1 -0
- package/dist/geometry/segmentText.d.ts +57 -0
- package/dist/geometry/segmentText.d.ts.map +1 -0
- package/dist/geometry/segmentText.js +145 -0
- package/dist/geometry/segmentText.js.map +1 -0
- package/dist/geometry/textGeometry.d.ts +59 -0
- package/dist/geometry/textGeometry.d.ts.map +1 -0
- package/dist/geometry/textGeometry.js +336 -0
- package/dist/geometry/textGeometry.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/build/pass/lines/lineRoom.d.ts.map +1 -1
- package/dist/pipeline/build/pass/lines/lineRoom.js +45 -0
- package/dist/pipeline/build/pass/lines/lineRoom.js.map +1 -1
- package/dist/pipeline/build/pass/lines/listSpacing.d.ts +45 -0
- package/dist/pipeline/build/pass/lines/listSpacing.d.ts.map +1 -0
- package/dist/pipeline/build/pass/lines/listSpacing.js +115 -0
- package/dist/pipeline/build/pass/lines/listSpacing.js.map +1 -0
- package/dist/types/columnBalancing.d.ts +14 -0
- package/dist/types/columnBalancing.d.ts.map +1 -1
- package/dist/types/structure/headings.d.ts +1 -0
- package/dist/types/structure/headings.d.ts.map +1 -1
- package/dist/vdt/blocks.d.ts +7 -2
- package/dist/vdt/blocks.d.ts.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words of a comic balloon under the pointer (#595): a press on the
|
|
3
|
+
* glyphs of a balloon selects its text in the Markdown editor, as a press
|
|
4
|
+
* on the body text does, while a press on the rest of the balloon (its
|
|
5
|
+
* body round the words, its tail) still drags it.
|
|
6
|
+
*
|
|
7
|
+
* The lettering lays each balloon's words out as a design text block that
|
|
8
|
+
* carries the script line's source map (`sourceText` / `sourceMap`: one
|
|
9
|
+
* source offset per printed character, the line breaks mapping to the next
|
|
10
|
+
* line's start). This module finds the line and the character under a
|
|
11
|
+
* sheet point the way the renderers paint them (`renderTextBlock`): a
|
|
12
|
+
* horizontal line from `bbox.x + xOffset`, its runs in paint order (a
|
|
13
|
+
* right-to-left run painted from its right end); a vertical block in its
|
|
14
|
+
* own frame, turned a quarter turn clockwise about the box's top right
|
|
15
|
+
* corner (columns right to left, each running down); a sound effect turned
|
|
16
|
+
* about its box's centre.
|
|
17
|
+
*
|
|
18
|
+
* The block keeps a line's advance, not each glyph's: within a run the
|
|
19
|
+
* characters share its advance as the font measures them in the language
|
|
20
|
+
* the lettering was measured in and is painted in (a canvas 2D context of
|
|
21
|
+
* that language in the browser, #770), or evenly where nothing can measure
|
|
22
|
+
* (tests).
|
|
23
|
+
*
|
|
24
|
+
* Pure apart from the default measurer: sheet px, no DOM.
|
|
25
|
+
*/
|
|
26
|
+
import { measureInLanguage } from './measureLanguage.js';
|
|
27
|
+
import { toBalloonFrame } from './frameSpace.js';
|
|
28
|
+
/** The browser's measure in `lang`, the language the document's text was
|
|
29
|
+
* measured in (`documentShapingLanguage`; undefined: the host's): a word
|
|
30
|
+
* of the lettering has the widths the layout gave it, so a character's
|
|
31
|
+
* share of its run is where the page paints it. Null outside a browser
|
|
32
|
+
* (node has no canvas). */
|
|
33
|
+
export const measureIn = (lang) => (text, font) => measureInLanguage(lang, text, font);
|
|
34
|
+
/** The font size of a CSS font string (px). */
|
|
35
|
+
function fontSizeOf(font, fallback) {
|
|
36
|
+
const m = /(?:^|\D)(\d+(?:\.\d+)?)px/.exec(font);
|
|
37
|
+
return m ? Number(m[1]) : fallback;
|
|
38
|
+
}
|
|
39
|
+
/** Spread a run's advance over its characters, measured with its font. */
|
|
40
|
+
function spread(text, font, width, measure) {
|
|
41
|
+
const n = text.length;
|
|
42
|
+
if (n === 0)
|
|
43
|
+
return [0];
|
|
44
|
+
const edges = [0];
|
|
45
|
+
const full = measure(text, font);
|
|
46
|
+
if (full === null || !(full > 0)) {
|
|
47
|
+
for (let k = 1; k <= n; k++)
|
|
48
|
+
edges.push((k / n) * width);
|
|
49
|
+
return edges;
|
|
50
|
+
}
|
|
51
|
+
for (let k = 1; k < n; k++) {
|
|
52
|
+
const w = measure(text.slice(0, k), font);
|
|
53
|
+
edges.push(w === null ? (k / n) * width : (w / full) * width);
|
|
54
|
+
}
|
|
55
|
+
edges.push(width);
|
|
56
|
+
return edges;
|
|
57
|
+
}
|
|
58
|
+
/** Whether a block's words map back to the script. */
|
|
59
|
+
function mapped(block) {
|
|
60
|
+
return !block.artifact && !!block.sourceMap && block.sourceMap.length > 0 && block.sourceText !== undefined;
|
|
61
|
+
}
|
|
62
|
+
/** The lines of a balloon's mapped text blocks in their own frames. */
|
|
63
|
+
function lineFrames(balloon, measure) {
|
|
64
|
+
const out = [];
|
|
65
|
+
balloon.text.forEach((block, bi) => {
|
|
66
|
+
if (!mapped(block))
|
|
67
|
+
return;
|
|
68
|
+
const em = fontSizeOf(block.fontString, block.bbox.height || 12);
|
|
69
|
+
const lines = block.lines;
|
|
70
|
+
const pitch = lines.length > 1 ? Math.abs(lines[1].baselineY - lines[0].baselineY) || em * 1.2 : em * 1.2;
|
|
71
|
+
const vertical = !!block.vertical;
|
|
72
|
+
const family = Object.keys(block.vertical?.centralBaselines ?? {})[0];
|
|
73
|
+
const central = (family !== undefined ? block.vertical?.centralBaselines[family] : undefined) ?? 0.38;
|
|
74
|
+
let plain = 0;
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
const length = line.text.length;
|
|
77
|
+
const chars = [];
|
|
78
|
+
if (!line.runs || line.runs.length === 0) {
|
|
79
|
+
const edges = spread(line.text, block.fontString, line.width, measure);
|
|
80
|
+
for (let k = 0; k < length; k++)
|
|
81
|
+
chars.push({ plain: plain + k, a: edges[k], b: edges[k + 1], rtl: false });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Logical starts of the runs (the line's text is their
|
|
85
|
+
// concatenation), then their places in paint order.
|
|
86
|
+
const starts = [];
|
|
87
|
+
let at = 0;
|
|
88
|
+
for (const r of line.runs) {
|
|
89
|
+
starts.push(at);
|
|
90
|
+
at += r.text.length;
|
|
91
|
+
}
|
|
92
|
+
const order = line.order && line.order.length === line.runs.length ? line.order : line.runs.map((_, i) => i);
|
|
93
|
+
let x = 0;
|
|
94
|
+
for (const i of order) {
|
|
95
|
+
const run = line.runs[i];
|
|
96
|
+
const edges = spread(run.text, run.fontString, run.width, measure);
|
|
97
|
+
const rtl = run.rtl === true && !vertical;
|
|
98
|
+
for (let k = 0; k < run.text.length; k++) {
|
|
99
|
+
const a = rtl ? x + run.width - edges[k + 1] : x + edges[k];
|
|
100
|
+
const b = rtl ? x + run.width - edges[k] : x + edges[k + 1];
|
|
101
|
+
chars.push({ plain: plain + starts[i] + k, a, b, rtl });
|
|
102
|
+
}
|
|
103
|
+
x += run.width;
|
|
104
|
+
}
|
|
105
|
+
chars.sort((p, q) => p.a - q.a);
|
|
106
|
+
}
|
|
107
|
+
// Across: a horizontal line owns the leading above its baseline (most
|
|
108
|
+
// of it) and a little below; a column is centred on its axis.
|
|
109
|
+
let t0;
|
|
110
|
+
let t1;
|
|
111
|
+
if (vertical) {
|
|
112
|
+
const axis = line.baselineY - central * em;
|
|
113
|
+
t0 = axis - pitch / 2;
|
|
114
|
+
t1 = axis + pitch / 2;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
t0 = line.baselineY - 0.8 * pitch;
|
|
118
|
+
t1 = line.baselineY + 0.2 * pitch;
|
|
119
|
+
}
|
|
120
|
+
out.push({ block: bi, plainStart: plain, length, s0: line.xOffset, s1: line.xOffset + line.width, t0, t1, chars });
|
|
121
|
+
// The next line starts after this one's `\n` in `sourceText`.
|
|
122
|
+
plain += length + 1;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
/** A sheet point in a block's line frame: `s` along its lines (from the
|
|
128
|
+
* box's left edge, or its top in a vertical block), `t` across them (the
|
|
129
|
+
* sheet's y, or the distance from the box's right edge). */
|
|
130
|
+
function toFrame(block, p) {
|
|
131
|
+
if (block.vertical)
|
|
132
|
+
return { s: p.y - block.bbox.y, t: block.bbox.x + block.bbox.width - p.x };
|
|
133
|
+
return { s: p.x - block.bbox.x, t: p.y };
|
|
134
|
+
}
|
|
135
|
+
/** The caret boundary nearest `s` on a line (an index into the block's
|
|
136
|
+
* `sourceText`). */
|
|
137
|
+
function boundaryAt(line, s) {
|
|
138
|
+
if (line.chars.length === 0)
|
|
139
|
+
return line.plainStart;
|
|
140
|
+
let hit = line.chars[0];
|
|
141
|
+
let best = Infinity;
|
|
142
|
+
for (const c of line.chars) {
|
|
143
|
+
const d = s < c.a ? c.a - s : s > c.b ? s - c.b : 0;
|
|
144
|
+
if (d < best) {
|
|
145
|
+
best = d;
|
|
146
|
+
hit = c;
|
|
147
|
+
}
|
|
148
|
+
if (d === 0)
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const before = s < (hit.a + hit.b) / 2;
|
|
152
|
+
// A character painted right to left starts on its right.
|
|
153
|
+
return before !== hit.rtl ? hit.plain : hit.plain + 1;
|
|
154
|
+
}
|
|
155
|
+
/** The source offset of a caret boundary of a block's text: before the
|
|
156
|
+
* character there, or after the last one of its line. */
|
|
157
|
+
function boundaryToSource(block, line, plain) {
|
|
158
|
+
const map = block.sourceMap;
|
|
159
|
+
const end = line.plainStart + line.length;
|
|
160
|
+
if (plain < end && plain < map.length)
|
|
161
|
+
return map[Math.max(0, plain)];
|
|
162
|
+
if (line.length === 0)
|
|
163
|
+
return map[Math.min(plain, map.length - 1)];
|
|
164
|
+
return map[Math.min(end - 1, map.length - 1)] + 1;
|
|
165
|
+
}
|
|
166
|
+
/** The point in the balloon's own frame (a sound effect turned and
|
|
167
|
+
* leaned back). */
|
|
168
|
+
function unturned(balloon, x, y) {
|
|
169
|
+
return toBalloonFrame(balloon, { x, y });
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The source offset of the caret a press at `(x, y)` puts in a balloon's
|
|
173
|
+
* words: the boundary nearest the point on the line under it. Null when
|
|
174
|
+
* the point is off its glyphs (the balloon's body round the words, its
|
|
175
|
+
* tail) or its words do not map back to the script.
|
|
176
|
+
*/
|
|
177
|
+
export function balloonTextAt(balloon, x, y, opts = {}) {
|
|
178
|
+
const measure = opts.measure ?? measureIn(opts.lang);
|
|
179
|
+
const slop = opts.slop ?? 0;
|
|
180
|
+
const p = unturned(balloon, x, y);
|
|
181
|
+
for (const line of lineFrames(balloon, measure)) {
|
|
182
|
+
const block = balloon.text[line.block];
|
|
183
|
+
const { s, t } = toFrame(block, p);
|
|
184
|
+
if (t < line.t0 || t > line.t1)
|
|
185
|
+
continue;
|
|
186
|
+
if (line.length === 0 || s < line.s0 - slop || s > line.s1 + slop)
|
|
187
|
+
continue;
|
|
188
|
+
return boundaryToSource(block, line, boundaryAt(line, s - line.s0));
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* The source offset nearest `(x, y)` in a balloon's words, wherever the
|
|
194
|
+
* point is (the head of a selection dragged from them: past the words it
|
|
195
|
+
* holds to their nearest line and end). Null when its words do not map
|
|
196
|
+
* back to the script.
|
|
197
|
+
*/
|
|
198
|
+
export function balloonTextNearest(balloon, x, y, opts = {}) {
|
|
199
|
+
const measure = opts.measure ?? measureIn(opts.lang);
|
|
200
|
+
const p = unturned(balloon, x, y);
|
|
201
|
+
let best = null;
|
|
202
|
+
for (const line of lineFrames(balloon, measure)) {
|
|
203
|
+
const { s, t } = toFrame(balloon.text[line.block], p);
|
|
204
|
+
const d = t < line.t0 ? line.t0 - t : t > line.t1 ? t - line.t1 : 0;
|
|
205
|
+
if (!best || d < best.d)
|
|
206
|
+
best = { line, s, d };
|
|
207
|
+
}
|
|
208
|
+
if (!best)
|
|
209
|
+
return null;
|
|
210
|
+
const block = balloon.text[best.line.block];
|
|
211
|
+
return boundaryToSource(block, best.line, boundaryAt(best.line, best.s - best.line.s0));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* The rectangles a source range `[from, to)` covers in a balloon's words
|
|
215
|
+
* (#796): on each line, the runs of its printed characters whose source
|
|
216
|
+
* offsets fall in the range, as wide as the line's band across. In the
|
|
217
|
+
* balloon's own frame; empty when the range misses its words or they do
|
|
218
|
+
* not map back to the script.
|
|
219
|
+
*/
|
|
220
|
+
export function balloonTextRangeRects(balloon, from, to, opts = {}) {
|
|
221
|
+
if (!(to > from) || balloon.sourceEnd <= from || balloon.sourceStart >= to)
|
|
222
|
+
return [];
|
|
223
|
+
const measure = opts.measure ?? measureIn(opts.lang);
|
|
224
|
+
const out = [];
|
|
225
|
+
for (const line of lineFrames(balloon, measure)) {
|
|
226
|
+
const block = balloon.text[line.block];
|
|
227
|
+
const map = block.sourceMap;
|
|
228
|
+
const inRange = (c) => {
|
|
229
|
+
const src = map[c.plain];
|
|
230
|
+
return src !== undefined && src >= from && src < to;
|
|
231
|
+
};
|
|
232
|
+
// The selected characters in order along the line, merged where they
|
|
233
|
+
// touch (a bidi line may break the range into several pieces).
|
|
234
|
+
let open = null;
|
|
235
|
+
const pieces = [];
|
|
236
|
+
for (const c of line.chars) {
|
|
237
|
+
if (!inRange(c)) {
|
|
238
|
+
if (open)
|
|
239
|
+
pieces.push(open);
|
|
240
|
+
open = null;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (open)
|
|
244
|
+
open.b = Math.max(open.b, c.b);
|
|
245
|
+
else
|
|
246
|
+
open = { a: c.a, b: c.b };
|
|
247
|
+
}
|
|
248
|
+
if (open)
|
|
249
|
+
pieces.push(open);
|
|
250
|
+
for (const { a, b } of pieces) {
|
|
251
|
+
const s0 = line.s0 + a;
|
|
252
|
+
const s1 = line.s0 + b;
|
|
253
|
+
if (block.vertical) {
|
|
254
|
+
// A column: `s` runs down from the box's top, `t` leftwards from
|
|
255
|
+
// its right edge.
|
|
256
|
+
const right = block.bbox.x + block.bbox.width;
|
|
257
|
+
out.push({ x: right - line.t1, y: block.bbox.y + s0, width: line.t1 - line.t0, height: s1 - s0 });
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
out.push({ x: block.bbox.x + s0, y: line.t0, width: s1 - s0, height: line.t1 - line.t0 });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return out;
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=balloonText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balloonText.js","sourceRoot":"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;gBAClB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC9C,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YACpG,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5F,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { VDTBlock, VDTDesignTextBlock, VDTDocument } from '../vdt.js';
|
|
2
|
+
/**
|
|
3
|
+
* Geometry and source mapping for design-band text that mirrors document
|
|
4
|
+
* text — the `{titleText}` of a chapter opener or a `:::part` page. Shared
|
|
5
|
+
* by the caret/selection overlay and the click-to-source hit test.
|
|
6
|
+
*/
|
|
7
|
+
export interface BandLineBox {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
text: string;
|
|
13
|
+
font: string;
|
|
14
|
+
/** Index of the line's first character in the block's title text. */
|
|
15
|
+
plainStart: number;
|
|
16
|
+
/** The language the layout measured the line in and the page paints it
|
|
17
|
+
* in (`documentShapingLanguage`), which its characters are measured in
|
|
18
|
+
* here (#770). Absent: the host's. */
|
|
19
|
+
lang?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Design text blocks of a page that carry a source range: the opener
|
|
22
|
+
* band, the running heads, and the advanced-design overlays of the page's
|
|
23
|
+
* headings (cover pages, in-column openers, `:::toc` part rows). */
|
|
24
|
+
export declare function bandTitleBlocks(doc: VDTDocument, pageIndex: number): VDTDesignTextBlock[];
|
|
25
|
+
/** The id of the block whose design overlay draws `title` (one
|
|
26
|
+
* {@link bandTitleBlocks} returned): the overlay is painted in that
|
|
27
|
+
* block's composed frame, if any (#910). Undefined for the opener band
|
|
28
|
+
* and the running heads. */
|
|
29
|
+
export declare function bandTitleOwner(title: VDTDesignTextBlock): string | undefined;
|
|
30
|
+
/** A flow heading rendered through an opener band keeps invisible lines
|
|
31
|
+
* under the band; its text is drawn by the band, so caret, selection and
|
|
32
|
+
* clicks should be routed through the band block instead. */
|
|
33
|
+
export declare function isHiddenUnderBand(block: VDTBlock, titles: readonly VDTDesignTextBlock[]): boolean;
|
|
34
|
+
/** Approximate line boxes for a design text block. The band layout keeps
|
|
35
|
+
* absolute baselines only, so the line pitch comes from consecutive
|
|
36
|
+
* baselines (or lineHeight × fontSize for a single line). Each box also
|
|
37
|
+
* records where its text starts in the title text, so characters can be
|
|
38
|
+
* mapped to source offsets, and `lang`, the language the document's text
|
|
39
|
+
* was measured in (`documentShapingLanguage(doc)`; undefined: the
|
|
40
|
+
* host's), which the caret and the hit test measure its characters in. */
|
|
41
|
+
export declare function bandLineBoxes(block: VDTDesignTextBlock, lang?: string): BandLineBox[];
|
|
42
|
+
/** X coordinate of the caret placed before character `chars` of the line. */
|
|
43
|
+
export declare function bandPrefixX(box: BandLineBox, chars: number): number;
|
|
44
|
+
/** Character index (0..text.length) closest to an x coordinate on the line. */
|
|
45
|
+
export declare function bandCharAtX(box: BandLineBox, x: number): number;
|
|
46
|
+
/** Source offset of character `plainIdx` of the title text (clamped). */
|
|
47
|
+
export declare function bandPlainToSource(block: VDTDesignTextBlock, plainIdx: number): number;
|
|
48
|
+
/** Index of the first title character whose source offset is ≥ `offset`
|
|
49
|
+
* (the title's end when the offset lies past the title). What the design
|
|
50
|
+
* prints before the title (a heading number, #546) is never reached: the
|
|
51
|
+
* title starts after it. */
|
|
52
|
+
export declare function bandSourceToPlain(block: VDTDesignTextBlock, offset: number): number;
|
|
53
|
+
//# sourceMappingURL=bandTitle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bandTitle.d.ts","sourceRoot":"","sources":["../../src/geometry/bandTitle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI3E;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB;;2CAEuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;qEAEqE;AACrE,wBAAgB,eAAe,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAoBzF;AAMD;;;6BAG6B;AAC7B,wBAAgB,cAAc,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,GAAG,SAAS,CAE5E;AAED;;8DAE8D;AAC9D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,kBAAkB,EAAE,GAAG,OAAO,CAKjG;AAQD;;;;;;2EAM2E;AAC3E,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE,CAyBrF;AAgBD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAc/D;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CASrF;AAED;;;6BAG6B;AAC7B,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAoBnF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { measureInLanguage } from './measureLanguage.js';
|
|
2
|
+
import { fontPx } from './fontPx.js';
|
|
3
|
+
/** Design text blocks of a page that carry a source range: the opener
|
|
4
|
+
* band, the running heads, and the advanced-design overlays of the page's
|
|
5
|
+
* headings (cover pages, in-column openers, `:::toc` part rows). */
|
|
6
|
+
export function bandTitleBlocks(doc, pageIndex) {
|
|
7
|
+
const page = doc.pages[pageIndex];
|
|
8
|
+
if (!page)
|
|
9
|
+
return [];
|
|
10
|
+
const slots = [page.openerBand, page.header, page.footer].map((slot) => ({ slot }));
|
|
11
|
+
for (const b of doc.blocks) {
|
|
12
|
+
if (b.pageIndex === pageIndex && b.designOverlay)
|
|
13
|
+
slots.push({ slot: b.designOverlay, owner: b.id });
|
|
14
|
+
}
|
|
15
|
+
for (const b of page.floats ?? []) {
|
|
16
|
+
if (b.designOverlay)
|
|
17
|
+
slots.push({ slot: b.designOverlay, owner: b.id });
|
|
18
|
+
}
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const { slot, owner } of slots) {
|
|
21
|
+
if (!slot)
|
|
22
|
+
continue;
|
|
23
|
+
for (const b of slot.blocks) {
|
|
24
|
+
if (b.kind !== 'text' || b.sourceStart === undefined || b.sourceEnd === undefined)
|
|
25
|
+
continue;
|
|
26
|
+
out.push(b);
|
|
27
|
+
if (owner !== undefined)
|
|
28
|
+
owners.set(b, owner);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
/** The block whose design overlay draws each title {@link bandTitleBlocks}
|
|
34
|
+
* returned (a heading, a box), by title. */
|
|
35
|
+
const owners = new WeakMap();
|
|
36
|
+
/** The id of the block whose design overlay draws `title` (one
|
|
37
|
+
* {@link bandTitleBlocks} returned): the overlay is painted in that
|
|
38
|
+
* block's composed frame, if any (#910). Undefined for the opener band
|
|
39
|
+
* and the running heads. */
|
|
40
|
+
export function bandTitleOwner(title) {
|
|
41
|
+
return owners.get(title);
|
|
42
|
+
}
|
|
43
|
+
/** A flow heading rendered through an opener band keeps invisible lines
|
|
44
|
+
* under the band; its text is drawn by the band, so caret, selection and
|
|
45
|
+
* clicks should be routed through the band block instead. */
|
|
46
|
+
export function isHiddenUnderBand(block, titles) {
|
|
47
|
+
return block.type === 'heading'
|
|
48
|
+
&& block.sourceStart !== undefined
|
|
49
|
+
&& block.sourceEnd !== undefined
|
|
50
|
+
&& titles.some((t) => block.sourceStart <= t.sourceStart && block.sourceEnd >= t.sourceEnd);
|
|
51
|
+
}
|
|
52
|
+
/** The title text the block renders: `sourceText` when known, else the
|
|
53
|
+
* laid-out lines joined by newlines. */
|
|
54
|
+
function titleTextOf(block) {
|
|
55
|
+
return block.sourceText ?? block.lines.map((l) => l.text).join('\n');
|
|
56
|
+
}
|
|
57
|
+
/** Approximate line boxes for a design text block. The band layout keeps
|
|
58
|
+
* absolute baselines only, so the line pitch comes from consecutive
|
|
59
|
+
* baselines (or lineHeight × fontSize for a single line). Each box also
|
|
60
|
+
* records where its text starts in the title text, so characters can be
|
|
61
|
+
* mapped to source offsets, and `lang`, the language the document's text
|
|
62
|
+
* was measured in (`documentShapingLanguage(doc)`; undefined: the
|
|
63
|
+
* host's), which the caret and the hit test measure its characters in. */
|
|
64
|
+
export function bandLineBoxes(block, lang) {
|
|
65
|
+
const lines = block.lines;
|
|
66
|
+
const fontSizePx = fontPx(block.fontString) ?? block.bbox.height;
|
|
67
|
+
const pitch = lines.length > 1 ? lines[1].baselineY - lines[0].baselineY : fontSizePx * 1.2;
|
|
68
|
+
const ascent = pitch * 0.8;
|
|
69
|
+
const title = titleTextOf(block);
|
|
70
|
+
let pos = 0;
|
|
71
|
+
return lines.map((l) => {
|
|
72
|
+
// Wrapping trims spaces and breaks at newlines: skip them, then find the
|
|
73
|
+
// line's text at (or after) the cursor.
|
|
74
|
+
while (pos < title.length && /\s/.test(title[pos]))
|
|
75
|
+
pos++;
|
|
76
|
+
const at = l.text.length > 0 ? title.indexOf(l.text, pos) : pos;
|
|
77
|
+
const plainStart = at >= 0 ? at : pos;
|
|
78
|
+
pos = plainStart + l.text.length;
|
|
79
|
+
return {
|
|
80
|
+
x: block.bbox.x + l.xOffset,
|
|
81
|
+
y: l.baselineY - ascent,
|
|
82
|
+
width: l.width,
|
|
83
|
+
height: pitch,
|
|
84
|
+
text: l.text,
|
|
85
|
+
font: block.fontString,
|
|
86
|
+
plainStart,
|
|
87
|
+
...(lang !== undefined ? { lang } : {}),
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Width of the first `chars` characters of a line, measured with its font
|
|
92
|
+
* in the language the layout measured the line in ({@link BandLineBox.lang})
|
|
93
|
+
* and scaled so the whole text spans the laid-out line width (absorbing
|
|
94
|
+
* letter-spacing or kerning applied by the layout). */
|
|
95
|
+
function prefixWidth(box, chars) {
|
|
96
|
+
const n = Math.max(0, Math.min(box.text.length, chars));
|
|
97
|
+
if (box.text.length === 0)
|
|
98
|
+
return 0;
|
|
99
|
+
const full = measureInLanguage(box.lang, box.text, box.font);
|
|
100
|
+
if (full === null || !(full > 0))
|
|
101
|
+
return (n / box.text.length) * box.width;
|
|
102
|
+
const prefix = measureInLanguage(box.lang, box.text.slice(0, n), box.font);
|
|
103
|
+
if (prefix === null)
|
|
104
|
+
return (n / box.text.length) * box.width;
|
|
105
|
+
return (prefix / full) * box.width;
|
|
106
|
+
}
|
|
107
|
+
/** X coordinate of the caret placed before character `chars` of the line. */
|
|
108
|
+
export function bandPrefixX(box, chars) {
|
|
109
|
+
return box.x + prefixWidth(box, chars);
|
|
110
|
+
}
|
|
111
|
+
/** Character index (0..text.length) closest to an x coordinate on the line. */
|
|
112
|
+
export function bandCharAtX(box, x) {
|
|
113
|
+
const rel = x - box.x;
|
|
114
|
+
if (rel <= 0)
|
|
115
|
+
return 0;
|
|
116
|
+
if (rel >= box.width)
|
|
117
|
+
return box.text.length;
|
|
118
|
+
// Smallest caret position whose following glyph's midpoint lies past x.
|
|
119
|
+
let lo = 0;
|
|
120
|
+
let hi = box.text.length;
|
|
121
|
+
while (lo < hi) {
|
|
122
|
+
const mid = (lo + hi) >> 1;
|
|
123
|
+
const midpoint = (prefixWidth(box, mid) + prefixWidth(box, mid + 1)) / 2;
|
|
124
|
+
if (midpoint < rel)
|
|
125
|
+
lo = mid + 1;
|
|
126
|
+
else
|
|
127
|
+
hi = mid;
|
|
128
|
+
}
|
|
129
|
+
return lo;
|
|
130
|
+
}
|
|
131
|
+
/** Source offset of character `plainIdx` of the title text (clamped). */
|
|
132
|
+
export function bandPlainToSource(block, plainIdx) {
|
|
133
|
+
const map = block.sourceMap;
|
|
134
|
+
if (map && map.length > 0) {
|
|
135
|
+
if (plainIdx >= map.length)
|
|
136
|
+
return (block.sourceEnd ?? map[map.length - 1] + 1);
|
|
137
|
+
return map[Math.max(0, plainIdx)];
|
|
138
|
+
}
|
|
139
|
+
const len = titleTextOf(block).length || 1;
|
|
140
|
+
const ratio = Math.max(0, Math.min(1, plainIdx / len));
|
|
141
|
+
return (block.sourceStart ?? 0) + Math.round(ratio * ((block.sourceEnd ?? 0) - (block.sourceStart ?? 0)));
|
|
142
|
+
}
|
|
143
|
+
/** Index of the first title character whose source offset is ≥ `offset`
|
|
144
|
+
* (the title's end when the offset lies past the title). What the design
|
|
145
|
+
* prints before the title (a heading number, #546) is never reached: the
|
|
146
|
+
* title starts after it. */
|
|
147
|
+
export function bandSourceToPlain(block, offset) {
|
|
148
|
+
const map = block.sourceMap;
|
|
149
|
+
const len = titleTextOf(block).length;
|
|
150
|
+
if (map && map.length > 0) {
|
|
151
|
+
const end = block.sourceEnd ?? Infinity;
|
|
152
|
+
// Past the title: where it ends, before what the design prints after it.
|
|
153
|
+
if (offset >= end)
|
|
154
|
+
offset = end;
|
|
155
|
+
let lo = Math.min(map.length, Math.max(0, block.sourcePrefixLen ?? 0));
|
|
156
|
+
let hi = map.length;
|
|
157
|
+
while (lo < hi) {
|
|
158
|
+
const mid = (lo + hi) >> 1;
|
|
159
|
+
if (map[mid] < offset)
|
|
160
|
+
lo = mid + 1;
|
|
161
|
+
else
|
|
162
|
+
hi = mid;
|
|
163
|
+
}
|
|
164
|
+
return lo;
|
|
165
|
+
}
|
|
166
|
+
const start = block.sourceStart ?? 0;
|
|
167
|
+
const end = block.sourceEnd ?? start + len;
|
|
168
|
+
const ratio = end > start ? (offset - start) / (end - start) : 0;
|
|
169
|
+
return Math.max(0, Math.min(len, Math.round(ratio * len)));
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=bandTitle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bandTitle.js","sourceRoot":"","sources":["../../src/geometry/bandTitle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuBrC;;qEAEqE;AACrE,MAAM,UAAU,eAAe,CAAC,GAAgB,EAAE,SAAiB;IACjE,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,KAAK,GAA+D,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MA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EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { VDTDocument } from '../vdt.js';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve which block should host the caret given a source offset.
|
|
4
|
+
* Prefers the block that actually contains the offset; a caret between two
|
|
5
|
+
* blocks (a blank line, text the page has not laid out yet) goes to the
|
|
6
|
+
* nearer one, and on a tie to the block before it: what is typed after a
|
|
7
|
+
* paragraph shows at its end, never at the head of the next one.
|
|
8
|
+
*
|
|
9
|
+
* `pages` narrows the search to the blocks of a page range (`[from, to)`):
|
|
10
|
+
* a whole-book canvas holds every chapter's blocks with chapter offsets, so
|
|
11
|
+
* the caret of the active chapter is looked up among its own pages only.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findCaretBlockIdx(doc: VDTDocument, head: number, pages?: {
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
}): number;
|
|
17
|
+
/**
|
|
18
|
+
* The block of a story carried in from chapter `chapter` (#943, #988) that
|
|
19
|
+
* holds the caret `head`, an offset in that chapter's file, on page
|
|
20
|
+
* `pageIndex` (one with lines: not the box around them); -1 when none does.
|
|
21
|
+
*/
|
|
22
|
+
export declare function findCarriedCaretBlockIdx(doc: VDTDocument, head: number, chapter: number, pageIndex: number): number;
|
|
23
|
+
//# sourceMappingURL=caret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caret.d.ts","sourceRoot":"","sources":["../../src/geometry/caret.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CA0B9G;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAOnH"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve which block should host the caret given a source offset.
|
|
3
|
+
* Prefers the block that actually contains the offset; a caret between two
|
|
4
|
+
* blocks (a blank line, text the page has not laid out yet) goes to the
|
|
5
|
+
* nearer one, and on a tie to the block before it: what is typed after a
|
|
6
|
+
* paragraph shows at its end, never at the head of the next one.
|
|
7
|
+
*
|
|
8
|
+
* `pages` narrows the search to the blocks of a page range (`[from, to)`):
|
|
9
|
+
* a whole-book canvas holds every chapter's blocks with chapter offsets, so
|
|
10
|
+
* the caret of the active chapter is looked up among its own pages only.
|
|
11
|
+
*/
|
|
12
|
+
export function findCaretBlockIdx(doc, head, pages) {
|
|
13
|
+
const inRange = (b) => !pages || (b.pageIndex >= pages.from && b.pageIndex < pages.to);
|
|
14
|
+
let last = -1;
|
|
15
|
+
let before = -1;
|
|
16
|
+
let after = -1;
|
|
17
|
+
for (let i = 0; i < doc.blocks.length; i++) {
|
|
18
|
+
const b = doc.blocks[i];
|
|
19
|
+
if (!inRange(b))
|
|
20
|
+
continue;
|
|
21
|
+
// Text carried in from another chapter (#943) has that file's offsets.
|
|
22
|
+
if (b.sourceChapter !== undefined)
|
|
23
|
+
continue;
|
|
24
|
+
last = i;
|
|
25
|
+
if (b.sourceStart === undefined || b.sourceEnd === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
if (head >= b.sourceStart && head <= b.sourceEnd)
|
|
28
|
+
return i;
|
|
29
|
+
// The block with lines wins over the box round it (same end or start).
|
|
30
|
+
if (b.sourceEnd < head) {
|
|
31
|
+
const held = doc.blocks[before];
|
|
32
|
+
if (!held || b.sourceEnd > held.sourceEnd || (b.sourceEnd === held.sourceEnd && b.lines.length > 0))
|
|
33
|
+
before = i;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const held = doc.blocks[after];
|
|
37
|
+
if (!held || b.sourceStart < held.sourceStart || (b.sourceStart === held.sourceStart && held.lines.length === 0 && b.lines.length > 0))
|
|
38
|
+
after = i;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (before === -1)
|
|
42
|
+
return after === -1 ? last : after;
|
|
43
|
+
if (after === -1)
|
|
44
|
+
return before;
|
|
45
|
+
return head - doc.blocks[before].sourceEnd <= doc.blocks[after].sourceStart - head ? before : after;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The block of a story carried in from chapter `chapter` (#943, #988) that
|
|
49
|
+
* holds the caret `head`, an offset in that chapter's file, on page
|
|
50
|
+
* `pageIndex` (one with lines: not the box around them); -1 when none does.
|
|
51
|
+
*/
|
|
52
|
+
export function findCarriedCaretBlockIdx(doc, head, chapter, pageIndex) {
|
|
53
|
+
for (let i = 0; i < doc.blocks.length; i++) {
|
|
54
|
+
const b = doc.blocks[i];
|
|
55
|
+
if (b.pageIndex !== pageIndex || b.sourceChapter !== chapter || b.lines.length === 0 || b.sourceStart === undefined || b.sourceEnd === undefined)
|
|
56
|
+
continue;
|
|
57
|
+
if (head >= b.sourceStart && head <= b.sourceEnd)
|
|
58
|
+
return i;
|
|
59
|
+
}
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=caret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caret.js","sourceRoot":"","sources":["../../src/geometry/caret.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAgB,EAAE,IAAY,EAAE,KAAoC;IACpG,MAAM,OAAO,GAAG,CAAC,CAAgC,EAAW,EAAE,CAC5D,CAAC,KAAK,I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IAC7D,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The px size a CSS font shorthand names (`"italic 600 11.5px Lora"` →
|
|
3
|
+
* 11.5), read in one pass without a regular expression: font strings
|
|
4
|
+
* reach these calls from documents and hosts.
|
|
5
|
+
*/
|
|
6
|
+
export declare function fontPx(font: string | undefined): number | undefined;
|
|
7
|
+
/** The family list after the size in a CSS font shorthand, and whether its
|
|
8
|
+
* style and weight words ask for italic or bold. */
|
|
9
|
+
export declare function fontParts(font: string): {
|
|
10
|
+
size?: number;
|
|
11
|
+
family?: string;
|
|
12
|
+
weight?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=fontPx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fontPx.d.ts","sourceRoot":"","sources":["../../src/geometry/fontPx.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAYnE;AAMD;qDACqD;AACrD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAS3G"}
|