@itwin/core-backend 5.4.0-dev.4 → 5.4.0-dev.5

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.
Files changed (25) hide show
  1. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
  2. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  3. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +32 -19
  4. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  5. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  6. package/lib/cjs/annotations/TextBlockLayout.js +2 -1
  7. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  8. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  9. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  10. package/lib/cjs/internal/annotations/fields.js +12 -5
  11. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  12. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
  13. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  14. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -20
  15. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  16. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  17. package/lib/esm/annotations/TextBlockLayout.js +2 -1
  18. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  19. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  20. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  21. package/lib/esm/internal/annotations/fields.js +11 -5
  22. package/lib/esm/internal/annotations/fields.js.map +1 -1
  23. package/lib/esm/test/annotations/TextAnnotation.test.js +3 -1
  24. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  25. package/package.json +12 -12
@@ -36,6 +36,15 @@ export interface ITextAnnotation {
36
36
  * @beta
37
37
  */
38
38
  export declare function isITextAnnotation(element: Element): element is ITextAnnotation & Element;
39
+ /** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].
40
+ * @beta
41
+ */
42
+ export interface EvaluateFieldsArgs {
43
+ /** The text block whose fields are to be evaluated. */
44
+ block: TextBlock;
45
+ /** The iModel containing the elements supplying the display strings for the fields in [[block]]. */
46
+ iModel: IModelDb;
47
+ }
39
48
  /** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.
40
49
  * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.
41
50
  * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to
@@ -60,6 +69,11 @@ export declare class ElementDrivesTextAnnotation extends ElementDrivesElement {
60
69
  * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
61
70
  */
62
71
  static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void;
72
+ /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
73
+ * @returns the number of fields whose display strings were modified.
74
+ * @throws Error if evaluation of any field fails.
75
+ */
76
+ static evaluateFields(args: EvaluateFieldsArgs): number;
63
77
  /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
64
78
  * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
65
79
  * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
@@ -1 +1 @@
1
- {"version":3,"file":"ElementDrivesTextAnnotation.d.ts","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAA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4B,SAAQ,oBAAoB;IACnE,WAA2B,SAAS,IAAI,MAAM,CAA0C;IAExF,gBAAgB;WACO,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAItF,gBAAgB;WACO,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAI5F;;;OAGG;WACW,oBAAoB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO;IAI7D;;;OAGG;WACW,uBAAuB,CAAC,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI;IAqE9F;;;OAGG;WACW,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,MAAM;IAI9D;;;OAGG;WACW,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,yBAAyB,GAAG,IAAI;CAwB5F;AAED;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,cAAc;IACtE,OAAc,aAAa,SAAkD;gBAC1D,qBAAqB,EAAE,UAAU,EAAE,YAAY,GAAE,MAA2D;CAGhI"}
@@ -45,17 +45,13 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
45
45
  * update when the source element changes.
46
46
  */
47
47
  static isSupportedForIModel(iModel) {
48
- const bisCoreVersion = iModel.querySchemaVersionNumbers("BisCore");
49
- return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;
48
+ return iModel.meetsMinimumSchemaVersion("BisCore", minBisCoreVersion);
50
49
  }
51
50
  /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate
52
51
  * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.
53
52
  * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.
54
53
  */
55
54
  static updateFieldDependencies(annotationElementId, iModel) {
56
- if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {
57
- return;
58
- }
59
55
  const annotationElement = iModel.elements.tryGetElement(annotationElementId);
60
56
  if (!annotationElement || !isITextAnnotation(annotationElement)) {
61
57
  return;
@@ -73,27 +69,37 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
73
69
  }
74
70
  const sourceToRelationship = new Map();
75
71
  const blocks = annotationElement.getTextBlocks();
72
+ let haveFields = false;
76
73
  for (const block of blocks) {
77
74
  for (const { child } of (0, core_common_1.traverseTextBlockComponent)(block.textBlock)) {
78
- if (child.type === "field" && isValidSourceId(child.propertyHost.elementId)) {
79
- sourceToRelationship.set(child.propertyHost.elementId, null);
75
+ if (child.type === "field") {
76
+ haveFields = true;
77
+ if (isValidSourceId(child.propertyHost.elementId)) {
78
+ sourceToRelationship.set(child.propertyHost.elementId, null);
79
+ }
80
80
  }
81
81
  }
82
82
  }
83
+ if (haveFields) {
84
+ iModel.requireMinimumSchemaVersion("BisCore", minBisCoreVersion, "Text fields");
85
+ (0, fields_1.updateAllFields)(annotationElementId, iModel);
86
+ }
83
87
  const staleRelationships = new Set();
84
- // eslint-disable-next-line @typescript-eslint/no-deprecated
85
- annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {
86
- while (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step()) {
87
- const relationshipId = stmt.getValue(0).getId();
88
- const sourceId = stmt.getValue(1).getId();
89
- if (sourceToRelationship.has(sourceId)) {
90
- sourceToRelationship.set(sourceId, relationshipId);
91
- }
92
- else {
93
- staleRelationships.add(relationshipId);
88
+ if (this.isSupportedForIModel(iModel)) {
89
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
90
+ annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {
91
+ while (core_bentley_1.DbResult.BE_SQLITE_ROW === stmt.step()) {
92
+ const relationshipId = stmt.getValue(0).getId();
93
+ const sourceId = stmt.getValue(1).getId();
94
+ if (sourceToRelationship.has(sourceId)) {
95
+ sourceToRelationship.set(sourceId, relationshipId);
96
+ }
97
+ else {
98
+ staleRelationships.add(relationshipId);
99
+ }
94
100
  }
95
- }
96
- });
101
+ });
102
+ }
97
103
  for (const [sourceId, relationshipId] of sourceToRelationship) {
98
104
  if (relationshipId === null) {
99
105
  ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();
@@ -104,6 +110,13 @@ class ElementDrivesTextAnnotation extends Relationship_1.ElementDrivesElement {
104
110
  annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);
105
111
  }
106
112
  }
113
+ /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).
114
+ * @returns the number of fields whose display strings were modified.
115
+ * @throws Error if evaluation of any field fails.
116
+ */
117
+ static evaluateFields(args) {
118
+ return (0, fields_1.updateFields)(args.block, (0, fields_1.createUpdateContext)(undefined, args.iModel, false));
119
+ }
107
120
  /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element
108
121
  * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).
109
122
  * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].
