chore(split): gitGraph

This commit is contained in:
Sidharth Vinod 2022-11-18 16:10:06 +05:30
parent 38e5c3a81e
commit 25bc381361
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 30 additions and 1 deletions

View File

@ -1,5 +1,21 @@
import type { DiagramDetector } from '../../diagram-api/types';
import type { ExternalDiagramDefinition } from '../../diagram-api/types';
export const gitGraphDetector: DiagramDetector = (txt) => {
const id = 'gitGraph';
const detector: DiagramDetector = (txt) => {
return txt.match(/^\s*gitGraph/) !== null;
};
const loader = async () => {
const { diagram } = await import('./gitGraphDiagram');
return { id, diagram };
};
const plugin: ExternalDiagramDefinition = {
id,
detector,
loader,
};
export default plugin;

View File

@ -0,0 +1,13 @@
// @ts-ignore: TODO Fix ts errors
import gitGraphParser from './parser/gitGraph';
import gitGraphDb from './gitGraphAst';
import gitGraphRenderer from './gitGraphRenderer';
import gitGraphStyles from './styles';
import { DiagramDefinition } from '../../diagram-api/types';
export const diagram: DiagramDefinition = {
parser: gitGraphParser,
db: gitGraphDb,
renderer: gitGraphRenderer,
styles: gitGraphStyles,
};