Skip to content

Commit

Permalink
Merge pull request #7647 from weseek/imprv/122147-mermaid
Browse files Browse the repository at this point in the history
feat: Support Mermaid (move into the feature dierctory)
  • Loading branch information
yuki-takei committed May 15, 2023
2 parents 0be1f0f + cf2dc5f commit 1ff92b0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
21 changes: 10 additions & 11 deletions apps/app/src/client/services/renderer/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ import type { Pluggable } from 'unified';

import { DrawioViewerWithEditButton } from '~/components/ReactMarkdownComponents/DrawioViewerWithEditButton';
import { Header } from '~/components/ReactMarkdownComponents/Header';
import { MermaidViewer } from '~/components/ReactMarkdownComponents/MermaidViewer';
import { TableWithEditButton } from '~/components/ReactMarkdownComponents/TableWithEditButton';
import * as mermaidPlugin from '~/features/mermaid-plugin';
import { RehypeSanitizeOption } from '~/interfaces/rehype';
import type { RendererOptions } from '~/interfaces/renderer-options';
import type { RendererConfig } from '~/interfaces/services/renderer';
import * as addLineNumberAttribute from '~/services/renderer/rehype-plugins/add-line-number-attribute';
import * as keywordHighlighter from '~/services/renderer/rehype-plugins/keyword-highlighter';
import * as relocateToc from '~/services/renderer/rehype-plugins/relocate-toc';
import * as mermaid from '~/services/renderer/remark-plugins/mermaid';
import * as plantuml from '~/services/renderer/remark-plugins/plantuml';
import * as xsvToTable from '~/services/renderer/remark-plugins/xsv-to-table';
import {
Expand Down Expand Up @@ -63,7 +62,7 @@ export const generateViewOptions = (
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
mermaid.remarkPlugin,
mermaidPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -79,7 +78,7 @@ export const generateViewOptions = (
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
mermaid.sanitizeOption,
mermaidPlugin.sanitizeOption,
)]
: () => {};

Expand Down Expand Up @@ -109,7 +108,7 @@ export const generateViewOptions = (
components.gallery = refsGrowiPlugin.Gallery;
components.drawio = DrawioViewerWithEditButton;
components.table = TableWithEditButton;
components.mermaid = MermaidViewer;
components.mermaid = mermaidPlugin.MermaidViewer;
}

if (config.isEnabledXssPrevention) {
Expand Down Expand Up @@ -169,7 +168,7 @@ export const generateSimpleViewOptions = (
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
mermaid.remarkPlugin,
mermaidPlugin.remarkPlugin,
);

const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
Expand All @@ -189,7 +188,7 @@ export const generateSimpleViewOptions = (
drawioPlugin.sanitizeOption,
lsxGrowiPlugin.sanitizeOption,
refsGrowiPlugin.sanitizeOption,
mermaid.sanitizeOption,
mermaidPlugin.sanitizeOption,
)]
: () => {};

Expand All @@ -211,7 +210,7 @@ export const generateSimpleViewOptions = (
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
components.mermaid = MermaidViewer;
components.mermaid = mermaidPlugin.MermaidViewer;
}

if (config.isEnabledXssPrevention) {
Expand Down Expand Up @@ -246,7 +245,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
xsvToTable.remarkPlugin,
lsxGrowiPlugin.remarkPlugin,
refsGrowiPlugin.remarkPlugin,
mermaid.remarkPlugin,
mermaidPlugin.remarkPlugin,
);
if (config.isEnabledLinebreaks) {
remarkPlugins.push(breaks);
Expand All @@ -263,7 +262,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
refsGrowiPlugin.sanitizeOption,
drawioPlugin.sanitizeOption,
addLineNumberAttribute.sanitizeOption,
mermaid.sanitizeOption,
mermaidPlugin.sanitizeOption,
)]
: () => {};

Expand All @@ -285,7 +284,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
components.refsimg = refsGrowiPlugin.RefsImgImmutable;
components.gallery = refsGrowiPlugin.GalleryImmutable;
components.drawio = drawioPlugin.DrawioViewer;
components.mermaid = MermaidViewer;
components.mermaid = mermaidPlugin.MermaidViewer;
}

if (config.isEnabledXssPrevention) {
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/features/mermaid-plugin/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MermaidViewer } from './MermaidViewer';
2 changes: 2 additions & 0 deletions apps/app/src/features/mermaid-plugin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './components';
export * from './services';
1 change: 1 addition & 0 deletions apps/app/src/features/mermaid-plugin/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { remarkPlugin, sanitizeOption } from './mermaid';

0 comments on commit 1ff92b0

Please sign in to comment.