@itwin/core-common 5.1.0-dev.9 → 5.2.0-dev.2
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/CHANGELOG.md +91 -1
- package/lib/cjs/BackgroundMapSettings.d.ts +2 -2
- package/lib/cjs/BackgroundMapSettings.js.map +1 -1
- package/lib/cjs/ChangesetProps.d.ts +28 -0
- package/lib/cjs/ChangesetProps.d.ts.map +1 -1
- package/lib/cjs/ChangesetProps.js.map +1 -1
- package/lib/cjs/ClipStyle.d.ts +1 -1
- package/lib/cjs/ClipStyle.d.ts.map +1 -1
- package/lib/cjs/ClipStyle.js.map +1 -1
- package/lib/cjs/CommonLoggerCategory.d.ts +2 -0
- package/lib/cjs/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/cjs/CommonLoggerCategory.js +2 -0
- package/lib/cjs/CommonLoggerCategory.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.d.ts +8 -23
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +1 -11
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/ContextRealityModel.d.ts +8 -8
- package/lib/cjs/ContextRealityModel.js +8 -8
- package/lib/cjs/ContextRealityModel.js.map +1 -1
- package/lib/cjs/ElementProps.d.ts +64 -54
- package/lib/cjs/ElementProps.d.ts.map +1 -1
- package/lib/cjs/ElementProps.js +6 -6
- package/lib/cjs/ElementProps.js.map +1 -1
- package/lib/cjs/EntityProps.d.ts +10 -10
- package/lib/cjs/EntityProps.d.ts.map +1 -1
- package/lib/cjs/EntityProps.js +4 -2
- package/lib/cjs/EntityProps.js.map +1 -1
- package/lib/cjs/Fonts.d.ts +2 -2
- package/lib/cjs/Fonts.js +1 -1
- package/lib/cjs/Fonts.js.map +1 -1
- package/lib/cjs/GeoCoordinateServices.d.ts +1 -1
- package/lib/cjs/GeoCoordinateServices.js +1 -1
- package/lib/cjs/GeoCoordinateServices.js.map +1 -1
- package/lib/cjs/GeometryParams.d.ts +3 -1
- package/lib/cjs/GeometryParams.d.ts.map +1 -1
- package/lib/cjs/GeometryParams.js +3 -1
- package/lib/cjs/GeometryParams.js.map +1 -1
- package/lib/cjs/GraphicParams.d.ts +1 -0
- package/lib/cjs/GraphicParams.d.ts.map +1 -1
- package/lib/cjs/GraphicParams.js +1 -0
- package/lib/cjs/GraphicParams.js.map +1 -1
- package/lib/cjs/IModel.d.ts +3 -3
- package/lib/cjs/IModel.js.map +1 -1
- package/lib/cjs/ITwinCoreErrors.d.ts +1 -1
- package/lib/cjs/ITwinCoreErrors.d.ts.map +1 -1
- package/lib/cjs/ITwinCoreErrors.js.map +1 -1
- package/lib/cjs/MassProperties.d.ts +2 -2
- package/lib/cjs/MassProperties.js.map +1 -1
- package/lib/cjs/MaterialProps.d.ts +6 -3
- package/lib/cjs/MaterialProps.d.ts.map +1 -1
- package/lib/cjs/MaterialProps.js.map +1 -1
- package/lib/cjs/RenderSchedule.d.ts +14 -0
- package/lib/cjs/RenderSchedule.d.ts.map +1 -1
- package/lib/cjs/RenderSchedule.js +4 -0
- package/lib/cjs/RenderSchedule.js.map +1 -1
- package/lib/cjs/RenderTexture.d.ts +1 -1
- package/lib/cjs/RenderTexture.d.ts.map +1 -1
- package/lib/cjs/RenderTexture.js.map +1 -1
- package/lib/cjs/TerrainSettings.d.ts +1 -1
- package/lib/cjs/TerrainSettings.d.ts.map +1 -1
- package/lib/cjs/TerrainSettings.js.map +1 -1
- package/lib/cjs/annotation/TextAnnotation.d.ts +78 -2
- package/lib/cjs/annotation/TextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotation/TextAnnotation.js +63 -10
- package/lib/cjs/annotation/TextAnnotation.js.map +1 -1
- package/lib/cjs/annotation/TextBlock.d.ts +179 -44
- package/lib/cjs/annotation/TextBlock.d.ts.map +1 -1
- package/lib/cjs/annotation/TextBlock.js +210 -57
- package/lib/cjs/annotation/TextBlock.js.map +1 -1
- package/lib/cjs/annotation/TextBlockGeometryProps.d.ts +1 -1
- package/lib/cjs/annotation/TextBlockGeometryProps.js.map +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.d.ts +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.d.ts.map +1 -1
- package/lib/cjs/annotation/TextBlockLayoutResult.js.map +1 -1
- package/lib/cjs/annotation/TextStyle.d.ts +115 -34
- package/lib/cjs/annotation/TextStyle.d.ts.map +1 -1
- package/lib/cjs/annotation/TextStyle.js +118 -37
- package/lib/cjs/annotation/TextStyle.js.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.d.ts +4 -0
- package/lib/cjs/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/cjs/geometry/AdditionalTransform.js +9 -0
- package/lib/cjs/geometry/AdditionalTransform.js.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts +1 -1
- package/lib/cjs/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/cjs/geometry/ElementGeometry.js +2 -2
- package/lib/cjs/geometry/ElementGeometry.js.map +1 -1
- package/lib/cjs/internal/BackendTypes.d.ts +3 -3
- package/lib/cjs/internal/BackendTypes.d.ts.map +1 -1
- package/lib/cjs/internal/BackendTypes.js.map +1 -1
- package/lib/cjs/internal/RenderMesh.d.ts +19 -5
- package/lib/cjs/internal/RenderMesh.d.ts.map +1 -1
- package/lib/cjs/internal/RenderMesh.js +11 -8
- package/lib/cjs/internal/RenderMesh.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +1 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js +1 -1
- package/lib/cjs/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.d.ts +4 -4
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.js +4 -4
- package/lib/cjs/rpc/SnapshotIModelRpcInterface.js.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/cjs/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/cjs/rpc/core/RpcConstants.js +6 -6
- package/lib/cjs/rpc/core/RpcConstants.js.map +1 -1
- package/lib/cjs/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/cjs/rpc/web/OpenAPI.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/cjs/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/cjs/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/cjs/tile/IModelTileIO.d.ts +2 -2
- package/lib/cjs/tile/IModelTileIO.js +2 -2
- package/lib/cjs/tile/IModelTileIO.js.map +1 -1
- package/lib/cjs/tile/TileMetadata.d.ts +6 -2
- package/lib/cjs/tile/TileMetadata.d.ts.map +1 -1
- package/lib/cjs/tile/TileMetadata.js +10 -4
- package/lib/cjs/tile/TileMetadata.js.map +1 -1
- package/lib/esm/BackgroundMapSettings.d.ts +2 -2
- package/lib/esm/BackgroundMapSettings.js.map +1 -1
- package/lib/esm/ChangesetProps.d.ts +28 -0
- package/lib/esm/ChangesetProps.d.ts.map +1 -1
- package/lib/esm/ChangesetProps.js.map +1 -1
- package/lib/esm/ClipStyle.d.ts +1 -1
- package/lib/esm/ClipStyle.d.ts.map +1 -1
- package/lib/esm/ClipStyle.js.map +1 -1
- package/lib/esm/CommonLoggerCategory.d.ts +2 -0
- package/lib/esm/CommonLoggerCategory.d.ts.map +1 -1
- package/lib/esm/CommonLoggerCategory.js +2 -0
- package/lib/esm/CommonLoggerCategory.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +8 -23
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +1 -11
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/ContextRealityModel.d.ts +8 -8
- package/lib/esm/ContextRealityModel.js +8 -8
- package/lib/esm/ContextRealityModel.js.map +1 -1
- package/lib/esm/ElementProps.d.ts +64 -54
- package/lib/esm/ElementProps.d.ts.map +1 -1
- package/lib/esm/ElementProps.js +6 -6
- package/lib/esm/ElementProps.js.map +1 -1
- package/lib/esm/EntityProps.d.ts +10 -10
- package/lib/esm/EntityProps.d.ts.map +1 -1
- package/lib/esm/EntityProps.js +4 -2
- package/lib/esm/EntityProps.js.map +1 -1
- package/lib/esm/Fonts.d.ts +2 -2
- package/lib/esm/Fonts.js +1 -1
- package/lib/esm/Fonts.js.map +1 -1
- package/lib/esm/GeoCoordinateServices.d.ts +1 -1
- package/lib/esm/GeoCoordinateServices.js +1 -1
- package/lib/esm/GeoCoordinateServices.js.map +1 -1
- package/lib/esm/GeometryParams.d.ts +3 -1
- package/lib/esm/GeometryParams.d.ts.map +1 -1
- package/lib/esm/GeometryParams.js +3 -1
- package/lib/esm/GeometryParams.js.map +1 -1
- package/lib/esm/GraphicParams.d.ts +1 -0
- package/lib/esm/GraphicParams.d.ts.map +1 -1
- package/lib/esm/GraphicParams.js +1 -0
- package/lib/esm/GraphicParams.js.map +1 -1
- package/lib/esm/IModel.d.ts +3 -3
- package/lib/esm/IModel.js.map +1 -1
- package/lib/esm/ITwinCoreErrors.d.ts +1 -1
- package/lib/esm/ITwinCoreErrors.d.ts.map +1 -1
- package/lib/esm/ITwinCoreErrors.js.map +1 -1
- package/lib/esm/MassProperties.d.ts +2 -2
- package/lib/esm/MassProperties.js.map +1 -1
- package/lib/esm/MaterialProps.d.ts +6 -3
- package/lib/esm/MaterialProps.d.ts.map +1 -1
- package/lib/esm/MaterialProps.js.map +1 -1
- package/lib/esm/RenderSchedule.d.ts +14 -0
- package/lib/esm/RenderSchedule.d.ts.map +1 -1
- package/lib/esm/RenderSchedule.js +4 -0
- package/lib/esm/RenderSchedule.js.map +1 -1
- package/lib/esm/RenderTexture.d.ts +1 -1
- package/lib/esm/RenderTexture.d.ts.map +1 -1
- package/lib/esm/RenderTexture.js.map +1 -1
- package/lib/esm/TerrainSettings.d.ts +1 -1
- package/lib/esm/TerrainSettings.d.ts.map +1 -1
- package/lib/esm/TerrainSettings.js.map +1 -1
- package/lib/esm/annotation/TextAnnotation.d.ts +78 -2
- package/lib/esm/annotation/TextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotation/TextAnnotation.js +63 -10
- package/lib/esm/annotation/TextAnnotation.js.map +1 -1
- package/lib/esm/annotation/TextBlock.d.ts +179 -44
- package/lib/esm/annotation/TextBlock.d.ts.map +1 -1
- package/lib/esm/annotation/TextBlock.js +207 -56
- package/lib/esm/annotation/TextBlock.js.map +1 -1
- package/lib/esm/annotation/TextBlockGeometryProps.d.ts +1 -1
- package/lib/esm/annotation/TextBlockGeometryProps.js.map +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.d.ts +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.d.ts.map +1 -1
- package/lib/esm/annotation/TextBlockLayoutResult.js.map +1 -1
- package/lib/esm/annotation/TextStyle.d.ts +115 -34
- package/lib/esm/annotation/TextStyle.d.ts.map +1 -1
- package/lib/esm/annotation/TextStyle.js +116 -34
- package/lib/esm/annotation/TextStyle.js.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.d.ts +4 -0
- package/lib/esm/geometry/AdditionalTransform.d.ts.map +1 -1
- package/lib/esm/geometry/AdditionalTransform.js +10 -1
- package/lib/esm/geometry/AdditionalTransform.js.map +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts +1 -1
- package/lib/esm/geometry/ElementGeometry.d.ts.map +1 -1
- package/lib/esm/geometry/ElementGeometry.js +2 -2
- package/lib/esm/geometry/ElementGeometry.js.map +1 -1
- package/lib/esm/internal/BackendTypes.d.ts +3 -3
- package/lib/esm/internal/BackendTypes.d.ts.map +1 -1
- package/lib/esm/internal/BackendTypes.js.map +1 -1
- package/lib/esm/internal/RenderMesh.d.ts +19 -5
- package/lib/esm/internal/RenderMesh.d.ts.map +1 -1
- package/lib/esm/internal/RenderMesh.js +11 -8
- package/lib/esm/internal/RenderMesh.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +1 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.d.ts.map +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js +1 -1
- package/lib/esm/rpc/IModelReadRpcInterface.js.map +1 -1
- package/lib/esm/rpc/SnapshotIModelRpcInterface.d.ts +4 -4
- package/lib/esm/rpc/SnapshotIModelRpcInterface.js +4 -4
- package/lib/esm/rpc/SnapshotIModelRpcInterface.js.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.d.ts +6 -6
- package/lib/esm/rpc/core/RpcConstants.d.ts.map +1 -1
- package/lib/esm/rpc/core/RpcConstants.js +6 -6
- package/lib/esm/rpc/core/RpcConstants.js.map +1 -1
- package/lib/esm/rpc/web/OpenAPI.d.ts +1 -1
- package/lib/esm/rpc/web/OpenAPI.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcLogging.js.map +1 -1
- package/lib/esm/rpc/web/WebAppRpcProtocol.d.ts +2 -2
- package/lib/esm/rpc/web/WebAppRpcProtocol.js.map +1 -1
- package/lib/esm/tile/IModelTileIO.d.ts +2 -2
- package/lib/esm/tile/IModelTileIO.js +2 -2
- package/lib/esm/tile/IModelTileIO.js.map +1 -1
- package/lib/esm/tile/TileMetadata.d.ts +6 -2
- package/lib/esm/tile/TileMetadata.d.ts.map +1 -1
- package/lib/esm/tile/TileMetadata.js +10 -4
- package/lib/esm/tile/TileMetadata.js.map +1 -1
- package/package.json +9 -8
|
@@ -5,29 +5,18 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Annotation
|
|
7
7
|
*/
|
|
8
|
+
import { TextStyleSettings } from "./TextStyle";
|
|
8
9
|
/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.
|
|
9
|
-
*
|
|
10
|
+
* The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.
|
|
10
11
|
* @beta
|
|
11
12
|
*/
|
|
12
13
|
export class TextBlockComponent {
|
|
13
|
-
_styleName;
|
|
14
14
|
_styleOverrides;
|
|
15
15
|
/** @internal */
|
|
16
16
|
constructor(props) {
|
|
17
|
-
this.
|
|
18
|
-
this._styleOverrides = { ...props.styleOverrides };
|
|
17
|
+
this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});
|
|
19
18
|
}
|
|
20
|
-
/**
|
|
21
|
-
* @note Assigning to this property is equivalent to calling [[applyStyle]] with default [[ApplyTextStyleOptions]], which propagates the style change to all of
|
|
22
|
-
* the components sub-components and clears any [[styleOverrides]].
|
|
23
|
-
*/
|
|
24
|
-
get styleName() {
|
|
25
|
-
return this._styleName;
|
|
26
|
-
}
|
|
27
|
-
set styleName(styleName) {
|
|
28
|
-
this.applyStyle(styleName);
|
|
29
|
-
}
|
|
30
|
-
/** Deviations in individual properties of the [[TextStyle]] specified by [[styleName]].
|
|
19
|
+
/** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].
|
|
31
20
|
* For example, if the style uses the "Arial" font, you can override that by settings `styleOverrides.fontName` to "Comic Sans".
|
|
32
21
|
* @see [[clearStyleOverrides]] to reset this to an empty object.
|
|
33
22
|
*/
|
|
@@ -35,35 +24,35 @@ export class TextBlockComponent {
|
|
|
35
24
|
return this._styleOverrides;
|
|
36
25
|
}
|
|
37
26
|
set styleOverrides(overrides) {
|
|
38
|
-
this._styleOverrides =
|
|
27
|
+
this._styleOverrides = TextStyleSettings.cloneProps(overrides);
|
|
39
28
|
}
|
|
40
|
-
/** Reset any [[styleOverrides]] applied to this component
|
|
41
|
-
clearStyleOverrides() {
|
|
29
|
+
/** Reset any [[styleOverrides]] applied to this component. */
|
|
30
|
+
clearStyleOverrides(_options) {
|
|
42
31
|
this.styleOverrides = {};
|
|
43
32
|
}
|
|
44
|
-
/**
|
|
45
|
-
applyStyle(styleName, options) {
|
|
46
|
-
this._styleName = styleName;
|
|
47
|
-
if (!(options?.preserveOverrides)) {
|
|
48
|
-
this.clearStyleOverrides();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/** Returns true if [[styleOverrides]] specifies any deviations from this component's base [[TextStyle]]. */
|
|
33
|
+
/** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */
|
|
52
34
|
get overridesStyle() {
|
|
53
35
|
return Object.keys(this.styleOverrides).length > 0;
|
|
54
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Returns true if the string representation of this component consists only of whitespace characters.
|
|
39
|
+
* Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.
|
|
40
|
+
*/
|
|
41
|
+
get isWhitespace() {
|
|
42
|
+
return /^\s*$/g.test(this.stringify());
|
|
43
|
+
}
|
|
44
|
+
;
|
|
55
45
|
/** Convert this component to its JSON representation. */
|
|
56
46
|
toJSON() {
|
|
57
47
|
return {
|
|
58
|
-
|
|
59
|
-
styleOverrides: { ...this.styleOverrides },
|
|
48
|
+
styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),
|
|
60
49
|
};
|
|
61
50
|
}
|
|
62
51
|
/** Returns true if `this` is equivalent to `other`. */
|
|
63
52
|
equals(other) {
|
|
64
53
|
const myKeys = Object.keys(this.styleOverrides);
|
|
65
54
|
const yrKeys = Object.keys(other._styleOverrides);
|
|
66
|
-
if (
|
|
55
|
+
if (myKeys.length !== yrKeys.length) {
|
|
67
56
|
return false;
|
|
68
57
|
}
|
|
69
58
|
for (const name of myKeys) {
|
|
@@ -89,7 +78,9 @@ export var Run;
|
|
|
89
78
|
switch (props.type) {
|
|
90
79
|
case "text": return TextRun.create(props);
|
|
91
80
|
case "fraction": return FractionRun.create(props);
|
|
81
|
+
case "tab": return TabRun.create(props);
|
|
92
82
|
case "linebreak": return LineBreakRun.create(props);
|
|
83
|
+
case "field": return FieldRun.create(props);
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
86
|
Run.fromJSON = fromJSON;
|
|
@@ -106,8 +97,8 @@ export class TextRun extends TextBlockComponent {
|
|
|
106
97
|
baselineShift;
|
|
107
98
|
constructor(props) {
|
|
108
99
|
super(props);
|
|
109
|
-
this.content = props
|
|
110
|
-
this.baselineShift = props
|
|
100
|
+
this.content = props?.content ?? "";
|
|
101
|
+
this.baselineShift = props?.baselineShift ?? "none";
|
|
111
102
|
}
|
|
112
103
|
clone() {
|
|
113
104
|
return new TextRun(this.toJSON());
|
|
@@ -144,8 +135,8 @@ export class FractionRun extends TextBlockComponent {
|
|
|
144
135
|
denominator;
|
|
145
136
|
constructor(props) {
|
|
146
137
|
super(props);
|
|
147
|
-
this.numerator = props
|
|
148
|
-
this.denominator = props
|
|
138
|
+
this.numerator = props?.numerator ?? "";
|
|
139
|
+
this.denominator = props?.denominator ?? "";
|
|
149
140
|
}
|
|
150
141
|
toJSON() {
|
|
151
142
|
return {
|
|
@@ -199,6 +190,147 @@ export class LineBreakRun extends TextBlockComponent {
|
|
|
199
190
|
return other instanceof LineBreakRun && super.equals(other);
|
|
200
191
|
}
|
|
201
192
|
}
|
|
193
|
+
/** A [[TabRun]] is used to shift the next tab stop.
|
|
194
|
+
* @note Only left-justified tabs are supported at this tab.
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
export class TabRun extends TextBlockComponent {
|
|
198
|
+
/** Discriminator field for the [[Run]] union. */
|
|
199
|
+
type = "tab";
|
|
200
|
+
toJSON() {
|
|
201
|
+
return {
|
|
202
|
+
...super.toJSON(),
|
|
203
|
+
type: "tab",
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
clone() {
|
|
207
|
+
return new TabRun(this.toJSON());
|
|
208
|
+
}
|
|
209
|
+
static create(props) {
|
|
210
|
+
return new TabRun(props);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Converts a [[TabRun]] to its string representation.
|
|
214
|
+
* If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.
|
|
215
|
+
* Otherwise, returns a tab character ("\t").
|
|
216
|
+
*/
|
|
217
|
+
stringify(options) {
|
|
218
|
+
if (options?.tabsAsSpaces) {
|
|
219
|
+
return " ".repeat(options.tabsAsSpaces);
|
|
220
|
+
}
|
|
221
|
+
return "\t";
|
|
222
|
+
}
|
|
223
|
+
equals(other) {
|
|
224
|
+
return other instanceof TabRun && super.equals(other);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** A [[Run]] that displays the formatted value of a property of some [Element]($backend).
|
|
228
|
+
* When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,
|
|
229
|
+
* a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that
|
|
230
|
+
* whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically
|
|
231
|
+
* recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or
|
|
232
|
+
* property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].
|
|
233
|
+
* A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.
|
|
234
|
+
* @beta
|
|
235
|
+
*/
|
|
236
|
+
export class FieldRun extends TextBlockComponent {
|
|
237
|
+
/** Display string used to signal an error in computing the field's value. */
|
|
238
|
+
static invalidContentIndicator = "####";
|
|
239
|
+
/** Discriminator field for the [[Run]] union. */
|
|
240
|
+
type = "field";
|
|
241
|
+
/** The element and BIS class containing the property described by [[propertyPath]]. */
|
|
242
|
+
propertyHost;
|
|
243
|
+
/** Describes how to obtain the property value from [[propertyHost]]. */
|
|
244
|
+
propertyPath;
|
|
245
|
+
/** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
|
|
246
|
+
formatter;
|
|
247
|
+
_cachedContent;
|
|
248
|
+
/** The field's most recently evaluated display string. */
|
|
249
|
+
get cachedContent() {
|
|
250
|
+
return this._cachedContent;
|
|
251
|
+
}
|
|
252
|
+
/** @internal Used by core-backend when re-evaluating field content. */
|
|
253
|
+
setCachedContent(content) {
|
|
254
|
+
this._cachedContent = content ?? FieldRun.invalidContentIndicator;
|
|
255
|
+
}
|
|
256
|
+
constructor(props) {
|
|
257
|
+
super(props);
|
|
258
|
+
this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;
|
|
259
|
+
this.propertyHost = props.propertyHost;
|
|
260
|
+
this.propertyPath = props.propertyPath;
|
|
261
|
+
this.formatter = props.formatter;
|
|
262
|
+
}
|
|
263
|
+
/** Create a FieldRun from its JSON representation. */
|
|
264
|
+
static create(props) {
|
|
265
|
+
return new FieldRun({
|
|
266
|
+
...props,
|
|
267
|
+
propertyHost: { ...props.propertyHost },
|
|
268
|
+
propertyPath: structuredClone(props.propertyPath),
|
|
269
|
+
formatter: structuredClone(props.formatter),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/** Convert the FieldRun to its JSON representation. */
|
|
273
|
+
toJSON() {
|
|
274
|
+
const json = {
|
|
275
|
+
...super.toJSON(),
|
|
276
|
+
type: "field",
|
|
277
|
+
propertyHost: { ...this.propertyHost },
|
|
278
|
+
propertyPath: structuredClone(this.propertyPath),
|
|
279
|
+
};
|
|
280
|
+
if (this.cachedContent !== FieldRun.invalidContentIndicator) {
|
|
281
|
+
json.cachedContent = this.cachedContent;
|
|
282
|
+
}
|
|
283
|
+
if (this.formatter) {
|
|
284
|
+
json.formatter = structuredClone(this.formatter);
|
|
285
|
+
}
|
|
286
|
+
return json;
|
|
287
|
+
}
|
|
288
|
+
/** Create a deep copy of this FieldRun. */
|
|
289
|
+
clone() {
|
|
290
|
+
return new FieldRun(this.toJSON());
|
|
291
|
+
}
|
|
292
|
+
/** Convert this FieldRun to a simple string representation. */
|
|
293
|
+
stringify() {
|
|
294
|
+
return this.cachedContent;
|
|
295
|
+
}
|
|
296
|
+
/** Returns true if `this` is equivalent to `other`. */
|
|
297
|
+
equals(other) {
|
|
298
|
+
if (!(other instanceof FieldRun) || !super.equals(other)) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
if (this.propertyHost.elementId !== other.propertyHost.elementId ||
|
|
302
|
+
this.propertyHost.className !== other.propertyHost.className ||
|
|
303
|
+
this.propertyHost.schemaName !== other.propertyHost.schemaName) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
const thisAccessors = this.propertyPath.accessors ?? [];
|
|
310
|
+
const otherAccessors = other.propertyPath.accessors ?? [];
|
|
311
|
+
const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];
|
|
312
|
+
const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];
|
|
313
|
+
if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if (this.formatter && other.formatter) {
|
|
323
|
+
// ###TODO better comparison of formatter objects.
|
|
324
|
+
if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else if (this.formatter || other.formatter) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
202
334
|
/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.
|
|
203
335
|
* @beta
|
|
204
336
|
*/
|
|
@@ -207,7 +339,7 @@ export class Paragraph extends TextBlockComponent {
|
|
|
207
339
|
runs;
|
|
208
340
|
constructor(props) {
|
|
209
341
|
super(props);
|
|
210
|
-
this.runs = props
|
|
342
|
+
this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];
|
|
211
343
|
}
|
|
212
344
|
toJSON() {
|
|
213
345
|
return {
|
|
@@ -222,13 +354,16 @@ export class Paragraph extends TextBlockComponent {
|
|
|
222
354
|
clone() {
|
|
223
355
|
return new Paragraph(this.toJSON());
|
|
224
356
|
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
357
|
+
/**
|
|
358
|
+
* Clears any [[styleOverrides]] applied to this Paragraph.
|
|
359
|
+
* Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.
|
|
360
|
+
*/
|
|
361
|
+
clearStyleOverrides(options) {
|
|
362
|
+
super.clearStyleOverrides();
|
|
363
|
+
if (options?.preserveChildrenOverrides)
|
|
364
|
+
return;
|
|
365
|
+
for (const run of this.runs) {
|
|
366
|
+
run.clearStyleOverrides();
|
|
232
367
|
}
|
|
233
368
|
}
|
|
234
369
|
/** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */
|
|
@@ -253,6 +388,11 @@ export class Paragraph extends TextBlockComponent {
|
|
|
253
388
|
* @beta
|
|
254
389
|
*/
|
|
255
390
|
export class TextBlock extends TextBlockComponent {
|
|
391
|
+
/** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.
|
|
392
|
+
* @note Assigning to this property retains all style overrides on the TextBlock and its child components.
|
|
393
|
+
* Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.
|
|
394
|
+
*/
|
|
395
|
+
styleId;
|
|
256
396
|
/** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.
|
|
257
397
|
* A value less than or equal to zero indicates no wrapping is to be applied.
|
|
258
398
|
* Default: 0
|
|
@@ -266,6 +406,7 @@ export class TextBlock extends TextBlockComponent {
|
|
|
266
406
|
paragraphs;
|
|
267
407
|
constructor(props) {
|
|
268
408
|
super(props);
|
|
409
|
+
this.styleId = props.styleId;
|
|
269
410
|
this.width = props.width ?? 0;
|
|
270
411
|
this.justification = props.justification ?? "left";
|
|
271
412
|
// Assign default margins if not provided
|
|
@@ -280,6 +421,7 @@ export class TextBlock extends TextBlockComponent {
|
|
|
280
421
|
toJSON() {
|
|
281
422
|
return {
|
|
282
423
|
...super.toJSON(),
|
|
424
|
+
styleId: this.styleId,
|
|
283
425
|
width: this.width,
|
|
284
426
|
justification: this.justification,
|
|
285
427
|
margins: this.margins,
|
|
@@ -290,9 +432,9 @@ export class TextBlock extends TextBlockComponent {
|
|
|
290
432
|
static create(props) {
|
|
291
433
|
return new TextBlock(props);
|
|
292
434
|
}
|
|
293
|
-
/** Create an empty text block containing no [[paragraphs]] and an empty [[
|
|
435
|
+
/** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */
|
|
294
436
|
static createEmpty() {
|
|
295
|
-
return TextBlock.create({
|
|
437
|
+
return TextBlock.create({ styleId: "" });
|
|
296
438
|
}
|
|
297
439
|
/** Returns true if every paragraph in this text block is empty. */
|
|
298
440
|
get isEmpty() {
|
|
@@ -301,13 +443,16 @@ export class TextBlock extends TextBlockComponent {
|
|
|
301
443
|
clone() {
|
|
302
444
|
return new TextBlock(this.toJSON());
|
|
303
445
|
}
|
|
304
|
-
/**
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Clears any [[styleOverrides]] applied to this TextBlock.
|
|
448
|
+
* Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.
|
|
449
|
+
*/
|
|
450
|
+
clearStyleOverrides(options) {
|
|
451
|
+
super.clearStyleOverrides();
|
|
452
|
+
if (options?.preserveChildrenOverrides)
|
|
453
|
+
return;
|
|
454
|
+
for (const paragraph of this.paragraphs) {
|
|
455
|
+
paragraph.clearStyleOverrides();
|
|
311
456
|
}
|
|
312
457
|
}
|
|
313
458
|
/** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */
|
|
@@ -315,14 +460,17 @@ export class TextBlock extends TextBlockComponent {
|
|
|
315
460
|
return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? " ");
|
|
316
461
|
}
|
|
317
462
|
/** Add and return a new paragraph.
|
|
318
|
-
*
|
|
319
|
-
* the paragraph will inherit
|
|
463
|
+
* By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.
|
|
464
|
+
* @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.
|
|
320
465
|
*/
|
|
321
|
-
appendParagraph() {
|
|
322
|
-
|
|
466
|
+
appendParagraph(seedFromLast = false) {
|
|
467
|
+
let styleOverrides = {};
|
|
468
|
+
if (seedFromLast && this.paragraphs.length > 0) {
|
|
469
|
+
const seed = this.paragraphs[this.paragraphs.length - 1];
|
|
470
|
+
styleOverrides = { ...seed.styleOverrides };
|
|
471
|
+
}
|
|
323
472
|
const paragraph = Paragraph.create({
|
|
324
|
-
|
|
325
|
-
styleOverrides: seed?.styleOverrides ?? undefined,
|
|
473
|
+
styleOverrides
|
|
326
474
|
});
|
|
327
475
|
this.paragraphs.push(paragraph);
|
|
328
476
|
return paragraph;
|
|
@@ -338,6 +486,9 @@ export class TextBlock extends TextBlockComponent {
|
|
|
338
486
|
if (!(other instanceof TextBlock)) {
|
|
339
487
|
return false;
|
|
340
488
|
}
|
|
489
|
+
if (this.styleId !== other.styleId || !super.equals(other)) {
|
|
490
|
+
return false;
|
|
491
|
+
}
|
|
341
492
|
if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {
|
|
342
493
|
return false;
|
|
343
494
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAgDH;;;GAGG;AACH,MAAM,OAAgB,kBAAkB;IAC9B,UAAU,CAAS;IACnB,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,YAAsB,KAA8B;QAClD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,EAAE,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAW,SAAS,CAAC,SAAiB;QACpC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAW,cAAc,CAAC,SAAiC;QACzD,IAAI,CAAC,eAAe,GAAG,EAAE,GAAG,SAAS,EAAE,CAAC;IAC1C,CAAC;IAED,8EAA8E;IACvE,mBAAmB;QACxB,IAAI,CAAC,cAAc,GAAG,EAAG,CAAC;IAC5B,CAAC;IAED,oKAAoK;IAC7J,UAAU,CAAC,SAAiB,EAAE,OAA+B;QAClE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAE5B,IAAI,CAAC,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE,CAAC;YAClC,IAAI,CAAC,mBAAmB,EAAE,CA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OAEG;IACI,SAAS,CAAC,GAAQ;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;QACxF,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEe,MAAM,CAAC,KAAyB;QAC9C,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACnI,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1E,KAAK,KAAM,KAAK,CAAC,OAAe,CAAC,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.applyStyle]] to control how the style is applied to the component and its child components.\n * @beta\n */\nexport interface ApplyTextStyleOptions {\n /** Controls whether any deviations from the style's settings stored in [[TextBlockComponent.styleOverrides]] are retained.\n * By default, all overrides are cleared.\n */\n preserveOverrides?: boolean;\n /** Controls whether the style should be recursively applied to the [[Paragraph]]s belonging to a [[TextBlock]] and the [[Run]]s belonging to a [[Paragraph]].\n * By default, the style change propagates to child components.\n */\n preventPropagation?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** The name of a [[TextStyle]] stored in a [Workspace]($backend) from which the base [[TextStyleSettings]] applied to the component originates. */\n styleName: string;\n /** Deviations from the base [[TextStyleSettings]] defined by the [[TextStyle]] applied to this component.\n * This permits you to, e.g., create a [[TextRun]] using \"Arial\" font and override it to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * Each component can specify a [[TextStyle]] that formats its contents and optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleName: string;\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props: TextBlockComponentProps) {\n this._styleName = props.styleName;\n this._styleOverrides = { ...props.styleOverrides };\n }\n\n /** The name of the [[TextStyle]] that provides the base formatting for the contents of this component.\n * @note Assigning to this property is equivalent to calling [[applyStyle]] with default [[ApplyTextStyleOptions]], which propagates the style change to all of\n * the components sub-components and clears any [[styleOverrides]].\n */\n public get styleName(): string {\n return this._styleName;\n }\n\n public set styleName(styleName: string) {\n this.applyStyle(styleName);\n }\n\n /** Deviations in individual properties of the [[TextStyle]] specified by [[styleName]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = { ...overrides };\n }\n\n /** Reset any [[styleOverrides]] applied to this component's [[TextStyle]]. */\n public clearStyleOverrides(): void {\n this.styleOverrides = { };\n }\n\n /** Apply the [[TextStyle]] specified by `styleName` to this component, optionally preserving [[styleOverrides]] and/or preventing propagation to sub-components. */\n public applyStyle(styleName: string, options?: ApplyTextStyleOptions): void {\n this._styleName = styleName;\n\n if (!(options?.preserveOverrides)) {\n this.clearStyleOverrides();\n }\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from this component's base [[TextStyle]]. */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleName: this.styleName,\n styleOverrides: { ...this.styleOverrides },\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (this.styleName !== other.styleName || myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/**\n * @beta\n */\nexport type Run = TextRun | FractionRun | LineBreakRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | LineBreakRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props.content ?? \"\";\n this.baselineShift = props.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyle.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyle.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props.numerator ?? \"\";\n this.denominator = props.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props: ParagraphProps) {\n super(props);\n this.runs = props.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /** Apply the specified style to this [[Paragraph]], and - unless [[ApplyTextStyleOptions.preventPropagation]] is `true` - to all of its [[runs]]. */\n public override applyStyle(styleName: string, options?: ApplyTextStyleOptions): void {\n super.applyStyle(styleName, options);\n if (!(options?.preventPropagation)) {\n for (const run of this.runs) {\n run.applyStyle(styleName, options);\n }\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleName]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleName: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /** Apply the specified style to this block and - unless [[ApplyTextStyleOptions.preventPropagation]] is `true` - to all of its [[paragraphs]]. */\n public override applyStyle(styleName: string, options?: ApplyTextStyleOptions): void {\n super.applyStyle(styleName, options);\n if (!(options?.preventPropagation)) {\n for (const paragraph of this.paragraphs) {\n paragraph.applyStyle(styleName, options);\n }\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * If [[paragraphs]] is not empty, the style and overrides of the last [[Paragraph]] in the block will be applied to the new paragraph; otherwise,\n * the paragraph will inherit this block's style with no overrides.\n */\n public appendParagraph(): Paragraph {\n const seed = this.paragraphs[0];\n const paragraph = Paragraph.create({\n styleName: seed?.styleName ?? this.styleName,\n styleOverrides: seed?.styleOverrides ?? undefined,\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[index]));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,iBAAiB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E,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { TextStyleSettings, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.clearStyleOverrides]] to control how the style overrides are cleared on the component and its child components.\n * @beta\n */\nexport interface ClearTextStyleOptions {\n /** Controls whether the styleOverrides of any child components are retained.\n * By default, all overrides are cleared.\n */\n preserveChildrenOverrides?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** Deviations from the base [[TextStyleSettings]] defined by the [AnnotationTextStyle]($backend) applied to this component.\n * This permits you to, e.g., create a [[TextBlock]] using \"Arial\" font and override one of its [[TextRun]]s to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n /** The number of spaces to use for tabs. If not provided, tabs will be represented by a tab character: \"\\t\".\n * Default: \"undefined\" - use \"\\t\".\n */\n tabsAsSpaces?: number;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props?: TextBlockComponentProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});\n }\n\n /** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(overrides);\n }\n\n /** Reset any [[styleOverrides]] applied to this component. */\n public clearStyleOverrides(_options?: ClearTextStyleOptions): void {\n this.styleOverrides = {};\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /**\n * Returns true if the string representation of this component consists only of whitespace characters.\n * Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.\n */\n public get isWhitespace(): boolean {\n return /^\\s*$/g.test(this.stringify());\n };\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/** [[TextBlockComponent]]s contained within a [[Paragraph]].\n * @beta\n */\nexport type Run = TextRun | FractionRun | TabRun | LineBreakRun | FieldRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps | FieldRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"tab\": return TabRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n case \"field\": return FieldRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props?: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props?.content ?? \"\";\n this.baselineShift = props?.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props?: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props?: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props?.numerator ?? \"\";\n this.denominator = props?.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props?: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props?: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props?: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[TabRun]].\n * @beta\n */\nexport interface TabRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"tab\";\n}\n\n/** A [[TabRun]] is used to shift the next tab stop.\n * @note Only left-justified tabs are supported at this tab.\n * @beta\n */\nexport class TabRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"tab\";\n\n public override toJSON(): TabRunProps {\n return {\n ...super.toJSON(),\n type: \"tab\",\n };\n }\n\n public override clone(): TabRun {\n return new TabRun(this.toJSON());\n }\n\n public static create(props?: Omit<TabRunProps, \"type\">): TabRun {\n return new TabRun(props);\n }\n\n /**\n * Converts a [[TabRun]] to its string representation.\n * If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.\n * Otherwise, returns a tab character (\"\\t\").\n */\n public override stringify(options?: TextBlockStringifyOptions): string {\n if (options?.tabsAsSpaces) {\n return \" \".repeat(options.tabsAsSpaces);\n }\n\n return \"\\t\";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TabRun && super.equals(other);\n }\n}\n\n/** A chain of property accesses that resolves to a primitive value that forms the basis of the displayed content\n * of a [[FieldRun]].\n * The simplest property paths consist of a [[propertyName]] and nothing else, where `propertyName` identifies\n * a primitive property.\n * If `propertyName` identifies a struct or array property, then additional [[accessors]] are required to identify the specific value.\n * If `propertyName` (including any [[accessors]]) resolves to a JSON property, then additional [[jsonAccessors]] are required to identify a specific value within the JSON.\n * Some examples:\n * ```\n * | Access String | propertyName | accessors | jsonAccessors |\n * | ------------- | ------------ | --------- | ------------- |\n * | name | \"name\" | undefined | undefined |\n * | spouse.name | \"spouse\" | [name] | undefined |\n * | colors[2] | \"colors\" | [2] | undefined |\n * | spouse.favoriteRestaurants[1].address | \"spouse\" | [\"favoriteRestaurants\", 1, \"address\"] | undefined |\n * | jsonProperties.contactInfo.email | \"jsonProperties\" | undefined | [\"contactInfo\", \"email\"] |\n * | spouse.jsonProperties.contactInfo.phoneNumbers[0].areaCode | \"spouse\" | [\"jsonProperties\"] | [\"contactInfo\", \"phoneNumbers\", 0, \"areaCode\"] |\n * ```\n * @beta\n */\nexport interface FieldPropertyPath {\n /** The name of the BIS property of the [[FieldPropertyHost]] that serves as the root of the path. */\n propertyName: string;\n /** Property names and/or array indices describing the path from [[propertyName]] to the ultimate BIS property. */\n accessors?: Array<string | number>;\n /** If [[propertyName]] and [[accessors]] (if defined) resolve to a BIS property of extended type `Json`, property names and/or\n * array indices for selecting a primitive value within the JSON.\n */\n jsonAccessors?: Array<string | number>;\n}\n\n/** Describes the source of the property value against which a [[FieldPropertyPath]] is evaluated.\n * A field property is always hosted by an [Element]($backend). It may be a property of the element's BIS class itself,\n * or that of one of its [ElementAspect]($backend)s.\n * The [[schemaName]] and [[className]] should always identify the exact class that contains [[FieldPropertyPath.propertyName]] - not a subclass thereof.\n * @beta\n */\nexport interface FieldPropertyHost {\n /** The Id of the [Element]($backend) that hosts the property. */\n elementId: Id64String;\n /** The name of the schema containing the class identified by [[className]]. */\n schemaName: string;\n /** The name of the exact class (not a subclass) containing the property identified by [[FieldPropertyPath.propertyName]]. */\n className: string;\n}\n\n/** Placeholder type for a description of how to format the raw property value resolved by a [[FieldPropertyPath]] into a [[FieldRun]]'s display string.\n * *** COMING SOON ***\n * @beta\n */\nexport interface FieldFormatter { [k: string]: any }\n\n/** JSON representation of a [[FieldRun]].\n * @beta\n */\nexport interface FieldRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n propertyHost: FieldPropertyHost;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n propertyPath: FieldPropertyPath;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n formatter?: FieldFormatter;\n /** The field's most recently evaluated display string. */\n cachedContent?: string;\n}\n\n/** A [[Run]] that displays the formatted value of a property of some [Element]($backend).\n * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,\n * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that\n * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically\n * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or\n * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].\n * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.\n * @beta\n */\nexport class FieldRun extends TextBlockComponent {\n /** Display string used to signal an error in computing the field's value. */\n public static invalidContentIndicator = \"####\";\n\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n public readonly propertyHost: Readonly<FieldPropertyHost>;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n public readonly propertyPath: Readonly<FieldPropertyPath>;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n public readonly formatter?: FieldFormatter;\n private _cachedContent: string;\n\n /** The field's most recently evaluated display string. */\n public get cachedContent(): string {\n return this._cachedContent;\n }\n\n /** @internal Used by core-backend when re-evaluating field content. */\n public setCachedContent(content: string | undefined): void {\n this._cachedContent = content ?? FieldRun.invalidContentIndicator;\n }\n\n private constructor(props: Omit<FieldRunProps, \"type\">) {\n super(props);\n\n this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;\n this.propertyHost = props.propertyHost\n this.propertyPath = props.propertyPath;\n this.formatter = props.formatter;\n }\n\n /** Create a FieldRun from its JSON representation. */\n public static create(props: Omit<FieldRunProps, \"type\">): FieldRun {\n return new FieldRun({\n ...props,\n propertyHost: { ...props.propertyHost },\n propertyPath: structuredClone(props.propertyPath),\n formatter: structuredClone(props.formatter),\n });\n }\n\n /** Convert the FieldRun to its JSON representation. */\n public override toJSON(): FieldRunProps {\n const json: FieldRunProps = {\n ...super.toJSON(),\n type: \"field\",\n propertyHost: { ...this.propertyHost },\n propertyPath: structuredClone(this.propertyPath),\n };\n\n if (this.cachedContent !== FieldRun.invalidContentIndicator) {\n json.cachedContent = this.cachedContent;\n }\n\n if (this.formatter) {\n json.formatter = structuredClone(this.formatter);\n }\n\n return json;\n }\n\n /** Create a deep copy of this FieldRun. */\n public override clone(): FieldRun {\n return new FieldRun(this.toJSON());\n }\n\n /** Convert this FieldRun to a simple string representation. */\n public override stringify(): string {\n return this.cachedContent;\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof FieldRun) || !super.equals(other)) {\n return false;\n }\n\n if (\n this.propertyHost.elementId !== other.propertyHost.elementId ||\n this.propertyHost.className !== other.propertyHost.className ||\n this.propertyHost.schemaName !== other.propertyHost.schemaName\n ) {\n return false;\n }\n\n if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {\n return false;\n }\n\n const thisAccessors = this.propertyPath.accessors ?? [];\n const otherAccessors = other.propertyPath.accessors ?? [];\n const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];\n const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];\n\n if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {\n return false;\n }\n\n if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {\n return false;\n }\n\n if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {\n return false;\n }\n\n if (this.formatter && other.formatter) {\n // ###TODO better comparison of formatter objects.\n if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {\n return false;\n }\n } else if (this.formatter || other.formatter) {\n return false;\n }\n\n return true;\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props?: ParagraphProps) {\n super(props);\n this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props?: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this Paragraph.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const run of this.runs) {\n run.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The ID of an [AnnotationTextStyle]($backend) stored in the iModel from which the base [[TextStyleSettings]] applied to the [[TextBlock]] originates. */\n styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.\n * @note Assigning to this property retains all style overrides on the TextBlock and its child components.\n * Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.\n */\n public styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.styleId = props.styleId;\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n styleId: this.styleId,\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleId: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this TextBlock.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const paragraph of this.paragraphs) {\n paragraph.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.\n * @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.\n */\n public appendParagraph(seedFromLast: boolean = false): Paragraph {\n let styleOverrides: TextStyleSettingsProps = {};\n\n if (seedFromLast && this.paragraphs.length > 0) {\n const seed = this.paragraphs[this.paragraphs.length - 1];\n styleOverrides = { ...seed.styleOverrides };\n }\n\n const paragraph = Paragraph.create({\n styleOverrides\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.styleId !== other.styleId || !super.equals(other)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[index]));\n }\n}\n"]}
|
|
@@ -29,7 +29,7 @@ export type TextBlockGeometryPropsEntry = {
|
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* JSON representation of the geometric primitives that can be used to display a [[TextBlock]].
|
|
32
|
-
* @see [
|
|
32
|
+
* @see [appendTextAnnotationGeometry]($backend) to convert an annotation to its geometric representation.
|
|
33
33
|
* @see [[GeometryStreamBuilder.appendTextBlock]] to add a block of text to a [GeometryStream]($docs/learning/common/GeometryStream.md).
|
|
34
34
|
* @beta
|
|
35
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockGeometryProps.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockGeometryProps.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { XYZProps } from \"@itwin/core-geometry\";\nimport { TextStringProps } from \"../geometry/TextString\";\nimport { TextStyleColor } from \"./TextStyle\";\n\n/**\n * A single entry in a [[TextBlockGeometryProps]], representing one of the following primitive types:\n * - A [[TextString]],\n * - A fraction separator described by a [LineSegment3d]($geometry), or\n * - A change in color, to be applied to all subsequent primitives.\n * @beta\n */\nexport type TextBlockGeometryPropsEntry = {\n text: TextStringProps;\n separator?: never;\n color?: never;\n} | {\n text?: never;\n separator: {\n startPoint: XYZProps;\n endPoint: XYZProps;\n };\n color?: never;\n} | {\n text?: never;\n separator?: never;\n color: TextStyleColor;\n};\n\n/**\n * JSON representation of the geometric primitives that can be used to display a [[TextBlock]].\n * @see [
|
|
1
|
+
{"version":3,"file":"TextBlockGeometryProps.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockGeometryProps.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { XYZProps } from \"@itwin/core-geometry\";\nimport { TextStringProps } from \"../geometry/TextString\";\nimport { TextStyleColor } from \"./TextStyle\";\n\n/**\n * A single entry in a [[TextBlockGeometryProps]], representing one of the following primitive types:\n * - A [[TextString]],\n * - A fraction separator described by a [LineSegment3d]($geometry), or\n * - A change in color, to be applied to all subsequent primitives.\n * @beta\n */\nexport type TextBlockGeometryPropsEntry = {\n text: TextStringProps;\n separator?: never;\n color?: never;\n} | {\n text?: never;\n separator: {\n startPoint: XYZProps;\n endPoint: XYZProps;\n };\n color?: never;\n} | {\n text?: never;\n separator?: never;\n color: TextStyleColor;\n};\n\n/**\n * JSON representation of the geometric primitives that can be used to display a [[TextBlock]].\n * @see [appendTextAnnotationGeometry]($backend) to convert an annotation to its geometric representation.\n * @see [[GeometryStreamBuilder.appendTextBlock]] to add a block of text to a [GeometryStream]($docs/learning/common/GeometryStream.md).\n * @beta\n */\nexport interface TextBlockGeometryProps {\n /** The set of geometric primitives representing the contents of the [[TextBlock]]. */\n entries: TextBlockGeometryPropsEntry[];\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export interface RunLayoutResult {
|
|
|
25
25
|
offsetFromLine: XAndY;
|
|
26
26
|
/** Bounding box enclosing this RunLayoutResult's content. */
|
|
27
27
|
range: Range2dProps;
|
|
28
|
-
/** The [[TextStyleSettings]] for the run. */
|
|
28
|
+
/** The resolved [[TextStyleSettings]] for the run. Takes into account overrides and styles on the parent classes. */
|
|
29
29
|
textStyle: TextStyleSettingsProps;
|
|
30
30
|
/** Bounding box used when justifying the run. This may be smaller than [[range]]. */
|
|
31
31
|
justificationRange?: Range2dProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockLayoutResult.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf;;;MAGE;IACF,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,cAAc,EAAE,KAAK,CAAC;IACtB,6DAA6D;IAC7D,KAAK,EAAE,YAAY,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"TextBlockLayoutResult.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf;;;MAGE;IACF,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,0FAA0F;IAC1F,cAAc,EAAE,KAAK,CAAC;IACtB,6DAA6D;IAC7D,KAAK,EAAE,YAAY,CAAC;IACpB,qHAAqH;IACrH,SAAS,EAAE,sBAAsB,CAAC;IAClC,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,YAAY,CAAC;IAClC,4EAA4E;IAC5E,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,YAAY,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,uGAAuG;IACvG,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sCAAsC;IACtC,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,qDAAqD;IACrD,KAAK,EAAE,YAAY,CAAC;IACpB,sFAAsF;IACtF,kBAAkB,EAAE,YAAY,CAAC;IACjC,yEAAyE;IACzE,kBAAkB,EAAE,KAAK,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,6CAA6C;IAC7C,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,4DAA4D;IAC5D,KAAK,EAAE,YAAY,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockLayoutResult.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Range2dProps, XAndY } from \"@itwin/core-geometry\";\nimport { FontId } from \"../Fonts\";\nimport { TextStyleSettingsProps } from \"./TextStyle\";\n\n/**\n * Represents a single run in a [[LineLayoutResult]].\n * @note Get the text content of the RunLayoutResult using a combination of the `sourceRunIndex`, `characterOffset`, and `characterCount`.\n * @beta\n */\nexport interface RunLayoutResult {\n /** The index of the Run this RunLayoutResult was generated from in [[Paragraph.runs]]. */\n sourceRunIndex: number;\n /** The ID of the font for the run. */\n fontId: FontId;\n /**\n * The number of characters from the source [[Run]] that have already appeared in the layout.\n * @note A single source [[TextRun]] can be split into multiple lines to respect the [[TextBlock.width]].\n */\n characterOffset: number;\n /** The number of characters in the RunLayoutResult. */\n characterCount: number;\n /** The offset of the RunLayoutResult from the top and left of the [[LineLayoutResult]] */\n offsetFromLine: XAndY;\n /** Bounding box enclosing this RunLayoutResult's content. */\n range: Range2dProps;\n /** The [[TextStyleSettings]] for the run. */\n textStyle: TextStyleSettingsProps;\n /** Bounding box used when justifying the run. This may be smaller than [[range]]. */\n justificationRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s numerator. */\n numeratorRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s denominator. */\n denominatorRange?: Range2dProps;\n}\n\n/**\n * Represents a single line in a [[TextBlockLayoutResult]].\n * @beta\n */\nexport interface LineLayoutResult {\n /** The index of the paragraph this LineLayoutResult was generated from in [[TextBlock.paragraphs]]. */\n sourceParagraphIndex: number;\n /** The runs contained in the line. */\n runs: RunLayoutResult[];\n /** The range containing the contents of the line. */\n range: Range2dProps;\n /** Bounding box used when justifying the line. This may be smaller than [[range]]. */\n justificationRange: Range2dProps;\n /** The offset of the line from the top and left of the [[TextBlock]]. */\n offsetFromDocument: XAndY;\n}\n\n/**\n * Represents the result of laying out a [[TextBlock]]'s contents into a series of lines containing runs.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n * @beta\n */\nexport interface TextBlockLayoutResult {\n /** The laid out lines of a [[TextBlock]]. */\n lines: LineLayoutResult[];\n /** The range containing the contents of a [[TextBlock]]. */\n range: Range2dProps;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TextBlockLayoutResult.js","sourceRoot":"","sources":["../../../src/annotation/TextBlockLayoutResult.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Range2dProps, XAndY } from \"@itwin/core-geometry\";\nimport { FontId } from \"../Fonts\";\nimport { TextStyleSettingsProps } from \"./TextStyle\";\n\n/**\n * Represents a single run in a [[LineLayoutResult]].\n * @note Get the text content of the RunLayoutResult using a combination of the `sourceRunIndex`, `characterOffset`, and `characterCount`.\n * @beta\n */\nexport interface RunLayoutResult {\n /** The index of the Run this RunLayoutResult was generated from in [[Paragraph.runs]]. */\n sourceRunIndex: number;\n /** The ID of the font for the run. */\n fontId: FontId;\n /**\n * The number of characters from the source [[Run]] that have already appeared in the layout.\n * @note A single source [[TextRun]] can be split into multiple lines to respect the [[TextBlock.width]].\n */\n characterOffset: number;\n /** The number of characters in the RunLayoutResult. */\n characterCount: number;\n /** The offset of the RunLayoutResult from the top and left of the [[LineLayoutResult]] */\n offsetFromLine: XAndY;\n /** Bounding box enclosing this RunLayoutResult's content. */\n range: Range2dProps;\n /** The resolved [[TextStyleSettings]] for the run. Takes into account overrides and styles on the parent classes. */\n textStyle: TextStyleSettingsProps;\n /** Bounding box used when justifying the run. This may be smaller than [[range]]. */\n justificationRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s numerator. */\n numeratorRange?: Range2dProps;\n /** The range containing the contents of the [[FractionRun]]'s denominator. */\n denominatorRange?: Range2dProps;\n}\n\n/**\n * Represents a single line in a [[TextBlockLayoutResult]].\n * @beta\n */\nexport interface LineLayoutResult {\n /** The index of the paragraph this LineLayoutResult was generated from in [[TextBlock.paragraphs]]. */\n sourceParagraphIndex: number;\n /** The runs contained in the line. */\n runs: RunLayoutResult[];\n /** The range containing the contents of the line. */\n range: Range2dProps;\n /** Bounding box used when justifying the line. This may be smaller than [[range]]. */\n justificationRange: Range2dProps;\n /** The offset of the line from the top and left of the [[TextBlock]]. */\n offsetFromDocument: XAndY;\n}\n\n/**\n * Represents the result of laying out a [[TextBlock]]'s contents into a series of lines containing runs.\n * @see [computeLayoutTextBlockResult]($backend) to lay out a `TextBlock`.\n * @beta\n */\nexport interface TextBlockLayoutResult {\n /** The laid out lines of a [[TextBlock]]. */\n lines: LineLayoutResult[];\n /** The range containing the contents of a [[TextBlock]]. */\n range: Range2dProps;\n}\n"]}
|