|
1 | | -import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getPreferredTheme } from "../../_content/BootstrapBlazor/modules/utility.js" |
| 1 | +import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getPreferredTheme, registerBootstrapBlazorModule } from "../../_content/BootstrapBlazor/modules/utility.js" |
2 | 2 | import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js" |
3 | 3 |
|
4 | 4 | export async function init(id, title, assetRoot) { |
@@ -48,6 +48,15 @@ export async function init(id, title, assetRoot) { |
48 | 48 | preElement.style.maxHeight = `${preHeight}px` |
49 | 49 | }) |
50 | 50 | } |
| 51 | + |
| 52 | + registerBootstrapBlazorModule('Pre', id, () => { |
| 53 | + EventHandler.on(document, 'changed.bb.theme', updateTheme); |
| 54 | + }); |
| 55 | +} |
| 56 | + |
| 57 | +const updateTheme = e => { |
| 58 | + const theme = e.theme; |
| 59 | + switchTheme(theme); |
51 | 60 | } |
52 | 61 |
|
53 | 62 | export async function highlight(id) { |
@@ -96,7 +105,12 @@ export function dispose(id) { |
96 | 105 | return |
97 | 106 | } |
98 | 107 |
|
99 | | - EventHandler.off(el, 'click', '.btn-copy') |
100 | | - EventHandler.off(el, 'click', '.btn-plus') |
101 | | - EventHandler.off(el, 'click', '.btn-minus') |
| 108 | + EventHandler.off(el, 'click', '.btn-copy'); |
| 109 | + EventHandler.off(el, 'click', '.btn-plus'); |
| 110 | + EventHandler.off(el, 'click', '.btn-minus'); |
| 111 | + |
| 112 | + const { Pre } = window.BootstrapBlazor; |
| 113 | + Pre.dispose(id, () => { |
| 114 | + EventHandler.off(document, 'changed.bb.theme', updateTheme); |
| 115 | + }); |
102 | 116 | } |
0 commit comments