@itwin/core-backend 5.1.0-dev.3 → 5.1.0-dev.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts +10 -2
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +12 -0
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CatalogDb.js.map +1 -1
- package/lib/cjs/Category.d.ts +41 -4
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +77 -4
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +2 -2
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +242 -242
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.js +5 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.js +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.d.ts +1 -1
- package/lib/cjs/CodeSpecs.js +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +9 -4
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +30 -3
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +216 -60
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +560 -59
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +7 -7
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +7 -7
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.d.ts +43 -3
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +59 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.d.ts +54 -8
- package/lib/cjs/ExportGraphics.d.ts.map +1 -1
- package/lib/cjs/ExportGraphics.js +158 -59
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/FontFile.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.d.ts +6 -2
- package/lib/cjs/GeographicCRSServices.d.ts.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +1 -1
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.js +47 -47
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +28 -43
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +177 -92
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelDbFonts.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +13 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +6 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/ImageSourceConversion.js.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.js +1 -1
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.js.map +1 -1
- package/lib/cjs/Material.d.ts +19 -0
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +29 -0
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +64 -28
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +115 -27
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SheetIndex.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/Texture.d.ts +1 -1
- package/lib/cjs/Texture.js +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +4 -4
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +2 -1
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +140 -14
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +250 -14
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js +3 -3
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/annotations/FrameGeometry.d.ts +52 -0
- package/lib/cjs/annotations/FrameGeometry.d.ts.map +1 -0
- package/lib/cjs/annotations/FrameGeometry.js +250 -0
- package/lib/cjs/annotations/FrameGeometry.js.map +1 -0
- package/lib/cjs/{TextAnnotationElement.d.ts → annotations/TextAnnotationElement.d.ts} +6 -11
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -0
- package/lib/cjs/{TextAnnotationElement.js → annotations/TextAnnotationElement.js} +20 -26
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -0
- package/lib/cjs/annotations/TextAnnotationGeometry.d.ts +31 -0
- package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -0
- package/lib/cjs/annotations/TextAnnotationGeometry.js +83 -0
- package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -0
- package/lib/cjs/annotations/TextBlockGeometry.d.ts +16 -0
- package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -0
- package/lib/cjs/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +11 -68
- package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -0
- package/lib/cjs/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +19 -7
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -0
- package/lib/cjs/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +19 -7
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -0
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.d.ts +5 -3
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +5 -6
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
- package/lib/cjs/internal/ElementLRUCache.d.ts +28 -0
- package/lib/cjs/internal/ElementLRUCache.d.ts.map +1 -0
- package/lib/cjs/internal/ElementLRUCache.js +120 -0
- package/lib/cjs/internal/ElementLRUCache.js.map +1 -0
- package/lib/cjs/internal/FontFileImpl.js.map +1 -1
- package/lib/cjs/internal/HubMock.js.map +1 -1
- package/lib/cjs/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/cjs/internal/NativePlatform.js.map +1 -1
- package/lib/cjs/internal/NoLocks.js.map +1 -1
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -1
- package/lib/cjs/internal/Symbols.d.ts +1 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -1
- package/lib/cjs/internal/Symbols.js +2 -1
- package/lib/cjs/internal/Symbols.js.map +1 -1
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +2 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/lib/esm/BackendHubAccess.js.map +1 -1
- package/lib/esm/BackendLoggerCategory.js.map +1 -1
- package/lib/esm/BisCoreSchema.js +1 -1
- package/lib/esm/BisCoreSchema.js.map +1 -1
- package/lib/esm/BlobContainerService.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +10 -2
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +12 -0
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/CatalogDb.js.map +1 -1
- package/lib/esm/Category.d.ts +41 -4
- package/lib/esm/Category.d.ts.map +1 -1
- package/lib/esm/Category.js +77 -4
- package/lib/esm/Category.js.map +1 -1
- package/lib/esm/ChangeSummaryManager.js +2 -2
- package/lib/esm/ChangeSummaryManager.js.map +1 -1
- package/lib/esm/ChangedElementsDb.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +242 -242
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/ChannelControl.js.map +1 -1
- package/lib/esm/CheckpointManager.js.map +1 -1
- package/lib/esm/ClassRegistry.js +5 -5
- package/lib/esm/ClassRegistry.js.map +1 -1
- package/lib/esm/CloudSqlite.js +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/CodeService.js.map +1 -1
- package/lib/esm/CodeSpecs.d.ts +1 -1
- package/lib/esm/CodeSpecs.js +1 -1
- package/lib/esm/CodeSpecs.js.map +1 -1
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/CustomViewState3dCreator.js.map +1 -1
- package/lib/esm/DevTools.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +9 -4
- package/lib/esm/DisplayStyle.d.ts.map +1 -1
- package/lib/esm/DisplayStyle.js +30 -3
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSchemaXmlContext.js.map +1 -1
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/Element.d.ts +216 -60
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +563 -62
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +7 -7
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +7 -7
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/ElementGraphics.js.map +1 -1
- package/lib/esm/ElementTreeWalker.js.map +1 -1
- package/lib/esm/Entity.d.ts +43 -3
- package/lib/esm/Entity.d.ts.map +1 -1
- package/lib/esm/Entity.js +59 -1
- package/lib/esm/Entity.js.map +1 -1
- package/lib/esm/EntityReferences.js.map +1 -1
- package/lib/esm/ExportGraphics.d.ts +54 -8
- package/lib/esm/ExportGraphics.d.ts.map +1 -1
- package/lib/esm/ExportGraphics.js +156 -58
- package/lib/esm/ExportGraphics.js.map +1 -1
- package/lib/esm/ExternalSource.js.map +1 -1
- package/lib/esm/FontFile.js.map +1 -1
- package/lib/esm/GeoCoordConfig.js.map +1 -1
- package/lib/esm/GeographicCRSServices.d.ts +6 -2
- package/lib/esm/GeographicCRSServices.d.ts.map +1 -1
- package/lib/esm/GeographicCRSServices.js +1 -1
- package/lib/esm/GeographicCRSServices.js.map +1 -1
- package/lib/esm/GeometrySummary.js +47 -47
- package/lib/esm/GeometrySummary.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +28 -43
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +180 -95
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelDbFonts.js.map +1 -1
- package/lib/esm/IModelElementCloneContext.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +13 -0
- package/lib/esm/IModelHost.d.ts.map +1 -1
- package/lib/esm/IModelHost.js +6 -0
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/IModelJsFs.js.map +1 -1
- package/lib/esm/ImageSourceConversion.js.map +1 -1
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/LineStyle.js.map +1 -1
- package/lib/esm/LocalHub.js +1 -1
- package/lib/esm/LocalHub.js.map +1 -1
- package/lib/esm/LocalhostIpcHost.js.map +1 -1
- package/lib/esm/LockControl.js.map +1 -1
- package/lib/esm/Material.d.ts +19 -0
- package/lib/esm/Material.d.ts.map +1 -1
- package/lib/esm/Material.js +30 -1
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/Model.d.ts +64 -28
- package/lib/esm/Model.d.ts.map +1 -1
- package/lib/esm/Model.js +116 -28
- package/lib/esm/Model.js.map +1 -1
- package/lib/esm/NativeAppStorage.js.map +1 -1
- package/lib/esm/NativeHost.js.map +1 -1
- package/lib/esm/NavigationRelationship.js.map +1 -1
- package/lib/esm/PromiseMemoizer.js.map +1 -1
- package/lib/esm/PropertyStore.js.map +1 -1
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/RpcBackend.js.map +1 -1
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/Schema.js.map +1 -1
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SchemaUtils.js.map +1 -1
- package/lib/esm/SheetIndex.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/SqliteStatement.js.map +1 -1
- package/lib/esm/Texture.d.ts +1 -1
- package/lib/esm/Texture.js +1 -1
- package/lib/esm/Texture.js.map +1 -1
- package/lib/esm/TileStorage.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +4 -4
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +2 -1
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +140 -14
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +251 -15
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/ViewStateHydrator.js +3 -3
- package/lib/esm/ViewStateHydrator.js.map +1 -1
- package/lib/esm/ViewStore.js.map +1 -1
- package/lib/esm/annotations/FrameGeometry.d.ts +52 -0
- package/lib/esm/annotations/FrameGeometry.d.ts.map +1 -0
- package/lib/esm/annotations/FrameGeometry.js +245 -0
- package/lib/esm/annotations/FrameGeometry.js.map +1 -0
- package/lib/esm/{TextAnnotationElement.d.ts → annotations/TextAnnotationElement.d.ts} +6 -11
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -0
- package/lib/esm/{TextAnnotationElement.js → annotations/TextAnnotationElement.js} +22 -28
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -0
- package/lib/esm/annotations/TextAnnotationGeometry.d.ts +31 -0
- package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -0
- package/lib/esm/annotations/TextAnnotationGeometry.js +80 -0
- package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -0
- package/lib/esm/annotations/TextBlockGeometry.d.ts +16 -0
- package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -0
- package/lib/esm/{TextAnnotationGeometry.js → annotations/TextBlockGeometry.js} +11 -68
- package/lib/esm/annotations/TextBlockGeometry.js.map +1 -0
- package/lib/esm/{TextAnnotationLayout.d.ts → annotations/TextBlockLayout.d.ts} +19 -7
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -0
- package/lib/esm/{TextAnnotationLayout.js → annotations/TextBlockLayout.js} +19 -7
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -0
- package/lib/esm/core-backend.d.ts +5 -3
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +5 -3
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/domains/FunctionalElements.js.map +1 -1
- package/lib/esm/domains/FunctionalSchema.js.map +1 -1
- package/lib/esm/domains/GenericElements.js.map +1 -1
- package/lib/esm/domains/GenericSchema.js.map +1 -1
- package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/esm/internal/ChannelAdmin.js.map +1 -1
- package/lib/esm/internal/ElementLRUCache.d.ts +28 -0
- package/lib/esm/internal/ElementLRUCache.d.ts.map +1 -0
- package/lib/esm/internal/ElementLRUCache.js +116 -0
- package/lib/esm/internal/ElementLRUCache.js.map +1 -0
- package/lib/esm/internal/FontFileImpl.js.map +1 -1
- package/lib/esm/internal/HubMock.js.map +1 -1
- package/lib/esm/internal/IModelDbFontsImpl.js.map +1 -1
- package/lib/esm/internal/NativePlatform.js.map +1 -1
- package/lib/esm/internal/NoLocks.js.map +1 -1
- package/lib/esm/internal/ServerBasedLocks.js.map +1 -1
- package/lib/esm/internal/Symbols.d.ts +1 -0
- package/lib/esm/internal/Symbols.d.ts.map +1 -1
- package/lib/esm/internal/Symbols.js +1 -0
- package/lib/esm/internal/Symbols.js.map +1 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/esm/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/esm/rpc/multipart.js.map +1 -1
- package/lib/esm/rpc/tracing.js.map +1 -1
- package/lib/esm/rpc/web/logging.js.map +1 -1
- package/lib/esm/rpc/web/request.js.map +1 -1
- package/lib/esm/rpc/web/response.js.map +1 -1
- package/lib/esm/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js +2 -2
- package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/esm/test/AdvancedEqual.js.map +1 -1
- package/lib/esm/test/AttachDb.test.js +11 -11
- package/lib/esm/test/AttachDb.test.js.map +1 -1
- package/lib/esm/test/ElementLRUCache.test.d.ts +2 -0
- package/lib/esm/test/ElementLRUCache.test.d.ts.map +1 -0
- package/lib/esm/test/ElementLRUCache.test.js +212 -0
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -0
- package/lib/esm/test/GeometryTestUtil.js.map +1 -1
- package/lib/esm/test/IModelHost.test.js.map +1 -1
- package/lib/esm/test/IModelTestUtils.js.map +1 -1
- package/lib/esm/test/ImageSourceConversion.test.js.map +1 -1
- package/lib/esm/test/IpcHost.test.js.map +1 -1
- package/lib/esm/test/KnownTestLocations.js.map +1 -1
- package/lib/esm/test/PrintElementTree.js.map +1 -1
- package/lib/esm/test/PropertyDb.test.js.map +1 -1
- package/lib/esm/test/RevisionUtility.js.map +1 -1
- package/lib/esm/test/SchemaUtils.test.js +25 -25
- package/lib/esm/test/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/SequentialLogMatcher.js.map +1 -1
- package/lib/esm/test/TestChangeSetUtility.js.map +1 -1
- package/lib/esm/test/TestUtils.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +190 -1025
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.d.ts +2 -0
- package/lib/esm/test/annotations/TextBlock.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/TextBlock.test.js +969 -0
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -0
- package/lib/esm/test/categories/Category.test.js.map +1 -1
- package/lib/esm/test/codespec/CodeSpec.test.js.map +1 -1
- package/lib/esm/test/ecdb/CTE.test.js +88 -88
- package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +15 -15
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +86 -65
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDbTestHelper.js.map +1 -1
- package/lib/esm/test/ecdb/ECSchemaXmlContext.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +65 -65
- package/lib/esm/test/ecdb/ECSqlAst.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +7 -30
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +16 -16
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +292 -292
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/ecdb/SqliteStatement.test.js.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js +21 -21
- package/lib/esm/test/ecsql/src/ECSqlTestGenerator.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/element/DeleteDefinitionElements.test.js.map +1 -1
- package/lib/esm/test/element/ElementAspect.test.js +22 -22
- package/lib/esm/test/element/ElementAspect.test.js.map +1 -1
- package/lib/esm/test/element/ElementDependencyGraph.test.js.map +1 -1
- package/lib/esm/test/element/ElementRoundTrip.test.js +139 -139
- package/lib/esm/test/element/ElementRoundTrip.test.js.map +1 -1
- package/lib/esm/test/element/ExcludedElements.test.js.map +1 -1
- package/lib/esm/test/element/ExternalSource.test.js.map +1 -1
- package/lib/esm/test/element/NullStructArray.test.js +13 -13
- package/lib/esm/test/element/NullStructArray.test.js.map +1 -1
- package/lib/esm/test/element/UrlLink.test.js.map +1 -1
- package/lib/esm/test/font/FontFile.test.js.map +1 -1
- package/lib/esm/test/font/IModelDbFonts.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/hubaccess/CheckpointManager.test.js.map +1 -1
- package/lib/esm/test/imageData.js.map +1 -1
- package/lib/esm/test/imodel/ElementTreeWalker.test.js.map +1 -1
- package/lib/esm/test/imodel/GetTextureImage.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +68 -16
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/imodel/ProjectExtents.test.js.map +1 -1
- package/lib/esm/test/imodel/SchemaXmlImport.test.js.map +1 -1
- package/lib/esm/test/index.js.map +1 -1
- package/lib/esm/test/misc/DevTools.test.js.map +1 -1
- package/lib/esm/test/misc/EntitySubClasses.test.js.map +1 -1
- package/lib/esm/test/misc/GeoServices.test.js +23 -9
- package/lib/esm/test/misc/GeoServices.test.js.map +1 -1
- package/lib/esm/test/misc/PromiseMemoizer.test.js.map +1 -1
- package/lib/esm/test/native/DgnDbWorker.test.js.map +1 -1
- package/lib/esm/test/rpc/response.test.js.map +1 -1
- package/lib/esm/test/schema/ClassRegistry.test.js +71 -71
- package/lib/esm/test/schema/ClassRegistry.test.js.map +1 -1
- package/lib/esm/test/schema/FunctionalDomain.test.js.map +1 -1
- package/lib/esm/test/schema/GenericDomain.test.js.map +1 -1
- package/lib/esm/test/schema/IModelSchemaContext.test.js.map +1 -1
- package/lib/esm/test/sheetindex/SheetIndex.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +28 -28
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/CustomViewState3dCreator.test.js.map +1 -1
- package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
- package/lib/esm/test/standalone/Drawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementMesh.test.js.map +1 -1
- package/lib/esm/test/standalone/ExportGraphics.test.js +67 -15
- package/lib/esm/test/standalone/ExportGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryChangeEvents.test.js.map +1 -1
- package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
- package/lib/esm/test/standalone/HubMock.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelLimits.test.d.ts +2 -0
- package/lib/esm/test/standalone/IModelLimits.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/IModelLimits.test.js +103 -0
- package/lib/esm/test/standalone/IModelLimits.test.js.map +1 -0
- package/lib/esm/test/standalone/IModelWrite.test.js +27 -27
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/InlineGeometryPartReferences.test.js.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/NativeAppStorage.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/lib/esm/test/standalone/SchemaUtils.test.js.map +1 -1
- package/lib/esm/test/standalone/SectionDrawing.test.js.map +1 -1
- package/lib/esm/test/standalone/ServerBasedLocks.test.js.map +1 -1
- package/lib/esm/test/standalone/Setting.test.js.map +1 -1
- package/lib/esm/test/standalone/Settings.test.js.map +1 -1
- package/lib/esm/test/standalone/SettingsSchemas.test.js.map +1 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js +20 -1
- package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Texture.test.js.map +1 -1
- package/lib/esm/test/standalone/TileCache.test.js.map +1 -1
- package/lib/esm/test/standalone/TileTree.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewDefinition.test.js.map +1 -1
- package/lib/esm/test/standalone/ViewStoreDb.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/workspace/Settings.js.map +1 -1
- package/lib/esm/workspace/SettingsSchemas.js.map +1 -1
- package/lib/esm/workspace/Workspace.js.map +1 -1
- package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +12 -12
- package/lib/cjs/TextAnnotationElement.d.ts.map +0 -1
- package/lib/cjs/TextAnnotationElement.js.map +0 -1
- package/lib/cjs/TextAnnotationGeometry.d.ts +0 -32
- package/lib/cjs/TextAnnotationGeometry.d.ts.map +0 -1
- package/lib/cjs/TextAnnotationGeometry.js.map +0 -1
- package/lib/cjs/TextAnnotationLayout.d.ts.map +0 -1
- package/lib/cjs/TextAnnotationLayout.js.map +0 -1
- package/lib/esm/TextAnnotationElement.d.ts.map +0 -1
- package/lib/esm/TextAnnotationElement.js.map +0 -1
- package/lib/esm/TextAnnotationGeometry.d.ts +0 -32
- package/lib/esm/TextAnnotationGeometry.d.ts.map +0 -1
- package/lib/esm/TextAnnotationGeometry.js.map +0 -1
- package/lib/esm/TextAnnotationLayout.d.ts.map +0 -1
- package/lib/esm/TextAnnotationLayout.js.map +0 -1
|
@@ -2,987 +2,33 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { TextAnnotation2d, TextAnnotation3d } from "../../TextAnnotationElement";
|
|
10
|
-
import { produceTextAnnotationGeometry } from "../../TextAnnotationGeometry";
|
|
5
|
+
import { expect } from "chai";
|
|
6
|
+
import { Angle, Point3d, Range2d, Range3d, YawPitchRollAngles } from "@itwin/core-geometry";
|
|
7
|
+
import { Code, ColorDef, FractionRun, SubCategoryAppearance, TextAnnotation, TextBlock, TextRun } from "@itwin/core-common";
|
|
8
|
+
import { StandaloneDb } from "../../IModelDb";
|
|
9
|
+
import { TextAnnotation2d, TextAnnotation3d } from "../../annotations/TextAnnotationElement";
|
|
11
10
|
import { IModelTestUtils } from "../IModelTestUtils";
|
|
12
|
-
import {
|
|
11
|
+
import { Subject } from "../../Element";
|
|
12
|
+
import { Guid, Id64 } from "@itwin/core-bentley";
|
|
13
|
+
import { DefinitionModel } from "../../Model";
|
|
14
|
+
import { DrawingCategory, SpatialCategory } from "../../Category";
|
|
15
|
+
import { DisplayStyle2d, DisplayStyle3d } from "../../DisplayStyle";
|
|
16
|
+
import { CategorySelector, DrawingViewDefinition, ModelSelector, SpatialViewDefinition } from "../../ViewDefinition";
|
|
17
|
+
import { FontFile } from "../../FontFile";
|
|
13
18
|
function computeTextRangeAsStringLength(args) {
|
|
14
19
|
const range = new Range2d(0, 0, args.chars.length, args.lineHeight);
|
|
15
20
|
return { layout: range, justification: range };
|
|
16
21
|
}
|
|
17
|
-
function doLayout(textBlock, args) {
|
|
18
|
-
const layout = layoutTextBlock({
|
|
19
|
-
textBlock,
|
|
20
|
-
iModel: {},
|
|
21
|
-
findTextStyle: args?.findTextStyle ?? (() => TextStyleSettings.defaults),
|
|
22
|
-
findFontId: args?.findFontId ?? (() => 0),
|
|
23
|
-
computeTextRange: args?.computeTextRange ?? computeTextRangeAsStringLength,
|
|
24
|
-
});
|
|
25
|
-
return layout;
|
|
26
|
-
}
|
|
27
|
-
function makeTextRun(content, styleName = "") {
|
|
28
|
-
return TextRun.create({ content, styleName });
|
|
29
|
-
}
|
|
30
|
-
function isIntlSupported() {
|
|
31
|
-
// Node in the mobile add-on does not include Intl, so this test fails. Right now, mobile
|
|
32
|
-
// users are not expected to do any editing, but long term we will attempt to find a better
|
|
33
|
-
// solution.
|
|
34
|
-
return !ProcessDetector.isMobileAppBackend;
|
|
35
|
-
}
|
|
36
|
-
describe("layoutTextBlock", () => {
|
|
37
|
-
it("resolves TextStyleSettings from combination of TextBlock and Run", () => {
|
|
38
|
-
const textBlock = TextBlock.create({ styleName: "block", styleOverrides: { widthFactor: 34, color: 0x00ff00 } });
|
|
39
|
-
const run0 = TextRun.create({ content: "run0", styleName: "run", styleOverrides: { lineHeight: 56, color: 0xff0000 } });
|
|
40
|
-
const run1 = TextRun.create({ content: "run1", styleName: "run", styleOverrides: { widthFactor: 78, fontName: "run1" } });
|
|
41
|
-
textBlock.appendRun(run0);
|
|
42
|
-
textBlock.appendRun(run1);
|
|
43
|
-
const tb = doLayout(textBlock, {
|
|
44
|
-
findTextStyle: (name) => TextStyleSettings.fromJSON(name === "block" ? { lineSpacingFactor: 12, fontName: "block" } : { lineSpacingFactor: 99, fontName: "run" }),
|
|
45
|
-
});
|
|
46
|
-
expect(tb.lines.length).to.equal(1);
|
|
47
|
-
expect(tb.lines[0].runs.length).to.equal(2);
|
|
48
|
-
const s0 = tb.lines[0].runs[0].style;
|
|
49
|
-
expect(s0.lineHeight).to.equal(1);
|
|
50
|
-
expect(s0.lineSpacingFactor).to.equal(12);
|
|
51
|
-
expect(s0.widthFactor).to.equal(34);
|
|
52
|
-
expect(s0.fontName).to.equal("run");
|
|
53
|
-
expect(s0.color).to.equal(0xff0000);
|
|
54
|
-
const s1 = tb.lines[0].runs[1].style;
|
|
55
|
-
expect(s1.widthFactor).to.equal(34);
|
|
56
|
-
expect(s1.lineSpacingFactor).to.equal(12);
|
|
57
|
-
expect(s1.lineHeight).to.equal(1);
|
|
58
|
-
expect(s1.fontName).to.equal("run1");
|
|
59
|
-
expect(s1.color).to.equal("subcategory");
|
|
60
|
-
});
|
|
61
|
-
it("aligns text to center based on height of stacked fraction", () => {
|
|
62
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
63
|
-
const fractionRun = FractionRun.create({ numerator: "1", denominator: "2", styleName: "fraction" });
|
|
64
|
-
const textRun = TextRun.create({ content: "text", styleName: "text" });
|
|
65
|
-
textBlock.appendRun(fractionRun);
|
|
66
|
-
textBlock.appendRun(textRun);
|
|
67
|
-
const layout = doLayout(textBlock);
|
|
68
|
-
const fractionLayout = layout.lines[0].runs[0];
|
|
69
|
-
const textLayout = layout.lines[0].runs[1];
|
|
70
|
-
const round = (num, numDecimalPlaces) => {
|
|
71
|
-
const mult = Math.pow(100, numDecimalPlaces);
|
|
72
|
-
return Math.round(num * mult) / mult;
|
|
73
|
-
};
|
|
74
|
-
expect(textLayout.range.yLength()).to.equal(1);
|
|
75
|
-
expect(round(fractionLayout.range.yLength(), 2)).to.equal(1.75);
|
|
76
|
-
expect(fractionLayout.offsetFromLine.y).to.equal(0);
|
|
77
|
-
expect(round(textLayout.offsetFromLine.y, 3)).to.equal(.375);
|
|
78
|
-
});
|
|
79
|
-
it("produces one line per paragraph if document width <= 0", () => {
|
|
80
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
81
|
-
for (let i = 0; i < 4; i++) {
|
|
82
|
-
const layout = doLayout(textBlock);
|
|
83
|
-
if (i === 0) {
|
|
84
|
-
expect(layout.range.isNull).to.be.true;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
expect(layout.lines.length).to.equal(i);
|
|
88
|
-
expect(layout.range.low.x).to.equal(0);
|
|
89
|
-
expect(layout.range.low.y).to.equal(-i - (0.5 * (i - 1))); // lineSpacingFactor=0.5
|
|
90
|
-
expect(layout.range.high.x).to.equal(i * 3);
|
|
91
|
-
expect(layout.range.high.y).to.equal(0);
|
|
92
|
-
}
|
|
93
|
-
for (let l = 0; l < layout.lines.length; l++) {
|
|
94
|
-
const line = layout.lines[l];
|
|
95
|
-
expect(line.runs.length).to.equal(l + 1);
|
|
96
|
-
expect(line.range.low.x).to.equal(0);
|
|
97
|
-
expect(line.range.low.y).to.equal(0);
|
|
98
|
-
expect(line.range.high.y).to.equal(1);
|
|
99
|
-
expect(line.range.high.x).to.equal(3 * (l + 1));
|
|
100
|
-
for (const run of line.runs) {
|
|
101
|
-
expect(run.charOffset).to.equal(0);
|
|
102
|
-
expect(run.numChars).to.equal(3);
|
|
103
|
-
expect(run.range.low.x).to.equal(0);
|
|
104
|
-
expect(run.range.low.y).to.equal(0);
|
|
105
|
-
expect(run.range.high.x).to.equal(3);
|
|
106
|
-
expect(run.range.high.y).to.equal(1);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const p = textBlock.appendParagraph();
|
|
110
|
-
for (let j = 0; j <= i; j++) {
|
|
111
|
-
p.runs.push(TextRun.create({ styleName: "", content: "Run" }));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
it("produces a new line for each LineBreakRun", () => {
|
|
116
|
-
const lineSpacingFactor = 0.5;
|
|
117
|
-
const lineHeight = 1;
|
|
118
|
-
const textBlock = TextBlock.create({ styleName: "", styleOverrides: { lineSpacingFactor, lineHeight } });
|
|
119
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "abc" }));
|
|
120
|
-
textBlock.appendRun(LineBreakRun.create({ styleName: "" }));
|
|
121
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "def" }));
|
|
122
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "ghi" }));
|
|
123
|
-
textBlock.appendRun(LineBreakRun.create({ styleName: "" }));
|
|
124
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "jkl" }));
|
|
125
|
-
const tb = doLayout(textBlock);
|
|
126
|
-
expect(tb.lines.length).to.equal(3);
|
|
127
|
-
expect(tb.lines[0].runs.length).to.equal(2);
|
|
128
|
-
expect(tb.lines[1].runs.length).to.equal(3);
|
|
129
|
-
expect(tb.lines[2].runs.length).to.equal(1);
|
|
130
|
-
expect(tb.range.low.x).to.equal(0);
|
|
131
|
-
expect(tb.range.high.x).to.equal(6);
|
|
132
|
-
expect(tb.range.high.y).to.equal(0);
|
|
133
|
-
expect(tb.range.low.y).to.equal(-(lineSpacingFactor * 2 + lineHeight * 3));
|
|
134
|
-
});
|
|
135
|
-
it("computes ranges based on custom line spacing and line height", () => {
|
|
136
|
-
const lineSpacingFactor = 2;
|
|
137
|
-
const lineHeight = 3;
|
|
138
|
-
const textBlock = TextBlock.create({ styleName: "", styleOverrides: { lineSpacingFactor, lineHeight } });
|
|
139
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "abc" }));
|
|
140
|
-
textBlock.appendRun(LineBreakRun.create({ styleName: "" }));
|
|
141
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "def" }));
|
|
142
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "ghi" }));
|
|
143
|
-
textBlock.appendRun(LineBreakRun.create({ styleName: "" }));
|
|
144
|
-
textBlock.appendRun(TextRun.create({ styleName: "", content: "jkl" }));
|
|
145
|
-
const tb = doLayout(textBlock);
|
|
146
|
-
expect(tb.lines.length).to.equal(3);
|
|
147
|
-
expect(tb.lines[0].runs.length).to.equal(2);
|
|
148
|
-
expect(tb.lines[1].runs.length).to.equal(3);
|
|
149
|
-
expect(tb.lines[2].runs.length).to.equal(1);
|
|
150
|
-
// We have 3 lines each `lineHeight` high, plus 2 line breaks in between each `lineHeight*lineSpacingFactor` high.
|
|
151
|
-
expect(tb.range.low.x).to.equal(0);
|
|
152
|
-
expect(tb.range.high.x).to.equal(6);
|
|
153
|
-
expect(tb.range.high.y).to.equal(0);
|
|
154
|
-
expect(tb.range.low.y).to.equal(-(lineHeight * 3 + (lineHeight * lineSpacingFactor) * 2));
|
|
155
|
-
expect(tb.lines[0].offsetFromDocument.y).to.equal(-lineHeight);
|
|
156
|
-
expect(tb.lines[1].offsetFromDocument.y).to.equal(tb.lines[0].offsetFromDocument.y - (lineHeight + lineHeight * lineSpacingFactor));
|
|
157
|
-
expect(tb.lines[2].offsetFromDocument.y).to.equal(tb.lines[1].offsetFromDocument.y - (lineHeight + lineHeight * lineSpacingFactor));
|
|
158
|
-
expect(tb.lines.every((line) => line.offsetFromDocument.x === 0)).to.be.true;
|
|
159
|
-
});
|
|
160
|
-
it("splits paragraphs into multiple lines if runs exceed the document width", function () {
|
|
161
|
-
if (!isIntlSupported()) {
|
|
162
|
-
this.skip();
|
|
163
|
-
}
|
|
164
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
165
|
-
textBlock.width = 6;
|
|
166
|
-
textBlock.appendRun(makeTextRun("ab"));
|
|
167
|
-
expect(doLayout(textBlock).lines.length).to.equal(1);
|
|
168
|
-
textBlock.appendRun(makeTextRun("cd"));
|
|
169
|
-
expect(doLayout(textBlock).lines.length).to.equal(1);
|
|
170
|
-
textBlock.appendRun(makeTextRun("ef"));
|
|
171
|
-
expect(doLayout(textBlock).lines.length).to.equal(1);
|
|
172
|
-
textBlock.appendRun(makeTextRun("ghi"));
|
|
173
|
-
expect(doLayout(textBlock).lines.length).to.equal(2);
|
|
174
|
-
textBlock.appendRun(makeTextRun("jklmnop"));
|
|
175
|
-
expect(doLayout(textBlock).lines.length).to.equal(3);
|
|
176
|
-
textBlock.appendRun(makeTextRun("q"));
|
|
177
|
-
expect(doLayout(textBlock).lines.length).to.equal(4);
|
|
178
|
-
textBlock.appendRun(makeTextRun("r"));
|
|
179
|
-
expect(doLayout(textBlock).lines.length).to.equal(4);
|
|
180
|
-
textBlock.appendRun(makeTextRun("stu"));
|
|
181
|
-
expect(doLayout(textBlock).lines.length).to.equal(4);
|
|
182
|
-
textBlock.appendRun(makeTextRun("vwxyz"));
|
|
183
|
-
expect(doLayout(textBlock).lines.length).to.equal(5);
|
|
184
|
-
});
|
|
185
|
-
function expectRange(width, height, range) {
|
|
186
|
-
expect(range.xLength()).to.equal(width);
|
|
187
|
-
expect(range.yLength()).to.equal(height);
|
|
188
|
-
}
|
|
189
|
-
it("computes range for wrapped lines", function () {
|
|
190
|
-
if (!isIntlSupported()) {
|
|
191
|
-
this.skip();
|
|
192
|
-
}
|
|
193
|
-
const block = TextBlock.create({ styleName: "", width: 3, styleOverrides: { lineHeight: 1, lineSpacingFactor: 0 } });
|
|
194
|
-
function expectBlockRange(width, height) {
|
|
195
|
-
const layout = doLayout(block);
|
|
196
|
-
expectRange(width, height, layout.range);
|
|
197
|
-
}
|
|
198
|
-
block.appendRun(makeTextRun("abc"));
|
|
199
|
-
expectBlockRange(3, 1);
|
|
200
|
-
block.appendRun(makeTextRun("defg"));
|
|
201
|
-
expectBlockRange(4, 2);
|
|
202
|
-
block.width = 1;
|
|
203
|
-
expectBlockRange(4, 2);
|
|
204
|
-
block.width = 8;
|
|
205
|
-
expectBlockRange(8, 1);
|
|
206
|
-
block.width = 6;
|
|
207
|
-
expectBlockRange(6, 2);
|
|
208
|
-
block.width = 10;
|
|
209
|
-
expectBlockRange(10, 1);
|
|
210
|
-
block.appendRun(makeTextRun("hijk"));
|
|
211
|
-
expectBlockRange(10, 2);
|
|
212
|
-
});
|
|
213
|
-
it("computes range for split runs", function () {
|
|
214
|
-
if (!isIntlSupported()) {
|
|
215
|
-
this.skip();
|
|
216
|
-
}
|
|
217
|
-
const block = TextBlock.create({ styleName: "", styleOverrides: { lineHeight: 1, lineSpacingFactor: 0 } });
|
|
218
|
-
function expectBlockRange(width, height) {
|
|
219
|
-
const layout = doLayout(block);
|
|
220
|
-
expectRange(width, height, layout.range);
|
|
221
|
-
}
|
|
222
|
-
const sentence = "a bc def ghij klmno";
|
|
223
|
-
expect(sentence.length).to.equal(19);
|
|
224
|
-
block.appendRun(makeTextRun(sentence));
|
|
225
|
-
block.width = 19;
|
|
226
|
-
expectBlockRange(19, 1);
|
|
227
|
-
block.width = 10;
|
|
228
|
-
expectBlockRange(10, 2);
|
|
229
|
-
});
|
|
230
|
-
it("justifies lines", function () {
|
|
231
|
-
if (!isIntlSupported()) {
|
|
232
|
-
this.skip();
|
|
233
|
-
}
|
|
234
|
-
const block = TextBlock.create({ styleName: "", styleOverrides: { lineSpacingFactor: 0 } });
|
|
235
|
-
function expectBlockRange(width, height) {
|
|
236
|
-
const layout = doLayout(block);
|
|
237
|
-
expectRange(width, height, layout.range);
|
|
238
|
-
}
|
|
239
|
-
function expectLineOffset(offset, lineIndex) {
|
|
240
|
-
const layout = doLayout(block);
|
|
241
|
-
expect(layout.lines.length).least(lineIndex + 1);
|
|
242
|
-
const line = layout.lines[lineIndex];
|
|
243
|
-
expect(line.offsetFromDocument.y).to.equal(-(lineIndex + 1));
|
|
244
|
-
expect(line.offsetFromDocument.x).to.equal(offset);
|
|
245
|
-
}
|
|
246
|
-
// Two text runs with 7 characters total.
|
|
247
|
-
block.appendRun(makeTextRun("abc"));
|
|
248
|
-
block.appendRun(makeTextRun("defg"));
|
|
249
|
-
// 1 line of text with width 0: left, right, center justification.
|
|
250
|
-
block.justification = "left";
|
|
251
|
-
expectBlockRange(7, 1);
|
|
252
|
-
expectLineOffset(0, 0);
|
|
253
|
-
block.justification = "right";
|
|
254
|
-
expectBlockRange(7, 1);
|
|
255
|
-
expectLineOffset(0, 0);
|
|
256
|
-
block.justification = "center";
|
|
257
|
-
expectBlockRange(7, 1);
|
|
258
|
-
expectLineOffset(0, 0);
|
|
259
|
-
// 1 line of text from a width greater than number of characters: left, right, center justification.
|
|
260
|
-
block.width = 10;
|
|
261
|
-
block.justification = "left";
|
|
262
|
-
expectBlockRange(10, 1);
|
|
263
|
-
expectLineOffset(0, 0);
|
|
264
|
-
block.justification = "right";
|
|
265
|
-
expectBlockRange(10, 1);
|
|
266
|
-
expectLineOffset(3, 0); // 3 = 10 - 7
|
|
267
|
-
block.justification = "center";
|
|
268
|
-
expectBlockRange(10, 1);
|
|
269
|
-
expectLineOffset(1.5, 0); // 1.5 = (10 - 7) / 2
|
|
270
|
-
// 2 line of text from a width less than number of characters: left, right, center justification.
|
|
271
|
-
block.justification = "left";
|
|
272
|
-
block.width = 4;
|
|
273
|
-
expectBlockRange(4, 2);
|
|
274
|
-
expectLineOffset(0, 0);
|
|
275
|
-
expectLineOffset(0, 1);
|
|
276
|
-
block.justification = "right";
|
|
277
|
-
expectBlockRange(4, 2);
|
|
278
|
-
expectLineOffset(1, 0);
|
|
279
|
-
expectLineOffset(0, 1);
|
|
280
|
-
block.justification = "center";
|
|
281
|
-
expectBlockRange(4, 2);
|
|
282
|
-
expectLineOffset(0.5, 0);
|
|
283
|
-
expectLineOffset(0, 1);
|
|
284
|
-
// Testing text longer the the width of the text block.
|
|
285
|
-
block.width = 2;
|
|
286
|
-
block.justification = "left";
|
|
287
|
-
expectBlockRange(4, 2);
|
|
288
|
-
expectLineOffset(0, 0);
|
|
289
|
-
expectLineOffset(0, 1);
|
|
290
|
-
block.justification = "right";
|
|
291
|
-
expectBlockRange(4, 2);
|
|
292
|
-
expectLineOffset(-1, 0);
|
|
293
|
-
expectLineOffset(-2, 1);
|
|
294
|
-
block.appendRun(makeTextRun("123456789"));
|
|
295
|
-
expectBlockRange(9, 3);
|
|
296
|
-
expectLineOffset(-1, 0);
|
|
297
|
-
expectLineOffset(-2, 1);
|
|
298
|
-
expectLineOffset(-7, 2);
|
|
299
|
-
block.justification = "center";
|
|
300
|
-
expectBlockRange(9, 3);
|
|
301
|
-
expectLineOffset(-0.5, 0);
|
|
302
|
-
expectLineOffset(-1, 1);
|
|
303
|
-
expectLineOffset(-3.5, 2);
|
|
304
|
-
});
|
|
305
|
-
function expectLines(input, width, expectedLines) {
|
|
306
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
307
|
-
textBlock.width = width;
|
|
308
|
-
const run = makeTextRun(input);
|
|
309
|
-
textBlock.appendRun(run);
|
|
310
|
-
const layout = doLayout(textBlock);
|
|
311
|
-
expect(layout.lines.every((line) => line.runs.every((r) => r.source === run))).to.be.true;
|
|
312
|
-
const actual = layout.lines.map((line) => line.runs.map((runLayout) => runLayout.source.content.substring(runLayout.charOffset, runLayout.charOffset + runLayout.numChars)).join(""));
|
|
313
|
-
expect(actual).to.deep.equal(expectedLines);
|
|
314
|
-
return layout;
|
|
315
|
-
}
|
|
316
|
-
it("splits a single TextRun at word boundaries if it exceeds the document width", function () {
|
|
317
|
-
if (!isIntlSupported()) {
|
|
318
|
-
this.skip();
|
|
319
|
-
}
|
|
320
|
-
expectLines("a bc def ghij klmno pqrstu vwxyz", 5, [
|
|
321
|
-
"a bc ",
|
|
322
|
-
"def ",
|
|
323
|
-
"ghij ",
|
|
324
|
-
"klmno ",
|
|
325
|
-
"pqrstu ",
|
|
326
|
-
"vwxyz",
|
|
327
|
-
]);
|
|
328
|
-
const fox = "The quick brown fox jumped over the lazy dog";
|
|
329
|
-
expectLines(fox, 50, [fox]);
|
|
330
|
-
expectLines(fox, 40, [
|
|
331
|
-
// 1 2 3 4
|
|
332
|
-
// 34567890123456789012345678901234567890
|
|
333
|
-
"The quick brown fox jumped over the ",
|
|
334
|
-
"lazy dog",
|
|
335
|
-
]);
|
|
336
|
-
expectLines(fox, 30, [
|
|
337
|
-
// 1 2 3
|
|
338
|
-
// 3456789012345678901234567890
|
|
339
|
-
"The quick brown fox jumped ",
|
|
340
|
-
"over the lazy dog",
|
|
341
|
-
]);
|
|
342
|
-
expectLines(fox, 20, [
|
|
343
|
-
// 1 2
|
|
344
|
-
// 345678901234567890
|
|
345
|
-
"The quick brown fox ",
|
|
346
|
-
"jumped over the ",
|
|
347
|
-
"lazy dog",
|
|
348
|
-
]);
|
|
349
|
-
expectLines(fox, 10, [
|
|
350
|
-
// 1
|
|
351
|
-
// 234567890
|
|
352
|
-
"The quick ",
|
|
353
|
-
"brown fox ",
|
|
354
|
-
"jumped ",
|
|
355
|
-
"over the ",
|
|
356
|
-
"lazy dog",
|
|
357
|
-
]);
|
|
358
|
-
});
|
|
359
|
-
it("considers consecutive whitespace part of a single 'word'", function () {
|
|
360
|
-
if (!isIntlSupported()) {
|
|
361
|
-
this.skip();
|
|
362
|
-
}
|
|
363
|
-
expectLines("a b c d e f ", 3, [
|
|
364
|
-
"a ",
|
|
365
|
-
"b ",
|
|
366
|
-
"c ",
|
|
367
|
-
"d ",
|
|
368
|
-
"e ",
|
|
369
|
-
"f ",
|
|
370
|
-
]);
|
|
371
|
-
});
|
|
372
|
-
it("wraps Japanese text", function () {
|
|
373
|
-
if (!isIntlSupported()) {
|
|
374
|
-
this.skip();
|
|
375
|
-
}
|
|
376
|
-
// "I am a cat. The name is Tanuki."
|
|
377
|
-
expectLines("吾輩は猫である。名前はたぬき。", 1, ["吾", "輩", "は", "猫", "で", "あ", "る。", "名", "前", "は", "た", "ぬ", "き。"]);
|
|
378
|
-
});
|
|
379
|
-
it("performs word-wrapping with punctuation", function () {
|
|
380
|
-
if (!isIntlSupported()) {
|
|
381
|
-
this.skip();
|
|
382
|
-
}
|
|
383
|
-
expectLines("1.24 56.7 8,910", 1, ["1.24 ", "56.7 ", "8,910"]);
|
|
384
|
-
expectLines("a.bc de.f g,hij", 1, ["a.bc ", "de.f ", "g,hij"]);
|
|
385
|
-
expectLines("Let's see... can you (or anyone) predict?!", 1, [
|
|
386
|
-
"Let's ",
|
|
387
|
-
"see... ",
|
|
388
|
-
"can ",
|
|
389
|
-
"you ",
|
|
390
|
-
"(or ",
|
|
391
|
-
"anyone) ",
|
|
392
|
-
"predict?!",
|
|
393
|
-
]);
|
|
394
|
-
});
|
|
395
|
-
it("performs word-wrapping and line-splitting with multiple runs", function () {
|
|
396
|
-
if (!isIntlSupported()) {
|
|
397
|
-
this.skip();
|
|
398
|
-
}
|
|
399
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
400
|
-
for (const str of ["The ", "quick brown", " fox jumped over ", "the lazy ", "dog"]) {
|
|
401
|
-
textBlock.appendRun(makeTextRun(str));
|
|
402
|
-
}
|
|
403
|
-
function test(width, expected) {
|
|
404
|
-
textBlock.width = width;
|
|
405
|
-
const layout = doLayout(textBlock);
|
|
406
|
-
const actual = layout.lines.map((line) => line.runs.map((runLayout) => runLayout.source.content.substring(runLayout.charOffset, runLayout.charOffset + runLayout.numChars)).join(""));
|
|
407
|
-
expect(actual).to.deep.equal(expected);
|
|
408
|
-
}
|
|
409
|
-
test(50, ["The quick brown fox jumped over the lazy dog"]);
|
|
410
|
-
test(40, [
|
|
411
|
-
// 1 2 3 4
|
|
412
|
-
// 34567890123456789012345678901234567890
|
|
413
|
-
"The quick brown fox jumped over the ",
|
|
414
|
-
"lazy dog",
|
|
415
|
-
]);
|
|
416
|
-
test(30, [
|
|
417
|
-
// 1 2 3
|
|
418
|
-
// 3456789012345678901234567890
|
|
419
|
-
"The quick brown fox jumped ",
|
|
420
|
-
"over the lazy dog",
|
|
421
|
-
]);
|
|
422
|
-
test(20, [
|
|
423
|
-
// 1 2
|
|
424
|
-
// 345678901234567890
|
|
425
|
-
"The quick brown fox ",
|
|
426
|
-
"jumped over the ",
|
|
427
|
-
"lazy dog",
|
|
428
|
-
]);
|
|
429
|
-
test(10, [
|
|
430
|
-
// 1
|
|
431
|
-
// 34567890
|
|
432
|
-
"The quick ",
|
|
433
|
-
"brown fox ",
|
|
434
|
-
"jumped ",
|
|
435
|
-
"over the ",
|
|
436
|
-
"lazy dog",
|
|
437
|
-
]);
|
|
438
|
-
});
|
|
439
|
-
it("wraps multiple runs", function () {
|
|
440
|
-
if (!isIntlSupported()) {
|
|
441
|
-
this.skip();
|
|
442
|
-
}
|
|
443
|
-
const block = TextBlock.create({ styleName: "" });
|
|
444
|
-
block.appendRun(makeTextRun("aa")); // 2 chars wide
|
|
445
|
-
block.appendRun(makeTextRun("bb ccc d ee")); // 11 chars wide
|
|
446
|
-
block.appendRun(makeTextRun("ff ggg h")); // 8 chars wide
|
|
447
|
-
function expectLayout(width, expected) {
|
|
448
|
-
block.width = width;
|
|
449
|
-
const layout = doLayout(block);
|
|
450
|
-
expect(layout.stringify()).to.equal(expected);
|
|
451
|
-
}
|
|
452
|
-
expectLayout(23, "aabb ccc d eeff ggg h");
|
|
453
|
-
expectLayout(22, "aabb ccc d eeff ggg h");
|
|
454
|
-
expectLayout(21, "aabb ccc d eeff ggg h");
|
|
455
|
-
expectLayout(20, "aabb ccc d eeff ggg \nh");
|
|
456
|
-
expectLayout(19, "aabb ccc d eeff \nggg h");
|
|
457
|
-
expectLayout(18, "aabb ccc d eeff \nggg h");
|
|
458
|
-
expectLayout(17, "aabb ccc d eeff \nggg h");
|
|
459
|
-
expectLayout(16, "aabb ccc d eeff \nggg h");
|
|
460
|
-
expectLayout(15, "aabb ccc d ee\nff ggg h");
|
|
461
|
-
expectLayout(14, "aabb ccc d ee\nff ggg h");
|
|
462
|
-
expectLayout(13, "aabb ccc d ee\nff ggg h");
|
|
463
|
-
expectLayout(12, "aabb ccc d \neeff ggg h");
|
|
464
|
-
expectLayout(11, "aabb ccc d \neeff ggg h");
|
|
465
|
-
expectLayout(10, "aabb ccc \nd eeff \nggg h");
|
|
466
|
-
expectLayout(9, "aabb ccc \nd eeff \nggg h");
|
|
467
|
-
expectLayout(8, "aabb \nccc d ee\nff ggg h");
|
|
468
|
-
expectLayout(7, "aabb \nccc d \neeff \nggg h");
|
|
469
|
-
expectLayout(6, "aabb \nccc d \neeff \nggg h");
|
|
470
|
-
expectLayout(5, "aabb \nccc \nd ee\nff \nggg h");
|
|
471
|
-
expectLayout(4, "aa\nbb \nccc \nd ee\nff \nggg \nh");
|
|
472
|
-
expectLayout(3, "aa\nbb \nccc \nd \nee\nff \nggg \nh");
|
|
473
|
-
expectLayout(2, "aa\nbb \nccc \nd \nee\nff \nggg \nh");
|
|
474
|
-
expectLayout(1, "aa\nbb \nccc \nd \nee\nff \nggg \nh");
|
|
475
|
-
expectLayout(0, "aabb ccc d eeff ggg h");
|
|
476
|
-
expectLayout(-1, "aabb ccc d eeff ggg h");
|
|
477
|
-
expectLayout(-2, "aabb ccc d eeff ggg h");
|
|
478
|
-
});
|
|
479
|
-
it("does not word wrap due to floating point rounding error", function () {
|
|
480
|
-
if (!isIntlSupported()) {
|
|
481
|
-
this.skip();
|
|
482
|
-
}
|
|
483
|
-
const block = TextBlock.create({ styleName: "", styleOverrides: { lineHeight: 1, lineSpacingFactor: 0 } });
|
|
484
|
-
block.appendRun(makeTextRun("abc defg"));
|
|
485
|
-
const layout1 = doLayout(block);
|
|
486
|
-
let width = layout1.range.xLength();
|
|
487
|
-
// Simulate a floating point rounding error by slightly reducing the width
|
|
488
|
-
width -= Geometry.smallFloatingPoint;
|
|
489
|
-
block.width = width;
|
|
490
|
-
const layout2 = doLayout(block);
|
|
491
|
-
expect(layout2.range.yLength()).to.equal(1);
|
|
492
|
-
});
|
|
493
|
-
it("has consistent data when converted to a layout result", function () {
|
|
494
|
-
if (!isIntlSupported()) {
|
|
495
|
-
this.skip();
|
|
496
|
-
}
|
|
497
|
-
// Initialize a new TextBlockLayout object
|
|
498
|
-
const textBlock = TextBlock.create({ width: 50, styleName: "", styleOverrides: { widthFactor: 34, color: 0x00ff00, fontName: "arial" } });
|
|
499
|
-
const run0 = TextRun.create({
|
|
500
|
-
content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium mi sit amet magna malesuada, at venenatis ante eleifend.",
|
|
501
|
-
styleName: "",
|
|
502
|
-
styleOverrides: { lineHeight: 56, color: 0xff0000 },
|
|
503
|
-
});
|
|
504
|
-
const run1 = TextRun.create({
|
|
505
|
-
content: "Donec sit amet semper sapien. Nullam commodo, libero a accumsan lacinia, metus enim pharetra lacus, eu facilisis sem nisi eu dui.",
|
|
506
|
-
styleName: "",
|
|
507
|
-
styleOverrides: { widthFactor: 78, fontName: "run1" },
|
|
508
|
-
});
|
|
509
|
-
const run2 = TextRun.create({
|
|
510
|
-
content: "Duis dui quam, suscipit quis feugiat id, fermentum ut augue. Mauris iaculis odio rhoncus lorem eleifend, posuere viverra turpis elementum.",
|
|
511
|
-
styleName: "",
|
|
512
|
-
styleOverrides: {},
|
|
513
|
-
});
|
|
514
|
-
const fractionRun = FractionRun.create({ numerator: "num", denominator: "denom", styleName: "", styleOverrides: {} });
|
|
515
|
-
textBlock.appendRun(run0);
|
|
516
|
-
textBlock.appendRun(fractionRun);
|
|
517
|
-
textBlock.appendParagraph();
|
|
518
|
-
textBlock.appendRun(run1);
|
|
519
|
-
textBlock.appendRun(run2);
|
|
520
|
-
// Call the toResult() method
|
|
521
|
-
const textBlockLayout = doLayout(textBlock, {
|
|
522
|
-
findFontId: (fontName) => {
|
|
523
|
-
if (fontName === "arial") {
|
|
524
|
-
return 1;
|
|
525
|
-
}
|
|
526
|
-
else if (fontName === "run1") {
|
|
527
|
-
return 2;
|
|
528
|
-
}
|
|
529
|
-
return 0;
|
|
530
|
-
},
|
|
531
|
-
});
|
|
532
|
-
const result = textBlockLayout.toResult();
|
|
533
|
-
// Assert that the result object has the same data as the original TextBlockLayout object
|
|
534
|
-
expect(result.range).to.deep.equal(textBlockLayout.range.toJSON());
|
|
535
|
-
expect(result.lines.length).to.equal(textBlockLayout.lines.length);
|
|
536
|
-
// Loop through each line in the result and the original object
|
|
537
|
-
for (let i = 0; i < result.lines.length; i++) {
|
|
538
|
-
const resultLine = result.lines[i];
|
|
539
|
-
const originalLine = textBlockLayout.lines[i];
|
|
540
|
-
// Source paragraph index matches
|
|
541
|
-
expect(resultLine.sourceParagraphIndex).to.equal(textBlock.paragraphs.indexOf(originalLine.source));
|
|
542
|
-
// Ranges match
|
|
543
|
-
expect(resultLine.range).to.deep.equal(originalLine.range.toJSON());
|
|
544
|
-
expect(resultLine.justificationRange).to.deep.equal(originalLine.justificationRange.toJSON());
|
|
545
|
-
// Offset matches
|
|
546
|
-
expect(resultLine.offsetFromDocument).to.deep.equal(originalLine.offsetFromDocument);
|
|
547
|
-
for (let j = 0; j < resultLine.runs.length; j++) {
|
|
548
|
-
const resultRun = resultLine.runs[j];
|
|
549
|
-
const originalRun = originalLine.runs[j];
|
|
550
|
-
// Source run index matches
|
|
551
|
-
expect(resultRun.sourceRunIndex).to.equal(textBlock.paragraphs[resultLine.sourceParagraphIndex].runs.indexOf(originalRun.source));
|
|
552
|
-
// FontId matches
|
|
553
|
-
expect(resultRun.fontId).to.equal(originalRun.fontId);
|
|
554
|
-
// Offsets match
|
|
555
|
-
expect(resultRun.characterOffset).to.equal(originalRun.charOffset);
|
|
556
|
-
expect(resultRun.characterCount).to.equal(originalRun.numChars);
|
|
557
|
-
expect(resultRun.offsetFromLine).to.deep.equal(originalRun.offsetFromLine);
|
|
558
|
-
// Range matches
|
|
559
|
-
expect(resultRun.range).to.deep.equal(originalRun.range.toJSON());
|
|
560
|
-
// Text style matches
|
|
561
|
-
expect(resultRun.textStyle).to.deep.equal(originalRun.style.toJSON());
|
|
562
|
-
// Optional values match existence and values
|
|
563
|
-
if (resultRun.justificationRange) {
|
|
564
|
-
expect(originalRun.justificationRange);
|
|
565
|
-
}
|
|
566
|
-
if (originalRun.justificationRange) {
|
|
567
|
-
expect(resultRun.justificationRange);
|
|
568
|
-
}
|
|
569
|
-
if (resultRun.justificationRange && originalRun.justificationRange) {
|
|
570
|
-
expect(resultRun.justificationRange).to.deep.equal(originalRun.justificationRange.toJSON());
|
|
571
|
-
}
|
|
572
|
-
if (resultRun.numeratorRange) {
|
|
573
|
-
expect(originalRun.numeratorRange);
|
|
574
|
-
}
|
|
575
|
-
if (originalRun.numeratorRange) {
|
|
576
|
-
expect(resultRun.numeratorRange);
|
|
577
|
-
}
|
|
578
|
-
if (resultRun.numeratorRange && originalRun.numeratorRange) {
|
|
579
|
-
expect(resultRun.numeratorRange).to.deep.equal(originalRun.numeratorRange.toJSON());
|
|
580
|
-
}
|
|
581
|
-
if (resultRun.denominatorRange) {
|
|
582
|
-
expect(originalRun.denominatorRange);
|
|
583
|
-
}
|
|
584
|
-
if (originalRun.denominatorRange) {
|
|
585
|
-
expect(resultRun.denominatorRange);
|
|
586
|
-
}
|
|
587
|
-
if (resultRun.denominatorRange && originalRun.denominatorRange) {
|
|
588
|
-
expect(resultRun.denominatorRange).to.deep.equal(originalRun.denominatorRange.toJSON());
|
|
589
|
-
}
|
|
590
|
-
// Check that the result string matches what we expect
|
|
591
|
-
const inputRun = textBlock.paragraphs[resultLine.sourceParagraphIndex].runs[resultRun.sourceRunIndex].clone();
|
|
592
|
-
if (inputRun.type === "text") {
|
|
593
|
-
const resultText = inputRun.content.substring(resultRun.characterOffset, resultRun.characterOffset + resultRun.characterCount);
|
|
594
|
-
const originalText = inputRun.content.substring(originalRun.charOffset, originalRun.charOffset + originalRun.numChars);
|
|
595
|
-
expect(resultText).to.equal(originalText);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
it("adds margins", function () {
|
|
601
|
-
const expectMargins = (layoutRange, marginRange, margins) => {
|
|
602
|
-
expect(marginRange.low.x).to.equal(layoutRange.low.x - (margins.left ?? 0));
|
|
603
|
-
expect(marginRange.high.x).to.equal(layoutRange.high.x + (margins.right ?? 0));
|
|
604
|
-
expect(marginRange.low.y).to.equal(layoutRange.low.y - (margins.bottom ?? 0));
|
|
605
|
-
expect(marginRange.high.y).to.equal(layoutRange.high.y + (margins.top ?? 0));
|
|
606
|
-
};
|
|
607
|
-
const makeTextBlock = (margins) => {
|
|
608
|
-
const textblock = TextBlock.create({ styleName: "", styleOverrides: { lineSpacingFactor: 0 }, margins });
|
|
609
|
-
textblock.appendRun(makeTextRun("abc"));
|
|
610
|
-
textblock.appendRun(makeTextRun("defg"));
|
|
611
|
-
return textblock;
|
|
612
|
-
};
|
|
613
|
-
let block = makeTextBlock({});
|
|
614
|
-
let layout = doLayout(block);
|
|
615
|
-
// Margins should be 0 by default
|
|
616
|
-
expect(layout.range.isAlmostEqual(layout.textRange)).to.be.true;
|
|
617
|
-
expectMargins(layout.textRange, layout.range, {});
|
|
618
|
-
// All margins should be applied to the range
|
|
619
|
-
block = makeTextBlock({ left: 1, right: 2, top: 3, bottom: 4 });
|
|
620
|
-
layout = doLayout(block);
|
|
621
|
-
expectMargins(layout.textRange, layout.range, { left: 1, right: 2, top: 3, bottom: 4 });
|
|
622
|
-
// Just horisontal margins should be applied
|
|
623
|
-
block = makeTextBlock({ left: 1, right: 2 });
|
|
624
|
-
layout = doLayout(block);
|
|
625
|
-
expectMargins(layout.textRange, layout.range, { left: 1, right: 2 });
|
|
626
|
-
// Just vertical margins should be applied
|
|
627
|
-
block = makeTextBlock({ top: 1, bottom: 2 });
|
|
628
|
-
layout = doLayout(block);
|
|
629
|
-
expectMargins(layout.textRange, layout.range, { top: 1, bottom: 2 });
|
|
630
|
-
});
|
|
631
|
-
describe("grapheme offsets", () => {
|
|
632
|
-
it("should return an empty array if source type is not text", function () {
|
|
633
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
634
|
-
const fractionRun = FractionRun.create({ numerator: "1", denominator: "2", styleName: "fraction" });
|
|
635
|
-
textBlock.appendRun(fractionRun);
|
|
636
|
-
const layout = doLayout(textBlock);
|
|
637
|
-
const result = layout.toResult();
|
|
638
|
-
const args = {
|
|
639
|
-
textBlock,
|
|
640
|
-
iModel: {},
|
|
641
|
-
findTextStyle: () => TextStyleSettings.defaults,
|
|
642
|
-
findFontId: () => 0,
|
|
643
|
-
computeTextRange: computeTextRangeAsStringLength,
|
|
644
|
-
paragraphIndex: result.lines[0].sourceParagraphIndex,
|
|
645
|
-
runLayoutResult: result.lines[0].runs[0],
|
|
646
|
-
graphemeCharIndexes: [0],
|
|
647
|
-
};
|
|
648
|
-
const graphemeRanges = computeGraphemeOffsets(args);
|
|
649
|
-
expect(graphemeRanges).to.be.an("array").that.is.empty;
|
|
650
|
-
});
|
|
651
|
-
it("should handle empty text content", function () {
|
|
652
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
653
|
-
const textRun = TextRun.create({ content: "", styleName: "text" });
|
|
654
|
-
textBlock.appendRun(textRun);
|
|
655
|
-
const layout = doLayout(textBlock);
|
|
656
|
-
const result = layout.toResult();
|
|
657
|
-
const args = {
|
|
658
|
-
textBlock,
|
|
659
|
-
iModel: {},
|
|
660
|
-
findTextStyle: () => TextStyleSettings.defaults,
|
|
661
|
-
findFontId: () => 0,
|
|
662
|
-
computeTextRange: computeTextRangeAsStringLength,
|
|
663
|
-
paragraphIndex: result.lines[0].sourceParagraphIndex,
|
|
664
|
-
runLayoutResult: result.lines[0].runs[0],
|
|
665
|
-
graphemeCharIndexes: [0], // Supply a grapheme index even though there is no text
|
|
666
|
-
};
|
|
667
|
-
const graphemeRanges = computeGraphemeOffsets(args);
|
|
668
|
-
expect(graphemeRanges).to.be.an("array").that.is.empty;
|
|
669
|
-
});
|
|
670
|
-
it("should compute grapheme offsets correctly for a given text", function () {
|
|
671
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
672
|
-
const textRun = TextRun.create({ content: "hello", styleName: "text" });
|
|
673
|
-
textBlock.appendRun(textRun);
|
|
674
|
-
const layout = doLayout(textBlock);
|
|
675
|
-
const result = layout.toResult();
|
|
676
|
-
const args = {
|
|
677
|
-
textBlock,
|
|
678
|
-
iModel: {},
|
|
679
|
-
findTextStyle: () => TextStyleSettings.defaults,
|
|
680
|
-
findFontId: () => 0,
|
|
681
|
-
computeTextRange: computeTextRangeAsStringLength,
|
|
682
|
-
paragraphIndex: result.lines[0].sourceParagraphIndex,
|
|
683
|
-
runLayoutResult: result.lines[0].runs[0],
|
|
684
|
-
graphemeCharIndexes: [0, 1, 2, 3, 4],
|
|
685
|
-
};
|
|
686
|
-
const graphemeRanges = computeGraphemeOffsets(args);
|
|
687
|
-
expect(graphemeRanges).to.be.an("array").that.has.lengthOf(5);
|
|
688
|
-
expect(graphemeRanges[0].high.x).to.equal(1);
|
|
689
|
-
expect(graphemeRanges[4].high.x).to.equal(5);
|
|
690
|
-
});
|
|
691
|
-
it("should compute grapheme offsets correctly for non-English text", function () {
|
|
692
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
693
|
-
// Hindi - "Paragraph"
|
|
694
|
-
const textRun = TextRun.create({ content: "अनुच्छेद", styleName: "text" });
|
|
695
|
-
textBlock.appendRun(textRun);
|
|
696
|
-
const layout = doLayout(textBlock);
|
|
697
|
-
const result = layout.toResult();
|
|
698
|
-
const args = {
|
|
699
|
-
textBlock,
|
|
700
|
-
iModel: {},
|
|
701
|
-
findTextStyle: () => TextStyleSettings.defaults,
|
|
702
|
-
findFontId: () => 0,
|
|
703
|
-
computeTextRange: computeTextRangeAsStringLength,
|
|
704
|
-
paragraphIndex: result.lines[0].sourceParagraphIndex,
|
|
705
|
-
runLayoutResult: result.lines[0].runs[0],
|
|
706
|
-
graphemeCharIndexes: [0, 1, 3, 7],
|
|
707
|
-
};
|
|
708
|
-
const graphemeRanges = computeGraphemeOffsets(args);
|
|
709
|
-
expect(graphemeRanges).to.be.an("array").that.has.lengthOf(4); // Length based on actual grapheme segmentation
|
|
710
|
-
expect(graphemeRanges[0].high.x).to.equal(1);
|
|
711
|
-
expect(graphemeRanges[1].high.x).to.equal(3);
|
|
712
|
-
expect(graphemeRanges[2].high.x).to.equal(7);
|
|
713
|
-
expect(graphemeRanges[3].high.x).to.equal(8);
|
|
714
|
-
});
|
|
715
|
-
it("should compute grapheme offsets correctly for emoji content", function () {
|
|
716
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
717
|
-
const textRun = TextRun.create({ content: "👨👦", styleName: "text" });
|
|
718
|
-
textBlock.appendRun(textRun);
|
|
719
|
-
const layout = doLayout(textBlock);
|
|
720
|
-
const result = layout.toResult();
|
|
721
|
-
const args = {
|
|
722
|
-
textBlock,
|
|
723
|
-
iModel: {},
|
|
724
|
-
findTextStyle: () => TextStyleSettings.defaults,
|
|
725
|
-
findFontId: () => 0,
|
|
726
|
-
computeTextRange: computeTextRangeAsStringLength,
|
|
727
|
-
paragraphIndex: result.lines[0].sourceParagraphIndex,
|
|
728
|
-
runLayoutResult: result.lines[0].runs[0],
|
|
729
|
-
graphemeCharIndexes: [0],
|
|
730
|
-
};
|
|
731
|
-
const graphemeRanges = computeGraphemeOffsets(args);
|
|
732
|
-
expect(graphemeRanges).to.be.an("array").that.has.lengthOf(1); // Length based on actual grapheme segmentation
|
|
733
|
-
expect(graphemeRanges[0].high.x).to.equal(5);
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
describe("using native font library", () => {
|
|
737
|
-
let iModel;
|
|
738
|
-
before(() => {
|
|
739
|
-
const seedFileName = IModelTestUtils.resolveAssetFile("CompatibilityTestSeed.bim");
|
|
740
|
-
const testFileName = IModelTestUtils.prepareOutputFile("NativeFonts", "NativeFonts.bim");
|
|
741
|
-
iModel = IModelTestUtils.createSnapshotFromSeed(testFileName, seedFileName);
|
|
742
|
-
});
|
|
743
|
-
after(() => iModel.close());
|
|
744
|
-
it("maps font names to Id", async () => {
|
|
745
|
-
const vera = iModel.fonts.findId({ name: "Vera" });
|
|
746
|
-
expect(vera).to.equal(1);
|
|
747
|
-
const arial = await iModel.fonts.acquireId({ name: "Arial", type: FontType.TrueType });
|
|
748
|
-
const comic = await iModel.fonts.acquireId({ name: "Comic Sans", type: FontType.TrueType });
|
|
749
|
-
iModel.saveChanges();
|
|
750
|
-
expect(arial).to.equal(2);
|
|
751
|
-
expect(comic).to.equal(3);
|
|
752
|
-
expect(iModel.fonts.findId({ name: "Consolas" })).to.be.undefined;
|
|
753
|
-
function test(fontName, expectedFontId) {
|
|
754
|
-
const textBlock = TextBlock.create({ styleName: "" });
|
|
755
|
-
textBlock.appendRun(TextRun.create({ styleName: "", styleOverrides: { fontName } }));
|
|
756
|
-
const layout = layoutTextBlock({ textBlock, iModel });
|
|
757
|
-
const run = layout.lines[0].runs[0];
|
|
758
|
-
expect(run).not.to.be.undefined;
|
|
759
|
-
expect(run.fontId).to.equal(expectedFontId);
|
|
760
|
-
}
|
|
761
|
-
test("Arial", arial);
|
|
762
|
-
test("Comic Sans", comic);
|
|
763
|
-
test("Consolas", 0);
|
|
764
|
-
test("arial", arial);
|
|
765
|
-
test("aRIaL", arial);
|
|
766
|
-
});
|
|
767
|
-
function computeDimensions(args) {
|
|
768
|
-
const textBlock = TextBlock.create({
|
|
769
|
-
styleName: "",
|
|
770
|
-
styleOverrides: {
|
|
771
|
-
lineHeight: args.height,
|
|
772
|
-
widthFactor: args.width,
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
textBlock.appendRun(TextRun.create({
|
|
776
|
-
styleName: "",
|
|
777
|
-
content: args.content ?? "This is a string of text.",
|
|
778
|
-
styleOverrides: {
|
|
779
|
-
isBold: args.bold,
|
|
780
|
-
isItalic: args.italic,
|
|
781
|
-
fontName: args.font ?? "Vera",
|
|
782
|
-
},
|
|
783
|
-
}));
|
|
784
|
-
const range = layoutTextBlock({ textBlock, iModel }).range;
|
|
785
|
-
return { x: range.high.x - range.low.x, y: range.high.y - range.low.y };
|
|
786
|
-
}
|
|
787
|
-
it("computes different ranges for different strings", () => {
|
|
788
|
-
expect(computeDimensions({ content: "text" })).to.deep.equal(computeDimensions({ content: "text" }));
|
|
789
|
-
expect(computeDimensions({ content: "text" })).not.to.deep.equal(computeDimensions({ content: "texttexttext" }));
|
|
790
|
-
expect(computeDimensions({ content: "text" })).not.to.deep.equal(computeDimensions({ content: "TEXT" }));
|
|
791
|
-
});
|
|
792
|
-
it("computes different ranges for different fonts", () => {
|
|
793
|
-
// These two are embedded in the iModel.
|
|
794
|
-
expect(computeDimensions({ font: "Vera" })).not.to.deep.equal(computeDimensions({ font: "Karla" }));
|
|
795
|
-
// These two are not embedded in the iModel, but do exist in its font table - they should both fall back to the default font.
|
|
796
|
-
expect(computeDimensions({ font: "Arial" })).to.deep.equal(computeDimensions({ font: "Comic Sans" }));
|
|
797
|
-
});
|
|
798
|
-
it("computes different ranges for different height and width", () => {
|
|
799
|
-
expect(computeDimensions({ height: 2 })).to.deep.equal(computeDimensions({ height: 2 }));
|
|
800
|
-
expect(computeDimensions({ height: 2 })).not.to.deep.equal(computeDimensions({ height: 3 }));
|
|
801
|
-
expect(computeDimensions({ width: 2 })).to.deep.equal(computeDimensions({ width: 2 }));
|
|
802
|
-
expect(computeDimensions({ width: 2 })).not.to.deep.equal(computeDimensions({ width: 3 }));
|
|
803
|
-
});
|
|
804
|
-
it("excludes trailing blank glyphs from justification ranges", () => {
|
|
805
|
-
function computeRanges(chars) {
|
|
806
|
-
return iModel.computeRangesForText({
|
|
807
|
-
chars,
|
|
808
|
-
bold: false,
|
|
809
|
-
italic: false,
|
|
810
|
-
fontId: 1,
|
|
811
|
-
widthFactor: 1,
|
|
812
|
-
lineHeight: 1,
|
|
813
|
-
baselineShift: "none",
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
function test(chars, expectEqualRanges) {
|
|
817
|
-
const { justification, layout } = computeRanges(chars);
|
|
818
|
-
expect(layout.low.x).to.equal(justification.low.x);
|
|
819
|
-
expect(layout.high.y).to.equal(justification.high.y);
|
|
820
|
-
expect(layout.low.y).to.equal(justification.low.y);
|
|
821
|
-
if (expectEqualRanges) {
|
|
822
|
-
expect(layout.high.x).to.equal(justification.high.x);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
expect(layout.high.x).greaterThan(justification.high.x);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
test("abcdef", true);
|
|
829
|
-
test("abcdef ", false);
|
|
830
|
-
test("abcdef ", false);
|
|
831
|
-
test("abc def", true);
|
|
832
|
-
// new line has no width ever.
|
|
833
|
-
test("abcdef\n", true);
|
|
834
|
-
// apparently native code doesn't consider tab characters to be "blank".
|
|
835
|
-
test("abcdef\t", true);
|
|
836
|
-
// apparently native code doesn't consider "thin space" to be "blank".
|
|
837
|
-
test("abcdef\u2009", true);
|
|
838
|
-
const r1 = computeRanges("abcdef ");
|
|
839
|
-
const r2 = computeRanges("abcdef ");
|
|
840
|
-
expect(r1.layout.xLength()).lessThan(r2.layout.xLength());
|
|
841
|
-
expect(r1.justification.xLength()).to.equal(r2.justification.xLength());
|
|
842
|
-
});
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
22
|
function mockIModel() {
|
|
846
23
|
const iModel = {
|
|
847
24
|
fonts: {
|
|
848
25
|
findId: () => 0,
|
|
849
26
|
},
|
|
850
|
-
computeRangesForText:
|
|
27
|
+
computeRangesForText: computeTextRangeAsStringLength,
|
|
851
28
|
forEachMetaData: () => undefined,
|
|
852
29
|
};
|
|
853
30
|
return iModel;
|
|
854
31
|
}
|
|
855
|
-
describe("produceTextAnnotationGeometry", () => {
|
|
856
|
-
function makeText(color) {
|
|
857
|
-
const styleOverrides = undefined !== color ? { color: color instanceof ColorDef ? color.toJSON() : color } : undefined;
|
|
858
|
-
return TextRun.create({ styleName: "", styleOverrides, content: "text" });
|
|
859
|
-
}
|
|
860
|
-
function makeFraction(color) {
|
|
861
|
-
const styleOverrides = undefined !== color ? { color: color instanceof ColorDef ? color.toJSON() : color } : undefined;
|
|
862
|
-
return FractionRun.create({ numerator: "num", denominator: "denom", styleName: "", styleOverrides });
|
|
863
|
-
}
|
|
864
|
-
function makeBreak(color) {
|
|
865
|
-
const styleOverrides = undefined !== color ? { color: color instanceof ColorDef ? color.toJSON() : color } : undefined;
|
|
866
|
-
return LineBreakRun.create({ styleName: "", styleOverrides });
|
|
867
|
-
}
|
|
868
|
-
function makeTextBlock(runs) {
|
|
869
|
-
const block = TextBlock.create({ styleName: "" });
|
|
870
|
-
for (const run of runs) {
|
|
871
|
-
block.appendRun(run);
|
|
872
|
-
}
|
|
873
|
-
return block;
|
|
874
|
-
}
|
|
875
|
-
function makeGeometry(runs) {
|
|
876
|
-
const block = makeTextBlock(runs);
|
|
877
|
-
const annotation = TextAnnotation.fromJSON({ textBlock: block.toJSON() });
|
|
878
|
-
return produceTextAnnotationGeometry({ iModel: mockIModel(), annotation }).entries;
|
|
879
|
-
}
|
|
880
|
-
it("produces an empty array for an empty text block", () => {
|
|
881
|
-
expect(makeGeometry([])).to.deep.equal([]);
|
|
882
|
-
});
|
|
883
|
-
it("produces an empty array for a block consisting only of line breaks", () => {
|
|
884
|
-
expect(makeGeometry([makeBreak(), makeBreak(), makeBreak()])).to.deep.equal([]);
|
|
885
|
-
});
|
|
886
|
-
it("produces one appearance entry if all runs use subcategory color", () => {
|
|
887
|
-
const geom = makeGeometry([makeText(), makeFraction(), makeText("subcategory"), makeFraction("subcategory")]);
|
|
888
|
-
expect(geom.length).to.equal(9);
|
|
889
|
-
expect(geom[0].color).to.equal("subcategory");
|
|
890
|
-
expect(geom.slice(1).some((entry) => entry.color !== undefined)).to.be.false;
|
|
891
|
-
});
|
|
892
|
-
it("produces strings and fraction separators", () => {
|
|
893
|
-
const geom = makeGeometry([makeText(), makeFraction(), makeFraction(), makeText()]);
|
|
894
|
-
expect(geom.length).to.equal(9);
|
|
895
|
-
expect(geom[0].color).to.equal("subcategory");
|
|
896
|
-
expect(geom[1].text).not.to.be.undefined;
|
|
897
|
-
expect(geom[2].text).not.to.be.undefined;
|
|
898
|
-
expect(geom[3].separator).not.to.be.undefined;
|
|
899
|
-
expect(geom[4].text).not.to.be.undefined;
|
|
900
|
-
expect(geom[5].text).not.to.be.undefined;
|
|
901
|
-
expect(geom[6].separator).not.to.be.undefined;
|
|
902
|
-
expect(geom[7].text).not.to.be.undefined;
|
|
903
|
-
expect(geom[8].text).not.to.be.undefined;
|
|
904
|
-
});
|
|
905
|
-
it("produces an appearance change for each non-break run that is a different color from the previous run", () => {
|
|
906
|
-
const geom = makeGeometry([
|
|
907
|
-
makeText(ColorDef.blue),
|
|
908
|
-
makeText(), // subcategory by default
|
|
909
|
-
makeText(),
|
|
910
|
-
makeText(ColorDef.red),
|
|
911
|
-
makeText(ColorDef.white),
|
|
912
|
-
makeText(ColorDef.white),
|
|
913
|
-
makeBreak("subcategory"),
|
|
914
|
-
makeFraction(ColorDef.green),
|
|
915
|
-
makeText(ColorDef.green),
|
|
916
|
-
makeBreak(ColorDef.black),
|
|
917
|
-
makeText(ColorDef.green),
|
|
918
|
-
]).map((entry) => entry.text ? "text" : (entry.separator ? "sep" : (typeof entry.color === "number" ? ColorDef.fromJSON(entry.color) : entry.color)));
|
|
919
|
-
expect(geom).to.deep.equal([
|
|
920
|
-
ColorDef.blue,
|
|
921
|
-
"text",
|
|
922
|
-
"subcategory",
|
|
923
|
-
"text",
|
|
924
|
-
"text",
|
|
925
|
-
ColorDef.red,
|
|
926
|
-
"text",
|
|
927
|
-
ColorDef.white,
|
|
928
|
-
"text",
|
|
929
|
-
"text",
|
|
930
|
-
ColorDef.green,
|
|
931
|
-
"text", "sep", "text",
|
|
932
|
-
"text",
|
|
933
|
-
"text",
|
|
934
|
-
]);
|
|
935
|
-
});
|
|
936
|
-
it("offsets geometry entries by margins", () => {
|
|
937
|
-
function makeGeometryWithMargins(anchor, margins) {
|
|
938
|
-
const runs = [makeText()];
|
|
939
|
-
const block = makeTextBlock(runs);
|
|
940
|
-
block.margins = margins;
|
|
941
|
-
const annotation = TextAnnotation.fromJSON({ textBlock: block.toJSON() });
|
|
942
|
-
annotation.anchor = anchor;
|
|
943
|
-
const geom = produceTextAnnotationGeometry({ iModel: mockIModel(), annotation }).entries;
|
|
944
|
-
return geom[1].text;
|
|
945
|
-
}
|
|
946
|
-
function testMargins(margins, height, width) {
|
|
947
|
-
// We want to disregard negative margins. Note, I'm not changing the margins object itself. It gets passed into makeGeometryWithMargins as it is.
|
|
948
|
-
const left = margins.left >= 0 ? margins.left : 0;
|
|
949
|
-
const right = margins.right >= 0 ? margins.right : 0;
|
|
950
|
-
const top = margins.top >= 0 ? margins.top : 0;
|
|
951
|
-
const bottom = margins.bottom >= 0 ? margins.bottom : 0;
|
|
952
|
-
// Test case: bottom, left
|
|
953
|
-
let props = makeGeometryWithMargins({ horizontal: "left", vertical: "bottom" }, margins);
|
|
954
|
-
expect(props).not.to.be.undefined;
|
|
955
|
-
expect(props?.origin, "Expected geometry to be offset by left and bottom margins").to.deep.equal({ x: left, y: bottom, z: 0 });
|
|
956
|
-
// Test case: top, right
|
|
957
|
-
props = makeGeometryWithMargins({ vertical: "top", horizontal: "right" }, margins);
|
|
958
|
-
let x = (right + width) * -1;
|
|
959
|
-
let y = (top + height) * -1;
|
|
960
|
-
expect(props).not.to.be.undefined;
|
|
961
|
-
expect(props?.origin, "Expected geometry to be offset by top and right margins").to.deep.equal({ x, y, z: 0 });
|
|
962
|
-
// Test case: middle, center
|
|
963
|
-
props = makeGeometryWithMargins({ vertical: "middle", horizontal: "center" }, margins);
|
|
964
|
-
x = (left - right - width) / 2;
|
|
965
|
-
y = (bottom - top - height) / 2;
|
|
966
|
-
expect(props).not.to.be.undefined;
|
|
967
|
-
expect(props?.origin, "Expected geometry to be centered in the margins").to.deep.equal({ x, y, z: 0 });
|
|
968
|
-
}
|
|
969
|
-
// Getting the range from the same mock the native code uses to compute the range of a text block.
|
|
970
|
-
const textRange = mockIModel().computeRangesForText({
|
|
971
|
-
chars: "text",
|
|
972
|
-
bold: false,
|
|
973
|
-
italic: false,
|
|
974
|
-
fontId: 1,
|
|
975
|
-
widthFactor: 1,
|
|
976
|
-
lineHeight: 1,
|
|
977
|
-
baselineShift: "none",
|
|
978
|
-
});
|
|
979
|
-
const xLength = textRange.layout.xLength(); // Will be 1 because of the mock implementation.
|
|
980
|
-
const yLength = textRange.layout.yLength(); // Will be 1 because of the mock implementation.
|
|
981
|
-
testMargins({ top: 0, right: 0, bottom: 0, left: 0 }, yLength, xLength);
|
|
982
|
-
testMargins({ top: 1, right: 2, bottom: 3, left: 4 }, yLength, xLength);
|
|
983
|
-
testMargins({ top: -1, right: -2, bottom: -3, left: -4 }, yLength, xLength);
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
32
|
describe("TextAnnotation element", () => {
|
|
987
33
|
function makeElement(props) {
|
|
988
34
|
return TextAnnotation2d.fromJSON({
|
|
@@ -993,6 +39,10 @@ describe("TextAnnotation element", () => {
|
|
|
993
39
|
scope: "0x78",
|
|
994
40
|
},
|
|
995
41
|
classFullName: TextAnnotation2d.classFullName,
|
|
42
|
+
placement: {
|
|
43
|
+
origin: { x: 0, y: 0 },
|
|
44
|
+
angle: 0,
|
|
45
|
+
},
|
|
996
46
|
...props,
|
|
997
47
|
}, mockIModel());
|
|
998
48
|
}
|
|
@@ -1028,74 +78,117 @@ describe("TextAnnotation element", () => {
|
|
|
1028
78
|
});
|
|
1029
79
|
});
|
|
1030
80
|
describe("setAnnotation", () => {
|
|
1031
|
-
it("updates JSON properties
|
|
81
|
+
it("updates JSON properties", () => {
|
|
1032
82
|
const elem = makeElement();
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
expect(elem.jsonProperties.annotation).to.deep.equal(annotation);
|
|
1038
|
-
expect(elem.jsonProperties.annotation).not.to.equal(annotation);
|
|
83
|
+
const textBlock = TextBlock.create({ styleName: "block" });
|
|
84
|
+
textBlock.appendRun(TextRun.create({ content: "text", styleName: "run" }));
|
|
85
|
+
const annotation = TextAnnotation.fromJSON({ textBlock: textBlock.toJSON() });
|
|
86
|
+
elem.setAnnotation(annotation);
|
|
87
|
+
expect(elem.jsonProperties.annotation).to.deep.equal(annotation.toJSON());
|
|
88
|
+
expect(elem.jsonProperties.annotation).not.to.equal(annotation.toJSON());
|
|
1039
89
|
});
|
|
1040
|
-
it("uses default subcategory by default", () => {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
90
|
+
// it("uses default subcategory by default", () => {
|
|
91
|
+
// const elem = makeElement();
|
|
92
|
+
// elem.setAnnotation(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } }));
|
|
93
|
+
// expect(elem.geom!.length).to.equal(1);
|
|
94
|
+
// expect(elem.geom![0].appearance!.subCategory).to.equal("0x13");
|
|
95
|
+
// });
|
|
96
|
+
// it("uses specific subcategory if provided", () => {
|
|
97
|
+
// const elem = makeElement();
|
|
98
|
+
// elem.setAnnotation(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } }));
|
|
99
|
+
// expect(elem.geom!.length).to.equal(1);
|
|
100
|
+
// expect(elem.geom![0].appearance!.subCategory).to.equal("0x1234");
|
|
101
|
+
// });
|
|
102
|
+
});
|
|
103
|
+
function createAnnotation() {
|
|
104
|
+
const styleOverrides = { fontName: "Karla" };
|
|
105
|
+
const block = TextBlock.create({ styleName: "block", styleOverrides });
|
|
106
|
+
block.appendRun(TextRun.create({ content: "Run, Barry,", styleName: "run1", styleOverrides }));
|
|
107
|
+
block.appendRun(TextRun.create({ content: " RUN!!! ", styleName: "run2", styleOverrides }));
|
|
108
|
+
block.appendRun(FractionRun.create({ numerator: "Harrison", denominator: "Wells", styleName: "run3", styleOverrides }));
|
|
109
|
+
block.margins = { left: 0, right: 1, top: 2, bottom: 3 };
|
|
110
|
+
const annotation = TextAnnotation.fromJSON({ textBlock: block.toJSON() });
|
|
111
|
+
annotation.anchor = { vertical: "middle", horizontal: "right" };
|
|
112
|
+
annotation.orientation = YawPitchRollAngles.createDegrees(1, 0, -1);
|
|
113
|
+
annotation.offset = Point3d.create(10, -5, 0);
|
|
114
|
+
annotation.frame = { shape: "rectangle", border: ColorDef.red.toJSON(), fill: ColorDef.green.toJSON(), borderWeight: 2 };
|
|
115
|
+
return annotation;
|
|
116
|
+
}
|
|
117
|
+
const createJobSubjectElement = (iModel, name) => {
|
|
118
|
+
const subj = Subject.create(iModel, iModel.elements.getRootSubject().id, name);
|
|
119
|
+
subj.setJsonProperty("Subject", { Job: name }); // eslint-disable-line @typescript-eslint/naming-convention
|
|
120
|
+
return subj;
|
|
121
|
+
};
|
|
122
|
+
const insertDrawingModel = (standaloneModel, parentId) => {
|
|
123
|
+
const definitionModel = DefinitionModel.insert(standaloneModel, parentId, "DrawingDefinition");
|
|
124
|
+
const category = DrawingCategory.insert(standaloneModel, definitionModel, "DrawingCategory", new SubCategoryAppearance());
|
|
125
|
+
const [_, model] = IModelTestUtils.createAndInsertDrawingPartitionAndModel(standaloneModel, { spec: '0x1', scope: '0x1', value: 'Drawing' }, undefined, parentId);
|
|
126
|
+
const displayStyle = DisplayStyle2d.insert(standaloneModel, definitionModel, "DisplayStyle2d");
|
|
127
|
+
const categorySelector = CategorySelector.insert(standaloneModel, definitionModel, "DrawingCategories", [category]);
|
|
128
|
+
const viewRange = new Range2d(0, 0, 500, 500);
|
|
129
|
+
DrawingViewDefinition.insert(standaloneModel, definitionModel, "Drawing View", model, categorySelector, displayStyle, viewRange);
|
|
130
|
+
return { category, model };
|
|
131
|
+
};
|
|
132
|
+
const insertSpatialModel = (standaloneModel, parentId) => {
|
|
133
|
+
const definitionModel = DefinitionModel.insert(standaloneModel, parentId, "SpatialDefinition");
|
|
134
|
+
const category = SpatialCategory.insert(standaloneModel, definitionModel, "spatialCategory", new SubCategoryAppearance());
|
|
135
|
+
const [_, model] = IModelTestUtils.createAndInsertPhysicalPartitionAndModel(standaloneModel, { spec: '0x1', scope: '0x1', value: 'Spatial' }, undefined, parentId);
|
|
136
|
+
const modelSelector = ModelSelector.insert(standaloneModel, definitionModel, "SpatialModelSelector", [model]);
|
|
137
|
+
const displayStyle = DisplayStyle3d.insert(standaloneModel, definitionModel, "DisplayStyle3d");
|
|
138
|
+
const categorySelector = CategorySelector.insert(standaloneModel, definitionModel, "spatialCategories", [category]);
|
|
139
|
+
const viewRange = new Range3d(0, 0, 0, 500, 500, 500);
|
|
140
|
+
SpatialViewDefinition.insertWithCamera(standaloneModel, definitionModel, "spatial View", modelSelector, categorySelector, displayStyle, viewRange);
|
|
141
|
+
return { category, model };
|
|
142
|
+
};
|
|
143
|
+
const createIModel = async (name) => {
|
|
144
|
+
const filePath = IModelTestUtils.prepareOutputFile("annotationTests", `${name}.bim`);
|
|
145
|
+
const iModel = StandaloneDb.createEmpty(filePath, {
|
|
146
|
+
rootSubject: { name: `${name} tests`, description: `${name} tests` },
|
|
147
|
+
client: "integration tests",
|
|
148
|
+
globalOrigin: { x: 0, y: 0 },
|
|
149
|
+
projectExtents: { low: { x: -500, y: -500, z: -50 }, high: { x: 500, y: 500, z: 50 } },
|
|
150
|
+
guid: Guid.createValue(),
|
|
1045
151
|
});
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
elem.setAnnotation(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } }), "0x1234");
|
|
1049
|
-
expect(elem.geom.length).to.equal(1);
|
|
1050
|
-
expect(elem.geom[0].appearance.subCategory).to.equal("0x1234");
|
|
152
|
+
await iModel.fonts.embedFontFile({
|
|
153
|
+
file: FontFile.createFromTrueTypeFileName(IModelTestUtils.resolveFontFile("Karla-Regular.ttf"))
|
|
1051
154
|
});
|
|
1052
|
-
|
|
1053
|
-
|
|
155
|
+
return iModel;
|
|
156
|
+
};
|
|
157
|
+
describe("TextAnnotation3d Persistence", () => {
|
|
1054
158
|
let imodel;
|
|
1055
|
-
let
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
159
|
+
let seedCategoryId;
|
|
160
|
+
let seedModelId;
|
|
161
|
+
before(async () => {
|
|
162
|
+
imodel = await createIModel("TextAnnotation3d");
|
|
163
|
+
const jobSubjectId = createJobSubjectElement(imodel, "Job").insert();
|
|
164
|
+
const { category, model } = insertSpatialModel(imodel, jobSubjectId);
|
|
165
|
+
expect(jobSubjectId).not.to.be.undefined;
|
|
166
|
+
expect(category).not.to.be.undefined;
|
|
167
|
+
expect(model).not.to.be.undefined;
|
|
168
|
+
seedCategoryId = category;
|
|
169
|
+
seedModelId = model;
|
|
1063
170
|
});
|
|
1064
171
|
after(() => imodel.close());
|
|
1065
|
-
function
|
|
172
|
+
function createElement3d(props) {
|
|
1066
173
|
return TextAnnotation3d.fromJSON({
|
|
1067
|
-
category:
|
|
1068
|
-
model:
|
|
1069
|
-
code:
|
|
1070
|
-
|
|
1071
|
-
|
|
174
|
+
category: seedCategoryId,
|
|
175
|
+
model: seedModelId,
|
|
176
|
+
code: Code.createEmpty(),
|
|
177
|
+
placement: {
|
|
178
|
+
origin: { x: 0, y: 0, z: 0 },
|
|
179
|
+
angles: YawPitchRollAngles.createDegrees(0, 0, 0).toJSON(),
|
|
1072
180
|
},
|
|
1073
181
|
...props,
|
|
1074
182
|
classFullName: TextAnnotation3d.classFullName,
|
|
1075
183
|
}, imodel);
|
|
1076
184
|
}
|
|
1077
|
-
function createAnnotation() {
|
|
1078
|
-
const block = TextBlock.createEmpty();
|
|
1079
|
-
block.styleName = "block";
|
|
1080
|
-
block.appendRun(makeTextRun("run", "run1"));
|
|
1081
|
-
block.appendRun(makeTextRun("RUN!!!!!", "run2"));
|
|
1082
|
-
return TextAnnotation.fromJSON({
|
|
1083
|
-
textBlock: block.toJSON(),
|
|
1084
|
-
anchor: {
|
|
1085
|
-
vertical: "middle",
|
|
1086
|
-
horizontal: "right",
|
|
1087
|
-
},
|
|
1088
|
-
orientation: { yaw: 1, pitch: 0, roll: -1 },
|
|
1089
|
-
offset: [0, -5, 100],
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
185
|
it("create method does not automatically compute the geometry", () => {
|
|
1093
186
|
const annotation = createAnnotation();
|
|
1094
|
-
const el =
|
|
187
|
+
const el = createElement3d({ jsonProperties: { annotation: annotation.toJSON() } });
|
|
1095
188
|
expect(el.getAnnotation().equals(annotation)).to.be.true;
|
|
1096
189
|
expect(el.geom).to.be.undefined;
|
|
1097
190
|
});
|
|
1098
|
-
function
|
|
191
|
+
function expectPlacement3d(el, expectValidBBox, expectedOrigin = [0, 0, 0], expectedYPR = [0, 0, 0]) {
|
|
1099
192
|
expect(el.placement.origin.x).to.equal(expectedOrigin[0]);
|
|
1100
193
|
expect(el.placement.origin.y).to.equal(expectedOrigin[1]);
|
|
1101
194
|
expect(el.placement.origin.z).to.equal(expectedOrigin[2]);
|
|
@@ -1104,19 +197,91 @@ describe("TextAnnotation element", () => {
|
|
|
1104
197
|
expect(el.placement.angles.roll.radians).to.equal(expectedYPR[2]);
|
|
1105
198
|
expect(el.placement.bbox.isNull).to.equal(!expectValidBBox);
|
|
1106
199
|
}
|
|
1107
|
-
|
|
1108
|
-
function test(annotation) {
|
|
1109
|
-
const el0 =
|
|
200
|
+
describe("inserts 3d element and round-trips through JSON", async () => {
|
|
201
|
+
async function test(annotation) {
|
|
202
|
+
const el0 = createElement3d();
|
|
1110
203
|
if (annotation) {
|
|
1111
204
|
el0.setAnnotation(annotation);
|
|
1112
205
|
}
|
|
1113
|
-
|
|
206
|
+
expectPlacement3d(el0, false);
|
|
207
|
+
expect(el0.toJSON().elementGeometryBuilderParams).not.to.be.undefined;
|
|
1114
208
|
const elId = el0.insert();
|
|
1115
209
|
expect(Id64.isValidId64(elId)).to.be.true;
|
|
1116
210
|
const el1 = imodel.elements.getElement(elId);
|
|
1117
211
|
expect(el1).not.to.be.undefined;
|
|
1118
212
|
expect(el1 instanceof TextAnnotation3d).to.be.true;
|
|
1119
|
-
|
|
213
|
+
expectPlacement3d(el1, undefined !== annotation && !annotation.textBlock.isEmpty);
|
|
214
|
+
const anno = el1.getAnnotation();
|
|
215
|
+
if (!annotation) {
|
|
216
|
+
expect(anno).to.be.undefined;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
expect(anno).not.to.be.undefined;
|
|
220
|
+
expect(anno.equals(annotation)).to.be.true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
it("roundtrips an empty annotation", async () => { await test(); });
|
|
224
|
+
it("roundtrips an annotation with a style", async () => { await test(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } })); });
|
|
225
|
+
it("roundtrips an annotation with a textBlock", async () => { await test(createAnnotation()); });
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe("TextAnnotation2d Persistence", () => {
|
|
229
|
+
let imodel;
|
|
230
|
+
let seedCategoryId;
|
|
231
|
+
let seedModelId;
|
|
232
|
+
before(async () => {
|
|
233
|
+
imodel = await createIModel("TextAnnotation2d");
|
|
234
|
+
const jobSubjectId = createJobSubjectElement(imodel, "Job").insert();
|
|
235
|
+
const { category, model } = insertDrawingModel(imodel, jobSubjectId);
|
|
236
|
+
expect(jobSubjectId).not.to.be.undefined;
|
|
237
|
+
expect(category).not.to.be.undefined;
|
|
238
|
+
expect(model).not.to.be.undefined;
|
|
239
|
+
seedCategoryId = category;
|
|
240
|
+
seedModelId = model;
|
|
241
|
+
});
|
|
242
|
+
after(() => {
|
|
243
|
+
imodel.saveChanges("tests");
|
|
244
|
+
imodel.close();
|
|
245
|
+
});
|
|
246
|
+
function createElement2d(props) {
|
|
247
|
+
return TextAnnotation2d.fromJSON({
|
|
248
|
+
category: seedCategoryId,
|
|
249
|
+
model: seedModelId,
|
|
250
|
+
code: Code.createEmpty(),
|
|
251
|
+
placement: {
|
|
252
|
+
origin: { x: 0, y: 0 },
|
|
253
|
+
angle: Angle.createDegrees(0).toJSON(),
|
|
254
|
+
},
|
|
255
|
+
...props,
|
|
256
|
+
classFullName: TextAnnotation2d.classFullName,
|
|
257
|
+
}, imodel);
|
|
258
|
+
}
|
|
259
|
+
it("create method does not automatically compute the geometry", () => {
|
|
260
|
+
const annotation = createAnnotation();
|
|
261
|
+
const el = createElement2d({ jsonProperties: { annotation: annotation.toJSON() } });
|
|
262
|
+
expect(el.getAnnotation().equals(annotation)).to.be.true;
|
|
263
|
+
expect(el.geom).to.be.undefined;
|
|
264
|
+
});
|
|
265
|
+
function expectPlacement2d(el, expectValidBBox, expectedOrigin = [0, 0, 0], expectedYPR = [0, 0, 0]) {
|
|
266
|
+
expect(el.placement.origin.x).to.equal(expectedOrigin[0]);
|
|
267
|
+
expect(el.placement.origin.y).to.equal(expectedOrigin[1]);
|
|
268
|
+
expect(el.placement.angle.degrees).to.equal(expectedYPR[0]);
|
|
269
|
+
expect(el.placement.bbox.isNull).to.equal(!expectValidBBox);
|
|
270
|
+
}
|
|
271
|
+
describe("inserts 2d element and round-trips through JSON", async () => {
|
|
272
|
+
async function test(annotation) {
|
|
273
|
+
const el0 = createElement2d();
|
|
274
|
+
if (annotation) {
|
|
275
|
+
el0.setAnnotation(annotation);
|
|
276
|
+
}
|
|
277
|
+
expectPlacement2d(el0, false);
|
|
278
|
+
expect(el0.toJSON().elementGeometryBuilderParams).not.to.be.undefined;
|
|
279
|
+
const elId = el0.insert();
|
|
280
|
+
expect(Id64.isValidId64(elId)).to.be.true;
|
|
281
|
+
const el1 = imodel.elements.getElement(elId);
|
|
282
|
+
expect(el1).not.to.be.undefined;
|
|
283
|
+
expect(el1 instanceof TextAnnotation2d).to.be.true;
|
|
284
|
+
expectPlacement2d(el1, undefined !== annotation && !annotation.textBlock.isEmpty);
|
|
1120
285
|
const anno = el1.getAnnotation();
|
|
1121
286
|
if (!annotation) {
|
|
1122
287
|
expect(anno).to.be.undefined;
|
|
@@ -1126,9 +291,9 @@ describe("TextAnnotation element", () => {
|
|
|
1126
291
|
expect(anno.equals(annotation)).to.be.true;
|
|
1127
292
|
}
|
|
1128
293
|
}
|
|
1129
|
-
test();
|
|
1130
|
-
test(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } }));
|
|
1131
|
-
test(createAnnotation());
|
|
294
|
+
it("roundtrips an empty annotation", async () => { await test(); });
|
|
295
|
+
it("roundtrips an annotation with a style", async () => { await test(TextAnnotation.fromJSON({ textBlock: { styleName: "block" } })); });
|
|
296
|
+
it("roundtrips an annotation with a textBlock", async () => { await test(createAnnotation()); });
|
|
1132
297
|
});
|
|
1133
298
|
});
|
|
1134
299
|
});
|