Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

refactor(ui): move CODE_LIGATURE_CLASS to zero-dep code-style module (#3463)

Bohan Jiang27b473151b1d
diff --git a/packages/ui/lib/code-style.ts b/packages/ui/lib/code-style.ts
new file mode 100644
index 0000000000..abf17892b3
--- /dev/null
+++ b/packages/ui/lib/code-style.ts
@@ -0,0 +1,5 @@
+export const CODE_LIGATURE_CLASS =
+ "[font-variant-ligatures:none] [font-feature-settings:'liga'_0]"
+
+export const CODE_LIGATURE_DESCENDANT_CLASS =
+ '[&_code]:[font-variant-ligatures:none] [&_code]:[font-feature-settings:"liga"_0]'
diff --git a/packages/ui/markdown/CodeBlock.tsx b/packages/ui/markdown/CodeBlock.tsx
index 1d85aafd74..d9b3a94c49 100644
--- a/packages/ui/markdown/CodeBlock.tsx
+++ b/packages/ui/markdown/CodeBlock.tsx
@@ -5,6 +5,10 @@ import { useTranslation } from "react-i18next"
import { Button } from "@multica/ui/components/ui/button"
import { Tooltip, TooltipTrigger, TooltipContent } from "@multica/ui/components/ui/tooltip"
import { cn } from '@multica/ui/lib/utils'
+import {
+ CODE_LIGATURE_CLASS,
+ CODE_LIGATURE_DESCENDANT_CLASS,
+} from '@multica/ui/lib/code-style'
export interface CodeBlockProps {
code: string
@@ -37,9 +41,6 @@ const LANGUAGE_ALIASES: Record<string, BundledLanguage> = {
// Simple LRU cache for highlighted code
const highlightCache = new Map<string, string>()
const CACHE_MAX_SIZE = 200
-export const CODE_LIGATURE_CLASS = "[font-variant-ligatures:none] [font-feature-settings:'liga'_0]"
-export const CODE_LIGATURE_DESCENDANT_CLASS =
- '[&_code]:[font-variant-ligatures:none] [&_code]:[font-feature-settings:"liga"_0]'
function getCacheKey(code: string, lang: string): string {
return `${lang}:${code}`
diff --git a/packages/ui/markdown/Markdown.tsx b/packages/ui/markdown/Markdown.tsx
index 0d05565084..a561c57994 100644
--- a/packages/ui/markdown/Markdown.tsx
+++ b/packages/ui/markdown/Markdown.tsx
@@ -8,7 +8,8 @@ import remarkGfm from 'remark-gfm'
import remarkMath from 'remark-math'
import { FileText, Download } from 'lucide-react'
import { cn } from '@multica/ui/lib/utils'
-import { CodeBlock, CODE_LIGATURE_CLASS, InlineCode } from './CodeBlock'
+import { CODE_LIGATURE_CLASS } from '@multica/ui/lib/code-style'
+import { CodeBlock, InlineCode } from './CodeBlock'
import { isAllowedFileCardHref, preprocessFileCards } from './file-cards'
import { preprocessLinks } from './linkify'
import { preprocessMentionShortcodes } from './mentions'
diff --git a/packages/ui/markdown/index.ts b/packages/ui/markdown/index.ts
index 0a91585098..d11121fb27 100644
--- a/packages/ui/markdown/index.ts
+++ b/packages/ui/markdown/index.ts
@@ -1,5 +1,5 @@
export { Markdown, MemoizedMarkdown, type MarkdownProps, type RenderMode } from './Markdown'
-export { CodeBlock, CODE_LIGATURE_CLASS, InlineCode, type CodeBlockProps } from './CodeBlock'
+export { CodeBlock, InlineCode, type CodeBlockProps } from './CodeBlock'
export { StreamingMarkdown, type StreamingMarkdownProps } from './StreamingMarkdown'
export { preprocessLinks, detectLinks, hasLinks } from './linkify'
export { preprocessMentionShortcodes } from './mentions'
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 2341e194c5..8f274a9031 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -17,6 +17,7 @@
"./hooks/*": "./hooks/*.ts",
"./lib/utils": "./lib/utils.ts",
"./lib/data-table": "./lib/data-table.ts",
+ "./lib/code-style": "./lib/code-style.ts",
"./i18n-types": "./types/i18next.ts",
"./styles/tokens.css": "./styles/tokens.css",
"./styles/base.css": "./styles/base.css"
diff --git a/packages/views/onboarding/steps/cli-install-instructions.tsx b/packages/views/onboarding/steps/cli-install-instructions.tsx
index e4a7560d0e..a997083230 100644
--- a/packages/views/onboarding/steps/cli-install-instructions.tsx
+++ b/packages/views/onboarding/steps/cli-install-instructions.tsx
@@ -3,7 +3,7 @@
import { useState } from "react";
import { Check, Copy, Terminal } from "lucide-react";
import { Card, CardContent } from "@multica/ui/components/ui/card";
-import { CODE_LIGATURE_CLASS } from "@multica/ui/markdown";
+import { CODE_LIGATURE_CLASS } from "@multica/ui/lib/code-style";
import { cn } from "@multica/ui/lib/utils";
import { useT } from "../../i18n";
diff --git a/packages/views/runtimes/components/connect-remote-dialog.tsx b/packages/views/runtimes/components/connect-remote-dialog.tsx
index 1944b5d236..9cbd1729e3 100644
--- a/packages/views/runtimes/components/connect-remote-dialog.tsx
+++ b/packages/views/runtimes/components/connect-remote-dialog.tsx
@@ -16,7 +16,7 @@ import {
DialogTitle,
} from "@multica/ui/components/ui/dialog";
import { Button } from "@multica/ui/components/ui/button";
-import { CODE_LIGATURE_CLASS } from "@multica/ui/markdown";
+import { CODE_LIGATURE_CLASS } from "@multica/ui/lib/code-style";
import { cn } from "@multica/ui/lib/utils";
import { useNavigation } from "../../navigation";
import { useT } from "../../i18n";