Merge pull request #8 from cloud-neutral-toolkit/codex/refactor-markdown-editor-to-internal-module

Refactor markdown editor as internal module
This commit is contained in:
cloudneutral 2025-12-16 12:06:49 +08:00 committed by GitHub
commit 5d55c135ca
66 changed files with 181 additions and 3225 deletions

View File

@ -62,7 +62,6 @@ const nextConfig = {
return config;
},
reactStrictMode: true,
transpilePackages: ['@internal/neurapress'],
typedRoutes: false,
turbopack: {
root: path.resolve(__dirname),

View File

@ -20,7 +20,6 @@
"test:e2e": "playwright test --config tests/e2e/playwright.config.ts"
},
"dependencies": {
"@internal/neurapress": "file:./packages/neurapress",
"dompurify": "^3.2.6",
"gray-matter": "^4.0.3",
"html2canvas": "^1.4.1",

View File

@ -3,9 +3,7 @@
import dynamic from 'next/dynamic'
import { Suspense } from 'react'
import { Loader2 } from 'lucide-react'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { AdBanner } from '@modules/markdown-editor/components/ui/AdBanner'
import '@modules/markdown-editor/app/globals.css'
import { AdBanner, Logo, Toaster } from '@modules/markdown-editor'
const LoadingLogo = () => (
<div className="h-full bg-background flex items-center justify-center">
@ -24,10 +22,13 @@ const LoadingLogo = () => (
</div>
)
const WechatEditor = dynamic(() => import('@modules/markdown-editor/components/editor/WechatEditor'), {
ssr: false,
loading: () => <LoadingLogo />
})
const WechatEditor = dynamic(
() => import('@modules/markdown-editor').then((module) => module.WechatEditor),
{
ssr: false,
loading: () => <LoadingLogo />,
},
)
export default function WechatPage() {
return (
@ -48,6 +49,7 @@ export default function WechatPage() {
console.log('广告已关闭')
}}
/>
<Toaster />
</main>
)
}

View File

@ -1,6 +1,4 @@
import '@modules/markdown-editor/app/globals.css'
import XiaohongshuMarkdownEditor from '@modules/markdown-editor/components/editor/xiaohongshu/XiaohongshuMarkdownEditor'
import { Toaster } from '@modules/markdown-editor/components/ui/toaster'
import { Toaster, XiaohongshuMarkdownEditor } from '@modules/markdown-editor'
export default function XiaohongshuPage() {
return (

View File

@ -3,7 +3,7 @@
import Link from 'next/link'
import { useEffect, useMemo, useState } from 'react'
import { useLanguage } from '@i18n/LanguageProvider'
import { neurapressSample, renderMarkdown } from '@internal/neurapress'
import { neurapressSample, renderMarkdown } from '@modules/markdown-editor'
import type { DraftStore } from './storage'
const defaultContent = `# 编辑器 / Editor

View File

@ -1,7 +1,7 @@
import { MainNav } from '@modules/markdown-editor/components/nav/MainNav'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@modules/markdown-editor/components/ui/card'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { MainNav } from '../../components/nav/MainNav'
import { Logo } from '../../components/icons/Logo'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../components/ui/card'
import { Button } from '../../components/ui/button'
import Link from 'next/link'
import {
Heart,

View File

@ -1,7 +1,7 @@
import { MainNav } from '@modules/markdown-editor/components/nav/MainNav'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@modules/markdown-editor/components/ui/card'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@modules/markdown-editor/components/ui/tabs'
import { MainNav } from '../../components/nav/MainNav'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../../components/ui/card'
import { Button } from '../../components/ui/button'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../components/ui/tabs'
import Link from 'next/link'
import {
BookOpen,

View File

@ -2,10 +2,10 @@ import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import 'katex/dist/katex.min.css'
import { ThemeProvider } from '@modules/markdown-editor/components/theme/ThemeProvider'
import { cn } from '@modules/markdown-editor/lib/utils'
import { Toaster } from '@modules/markdown-editor/components/ui/toaster'
import { GoogleAnalytics } from '@modules/markdown-editor/components/GoogleAnalytics'
import { ThemeProvider } from '../components/theme/ThemeProvider'
import { cn } from '../lib/utils'
import { Toaster } from '../components/ui/toaster'
import { GoogleAnalytics } from '../components/GoogleAnalytics'
const inter = Inter({ subsets: ['latin'] })

View File

@ -1,10 +1,10 @@
'use client'
import Link from 'next/link'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@modules/markdown-editor/components/ui/card'
import { MainNav } from '@modules/markdown-editor/components/nav/MainNav'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { Button } from '../components/ui/button'
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../components/ui/card'
import { MainNav } from '../components/nav/MainNav'
import { Logo } from '../components/icons/Logo'
import {
FileText,
Smartphone,

View File

@ -2,9 +2,9 @@
import dynamic from 'next/dynamic'
import { Suspense } from 'react'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { Logo } from '../../components/icons/Logo'
import { Loader2 } from 'lucide-react'
import { AdBanner } from '@modules/markdown-editor/components/ui/AdBanner'
import { AdBanner } from '../../components/ui/AdBanner'
const LoadingLogo = () => (
<div className="h-full bg-background flex items-center justify-center">
@ -24,7 +24,7 @@ const LoadingLogo = () => (
)
// Dynamically import WechatEditor with no SSR
const WechatEditor = dynamic(() => import('@modules/markdown-editor/components/editor/WechatEditor'), {
const WechatEditor = dynamic(() => import('../../components/editor/WechatEditor'), {
ssr: false,
loading: () => (
<LoadingLogo />

View File

@ -1,5 +1,5 @@
import XiaohongshuMarkdownEditor from '@modules/markdown-editor/components/editor/xiaohongshu/XiaohongshuMarkdownEditor'
import { Toaster } from '@modules/markdown-editor/components/ui/toaster'
import XiaohongshuMarkdownEditor from '../../components/editor/xiaohongshu/XiaohongshuMarkdownEditor'
import { Toaster } from '../../components/ui/toaster'
export default function XiaohongshuPage() {
return (

View File

@ -1,8 +1,8 @@
'use client'
import { useState, useEffect } from 'react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { cn } from '../lib/utils'
import { Button } from './ui/button'
import {
Sheet,
SheetContent,
@ -10,7 +10,7 @@ import {
SheetHeader,
SheetTitle,
SheetTrigger,
} from '@modules/markdown-editor/components/ui/sheet'
} from './ui/sheet'
import {
AlertDialog,
AlertDialogAction,
@ -21,12 +21,12 @@ import {
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@modules/markdown-editor/components/ui/alert-dialog"
import { ScrollArea } from '@modules/markdown-editor/components/ui/scroll-area'
} from './ui/alert-dialog'
import { ScrollArea } from './ui/scroll-area'
import { FileText, Trash2, Menu, Plus, Save, Edit2, Check } from 'lucide-react'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { ToastAction } from '@modules/markdown-editor/components/ui/toast'
import { Input } from '@modules/markdown-editor/components/ui/input'
import { useToast } from './ui/use-toast'
import { ToastAction } from './ui/toast'
import { Input } from './ui/input'
interface Article {
id: string

View File

@ -1,8 +1,8 @@
'use client'
import { codeThemes, type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@modules/markdown-editor/components/ui/select'
import { Label } from '@modules/markdown-editor/components/ui/label'
import { codeThemes, type CodeThemeId } from '../../config/code-themes'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
import { Label } from '../ui/label'
interface CodeThemeSelectorProps {
value: CodeThemeId

View File

@ -1,13 +1,13 @@
'use client'
import { useState, useEffect } from 'react'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@modules/markdown-editor/components/ui/dialog'
import { Label } from '@modules/markdown-editor/components/ui/label'
import { Input } from '@modules/markdown-editor/components/ui/input'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog'
import { Label } from '../ui/label'
import { Input } from '../ui/input'
import { Button } from '../ui/button'
import { Settings } from 'lucide-react'
import { type RendererOptions } from '@modules/markdown-editor/lib/markdown'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@modules/markdown-editor/components/ui/select'
import { type RendererOptions } from '../../lib/markdown'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
const themeColors = [
{ name: '经典黑', value: '#1a1a1a' },

View File

@ -1,29 +1,29 @@
'use client'
import { useState, useCallback, useRef, useEffect } from 'react'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { ToastAction } from '@modules/markdown-editor/components/ui/toast'
import { type RendererOptions } from '@modules/markdown-editor/lib/markdown'
import { useToast } from '../ui/use-toast'
import { ToastAction } from '../ui/toast'
import { type RendererOptions } from '../../lib/markdown'
import { useAutoSave } from './hooks/useAutoSave'
import { EditorToolbar } from './components/EditorToolbar'
import { EditorPreview } from './components/EditorPreview'
import { MarkdownToolbar } from './components/MarkdownToolbar'
import { type PreviewSize } from './constants'
import { useLocalStorage } from '@modules/markdown-editor/hooks/use-local-storage'
import { codeThemes, type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { cn } from '@modules/markdown-editor/lib/utils'
import { useLocalStorage } from '../../hooks/use-local-storage'
import { codeThemes, type CodeThemeId } from '../../config/code-themes'
import { templates } from '../../config/wechat-templates'
import { cn } from '../../lib/utils'
import { usePreviewContent } from './hooks/usePreviewContent'
import { useEditorKeyboard } from './hooks/useEditorKeyboard'
import { useScrollSync } from './hooks/useScrollSync'
import { useWordStats } from './hooks/useWordStats'
import { useCopy } from './hooks/useCopy'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@modules/markdown-editor/components/ui/tabs'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/tabs'
import { Button } from '../ui/button'
import { Copy } from 'lucide-react'
import { MobileEditor } from './components/MobileEditor'
import { DesktopEditor } from './components/DesktopEditor'
import { getExampleContent } from '@modules/markdown-editor/lib/utils/loadExampleContent'
import { getExampleContent } from '../../lib/utils/loadExampleContent'
export default function WechatEditor() {
const { toast } = useToast()

View File

@ -3,7 +3,7 @@
import { useEditor, EditorContent } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit'
import { useState } from 'react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { cn } from '../../lib/utils'
import { Copy, Eye, Pencil } from 'lucide-react'
export default function XiaohongshuEditor() {

View File

@ -1,12 +1,12 @@
'use client'
import { type RefObject } from 'react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { cn } from '../../../lib/utils'
import { templates } from '../../../config/wechat-templates'
import { EditorPreview } from './EditorPreview'
import { MarkdownToolbar } from './MarkdownToolbar'
import { type PreviewSize } from '../constants'
import { type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { type CodeThemeId } from '../../../config/code-themes'
interface DesktopEditorProps {
editorRef: RefObject<HTMLDivElement>

View File

@ -1,11 +1,11 @@
'use client'
import { cn } from '@modules/markdown-editor/lib/utils'
import { cn } from '../../../lib/utils'
import { PREVIEW_SIZES, type PreviewSize } from '../constants'
import { Loader2, ZoomIn, ZoomOut, Maximize2, Minimize2 } from 'lucide-react'
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { templates } from '../../../config/wechat-templates'
import { useState, useRef, useEffect, useMemo } from 'react'
import { type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { type CodeThemeId } from '../../../config/code-themes'
import { useTheme } from 'next-themes'
import mermaid from 'mermaid'
import { useScrollSync } from '../hooks/useScrollSync'

View File

@ -2,22 +2,22 @@
import { useState } from 'react'
import { Copy, Plus, Save, Smartphone, Settings, Github, Trash2 } from 'lucide-react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { cn } from '../../../lib/utils'
import { WechatStylePicker } from '../../template/WechatStylePicker'
import { TemplateManager } from '../../template/TemplateManager'
import { StyleConfigDialog } from '../StyleConfigDialog'
import { ArticleList } from '@modules/markdown-editor/components/ArticleList'
import { ArticleList } from '../../ArticleList'
import { type Article } from '../constants'
import { type RendererOptions } from '@modules/markdown-editor/lib/markdown'
import { ThemeToggle } from '@modules/markdown-editor/components/theme/ThemeToggle'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { type RendererOptions } from '../../../lib/markdown'
import { ThemeToggle } from '../../theme/ThemeToggle'
import { Logo } from '../../icons/Logo'
import Link from 'next/link'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { ToastAction } from '@modules/markdown-editor/components/ui/toast'
import { Button } from '../../ui/button'
import { useToast } from '../../ui/use-toast'
import { ToastAction } from '../../ui/toast'
import { CodeThemeSelector } from '../CodeThemeSelector'
import { useLocalStorage } from '@modules/markdown-editor/hooks/use-local-storage'
import { codeThemes, type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { useLocalStorage } from '../../../hooks/use-local-storage'
import { codeThemes, type CodeThemeId } from '../../../config/code-themes'
interface EditorToolbarProps {
value: string

View File

@ -5,8 +5,8 @@ import {
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@modules/markdown-editor/components/ui/dialog"
import { Button } from "@modules/markdown-editor/components/ui/button"
} from '../../ui/dialog'
import { Button } from '../../ui/button'
import { HelpCircle } from 'lucide-react'
const cheatSheet = [

View File

@ -1,7 +1,7 @@
import React from 'react'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@modules/markdown-editor/components/ui/tooltip'
import { Separator } from '@modules/markdown-editor/components/ui/separator'
import { Button } from '../../ui/button'
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '../../ui/tooltip'
import { Separator } from '../../ui/separator'
import {
Bold,
Italic,

View File

@ -1,12 +1,12 @@
'use client'
import { type RefObject } from 'react'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@modules/markdown-editor/components/ui/tabs'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../ui/tabs'
import { Button } from '../../ui/button'
import { Copy } from 'lucide-react'
import { EditorPreview } from './EditorPreview'
import { type PreviewSize } from '../constants'
import { type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { type CodeThemeId } from '../../../config/code-themes'
interface MobileEditorProps {
textareaRef: RefObject<HTMLTextAreaElement>

View File

@ -1,6 +1,6 @@
import { Copy, Save, Settings } from 'lucide-react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { Sheet, SheetContent, SheetTrigger } from '@modules/markdown-editor/components/ui/sheet'
import { cn } from '../../../lib/utils'
import { Sheet, SheetContent, SheetTrigger } from '../../ui/sheet'
import { WechatStylePicker } from '../../template/WechatStylePicker'
interface MobileToolbarProps {

View File

@ -1,8 +1,8 @@
'use client'
import { useCallback } from 'react'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { initializeMermaid } from '@modules/markdown-editor/lib/markdown/mermaid-utils'
import { useToast } from '../../ui/use-toast'
import { initializeMermaid } from '../../../lib/markdown/mermaid-utils'
export const useCopy = () => {
const { toast } = useToast()

View File

@ -1,9 +1,9 @@
import { useState, useCallback, useEffect } from 'react'
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { convertToWechat, getCodeThemeStyles, type RendererOptions } from '@modules/markdown-editor/lib/markdown'
import { type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { initializeMermaid } from '@modules/markdown-editor/lib/markdown/mermaid-utils'
import { templates } from '../../../config/wechat-templates'
import { convertToWechat, getCodeThemeStyles, type RendererOptions } from '../../../lib/markdown'
import { type CodeThemeId } from '../../../config/code-themes'
import { useToast } from '../../ui/use-toast'
import { initializeMermaid } from '../../../lib/markdown/mermaid-utils'
interface UsePreviewContentProps {
value: string

View File

@ -1,5 +1,5 @@
import { useState, useEffect } from 'react'
import { convertToWechat } from '@modules/markdown-editor/lib/markdown'
import { convertToWechat } from '../../../lib/markdown'
// 计算阅读时间假设每分钟阅读300字
const calculateReadingTime = (text: string): string => {

View File

@ -1,7 +1,7 @@
'use client'
import { useRef, useEffect } from 'react'
import { TooltipProvider } from '@modules/markdown-editor/components/ui/tooltip'
import { TooltipProvider } from '../../ui/tooltip'
import { XiaohongshuToolbar } from './components/XiaohongshuToolbar'
import { XiaohongshuEditor } from './components/XiaohongshuEditor'
import { XiaohongshuPreview } from './components/XiaohongshuPreview'

View File

@ -1,6 +1,6 @@
'use client'
import { Textarea } from '@modules/markdown-editor/components/ui/textarea'
import { Textarea } from '../../../ui/textarea'
import { XiaohongshuMarkdownToolbar } from './XiaohongshuMarkdownToolbar'
interface XiaohongshuEditorProps {

View File

@ -1,9 +1,9 @@
'use client'
import React from 'react'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '@modules/markdown-editor/components/ui/tooltip'
import { Separator } from '@modules/markdown-editor/components/ui/separator'
import { Button } from '../../../ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from '../../../ui/tooltip'
import { Separator } from '../../../ui/separator'
import {
Bold,
Italic,

View File

@ -1,7 +1,7 @@
'use client'
import { ZoomIn, ZoomOut, Maximize2, Minimize2, ChevronLeft, ChevronRight } from 'lucide-react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { cn } from '../../../../lib/utils'
import { xiaohongshuTemplates, type XiaohongshuTemplateId, type PageMode, type PageNumberPosition } from '../constants'
interface XiaohongshuPreviewProps {

View File

@ -1,11 +1,11 @@
'use client'
import { Save, Copy, Palette, Image as ImageIcon, Settings, FileText } from 'lucide-react'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@modules/markdown-editor/components/ui/select'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@modules/markdown-editor/components/ui/dialog'
import { Label } from '@modules/markdown-editor/components/ui/label'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { Button } from '../../../ui/button'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../ui/select'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../../../ui/dialog'
import { Label } from '../../../ui/label'
import { Logo } from '../../../icons/Logo'
import Link from 'next/link'
import {
xiaohongshuTemplates,

View File

@ -1,7 +1,7 @@
import { useState, useCallback } from 'react'
import html2canvas from 'html2canvas'
import JSZip from 'jszip'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { useToast } from '../../../ui/use-toast'
import type { PageMode } from '../constants'
export function useImageGeneration() {

View File

@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react'
import { marked } from 'marked'
import { useToast } from '@modules/markdown-editor/components/ui/use-toast'
import { useToast } from '../../../ui/use-toast'
import { defaultMarkdown, STORAGE_KEYS, type XiaohongshuTemplateId } from '../constants'
export function useXiaohongshuEditor() {

View File

@ -2,11 +2,11 @@
import Link from 'next/link'
import { usePathname } from 'next/navigation'
import { cn } from '@modules/markdown-editor/lib/utils'
import { ThemeToggle } from '@modules/markdown-editor/components/theme-toggle'
import { Logo } from '@modules/markdown-editor/components/icons/Logo'
import { cn } from '../../lib/utils'
import { ThemeToggle } from '../theme-toggle'
import { Logo } from '../icons/Logo'
import { Github } from 'lucide-react'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Button } from '../ui/button'
const navigation = [
{ name: '微信公众号', href: '/wechat' },

View File

@ -1,16 +1,16 @@
'use client'
import { useState } from 'react'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '@modules/markdown-editor/components/ui/dialog'
import { Button } from '@modules/markdown-editor/components/ui/button'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog'
import { Button } from '../ui/button'
import { Settings2, Download, Upload, Star, Plus } from 'lucide-react'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@modules/markdown-editor/components/ui/tabs'
import { Input } from '@modules/markdown-editor/components/ui/input'
import { Label } from '@modules/markdown-editor/components/ui/label'
import { Textarea } from '@modules/markdown-editor/components/ui/textarea'
import { templates as defaultTemplates, type Template } from '@modules/markdown-editor/config/wechat-templates'
import { useLocalStorage } from '@modules/markdown-editor/hooks/use-local-storage'
import { cn } from '@modules/markdown-editor/lib/utils'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '../ui/tabs'
import { Input } from '../ui/input'
import { Label } from '../ui/label'
import { Textarea } from '../ui/textarea'
import { templates as defaultTemplates, type Template } from '../../config/wechat-templates'
import { useLocalStorage } from '../../hooks/use-local-storage'
import { cn } from '../../lib/utils'
interface TemplateManagerProps {
onTemplateChange: () => void

View File

@ -2,16 +2,16 @@
import * as React from 'react'
import { Check } from 'lucide-react'
import { cn } from '@modules/markdown-editor/lib/utils'
import { cn } from '../../lib/utils'
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@modules/markdown-editor/components/ui/dialog"
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { Button } from "@modules/markdown-editor/components/ui/button"
} from '../ui/dialog'
import { templates } from '../../config/wechat-templates'
import { Button } from '../ui/button'
interface WechatStylePickerProps {
value?: string

View File

@ -2,8 +2,8 @@
import { Check, ChevronDown } from "lucide-react"
import * as SelectPrimitive from '@radix-ui/react-select'
import { cn } from "@modules/markdown-editor/lib/utils"
import { templates } from '@modules/markdown-editor/config/wechat-templates'
import { cn } from '../../lib/utils'
import { templates } from '../../config/wechat-templates'
export function WechatTemplateSelector({
onSelectAction

View File

@ -4,13 +4,13 @@ import * as React from "react"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "@modules/markdown-editor/components/ui/button"
import { Button } from './ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@modules/markdown-editor/components/ui/dropdown-menu"
} from './ui/dropdown-menu'
export function ThemeToggle() {
const { setTheme } = useTheme()

View File

@ -3,7 +3,7 @@
import * as React from "react"
import { Moon, Sun } from "lucide-react"
import { useTheme } from "next-themes"
import { Button } from "@modules/markdown-editor/components/ui/button"
import { Button } from '../ui/button'
export function ThemeToggle() {
const { theme, setTheme } = useTheme()

View File

@ -4,7 +4,7 @@ import * as React from "react"
import { X } from "lucide-react"
import { Button } from "./button"
import { Card } from "./card"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
interface AdBannerProps {
id?: string // 广告ID用于本地存储

View File

@ -3,8 +3,8 @@
import * as React from "react"
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
import { cn } from "@modules/markdown-editor/lib/utils"
import { buttonVariants } from "@modules/markdown-editor/components/ui/button"
import { cn } from '../../lib/utils'
import { buttonVariants } from './button'
const AlertDialog = AlertDialogPrimitive.Root

View File

@ -4,7 +4,7 @@ import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",

View File

@ -1,6 +1,6 @@
import * as React from "react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Card = React.forwardRef<
HTMLDivElement,

View File

@ -4,7 +4,7 @@ import * as React from "react"
import * as DialogPrimitive from "@radix-ui/react-dialog"
import { X } from "lucide-react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Dialog = DialogPrimitive.Root

View File

@ -4,7 +4,7 @@ import * as React from "react"
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
import { Check, ChevronRight, Circle } from "lucide-react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const DropdownMenu = DropdownMenuPrimitive.Root

View File

@ -1,6 +1,6 @@
import * as React from "react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}

View File

@ -4,7 +4,7 @@ import * as React from "react"
import * as LabelPrimitive from "@radix-ui/react-label"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"

View File

@ -3,7 +3,7 @@
import * as React from "react"
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const ScrollArea = React.forwardRef<
React.ElementRef<typeof ScrollAreaPrimitive.Root>,

View File

@ -4,7 +4,7 @@ import * as React from "react"
import * as SelectPrimitive from "@radix-ui/react-select"
import { Check, ChevronDown, ChevronUp } from "lucide-react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Select = SelectPrimitive.Root

View File

@ -3,7 +3,7 @@
import * as React from "react"
import * as SeparatorPrimitive from "@radix-ui/react-separator"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>,

View File

@ -5,7 +5,7 @@ import * as SheetPrimitive from "@radix-ui/react-dialog"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Sheet = SheetPrimitive.Root

View File

@ -2,7 +2,7 @@
import * as React from "react"
import * as TabsPrimitive from "@radix-ui/react-tabs"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const Tabs = TabsPrimitive.Root

View File

@ -1,6 +1,6 @@
import * as React from "react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
export interface TextareaProps
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}

View File

@ -5,7 +5,7 @@ import * as ToastPrimitives from "@radix-ui/react-toast"
import { cva, type VariantProps } from "class-variance-authority"
import { X } from "lucide-react"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const ToastProvider = ToastPrimitives.Provider

View File

@ -7,8 +7,8 @@ import {
ToastProvider,
ToastTitle,
ToastViewport,
} from "@modules/markdown-editor/components/ui/toast"
import { useToast } from "@modules/markdown-editor/components/ui/use-toast"
} from './toast'
import { useToast } from './use-toast'
export function Toaster() {
const { toasts } = useToast()

View File

@ -4,7 +4,7 @@ import * as React from "react"
import * as TogglePrimitive from "@radix-ui/react-toggle"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const toggleVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",

View File

@ -3,7 +3,7 @@
import * as React from "react"
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
import { cn } from "@modules/markdown-editor/lib/utils"
import { cn } from '../../lib/utils'
const TooltipProvider = TooltipPrimitive.Provider

View File

@ -5,7 +5,7 @@ import * as React from "react"
import type {
ToastActionElement,
ToastProps,
} from "@modules/markdown-editor/components/ui/toast"
} from './toast'
const TOAST_LIMIT = 1
const TOAST_REMOVE_DELAY = 1000000

View File

@ -1,4 +1,4 @@
import type { RendererOptions } from '@modules/markdown-editor/lib/markdown'
import type { RendererOptions } from '../lib/markdown'
export interface Template {
id: string

View File

@ -1,6 +1,7 @@
import { convertToWechat, defaultOptions } from '../lib/markdown'
import { getExampleContent } from '../lib/utils/loadExampleContent'
import XiaohongshuEditor from '../components/editor/XiaohongshuEditor'
import XiaohongshuMarkdownEditor from '../components/editor/xiaohongshu/XiaohongshuMarkdownEditor'
import WechatEditor from '../components/editor/WechatEditor'
export const neurapressSample = getExampleContent()
@ -10,4 +11,4 @@ export function renderMarkdown(markdown: string): string {
}
export const Editor = WechatEditor
export { WechatEditor, XiaohongshuEditor }
export { WechatEditor, XiaohongshuEditor, XiaohongshuMarkdownEditor }

View File

@ -1,4 +1,13 @@
'use client'
import './app/globals.css'
export * from './components'
export * from './editor'
export * from './lib'
export { Logo } from './components/icons/Logo'
export { AdBanner, type AdBannerProps } from './components/ui/AdBanner'
export { Toaster } from './components/ui/toaster'
export { ThemeProvider } from './components/theme/ThemeProvider'
export { ThemeToggle } from './components/theme/ThemeToggle'
export { default as XiaohongshuMarkdownEditor } from './components/editor/xiaohongshu/XiaohongshuMarkdownEditor'

View File

@ -16,7 +16,7 @@ import 'prismjs/components/prism-rust'
import 'prismjs/components/prism-sql'
import 'prismjs/components/prism-docker'
import 'prismjs/components/prism-nginx'
import type { CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import type { CodeThemeId } from '../../config/code-themes'
import { getTokenStyles } from './styles'
// Helper function to recursively process tokens

View File

@ -1,5 +1,5 @@
import type { StyleOptions, RendererOptions } from './types'
import { codeThemes, type CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import { codeThemes, type CodeThemeId } from '../../config/code-themes'
// 将样式对象转换为 CSS 字符串
export function cssPropertiesToString(style: StyleOptions = {}): string {

View File

@ -1,5 +1,5 @@
import type { CSSProperties } from 'react'
import type { CodeThemeId } from '@modules/markdown-editor/config/code-themes'
import type { CodeThemeId } from '../../config/code-themes'
export interface StyleOptions {
// Layout

View File

@ -28,9 +28,7 @@
"@theme": ["src/components/theme"],
"@theme/*": ["src/components/theme/*"],
"@templates/*": ["src/modules/templates/*"],
"@src/*": ["src/*"],
"@internal/neurapress": ["../packages/neurapress/src/index.ts"],
"@internal/neurapress/*": ["../packages/neurapress/src/*"]
"@src/*": ["src/*"]
},
"types": ["node", "vitest/globals", "@testing-library/jest-dom"],
"plugins": [{ "name": "next" }]

3080
yarn.lock

File diff suppressed because it is too large Load Diff