@itwin/core-backend 5.4.0-dev.3 → 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 (39) 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/LeaderGeometry.d.ts.map +1 -1
  6. package/lib/cjs/annotations/LeaderGeometry.js +7 -9
  7. package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
  8. package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
  9. package/lib/cjs/annotations/TextAnnotationElement.js +3 -4
  10. package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
  11. package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
  12. package/lib/cjs/annotations/TextBlockLayout.js +2 -1
  13. package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
  14. package/lib/cjs/internal/annotations/fields.d.ts +3 -2
  15. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  16. package/lib/cjs/internal/annotations/fields.js +12 -5
  17. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  18. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +14 -0
  19. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  20. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +33 -20
  21. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  22. package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
  23. package/lib/esm/annotations/LeaderGeometry.js +7 -9
  24. package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
  25. package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
  26. package/lib/esm/annotations/TextAnnotationElement.js +3 -4
  27. package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
  28. package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
  29. package/lib/esm/annotations/TextBlockLayout.js +2 -1
  30. package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
  31. package/lib/esm/internal/annotations/fields.d.ts +3 -2
  32. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  33. package/lib/esm/internal/annotations/fields.js +11 -5
  34. package/lib/esm/internal/annotations/fields.js.map +1 -1
  35. package/lib/esm/test/annotations/LeaderGeometry.test.js +0 -1
  36. package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
  37. package/lib/esm/test/annotations/TextAnnotation.test.js +49 -6
  38. package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
  39. package/package.json +12 -12
