|
@@ -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';
|
|
@@ -35,6 +36,7 @@ import loggerFactory from '~/utils/logger';
|
|
|
// import EasyGrid from './PreProcessor/EasyGrid';
|
|
// import EasyGrid from './PreProcessor/EasyGrid';
|
|
|
|
|
|
|
|
import '@growi/remark-lsx/dist/client/style.css';
|
|
import '@growi/remark-lsx/dist/client/style.css';
|
|
|
|
|
+import '@growi/remark-attachment-refs/dist/client/style.css';
|
|
|
|
|
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:cli:services:renderer');
|
|
const logger = loggerFactory('growi:cli:services:renderer');
|
|
@@ -61,6 +63,7 @@ export const generateViewOptions = (
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
attachmentPlugin.remarkPlugin,
|
|
attachmentPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
if (config.isEnabledLinebreaks) {
|
|
if (config.isEnabledLinebreaks) {
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
@@ -76,6 +79,7 @@ export const generateViewOptions = (
|
|
|
drawioPlugin.sanitizeOption,
|
|
drawioPlugin.sanitizeOption,
|
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
|
attachmentPlugin.sanitizeOption,
|
|
attachmentPlugin.sanitizeOption,
|
|
|
|
|
+ refsGrowiPlugin.sanitizeOption,
|
|
|
)]
|
|
)]
|
|
|
: () => {};
|
|
: () => {};
|
|
|
|
|
|
|
@@ -83,6 +87,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 }],
|
|
@@ -97,6 +102,11 @@ 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.refs = refsGrowiPlugin.Refs;
|
|
|
|
|
+ components.refimg = refsGrowiPlugin.RefImg;
|
|
|
|
|
+ components.refsimg = refsGrowiPlugin.RefsImg;
|
|
|
|
|
+ components.gallery = refsGrowiPlugin.Gallery;
|
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
components.drawio = DrawioViewerWithEditButton;
|
|
|
components.table = TableWithEditButton;
|
|
components.table = TableWithEditButton;
|
|
|
components.attachment = Attachment;
|
|
components.attachment = Attachment;
|
|
@@ -159,6 +169,7 @@ export const generateSimpleViewOptions = (
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
attachmentPlugin.remarkPlugin,
|
|
attachmentPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
|
|
const isEnabledLinebreaks = overrideIsEnabledLinebreaks ?? config.isEnabledLinebreaks;
|
|
@@ -178,12 +189,14 @@ export const generateSimpleViewOptions = (
|
|
|
drawioPlugin.sanitizeOption,
|
|
drawioPlugin.sanitizeOption,
|
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
lsxGrowiPlugin.sanitizeOption,
|
|
|
attachmentPlugin.sanitizeOption,
|
|
attachmentPlugin.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,
|
|
@@ -192,6 +205,11 @@ export const generateSimpleViewOptions = (
|
|
|
// add components
|
|
// add components
|
|
|
if (components != null) {
|
|
if (components != null) {
|
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
components.lsx = lsxGrowiPlugin.LsxImmutable;
|
|
|
|
|
+ components.ref = refsGrowiPlugin.RefImmutable;
|
|
|
|
|
+ components.refs = refsGrowiPlugin.RefsImmutable;
|
|
|
|
|
+ components.refimg = refsGrowiPlugin.RefImgImmutable;
|
|
|
|
|
+ components.refsimg = refsGrowiPlugin.RefsImgImmutable;
|
|
|
|
|
+ components.gallery = refsGrowiPlugin.GalleryImmutable;
|
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
|
components.attachment = Attachment;
|
|
components.attachment = Attachment;
|
|
|
}
|
|
}
|
|
@@ -228,6 +246,7 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
|
|
|
xsvToTable.remarkPlugin,
|
|
xsvToTable.remarkPlugin,
|
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
lsxGrowiPlugin.remarkPlugin,
|
|
|
attachmentPlugin.remarkPlugin,
|
|
attachmentPlugin.remarkPlugin,
|
|
|
|
|
+ refsGrowiPlugin.remarkPlugin,
|
|
|
);
|
|
);
|
|
|
if (config.isEnabledLinebreaks) {
|
|
if (config.isEnabledLinebreaks) {
|
|
|
remarkPlugins.push(breaks);
|
|
remarkPlugins.push(breaks);
|
|
@@ -241,6 +260,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,
|
|
|
attachmentPlugin.sanitizeOption,
|
|
attachmentPlugin.sanitizeOption,
|
|
@@ -250,6 +270,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,
|
|
@@ -258,6 +279,11 @@ 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.RefImmutable;
|
|
|
|
|
+ components.refs = refsGrowiPlugin.RefsImmutable;
|
|
|
|
|
+ components.refimg = refsGrowiPlugin.RefImgImmutable;
|
|
|
|
|
+ components.refsimg = refsGrowiPlugin.RefsImgImmutable;
|
|
|
|
|
+ components.gallery = refsGrowiPlugin.GalleryImmutable;
|
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
components.drawio = drawioPlugin.DrawioViewer;
|
|
|
components.attachment = Attachment;
|
|
components.attachment = Attachment;
|
|
|
}
|
|
}
|