@@ -1 +1 @@
1
- {"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4CH,8CAEC;AA5CD,oDAA8G;AAC9G,kDAAuD;AAGvD,2DAAqE;AACrE,sDAAiE;AACjE,gEAAqD;AAgBrD,2IAA2I;AAC3I,MAAM,iBAAiB,GAAG,IAAI,6BAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAgBlD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OA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wCAA0B,EAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACpE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;oBAC3B,KAAK,CAAC,YAAY,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;oBACzF,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AApHD,kEAoHC;AAED;;GAEG;AACH,MAAa,oCAAqC,SAAQ,4BAAc;IAC/D,MAAM,CAAC,aAAa,GAAG,8CAA8C,CAAC;IAC7E,YAAmB,qBAAiC,EAAE,eAAuB,oCAAoC,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;;AAJH,oFAKC","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 Elements\n */\n\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\nimport { ElementDrivesElement } from \"../Relationship\";\nimport { IModelDb } from \"../IModelDb\";\nimport { Element } from \"../Element\";\nimport { updateElementFields } from \"../internal/annotations/fields\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\n\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\n * host one text block for each cell in the table, in which case it might use the combination of row and column\n * as the [[id]] for each text block.\n * @beta\n */\nexport interface TextBlockAndId {\n /** The text block. */\n readonly textBlock: TextBlock;\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\n readonly id: unknown;\n}\n\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\n\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\n * the type of element to which it belongs.\n * @beta\n */\nexport interface ITextAnnotation {\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\n getTextBlocks(): Iterable<TextBlockAndId>;\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\n}\n\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\n * @beta\n */\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\n}\n\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\n * @beta\n */\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\n\n /** @internal */\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, false);\n }\n\n /** @internal */\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, true);\n }\n\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\n * update when the source element changes.\n */\n public static isSupportedForIModel(iModel: IModelDb): boolean {\n const bisCoreVersion = iModel.querySchemaVersionNumbers(\"BisCore\");\n return undefined !== bisCoreVersion && bisCoreVersion.compare(minBisCoreVersion) >= 0;\n }\n\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\n */\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\n if (!ElementDrivesTextAnnotation.isSupportedForIModel(iModel)) {\n return;\n }\n\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\n return;\n }\n\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\n function isValidSourceId(id: Id64String): boolean {\n if (!Id64.isValidId64(id)) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\n stmt.bindId(1, id);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\n const blocks = annotationElement.getTextBlocks();\n\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\" && isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n\n const staleRelationships = new Set<Id64String>();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const relationshipId = stmt.getValue(0).getId();\n const sourceId = stmt.getValue(1).getId();\n if (sourceToRelationship.has(sourceId)) {\n sourceToRelationship.set(sourceId, relationshipId);\n } else {\n staleRelationships.add(relationshipId);\n }\n }\n });\n\n for (const [sourceId, relationshipId] of sourceToRelationship) {\n if (relationshipId === null) {\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\n }\n }\n\n if (staleRelationships.size > 0) {\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\n );\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\n }\n }\n\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\n */\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\n if (!context.isBetweenIModels) {\n return;\n }\n\n const updatedBlocks = [];\n for (const block of clone.getTextBlocks()) {\n let anyUpdated = false;\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\n anyUpdated = true;\n }\n }\n\n if (anyUpdated) {\n updatedBlocks.push(block);\n }\n }\n\n if (updatedBlocks.length > 0) {\n clone.updateTextBlocks(updatedBlocks);\n }\n }\n}\n\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\n * @beta\n */\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\n super({ id: annotationTextStyleId, relClassName });\n }\n}\n"]}
1
+ {"version":3,"file":"ElementDrivesTextAnnotation.js","sourceRoot":"","sources":["../../../src/annotations/ElementDrivesTextAnnotation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA4CH,8CAEC;AA5CD,oDAA8G;AAC9G,kDAAuD;AAGvD,2DAAyH;AACzH,sDAAiE;AACjE,gEAAqD;AAgBrD,2IAA2I;AAC3I,MAAM,iBAAiB,GAAG,IAAI,6BAAS,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAgBlD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,OAAO,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,IAAI,OAAQ,OAAe,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC;AACvH,CAAC;AAYD;;;;;;;GAOG;AACH,MAAa,2BAA4B,SAAQ,mCAAoB;IAC5D,MAAM,KAAc,SAAS,KAAa,OAAO,6BAA6B,CAAC,CAAC,CAAC;IAExF,gBAAgB;IACT,MAAM,CAAU,aAAa,CAAC,KAAwB,EAAE,MAAgB;QAC7E,IAAA,4BAAmB,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAU,mBAAmB,CAAC,KAAwB,EAAE,MAAgB;QACnF,IAAA,4BAAmB,EAAC,KAAK,EAAE,MAAM,EAAE,IAA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AC,CAAC;oBACzF,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;YAED,IAAI,UAAU,EAAE,CAAC;gBACf,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;CACF;AAlID,kEAkIC;AAED;;GAEG;AACH,MAAa,oCAAqC,SAAQ,4BAAc;IAC/D,MAAM,CAAC,aAAa,GAAG,8CAA8C,CAAC;IAC7E,YAAmB,qBAAiC,EAAE,eAAuB,oCAAoC,CAAC,aAAa;QAC7H,KAAK,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;;AAJH,oFAKC","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 Elements\n */\n\nimport { RelatedElement, RelationshipProps, TextBlock, traverseTextBlockComponent } from \"@itwin/core-common\";\nimport { ElementDrivesElement } from \"../Relationship\";\nimport { IModelDb } from \"../IModelDb\";\nimport { Element } from \"../Element\";\nimport { createUpdateContext, updateAllFields, updateElementFields, updateFields } from \"../internal/annotations/fields\";\nimport { DbResult, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { ECVersion } from \"@itwin/ecschema-metadata\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\n\n/** Describes one of potentially many [TextBlock]($common)s hosted by an [[ITextAnnotation]].\n * For example, a [[TextAnnotation2d]] hosts only a single text block, but an element representing a table may\n * host one text block for each cell in the table, in which case it might use the combination of row and column\n * as the [[id]] for each text block.\n * @beta\n */\nexport interface TextBlockAndId {\n /** The text block. */\n readonly textBlock: TextBlock;\n /** An opaque identifier that allows the [[ITextAnnotation]] to discern which of its hosted text blocks is being referred to. */\n readonly id: unknown;\n}\n\n// ElementDrivesTextAnnotation was introduced in this version of BisCore - iModels with earlier versions cannot support field dependencies.\nconst minBisCoreVersion = new ECVersion(1, 0, 22);\n\n/** Interface implemented by [[GeometricElement]] subclasses whose schemas declare them to implement the mix-in `BisCore:ITextAnnotation`.\n * Such elements may host any number of [TextBlock]($common)s. `ITextAnnotation` provides a uniform way to interact with text regardless of\n * the type of element to which it belongs.\n * @beta\n */\nexport interface ITextAnnotation {\n /** The default [[AnnotationTextStyle]] used by the text annotation. */\n defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** Obtain a collection of all of the [TextBlock]($common)s hosted by this element. */\n getTextBlocks(): Iterable<TextBlockAndId>;\n /** Update the element in-memory to replace the contents of the specified [TextBlock]($common)s. */\n updateTextBlocks(textBlocks: TextBlockAndId[]): void;\n}\n\n/** Returns `true` if the specified `element` implements [[ITextAnnotation]].\n * @beta\n */\nexport function isITextAnnotation(element: Element): element is ITextAnnotation & Element {\n return [\"getTextBlocks\", \"updateTextBlocks\"].every((x) => x in element && typeof (element as any)[x] === \"function\");\n}\n\n/** Arguments supplied to [[ElementDrivesTextAnnotation.evaluateFields]].\n * @beta\n */\nexport interface EvaluateFieldsArgs {\n /** The text block whose fields are to be evaluated. */\n block: TextBlock;\n /** The iModel containing the elements supplying the display strings for the fields in [[block]]. */\n iModel: IModelDb;\n}\n\n/** A relationship in which the source element hosts one or more properties that are displayed by a target [[ITextAnnotation]] element.\n * This relationship is used to automatically update the [FieldRun]($common)s contained in the target element when the source element is modified.\n * An [[ITextAnnotation]] element should invoke [[updateFieldDependencies]] from its [[Element.onInserted]] and [[Element.onUpdated]] functions to\n * establish or update the relationships required for the [FieldRun]($common)s it contains.\n * @note This relationship was introduced in version 01.00.22 of the BisCore schema. [FieldRun]($common)s created in iModels that have not been upgraded to\n * that version or newer will not automatically update. Use [[isSupportedForIModel]] to check.\n * @beta\n */\nexport class ElementDrivesTextAnnotation extends ElementDrivesElement {\n public static override get className(): string { return \"ElementDrivesTextAnnotation\"; }\n\n /** @internal */\n public static override onRootChanged(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, false);\n }\n\n /** @internal */\n public static override onDeletedDependency(props: RelationshipProps, iModel: IModelDb): void {\n updateElementFields(props, iModel, true);\n }\n\n /** Returns true if `iModel` contains a version of the BisCore schema new enough to support this relationship.\n * If not, the schema should be updated before inserting any [FieldRun]($common)s, or those runs will not\n * update when the source element changes.\n */\n public static isSupportedForIModel(iModel: IModelDb): boolean {\n return iModel.meetsMinimumSchemaVersion(\"BisCore\", minBisCoreVersion);\n }\n\n /** Examines all of the [FieldRun]($common)s within the specified [[ITextAnnotation]] and ensures that the appropriate\n * `ElementDrivesTextAnnotation` relationships exist between the fields' source elements and this target element.\n * It also deletes any stale relationships left over from fields that were deleted or whose source elements changed.\n */\n public static updateFieldDependencies(annotationElementId: Id64String, iModel: IModelDb): void {\n const annotationElement = iModel.elements.tryGetElement<Element>(annotationElementId);\n if (!annotationElement || !isITextAnnotation(annotationElement)) {\n return;\n }\n\n // The native layer will allow us to insert relationships to invalid or non-existent source elements...errors will arise later. Prevent it.\n function isValidSourceId(id: Id64String): boolean {\n if (!Id64.isValidId64(id)) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return iModel.withPreparedStatement(\"SELECT CodeValue FROM BisCore.Element WHERE ECInstanceId=?\", (stmt) => {\n stmt.bindId(1, id);\n return DbResult.BE_SQLITE_ROW === stmt.step();\n });\n }\n\n const sourceToRelationship = new Map<Id64String, Id64String | null>();\n const blocks = annotationElement.getTextBlocks();\n\n let haveFields = false;\n for (const block of blocks) {\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n haveFields = true;\n if (isValidSourceId(child.propertyHost.elementId)) {\n sourceToRelationship.set(child.propertyHost.elementId, null);\n }\n }\n }\n }\n\n if (haveFields) {\n iModel.requireMinimumSchemaVersion(\"BisCore\", minBisCoreVersion, \"Text fields\");\n updateAllFields(annotationElementId, iModel)\n }\n\n const staleRelationships = new Set<Id64String>();\n if (this.isSupportedForIModel(iModel)) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n annotationElement.iModel.withPreparedStatement(`SELECT ECInstanceId, SourceECInstanceId FROM BisCore.ElementDrivesTextAnnotation WHERE TargetECInstanceId=${annotationElement.id}`, (stmt) => {\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const relationshipId = stmt.getValue(0).getId();\n const sourceId = stmt.getValue(1).getId();\n if (sourceToRelationship.has(sourceId)) {\n sourceToRelationship.set(sourceId, relationshipId);\n } else {\n staleRelationships.add(relationshipId);\n }\n }\n });\n }\n\n for (const [sourceId, relationshipId] of sourceToRelationship) {\n if (relationshipId === null) {\n ElementDrivesTextAnnotation.create(annotationElement.iModel, sourceId, annotationElement.id).insert();\n }\n }\n\n if (staleRelationships.size > 0) {\n const staleRelationshipProps = Array.from(staleRelationships).map(relationshipId =>\n annotationElement.iModel.relationships.getInstanceProps(\"BisCore.ElementDrivesTextAnnotation\", relationshipId)\n );\n annotationElement.iModel.relationships.deleteInstances(staleRelationshipProps);\n }\n }\n\n /** Recompute the display strings of all [FieldRun]($common)s in a [TextBlock]($common).\n * @returns the number of fields whose display strings were modified.\n * @throws Error if evaluation of any field fails.\n */\n public static evaluateFields(args: EvaluateFieldsArgs): number {\n return updateFields(args.block, createUpdateContext(undefined, args.iModel, false))\n }\n\n /** When copying an [[ITextAnnotation]] from one iModel into another, remaps the element Ids in any [FieldPropertyHost]($common) within the cloned element\n * so that they refer to elements in the `context`'s target iModel, and sets any Ids that cannot be remapped to [Id64.invalid]($bentley).\n * Implementations of `ITextAnnotation` should invoke this function from their implementations of [[Element.onCloned]].\n */\n public static remapFields(clone: ITextAnnotation, context: IModelElementCloneContext): void {\n if (!context.isBetweenIModels) {\n return;\n }\n\n const updatedBlocks = [];\n for (const block of clone.getTextBlocks()) {\n let anyUpdated = false;\n for (const { child } of traverseTextBlockComponent(block.textBlock)) {\n if (child.type === \"field\") {\n child.propertyHost.elementId = context.findTargetElementId(child.propertyHost.elementId);\n anyUpdated = true;\n }\n }\n\n if (anyUpdated) {\n updatedBlocks.push(block);\n }\n }\n\n if (updatedBlocks.length > 0) {\n clone.updateTextBlocks(updatedBlocks);\n }\n }\n}\n\n/** Relationship indicating that the [[AnnotationTextStyle]] is being used as the default style for the [[ITextAnnotation]].\n * @beta\n */\nexport class TextAnnotationUsesTextStyleByDefault extends RelatedElement {\n public static classFullName = \"BisCore:TextAnnotationUsesTextStyleByDefault\";\n public constructor(annotationTextStyleId: Id64String, relClassName: string = TextAnnotationUsesTextStyleByDefault.classFullName) {\n super({ id: annotationTextStyleId, relClassName });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlockLayout.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAiB,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAgC,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,qBAAqB,EAAoB,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACtU,OAAO,EAAY,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAU,UAAU,EAA2B,MAAM,qBAAqB,CAAC;AAKlF,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,E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,GAAG,SAAS,CAAyB;IACnE,IAAW,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAA2B;IAElE,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAKnC,6CAA6C;IAC7C,OAAO,CAAC,aAAa;IAyEd,QAAQ,IAAI,gBAAgB;CASpC;AAED;;;;;GAKG;AACH,qBAAa,eAAe;IACnB,MAAM,EAAE,SAAS,CAAC;IAEzB,8FAA8F;IACvF,SAAS,UAAiB;IAEjC,wDAAwD;IACjD,KAAK,UAAiB;IACtB,KAAK,EAAE,UAAU,EAAE,CAAM;IAChC,OAAO,CAAC,QAAQ,CAAgB;gBAEb,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa;IAcrD,QAAQ,IAAI,qBAAqB;IAOxC,yEAAyE;IAClE,SAAS,IAAI,MAAM;IAI1B,OAAO,KAAK,KAAK,GAGhB;IAED,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,iBAAiB;IAmFzB,OAAO,CAAC,WAAW;IAwCnB,OAAO,CAAC,SAAS;IA2CjB,OAAO,CAAC,YAAY;IA6BpB,OAAO,CAAC,YAAY;CAoBrB"}
@@ -604,7 +604,8 @@ class TextBlockLayout {
604
604
  }
605
605
  break;
606
606
  }
