mirror of
https://github.com/prodigist/ReactiveNotes.git
synced 2026-07-22 12:30:26 +00:00
Localised Markdown Rendering to Reactcomponent classes
This commit is contained in:
parent
6352387216
commit
9db72da603
4 changed files with 19009 additions and 1102 deletions
15
main.tsx
15
main.tsx
|
|
@ -10,6 +10,7 @@ import { ComponentRegistry } from 'src/components/componentRegistry';
|
|||
import { ErrorBoundary } from 'src/components/ErrorBoundary';
|
||||
|
||||
|
||||
|
||||
class ReactComponentChild extends MarkdownRenderChild {
|
||||
private root: ReturnType<typeof createRoot>;
|
||||
private storage: StorageManager;
|
||||
|
|
@ -40,10 +41,10 @@ class ReactComponentChild extends MarkdownRenderChild {
|
|||
// Add these classes to the container
|
||||
containerEl.classList.add('react-component-container');
|
||||
if (document.body.hasClass('theme-dark')) {
|
||||
containerEl.classList.add('theme-dark');
|
||||
// containerEl.classList.add('theme-dark');
|
||||
containerEl.classList.add('dark');
|
||||
}else {
|
||||
containerEl.classList.add('theme-light');
|
||||
// containerEl.classList.add('theme-light');
|
||||
containerEl.classList.remove('dark');
|
||||
}
|
||||
|
||||
|
|
@ -391,7 +392,9 @@ export default class ReactNotesPlugin extends Plugin {
|
|||
);
|
||||
// Register a global Markdown postprocessor for HTML
|
||||
this.registerMarkdownPostProcessor((element, context) => {
|
||||
this.parseMarkdownInHtml(element);
|
||||
if (element.closest('.react-component-container')) {
|
||||
this.parseMarkdownInHtml(element);
|
||||
}
|
||||
});
|
||||
// Initial theme setup
|
||||
this.updateTheme();
|
||||
|
|
@ -419,8 +422,8 @@ export default class ReactNotesPlugin extends Plugin {
|
|||
};
|
||||
private async parseMarkdownInHtml(container: HTMLElement) {
|
||||
// Query all divs or specific HTML blocks you want to process
|
||||
const htmlBlocks = Array.from(container.querySelectorAll('div')) as HTMLDivElement[];
|
||||
|
||||
const htmlBlocks = Array.from(container.querySelectorAll('div:not(.markdown-rendered)')) as HTMLDivElement[];
|
||||
//console.log('Processing HTML container:', container);
|
||||
// Iterate over each div block
|
||||
for (const block of htmlBlocks) {
|
||||
// Check if it already contains rendered Markdown (to avoid double processing)
|
||||
|
|
@ -441,7 +444,7 @@ const tempDiv = document.createElement('div');
|
|||
tempDiv.appendChild(block.cloneNode(true));
|
||||
const safeContent = tempDiv.textContent || "";
|
||||
|
||||
await MarkdownRenderer.render(
|
||||
await MarkdownRenderer.renderMarkdown(
|
||||
this.app,
|
||||
safeContent,
|
||||
block,
|
||||
|
|
|
|||
9790
outStyles.css
9790
outStyles.css
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "reactive-notes",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Transform your vault into a reactive computational environment with React components.",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
10304
styles.css
10304
styles.css
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue