Browse Source

Merge pull request #9255 from weseek/fix/153035-155771-can-use-lsx

fix: Cannot use lsx and some GitHub Alerts
mergify[bot] 1 year ago
parent
commit
764664c1d0

+ 0 - 1
apps/app/package.json

@@ -275,7 +275,6 @@
     "react-hotkeys": "^2.0.0",
     "react-input-autosize": "^3.0.0",
     "react-toastify": "^9.1.3",
-    "remark-directive": "^3.0.0",
     "remark-github-admonitions-to-directives": "^2.0.0",
     "rehype-rewrite": "^4.0.2",
     "replacestream": "^4.0.3",

+ 0 - 4
apps/app/src/client/services/renderer/renderer.tsx

@@ -10,7 +10,6 @@ import sanitize from 'rehype-sanitize';
 import slug from 'rehype-slug';
 import type { HtmlElementNode } from 'rehype-toc';
 import breaks from 'remark-breaks';
-import remarkDirective from 'remark-directive';
 import remarkGithubAdmonitionsToDirectives from 'remark-github-admonitions-to-directives';
 import math from 'remark-math';
 import deepmerge from 'ts-deepmerge';
@@ -69,7 +68,6 @@ export const generateViewOptions = (
     xsvToTable.remarkPlugin,
     attachment.remarkPlugin,
     remarkGithubAdmonitionsToDirectives,
-    remarkDirective,
     callout.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,
@@ -178,7 +176,6 @@ export const generateSimpleViewOptions = (
     xsvToTable.remarkPlugin,
     attachment.remarkPlugin,
     remarkGithubAdmonitionsToDirectives,
-    remarkDirective,
     callout.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,
@@ -276,7 +273,6 @@ export const generatePreviewOptions = (config: RendererConfig, pagePath: string)
     xsvToTable.remarkPlugin,
     attachment.remarkPlugin,
     remarkGithubAdmonitionsToDirectives,
-    remarkDirective,
     callout.remarkPlugin,
     lsxGrowiDirective.remarkPlugin,
     refsGrowiDirective.remarkPlugin,

+ 4 - 0
apps/app/src/features/callout/components/CalloutViewer.tsx

@@ -17,16 +17,20 @@ const CALLOUT_TO_TITLE: CALLOUT_TO = {
   note: 'Note',
   tip: 'Tip',
   important: 'Important',
+  info: 'Important',
   warning: 'Warning',
   caution: 'Caution',
+  danger: 'Caution',
 };
 
 const CALLOUT_TO_ICON: CALLOUT_TO = {
   note: 'info',
   tip: 'lightbulb',
   important: 'feedback',
+  info: 'feedback',
   warning: 'warning',
   caution: 'report',
+  danger: 'report',
 };
 
 type CalloutViewerProps = {

+ 1 - 1
apps/app/src/features/callout/services/callout.ts

@@ -7,7 +7,7 @@ import { AllCallout } from './consts';
 export const remarkPlugin: Plugin = () => {
   return (tree) => {
     visit(tree, 'containerDirective', (node: ContainerDirective) => {
-      if (AllCallout.some(name => name === node.name)) {
+      if (AllCallout.some(name => name === node.name.toLowerCase())) {
         const data = node.data ?? (node.data = {});
         data.hName = 'callout';
         data.hProperties = {

+ 1 - 1
apps/app/src/features/callout/services/consts.ts

@@ -1,5 +1,5 @@
 // Ref: https://github.com/Microflash/remark-callout-directives/blob/fabe4d8adc7738469f253836f0da346591ea2a2b/themes/github/index.js
 // Ref: https://github.com/orgs/community/discussions/16925
 
-export const AllCallout = ['note', 'tip', 'important', 'warning', 'caution'] as const;
+export const AllCallout = ['note', 'tip', 'important', 'info', 'warning', 'danger', 'caution'] as const;
 export type Callout = typeof AllCallout[number];

+ 0 - 23
yarn.lock

@@ -13134,19 +13134,6 @@ micromark-core-commonmark@^2.0.0:
     micromark-util-symbol "^2.0.0"
     micromark-util-types "^2.0.0"
 
-micromark-extension-directive@^3.0.0:
-  version "3.0.2"
-  resolved "https://registry.yarnpkg.com/micromark-extension-directive/-/micromark-extension-directive-3.0.2.tgz#2eb61985d1995a7c1ff7621676a4f32af29409e8"
-  integrity sha512-wjcXHgk+PPdmvR58Le9d7zQYWy+vKEU9Se44p2CrCDPiLr2FMyiT4Fyb5UFKFC66wGB3kPlgD7q3TnoqPS7SZA==
-  dependencies:
-    devlop "^1.0.0"
-    micromark-factory-space "^2.0.0"
-    micromark-factory-whitespace "^2.0.0"
-    micromark-util-character "^2.0.0"
-    micromark-util-symbol "^2.0.0"
-    micromark-util-types "^2.0.0"
-    parse-entities "^4.0.0"
-
 micromark-extension-frontmatter@^2.0.0:
   version "2.0.0"
   resolved "https://registry.yarnpkg.com/micromark-extension-frontmatter/-/micromark-extension-frontmatter-2.0.0.tgz#651c52ffa5d7a8eeed687c513cd869885882d67a"
@@ -16124,16 +16111,6 @@ remark-breaks@^4.0.0:
     mdast-util-newline-to-break "^2.0.0"
     unified "^11.0.0"
 
-remark-directive@^3.0.0:
-  version "3.0.0"
-  resolved "https://registry.yarnpkg.com/remark-directive/-/remark-directive-3.0.0.tgz#34452d951b37e6207d2e2a4f830dc33442923268"
-  integrity sha512-l1UyWJ6Eg1VPU7Hm/9tt0zKtReJQNOA4+iDMAxTyZNWnJnFlbS/7zhiel/rogTLQ2vMYwDzSJa4BiVNqGlqIMA==
-  dependencies:
-    "@types/mdast" "^4.0.0"
-    mdast-util-directive "^3.0.0"
-    micromark-extension-directive "^3.0.0"
-    unified "^11.0.0"
-
 remark-emoji@^5.0.0:
   version "5.0.1"
   resolved "https://registry.yarnpkg.com/remark-emoji/-/remark-emoji-5.0.1.tgz#fb08ef9f5a1a036e765d68ac3dcc1b81624f4f6f"