Skip to content

Commit b8b9746

Browse files
committed
export QuartoPreview initialize options
1 parent 8178c36 commit b8b9746

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/webui/quarto-preview/src/index.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ export interface Options {
2323
isPresentation: boolean;
2424
}
2525

26+
// Store the current options
27+
let currentOptions: Options | null = null;
28+
2629
function init(options: Options) {
30+
// Store the options for export
31+
currentOptions = options;
32+
2733
try {
2834
// detect dark mode
2935
const darkMode = detectDarkMode();
@@ -51,6 +57,13 @@ function init(options: Options) {
5157
} else {
5258
handleViewerMessages(options.inputFile);
5359
}
60+
61+
// Dispatch event when initialized
62+
const event = new CustomEvent("quarto-preview-initialized", {
63+
detail: options,
64+
});
65+
66+
document.dispatchEvent(event);
5467
} catch (error) {
5568
console.error(error);
5669
}
@@ -65,4 +78,9 @@ function detectDarkMode() {
6578
}
6679
}
6780

68-
export { init };
81+
// Export the current options
82+
function getOptions() {
83+
return currentOptions;
84+
}
85+
86+
export { init, getOptions };

0 commit comments

Comments
 (0)