|
@@ -1,6 +1,7 @@
|
|
|
import assert from 'assert';
|
|
import assert from 'assert';
|
|
|
|
|
|
|
|
import { isClient } from '@growi/core/dist/utils/browser-utils';
|
|
import { isClient } from '@growi/core/dist/utils/browser-utils';
|
|
|
|
|
+import * as refsGrowiPlugin from '@growi/remark-attachment-refs/dist/client/index.mjs';
|
|
|
import * as drawioPlugin from '@growi/remark-drawio';
|
|
import * as drawioPlugin from '@growi/remark-drawio';
|
|
|
// eslint-disable-next-line import/extensions
|
|
// eslint-disable-next-line import/extensions
|
|
|
import * as lsxGrowiPlugin from '@growi/remark-lsx/dist/client/index.mjs';
|
|
import * as lsxGrowiPlugin from '@growi/remark-lsx/dist/client/index.mjs';
|
|
@@ -58,6 +59,7 @@ export const generateViewOptions = (
|
|
|
drawioPlugin.remarkPlugin,
|
|
drawioPlugin.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
if (config.isEnabledLinebreaks) {
|
|
if (config.isEnabledLinebreaks) {
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
@@ -72,6 +74,7 @@ export const generateViewOptions = (
|
|
|
commonSanitizeOption,
|
|
commonSanitizeOption,
|
|
|
drawioPlugin.sanitizeOption,
|
|
drawioPlugin.sanitizeOption,
|
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
|
|
|
+ refsGrowiPlugin.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -79,6 +82,7 @@ export const generateViewOptions = (
|
|
|
rehypePlugins.push(
|
|
rehypePlugins.push(
|
|
|
slug,
|
|
slug,
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
|
|
|
+ [refsGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
rehypeSanitizePlugin,
|
|
rehypeSanitizePlugin,
|
|
|
katex,
|
|
katex,
|
|
|
[relocateToc.rehypePluginStore, { storeTocNode }],
|
|
[relocateToc.rehypePluginStore, { storeTocNode }],
|
|
@@ -93,6 +97,7 @@ export const generateViewOptions = (
|
|
|
components.h5 = Header;
|
|
components.h5 = Header;
|
|
|
components.h6 = Header;
|
|
components.h6 = Header;
|
|
|
components.lsx = lsxGrowiPlugin.Lsx;
|
|
components.lsx = lsxGrowiPlugin.Lsx;
|
|
|
|
|
+ components.ref = refsGrowiPlugin.Ref;
|
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
|
components.table = TableWithEditButton;
|
|
components.table = TableWithEditButton;
|
|
|
}
|
|
}
|
|
@@ -153,6 +158,7 @@ export const generateSimpleViewOptions = (
|
|
|
drawioPlugin.remarkPlugin,
|
|
drawioPlugin.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
|
|
const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
|
|
@@ -171,12 +177,14 @@ export const generateSimpleViewOptions = (
|
|
|
commonSanitizeOption,
|
|
commonSanitizeOption,
|
|
|
drawioPlugin.sanitizeOption,
|
|
drawioPlugin.sanitizeOption,
|
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
|
|
|
+ refsGrowiPlugin.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
|
// add rehype plugins
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
rehypePlugins.push(
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
|
|
|
+ [refsGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
[keywordHighlighter.rehypePlugin, { keywords: highlightKeywords }],
|
|
[keywordHighlighter.rehypePlugin, { keywords: highlightKeywords }],
|
|
|
rehypeSanitizePlugin,
|
|
rehypeSanitizePlugin,
|
|
|
katex,
|
|
katex,
|
|
@@ -185,6 +193,7 @@ export const generateSimpleViewOptions = (
|
|
|
// add components
|
|
// add components
|
|
|
if (components != null) {
|
|
if (components != null) {
|
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
|
|
|
+ components.ref = refsGrowiPlugin.Ref;
|
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -219,6 +228,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
drawioPlugin.remarkPlugin,
|
|
drawioPlugin.remarkPlugin,
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
if (config.isEnabledLinebreaks) {
|
|
if (config.isEnabledLinebreaks) {
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
@@ -232,6 +242,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
? [sanitize, deepmerge(
|
|
? [sanitize, deepmerge(
|
|
|
commonSanitizeOption,
|
|
commonSanitizeOption,
|
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
|
|
|
+ refsGrowiPlugin.sanitizeOption,
|
|
|
drawioPlugin.sanitizeOption,
|
|
drawioPlugin.sanitizeOption,
|
|
|
addLineNumberAttribute.sanitizeOption,
|
|
addLineNumberAttribute.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
@@ -240,6 +251,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
// add rehype plugins
|
|
// add rehype plugins
|
|
|
rehypePlugins.push(
|
|
rehypePlugins.push(
|
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
[lsxGrowiPlugin.rehypePlugin, { pagePath, isSharedPage: config.isSharedPage }],
|
|
|
|
|
+ [refsGrowiPlugin.rehypePlugin, { pagePath }],
|
|
|
addLineNumberAttribute.rehypePlugin,
|
|
addLineNumberAttribute.rehypePlugin,
|
|
|
rehypeSanitizePlugin,
|
|
rehypeSanitizePlugin,
|
|
|
katex,
|
|
katex,
|
|
@@ -248,6 +260,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
// add components
|
|
// add components
|
|
|
if (components != null) {
|
|
if (components != null) {
|
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
|
|
|
+ components.ref = refsGrowiPlugin.Ref;
|
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
|
}
|
|
}
|
|
|
|
|
|