Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 2x 2x 2x 8x 8x 8x 8x 3x 3x 3x 3x 3x 3x | import { MarkdownRenderChild } from 'obsidian'; import type { ILogger } from 'src/interfaces/ILogger'; import { ICustomizableRenderChild } from './ICustomizableRenderChild'; import { Register } from '../DependencyInjection/decorators/Register'; /** * Customizable Render Child class. * This class is a wrapper for the `MarkdownRenderChild` class. * It allows you to customize the `onLoad` and `onUnload` functions. * @remarks Use this as a child when you want to customize the `onLoad` and `onUnload` functions. */ @Register('CustomizableRenderChild') export default class CustomizableRenderChild extends MarkdownRenderChild implements ICustomizableRenderChild { private readonly _logger: ILogger | undefined; private readonly _onUnload: (() => void) | undefined; private readonly _onLoad: (() => void) | undefined; /** * Constructor of the `CustomizableRenderChild` class. * @param containerEl The HTML container. * @param onLoad Your custom `onLoad` function. Set `undefined` if you don't want to use it. * @param onUnload Your custom `onUnload` function. Set `undefined` if you don't want to use it. * @param logger Your custom logger. */ constructor( containerEl: HTMLElement, onLoad?: (() => void) | undefined, onUnload?: (() => void) | undefined, logger?: ILogger, ) { super(containerEl); this._logger = logger ?? undefined; this._onLoad = onLoad; this._onUnload = onUnload; } /** * Custom `onLoad` function. * This function is called when the child is loaded. * @remarks Calls the custom `onLoad` function if it is defined and then calls the base `onLoad` function. */ override onload(): void { this._logger?.trace('On Load'); this._onLoad?.(); super.onload(); } /** * Custom `onUnload` function. * This function is called when the child is unloaded. * @remarks Calls the custom `onUnload` function if it is defined and then calls the base `onUnload` function. */ override onunload(): void { this._logger?.trace('On Unload'); this._onUnload?.(); super.onunload(); } } |