607
- case "text": {
607
+ case "text":
608
+ case "field": {
608
609
  const layout = RunLayout.create(component, context, cumulativeOverrides);
609
610
  // Text can be word-wrapped, so we need to split it into multiple runs if necessary.
610
611
  if (docWidth > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlockLayout.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwFH,0CAKC;AAQD,oEAGC;AAsBD,wDAmBC;AA/ID,oDAAsU;AACtU,wDAAwE;AAExE,sDAAkF;AAClF,yCAAyC;AACzC,mEAA8D;AAoC9D,gBAAgB;AAChB,SAAS,uBAAuB,CAAC,MAAgB;IAC/C,OAAO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,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;QAE3C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAjRD,0CAiRC","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 ElementGeometry\n */\n\nimport { BaselineShift, FieldRun, FontId, FontType, FractionRun, getMarkerText, LineLayoutResult, List, Paragraph, Run, RunLayoutResult, StructuralTextBlockComponent, TabRun, TextBlock, TextBlockComponent, TextBlockLayoutResult, TextBlockMargins, TextRun, TextStyleSettings, TextStyleSettingsProps } from \"@itwin/core-common\";\nimport { Geometry, Range2d, WritableXAndY } from \"@itwin/core-geometry\";\nimport { IModelDb } from \"../IModelDb\";\nimport { assert, Id64String, NonFunctionPropertiesOf } from \"@itwin/core-bentley\";\nimport * as LineBreaker from \"linebreak\";\nimport { AnnotationTextStyle } from \"./TextAnnotationElement\";\n\n\n/** @internal */\nexport interface TextLayoutRanges {\n layout: Range2d;\n justification: Range2d;\n}\n\n/** Arguments to [[ComputeRangesForTextLayout]].\n * @internal\n */\nexport interface ComputeRangesForTextLayoutArgs {\n chars: string;\n bold: boolean;\n italic: boolean;\n baselineShift: BaselineShift;\n fontId: FontId;\n widthFactor: number;\n textHeight: number;\n}\n\n/** A function that uses a font to compute the layout and justification ranges of a string of text.\n * @internal\n */\nexport type ComputeRangesForTextLayout = (args: ComputeRangesForTextLayoutArgs) => TextLayoutRanges;\n\n/** A function that looks up the font Id corresponding to a [FontFamilyDescriptor]($common).\n * If no type is provided, the function can return a font of any type matching `name` (there may be more than one, of different types).\n * @internal\n */\nexport type FindFontId = (name: string, type?: FontType) => FontId;\n\n/** @internal chiefly for tests. */\nexport type FindTextStyle = (id: Id64String) => TextStyleSettings;\n\n/** @internal */\nfunction createFindTextStyleImpl(iModel: IModelDb): FindTextStyle {\n return function findTextStyleImpl(id: Id64String): TextStyleSettings {\n const annotationTextStyle = iModel.elements.tryGetElement<AnnotationTextStyle>(id);\n if (annotationTextStyle && annotationTextStyle instanceof AnnotationTextStyle) {\n return annotationTextStyle.settings;\n }\n\n return TextStyleSettings.fromJSON();\n };\n}\n\n/**\n * Base interface for arguments supplied to [[computeLayoutTextBlockResult]] and [[computeGraphemeOffsets]].\n * @beta\n */\nexport interface LayoutTextArgs {\n /** The iModel from which to obtain fonts and [[AnnotationTextStyle]]s when laying out glyphs. */\n iModel: IModelDb;\n /** The text style resolver used to resolve effective text styles during layout. */\n textStyleResolver: TextStyleResolver;\n /** @internal chiefly for tests, by default uses IModelJsNative.DgnDb.computeRangesForText. */\n computeTextRange?: ComputeRangesForTextLayout;\n /** @internal chiefly for tests, by default uses IModelDb.fontMap. */\n findFontId?: FindFontId;\n}\n\n/**\n * Arguments supplied to [[computeLayoutTextBlockResult]].\n * @beta\n */\nexport interface LayoutTextBlockArgs extends LayoutTextArgs {\n /** The text block whose extents are to be computed. */\n textBlock: TextBlock;\n}\n\n/**\n * Lays out the contents of a TextBlock into a series of lines containing runs.\n * Each paragraph is decomposed into a series of lines.\n * Each series of consecutive non-linebreak runs within a paragraph is concatenated into one line.\n * If the document specifies a width > 0, individual lines are split to try to avoid exceeding that width.\n * Individual TextRuns can be split onto multiple lines at word boundaries if necessary. Individual FractionRuns are never split.\n * @see [[computeLayoutTextBlockResult]]\n * @beta\n */\nexport function layoutTextBlock(args: LayoutTextBlockArgs): TextBlockLayout {\n const findFontId = args.findFontId ?? ((name, type) => args.iModel.fonts.findId({ name, type }) ?? 0);\n const computeTextRange = args.computeTextRange ?? ((x) => args.iModel.computeRangesForText(x));\n\n return new TextBlockLayout(args.textBlock, new LayoutContext(args.textStyleResolver, computeTextRange, findFontId));\n}\n\n/**\n * Gets the result of laying out the the contents of a TextBlock into a series of lines containing runs.\n * The visual layout accounts for the [[AnnotationTextStyle]]s, fonts, and [TextBlock.width]($common). It applies word-wrapping if needed.\n * The layout returned matches the visual layout of the geometry produced by [[appendTextAnnotationGeometry]].\n * @beta\n */\nexport function computeLayoutTextBlockResult(args: LayoutTextBlockArgs): TextBlockLayoutResult {\n const layout = layoutTextBlock(args);\n return layout.toResult();\n}\n\n/**\n * Arguments supplied to [[computeGraphemeOffsets]].\n * @beta\n */\nexport interface ComputeGraphemeOffsetsArgs extends LayoutTextArgs {\n /** The TextBlockComponent for which to compute grapheme offsets. */\n source: TextBlockComponent;\n /** The run layout result for which grapheme ranges will be computed. */\n runLayoutResult: RunLayoutResult;\n /** An array of starting character indexes for each grapheme. Each entry represents the index of the first character in a grapheme. */\n graphemeCharIndexes: number[];\n};\n\n/**\n * Computes the range from the start of a [RunLayoutResult]($common) to the trailing edge of each grapheme.\n * It is the responsibility of the caller to determine the number and character indexes of the graphemes.\n * @returns If the [RunLayoutResult]($common)'s source is a [TextRun]($common), it returns an array containing the range of each grapheme.\n * Otherwise, it returns and empty array.\n * @beta\n */\nexport function computeGraphemeOffsets(args: ComputeGraphemeOffsetsArgs): Range2d[] {\n const { source, runLayoutResult, graphemeCharIndexes, iModel } = args;\n const findFontId = args.findFontId ?? ((name, type) => iModel.fonts.findId({ name, type }) ?? 0);\n const computeTextRange = args.computeTextRange ?? ((x) => iModel.computeRangesForText(x));\n\n if (!(source instanceof TextRun) || runLayoutResult.characterCount === 0) {\n return [];\n }\n\n const style = TextStyleSettings.fromJSON(runLayoutResult.textStyle);\n\n const layoutContext = new LayoutContext(args.textStyleResolver, computeTextRange, findFontId);\n const graphemeRanges: Range2d[] = [];\n\n graphemeCharIndexes.forEach((_, index) => {\n const nextGraphemeCharIndex = graphemeCharIndexes[index + 1] ?? runLayoutResult.characterCount;\n graphemeRanges.push(layoutContext.computeRangeForTextRun(style, source, runLayoutResult.characterOffset, nextGraphemeCharIndex).layout);\n });\n return graphemeRanges;\n}\n\nfunction scaleRange(range: Range2d, scale: number): void {\n range.low.scaleInPlace(scale);\n range.high.scaleInPlace(scale);\n}\n\n/**\n * Applies block level settings (lineSpacingFactor, paragraphSpacingFactor, widthFactor, frame, margins, justification, and leader) to a [TextStyleSettings]($common).\n * These must be set on the block, as they are meaningless on individual paragraphs/runs.\n * However, leaders are a special case and can override the block's leader settings.\n * Setting `isLeader` to `true` makes the [TextBlock]($common) settings not override the leader's settings.\n * @internal\n */\nfunction applyBlockSettings(target: TextStyleSettings, source: TextStyleSettings | TextStyleSettingsProps, isLeader: boolean = false): TextStyleSettings {\n if (source === target) {\n return target;\n }\n\n const lineSpacingFactor = source.lineSpacingFactor ?? target.lineSpacingFactor;\n const paragraphSpacingFactor = source.paragraphSpacingFactor ?? target.paragraphSpacingFactor;\n const widthFactor = source.widthFactor ?? target.widthFactor;\n const justification = source.justification ?? target.justification;\n const frame = source.frame ?? target.frame;\n const margins = source.margins ?? target.margins;\n const leader = source.leader ?? target.leader;\n\n const leaderShouldChange = !isLeader && !target.leaderEquals(leader);\n\n if (lineSpacingFactor !== target.lineSpacingFactor ||\n paragraphSpacingFactor !== target.paragraphSpacingFactor ||\n widthFactor !== target.widthFactor ||\n justification !== target.justification ||\n !target.frameEquals(frame) ||\n !target.marginsEqual(margins) ||\n leaderShouldChange\n ) {\n const cloneProps: TextStyleSettingsProps = {\n lineSpacingFactor,\n paragraphSpacingFactor,\n widthFactor,\n justification,\n frame,\n margins,\n };\n\n if (leaderShouldChange) {\n cloneProps.leader = leader;\n }\n\n target = target.clone(cloneProps);\n }\n\n return target;\n}\n\n/**\n * Arguments used when constructing a [[TextStyleResolver]].\n * @beta\n */\nexport interface TextStyleResolverArgs {\n /** The text block whose styles are being resolved. */\n textBlock: TextBlock;\n /** The ID of the [[AnnotationTextStyle]] to apply. */\n textStyleId: Id64String;\n /** The iModel from which to obtain [[AnnotationTextStyle]]s when resolving styles. */\n iModel: IModelDb;\n /** @internal chiefly for tests, by default looks up an [[AnnotationTextStyle]] in the iModel by ID. */\n findTextStyle?: FindTextStyle;\n}\n\n/**\n * Resolves the effective style of TextBlockComponents and Leaders, taking into account overrides of the instance and its parent(s).\n * @beta\n */\nexport class TextStyleResolver {\n /** The resolved style of the TextBlock. */\n public readonly blockSettings: TextStyleSettings;\n\n public constructor(args: TextStyleResolverArgs) {\n const findTextStyle = args.findTextStyle ?? createFindTextStyleImpl(args.iModel);\n this.blockSettings = findTextStyle(args.textStyleId);\n\n if (args.textBlock.styleOverrides)\n this.blockSettings = this.blockSettings.clone(args.textBlock.styleOverrides);\n }\n\n /**\n * Resolves the effective text style settings for a given TextBlockComponent, applying block-level overrides.\n */\n public resolveSettings(overrides: TextStyleSettingsProps, isLeader: boolean = false): TextStyleSettings {\n let settings = this.blockSettings;\n\n if (overrides)\n settings = settings.clone(overrides);\n\n return applyBlockSettings(settings, this.blockSettings, isLeader);\n }\n\n public resolveMarkerText(overrides: TextStyleSettingsProps, index: number): string {\n const markerSettings = overrides.listMarker ?? this.blockSettings.listMarker;\n return getMarkerText(markerSettings, index);\n }\n\n /**\n * Computes the indentation based on its style and nesting depth.\n */\n public resolveIndentation(styleOverrides: TextStyleSettingsProps, depth: number): number {\n const overrides = this.resolveSettings(styleOverrides);\n const indentation = overrides.indentation;\n const tabInterval = overrides.tabInterval;\n return indentation + tabInterval * depth;\n }\n}\n\nclass LayoutContext {\n private readonly _fontIds = new Map<string, FontId>();\n\n public constructor(public readonly textStyleResolver: TextStyleResolver, private readonly _computeTextRange: ComputeRangesForTextLayout, private readonly _findFontId: FindFontId) { }\n\n public findFontId(name: string, type?: FontType): FontId {\n let fontId = this._fontIds.get(name);\n if (undefined === fontId) {\n this._fontIds.set(name, fontId = this._findFontId(name, type));\n }\n\n return fontId;\n }\n\n public computeRangeForText(chars: string, style: TextStyleSettings, baselineShift: BaselineShift): TextLayoutRanges {\n if (chars.length === 0) {\n return {\n layout: new Range2d(0, 0, 0, style.textHeight),\n justification: new Range2d(),\n };\n }\n\n const fontId = this.findFontId(style.font.name, style.font.type);\n const { layout, justification } = this._computeTextRange({\n chars,\n fontId,\n baselineShift,\n bold: style.isBold,\n italic: style.isItalic,\n textHeight: style.textHeight,\n widthFactor: this.textStyleResolver.blockSettings.widthFactor,\n });\n\n if (\"none\" !== baselineShift) {\n const isSub = \"subscript\" === baselineShift;\n const scale = isSub ? style.subScriptScale : style.superScriptScale;\n const offsetFactor = isSub ? style.subScriptOffsetFactor : style.superScriptOffsetFactor;\n const offset = { x: 0, y: style.textHeight * offsetFactor };\n\n scaleRange(layout, scale);\n layout.cloneTranslated(offset, layout);\n\n scaleRange(justification, scale);\n justification.cloneTranslated(offset, justification);\n }\n\n return { layout, justification };\n }\n\n public computeRangeForTextRun(style: TextStyleSettings, run: TextRun | FieldRun, charOffset: number, numChars: number): TextLayoutRanges {\n let content: string;\n let baselineShift: BaselineShift;\n\n if (run.type === \"text\") {\n content = run.content;\n baselineShift = run.baselineShift;\n } else {\n content = run.cachedContent;\n baselineShift = \"none\";\n }\n\n return this.computeRangeForText(content.substring(charOffset, charOffset + numChars), style, baselineShift);\n }\n\n public computeRangeForFractionRun(style: TextStyleSettings, source: FractionRun): { layout: Range2d, numerator: Range2d, denominator: Range2d } {\n const numerator = this.computeRangeForText(source.numerator, style, \"none\").layout;\n scaleRange(numerator, style.stackedFractionScale);\n\n const denominator = this.computeRangeForText(source.denominator, style, \"none\").layout;\n scaleRange(denominator, style.stackedFractionScale);\n\n const numLen = numerator.xLength();\n const denomLen = denominator.xLength();\n switch (style.stackedFractionType) {\n case \"horizontal\": {\n if (numLen > denomLen) {\n denominator.cloneTranslated({ x: (numLen - denomLen) / 2, y: 0 }, denominator);\n } else {\n numerator.cloneTranslated({ x: (denomLen - numLen) / 2, y: 0 }, numerator);\n }\n\n numerator.cloneTranslated({ x: 0, y: 1.5 * denominator.yLength() }, numerator);\n break;\n }\n case \"diagonal\": {\n numerator.cloneTranslated({ x: 0, y: denominator.yLength() }, numerator);\n denominator.cloneTranslated({ x: numLen, y: 0 }, denominator);\n break;\n }\n }\n\n const layout = numerator.clone();\n layout.extendRange(denominator);\n return { layout, numerator, denominator };\n }\n\n public computeRangeForTabRun(style: TextStyleSettings, source: TabRun, lengthFromLastTab: number): Range2d {\n const interval = source.styleOverrides.tabInterval ?? style.tabInterval;\n const tabEndX = interval - lengthFromLastTab % interval;\n\n const range = new Range2d(0, 0, 0, style.textHeight);\n range.extendXY(tabEndX, range.low.y);\n\n return range;\n }\n}\n\ninterface Segment {\n segment: string;\n index: number;\n}\n\nfunction split(source: string): Segment[] {\n if (source.length === 0) {\n return [];\n }\n\n let index = 0;\n const segments: Segment[] = [];\n const breaker = new LineBreaker(source);\n for (let brk = breaker.nextBreak(); brk; brk = breaker.nextBreak()) {\n segments.push({\n segment: source.slice(index, brk.position),\n index,\n });\n\n index = brk.position;\n }\n\n return segments;\n}\n\nfunction applyTabShift(run: RunLayout, parent: LineLayout, context: LayoutContext): void {\n if (run.source.type === \"tab\") {\n run.range.setFrom(context.computeRangeForTabRun(run.style, run.source, parent.lengthFromLastTab));\n }\n}\n\n/**\n * Represents the layout of a single run (text, fraction, or line break) within a line of text.\n * Stores information about the run's position, style, and font within the line.\n * Provides utilities for splitting text runs for word wrapping and converting to result objects.\n * @beta\n */\nexport class RunLayout {\n public source: Run;\n public charOffset: number;\n public numChars: number;\n public range: Range2d;\n public justificationRange?: Range2d;\n public denominatorRange?: Range2d;\n public numeratorRange?: Range2d;\n public offsetFromLine: { x: number, y: number };\n public style: TextStyleSettings;\n public fontId: FontId;\n\n private constructor(props: NonFunctionPropertiesOf<RunLayout>) {\n this.source = props.source;\n this.charOffset = props.charOffset;\n this.numChars = props.numChars;\n this.range = props.range;\n this.justificationRange = props.justificationRange;\n this.denominatorRange = props.denominatorRange;\n this.numeratorRange = props.numeratorRange;\n this.offsetFromLine = props.offsetFromLine;\n this.style = props.style;\n this.fontId = props.fontId;\n }\n\n public static create(source: Run, context: LayoutContext, cumulativeOverrides: TextStyleSettingsProps): RunLayout {\n const style = context.textStyleResolver.resolveSettings(cumulativeOverrides);\n const fontId = context.findFontId(style.font.name, style.font.type);\n const charOffset = 0;\n const offsetFromLine = { x: 0, y: 0 };\n let numChars = 0;\n\n let range, justificationRange, numeratorRange, denominatorRange;\n\n switch (source.type) {\n case \"field\":\n case \"text\": {\n const content = source.type === \"text\" ? source.content : source.cachedContent;\n numChars = content.length;\n const ranges = context.computeRangeForTextRun(style, source, charOffset, numChars);\n range = ranges.layout;\n justificationRange = ranges.justification;\n break;\n }\n case \"fraction\": {\n numChars = 1;\n const ranges = context.computeRangeForFractionRun(style, source);\n range = ranges.layout;\n numeratorRange = ranges.numerator;\n denominatorRange = ranges.denominator;\n break;\n }\n default: { // \"linebreak\" or \"tab\"\n // \"tab\": Tabs rely on the context they are in, so we compute its range later.\n // lineBreak: We do this so that blank lines space correctly without special casing later.\n range = new Range2d(0, 0, 0, style.textHeight);\n break;\n }\n }\n\n return new RunLayout({ source, charOffset, numChars, range, justificationRange, denominatorRange, numeratorRange, offsetFromLine, style, fontId });\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n return this.source.type === \"text\" ? this.source.content.substring(this.charOffset, this.charOffset + this.numChars) : this.source.stringify();\n }\n\n public canWrap(): this is { source: TextRun } {\n return this.source.type === \"text\";\n }\n\n private cloneForWrap(args: { ranges: TextLayoutRanges, charOffset: number, numChars: number }): RunLayout {\n assert(this.canWrap());\n\n return new RunLayout({\n ...this,\n charOffset: args.charOffset,\n numChars: args.numChars,\n range: args.ranges.layout,\n justificationRange: args.ranges.justification,\n offsetFromLine: { ...this.offsetFromLine },\n });\n }\n\n public split(context: LayoutContext): RunLayout[] {\n assert(this.charOffset === 0, \"cannot re-split a run\");\n if (!this.canWrap() || this.charOffset > 0) {\n return [this];\n }\n\n const myText = this.source.content.substring(this.charOffset, this.charOffset + this.numChars);\n const segments = split(myText);\n\n if (segments.length <= 1) {\n return [this];\n }\n\n return segments.map((segment: any) => {\n return this.cloneForWrap({\n ranges: context.computeRangeForText(segment.segment, this.style, this.source.baselineShift),\n charOffset: segment.index,\n numChars: segment.segment.length,\n });\n });\n }\n\n public toResult(): RunLayoutResult {\n const result: RunLayoutResult = {\n fontId: this.fontId,\n characterOffset: this.charOffset,\n characterCount: this.numChars,\n range: this.range.toJSON(),\n offsetFromLine: this.offsetFromLine,\n textStyle: this.style.toJSON(),\n };\n\n if (this.justificationRange) {\n result.justificationRange = this.justificationRange.toJSON();\n }\n\n if (this.numeratorRange) {\n result.numeratorRange = this.numeratorRange.toJSON();\n }\n\n if (this.denominatorRange) {\n result.denominatorRange = this.denominatorRange.toJSON();\n }\n\n return result;\n }\n}\n\n/**\n * Represents the layout of a single line within a paragraph of a text block.\n * Contains a sequence of RunLayout objects, the computed range of the line, and its offset from the document origin.\n * Provides utilities for appending runs, computing ranges, and converting to result objects.\n * @beta\n */\nexport class LineLayout {\n public source: List | Run | Paragraph;\n public range = new Range2d(0, 0, 0, 0);\n public runRange = new Range2d(0, 0, 0, 0); // Range of all runs excluding marker.\n public justificationRange = new Range2d(0, 0, 0, 0);\n public offsetFromDocument: WritableXAndY;\n public depth: number;\n public lengthFromLastTab = 0; // Used to track the length from the last tab for tab runs.\n private _runs: RunLayout[] = [];\n private _marker?: RunLayout;\n\n public constructor(source: List | Run | Paragraph, style: TextStyleSettingsProps, context?: LayoutContext, depth: number = 0) {\n this.source = source;\n this.depth = depth;\n this.offsetFromDocument = { x: context?.textStyleResolver.resolveIndentation(style, depth) ?? 0, y: 0 };\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n const runs = this._runs.map((run) => run.stringify());\n return `${runs.join(\"\")}`;\n }\n\n /** Gets the array of RunLayout objects contained in this line. */\n public get runs(): ReadonlyArray<RunLayout> { return this._runs; }\n /** Indicates whether this line contains any runs. */\n public get isEmpty() { return this._runs.length === 0; }\n /** Gets the last RunLayout in this line. */\n public get back(): RunLayout {\n assert(!this.isEmpty);\n return this._runs[this._runs.length - 1];\n }\n\n /**\n * Gets or sets the marker RunLayout for this line, used for lists.\n * A marker is the symbol or character that appears before each list item in a list, bullets, numbers, etc.\n * */\n public get marker(): RunLayout | undefined { return this._marker; }\n public set marker(value: RunLayout | undefined) { this._marker = value; }\n\n public append(run: RunLayout): void {\n this._runs.push(run);\n this.computeRanges();\n }\n\n /** Invoked every time a run is appended,. */\n private computeRanges(): void {\n this.runRange.low.setZero();\n this.runRange.high.setZero();\n this.lengthFromLastTab = 0;\n\n let lineHeight = 0;\n let tallestNonFractionRun: RunLayout | undefined;\n for (const run of this._runs) {\n const runHeight = run.range.yLength();\n lineHeight = Math.max(lineHeight, runHeight);\n if (run.source.type !== \"fraction\" && (!tallestNonFractionRun || runHeight > tallestNonFractionRun.range.yLength())) {\n tallestNonFractionRun = run;\n }\n }\n\n // // The baseline for the line is the bottom of the tallest non-fraction run, centered in the line.\n let baseline = 0;\n if (tallestNonFractionRun) {\n baseline = (lineHeight + tallestNonFractionRun.range.yLength()) / 2\n }\n\n for (const run of this._runs) {\n const runHeight = run.range.yLength();\n // Vertically align runs: normal text at baseline, fractions visually centered on text or line as appropriate.\n let yOffset = lineHeight - baseline;\n\n if (run.source.type === \"fraction\") {\n const denominatorHeight = run.denominatorRange?.yLength() ?? 0;\n if (tallestNonFractionRun && run.style.textHeight <= tallestNonFractionRun.style.textHeight) {\n // Shift fraction to baseline, then down by half the denominator height so it appears centered relative to any non-fraction text of the same height.\n yOffset = (lineHeight - baseline) - denominatorHeight / 2;\n } else {\n // If the fraction text height is greater than the largest non-fraction text, just center it in the line.\n yOffset = (lineHeight - runHeight) / 2;\n }\n }\n\n const runOffset = { x: this.runRange.high.x, y: yOffset };\n run.offsetFromLine = runOffset;\n\n const runLayoutRange = run.range.cloneTranslated(runOffset);\n this.runRange.extendRange(runLayoutRange);\n\n if (\"linebreak\" !== run.source.type) {\n const runJustificationRange = run.justificationRange?.cloneTranslated(runOffset);\n this.justificationRange.extendRange(runJustificationRange ?? runLayoutRange);\n }\n\n if (\"tab\" === run.source.type) {\n this.lengthFromLastTab = 0;\n } else {\n this.lengthFromLastTab += run.range.xLength();\n }\n }\n\n this.range.setFrom(this.runRange);\n\n if (this._marker) {\n const indentation = this.range.low.x;\n const x = indentation - (this._marker.style.tabInterval / 2) - this._marker.range.xLength();\n const runHeight = this._marker.range.yLength();\n const runOffset = {\n x,\n y: (lineHeight - runHeight) / 2 // Center the marker vertically in the line.\n };\n\n this._marker.offsetFromLine = runOffset;\n\n const markerRange = this._marker.range.cloneTranslated(this._marker.offsetFromLine);\n this.range.extendRange(markerRange);\n }\n }\n\n public toResult(): LineLayoutResult {\n return {\n runs: this.runs.map((x) => x.toResult()),\n marker: this.marker?.toResult(),\n range: this.range.toJSON(),\n justificationRange: this.justificationRange.toJSON(),\n offsetFromDocument: this.offsetFromDocument,\n };\n }\n}\n\n/**\n * Describes the layout of a text block as a collection of lines containing runs.\n * Computes the visual layout of the text block, including word wrapping, justification, and margins.\n * Provides access to the computed lines, ranges, and utilities for converting to result objects.\n * @beta\n */\nexport class TextBlockLayout {\n public source: TextBlock;\n\n /** @internal: This is primarily for debugging purposes. This is the range of text geometry */\n public textRange = new Range2d();\n\n /** The range including margins of the [[TextBlock]]. */\n public range = new Range2d();\n public lines: LineLayout[] = [];\n private _context: LayoutContext;\n\n public constructor(source: TextBlock, context: LayoutContext) {\n this._context = context;\n this.source = source;\n\n if (source.width > 0) {\n this.textRange.low.x = 0;\n this.textRange.high.x = source.width;\n }\n\n this.populateLines(context);\n this.justifyLines(context);\n this.applyMargins(context.textStyleResolver.blockSettings.margins);\n }\n\n public toResult(): TextBlockLayoutResult {\n return {\n lines: this.lines.map((x) => x.toResult()),\n range: this.range.toJSON(),\n };\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n return this.lines.map((line) => line.stringify()).join(\"\\n\");\n }\n\n private get _back(): LineLayout {\n assert(this.lines.length > 0);\n return this.lines[this.lines.length - 1];\n }\n\n private populateLines(context: LayoutContext): void {\n const doc = this.source;\n if (!doc.children || doc.children.length === 0) {\n return;\n }\n\n let curLine = new LineLayout(doc.children[0], doc.children[0].styleOverrides, context);\n let childIndex = 0;\n for (const child of doc.children) {\n curLine = this.populateComponent(child, childIndex++, context, doc.width, curLine, doc, doc.styleOverrides);\n }\n\n if (curLine.runs.length > 0) {\n this.flushLine(context, curLine, doc.styleOverrides);\n }\n }\n\n private populateComponent(\n component: Run | Paragraph | List,\n componentIndex: number,\n context: LayoutContext,\n docWidth: number,\n curLine: LineLayout,\n parent: StructuralTextBlockComponent,\n cumulativeOverrides: TextStyleSettingsProps,\n depth: number = 0\n ): LineLayout {\n cumulativeOverrides = { ...cumulativeOverrides, ...component.styleOverrides };\n\n switch (component.type) {\n case \"list\": {\n // If we have any runs in the current line, flush it before starting the list.\n if (curLine.runs.length > 0) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, component.children[0], true, depth + 1);\n } else {\n // If not, we need to apply the indentation for the list to the first line.\n curLine.offsetFromDocument.x = context.textStyleResolver.resolveIndentation(cumulativeOverrides, depth + 1);\n curLine.depth = depth + 1;\n }\n\n // Iterate through each list item, setting the marker and populating its contents.\n component.children.forEach((child, index) => {\n const markerContent = context.textStyleResolver.resolveMarkerText(cumulativeOverrides, index + 1);\n const markerRun = TextRun.create({ content: markerContent });\n curLine.marker = RunLayout.create(markerRun, context, cumulativeOverrides);\n\n curLine = this.populateComponent(child, index, context, docWidth, curLine, component, cumulativeOverrides, depth + 1);\n });\n\n // Lastly flush the line.\n const nextSibling = parent?.children[componentIndex + 1];\n if (curLine && nextSibling) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, nextSibling, true, depth);\n }\n break;\n }\n case \"paragraph\": {\n // Iterate through each paragraph child (either a list or a run), populating its contents.\n component.children.forEach((child, index) => {\n curLine = this.populateComponent(child, index, context, docWidth, curLine, component, cumulativeOverrides, depth);\n });\n\n // Lastly flush the line.\n const nextSibling = parent?.children[componentIndex + 1];\n if (curLine && nextSibling) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, nextSibling, true, depth);\n }\n break;\n }\n case \"text\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n\n // Text can be word-wrapped, so we need to split it into multiple runs if necessary.\n if (docWidth > 0) {\n layout.split(context).forEach(r => { curLine = this.populateRun(curLine, r, context, cumulativeOverrides, docWidth) });\n } else {\n curLine = this.populateRun(curLine, layout, context, cumulativeOverrides, docWidth);\n }\n break;\n }\n case \"fraction\":\n case \"tab\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n curLine = this.populateRun(curLine, layout, context, cumulativeOverrides, docWidth);\n break;\n }\n case \"linebreak\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n\n curLine.append(layout);\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, depth);\n break;\n }\n default: break;\n }\n\n return curLine;\n };\n\n private populateRun(curLine: LineLayout, run: RunLayout, context: LayoutContext, cumulativeOverrides: TextStyleSettingsProps, docWidth: number): LineLayout {\n // If this is a tab, we need to apply the tab shift first, and then we can treat it like a text run.\n applyTabShift(run, curLine, context);\n\n // If our width is not set, then we don't have to compute word wrapping, so just append the run, and continue.\n if (docWidth <= 0) {\n curLine.append(run);\n return curLine;\n }\n\n // If not, we need to determine if we can append this run to the current line without exceeding the document width or if we need to word wrap.\n const runWidth = run.justificationRange?.xLength() ?? run.range.xLength();\n const lineWidth = curLine.runRange.xLength();\n const newWidth = runWidth + lineWidth + curLine.offsetFromDocument.x;\n\n // If true, then no word wrapping is required, so we can append to the current line.\n if (newWidth < docWidth || Geometry.isAlmostEqualNumber(newWidth, docWidth, Geometry.smallMetricDistance)) {\n curLine.append(run);\n return curLine;\n }\n\n // If not, do word wrapping\n if (curLine.runs.length === 0) {\n curLine.append(run);\n\n // Lastly, flush line\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, curLine.depth);\n } else {\n // First, flush line\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, curLine.depth);\n\n // Recompute tab shift if applicable\n applyTabShift(run, curLine, context);\n\n curLine.append(run);\n }\n\n return curLine;\n };\n\n private flushLine(context: LayoutContext, curLine: LineLayout, cumulativeOverrides: TextStyleSettingsProps, next?: List | Run | Paragraph, newParagraph: boolean = false, depth: number = 0): LineLayout {\n next = next ?? curLine.source;\n\n // We want to guarantee that each layout line has at least one run.\n if (curLine.runs.length === 0) {\n if (this.lines.length === 0 || this._back.runs.length === 0) {\n return new LineLayout(next, cumulativeOverrides, context, depth);\n }\n\n if (curLine.source.type !== \"linebreak\") {\n const newLine = new LineLayout(next, cumulativeOverrides, context, depth);\n newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n return newLine;\n }\n\n const run = curLine.source.clone();\n curLine.append(RunLayout.create(run, context, cumulativeOverrides));\n }\n\n // Line origin is its baseline.\n const lineOffset = { ...curLine.offsetFromDocument }; // Start with the line's original offset, which includes indentation.\n lineOffset.y -= curLine.range.yLength(); // Shift down the baseline\n\n // Place it below any existing lines\n if (this.lines.length > 0) {\n lineOffset.y += this._back.offsetFromDocument.y;\n lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n }\n\n curLine.offsetFromDocument = lineOffset;\n\n // Update document range from computed line range and position\n this.textRange.extendRange(curLine.range.cloneTranslated(lineOffset));\n\n this.lines.push(curLine);\n if (newParagraph) {\n const newLine = new LineLayout(next, cumulativeOverrides, context, depth);\n newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n return newLine;\n }\n return new LineLayout(next, cumulativeOverrides, context, depth);\n }\n\n private justifyLines(context: LayoutContext): void {\n // We don't want to justify empty text, or a single line of text whose width is 0. By default text is already left justified.\n if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || \"left\" === context.textStyleResolver.blockSettings.justification) {\n return;\n }\n\n // This is the minimum width of the document's bounding box.\n const docWidth = this.source.width;\n\n let minOffset = Number.MAX_VALUE;\n for (const line of this.lines) {\n const lineWidth = line.justificationRange.xLength() + line.offsetFromDocument.x;\n\n let offset = docWidth - lineWidth;\n if (\"center\" === context.textStyleResolver.blockSettings.justification) {\n offset = offset / 2;\n }\n\n line.offsetFromDocument.x += offset;\n minOffset = Math.min(offset, minOffset);\n }\n\n if (minOffset < 0) {\n // Shift left to accommodate lines that exceeded the document's minimum width.\n this.textRange.low.x += minOffset;\n this.textRange.high.x += minOffset;\n }\n }\n\n private applyMargins(margins: Required<TextBlockMargins>) {\n this.range = this.textRange.clone();\n\n if (this.range.isNull)\n return;\n\n // Disregard negative margins.\n const right = margins.right >= 0 ? margins.right : 0;\n const left = margins.left >= 0 ? margins.left : 0;\n const top = margins.top >= 0 ? margins.top : 0;\n const bottom = margins.bottom >= 0 ? margins.bottom : 0;\n\n const xHigh = this.textRange.high.x + right;\n const yHigh = this.textRange.high.y + top;\n const xLow = this.textRange.low.x - left;\n const yLow = this.textRange.low.y - bottom;\n\n this.range.extendXY(xHigh, yHigh);\n this.range.extendXY(xLow, yLow);\n }\n}\n"]}
1
+ {"version":3,"file":"TextBlockLayout.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAwFH,0CAKC;AAQD,oEAGC;AAsBD,wDAmBC;AA/ID,oDAAsU;AACtU,wDAAwE;AAExE,sDAAkF;AAClF,yCAAyC;AACzC,mEAA8D;AAoC9D,gBAAgB;AAChB,SAAS,uBAAuB,CAAC,MAAgB;IAC/C,OAAO,SAAS,iBAAiB,CAAC,EAAc;QAC9C,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAsB,EAAE,CAAC,CAAC;QACnF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AC,CAAC,GAAG,MAAM,CAAC;QAE3C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAlRD,0CAkRC","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 ElementGeometry\n */\n\nimport { BaselineShift, FieldRun, FontId, FontType, FractionRun, getMarkerText, LineLayoutResult, List, Paragraph, Run, RunLayoutResult, StructuralTextBlockComponent, TabRun, TextBlock, TextBlockComponent, TextBlockLayoutResult, TextBlockMargins, TextRun, TextStyleSettings, TextStyleSettingsProps } from \"@itwin/core-common\";\nimport { Geometry, Range2d, WritableXAndY } from \"@itwin/core-geometry\";\nimport { IModelDb } from \"../IModelDb\";\nimport { assert, Id64String, NonFunctionPropertiesOf } from \"@itwin/core-bentley\";\nimport * as LineBreaker from \"linebreak\";\nimport { AnnotationTextStyle } from \"./TextAnnotationElement\";\n\n\n/** @internal */\nexport interface TextLayoutRanges {\n layout: Range2d;\n justification: Range2d;\n}\n\n/** Arguments to [[ComputeRangesForTextLayout]].\n * @internal\n */\nexport interface ComputeRangesForTextLayoutArgs {\n chars: string;\n bold: boolean;\n italic: boolean;\n baselineShift: BaselineShift;\n fontId: FontId;\n widthFactor: number;\n textHeight: number;\n}\n\n/** A function that uses a font to compute the layout and justification ranges of a string of text.\n * @internal\n */\nexport type ComputeRangesForTextLayout = (args: ComputeRangesForTextLayoutArgs) => TextLayoutRanges;\n\n/** A function that looks up the font Id corresponding to a [FontFamilyDescriptor]($common).\n * If no type is provided, the function can return a font of any type matching `name` (there may be more than one, of different types).\n * @internal\n */\nexport type FindFontId = (name: string, type?: FontType) => FontId;\n\n/** @internal chiefly for tests. */\nexport type FindTextStyle = (id: Id64String) => TextStyleSettings;\n\n/** @internal */\nfunction createFindTextStyleImpl(iModel: IModelDb): FindTextStyle {\n return function findTextStyleImpl(id: Id64String): TextStyleSettings {\n const annotationTextStyle = iModel.elements.tryGetElement<AnnotationTextStyle>(id);\n if (annotationTextStyle && annotationTextStyle instanceof AnnotationTextStyle) {\n return annotationTextStyle.settings;\n }\n\n return TextStyleSettings.fromJSON();\n };\n}\n\n/**\n * Base interface for arguments supplied to [[computeLayoutTextBlockResult]] and [[computeGraphemeOffsets]].\n * @beta\n */\nexport interface LayoutTextArgs {\n /** The iModel from which to obtain fonts and [[AnnotationTextStyle]]s when laying out glyphs. */\n iModel: IModelDb;\n /** The text style resolver used to resolve effective text styles during layout. */\n textStyleResolver: TextStyleResolver;\n /** @internal chiefly for tests, by default uses IModelJsNative.DgnDb.computeRangesForText. */\n computeTextRange?: ComputeRangesForTextLayout;\n /** @internal chiefly for tests, by default uses IModelDb.fontMap. */\n findFontId?: FindFontId;\n}\n\n/**\n * Arguments supplied to [[computeLayoutTextBlockResult]].\n * @beta\n */\nexport interface LayoutTextBlockArgs extends LayoutTextArgs {\n /** The text block whose extents are to be computed. */\n textBlock: TextBlock;\n}\n\n/**\n * Lays out the contents of a TextBlock into a series of lines containing runs.\n * Each paragraph is decomposed into a series of lines.\n * Each series of consecutive non-linebreak runs within a paragraph is concatenated into one line.\n * If the document specifies a width > 0, individual lines are split to try to avoid exceeding that width.\n * Individual TextRuns can be split onto multiple lines at word boundaries if necessary. Individual FractionRuns are never split.\n * @see [[computeLayoutTextBlockResult]]\n * @beta\n */\nexport function layoutTextBlock(args: LayoutTextBlockArgs): TextBlockLayout {\n const findFontId = args.findFontId ?? ((name, type) => args.iModel.fonts.findId({ name, type }) ?? 0);\n const computeTextRange = args.computeTextRange ?? ((x) => args.iModel.computeRangesForText(x));\n\n return new TextBlockLayout(args.textBlock, new LayoutContext(args.textStyleResolver, computeTextRange, findFontId));\n}\n\n/**\n * Gets the result of laying out the the contents of a TextBlock into a series of lines containing runs.\n * The visual layout accounts for the [[AnnotationTextStyle]]s, fonts, and [TextBlock.width]($common). It applies word-wrapping if needed.\n * The layout returned matches the visual layout of the geometry produced by [[appendTextAnnotationGeometry]].\n * @beta\n */\nexport function computeLayoutTextBlockResult(args: LayoutTextBlockArgs): TextBlockLayoutResult {\n const layout = layoutTextBlock(args);\n return layout.toResult();\n}\n\n/**\n * Arguments supplied to [[computeGraphemeOffsets]].\n * @beta\n */\nexport interface ComputeGraphemeOffsetsArgs extends LayoutTextArgs {\n /** The TextBlockComponent for which to compute grapheme offsets. */\n source: TextBlockComponent;\n /** The run layout result for which grapheme ranges will be computed. */\n runLayoutResult: RunLayoutResult;\n /** An array of starting character indexes for each grapheme. Each entry represents the index of the first character in a grapheme. */\n graphemeCharIndexes: number[];\n};\n\n/**\n * Computes the range from the start of a [RunLayoutResult]($common) to the trailing edge of each grapheme.\n * It is the responsibility of the caller to determine the number and character indexes of the graphemes.\n * @returns If the [RunLayoutResult]($common)'s source is a [TextRun]($common), it returns an array containing the range of each grapheme.\n * Otherwise, it returns and empty array.\n * @beta\n */\nexport function computeGraphemeOffsets(args: ComputeGraphemeOffsetsArgs): Range2d[] {\n const { source, runLayoutResult, graphemeCharIndexes, iModel } = args;\n const findFontId = args.findFontId ?? ((name, type) => iModel.fonts.findId({ name, type }) ?? 0);\n const computeTextRange = args.computeTextRange ?? ((x) => iModel.computeRangesForText(x));\n\n if (!(source instanceof TextRun) || runLayoutResult.characterCount === 0) {\n return [];\n }\n\n const style = TextStyleSettings.fromJSON(runLayoutResult.textStyle);\n\n const layoutContext = new LayoutContext(args.textStyleResolver, computeTextRange, findFontId);\n const graphemeRanges: Range2d[] = [];\n\n graphemeCharIndexes.forEach((_, index) => {\n const nextGraphemeCharIndex = graphemeCharIndexes[index + 1] ?? runLayoutResult.characterCount;\n graphemeRanges.push(layoutContext.computeRangeForTextRun(style, source, runLayoutResult.characterOffset, nextGraphemeCharIndex).layout);\n });\n return graphemeRanges;\n}\n\nfunction scaleRange(range: Range2d, scale: number): void {\n range.low.scaleInPlace(scale);\n range.high.scaleInPlace(scale);\n}\n\n/**\n * Applies block level settings (lineSpacingFactor, paragraphSpacingFactor, widthFactor, frame, margins, justification, and leader) to a [TextStyleSettings]($common).\n * These must be set on the block, as they are meaningless on individual paragraphs/runs.\n * However, leaders are a special case and can override the block's leader settings.\n * Setting `isLeader` to `true` makes the [TextBlock]($common) settings not override the leader's settings.\n * @internal\n */\nfunction applyBlockSettings(target: TextStyleSettings, source: TextStyleSettings | TextStyleSettingsProps, isLeader: boolean = false): TextStyleSettings {\n if (source === target) {\n return target;\n }\n\n const lineSpacingFactor = source.lineSpacingFactor ?? target.lineSpacingFactor;\n const paragraphSpacingFactor = source.paragraphSpacingFactor ?? target.paragraphSpacingFactor;\n const widthFactor = source.widthFactor ?? target.widthFactor;\n const justification = source.justification ?? target.justification;\n const frame = source.frame ?? target.frame;\n const margins = source.margins ?? target.margins;\n const leader = source.leader ?? target.leader;\n\n const leaderShouldChange = !isLeader && !target.leaderEquals(leader);\n\n if (lineSpacingFactor !== target.lineSpacingFactor ||\n paragraphSpacingFactor !== target.paragraphSpacingFactor ||\n widthFactor !== target.widthFactor ||\n justification !== target.justification ||\n !target.frameEquals(frame) ||\n !target.marginsEqual(margins) ||\n leaderShouldChange\n ) {\n const cloneProps: TextStyleSettingsProps = {\n lineSpacingFactor,\n paragraphSpacingFactor,\n widthFactor,\n justification,\n frame,\n margins,\n };\n\n if (leaderShouldChange) {\n cloneProps.leader = leader;\n }\n\n target = target.clone(cloneProps);\n }\n\n return target;\n}\n\n/**\n * Arguments used when constructing a [[TextStyleResolver]].\n * @beta\n */\nexport interface TextStyleResolverArgs {\n /** The text block whose styles are being resolved. */\n textBlock: TextBlock;\n /** The ID of the [[AnnotationTextStyle]] to apply. */\n textStyleId: Id64String;\n /** The iModel from which to obtain [[AnnotationTextStyle]]s when resolving styles. */\n iModel: IModelDb;\n /** @internal chiefly for tests, by default looks up an [[AnnotationTextStyle]] in the iModel by ID. */\n findTextStyle?: FindTextStyle;\n}\n\n/**\n * Resolves the effective style of TextBlockComponents and Leaders, taking into account overrides of the instance and its parent(s).\n * @beta\n */\nexport class TextStyleResolver {\n /** The resolved style of the TextBlock. */\n public readonly blockSettings: TextStyleSettings;\n\n public constructor(args: TextStyleResolverArgs) {\n const findTextStyle = args.findTextStyle ?? createFindTextStyleImpl(args.iModel);\n this.blockSettings = findTextStyle(args.textStyleId);\n\n if (args.textBlock.styleOverrides)\n this.blockSettings = this.blockSettings.clone(args.textBlock.styleOverrides);\n }\n\n /**\n * Resolves the effective text style settings for a given TextBlockComponent, applying block-level overrides.\n */\n public resolveSettings(overrides: TextStyleSettingsProps, isLeader: boolean = false): TextStyleSettings {\n let settings = this.blockSettings;\n\n if (overrides)\n settings = settings.clone(overrides);\n\n return applyBlockSettings(settings, this.blockSettings, isLeader);\n }\n\n public resolveMarkerText(overrides: TextStyleSettingsProps, index: number): string {\n const markerSettings = overrides.listMarker ?? this.blockSettings.listMarker;\n return getMarkerText(markerSettings, index);\n }\n\n /**\n * Computes the indentation based on its style and nesting depth.\n */\n public resolveIndentation(styleOverrides: TextStyleSettingsProps, depth: number): number {\n const overrides = this.resolveSettings(styleOverrides);\n const indentation = overrides.indentation;\n const tabInterval = overrides.tabInterval;\n return indentation + tabInterval * depth;\n }\n}\n\nclass LayoutContext {\n private readonly _fontIds = new Map<string, FontId>();\n\n public constructor(public readonly textStyleResolver: TextStyleResolver, private readonly _computeTextRange: ComputeRangesForTextLayout, private readonly _findFontId: FindFontId) { }\n\n public findFontId(name: string, type?: FontType): FontId {\n let fontId = this._fontIds.get(name);\n if (undefined === fontId) {\n this._fontIds.set(name, fontId = this._findFontId(name, type));\n }\n\n return fontId;\n }\n\n public computeRangeForText(chars: string, style: TextStyleSettings, baselineShift: BaselineShift): TextLayoutRanges {\n if (chars.length === 0) {\n return {\n layout: new Range2d(0, 0, 0, style.textHeight),\n justification: new Range2d(),\n };\n }\n\n const fontId = this.findFontId(style.font.name, style.font.type);\n const { layout, justification } = this._computeTextRange({\n chars,\n fontId,\n baselineShift,\n bold: style.isBold,\n italic: style.isItalic,\n textHeight: style.textHeight,\n widthFactor: this.textStyleResolver.blockSettings.widthFactor,\n });\n\n if (\"none\" !== baselineShift) {\n const isSub = \"subscript\" === baselineShift;\n const scale = isSub ? style.subScriptScale : style.superScriptScale;\n const offsetFactor = isSub ? style.subScriptOffsetFactor : style.superScriptOffsetFactor;\n const offset = { x: 0, y: style.textHeight * offsetFactor };\n\n scaleRange(layout, scale);\n layout.cloneTranslated(offset, layout);\n\n scaleRange(justification, scale);\n justification.cloneTranslated(offset, justification);\n }\n\n return { layout, justification };\n }\n\n public computeRangeForTextRun(style: TextStyleSettings, run: TextRun | FieldRun, charOffset: number, numChars: number): TextLayoutRanges {\n let content: string;\n let baselineShift: BaselineShift;\n\n if (run.type === \"text\") {\n content = run.content;\n baselineShift = run.baselineShift;\n } else {\n content = run.cachedContent;\n baselineShift = \"none\";\n }\n\n return this.computeRangeForText(content.substring(charOffset, charOffset + numChars), style, baselineShift);\n }\n\n public computeRangeForFractionRun(style: TextStyleSettings, source: FractionRun): { layout: Range2d, numerator: Range2d, denominator: Range2d } {\n const numerator = this.computeRangeForText(source.numerator, style, \"none\").layout;\n scaleRange(numerator, style.stackedFractionScale);\n\n const denominator = this.computeRangeForText(source.denominator, style, \"none\").layout;\n scaleRange(denominator, style.stackedFractionScale);\n\n const numLen = numerator.xLength();\n const denomLen = denominator.xLength();\n switch (style.stackedFractionType) {\n case \"horizontal\": {\n if (numLen > denomLen) {\n denominator.cloneTranslated({ x: (numLen - denomLen) / 2, y: 0 }, denominator);\n } else {\n numerator.cloneTranslated({ x: (denomLen - numLen) / 2, y: 0 }, numerator);\n }\n\n numerator.cloneTranslated({ x: 0, y: 1.5 * denominator.yLength() }, numerator);\n break;\n }\n case \"diagonal\": {\n numerator.cloneTranslated({ x: 0, y: denominator.yLength() }, numerator);\n denominator.cloneTranslated({ x: numLen, y: 0 }, denominator);\n break;\n }\n }\n\n const layout = numerator.clone();\n layout.extendRange(denominator);\n return { layout, numerator, denominator };\n }\n\n public computeRangeForTabRun(style: TextStyleSettings, source: TabRun, lengthFromLastTab: number): Range2d {\n const interval = source.styleOverrides.tabInterval ?? style.tabInterval;\n const tabEndX = interval - lengthFromLastTab % interval;\n\n const range = new Range2d(0, 0, 0, style.textHeight);\n range.extendXY(tabEndX, range.low.y);\n\n return range;\n }\n}\n\ninterface Segment {\n segment: string;\n index: number;\n}\n\nfunction split(source: string): Segment[] {\n if (source.length === 0) {\n return [];\n }\n\n let index = 0;\n const segments: Segment[] = [];\n const breaker = new LineBreaker(source);\n for (let brk = breaker.nextBreak(); brk; brk = breaker.nextBreak()) {\n segments.push({\n segment: source.slice(index, brk.position),\n index,\n });\n\n index = brk.position;\n }\n\n return segments;\n}\n\nfunction applyTabShift(run: RunLayout, parent: LineLayout, context: LayoutContext): void {\n if (run.source.type === \"tab\") {\n run.range.setFrom(context.computeRangeForTabRun(run.style, run.source, parent.lengthFromLastTab));\n }\n}\n\n/**\n * Represents the layout of a single run (text, fraction, or line break) within a line of text.\n * Stores information about the run's position, style, and font within the line.\n * Provides utilities for splitting text runs for word wrapping and converting to result objects.\n * @beta\n */\nexport class RunLayout {\n public source: Run;\n public charOffset: number;\n public numChars: number;\n public range: Range2d;\n public justificationRange?: Range2d;\n public denominatorRange?: Range2d;\n public numeratorRange?: Range2d;\n public offsetFromLine: { x: number, y: number };\n public style: TextStyleSettings;\n public fontId: FontId;\n\n private constructor(props: NonFunctionPropertiesOf<RunLayout>) {\n this.source = props.source;\n this.charOffset = props.charOffset;\n this.numChars = props.numChars;\n this.range = props.range;\n this.justificationRange = props.justificationRange;\n this.denominatorRange = props.denominatorRange;\n this.numeratorRange = props.numeratorRange;\n this.offsetFromLine = props.offsetFromLine;\n this.style = props.style;\n this.fontId = props.fontId;\n }\n\n public static create(source: Run, context: LayoutContext, cumulativeOverrides: TextStyleSettingsProps): RunLayout {\n const style = context.textStyleResolver.resolveSettings(cumulativeOverrides);\n const fontId = context.findFontId(style.font.name, style.font.type);\n const charOffset = 0;\n const offsetFromLine = { x: 0, y: 0 };\n let numChars = 0;\n\n let range, justificationRange, numeratorRange, denominatorRange;\n\n switch (source.type) {\n case \"field\":\n case \"text\": {\n const content = source.type === \"text\" ? source.content : source.cachedContent;\n numChars = content.length;\n const ranges = context.computeRangeForTextRun(style, source, charOffset, numChars);\n range = ranges.layout;\n justificationRange = ranges.justification;\n break;\n }\n case \"fraction\": {\n numChars = 1;\n const ranges = context.computeRangeForFractionRun(style, source);\n range = ranges.layout;\n numeratorRange = ranges.numerator;\n denominatorRange = ranges.denominator;\n break;\n }\n default: { // \"linebreak\" or \"tab\"\n // \"tab\": Tabs rely on the context they are in, so we compute its range later.\n // lineBreak: We do this so that blank lines space correctly without special casing later.\n range = new Range2d(0, 0, 0, style.textHeight);\n break;\n }\n }\n\n return new RunLayout({ source, charOffset, numChars, range, justificationRange, denominatorRange, numeratorRange, offsetFromLine, style, fontId });\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n return this.source.type === \"text\" ? this.source.content.substring(this.charOffset, this.charOffset + this.numChars) : this.source.stringify();\n }\n\n public canWrap(): this is { source: TextRun } {\n return this.source.type === \"text\";\n }\n\n private cloneForWrap(args: { ranges: TextLayoutRanges, charOffset: number, numChars: number }): RunLayout {\n assert(this.canWrap());\n\n return new RunLayout({\n ...this,\n charOffset: args.charOffset,\n numChars: args.numChars,\n range: args.ranges.layout,\n justificationRange: args.ranges.justification,\n offsetFromLine: { ...this.offsetFromLine },\n });\n }\n\n public split(context: LayoutContext): RunLayout[] {\n assert(this.charOffset === 0, \"cannot re-split a run\");\n if (!this.canWrap() || this.charOffset > 0) {\n return [this];\n }\n\n const myText = this.source.content.substring(this.charOffset, this.charOffset + this.numChars);\n const segments = split(myText);\n\n if (segments.length <= 1) {\n return [this];\n }\n\n return segments.map((segment: any) => {\n return this.cloneForWrap({\n ranges: context.computeRangeForText(segment.segment, this.style, this.source.baselineShift),\n charOffset: segment.index,\n numChars: segment.segment.length,\n });\n });\n }\n\n public toResult(): RunLayoutResult {\n const result: RunLayoutResult = {\n fontId: this.fontId,\n characterOffset: this.charOffset,\n characterCount: this.numChars,\n range: this.range.toJSON(),\n offsetFromLine: this.offsetFromLine,\n textStyle: this.style.toJSON(),\n };\n\n if (this.justificationRange) {\n result.justificationRange = this.justificationRange.toJSON();\n }\n\n if (this.numeratorRange) {\n result.numeratorRange = this.numeratorRange.toJSON();\n }\n\n if (this.denominatorRange) {\n result.denominatorRange = this.denominatorRange.toJSON();\n }\n\n return result;\n }\n}\n\n/**\n * Represents the layout of a single line within a paragraph of a text block.\n * Contains a sequence of RunLayout objects, the computed range of the line, and its offset from the document origin.\n * Provides utilities for appending runs, computing ranges, and converting to result objects.\n * @beta\n */\nexport class LineLayout {\n public source: List | Run | Paragraph;\n public range = new Range2d(0, 0, 0, 0);\n public runRange = new Range2d(0, 0, 0, 0); // Range of all runs excluding marker.\n public justificationRange = new Range2d(0, 0, 0, 0);\n public offsetFromDocument: WritableXAndY;\n public depth: number;\n public lengthFromLastTab = 0; // Used to track the length from the last tab for tab runs.\n private _runs: RunLayout[] = [];\n private _marker?: RunLayout;\n\n public constructor(source: List | Run | Paragraph, style: TextStyleSettingsProps, context?: LayoutContext, depth: number = 0) {\n this.source = source;\n this.depth = depth;\n this.offsetFromDocument = { x: context?.textStyleResolver.resolveIndentation(style, depth) ?? 0, y: 0 };\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n const runs = this._runs.map((run) => run.stringify());\n return `${runs.join(\"\")}`;\n }\n\n /** Gets the array of RunLayout objects contained in this line. */\n public get runs(): ReadonlyArray<RunLayout> { return this._runs; }\n /** Indicates whether this line contains any runs. */\n public get isEmpty() { return this._runs.length === 0; }\n /** Gets the last RunLayout in this line. */\n public get back(): RunLayout {\n assert(!this.isEmpty);\n return this._runs[this._runs.length - 1];\n }\n\n /**\n * Gets or sets the marker RunLayout for this line, used for lists.\n * A marker is the symbol or character that appears before each list item in a list, bullets, numbers, etc.\n * */\n public get marker(): RunLayout | undefined { return this._marker; }\n public set marker(value: RunLayout | undefined) { this._marker = value; }\n\n public append(run: RunLayout): void {\n this._runs.push(run);\n this.computeRanges();\n }\n\n /** Invoked every time a run is appended,. */\n private computeRanges(): void {\n this.runRange.low.setZero();\n this.runRange.high.setZero();\n this.lengthFromLastTab = 0;\n\n let lineHeight = 0;\n let tallestNonFractionRun: RunLayout | undefined;\n for (const run of this._runs) {\n const runHeight = run.range.yLength();\n lineHeight = Math.max(lineHeight, runHeight);\n if (run.source.type !== \"fraction\" && (!tallestNonFractionRun || runHeight > tallestNonFractionRun.range.yLength())) {\n tallestNonFractionRun = run;\n }\n }\n\n // // The baseline for the line is the bottom of the tallest non-fraction run, centered in the line.\n let baseline = 0;\n if (tallestNonFractionRun) {\n baseline = (lineHeight + tallestNonFractionRun.range.yLength()) / 2\n }\n\n for (const run of this._runs) {\n const runHeight = run.range.yLength();\n // Vertically align runs: normal text at baseline, fractions visually centered on text or line as appropriate.\n let yOffset = lineHeight - baseline;\n\n if (run.source.type === \"fraction\") {\n const denominatorHeight = run.denominatorRange?.yLength() ?? 0;\n if (tallestNonFractionRun && run.style.textHeight <= tallestNonFractionRun.style.textHeight) {\n // Shift fraction to baseline, then down by half the denominator height so it appears centered relative to any non-fraction text of the same height.\n yOffset = (lineHeight - baseline) - denominatorHeight / 2;\n } else {\n // If the fraction text height is greater than the largest non-fraction text, just center it in the line.\n yOffset = (lineHeight - runHeight) / 2;\n }\n }\n\n const runOffset = { x: this.runRange.high.x, y: yOffset };\n run.offsetFromLine = runOffset;\n\n const runLayoutRange = run.range.cloneTranslated(runOffset);\n this.runRange.extendRange(runLayoutRange);\n\n if (\"linebreak\" !== run.source.type) {\n const runJustificationRange = run.justificationRange?.cloneTranslated(runOffset);\n this.justificationRange.extendRange(runJustificationRange ?? runLayoutRange);\n }\n\n if (\"tab\" === run.source.type) {\n this.lengthFromLastTab = 0;\n } else {\n this.lengthFromLastTab += run.range.xLength();\n }\n }\n\n this.range.setFrom(this.runRange);\n\n if (this._marker) {\n const indentation = this.range.low.x;\n const x = indentation - (this._marker.style.tabInterval / 2) - this._marker.range.xLength();\n const runHeight = this._marker.range.yLength();\n const runOffset = {\n x,\n y: (lineHeight - runHeight) / 2 // Center the marker vertically in the line.\n };\n\n this._marker.offsetFromLine = runOffset;\n\n const markerRange = this._marker.range.cloneTranslated(this._marker.offsetFromLine);\n this.range.extendRange(markerRange);\n }\n }\n\n public toResult(): LineLayoutResult {\n return {\n runs: this.runs.map((x) => x.toResult()),\n marker: this.marker?.toResult(),\n range: this.range.toJSON(),\n justificationRange: this.justificationRange.toJSON(),\n offsetFromDocument: this.offsetFromDocument,\n };\n }\n}\n\n/**\n * Describes the layout of a text block as a collection of lines containing runs.\n * Computes the visual layout of the text block, including word wrapping, justification, and margins.\n * Provides access to the computed lines, ranges, and utilities for converting to result objects.\n * @beta\n */\nexport class TextBlockLayout {\n public source: TextBlock;\n\n /** @internal: This is primarily for debugging purposes. This is the range of text geometry */\n public textRange = new Range2d();\n\n /** The range including margins of the [[TextBlock]]. */\n public range = new Range2d();\n public lines: LineLayout[] = [];\n private _context: LayoutContext;\n\n public constructor(source: TextBlock, context: LayoutContext) {\n this._context = context;\n this.source = source;\n\n if (source.width > 0) {\n this.textRange.low.x = 0;\n this.textRange.high.x = source.width;\n }\n\n this.populateLines(context);\n this.justifyLines(context);\n this.applyMargins(context.textStyleResolver.blockSettings.margins);\n }\n\n public toResult(): TextBlockLayoutResult {\n return {\n lines: this.lines.map((x) => x.toResult()),\n range: this.range.toJSON(),\n };\n }\n\n /** Compute a string representation, primarily for debugging purposes. */\n public stringify(): string {\n return this.lines.map((line) => line.stringify()).join(\"\\n\");\n }\n\n private get _back(): LineLayout {\n assert(this.lines.length > 0);\n return this.lines[this.lines.length - 1];\n }\n\n private populateLines(context: LayoutContext): void {\n const doc = this.source;\n if (!doc.children || doc.children.length === 0) {\n return;\n }\n\n let curLine = new LineLayout(doc.children[0], doc.children[0].styleOverrides, context);\n let childIndex = 0;\n for (const child of doc.children) {\n curLine = this.populateComponent(child, childIndex++, context, doc.width, curLine, doc, doc.styleOverrides);\n }\n\n if (curLine.runs.length > 0) {\n this.flushLine(context, curLine, doc.styleOverrides);\n }\n }\n\n private populateComponent(\n component: Run | Paragraph | List,\n componentIndex: number,\n context: LayoutContext,\n docWidth: number,\n curLine: LineLayout,\n parent: StructuralTextBlockComponent,\n cumulativeOverrides: TextStyleSettingsProps,\n depth: number = 0\n ): LineLayout {\n cumulativeOverrides = { ...cumulativeOverrides, ...component.styleOverrides };\n\n switch (component.type) {\n case \"list\": {\n // If we have any runs in the current line, flush it before starting the list.\n if (curLine.runs.length > 0) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, component.children[0], true, depth + 1);\n } else {\n // If not, we need to apply the indentation for the list to the first line.\n curLine.offsetFromDocument.x = context.textStyleResolver.resolveIndentation(cumulativeOverrides, depth + 1);\n curLine.depth = depth + 1;\n }\n\n // Iterate through each list item, setting the marker and populating its contents.\n component.children.forEach((child, index) => {\n const markerContent = context.textStyleResolver.resolveMarkerText(cumulativeOverrides, index + 1);\n const markerRun = TextRun.create({ content: markerContent });\n curLine.marker = RunLayout.create(markerRun, context, cumulativeOverrides);\n\n curLine = this.populateComponent(child, index, context, docWidth, curLine, component, cumulativeOverrides, depth + 1);\n });\n\n // Lastly flush the line.\n const nextSibling = parent?.children[componentIndex + 1];\n if (curLine && nextSibling) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, nextSibling, true, depth);\n }\n break;\n }\n case \"paragraph\": {\n // Iterate through each paragraph child (either a list or a run), populating its contents.\n component.children.forEach((child, index) => {\n curLine = this.populateComponent(child, index, context, docWidth, curLine, component, cumulativeOverrides, depth);\n });\n\n // Lastly flush the line.\n const nextSibling = parent?.children[componentIndex + 1];\n if (curLine && nextSibling) {\n curLine = this.flushLine(context, curLine, cumulativeOverrides, nextSibling, true, depth);\n }\n break;\n }\n case \"text\":\n case \"field\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n\n // Text can be word-wrapped, so we need to split it into multiple runs if necessary.\n if (docWidth > 0) {\n layout.split(context).forEach(r => { curLine = this.populateRun(curLine, r, context, cumulativeOverrides, docWidth) });\n } else {\n curLine = this.populateRun(curLine, layout, context, cumulativeOverrides, docWidth);\n }\n break;\n }\n case \"fraction\":\n case \"tab\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n curLine = this.populateRun(curLine, layout, context, cumulativeOverrides, docWidth);\n break;\n }\n case \"linebreak\": {\n const layout = RunLayout.create(component, context, cumulativeOverrides);\n\n curLine.append(layout);\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, depth);\n break;\n }\n default: break;\n }\n\n return curLine;\n };\n\n private populateRun(curLine: LineLayout, run: RunLayout, context: LayoutContext, cumulativeOverrides: TextStyleSettingsProps, docWidth: number): LineLayout {\n // If this is a tab, we need to apply the tab shift first, and then we can treat it like a text run.\n applyTabShift(run, curLine, context);\n\n // If our width is not set, then we don't have to compute word wrapping, so just append the run, and continue.\n if (docWidth <= 0) {\n curLine.append(run);\n return curLine;\n }\n\n // If not, we need to determine if we can append this run to the current line without exceeding the document width or if we need to word wrap.\n const runWidth = run.justificationRange?.xLength() ?? run.range.xLength();\n const lineWidth = curLine.runRange.xLength();\n const newWidth = runWidth + lineWidth + curLine.offsetFromDocument.x;\n\n // If true, then no word wrapping is required, so we can append to the current line.\n if (newWidth < docWidth || Geometry.isAlmostEqualNumber(newWidth, docWidth, Geometry.smallMetricDistance)) {\n curLine.append(run);\n return curLine;\n }\n\n // If not, do word wrapping\n if (curLine.runs.length === 0) {\n curLine.append(run);\n\n // Lastly, flush line\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, curLine.depth);\n } else {\n // First, flush line\n curLine = this.flushLine(context, curLine, cumulativeOverrides, undefined, undefined, curLine.depth);\n\n // Recompute tab shift if applicable\n applyTabShift(run, curLine, context);\n\n curLine.append(run);\n }\n\n return curLine;\n };\n\n private flushLine(context: LayoutContext, curLine: LineLayout, cumulativeOverrides: TextStyleSettingsProps, next?: List | Run | Paragraph, newParagraph: boolean = false, depth: number = 0): LineLayout {\n next = next ?? curLine.source;\n\n // We want to guarantee that each layout line has at least one run.\n if (curLine.runs.length === 0) {\n if (this.lines.length === 0 || this._back.runs.length === 0) {\n return new LineLayout(next, cumulativeOverrides, context, depth);\n }\n\n if (curLine.source.type !== \"linebreak\") {\n const newLine = new LineLayout(next, cumulativeOverrides, context, depth);\n newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n return newLine;\n }\n\n const run = curLine.source.clone();\n curLine.append(RunLayout.create(run, context, cumulativeOverrides));\n }\n\n // Line origin is its baseline.\n const lineOffset = { ...curLine.offsetFromDocument }; // Start with the line's original offset, which includes indentation.\n lineOffset.y -= curLine.range.yLength(); // Shift down the baseline\n\n // Place it below any existing lines\n if (this.lines.length > 0) {\n lineOffset.y += this._back.offsetFromDocument.y;\n lineOffset.y -= context.textStyleResolver.blockSettings.lineSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n }\n\n curLine.offsetFromDocument = lineOffset;\n\n // Update document range from computed line range and position\n this.textRange.extendRange(curLine.range.cloneTranslated(lineOffset));\n\n this.lines.push(curLine);\n if (newParagraph) {\n const newLine = new LineLayout(next, cumulativeOverrides, context, depth);\n newLine.offsetFromDocument.y -= context.textStyleResolver.blockSettings.paragraphSpacingFactor * context.textStyleResolver.blockSettings.textHeight;\n return newLine;\n }\n return new LineLayout(next, cumulativeOverrides, context, depth);\n }\n\n private justifyLines(context: LayoutContext): void {\n // We don't want to justify empty text, or a single line of text whose width is 0. By default text is already left justified.\n if (this.lines.length < 1 || (this.lines.length === 1 && this.source.width === 0) || \"left\" === context.textStyleResolver.blockSettings.justification) {\n return;\n }\n\n // This is the minimum width of the document's bounding box.\n const docWidth = this.source.width;\n\n let minOffset = Number.MAX_VALUE;\n for (const line of this.lines) {\n const lineWidth = line.justificationRange.xLength() + line.offsetFromDocument.x;\n\n let offset = docWidth - lineWidth;\n if (\"center\" === context.textStyleResolver.blockSettings.justification) {\n offset = offset / 2;\n }\n\n line.offsetFromDocument.x += offset;\n minOffset = Math.min(offset, minOffset);\n }\n\n if (minOffset < 0) {\n // Shift left to accommodate lines that exceeded the document's minimum width.\n this.textRange.low.x += minOffset;\n this.textRange.high.x += minOffset;\n }\n }\n\n private applyMargins(margins: Required<TextBlockMargins>) {\n this.range = this.textRange.clone();\n\n if (this.range.isNull)\n return;\n\n // Disregard negative margins.\n const right = margins.right >= 0 ? margins.right : 0;\n const left = margins.left >= 0 ? margins.left : 0;\n const top = margins.top >= 0 ? margins.top : 0;\n const bottom = margins.bottom >= 0 ? margins.bottom : 0;\n\n const xHigh = this.textRange.high.x + right;\n const yHigh = this.textRange.high.y + top;\n const xLow = this.textRange.low.x - left;\n const yLow = this.textRange.low.y - bottom;\n\n this.range.extendXY(xHigh, yHigh);\n this.range.extendXY(xLow, yLow);\n }\n}\n"]}
@@ -2,11 +2,12 @@ import { FieldRun, FieldValue, RelationshipProps, TextBlock } from "@itwin/core-
2
2
  import { IModelDb } from "../../IModelDb";
