Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to initialize Presentation with custom props #314

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/viewer-react",
"comment": "Added ability to supply custom Presentation initialization props",
"type": "minor"
}
],
"packageName": "@itwin/viewer-react"
}
44 changes: 22 additions & 22 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ export class BaseInitializer {
yield UiFramework.initialize(undefined);

// initialize Presentation
yield Presentation.initialize({
presentation: {
activeLocale: IModelApp.localization.getLanguageList()[0],
aruniverse marked this conversation as resolved.
Show resolved Hide resolved
},
});
yield Presentation.initialize(viewerOptions?.presentationProps);

// Sync selection count & active selection scope between Presentation and AppUi. Runs after the Presentation is initialized.
syncSelectionCount();
Expand Down
4 changes: 4 additions & 0 deletions packages/modules/viewer-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import type {
XAndY,
XYAndZ,
} from "@itwin/core-geometry";
import { PresentationProps } from "@itwin/presentation-frontend";

export type Without<T1, T2> = { [P in Exclude<keyof T1, keyof T2>]?: never };
export type XOR<T1, T2> = T1 | T2 extends Record<string, unknown>
Expand Down Expand Up @@ -137,6 +138,8 @@ export interface ViewerInitializerParams extends ViewerIModelAppOptions {
additionalI18nNamespaces?: string[];
/** array of iTwin.js Extensions */
extensions?: ExtensionProvider[];
/** Props for presentation initialization */
presentationProps?: PresentationProps
}
export type RequiredViewerProps = XOR<
XOR<ConnectedViewerProps, FileViewerProps>,
Expand Down Expand Up @@ -192,6 +195,7 @@ const iTwinViewerInitializerParamSample: OptionalToUndefinedUnion<ViewerInitiali
additionalI18nNamespaces: undefined,
extensions: undefined,
userPreferences: undefined,
presentationProps: undefined,
};

export const iTwinViewerInitializerParamList = Object.keys(
Expand Down
Loading