@@ -1 +1 @@
1
- {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA8DH,0DAIC;AAhED,oDAAic;AAEjc,wCAAoI;AACpI,sDAA+D;AAC/D,uDAAuE;AACvE,qEAAwE;AACxE,+EAAkI;AAGlI,iCAAiC;AAEjC;;;EAGE;AACW,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC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AAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;QACpD,OAAO,UAAU,CAAC;IACpB,CAAC;IAES,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,OAAkC,EAAE,QAAkC,EAAE,QAAkC;QACjJ,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,+BAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,CAAC;;AAlMH,kDAmMC","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 { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n if (oldData.data.leader) {\n oldData.data.leader.terminatorShape = oldData.data.leader.terminatorShape ?? TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n // Only if something goes wrong, throw an error.\n // throw new Error(`Migration for settings from version ${oldData.version} to ${TEXT_STYLE_SETTINGS_JSON_VERSION} failed.`);\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\n }\n}\n"]}
1
+ {"version":3,"file":"TextAnnotationElement.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationElement.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AA8DH,0DAIC;AAhED,oDAAic;AAEjc,wCAAoI;AACpI,sDAA+D;AAC/D,uDAAuE;AACvE,qEAAwE;AACxE,+EAAkI;AAGlI,iCAAiC;AAEjC;;;EAGE;AACW,QAAA,4BAA4B,GAAG,OAAO,CAAC;AAEpD,SAAS,+BAA+B,CACtC,IAAY,EACZ,cAA+B,EAC/B,OAAqC;IAErC,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAqB,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAEzD,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,C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;IAES,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,OAAkC,EAAE,QAAkC,EAAE,QAAkC;QACjJ,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,+BAAiB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC;YACnE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxF,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtG,CAAC;;AAlMH,kDAmMC","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 { AnnotationTextStyleProps, BisCodeSpec, Code, CodeProps, CodeScopeProps, CodeSpec, ECVersionString, ElementGeometry, ElementGeometryBuilderParams, EntityReferenceSet, Placement2d, Placement2dProps, Placement3d, Placement3dProps, PlacementProps, TextAnnotation, TextAnnotation2dProps, TextAnnotation3dProps, TextAnnotationProps, TextStyleSettings, TextStyleSettingsProps, traverseTextBlockComponent, VersionedJSON } from \"@itwin/core-common\";\nimport { IModelDb } from \"../IModelDb\";\nimport { AnnotationElement2d, DefinitionElement, Drawing, GraphicalElement3d, OnElementIdArg, OnElementPropsArg } from \"../Element\";\nimport { assert, Id64, Id64String } from \"@itwin/core-bentley\";\nimport { layoutTextBlock, TextStyleResolver } from \"./TextBlockLayout\";\nimport { appendTextAnnotationGeometry } from \"./TextAnnotationGeometry\";\nimport { ElementDrivesTextAnnotation, TextAnnotationUsesTextStyleByDefault, TextBlockAndId } from \"./ElementDrivesTextAnnotation\";\nimport { IModelElementCloneContext } from \"../IModelElementCloneContext\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"../Entity\";\nimport * as semver from \"semver\";\n\n/** The version of the JSON stored in `TextAnnotation2d/3dProps.textAnnotationData` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\nexport const TEXT_ANNOTATION_JSON_VERSION = \"1.0.0\";\n\nfunction validateAndMigrateVersionedJSON<T>(\n json: string,\n currentVersion: ECVersionString,\n migrate: (old: VersionedJSON<T>) => T\n): VersionedJSON<T> | undefined {\n let parsed;\n try {\n parsed = JSON.parse(json) as VersionedJSON<T>;\n } catch {\n return undefined;\n }\n\n const version = parsed.version;\n if (typeof version !== \"string\" || !semver.valid(version))\n throw new Error(\"JSON version is missing or invalid.\");\n\n if (typeof parsed.data !== \"object\" || parsed.data === null)\n throw new Error(\"JSON data is missing or invalid.\");\n\n // Newer\n if (semver.gt(version, currentVersion))\n throw new Error(`JSON version ${parsed.version} is newer than supported version ${currentVersion}. Application update required to understand data.`);\n\n // Older\n if (semver.lt(version, currentVersion)) {\n parsed.data = migrate(parsed);\n parsed.version = currentVersion;\n }\n\n return parsed;\n}\n\nfunction migrateTextAnnotationData(oldData: VersionedJSON<TextAnnotationProps>): TextAnnotationProps {\n if (oldData.version === TEXT_ANNOTATION_JSON_VERSION) return oldData.data;\n\n // Place migration logic here.\n\n throw new Error(`Migration for textAnnotationData from version ${oldData.version} to ${TEXT_ANNOTATION_JSON_VERSION} failed.`);\n}\n\n/** Parses, validates, and potentially migrates the text annotation data from a JSON string.\n * @internal\n */\nexport function parseTextAnnotationData(json: string | undefined): VersionedJSON<TextAnnotationProps> | undefined {\n if (!json) return undefined;\n\n return validateAndMigrateVersionedJSON<TextAnnotationProps>(json, TEXT_ANNOTATION_JSON_VERSION, migrateTextAnnotationData);\n}\n\nfunction getElementGeometryBuilderParams(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, _placementProps: PlacementProps, annotationProps?: TextAnnotationProps, textStyleId?: Id64String, _subCategory?: Id64String): ElementGeometryBuilderParams {\n const textBlock = TextAnnotation.fromJSON(annotationProps).textBlock;\n const textStyleResolver = new TextStyleResolver({ textBlock, textStyleId: textStyleId ?? \"\", iModel });\n const layout = layoutTextBlock({ iModel, textBlock, textStyleResolver });\n const builder = new ElementGeometry.Builder();\n let scaleFactor = 1;\n const element = iModel.elements.getElement(modelId);\n if (element instanceof Drawing)\n scaleFactor = element.scaleFactor;\n appendTextAnnotationGeometry({ layout, textStyleResolver, scaleFactor, annotationProps: annotationProps ?? {}, builder, categoryId });\n\n return { entryArray: builder.entries };\n}\n\n/** Arguments supplied when creating a [[TextAnnotation2d]].\n * @beta\n */\nexport interface TextAnnotation2dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement2dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation2d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** Arguments supplied when creating a [[TextAnnotation3d]].\n * @beta\n */\nexport interface TextAnnotation3dCreateArgs {\n /** The category ID for the annotation. */\n category: Id64String;\n /** The model ID where the annotation will be placed. */\n model: Id64String;\n /** The placement properties for the annotation. */\n placement: Placement3dProps;\n /** The default text style ID for the annotation. */\n defaultTextStyleId?: Id64String;\n /** Optional [[TextAnnotation]] JSON representation used to create the `TextAnnotation3d`. Essentially an empty element if not provided. */\n textAnnotationProps?: TextAnnotationProps;\n /** Optional code for the element. */\n code?: CodeProps;\n}\n\n/** An element that displays textual content within a 2d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation2d extends AnnotationElement2d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation2d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation2d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation2d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation2dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation2d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation2dProps, iModel: IModelDb): TextAnnotation2d {\n return new TextAnnotation2d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation2d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation2dProps {\n const props = super.toJSON() as TextAnnotation2dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation2d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation2d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation2dCreateArgs): TextAnnotation2d {\n const elementProps: TextAnnotation2dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on insert and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation2d on update and validates version.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation2dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement2d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation2d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation2d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation2dProps {\n const elProps = super.deserialize(props) as TextAnnotation2dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation2d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation2dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation2dProps, dstProps: TextAnnotation2dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation2d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\n/** An element that displays textual content within a 3d model.\n * The text is stored as a [TextAnnotation]($common) from which the element's [geometry]($docs/learning/common/GeometryStream.md) and [Placement]($common) are computed.\n * @see [[setAnnotation]] to change the textual content.\n * @public @preview\n */\nexport class TextAnnotation3d extends GraphicalElement3d /* implements ITextAnnotation */ {\n /** @internal */\n public static override get className(): string { return \"TextAnnotation3d\"; }\n /**\n * The default [[AnnotationTextStyle]] used by the TextAnnotation3d.\n * @beta\n */\n public defaultTextStyle?: TextAnnotationUsesTextStyleByDefault;\n /** The data associated with the text annotation. */\n private _textAnnotationProps?: TextAnnotationProps;\n\n /** Extract the textual content, if present.\n * @see [[setAnnotation]] to change it.\n */\n public getAnnotation(): TextAnnotation | undefined {\n return this._textAnnotationProps ? TextAnnotation.fromJSON(this._textAnnotationProps) : undefined;\n }\n\n /** Change the textual content of the `TextAnnotation3d`.\n * @see [[getAnnotation]] to extract the current annotation.\n * @param annotation The new annotation\n */\n public setAnnotation(annotation: TextAnnotation) {\n this._textAnnotationProps = annotation.toJSON();\n }\n\n protected constructor(props: TextAnnotation3dProps, iModel: IModelDb) {\n super(props, iModel);\n if (props.defaultTextStyle) {\n this.defaultTextStyle = new TextAnnotationUsesTextStyleByDefault(props.defaultTextStyle.id);\n }\n this._textAnnotationProps = parseTextAnnotationData(props.textAnnotationData)?.data;\n }\n\n /** Creates a new instance of `TextAnnotation3d` from its JSON representation. */\n public static fromJSON(props: TextAnnotation3dProps, iModel: IModelDb): TextAnnotation3d {\n return new TextAnnotation3d(props, iModel);\n }\n\n /**\n * Converts the current `TextAnnotation3d` instance to its JSON representation.\n * It also computes the `elementGeometryBuilderParams` property used to create the GeometryStream.\n * @inheritdoc\n */\n public override toJSON(): TextAnnotation3dProps {\n const props = super.toJSON() as TextAnnotation3dProps;\n props.textAnnotationData = this._textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: this._textAnnotationProps }) : undefined;\n if (this._textAnnotationProps) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(this.iModel, this.model, this.category, this.placement, this._textAnnotationProps, this.defaultTextStyle ? this.defaultTextStyle.id : undefined);\n }\n\n return props;\n }\n\n /** Creates a new `TextAnnotation3d` instance with the specified properties.\n * @param iModelDb The iModel.\n * @param arg The arguments for creating the TextAnnotation3d.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextAnnotation3dCreateArgs): TextAnnotation3d {\n const elementProps: TextAnnotation3dProps = {\n classFullName: this.classFullName,\n textAnnotationData: arg.textAnnotationProps ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: arg.textAnnotationProps }) : undefined,\n defaultTextStyle: arg.defaultTextStyleId ? new TextAnnotationUsesTextStyleByDefault(arg.defaultTextStyleId).toJSON() : undefined,\n placement: arg.placement,\n model: arg.model,\n category: arg.category,\n code: arg.code ?? Code.createEmpty(),\n };\n return new this(elementProps, iModelDb);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on insert and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Updates the geometry of the TextAnnotation3d on update and validates version..\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateVersionAndUpdateGeometry(arg);\n }\n\n /**\n * Populates the `elementGeometryBuilderParams` property in the [TextAnnotation3dProps]($common).\n * Only does this if the `elementGeometryBuilderParams` is not already set and if there is actually a text annotation to produce geometry for.\n * Also, validates the version of the text annotation data and migrates it if necessary.\n * @beta\n */\n protected static validateVersionAndUpdateGeometry(arg: OnElementPropsArg): void {\n const props = arg.props as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.textAnnotationData);\n if (!props.elementGeometryBuilderParams && textAnnotationData) {\n props.elementGeometryBuilderParams = getElementGeometryBuilderParams(arg.iModel, props.model, props.category, props.placement ?? Placement3d.fromJSON(), textAnnotationData.data, props.defaultTextStyle?.id);\n }\n }\n\n /**\n * TextAnnotation3d custom HandledProps include 'textAnnotationData'.\n * @inheritdoc\n * @internal\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"textAnnotationData\", source: \"Class\" },\n ];\n\n /**\n * TextAnnotation3d deserializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): TextAnnotation3dProps {\n const elProps = super.deserialize(props) as TextAnnotation3dProps;\n const textAnnotationData = parseTextAnnotationData(props.row.textAnnotationData);\n if (textAnnotationData) {\n elProps.textAnnotationData = JSON.stringify(textAnnotationData);\n }\n return elProps;\n }\n\n /**\n * TextAnnotation3d serializes 'textAnnotationData'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: TextAnnotation3dProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.textAnnotationData !== undefined) {\n inst.textAnnotationData = props.textAnnotationData;\n }\n return inst;\n }\n\n /** @internal */\n public getTextBlocks(): Iterable<TextBlockAndId> {\n return getTextBlocks(this);\n }\n\n /** @internal */\n public updateTextBlocks(textBlocks: TextBlockAndId[]): void {\n return updateTextBlocks(this, textBlocks);\n }\n\n /** @internal */\n public static override onInserted(arg: OnElementIdArg): void {\n super.onInserted(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n /** @internal */\n public static override onUpdated(arg: OnElementIdArg): void {\n super.onUpdated(arg);\n ElementDrivesTextAnnotation.updateFieldDependencies(arg.id, arg.iModel);\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n collectReferenceIds(this, referenceIds);\n }\n\n /** @internal */\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: TextAnnotation3dProps, dstProps: TextAnnotation3dProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n\n const srcElem = TextAnnotation3d.fromJSON(srcProps, context.sourceDb);\n ElementDrivesTextAnnotation.remapFields(srcElem, context);\n const anno = srcElem.getAnnotation();\n dstProps.textAnnotationData = anno ? JSON.stringify({ version: TEXT_ANNOTATION_JSON_VERSION, data: anno.toJSON() }) : undefined;\n\n return remapTextStyle(context, srcElem, dstProps);\n }\n}\n\nasync function remapTextStyle(\n context: IModelElementCloneContext,\n srcElem: TextAnnotation2d | TextAnnotation3d,\n dstProps: TextAnnotation2dProps | TextAnnotation3dProps\n): Promise<void> {\n const dstStyleId = await AnnotationTextStyle.remapTextStyleId(srcElem.defaultTextStyle?.id ?? Id64.invalid, context);\n dstProps.defaultTextStyle = Id64.isValid(dstStyleId) ? new TextAnnotationUsesTextStyleByDefault(dstStyleId).toJSON() : undefined;\n}\n\nfunction collectReferenceIds(elem: TextAnnotation2d | TextAnnotation3d, referenceIds: EntityReferenceSet): void {\n const style = elem.defaultTextStyle?.id;\n if (style && Id64.isValidId64(style)) {\n referenceIds.addElement(style);\n }\n\n const block = elem.getAnnotation()?.textBlock;\n if (block) {\n for (const { child } of traverseTextBlockComponent(block)) {\n if (child.type === \"field\") {\n const hostId = child.propertyHost.elementId;\n if (Id64.isValidId64(hostId)) {\n referenceIds.addElement(hostId);\n }\n }\n }\n }\n}\n\nfunction getTextBlocks(elem: TextAnnotation2d | TextAnnotation3d): Iterable<TextBlockAndId> {\n const annotation = elem.getAnnotation();\n return annotation ? [{ textBlock: annotation.textBlock, id: undefined }] : [];\n}\n\nfunction updateTextBlocks(elem: TextAnnotation2d | TextAnnotation3d, textBlocks: TextBlockAndId[]): void {\n assert(textBlocks.length === 1);\n assert(textBlocks[0].id === undefined);\n\n const annotation = elem.getAnnotation();\n if (!annotation) {\n // We must obtain the TextBlockAndId from the element in the first place, so the only way we could end up here is if\n // somebody removed the text annotation after we called getTextBlocks. That's gotta be a mistake.\n throw new Error(\"Text annotation element has no text\");\n }\n\n annotation.textBlock = textBlocks[0].textBlock;\n\n elem.setAnnotation(annotation);\n}\n\n/** The version of the JSON stored in `AnnotationTextStyleProps.settings` used by the code.\n * Uses the same semantics as [ECVersion]($ecschema-metadata).\n * @internal\n*/\n// 1.0.1 - Added terminatorShapes for leaders\nexport const TEXT_STYLE_SETTINGS_JSON_VERSION = \"1.0.1\";\n\nfunction migrateTextStyleSettings(oldData: VersionedJSON<TextStyleSettingsProps>): TextStyleSettingsProps {\n if (oldData.version === TEXT_STYLE_SETTINGS_JSON_VERSION) return oldData.data;\n\n // Migrate from 1.0.0 to 1.0.1\n if (oldData.data.leader && !oldData.data.leader.terminatorShape) {\n oldData.data.leader.terminatorShape = TextStyleSettings.defaultProps.leader.terminatorShape;\n }\n return oldData.data;\n\n}\n\n/** Arguments supplied when creating an [[AnnotationTextStyle]].\n * @beta\n */\nexport interface TextStyleCreateArgs {\n /** The ID of the [[DefinitionModel]]. */\n definitionModelId: Id64String;\n /** The name to assign to the [[AnnotationTextStyle]]. */\n name: string;\n /** Optional text style settings used to create the [[AnnotationTextStyle]]. Default settings will be used if not provided. */\n settings?: TextStyleSettingsProps;\n /** Optional description for the [[AnnotationTextStyle]]. */\n description?: string;\n}\n\n/**\n * The definition element that holds text style information.\n * The style is stored as a [TextStyleSettings]($common).\n * @beta\n */\nexport class AnnotationTextStyle extends DefinitionElement {\n /** @internal */\n public static override get className(): string { return \"AnnotationTextStyle\"; }\n /**\n * Optional text describing the `AnnotationTextStyle`.\n */\n public description?: string;\n /**\n * The text style settings for the `AnnotationTextStyle`.\n * @see [[TextStyleSettings]] for more information.\n */\n public settings: TextStyleSettings;\n\n protected constructor(props: AnnotationTextStyleProps, iModel: IModelDb) {\n super(props, iModel);\n this.description = props.description;\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n this.settings = TextStyleSettings.fromJSON(settingsProps?.data);\n }\n\n /**\n * Creates a Code for an `AnnotationTextStyle` given a name that is meant to be unique within the scope of the specified DefinitionModel.\n *\n * @param iModel - The IModelDb.\n * @param definitionModelId - The ID of the DefinitionModel that contains the AnnotationTextStyle and provides the scope for its name.\n * @param name - The AnnotationTextStyle name.\n * @beta\n */\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.annotationTextStyle);\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\n }\n\n /**\n * Creates a new instance of `AnnotationTextStyle` with the specified properties.\n *\n * @param iModelDb - The iModelDb.\n * @param arg - The arguments for creating the AnnotationTextStyle.\n * @beta\n */\n public static create(iModelDb: IModelDb, arg: TextStyleCreateArgs): AnnotationTextStyle {\n const props: AnnotationTextStyleProps = {\n classFullName: this.classFullName,\n model: arg.definitionModelId,\n code: this.createCode(iModelDb, arg.definitionModelId, arg.name).toJSON(),\n description: arg.description,\n settings: arg.settings ? JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: arg.settings }) : undefined,\n }\n return new this(props, iModelDb);\n }\n\n /**\n * Converts the current `AnnotationTextStyle` instance to its JSON representation.\n * @inheritdoc\n */\n public override toJSON(): AnnotationTextStyleProps {\n const props = super.toJSON() as AnnotationTextStyleProps;\n props.description = this.description;\n props.settings = JSON.stringify({ version: TEXT_STYLE_SETTINGS_JSON_VERSION, data: this.settings.toJSON() });\n return props;\n }\n\n /** Creates a new instance of `AnnotationTextStyle` from its JSON representation. */\n public static fromJSON(props: AnnotationTextStyleProps, iModel: IModelDb): AnnotationTextStyle {\n return new AnnotationTextStyle(props, iModel);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before insert.\n * @inheritdoc\n * @beta\n */\n protected static override onInsert(arg: OnElementPropsArg): void {\n super.onInsert(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n /**\n * Validates that the AnnotationTextStyle's settings are valid before update.\n * @inheritdoc\n * @beta\n */\n protected static override onUpdate(arg: OnElementPropsArg): void {\n super.onUpdate(arg);\n this.validateSettings(arg.props as AnnotationTextStyleProps);\n }\n\n private static validateSettings(props: AnnotationTextStyleProps): void {\n const settingProps = AnnotationTextStyle.parseTextStyleSettings(props.settings);\n if (!settingProps) return;\n const settings = TextStyleSettings.fromJSON(settingProps.data);\n const errors = settings.getValidationErrors();\n if (errors.length > 0) {\n throw new Error(`Invalid AnnotationTextStyle settings: ${errors.join(\", \")}`);\n }\n }\n\n /**\n * AnnotationTextStyle custom HandledProps include 'settings'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"settings\", source: \"Class\" },\n ];\n\n /**\n * AnnotationTextStyle deserializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): AnnotationTextStyleProps {\n const elProps = super.deserialize(props) as AnnotationTextStyleProps;\n const settings = this.parseTextStyleSettings(props.row.settings);\n if (settings) {\n elProps.settings = JSON.stringify(settings);\n }\n return elProps;\n }\n\n /**\n * AnnotationTextStyle serializes 'settings'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: AnnotationTextStyleProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.settings !== undefined) {\n inst.settings = props.settings;\n }\n return inst;\n }\n\n /** Parses, validates, and potentially migrates the text style settings data from a JSON string. */\n private static parseTextStyleSettings(json: string | undefined): VersionedJSON<TextStyleSettingsProps> | undefined {\n if (!json) return undefined;\n return validateAndMigrateVersionedJSON<TextStyleSettingsProps>(json, TEXT_STYLE_SETTINGS_JSON_VERSION, migrateTextStyleSettings);\n }\n\n /** When copying an element from one iModel to another, returns the Id of the AnnotationTextStyle in the `context`'s target iModel\n * corresponding to `sourceTextStyleId`, or [Id64.invalid]($bentley) if no corresponding text style exists.\n * If a text style with the same [Code]($common) exists in the target iModel, the style Id will be remapped to refer to that style.\n * Otherwise, a copy of the style will be imported into the target iModel and its element Id returned.\n * Implementations of [[ITextAnnotation]] should invoke this function when implementing their [[Element.onCloned]] method.\n * @throws Error if an attempt to import the text style failed.\n */\n public static async remapTextStyleId(sourceTextStyleId: Id64String, context: IModelElementCloneContext): Promise<Id64String> {\n // No remapping necessary if there's no text style or we're not copying to a different iModel.\n if (!Id64.isValid(sourceTextStyleId) || !context.isBetweenIModels) {\n return sourceTextStyleId;\n }\n\n // If the style's already been remapped, we're finished.\n let dstStyleId: Id64String | undefined = context.findTargetElementId(sourceTextStyleId);\n if (Id64.isValid(dstStyleId)) {\n return dstStyleId;\n }\n\n // Look up the style. It really ought to exist.\n const srcStyle = context.sourceDb.elements.tryGetElement<AnnotationTextStyle>(sourceTextStyleId);\n if (!srcStyle) {\n return Id64.invalid;\n }\n\n // If a style with the same code exists in the target iModel, remap to that one.\n dstStyleId = context.targetDb.elements.queryElementIdByCode(srcStyle.code);\n if (undefined !== dstStyleId) {\n return dstStyleId;\n }\n\n // Copy the style into the target iModel and remap its Id.\n const dstStyleProps = await context.cloneElement(srcStyle);\n dstStyleId = context.targetDb.elements.insertElement(dstStyleProps);\n context.remapElement(sourceTextStyleId, dstStyleId);\n return dstStyleId;\n }\n\n protected static override async onCloned(context: IModelElementCloneContext, srcProps: AnnotationTextStyleProps, dstProps: AnnotationTextStyleProps): Promise<void> {\n await super.onCloned(context, srcProps, dstProps);\n if (!context.isBetweenIModels) {\n return;\n }\n\n const settingsProps = AnnotationTextStyle.parseTextStyleSettings(srcProps.settings);\n const font = TextStyleSettings.fromJSON(settingsProps?.data).font;\n\n const fontsToEmbed = [];\n for (const file of context.sourceDb.fonts.queryEmbeddedFontFiles()) {\n if (file.type === font.type && file.faces.some((face) => face.familyName === font.name)) {\n fontsToEmbed.push(file);\n }\n }\n\n await Promise.all(fontsToEmbed.map(async (file) => context.targetDb.fonts.embedFontFile({ file })));\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,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;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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,SAAS,iBAAiB,CAAC,EAAc;QAC9C,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAsB,EAAE,CAAC,CAAC;QACnF,IAAI,mBAAmB,IAAI,mBAAmB,YAAY,2CAAmB,EAAE,CAAC;YAC9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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,IAAI,mBAAmB,IAAI,mBAAmB,YAAY,2CAAmB,EAAE,CAAC;YAC9E,OAAO,mBAAmB,CAAC,QAAQ,CAAC;QACtC,CAAC;QAED,OAAO,+BAAiB,CAAC,QAAQ,EAAE,CAAC;IACtC,CAAC,CAAC;AACJ,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ClC,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"]}