|
@@ -10,6 +10,7 @@ import sanitize from 'rehype-sanitize';
|
|
|
import slug from 'rehype-slug';
|
|
import slug from 'rehype-slug';
|
|
|
import type { HtmlElementNode } from 'rehype-toc';
|
|
import type { HtmlElementNode } from 'rehype-toc';
|
|
|
import breaks from 'remark-breaks';
|
|
import breaks from 'remark-breaks';
|
|
|
|
|
+import remarkGithubAdmonitionsToDirectives from 'remark-github-admonitions-to-directives';
|
|
|
import math from 'remark-math';
|
|
import math from 'remark-math';
|
|
|
import deepmerge from 'ts-deepmerge';
|
|
import deepmerge from 'ts-deepmerge';
|
|
|
import type { Pluggable } from 'unified';
|
|
import type { Pluggable } from 'unified';
|
|
@@ -19,6 +20,7 @@ import { Header } from '~/client/components/ReactMarkdownComponents/Header';
|
|
|
import { LightBox } from '~/client/components/ReactMarkdownComponents/LightBox';
|
|
import { LightBox } from '~/client/components/ReactMarkdownComponents/LightBox';
|
|
|
import { RichAttachment } from '~/client/components/ReactMarkdownComponents/RichAttachment';
|
|
import { RichAttachment } from '~/client/components/ReactMarkdownComponents/RichAttachment';
|
|
|
import { TableWithEditButton } from '~/client/components/ReactMarkdownComponents/TableWithEditButton';
|
|
import { TableWithEditButton } from '~/client/components/ReactMarkdownComponents/TableWithEditButton';
|
|
|
|
|
+import * as callout from '~/features/callout';
|
|
|
import * as mermaid from '~/features/mermaid';
|
|
import * as mermaid from '~/features/mermaid';
|
|
|
import type { RendererOptions } from '~/interfaces/renderer-options';
|
|
import type { RendererOptions } from '~/interfaces/renderer-options';
|
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
import type { RendererConfig } from '~/interfaces/services/renderer';
|
|
@@ -26,6 +28,7 @@ import * as addLineNumberAttribute from '~/services/renderer/rehype-plugins/add-
|
|
|
import * as keywordHighlighter from '~/services/renderer/rehype-plugins/keyword-highlighter';
|
|
import * as keywordHighlighter from '~/services/renderer/rehype-plugins/keyword-highlighter';
|
|
|
import * as relocateToc from '~/services/renderer/rehype-plugins/relocate-toc';
|
|
import * as relocateToc from '~/services/renderer/rehype-plugins/relocate-toc';
|
|
|
import * as attachment from '~/services/renderer/remark-plugins/attachment';
|
|
import * as attachment from '~/services/renderer/remark-plugins/attachment';
|
|
|
|
|
+import * as codeBlock from '~/services/renderer/remark-plugins/codeblock';
|
|
|
import * as plantuml from '~/services/renderer/remark-plugins/plantuml';
|
|
import * as plantuml from '~/services/renderer/remark-plugins/plantuml';
|
|
|
import * as xsvToTable from '~/services/renderer/remark-plugins/xsv-to-table';
|
|
import * as xsvToTable from '~/services/renderer/remark-plugins/xsv-to-table';
|
|
|
import {
|
|
import {
|
|
@@ -64,6 +67,8 @@ export const generateViewOptions = (
|
|
|
mermaid.remarkPlugin,
|
|
mermaid.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
attachment.remarkPlugin,
|
|
attachment.remarkPlugin,
|
|
|
|
|
+ remarkGithubAdmonitionsToDirectives,
|
|
|
|
|
+ callout.remarkPlugin,
|
|
|
lsxGrowiDirective.remarkPlugin,
|
|
lsxGrowiDirective.remarkPlugin,
|
|
|
refsGrowiDirective.remarkPlugin,
|
|
refsGrowiDirective.remarkPlugin,
|
|
|
);
|
|
);
|
|
@@ -71,15 +76,17 @@ export const generateViewOptions = (
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable | (() => void) = config.isEnabledXssPrevention
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
getCommonSanitizeOption(config),
|
|
getCommonSanitizeOption(config),
|
|
|
presentation.sanitizeOption,
|
|
presentation.sanitizeOption,
|
|
|
drawio.sanitizeOption,
|
|
drawio.sanitizeOption,
|
|
|
mermaid.sanitizeOption,
|
|
mermaid.sanitizeOption,
|
|
|
|
|
+ callout.sanitizeOption,
|
|
|
attachment.sanitizeOption,
|
|
attachment.sanitizeOption,
|
|
|
lsxGrowiDirective.sanitizeOption,
|
|
lsxGrowiDirective.sanitizeOption,
|
|
|
refsGrowiDirective.sanitizeOption,
|
|
refsGrowiDirective.sanitizeOption,
|
|
|
|
|
+ codeBlock.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -110,6 +117,7 @@ export const generateViewOptions = (
|
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
|
components.table = TableWithEditButton;
|
|
components.table = TableWithEditButton;
|
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
|
|
|
+ components.callout = callout.CalloutViewer;
|
|
|
components.attachment = RichAttachment;
|
|
components.attachment = RichAttachment;
|
|
|
components.img = LightBox;
|
|
components.img = LightBox;
|
|
|
}
|
|
}
|
|
@@ -129,9 +137,10 @@ export const generateTocOptions = (config: RendererConfig, tocNode: HtmlElementN
|
|
|
// add remark plugins
|
|
// add remark plugins
|
|
|
// remarkPlugins.push();
|
|
// remarkPlugins.push();
|
|
|
|
|
|
|
|
- const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable | (() => void) = config.isEnabledXssPrevention
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
getCommonSanitizeOption(config),
|
|
getCommonSanitizeOption(config),
|
|
|
|
|
+ codeBlock.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -166,6 +175,8 @@ export const generateSimpleViewOptions = (
|
|
|
mermaid.remarkPlugin,
|
|
mermaid.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
attachment.remarkPlugin,
|
|
attachment.remarkPlugin,
|
|
|
|
|
+ remarkGithubAdmonitionsToDirectives,
|
|
|
|
|
+ callout.remarkPlugin,
|
|
|
lsxGrowiDirective.remarkPlugin,
|
|
lsxGrowiDirective.remarkPlugin,
|
|
|
refsGrowiDirective.remarkPlugin,
|
|
refsGrowiDirective.remarkPlugin,
|
|
|
);
|
|
);
|
|
@@ -176,15 +187,17 @@ export const generateSimpleViewOptions = (
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable | (() => void) = config.isEnabledXssPrevention
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
getCommonSanitizeOption(config),
|
|
getCommonSanitizeOption(config),
|
|
|
presentation.sanitizeOption,
|
|
presentation.sanitizeOption,
|
|
|
drawio.sanitizeOption,
|
|
drawio.sanitizeOption,
|
|
|
mermaid.sanitizeOption,
|
|
mermaid.sanitizeOption,
|
|
|
|
|
+ callout.sanitizeOption,
|
|
|
attachment.sanitizeOption,
|
|
attachment.sanitizeOption,
|
|
|
lsxGrowiDirective.sanitizeOption,
|
|
lsxGrowiDirective.sanitizeOption,
|
|
|
refsGrowiDirective.sanitizeOption,
|
|
refsGrowiDirective.sanitizeOption,
|
|
|
|
|
+ codeBlock.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -207,6 +220,7 @@ export const generateSimpleViewOptions = (
|
|
|
components.gallery = refsGrowiDirective.GalleryImmutable;
|
|
components.gallery = refsGrowiDirective.GalleryImmutable;
|
|
|
components.drawio = drawio.DrawioViewer;
|
|
components.drawio = drawio.DrawioViewer;
|
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
|
|
|
+ components.callout = callout.CalloutViewer;
|
|
|
components.attachment = RichAttachment;
|
|
components.attachment = RichAttachment;
|
|
|
components.img = LightBox;
|
|
components.img = LightBox;
|
|
|
}
|
|
}
|
|
@@ -227,7 +241,7 @@ export const generatePresentationViewOptions = (
|
|
|
const { rehypePlugins } = options;
|
|
const { rehypePlugins } = options;
|
|
|
|
|
|
|
|
|
|
|
|
|
- const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable | (() => void) = config.isEnabledXssPrevention
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
addLineNumberAttribute.sanitizeOption,
|
|
addLineNumberAttribute.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
@@ -258,6 +272,8 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
mermaid.remarkPlugin,
|
|
mermaid.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
attachment.remarkPlugin,
|
|
attachment.remarkPlugin,
|
|
|
|
|
+ remarkGithubAdmonitionsToDirectives,
|
|
|
|
|
+ callout.remarkPlugin,
|
|
|
lsxGrowiDirective.remarkPlugin,
|
|
lsxGrowiDirective.remarkPlugin,
|
|
|
refsGrowiDirective.remarkPlugin,
|
|
refsGrowiDirective.remarkPlugin,
|
|
|
);
|
|
);
|
|
@@ -265,15 +281,17 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const rehypeSanitizePlugin: Pluggable<any[]> | (() => void) = config.isEnabledXssPrevention
|
|
|
|
|
|
|
+ const rehypeSanitizePlugin: Pluggable | (() => void) = config.isEnabledXssPrevention
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
getCommonSanitizeOption(config),
|
|
getCommonSanitizeOption(config),
|
|
|
drawio.sanitizeOption,
|
|
drawio.sanitizeOption,
|
|
|
mermaid.sanitizeOption,
|
|
mermaid.sanitizeOption,
|
|
|
|
|
+ callout.sanitizeOption,
|
|
|
attachment.sanitizeOption,
|
|
attachment.sanitizeOption,
|
|
|
lsxGrowiDirective.sanitizeOption,
|
|
lsxGrowiDirective.sanitizeOption,
|
|
|
refsGrowiDirective.sanitizeOption,
|
|
refsGrowiDirective.sanitizeOption,
|
|
|
addLineNumberAttribute.sanitizeOption,
|
|
addLineNumberAttribute.sanitizeOption,
|
|
|
|
|
+ codeBlock.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -296,6 +314,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
components.gallery = refsGrowiDirective.GalleryImmutable;
|
|
components.gallery = refsGrowiDirective.GalleryImmutable;
|
|
|
components.drawio = drawio.DrawioViewer;
|
|
components.drawio = drawio.DrawioViewer;
|
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
components.mermaid = mermaid.MermaidViewer;
|
|
|
|
|
+ components.callout = callout.CalloutViewer;
|
|
|
components.attachment = RichAttachment;
|
|
components.attachment = RichAttachment;
|
|
|
components.img = LightBox;
|
|
components.img = LightBox;
|
|
|
}
|
|
}
|