CodeBlockRenderer
This class is responsible for rendering custom code blocks within Obsidian markdown files. It registers a markdown code block processor for the ‘enzyme’ code block type and defines the rendering logic for these blocks. The class interacts with various components of the Enzyme plugin, such as EnzymeAgent, and the markdown code block processor registration function, to facilitate the rendering of ‘enzyme’ blocks with interactive elements and integration with the enzymeing engine.
Methods
createSynthesisContainerAction()
Creates a synthesis container and performs the provided action on it. This function is designed to be called when a user interaction requires a synthesis container to be created and an action to be executed with it. The action is an asynchronous callback that receives the created synthesis container as an argument. The execution of the action is guarded by an execution lock to prevent concurrent executions.
Parameters
Parameter | Type | Description |
---|---|---|
el | HTMLElement | The HTML element where the synthesis container will be attached. |
context | any | The context in which the synthesis container is being created. |
executionLock | object | An object with an ‘isExecuting’ property that indicates if an action is currently being executed. |
executionLock.isExecuting | boolean | - |
callback | (synthesisContainerEl ) => Promise <void > | The asynchronous function to be executed with the created synthesis container. It must return a Promise. |
Source
render/CodeBlockRenderer.ts:187
parseEnzymeBlockContents()
Parses the contents of a Enzyme code block as YAML, producing an Aggregator (with guidance + sources, or by ID)
Parameters
Parameter | Type | Description |
---|---|---|
contents | string | the raw contents, which we’ll try to parse as valid YAML syntax. |
Returns
metadata, i.e. Aggregator metadata
Source
render/CodeBlockRenderer.ts:238
renderEnzyme()
Renders the ‘enzyme’ code block in the markdown preview.
This function is responsible for parsing the contents of a ‘enzyme’ code block, creating the necessary HTML elements to display the block within the markdown preview, and setting up the interaction logic for the ‘Send’ button which triggers the enzymeing process.
Parameters
Parameter | Type | Description |
---|---|---|
blockContents | string | The raw text content of the ‘enzyme’ code block. |
el | HTMLElement | The parent HTML element where the ‘enzyme’ block will be rendered. |
context | MarkdownPostProcessorContext | The context provided by Obsidian for post-processing the markdown. |
Source
render/CodeBlockRenderer.ts:67
Generated using typedoc-plugin-markdown and TypeDoc