-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #310 from RyoJerryYu/refactor-parsing-phase-refactor
feat: add new rendering plugin system
- Loading branch information
Showing
40 changed files
with
1,408 additions
and
935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
// jest.config.js | ||
const nextJest = require('next/jest') | ||
const nextJest = require("next/jest"); | ||
|
||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}) | ||
dir: "./", | ||
}); | ||
|
||
// Add any custom config to be passed to Jest | ||
/** @type {import('jest').Config} */ | ||
const customJestConfig = { | ||
// Add more setup options before each test is run | ||
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work | ||
moduleDirectories: ['node_modules', '<rootDir>/'], | ||
moduleDirectories: ["node_modules", "<rootDir>/"], | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
"^@/(.*)$": "<rootDir>/src/$1", | ||
}, | ||
testEnvironment: 'jest-environment-jsdom', | ||
} | ||
testEnvironment: "jest-environment-jsdom", | ||
// for importing ESM modules, should treat and transform them in node_modules | ||
// see: https://jestjs.io/docs/next/ecmascript-modules | ||
transform: {}, | ||
extensionsToTreatAsEsm: [".ts", ".tsx"], | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(customJestConfig) | ||
module.exports = createJestConfig(customJestConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
BarElement, | ||
CategoryScale, | ||
Chart as ChartJS, | ||
Legend, | ||
LinearScale, | ||
Title, | ||
Tooltip, | ||
} from "chart.js"; | ||
import { Bar } from "react-chartjs-2"; | ||
|
||
ChartJS.register( | ||
CategoryScale, | ||
LinearScale, | ||
BarElement, | ||
Title, | ||
Tooltip, | ||
Legend | ||
); | ||
|
||
export { Bar }; |
10 changes: 10 additions & 0 deletions
10
src/components-parsing/complex-plugin-components/code-block-escape/CodeBlockMermaid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { MermaidExcalidraw } from "@/components/ExcalidrawScene/MermaidExcalidraw"; | ||
import { CodeBlockProps } from "../../../core/parsing/complex-plugins/code-block-escape/types"; | ||
|
||
export const CodeBlockMermaid = (props: CodeBlockProps) => { | ||
let name = props.lang ?? undefined; // string | undefined | ||
if (props.lang && props.meta) { | ||
name = `${props.lang} ${props.meta}`; | ||
} | ||
return <MermaidExcalidraw name={name}>{props.value}</MermaidExcalidraw>; | ||
}; |
7 changes: 7 additions & 0 deletions
7
src/components-parsing/complex-plugin-components/obsidian-rich/ObsidianRichExcalidraw.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import EmbededExcalidraw from "@/components/ExcalidrawScene/EmbededExcalidraw"; | ||
import { ObsidianRichProps } from "../../../core/parsing/complex-plugins/obsidian-rich/types"; | ||
|
||
export const ObsidianRichExcalidraw = (props: ObsidianRichProps) => { | ||
console.log("ObsidianRichExcalidraw:", props); | ||
return <EmbededExcalidraw {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import License from "@/components/License"; | ||
import { MDXComponents } from "mdx/types"; | ||
import { Bar } from "./chartjs"; | ||
import { CodeBlockMermaid } from "./complex-plugin-components/code-block-escape/CodeBlockMermaid"; | ||
import { ObsidianRichExcalidraw } from "./complex-plugin-components/obsidian-rich/ObsidianRichExcalidraw"; | ||
|
||
export const components: MDXComponents = { | ||
Bar, | ||
License, | ||
CodeBlockMermaid, | ||
ObsidianRichExcalidraw, | ||
// code: (props: any) => { | ||
// if (props.className === "language-mermaid") { | ||
// return <Mermaid {...props} />; | ||
// } | ||
// const language = props.className?.replace("language-", ""); | ||
// return <CodeBlock language={language} {...props} />; | ||
// }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { dynamicLoading } from "@/components/Loading/dynamic-loading"; | ||
import { MermaidCodeBlockProps } from "./clientComponent/MermaidExcalidrawImpl"; | ||
|
||
const MermaidExcalidrawImpl = dynamicLoading( | ||
async () => | ||
(await import("./clientComponent/MermaidExcalidrawImpl")) | ||
.MermaidExcalidrawImpl | ||
); | ||
|
||
export function MermaidExcalidraw(props: MermaidCodeBlockProps) { | ||
return ( | ||
<div className="relative h-[600px] py-4"> | ||
<MermaidExcalidrawImpl {...props} /> | ||
</div> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.