@itwin/core-common 5.3.0-dev.2 → 5.3.0-dev.3
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/lib/cjs/annotation/TextBlock.d.ts +1 -26
- package/lib/cjs/annotation/TextBlock.d.ts.map +1 -1
- package/lib/cjs/annotation/TextBlock.js +8 -35
- package/lib/cjs/annotation/TextBlock.js.map +1 -1
- package/lib/cjs/annotation/TextStyle.d.ts +64 -36
- package/lib/cjs/annotation/TextStyle.d.ts.map +1 -1
- package/lib/cjs/annotation/TextStyle.js +63 -44
- package/lib/cjs/annotation/TextStyle.js.map +1 -1
- package/lib/esm/annotation/TextBlock.d.ts +1 -26
- package/lib/esm/annotation/TextBlock.d.ts.map +1 -1
- package/lib/esm/annotation/TextBlock.js +8 -35
- package/lib/esm/annotation/TextBlock.js.map +1 -1
- package/lib/esm/annotation/TextStyle.d.ts +64 -36
- package/lib/esm/annotation/TextStyle.d.ts.map +1 -1
- package/lib/esm/annotation/TextStyle.js +63 -44
- package/lib/esm/annotation/TextStyle.js.map +1 -1
- package/package.json +6 -6
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { DeepReadonlyObject, DeepRequiredObject } from "@itwin/core-bentley";
|
|
5
5
|
import { ColorDefProps } from "../ColorDef";
|
|
6
|
+
import { FontFamilySelector } from "../Fonts";
|
|
6
7
|
/** Predefined markers for list items in text annotations.
|
|
7
8
|
* These values control the appearance of list item markers (e.g., bullet, circle, square, dash, number) that denote the start of a list item in a list.
|
|
8
9
|
* @beta
|
|
@@ -44,6 +45,24 @@ export type TextAnnotationFrameShape = typeof textAnnotationFrameShapes[number];
|
|
|
44
45
|
* @beta
|
|
45
46
|
*/
|
|
46
47
|
export type TextAnnotationFillColor = TextStyleColor | "background" | "none";
|
|
48
|
+
/** Describes the margins around the content inside a [[TextBlock]], measured in meters.
|
|
49
|
+
* All margins default to zero if `undefined`.
|
|
50
|
+
* @beta
|
|
51
|
+
*/
|
|
52
|
+
export interface TextBlockMargins {
|
|
53
|
+
/** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */
|
|
54
|
+
left?: number;
|
|
55
|
+
/** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */
|
|
56
|
+
right?: number;
|
|
57
|
+
/** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */
|
|
58
|
+
top?: number;
|
|
59
|
+
/** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */
|
|
60
|
+
bottom?: number;
|
|
61
|
+
}
|
|
62
|
+
/** Describes the relative alignment of text.
|
|
63
|
+
* @beta
|
|
64
|
+
*/
|
|
65
|
+
export type TextJustification = "left" | "center" | "right";
|
|
47
66
|
/** Specifies how to separate the numerator and denominator of a [[FractionRun]], by either a horizontal or diagonal bar.
|
|
48
67
|
* @see [[TextStyleSettingsProps.stackedFractionType]] and [[TextStyleSettings.stackedFractionType]].
|
|
49
68
|
* @beta
|
|
@@ -65,9 +84,9 @@ export interface TextFrameStyleProps {
|
|
|
65
84
|
/** Shape of the frame. Default: "none" */
|
|
66
85
|
shape?: TextAnnotationFrameShape;
|
|
67
86
|
/** The color to fill the shape of the text frame. This fill is applied using [[FillDisplay.Blanking]]. Default: "none" */
|
|
68
|
-
|
|
87
|
+
fillColor?: TextAnnotationFillColor;
|
|
69
88
|
/** The color of the text frame's outline. Default: black */
|
|
70
|
-
|
|
89
|
+
borderColor?: TextStyleColor;
|
|
71
90
|
/** This will be used to set the [[GeometryParams.weight]] property of the frame (in pixels). Default: 1px */
|
|
72
91
|
borderWeight?: number;
|
|
73
92
|
}
|
|
@@ -86,17 +105,17 @@ export interface TextLeaderStyleProps {
|
|
|
86
105
|
*/
|
|
87
106
|
wantElbow?: boolean;
|
|
88
107
|
/** Multiplier used to compute length of the elbow in the leader.
|
|
89
|
-
* The elbowLength is computed in meters as elbowLength * [[
|
|
108
|
+
* The elbowLength is computed in meters as elbowLength * [[textHeight]].
|
|
90
109
|
* Default: 1.0
|
|
91
110
|
*/
|
|
92
111
|
elbowLength?: number;
|
|
93
112
|
/** Multiplier to compute height of the leader terminator.
|
|
94
|
-
* The terminator height is computed in meters as terminatorHeight * [[
|
|
113
|
+
* The terminator height is computed in meters as terminatorHeight * [[textHeight]].
|
|
95
114
|
* Default: 1.0
|
|
96
115
|
*/
|
|
97
116
|
terminatorHeightFactor?: number;
|
|
98
117
|
/** Multiplier to compute width of the leader terminator.
|
|
99
|
-
* The terminator width is computed in meters as terminatorWidth * [[
|
|
118
|
+
* The terminator width is computed in meters as terminatorWidth * [[textHeight]].
|
|
100
119
|
* Default: 1.0
|
|
101
120
|
*/
|
|
102
121
|
terminatorWidthFactor?: number;
|
|
@@ -109,22 +128,22 @@ export interface TextStyleSettingsProps {
|
|
|
109
128
|
* Default: "subcategory".
|
|
110
129
|
*/
|
|
111
130
|
color?: TextStyleColor;
|
|
112
|
-
/** The
|
|
113
|
-
* Default: "" (an invalid font name).
|
|
131
|
+
/** The font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
132
|
+
* Default: { name: "" } (an invalid font name).
|
|
114
133
|
*/
|
|
115
|
-
|
|
116
|
-
/** The height
|
|
117
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as
|
|
118
|
-
*
|
|
134
|
+
font?: FontFamilySelector;
|
|
135
|
+
/** The height of the text, in meters. Many other settings use the text height as the basis for computing their own values.
|
|
136
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as textHeight * [[subScriptScale]] and
|
|
137
|
+
* textHeight * [[subScriptOffsetFactor]], respectively.
|
|
119
138
|
* Default: 1.0. */
|
|
120
|
-
|
|
139
|
+
textHeight?: number;
|
|
121
140
|
/** Multiplier used to compute the vertical distance between two lines of text.
|
|
122
|
-
* The distance is computed in meters as lineSpacingFactor * [[
|
|
141
|
+
* The distance is computed in meters as lineSpacingFactor * [[textHeight]].
|
|
123
142
|
* Default: 0.5.
|
|
124
143
|
*/
|
|
125
144
|
lineSpacingFactor?: number;
|
|
126
145
|
/** Multiplier used to compute the vertical distance between two paragraphs of text.
|
|
127
|
-
* The distance is computed in meters as paragraphSpacingFactor * [[
|
|
146
|
+
* The distance is computed in meters as paragraphSpacingFactor * [[textHeight]].
|
|
128
147
|
* Default: 0.5.
|
|
129
148
|
*/
|
|
130
149
|
paragraphSpacingFactor?: number;
|
|
@@ -141,7 +160,7 @@ export interface TextStyleSettingsProps {
|
|
|
141
160
|
*/
|
|
142
161
|
isUnderlined?: boolean;
|
|
143
162
|
/** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].
|
|
144
|
-
* The height is computed in meters as stackedFractionScale * [[
|
|
163
|
+
* The height is computed in meters as stackedFractionScale * [[textHeight]].
|
|
145
164
|
* Default: 0.7.
|
|
146
165
|
*/
|
|
147
166
|
stackedFractionScale?: number;
|
|
@@ -150,22 +169,22 @@ export interface TextStyleSettingsProps {
|
|
|
150
169
|
*/
|
|
151
170
|
stackedFractionType?: StackedFractionType;
|
|
152
171
|
/** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].
|
|
153
|
-
* The offset is computed in meters as subScriptOffsetFactor * [[
|
|
172
|
+
* The offset is computed in meters as subScriptOffsetFactor * [[textHeight]].
|
|
154
173
|
* Default: -0.15.
|
|
155
174
|
*/
|
|
156
175
|
subScriptOffsetFactor?: number;
|
|
157
176
|
/** Multiplier used to compute the height of a subscript [[TextRun]].
|
|
158
|
-
* The height is computed as subScriptScale * [[
|
|
177
|
+
* The height is computed as subScriptScale * [[textHeight]].
|
|
159
178
|
* Default: 2/3
|
|
160
179
|
*/
|
|
161
180
|
subScriptScale?: number;
|
|
162
181
|
/** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].
|
|
163
|
-
* The offset is computed in meters as superScriptOffsetFactor * [[
|
|
182
|
+
* The offset is computed in meters as superScriptOffsetFactor * [[textHeight]].
|
|
164
183
|
* Default: -0.5.
|
|
165
184
|
*/
|
|
166
185
|
superScriptOffsetFactor?: number;
|
|
167
186
|
/** Multiplier used to compute the height of a superscript [[TextRun]].
|
|
168
|
-
* The height is computed as superScriptScale * [[
|
|
187
|
+
* The height is computed as superScriptScale * [[textHeight]].
|
|
169
188
|
* Default: 2/3
|
|
170
189
|
*/
|
|
171
190
|
superScriptScale?: number;
|
|
@@ -192,6 +211,9 @@ export interface TextStyleSettingsProps {
|
|
|
192
211
|
* Default: {shape: "none", fill: "none", border: black, borderWeight: 1} for no frame.
|
|
193
212
|
*/
|
|
194
213
|
frame?: TextFrameStyleProps;
|
|
214
|
+
/** The margins to surround the document content.
|
|
215
|
+
* Default: 0 margins on all sides */
|
|
216
|
+
margins?: TextBlockMargins;
|
|
195
217
|
/** The offset (in meters) from the left edge of the text block to the start of the line of text.
|
|
196
218
|
* In lists, the indentation is added to offset of list items.
|
|
197
219
|
* The [[listMarker]] is right justified on [[indentation]] + [[tabInterval]]*(depth - 1/2).
|
|
@@ -203,6 +225,9 @@ export interface TextStyleSettingsProps {
|
|
|
203
225
|
* Default: "1.".
|
|
204
226
|
*/
|
|
205
227
|
listMarker?: ListMarker;
|
|
228
|
+
/** The alignment of the text content.
|
|
229
|
+
* Default: "left". */
|
|
230
|
+
justification?: TextJustification;
|
|
206
231
|
}
|
|
207
232
|
/** A description of the formatting to be applied to a [[TextBlockComponent]].
|
|
208
233
|
* Named instances of these settings can be stored as [AnnotationTextStyle]($backend)s in an iModel.
|
|
@@ -213,20 +238,20 @@ export interface TextStyleSettingsProps {
|
|
|
213
238
|
export declare class TextStyleSettings {
|
|
214
239
|
/** The color of the text. */
|
|
215
240
|
readonly color: TextStyleColor;
|
|
216
|
-
/** The
|
|
241
|
+
/** The font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
217
242
|
*/
|
|
218
|
-
readonly
|
|
219
|
-
/** The height
|
|
220
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as
|
|
221
|
-
*
|
|
243
|
+
readonly font: Readonly<Required<FontFamilySelector>>;
|
|
244
|
+
/** The height of the text, in meters. Many other settings use the text height as the basis for computing their own values.
|
|
245
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as textHeight * [[subScriptScale]] and
|
|
246
|
+
* textHeight * [[subScriptOffsetFactor]], respectively.
|
|
222
247
|
*/
|
|
223
|
-
readonly
|
|
248
|
+
readonly textHeight: number;
|
|
224
249
|
/** Multiplier used to compute the vertical distance between two lines of text.
|
|
225
|
-
* The distance is computed in meters as lineSpacingFactor * [[
|
|
250
|
+
* The distance is computed in meters as lineSpacingFactor * [[textHeight]] of the [[TextBlock]].
|
|
226
251
|
*/
|
|
227
252
|
readonly lineSpacingFactor: number;
|
|
228
253
|
/** Multiplier used to compute the vertical distance between two paragraphs of text.
|
|
229
|
-
* The distance is computed in meters as paragraphSpacingFactor * [[
|
|
254
|
+
* The distance is computed in meters as paragraphSpacingFactor * the [[TextBlock]]'s [[textHeight]].
|
|
230
255
|
*/
|
|
231
256
|
readonly paragraphSpacingFactor: number;
|
|
232
257
|
/** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */
|
|
@@ -236,28 +261,28 @@ export declare class TextStyleSettings {
|
|
|
236
261
|
/** Specifies whether the content of a [[TextRun]] should be underlined. */
|
|
237
262
|
readonly isUnderlined: boolean;
|
|
238
263
|
/** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].
|
|
239
|
-
* The height is computed in meters as stackedFractionScale * [[
|
|
264
|
+
* The height is computed in meters as stackedFractionScale * [[textHeight]].
|
|
240
265
|
*/
|
|
241
266
|
readonly stackedFractionScale: number;
|
|
242
267
|
/** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */
|
|
243
268
|
readonly stackedFractionType: StackedFractionType;
|
|
244
269
|
/** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].
|
|
245
|
-
* The offset is computed in meters as subScriptOffsetFactor * [[
|
|
270
|
+
* The offset is computed in meters as subScriptOffsetFactor * [[textHeight]].
|
|
246
271
|
*/
|
|
247
272
|
readonly subScriptOffsetFactor: number;
|
|
248
273
|
/** Multiplier used to compute the height of a subscript [[TextRun]].
|
|
249
|
-
* The height is computed as subScriptScale * [[
|
|
274
|
+
* The height is computed as subScriptScale * [[textHeight]].
|
|
250
275
|
*/
|
|
251
276
|
readonly subScriptScale: number;
|
|
252
277
|
/** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].
|
|
253
|
-
* The offset is computed in meters as superScriptOffsetFactor * [[
|
|
278
|
+
* The offset is computed in meters as superScriptOffsetFactor * [[textHeight]].
|
|
254
279
|
*/
|
|
255
280
|
readonly superScriptOffsetFactor: number;
|
|
256
281
|
/** Multiplier used to compute the height of a superscript [[TextRun]].
|
|
257
|
-
* The height is computed as superScriptScale * [[
|
|
282
|
+
* The height is computed as superScriptScale * [[textHeight]].
|
|
258
283
|
*/
|
|
259
284
|
readonly superScriptScale: number;
|
|
260
|
-
/** Multiplier used to compute the width of each glyph, relative to [[
|
|
285
|
+
/** Multiplier used to compute the width of each glyph, relative to [[textHeight]]. */
|
|
261
286
|
readonly widthFactor: number;
|
|
262
287
|
/** Properties describing appearance of leaders in a [[TextAnnotation]].
|
|
263
288
|
* Used when producing geometry for [[TextAnnotation]].
|
|
@@ -282,15 +307,17 @@ export declare class TextStyleSettings {
|
|
|
282
307
|
readonly listMarker: ListMarker;
|
|
283
308
|
/** The frame settings of the [[TextAnnotation]]. */
|
|
284
309
|
readonly frame: Readonly<Required<TextFrameStyleProps>>;
|
|
285
|
-
/**
|
|
310
|
+
/** The margins to surround the document content. */
|
|
311
|
+
readonly margins: Readonly<Required<TextBlockMargins>>;
|
|
312
|
+
/** The alignment of the text content. */
|
|
313
|
+
readonly justification: TextJustification;
|
|
314
|
+
/** A fully-populated JSON representation of the default settings. A real `font` must be provided before use. */
|
|
286
315
|
static defaultProps: DeepReadonlyObject<DeepRequiredObject<TextStyleSettingsProps>>;
|
|
287
316
|
/** Settings initialized to all default values. */
|
|
288
317
|
static defaults: TextStyleSettings;
|
|
289
318
|
private constructor();
|
|
290
319
|
/** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
|
|
291
320
|
clone(alteredProps?: TextStyleSettingsProps): TextStyleSettings;
|
|
292
|
-
/** Creates a deep copy of the `TextStyleSettingsProps`. */
|
|
293
|
-
static cloneProps(props: TextStyleSettingsProps): TextStyleSettingsProps;
|
|
294
321
|
/** Create settings from their JSON representation. */
|
|
295
322
|
static fromJSON(props?: TextStyleSettingsProps): TextStyleSettings;
|
|
296
323
|
toJSON(): TextStyleSettingsProps;
|
|
@@ -300,6 +327,7 @@ export declare class TextStyleSettings {
|
|
|
300
327
|
*/
|
|
301
328
|
leaderEquals(other: TextLeaderStyleProps): boolean;
|
|
302
329
|
frameEquals(other: TextFrameStyleProps): boolean;
|
|
330
|
+
marginsEqual(other: TextBlockMargins): boolean;
|
|
303
331
|
equals(other: TextStyleSettings): boolean;
|
|
304
332
|
/**
|
|
305
333
|
* Returns a list of validation errors for this instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"TextStyle.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextStyle.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAY,MAAM,UAAU,CAAC;AAExD;;;GAGG;AACH,oBAAY,oBAAoB;IAC9B,uBAAuB;IACvB,MAAM,MAAM;IACZ,YAAY,MAAM;IAClB,MAAM,MAAM;IACZ,MAAM,WAAM;IACZ,MAAM,WAAM;IACZ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AAW,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC;;OAEG;IACH,SAAgB,UAAU,EAAE,UAAU,CAAC;IACvC,oDAAoD;IACpD,SAAgB,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC/D,oDAAoD;IACpD,SAAgB,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC9D,yCAAyC;IACzC,SAAgB,aAAa,EAAE,iBAAiB,CAAC;IAEjD,gHAAgH;IAChH,OAAc,YAAY,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAC,CAuCxF;IAEF,kDAAkD;IAClD,OAAc,QAAQ,EAAE,iBAAiB,CAA6B;IAEtE,OAAO;IAoDP,uGAAuG;IAChG,KAAK,CAAC,YAAY,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAItE,sDAAsD;WACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,GAAG,iBAAiB;IAIlE,MAAM,IAAI,sBAAsB;IAIvC;;;OAGG;IACI,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAMlD,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO;IAOhD,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAM9C,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO;IAgBhD;;;;;;;;;OASG;IACI,mBAAmB,IAAI,MAAM,EAAE;CAgBvC"}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.TextStyleSettings = exports.textAnnotationFrameShapes = exports.ListMarkerEnumerator = void 0;
|
|
11
11
|
const ColorDef_1 = require("../ColorDef");
|
|
12
|
+
const Fonts_1 = require("../Fonts");
|
|
12
13
|
/** Predefined markers for list items in text annotations.
|
|
13
14
|
* These values control the appearance of list item markers (e.g., bullet, circle, square, dash, number) that denote the start of a list item in a list.
|
|
14
15
|
* @beta
|
|
@@ -30,6 +31,7 @@ var ListMarkerEnumerator;
|
|
|
30
31
|
*/
|
|
31
32
|
exports.textAnnotationFrameShapes = ["none", "line", "rectangle", "circle", "equilateralTriangle", "diamond", "square", "pentagon", "hexagon", "octagon", "capsule", "roundedRectangle"];
|
|
32
33
|
;
|
|
34
|
+
;
|
|
33
35
|
function deepFreeze(obj) {
|
|
34
36
|
if (obj === null || typeof obj !== "object" || Object.isFrozen(obj))
|
|
35
37
|
return;
|
|
@@ -50,20 +52,20 @@ function deepFreeze(obj) {
|
|
|
50
52
|
class TextStyleSettings {
|
|
51
53
|
/** The color of the text. */
|
|
52
54
|
color;
|
|
53
|
-
/** The
|
|
55
|
+
/** The font stored in an iModel, used to draw the contents of a [[TextRun]].
|
|
54
56
|
*/
|
|
55
|
-
|
|
56
|
-
/** The height
|
|
57
|
-
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as
|
|
58
|
-
*
|
|
57
|
+
font;
|
|
58
|
+
/** The height of the text, in meters. Many other settings use the text height as the basis for computing their own values.
|
|
59
|
+
* For example, the height and offset from baseline of a subscript [[TextRun]] are computed as textHeight * [[subScriptScale]] and
|
|
60
|
+
* textHeight * [[subScriptOffsetFactor]], respectively.
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
textHeight;
|
|
61
63
|
/** Multiplier used to compute the vertical distance between two lines of text.
|
|
62
|
-
* The distance is computed in meters as lineSpacingFactor * [[
|
|
64
|
+
* The distance is computed in meters as lineSpacingFactor * [[textHeight]] of the [[TextBlock]].
|
|
63
65
|
*/
|
|
64
66
|
lineSpacingFactor;
|
|
65
67
|
/** Multiplier used to compute the vertical distance between two paragraphs of text.
|
|
66
|
-
* The distance is computed in meters as paragraphSpacingFactor * [[
|
|
68
|
+
* The distance is computed in meters as paragraphSpacingFactor * the [[TextBlock]]'s [[textHeight]].
|
|
67
69
|
*/
|
|
68
70
|
paragraphSpacingFactor;
|
|
69
71
|
/** Specifies whether the content of a [[TextRun]] should be rendered **bold**. */
|
|
@@ -73,28 +75,28 @@ class TextStyleSettings {
|
|
|
73
75
|
/** Specifies whether the content of a [[TextRun]] should be underlined. */
|
|
74
76
|
isUnderlined;
|
|
75
77
|
/** Multiplier used to compute the height of both the numerator and denominator of a [[FractionRun]].
|
|
76
|
-
* The height is computed in meters as stackedFractionScale * [[
|
|
78
|
+
* The height is computed in meters as stackedFractionScale * [[textHeight]].
|
|
77
79
|
*/
|
|
78
80
|
stackedFractionScale;
|
|
79
81
|
/** Specifies how to separate the numerator and denominator of a [[FractionRun]]. */
|
|
80
82
|
stackedFractionType;
|
|
81
83
|
/** Multiplier used to compute the vertical offset from the baseline for a subscript [[TextRun]].
|
|
82
|
-
* The offset is computed in meters as subScriptOffsetFactor * [[
|
|
84
|
+
* The offset is computed in meters as subScriptOffsetFactor * [[textHeight]].
|
|
83
85
|
*/
|
|
84
86
|
subScriptOffsetFactor;
|
|
85
87
|
/** Multiplier used to compute the height of a subscript [[TextRun]].
|
|
86
|
-
* The height is computed as subScriptScale * [[
|
|
88
|
+
* The height is computed as subScriptScale * [[textHeight]].
|
|
87
89
|
*/
|
|
88
90
|
subScriptScale;
|
|
89
91
|
/** Multiplier used to compute the vertical offset from the baseline for a super [[TextRun]].
|
|
90
|
-
* The offset is computed in meters as superScriptOffsetFactor * [[
|
|
92
|
+
* The offset is computed in meters as superScriptOffsetFactor * [[textHeight]].
|
|
91
93
|
*/
|
|
92
94
|
superScriptOffsetFactor;
|
|
93
95
|
/** Multiplier used to compute the height of a superscript [[TextRun]].
|
|
94
|
-
* The height is computed as superScriptScale * [[
|
|
96
|
+
* The height is computed as superScriptScale * [[textHeight]].
|
|
95
97
|
*/
|
|
96
98
|
superScriptScale;
|
|
97
|
-
/** Multiplier used to compute the width of each glyph, relative to [[
|
|
99
|
+
/** Multiplier used to compute the width of each glyph, relative to [[textHeight]]. */
|
|
98
100
|
widthFactor;
|
|
99
101
|
/** Properties describing appearance of leaders in a [[TextAnnotation]].
|
|
100
102
|
* Used when producing geometry for [[TextAnnotation]].
|
|
@@ -119,11 +121,15 @@ class TextStyleSettings {
|
|
|
119
121
|
listMarker;
|
|
120
122
|
/** The frame settings of the [[TextAnnotation]]. */
|
|
121
123
|
frame;
|
|
122
|
-
/**
|
|
124
|
+
/** The margins to surround the document content. */
|
|
125
|
+
margins;
|
|
126
|
+
/** The alignment of the text content. */
|
|
127
|
+
justification;
|
|
128
|
+
/** A fully-populated JSON representation of the default settings. A real `font` must be provided before use. */
|
|
123
129
|
static defaultProps = {
|
|
124
130
|
color: "subcategory",
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
font: { name: "", type: Fonts_1.FontType.TrueType },
|
|
132
|
+
textHeight: 1,
|
|
127
133
|
lineSpacingFactor: 0.5,
|
|
128
134
|
paragraphSpacingFactor: 0.5,
|
|
129
135
|
isBold: false,
|
|
@@ -148,10 +154,17 @@ class TextStyleSettings {
|
|
|
148
154
|
listMarker: { enumerator: "1", terminator: "period", case: "lower" },
|
|
149
155
|
frame: {
|
|
150
156
|
shape: "none",
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
fillColor: "none",
|
|
158
|
+
borderColor: ColorDef_1.ColorDef.black.toJSON(),
|
|
153
159
|
borderWeight: 1,
|
|
154
160
|
},
|
|
161
|
+
margins: {
|
|
162
|
+
left: 0,
|
|
163
|
+
right: 0,
|
|
164
|
+
top: 0,
|
|
165
|
+
bottom: 0
|
|
166
|
+
},
|
|
167
|
+
justification: "left",
|
|
155
168
|
};
|
|
156
169
|
/** Settings initialized to all default values. */
|
|
157
170
|
static defaults = new TextStyleSettings({});
|
|
@@ -160,8 +173,12 @@ class TextStyleSettings {
|
|
|
160
173
|
defaults = TextStyleSettings.defaultProps;
|
|
161
174
|
}
|
|
162
175
|
this.color = props.color ?? defaults.color;
|
|
163
|
-
|
|
164
|
-
|
|
176
|
+
const font = {
|
|
177
|
+
name: props.font?.name ?? defaults.font.name,
|
|
178
|
+
type: props.font?.type ?? defaults.font.type,
|
|
179
|
+
};
|
|
180
|
+
this.font = Object.freeze(font);
|
|
181
|
+
this.textHeight = props.textHeight ?? defaults.textHeight;
|
|
165
182
|
this.lineSpacingFactor = props.lineSpacingFactor ?? defaults.lineSpacingFactor;
|
|
166
183
|
this.paragraphSpacingFactor = props.paragraphSpacingFactor ?? defaults.paragraphSpacingFactor;
|
|
167
184
|
this.isBold = props.isBold ?? defaults.isBold;
|
|
@@ -187,34 +204,30 @@ class TextStyleSettings {
|
|
|
187
204
|
this.listMarker = props.listMarker ?? defaults.listMarker;
|
|
188
205
|
const frame = {
|
|
189
206
|
shape: props.frame?.shape ?? defaults.frame.shape,
|
|
190
|
-
|
|
191
|
-
|
|
207
|
+
fillColor: props.frame?.fillColor ?? defaults.frame.fillColor,
|
|
208
|
+
borderColor: props.frame?.borderColor ?? defaults.frame.borderColor,
|
|
192
209
|
borderWeight: props.frame?.borderWeight ?? defaults.frame.borderWeight,
|
|
193
210
|
};
|
|
194
211
|
// Cast to indicate to TypeScript that the frame properties are all defined
|
|
195
212
|
this.frame = Object.freeze(frame);
|
|
213
|
+
this.margins = Object.freeze({
|
|
214
|
+
left: props.margins?.left ?? defaults.margins.left,
|
|
215
|
+
right: props.margins?.right ?? defaults.margins.right,
|
|
216
|
+
top: props.margins?.top ?? defaults.margins.top,
|
|
217
|
+
bottom: props.margins?.bottom ?? defaults.margins.bottom,
|
|
218
|
+
});
|
|
219
|
+
this.justification = props.justification ?? defaults.justification;
|
|
196
220
|
}
|
|
197
221
|
/** Create a copy of these settings, modified according to the properties defined by `alteredProps`. */
|
|
198
222
|
clone(alteredProps) {
|
|
199
223
|
return alteredProps ? new TextStyleSettings(alteredProps, this) : this;
|
|
200
224
|
}
|
|
201
|
-
/** Creates a deep copy of the `TextStyleSettingsProps`. */
|
|
202
|
-
static cloneProps(props) {
|
|
203
|
-
const copy = { ...props };
|
|
204
|
-
if (props.leader) {
|
|
205
|
-
copy.leader = { ...props.leader };
|
|
206
|
-
}
|
|
207
|
-
if (props.frame) {
|
|
208
|
-
copy.frame = { ...props.frame };
|
|
209
|
-
}
|
|
210
|
-
return copy;
|
|
211
|
-
}
|
|
212
225
|
/** Create settings from their JSON representation. */
|
|
213
226
|
static fromJSON(props) {
|
|
214
227
|
return props ? new TextStyleSettings(props) : TextStyleSettings.defaults;
|
|
215
228
|
}
|
|
216
229
|
toJSON() {
|
|
217
|
-
return
|
|
230
|
+
return structuredClone(this);
|
|
218
231
|
}
|
|
219
232
|
/** Compare two [[TextLeaderStyleProps]] for equality.
|
|
220
233
|
* @param other The other leader style properties to compare against.
|
|
@@ -227,21 +240,27 @@ class TextStyleSettings {
|
|
|
227
240
|
}
|
|
228
241
|
frameEquals(other) {
|
|
229
242
|
return this.frame?.shape === other.shape
|
|
230
|
-
&& this.frame?.
|
|
231
|
-
&& this.frame?.
|
|
243
|
+
&& this.frame?.fillColor === other.fillColor
|
|
244
|
+
&& this.frame?.borderColor === other.borderColor
|
|
232
245
|
&& this.frame?.borderWeight === other.borderWeight;
|
|
233
246
|
}
|
|
247
|
+
marginsEqual(other) {
|
|
248
|
+
return Object.entries(this.margins).every(([key, value]) => value === other[key]);
|
|
249
|
+
}
|
|
234
250
|
equals(other) {
|
|
235
|
-
return this.color === other.color && this.
|
|
236
|
-
&& this.
|
|
251
|
+
return this.color === other.color && this.font.name === other.font.name && this.font.type === other.font.type
|
|
252
|
+
&& this.textHeight === other.textHeight && this.widthFactor === other.widthFactor
|
|
253
|
+
&& this.lineSpacingFactor === other.lineSpacingFactor && this.paragraphSpacingFactor === other.paragraphSpacingFactor
|
|
237
254
|
&& this.isBold === other.isBold && this.isItalic === other.isItalic && this.isUnderlined === other.isUnderlined
|
|
238
255
|
&& this.stackedFractionType === other.stackedFractionType && this.stackedFractionScale === other.stackedFractionScale
|
|
239
256
|
&& this.subScriptOffsetFactor === other.subScriptOffsetFactor && this.subScriptScale === other.subScriptScale
|
|
240
257
|
&& this.superScriptOffsetFactor === other.superScriptOffsetFactor && this.superScriptScale === other.superScriptScale
|
|
241
258
|
&& this.tabInterval === other.tabInterval && this.indentation === other.indentation
|
|
242
259
|
&& this.listMarker.case === other.listMarker.case && this.listMarker.enumerator === other.listMarker.enumerator && this.listMarker.terminator === other.listMarker.terminator
|
|
260
|
+
&& this.justification === other.justification
|
|
243
261
|
&& this.leaderEquals(other.leader)
|
|
244
|
-
&& this.frameEquals(other.frame)
|
|
262
|
+
&& this.frameEquals(other.frame)
|
|
263
|
+
&& this.marginsEqual(other.margins);
|
|
245
264
|
}
|
|
246
265
|
/**
|
|
247
266
|
* Returns a list of validation errors for this instance.
|
|
@@ -255,11 +274,11 @@ class TextStyleSettings {
|
|
|
255
274
|
*/
|
|
256
275
|
getValidationErrors() {
|
|
257
276
|
const errorMessages = [];
|
|
258
|
-
if (this.
|
|
259
|
-
errorMessages.push("
|
|
277
|
+
if (this.font.name.trim() === "") {
|
|
278
|
+
errorMessages.push("font name must be provided");
|
|
260
279
|
}
|
|
261
|
-
if (this.
|
|
262
|
-
errorMessages.push("
|
|
280
|
+
if (this.textHeight <= 0) {
|
|
281
|
+
errorMessages.push("textHeight must be greater than 0");
|
|
263
282
|
}
|
|
264
283
|
if (this.stackedFractionScale <= 0) {
|
|
265
284
|
errorMessages.push("stackedFractionScale must be greater than 0");
|