3
3
  import { Id64String } from "@itwin/core-bentley";
4
4
  export interface UpdateFieldsContext {
5
- readonly hostElementId: Id64String;
5
+ readonly hostElementId: Id64String | undefined;
6
6
  getProperty(field: FieldRun): FieldValue | undefined;
7
7
  }
8
- export declare function createUpdateContext(hostElementId: string, iModel: IModelDb, deleted: boolean): UpdateFieldsContext;
8
+ export declare function createUpdateContext(hostElementId: string | undefined, iModel: IModelDb, deleted: boolean): UpdateFieldsContext;
9
9
  export declare function updateField(field: FieldRun, context: UpdateFieldsContext): boolean;
10
10
  export declare function updateFields(textBlock: TextBlock, context: UpdateFieldsContext): number;
11
11
  export declare function updateElementFields(props: RelationshipProps, iModel: IModelDb, deleted: boolean): void;
12
+ export declare function updateAllFields(annotationElementId: Id64String, iModel: IModelDb): void;
12
13
  //# sourceMappingURL=fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/internal/annotations/fields.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0D,QAAQ,EAAE,UAAU,EAAoB,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBAAoB,CAAC;AAC9L,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAmC,UAAU,EAAU,MAAM,qBAAqB,CAAC;AA8B1F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC;IAEnC,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;CACrD;AAsLD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAKlH;AAGD,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAsBlF;AAID,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,GAAG,MAAM,CASvF;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAoBtG"}
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../../src/internal/annotations/fields.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0D,QAAQ,EAAE,UAAU,EAAoB,iBAAiB,EAAE,SAAS,EAA8B,MAAM,oBAAoB,CAAC;AAC9L,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAmC,UAAU,EAAU,MAAM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