Răsfoiți Sursa

Relocate plantuml modules under the features dir

Yuki Takei 9 luni în urmă
părinte
comite
b386305727

+ 1 - 1
apps/app/src/client/services/renderer/renderer.tsx

@@ -22,6 +22,7 @@ import { RichAttachment } from '~/client/components/ReactMarkdownComponents/Rich
 import { TableWithEditButton } from '~/client/components/ReactMarkdownComponents/TableWithEditButton';
 import { TableWithEditButton } from '~/client/components/ReactMarkdownComponents/TableWithEditButton';
 import * as callout from '~/features/callout';
 import * as callout from '~/features/callout';
 import * as mermaid from '~/features/mermaid';
 import * as mermaid from '~/features/mermaid';
+import * as plantuml from '~/features/plantuml';
 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';
 import * as addLineNumberAttribute from '~/services/renderer/rehype-plugins/add-line-number-attribute';
 import * as addLineNumberAttribute from '~/services/renderer/rehype-plugins/add-line-number-attribute';
@@ -29,7 +30,6 @@ import * as keywordHighlighter from '~/services/renderer/rehype-plugins/keyword-
 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 codeBlock from '~/services/renderer/remark-plugins/codeblock';
-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 {
   getCommonSanitizeOption, generateCommonOptions, verifySanitizePlugin,
   getCommonSanitizeOption, generateCommonOptions, verifySanitizePlugin,

+ 1 - 0
apps/app/src/features/plantuml/index.ts

@@ -0,0 +1 @@
+export * from './services';

+ 1 - 0
apps/app/src/features/plantuml/services/index.ts

@@ -0,0 +1 @@
+export { remarkPlugin } from './plantuml';

+ 5 - 6
apps/app/src/services/renderer/remark-plugins/plantuml.ts → apps/app/src/features/plantuml/services/plantuml.ts

@@ -4,6 +4,9 @@ import type { Plugin } from 'unified';
 import { visit } from 'unist-util-visit';
 import { visit } from 'unist-util-visit';
 import urljoin from 'url-join';
 import urljoin from 'url-join';
 
 
+import carbonGrayDarkStyles from '../themes/carbon-gray-dark.puml';
+import carbonGrayLightStyles from '../themes/carbon-gray-light.puml';
+
 type PlantUMLPluginParams = {
 type PlantUMLPluginParams = {
   plantumlUri: string,
   plantumlUri: string,
   isDarkMode?: boolean,
   isDarkMode?: boolean,
@@ -18,12 +21,8 @@ export const remarkPlugin: Plugin<[PlantUMLPluginParams]> = (options) => {
   return (tree, file) => {
   return (tree, file) => {
     visit(tree, 'code', (node: Code) => {
     visit(tree, 'code', (node: Code) => {
       if (node.lang === 'plantuml') {
       if (node.lang === 'plantuml') {
-        const themeLine = isDarkMode
-          ? '!theme reddress-darkblue'
-          : '!theme carbon-gray';
-
-        // node.value = `${themeLine}\n${node.value}`;
-        node.value = `${''}\n${node.value}`;
+        const themeStyles = isDarkMode ? carbonGrayDarkStyles : carbonGrayLightStyles;
+        node.value = `${themeStyles}\n${node.value}`;
       }
       }
     });
     });
 
 

+ 8 - 0
apps/app/src/features/plantuml/themes/.eslintrc.js

@@ -0,0 +1,8 @@
+/**
+ * @type {import('eslint').Linter.Config}
+ */
+module.exports = {
+  ignorePatterns: [
+    '*.puml.ts',
+  ],
+};

+ 4 - 0
apps/app/public/plantuml-themes/carbon-gray-dark.puml → apps/app/src/features/plantuml/themes/carbon-gray-dark.puml.ts

@@ -1,3 +1,4 @@
+const style = `
 ---
 ---
 name: growi-carbon-gray-dark
 name: growi-carbon-gray-dark
 display_name: GROWI Carbon Gray
 display_name: GROWI Carbon Gray
@@ -776,3 +777,6 @@ yamlDiagram {
 </style>
 </style>
 !endsub
 !endsub
 '!endif
 '!endif
+`;
+
+export default style;

+ 4 - 0
apps/app/public/plantuml-themes/carbon-gray-light.puml → apps/app/src/features/plantuml/themes/carbon-gray-light.puml.ts

@@ -1,3 +1,4 @@
+const style = `
 ---
 ---
 name: growi-carbon-gray-light
 name: growi-carbon-gray-light
 display_name: GROWI Carbon Gray
 display_name: GROWI Carbon Gray
@@ -776,3 +777,6 @@ yamlDiagram {
 </style>
 </style>
 !endsub
 !endsub
 '!endif
 '!endif
+`;
+
+export default style;