@yuhuanowo/yunui 0.2.15 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/README.zh-CN.md +9 -0
- package/README.zh-TW.md +9 -0
- package/dist/adapters.js +1 -1
- package/dist/ai.d.ts +94 -6
- package/dist/ai.js +466 -76
- package/dist/ai.js.map +1 -1
- package/dist/chat.d.ts +152 -0
- package/dist/chat.js +321 -0
- package/dist/chat.js.map +1 -0
- package/dist/{chunk-U2LNRVMI.js → chunk-3RT24MSH.js} +4 -3
- package/dist/chunk-3RT24MSH.js.map +1 -0
- package/dist/{chunk-6MZN3GOP.js → chunk-BCOKFWXC.js} +326 -891
- package/dist/chunk-BCOKFWXC.js.map +1 -0
- package/dist/{chunk-N53PNMPJ.js → chunk-DDUP7GAX.js} +14 -7
- package/dist/chunk-DDUP7GAX.js.map +1 -0
- package/dist/{chunk-LLNTUA5K.js → chunk-F2HG4TOQ.js} +44 -67
- package/dist/chunk-F2HG4TOQ.js.map +1 -0
- package/dist/chunk-HH3JBHRP.js +1211 -0
- package/dist/chunk-HH3JBHRP.js.map +1 -0
- package/dist/chunk-N4QO7RN5.js +98 -0
- package/dist/chunk-N4QO7RN5.js.map +1 -0
- package/dist/chunk-QEIBYOG2.js +188 -0
- package/dist/chunk-QEIBYOG2.js.map +1 -0
- package/dist/content.d.ts +178 -0
- package/dist/content.js +1064 -0
- package/dist/content.js.map +1 -0
- package/dist/index.d.ts +237 -12
- package/dist/index.js +5 -3
- package/dist/patterns.d.ts +176 -7
- package/dist/patterns.js +745 -69
- package/dist/patterns.js.map +1 -1
- package/icons/apps/aistudio.webp +0 -0
- package/icons/apps/application.png +0 -0
- package/icons/apps/baixiaoying.webp +0 -0
- package/icons/apps/coze.webp +0 -0
- package/icons/apps/dify.webp +0 -0
- package/icons/apps/doubao.webp +0 -0
- package/icons/apps/flowith.webp +0 -0
- package/icons/apps/gemini.webp +0 -0
- package/icons/apps/github-copilot.webp +0 -0
- package/icons/apps/google.webp +0 -0
- package/icons/apps/grok.webp +0 -0
- package/icons/apps/kimi.webp +0 -0
- package/icons/apps/longcat.webp +0 -0
- package/icons/apps/metaso.webp +0 -0
- package/icons/apps/monica.webp +0 -0
- package/icons/apps/n8n.webp +0 -0
- package/icons/apps/nm-search.webp +0 -0
- package/icons/apps/notebooklm.webp +0 -0
- package/icons/apps/perplexity.webp +0 -0
- package/icons/apps/poe.webp +0 -0
- package/icons/apps/qingyan.webp +0 -0
- package/icons/apps/stepfun.webp +0 -0
- package/icons/apps/tiangong.webp +0 -0
- package/icons/apps/xiaoyi.webp +0 -0
- package/icons/apps/yuanbao.webp +0 -0
- package/icons/apps/zai.webp +0 -0
- package/icons/models/ai21.webp +0 -0
- package/icons/models/aimass.webp +0 -0
- package/icons/models/anthropic.webp +0 -0
- package/icons/models/baichuan.webp +0 -0
- package/icons/models/byte_dance.webp +0 -0
- package/icons/models/chatglm.webp +0 -0
- package/icons/models/claude.webp +0 -0
- package/icons/models/codegeex.webp +0 -0
- package/icons/models/cogview3flash.webp +0 -0
- package/icons/models/cohere.webp +0 -0
- package/icons/models/copilot.webp +0 -0
- package/icons/models/dalle.webp +0 -0
- package/icons/models/dbrx.webp +0 -0
- package/icons/models/deepseek.webp +0 -0
- package/icons/models/doubao.webp +0 -0
- package/icons/models/flux.webp +0 -0
- package/icons/models/gemini.webp +0 -0
- package/icons/models/gemma.webp +0 -0
- package/icons/models/google.webp +0 -0
- package/icons/models/grok.webp +0 -0
- package/icons/models/hailuo.webp +0 -0
- package/icons/models/huggingface.webp +0 -0
- package/icons/models/hunyuan.webp +0 -0
- package/icons/models/ibm.webp +0 -0
- package/icons/models/ideogram.webp +0 -0
- package/icons/models/internlm.webp +0 -0
- package/icons/models/jina.webp +0 -0
- package/icons/models/llava.webp +0 -0
- package/icons/models/luma.webp +0 -0
- package/icons/models/magic.webp +0 -0
- package/icons/models/microsoft.webp +0 -0
- package/icons/models/midjourney.webp +0 -0
- package/icons/models/minimax.webp +0 -0
- package/icons/models/mistral.webp +0 -0
- package/icons/models/moonshot.webp +0 -0
- package/icons/models/nousresearch.webp +0 -0
- package/icons/models/nvidia.webp +0 -0
- package/icons/models/o3.webp +0 -0
- package/icons/models/openai.webp +0 -0
- package/icons/models/palm.webp +0 -0
- package/icons/models/perplexity.webp +0 -0
- package/icons/models/qwen.webp +0 -0
- package/icons/models/stability.webp +0 -0
- package/icons/models/step.webp +0 -0
- package/icons/models/suno.webp +0 -0
- package/icons/models/upstage.webp +0 -0
- package/icons/models/vidu.webp +0 -0
- package/icons/models/volcengine.webp +0 -0
- package/icons/models/voyageai.webp +0 -0
- package/icons/models/wenxin.webp +0 -0
- package/icons/models/xirang.png +0 -0
- package/icons/models/xirang_dark.png +0 -0
- package/icons/models/yi.webp +0 -0
- package/icons/models/zai.webp +0 -0
- package/icons/models/zero-one.webp +0 -0
- package/icons/models/zhipu.webp +0 -0
- package/icons/providers/302ai.webp +0 -0
- package/icons/providers/DMXAPI-to-img.webp +0 -0
- package/icons/providers/Tesseract.js.png +0 -0
- package/icons/providers/ace.webp +0 -0
- package/icons/providers/adobe.webp +0 -0
- package/icons/providers/adobefirefly.webp +0 -0
- package/icons/providers/agentvoice.webp +0 -0
- package/icons/providers/agui.webp +0 -0
- package/icons/providers/ai2.webp +0 -0
- package/icons/providers/ai21.webp +0 -0
- package/icons/providers/ai302.webp +0 -0
- package/icons/providers/ai360.webp +0 -0
- package/icons/providers/aiOnly.webp +0 -0
- package/icons/providers/aihubmix.webp +0 -0
- package/icons/providers/aimass.webp +0 -0
- package/icons/providers/aionlabs.webp +0 -0
- package/icons/providers/airjelly.webp +0 -0
- package/icons/providers/aistudio.webp +0 -0
- package/icons/providers/akashchat.webp +0 -0
- package/icons/providers/alephalpha.webp +0 -0
- package/icons/providers/alibaba.webp +0 -0
- package/icons/providers/alibabacloud.webp +0 -0
- package/icons/providers/amp.webp +0 -0
- package/icons/providers/antgroup.webp +0 -0
- package/icons/providers/anthropic.webp +0 -0
- package/icons/providers/antigravity.webp +0 -0
- package/icons/providers/anyscale.webp +0 -0
- package/icons/providers/apertis.webp +0 -0
- package/icons/providers/apple.webp +0 -0
- package/icons/providers/arcee.webp +0 -0
- package/icons/providers/askverdict.webp +0 -0
- package/icons/providers/assemblyai.webp +0 -0
- package/icons/providers/atlascloud.webp +0 -0
- package/icons/providers/automatic.webp +0 -0
- package/icons/providers/aws-bedrock.webp +0 -0
- package/icons/providers/aws.webp +0 -0
- package/icons/providers/aya.webp +0 -0
- package/icons/providers/azure.webp +0 -0
- package/icons/providers/azureai.webp +0 -0
- package/icons/providers/baai.webp +0 -0
- package/icons/providers/baichuan.webp +0 -0
- package/icons/providers/baidu-cloud.webp +0 -0
- package/icons/providers/baidu.webp +0 -0
- package/icons/providers/baiducloud.webp +0 -0
- package/icons/providers/bailian.webp +0 -0
- package/icons/providers/baseten.webp +0 -0
- package/icons/providers/bedrock.webp +0 -0
- package/icons/providers/bfl.webp +0 -0
- package/icons/providers/bigModel.webp +0 -0
- package/icons/providers/bilibili.webp +0 -0
- package/icons/providers/bilibiliindex.webp +0 -0
- package/icons/providers/bing.webp +0 -0
- package/icons/providers/briaai.webp +0 -0
- package/icons/providers/burncloud.webp +0 -0
- package/icons/providers/bytedance.webp +0 -0
- package/icons/providers/capcut.webp +0 -0
- package/icons/providers/centml.webp +0 -0
- package/icons/providers/cephalon.jpeg +0 -0
- package/icons/providers/cerebras.webp +0 -0
- package/icons/providers/chatglm.webp +0 -0
- package/icons/providers/cherryin.png +0 -0
- package/icons/providers/cherrystudio.webp +0 -0
- package/icons/providers/civitai.webp +0 -0
- package/icons/providers/claude.webp +0 -0
- package/icons/providers/claudecode.webp +0 -0
- package/icons/providers/cline.webp +0 -0
- package/icons/providers/clipdrop.webp +0 -0
- package/icons/providers/cloudflare.webp +0 -0
- package/icons/providers/codebuddy.webp +0 -0
- package/icons/providers/codeflicker.webp +0 -0
- package/icons/providers/codegeex.webp +0 -0
- package/icons/providers/codex.webp +0 -0
- package/icons/providers/cogvideo.webp +0 -0
- package/icons/providers/cogview.webp +0 -0
- package/icons/providers/cogview3flash.webp +0 -0
- package/icons/providers/cohere.webp +0 -0
- package/icons/providers/colab.webp +0 -0
- package/icons/providers/cometapi.webp +0 -0
- package/icons/providers/comfyui.webp +0 -0
- package/icons/providers/commanda.webp +0 -0
- package/icons/providers/copilot.webp +0 -0
- package/icons/providers/copilotkit.webp +0 -0
- package/icons/providers/coqui.webp +0 -0
- package/icons/providers/coze.webp +0 -0
- package/icons/providers/crewai.webp +0 -0
- package/icons/providers/crusoe.webp +0 -0
- package/icons/providers/cursor.webp +0 -0
- package/icons/providers/cybercut.webp +0 -0
- package/icons/providers/dalle.webp +0 -0
- package/icons/providers/dbrx.webp +0 -0
- package/icons/providers/deepai.webp +0 -0
- package/icons/providers/deepcogito.webp +0 -0
- package/icons/providers/deepinfra.webp +0 -0
- package/icons/providers/deepl.webp +0 -0
- package/icons/providers/deepmind.webp +0 -0
- package/icons/providers/deepseek.webp +0 -0
- package/icons/providers/devin.webp +0 -0
- package/icons/providers/dify.webp +0 -0
- package/icons/providers/dmxapi-logo-dark.webp +0 -0
- package/icons/providers/dmxapi-logo.webp +0 -0
- package/icons/providers/doc2x.webp +0 -0
- package/icons/providers/docsearch.webp +0 -0
- package/icons/providers/dolphin.webp +0 -0
- package/icons/providers/doubao.webp +0 -0
- package/icons/providers/dreammachine.webp +0 -0
- package/icons/providers/elevenlabs.webp +0 -0
- package/icons/providers/elevenx.webp +0 -0
- package/icons/providers/essentialai.webp +0 -0
- package/icons/providers/exa.webp +0 -0
- package/icons/providers/fal.webp +0 -0
- package/icons/providers/fastgpt.webp +0 -0
- package/icons/providers/featherless.webp +0 -0
- package/icons/providers/figma.webp +0 -0
- package/icons/providers/fireworks.webp +0 -0
- package/icons/providers/fishaudio.webp +0 -0
- package/icons/providers/flora.webp +0 -0
- package/icons/providers/flowith.webp +0 -0
- package/icons/providers/flux.webp +0 -0
- package/icons/providers/friendli.webp +0 -0
- package/icons/providers/gemini.webp +0 -0
- package/icons/providers/geminicli.webp +0 -0
- package/icons/providers/gemma.webp +0 -0
- package/icons/providers/gitee-ai.webp +0 -0
- package/icons/providers/giteeai.webp +0 -0
- package/icons/providers/github.webp +0 -0
- package/icons/providers/githubcopilot.webp +0 -0
- package/icons/providers/glama.webp +0 -0
- package/icons/providers/glif.webp +0 -0
- package/icons/providers/glmv.webp +0 -0
- package/icons/providers/google.webp +0 -0
- package/icons/providers/googlecloud.webp +0 -0
- package/icons/providers/goose.webp +0 -0
- package/icons/providers/gradio.webp +0 -0
- package/icons/providers/greptile.webp +0 -0
- package/icons/providers/grok.webp +0 -0
- package/icons/providers/groq.webp +0 -0
- package/icons/providers/hailuo.webp +0 -0
- package/icons/providers/haiper.webp +0 -0
- package/icons/providers/hedra.webp +0 -0
- package/icons/providers/hermesagent.webp +0 -0
- package/icons/providers/higress.webp +0 -0
- package/icons/providers/huawei.webp +0 -0
- package/icons/providers/huaweicloud.webp +0 -0
- package/icons/providers/huggingface.webp +0 -0
- package/icons/providers/hunyuan.webp +0 -0
- package/icons/providers/hyperbolic.webp +0 -0
- package/icons/providers/ibm.webp +0 -0
- package/icons/providers/ideogram.webp +0 -0
- package/icons/providers/iflytekcloud.webp +0 -0
- package/icons/providers/inception.webp +0 -0
- package/icons/providers/inference.webp +0 -0
- package/icons/providers/infermatic.webp +0 -0
- package/icons/providers/infini.webp +0 -0
- package/icons/providers/infinigence.webp +0 -0
- package/icons/providers/inflection.webp +0 -0
- package/icons/providers/internlm.webp +0 -0
- package/icons/providers/jimeng.webp +0 -0
- package/icons/providers/jina.webp +0 -0
- package/icons/providers/junie.webp +0 -0
- package/icons/providers/kilocode.webp +0 -0
- package/icons/providers/kimi.webp +0 -0
- package/icons/providers/kiro.webp +0 -0
- package/icons/providers/kling.webp +0 -0
- package/icons/providers/kluster.webp +0 -0
- package/icons/providers/kolors.webp +0 -0
- package/icons/providers/krea.webp +0 -0
- package/icons/providers/kwaikat.webp +0 -0
- package/icons/providers/kwaipilot.webp +0 -0
- package/icons/providers/lambda.webp +0 -0
- package/icons/providers/langchain.webp +0 -0
- package/icons/providers/langfuse.webp +0 -0
- package/icons/providers/langgraph.webp +0 -0
- package/icons/providers/langsmith.webp +0 -0
- package/icons/providers/leptonai.webp +0 -0
- package/icons/providers/lg.webp +0 -0
- package/icons/providers/lightricks.webp +0 -0
- package/icons/providers/liquid.webp +0 -0
- package/icons/providers/livekit.webp +0 -0
- package/icons/providers/llamaindex.webp +0 -0
- package/icons/providers/llava.webp +0 -0
- package/icons/providers/llmapi.webp +0 -0
- package/icons/providers/lmstudio.webp +0 -0
- package/icons/providers/lobehub.webp +0 -0
- package/icons/providers/longcat.webp +0 -0
- package/icons/providers/lovable.webp +0 -0
- package/icons/providers/lovart.webp +0 -0
- package/icons/providers/luma.webp +0 -0
- package/icons/providers/magic.webp +0 -0
- package/icons/providers/make.webp +0 -0
- package/icons/providers/manus.webp +0 -0
- package/icons/providers/mastra.webp +0 -0
- package/icons/providers/mcp.webp +0 -0
- package/icons/providers/mcpso.webp +0 -0
- package/icons/providers/menlo.webp +0 -0
- package/icons/providers/meshy.webp +0 -0
- package/icons/providers/meta.webp +0 -0
- package/icons/providers/metaai.webp +0 -0
- package/icons/providers/metagpt.webp +0 -0
- package/icons/providers/microsoft.webp +0 -0
- package/icons/providers/midjourney.webp +0 -0
- package/icons/providers/minimax.webp +0 -0
- package/icons/providers/mistral.webp +0 -0
- package/icons/providers/modelscope.webp +0 -0
- package/icons/providers/monica.webp +0 -0
- package/icons/providers/moonshot.webp +0 -0
- package/icons/providers/morph.webp +0 -0
- package/icons/providers/moxt.webp +0 -0
- package/icons/providers/myshell.webp +0 -0
- package/icons/providers/n8n.webp +0 -0
- package/icons/providers/nanobanana.webp +0 -0
- package/icons/providers/nebius.webp +0 -0
- package/icons/providers/newapi.webp +0 -0
- package/icons/providers/notebooklm.webp +0 -0
- package/icons/providers/notion.webp +0 -0
- package/icons/providers/nousresearch.webp +0 -0
- package/icons/providers/nova.webp +0 -0
- package/icons/providers/novelai.webp +0 -0
- package/icons/providers/novita.webp +0 -0
- package/icons/providers/nplcloud.webp +0 -0
- package/icons/providers/nvidia.webp +0 -0
- package/icons/providers/o3.webp +0 -0
- package/icons/providers/obsidian.webp +0 -0
- package/icons/providers/ollama.webp +0 -0
- package/icons/providers/openai.webp +0 -0
- package/icons/providers/openchat.webp +0 -0
- package/icons/providers/openclaw.webp +0 -0
- package/icons/providers/opencode.webp +0 -0
- package/icons/providers/openhands.webp +0 -0
- package/icons/providers/openhuman.webp +0 -0
- package/icons/providers/openrouter.webp +0 -0
- package/icons/providers/openwebui.webp +0 -0
- package/icons/providers/paddleocr.webp +0 -0
- package/icons/providers/palm.webp +0 -0
- package/icons/providers/parasail.webp +0 -0
- package/icons/providers/perplexity.webp +0 -0
- package/icons/providers/phidata.webp +0 -0
- package/icons/providers/phind.webp +0 -0
- package/icons/providers/pika.webp +0 -0
- package/icons/providers/pixverse.webp +0 -0
- package/icons/providers/player2.webp +0 -0
- package/icons/providers/poe.webp +0 -0
- package/icons/providers/pollinations.webp +0 -0
- package/icons/providers/ppio.webp +0 -0
- package/icons/providers/prunaai.webp +0 -0
- package/icons/providers/pydanticai.webp +0 -0
- package/icons/providers/qingyan.webp +0 -0
- package/icons/providers/qiniu.webp +0 -0
- package/icons/providers/qoder.webp +0 -0
- package/icons/providers/qwen.webp +0 -0
- package/icons/providers/railway.webp +0 -0
- package/icons/providers/recraft.webp +0 -0
- package/icons/providers/relace.webp +0 -0
- package/icons/providers/replicate.webp +0 -0
- package/icons/providers/replit.webp +0 -0
- package/icons/providers/reve.webp +0 -0
- package/icons/providers/roocode.webp +0 -0
- package/icons/providers/rsshub.webp +0 -0
- package/icons/providers/runway.webp +0 -0
- package/icons/providers/rwkv.webp +0 -0
- package/icons/providers/sambanova.webp +0 -0
- package/icons/providers/search1api.webp +0 -0
- package/icons/providers/searchapi.webp +0 -0
- package/icons/providers/sensenova.webp +0 -0
- package/icons/providers/silicon.webp +0 -0
- package/icons/providers/siliconcloud.webp +0 -0
- package/icons/providers/sillytavern.webp +0 -0
- package/icons/providers/skywork.webp +0 -0
- package/icons/providers/slock.webp +0 -0
- package/icons/providers/smithery.webp +0 -0
- package/icons/providers/snowflake.webp +0 -0
- package/icons/providers/sophnet.webp +0 -0
- package/icons/providers/sora.webp +0 -0
- package/icons/providers/spark.webp +0 -0
- package/icons/providers/speedai.webp +0 -0
- package/icons/providers/stability.webp +0 -0
- package/icons/providers/statecloud.webp +0 -0
- package/icons/providers/step.webp +0 -0
- package/icons/providers/stepfun.webp +0 -0
- package/icons/providers/straico.webp +0 -0
- package/icons/providers/streamlake.webp +0 -0
- package/icons/providers/submodel.webp +0 -0
- package/icons/providers/suno.webp +0 -0
- package/icons/providers/sync.webp +0 -0
- package/icons/providers/targon.webp +0 -0
- package/icons/providers/tavily.webp +0 -0
- package/icons/providers/tencent-cloud-ti.webp +0 -0
- package/icons/providers/tencent.webp +0 -0
- package/icons/providers/tencentcloud.webp +0 -0
- package/icons/providers/tiangong.webp +0 -0
- package/icons/providers/tii.webp +0 -0
- package/icons/providers/together.webp +0 -0
- package/icons/providers/tokenrouter.png +0 -0
- package/icons/providers/topazlabs.webp +0 -0
- package/icons/providers/trae.webp +0 -0
- package/icons/providers/tripo.webp +0 -0
- package/icons/providers/turix.webp +0 -0
- package/icons/providers/udio.webp +0 -0
- package/icons/providers/unstructured.webp +0 -0
- package/icons/providers/upstage.webp +0 -0
- package/icons/providers/v0.webp +0 -0
- package/icons/providers/vectorizerai.webp +0 -0
- package/icons/providers/venice.webp +0 -0
- package/icons/providers/vercel.webp +0 -0
- package/icons/providers/vertexai.webp +0 -0
- package/icons/providers/vidu.webp +0 -0
- package/icons/providers/viggle.webp +0 -0
- package/icons/providers/vllm.webp +0 -0
- package/icons/providers/volcengine.webp +0 -0
- package/icons/providers/voyage.webp +0 -0
- package/icons/providers/voyageai.webp +0 -0
- package/icons/providers/wenxin.webp +0 -0
- package/icons/providers/windsurf.webp +0 -0
- package/icons/providers/workersai.webp +0 -0
- package/icons/providers/worldrouter.webp +0 -0
- package/icons/providers/xai.webp +0 -0
- package/icons/providers/xiaomimimo.webp +0 -0
- package/icons/providers/xinference.webp +0 -0
- package/icons/providers/xirang.png +0 -0
- package/icons/providers/xpay.webp +0 -0
- package/icons/providers/xuanyuan.webp +0 -0
- package/icons/providers/yandex.webp +0 -0
- package/icons/providers/yi.webp +0 -0
- package/icons/providers/youmind.webp +0 -0
- package/icons/providers/yuanbao.webp +0 -0
- package/icons/providers/zai.webp +0 -0
- package/icons/providers/zapier.webp +0 -0
- package/icons/providers/zeabur.webp +0 -0
- package/icons/providers/zencoder.webp +0 -0
- package/icons/providers/zenmux.webp +0 -0
- package/icons/providers/zero-one.webp +0 -0
- package/icons/providers/zeroone.webp +0 -0
- package/icons/providers/zhipu.webp +0 -0
- package/package.json +105 -32
- package/styles/content.css +129 -0
- package/styles/yunui.css +185 -21
- package/dist/chunk-6MZN3GOP.js.map +0 -1
- package/dist/chunk-LLNTUA5K.js.map +0 -1
- package/dist/chunk-N53PNMPJ.js.map +0 -1
- package/dist/chunk-U2LNRVMI.js.map +0 -1
package/dist/content.js
ADDED
|
@@ -0,0 +1,1064 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useContentT, ImageLightbox } from './chunk-QEIBYOG2.js';
|
|
3
|
+
export { ImageLightbox } from './chunk-QEIBYOG2.js';
|
|
4
|
+
import { Alert, TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from './chunk-BCOKFWXC.js';
|
|
5
|
+
import { cn } from './chunk-N4QO7RN5.js';
|
|
6
|
+
import './chunk-3RT24MSH.js';
|
|
7
|
+
import * as React2 from 'react';
|
|
8
|
+
import { useState, useRef, useEffect, useMemo, useCallback } from 'react';
|
|
9
|
+
import ReactMarkdown from 'react-markdown';
|
|
10
|
+
import remarkGfm from 'remark-gfm';
|
|
11
|
+
import remarkMath from 'remark-math';
|
|
12
|
+
import rehypeRaw from 'rehype-raw';
|
|
13
|
+
import rehypeKatex from 'rehype-katex';
|
|
14
|
+
import rehypeSlug from 'rehype-slug';
|
|
15
|
+
import { Edit3, Check, Copy, CheckCircle2, XOctagon, AlertTriangle, AlertCircle, Lightbulb, Info, ExternalLink, Link2 } from 'lucide-react';
|
|
16
|
+
import { createHighlighterCore } from 'shiki/core';
|
|
17
|
+
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
18
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
+
import katex from 'katex';
|
|
20
|
+
|
|
21
|
+
var languageNames = {
|
|
22
|
+
js: "JavaScript",
|
|
23
|
+
javascript: "JavaScript",
|
|
24
|
+
ts: "TypeScript",
|
|
25
|
+
typescript: "TypeScript",
|
|
26
|
+
tsx: "TSX",
|
|
27
|
+
jsx: "JSX",
|
|
28
|
+
py: "Python",
|
|
29
|
+
python: "Python",
|
|
30
|
+
rb: "Ruby",
|
|
31
|
+
ruby: "Ruby",
|
|
32
|
+
go: "Go",
|
|
33
|
+
rust: "Rust",
|
|
34
|
+
rs: "Rust",
|
|
35
|
+
cpp: "C++",
|
|
36
|
+
c: "C",
|
|
37
|
+
java: "Java",
|
|
38
|
+
kotlin: "Kotlin",
|
|
39
|
+
kt: "Kotlin",
|
|
40
|
+
swift: "Swift",
|
|
41
|
+
php: "PHP",
|
|
42
|
+
sql: "SQL",
|
|
43
|
+
html: "HTML",
|
|
44
|
+
css: "CSS",
|
|
45
|
+
scss: "SCSS",
|
|
46
|
+
sass: "Sass",
|
|
47
|
+
json: "JSON",
|
|
48
|
+
yaml: "YAML",
|
|
49
|
+
yml: "YAML",
|
|
50
|
+
xml: "XML",
|
|
51
|
+
md: "Markdown",
|
|
52
|
+
markdown: "Markdown",
|
|
53
|
+
bash: "Bash",
|
|
54
|
+
sh: "Shell",
|
|
55
|
+
shell: "Shell",
|
|
56
|
+
zsh: "Zsh",
|
|
57
|
+
powershell: "PowerShell",
|
|
58
|
+
ps1: "PowerShell",
|
|
59
|
+
dockerfile: "Dockerfile",
|
|
60
|
+
docker: "Docker",
|
|
61
|
+
graphql: "GraphQL",
|
|
62
|
+
vue: "Vue",
|
|
63
|
+
svelte: "Svelte",
|
|
64
|
+
diff: "Diff",
|
|
65
|
+
plaintext: "Plain Text",
|
|
66
|
+
text: "Plain Text"
|
|
67
|
+
};
|
|
68
|
+
var langExtMap = {
|
|
69
|
+
typescript: "ts",
|
|
70
|
+
javascript: "js",
|
|
71
|
+
python: "py",
|
|
72
|
+
bash: "sh",
|
|
73
|
+
shell: "sh",
|
|
74
|
+
markdown: "md"
|
|
75
|
+
};
|
|
76
|
+
var shikiLanguages = {
|
|
77
|
+
bash: () => import('shiki/langs/bash.mjs'),
|
|
78
|
+
c: () => import('shiki/langs/c.mjs'),
|
|
79
|
+
cpp: () => import('shiki/langs/cpp.mjs'),
|
|
80
|
+
css: () => import('shiki/langs/css.mjs'),
|
|
81
|
+
diff: () => import('shiki/langs/diff.mjs'),
|
|
82
|
+
dockerfile: () => import('shiki/langs/dockerfile.mjs'),
|
|
83
|
+
go: () => import('shiki/langs/go.mjs'),
|
|
84
|
+
graphql: () => import('shiki/langs/graphql.mjs'),
|
|
85
|
+
html: () => import('shiki/langs/html.mjs'),
|
|
86
|
+
java: () => import('shiki/langs/java.mjs'),
|
|
87
|
+
javascript: () => import('shiki/langs/javascript.mjs'),
|
|
88
|
+
json: () => import('shiki/langs/json.mjs'),
|
|
89
|
+
jsx: () => import('shiki/langs/jsx.mjs'),
|
|
90
|
+
kotlin: () => import('shiki/langs/kotlin.mjs'),
|
|
91
|
+
markdown: () => import('shiki/langs/markdown.mjs'),
|
|
92
|
+
php: () => import('shiki/langs/php.mjs'),
|
|
93
|
+
powershell: () => import('shiki/langs/powershell.mjs'),
|
|
94
|
+
python: () => import('shiki/langs/python.mjs'),
|
|
95
|
+
ruby: () => import('shiki/langs/ruby.mjs'),
|
|
96
|
+
rust: () => import('shiki/langs/rust.mjs'),
|
|
97
|
+
sass: () => import('shiki/langs/sass.mjs'),
|
|
98
|
+
scss: () => import('shiki/langs/scss.mjs'),
|
|
99
|
+
sql: () => import('shiki/langs/sql.mjs'),
|
|
100
|
+
svelte: () => import('shiki/langs/svelte.mjs'),
|
|
101
|
+
swift: () => import('shiki/langs/swift.mjs'),
|
|
102
|
+
tsx: () => import('shiki/langs/tsx.mjs'),
|
|
103
|
+
typescript: () => import('shiki/langs/typescript.mjs'),
|
|
104
|
+
vue: () => import('shiki/langs/vue.mjs'),
|
|
105
|
+
xml: () => import('shiki/langs/xml.mjs'),
|
|
106
|
+
yaml: () => import('shiki/langs/yaml.mjs')
|
|
107
|
+
};
|
|
108
|
+
var shikiLanguageAliases = {
|
|
109
|
+
cxx: "cpp",
|
|
110
|
+
docker: "dockerfile",
|
|
111
|
+
js: "javascript",
|
|
112
|
+
kt: "kotlin",
|
|
113
|
+
md: "markdown",
|
|
114
|
+
py: "python",
|
|
115
|
+
rb: "ruby",
|
|
116
|
+
rs: "rust",
|
|
117
|
+
sh: "bash",
|
|
118
|
+
shell: "bash",
|
|
119
|
+
ts: "typescript",
|
|
120
|
+
yml: "yaml",
|
|
121
|
+
zsh: "bash"
|
|
122
|
+
};
|
|
123
|
+
var shikiThemes = {
|
|
124
|
+
"github-dark": () => import('shiki/themes/github-dark.mjs'),
|
|
125
|
+
"github-light": () => import('shiki/themes/github-light.mjs')
|
|
126
|
+
};
|
|
127
|
+
var contentHighlighterPromise;
|
|
128
|
+
var languageLoadPromises = /* @__PURE__ */ new Map();
|
|
129
|
+
var themeLoadPromises = /* @__PURE__ */ new Map();
|
|
130
|
+
function getContentHighlighter() {
|
|
131
|
+
contentHighlighterPromise ??= createHighlighterCore({
|
|
132
|
+
// The JavaScript regex engine avoids a WASM payload and is sufficient for
|
|
133
|
+
// browser-side highlighting of the curated grammar set above.
|
|
134
|
+
engine: createJavaScriptRegexEngine()
|
|
135
|
+
});
|
|
136
|
+
return contentHighlighterPromise;
|
|
137
|
+
}
|
|
138
|
+
async function ensureLanguage(highlighter, language) {
|
|
139
|
+
if (language === "plaintext" || highlighter.getLoadedLanguages().includes(language)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let pending = languageLoadPromises.get(language);
|
|
143
|
+
if (!pending) {
|
|
144
|
+
pending = (async () => {
|
|
145
|
+
const registration = (await shikiLanguages[language]()).default;
|
|
146
|
+
await highlighter.loadLanguage(registration);
|
|
147
|
+
})();
|
|
148
|
+
languageLoadPromises.set(language, pending);
|
|
149
|
+
}
|
|
150
|
+
await pending;
|
|
151
|
+
}
|
|
152
|
+
async function ensureTheme(highlighter, theme) {
|
|
153
|
+
if (highlighter.getLoadedThemes().includes(theme)) return;
|
|
154
|
+
let pending = themeLoadPromises.get(theme);
|
|
155
|
+
if (!pending) {
|
|
156
|
+
pending = (async () => {
|
|
157
|
+
const registration = (await shikiThemes[theme]()).default;
|
|
158
|
+
await highlighter.loadTheme(registration);
|
|
159
|
+
})();
|
|
160
|
+
themeLoadPromises.set(theme, pending);
|
|
161
|
+
}
|
|
162
|
+
await pending;
|
|
163
|
+
}
|
|
164
|
+
async function highlightToHtml(code, options) {
|
|
165
|
+
const highlighter = await getContentHighlighter();
|
|
166
|
+
const language = options.lang;
|
|
167
|
+
const theme = options.theme;
|
|
168
|
+
await Promise.all([
|
|
169
|
+
ensureLanguage(highlighter, language),
|
|
170
|
+
ensureTheme(highlighter, theme)
|
|
171
|
+
]);
|
|
172
|
+
return highlighter.codeToHtml(code, options);
|
|
173
|
+
}
|
|
174
|
+
function resolveShikiLanguage(language) {
|
|
175
|
+
const normalized = language.trim().toLowerCase();
|
|
176
|
+
if (!normalized || normalized === "text" || normalized === "plaintext") {
|
|
177
|
+
return "plaintext";
|
|
178
|
+
}
|
|
179
|
+
if (normalized in shikiLanguages) return normalized;
|
|
180
|
+
return shikiLanguageAliases[normalized] ?? "plaintext";
|
|
181
|
+
}
|
|
182
|
+
function useIsDarkMode() {
|
|
183
|
+
const [isDark, setIsDark] = useState(false);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
const check = () => setIsDark(document.documentElement.classList.contains("dark"));
|
|
186
|
+
check();
|
|
187
|
+
const observer = new MutationObserver(check);
|
|
188
|
+
observer.observe(document.documentElement, {
|
|
189
|
+
attributes: true,
|
|
190
|
+
attributeFilter: ["class"]
|
|
191
|
+
});
|
|
192
|
+
return () => observer.disconnect();
|
|
193
|
+
}, []);
|
|
194
|
+
return isDark;
|
|
195
|
+
}
|
|
196
|
+
function CodeBlock({
|
|
197
|
+
children,
|
|
198
|
+
language = "plaintext",
|
|
199
|
+
showLineNumbers = false,
|
|
200
|
+
highlightLines = [],
|
|
201
|
+
filename,
|
|
202
|
+
className,
|
|
203
|
+
onEdit
|
|
204
|
+
}) {
|
|
205
|
+
const [copied, setCopied] = useState(false);
|
|
206
|
+
const [highlightedCode, setHighlightedCode] = useState("");
|
|
207
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
208
|
+
const isDark = useIsDarkMode();
|
|
209
|
+
const t = useContentT();
|
|
210
|
+
const code = useMemo(
|
|
211
|
+
() => typeof children === "string" ? children.trim() : String(children).trim(),
|
|
212
|
+
[children]
|
|
213
|
+
);
|
|
214
|
+
const displayLanguage = languageNames[language?.toLowerCase()] || language?.toUpperCase() || "CODE";
|
|
215
|
+
const handleEdit = useCallback(() => {
|
|
216
|
+
if (!onEdit) return;
|
|
217
|
+
const ext = langExtMap[language?.toLowerCase()] || language || "txt";
|
|
218
|
+
onEdit({ code, language, filename: filename || `snippet.${ext}` });
|
|
219
|
+
}, [onEdit, code, language, filename]);
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
let cancelled = false;
|
|
222
|
+
async function highlight() {
|
|
223
|
+
setIsLoading(true);
|
|
224
|
+
try {
|
|
225
|
+
const theme = isDark ? "github-dark" : "github-light";
|
|
226
|
+
const lang = resolveShikiLanguage(language || "plaintext");
|
|
227
|
+
const html = await highlightToHtml(code, {
|
|
228
|
+
lang,
|
|
229
|
+
theme,
|
|
230
|
+
transformers: [
|
|
231
|
+
{
|
|
232
|
+
line(node, line) {
|
|
233
|
+
if (showLineNumbers) node.properties["data-line"] = line;
|
|
234
|
+
if (highlightLines.includes(line)) {
|
|
235
|
+
node.properties["class"] = `${node.properties["class"] || ""} highlighted-line`;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
});
|
|
241
|
+
if (!cancelled) {
|
|
242
|
+
setHighlightedCode(html);
|
|
243
|
+
setIsLoading(false);
|
|
244
|
+
}
|
|
245
|
+
} catch {
|
|
246
|
+
if (!cancelled) {
|
|
247
|
+
setHighlightedCode(
|
|
248
|
+
`<pre class="shiki"><code>${escapeHtml(code)}</code></pre>`
|
|
249
|
+
);
|
|
250
|
+
setIsLoading(false);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
highlight();
|
|
255
|
+
return () => {
|
|
256
|
+
cancelled = true;
|
|
257
|
+
};
|
|
258
|
+
}, [code, language, isDark, showLineNumbers, highlightLines]);
|
|
259
|
+
const handleCopy = async () => {
|
|
260
|
+
try {
|
|
261
|
+
if (navigator.clipboard?.writeText) {
|
|
262
|
+
await navigator.clipboard.writeText(code);
|
|
263
|
+
} else {
|
|
264
|
+
const textArea = document.createElement("textarea");
|
|
265
|
+
textArea.value = code;
|
|
266
|
+
document.body.appendChild(textArea);
|
|
267
|
+
textArea.select();
|
|
268
|
+
document.execCommand("copy");
|
|
269
|
+
document.body.removeChild(textArea);
|
|
270
|
+
}
|
|
271
|
+
setCopied(true);
|
|
272
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
273
|
+
} catch {
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
const btnBase = "flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium transition-all hover:bg-(--accent-subtle) outline-none focus-visible:ring-2 focus-visible:ring-ring";
|
|
277
|
+
return /* @__PURE__ */ jsxs(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: cn(
|
|
281
|
+
"card group my-4 overflow-hidden max-w-full min-w-0",
|
|
282
|
+
className
|
|
283
|
+
),
|
|
284
|
+
children: [
|
|
285
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2.5 border-b border-(--border-hairline) bg-(--bg-elevated)", children: [
|
|
286
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
287
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
288
|
+
/* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--error) opacity-80" }),
|
|
289
|
+
/* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--warning) opacity-80" }),
|
|
290
|
+
/* @__PURE__ */ jsx("div", { className: "w-2 h-2 rounded-full bg-(--success) opacity-80" })
|
|
291
|
+
] }),
|
|
292
|
+
filename ? /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-(--text-secondary) font-mono", children: filename }) : /* @__PURE__ */ jsx("span", { className: "badge text-xs", children: displayLanguage })
|
|
293
|
+
] }),
|
|
294
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
295
|
+
onEdit && /* @__PURE__ */ jsxs("button", { onClick: handleEdit, className: cn(btnBase, "text-(--text-secondary)"), children: [
|
|
296
|
+
/* @__PURE__ */ jsx(Edit3, { className: "w-3.5 h-3.5" }),
|
|
297
|
+
t("edit", "Edit")
|
|
298
|
+
] }),
|
|
299
|
+
/* @__PURE__ */ jsx("button", { onClick: handleCopy, className: btnBase, children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
300
|
+
/* @__PURE__ */ jsx(Check, { className: "w-3.5 h-3.5 text-(--success)" }),
|
|
301
|
+
/* @__PURE__ */ jsx("span", { className: "text-(--success)", children: t("copied", "Copied") })
|
|
302
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
303
|
+
/* @__PURE__ */ jsx(Copy, { className: "w-3.5 h-3.5 text-(--text-secondary)" }),
|
|
304
|
+
/* @__PURE__ */ jsx("span", { className: "text-(--text-secondary)", children: t("copy", "Copy") })
|
|
305
|
+
] }) })
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
"div",
|
|
310
|
+
{
|
|
311
|
+
tabIndex: 0,
|
|
312
|
+
className: cn(
|
|
313
|
+
"overflow-x-auto overflow-y-auto p-4 max-h-100 bg-(--bg-base)",
|
|
314
|
+
showLineNumbers && "code-with-line-numbers"
|
|
315
|
+
),
|
|
316
|
+
children: isLoading ? /* @__PURE__ */ jsx("pre", { className: "text-sm font-mono", children: /* @__PURE__ */ jsx("code", { children: code }) }) : /* @__PURE__ */ jsx(
|
|
317
|
+
"div",
|
|
318
|
+
{
|
|
319
|
+
className: "shiki-wrapper text-sm [&_pre]:bg-transparent! [&_code]:bg-transparent!",
|
|
320
|
+
dangerouslySetInnerHTML: { __html: highlightedCode }
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
function InlineCode({
|
|
330
|
+
children,
|
|
331
|
+
className
|
|
332
|
+
}) {
|
|
333
|
+
return /* @__PURE__ */ jsx(
|
|
334
|
+
"code",
|
|
335
|
+
{
|
|
336
|
+
className: cn(
|
|
337
|
+
"px-1.5 py-0.5 mx-0.5 rounded text-sm font-mono",
|
|
338
|
+
"bg-(--accent-subtle) text-(--text-primary) border border-(--border-hairline)",
|
|
339
|
+
"wrap-break-word",
|
|
340
|
+
className
|
|
341
|
+
),
|
|
342
|
+
children
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
function escapeHtml(str) {
|
|
347
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
348
|
+
}
|
|
349
|
+
var mermaidSeq = 0;
|
|
350
|
+
var NEEDS_MANUAL_ROUGHENING = /* @__PURE__ */ new Set([
|
|
351
|
+
"sequenceDiagram",
|
|
352
|
+
"gantt",
|
|
353
|
+
"pie",
|
|
354
|
+
"journey",
|
|
355
|
+
"gitGraph",
|
|
356
|
+
"timeline",
|
|
357
|
+
"mindmap",
|
|
358
|
+
"quadrantChart",
|
|
359
|
+
"xychart-beta",
|
|
360
|
+
"sankey-beta",
|
|
361
|
+
"packet-beta"
|
|
362
|
+
]);
|
|
363
|
+
function diagramType(chart) {
|
|
364
|
+
const lines = chart.trim().split("\n");
|
|
365
|
+
let i = 0;
|
|
366
|
+
if (lines[0]?.trim() === "---") {
|
|
367
|
+
i = 1;
|
|
368
|
+
while (i < lines.length && lines[i].trim() !== "---") i++;
|
|
369
|
+
i++;
|
|
370
|
+
}
|
|
371
|
+
for (; i < lines.length; i++) {
|
|
372
|
+
const l = lines[i].trim();
|
|
373
|
+
if (!l || l.startsWith("%%")) continue;
|
|
374
|
+
return l.split(/[\s:({]/)[0];
|
|
375
|
+
}
|
|
376
|
+
return "";
|
|
377
|
+
}
|
|
378
|
+
function needsManualRoughening(chart) {
|
|
379
|
+
return NEEDS_MANUAL_ROUGHENING.has(diagramType(chart));
|
|
380
|
+
}
|
|
381
|
+
function roughenSvg(svg, id) {
|
|
382
|
+
const vb = svg.match(/viewBox="([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)\s+([-\d.]+)"/);
|
|
383
|
+
if (!vb) return svg;
|
|
384
|
+
const [, mx, my, w, h] = vb.map(Number);
|
|
385
|
+
const pad = 12;
|
|
386
|
+
const fid = `${id}-rough`;
|
|
387
|
+
const defs = `<defs><filter id="${fid}" filterUnits="userSpaceOnUse" primitiveUnits="userSpaceOnUse" x="${mx - pad}" y="${my - pad}" width="${w + pad * 2}" height="${h + pad * 2}"><feTurbulence type="fractalNoise" baseFrequency="0.014" numOctaves="2" seed="7" result="n"/><feDisplacementMap in="SourceGraphic" in2="n" scale="2.4" xChannelSelector="R" yChannelSelector="G"/></filter></defs><style>#${id} path,#${id} rect,#${id} circle,#${id} ellipse,#${id} line,#${id} polygon,#${id} polyline{filter:url(#${fid})}#${id} text,#${id} tspan{filter:none}</style>`;
|
|
388
|
+
return svg.replace(/(<svg\b[^>]*>)/, `$1${defs}`);
|
|
389
|
+
}
|
|
390
|
+
function MermaidDiagram({
|
|
391
|
+
chart,
|
|
392
|
+
className,
|
|
393
|
+
enableZoom = true
|
|
394
|
+
}) {
|
|
395
|
+
const containerRef = useRef(null);
|
|
396
|
+
const [svg, setSvg] = useState("");
|
|
397
|
+
const [error, setError] = useState("");
|
|
398
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
399
|
+
const [themeTick, setThemeTick] = useState(0);
|
|
400
|
+
const [zoomOpen, setZoomOpen] = useState(false);
|
|
401
|
+
const t = useContentT();
|
|
402
|
+
useEffect(() => {
|
|
403
|
+
let cancelled = false;
|
|
404
|
+
async function renderDiagram() {
|
|
405
|
+
setIsLoading(true);
|
|
406
|
+
setError("");
|
|
407
|
+
const diagramId = `yunui-mermaid-${mermaidSeq += 1}`;
|
|
408
|
+
try {
|
|
409
|
+
const mermaid = (await import('mermaid')).default;
|
|
410
|
+
const isDark = typeof document !== "undefined" && document.documentElement.classList.contains("dark");
|
|
411
|
+
mermaid.initialize({
|
|
412
|
+
startOnLoad: false,
|
|
413
|
+
theme: isDark ? "dark" : "default",
|
|
414
|
+
// Native rough.js hand-drawn look — clean output for the types it
|
|
415
|
+
// supports (flowchart, state, class, ER, requirement, C4, block…).
|
|
416
|
+
look: "handDrawn",
|
|
417
|
+
handDrawnSeed: 1,
|
|
418
|
+
// "strict" (not "loose"): diagram source here is untrusted LLM/chat output.
|
|
419
|
+
// "loose" enables HTML labels + relaxes Mermaid's internal DOMPurify, so a
|
|
420
|
+
// label like <img src=x onerror=...> executes when the SVG is injected via
|
|
421
|
+
// dangerouslySetInnerHTML. "strict" sanitizes labels and disables htmlLabels.
|
|
422
|
+
securityLevel: "strict",
|
|
423
|
+
fontFamily: '"Comic Sans MS", "Segoe Print", ui-rounded, system-ui, sans-serif',
|
|
424
|
+
flowchart: { curve: "basis", padding: 20 },
|
|
425
|
+
sequence: { diagramMarginX: 20, diagramMarginY: 20 },
|
|
426
|
+
gantt: { barHeight: 20, barGap: 4 }
|
|
427
|
+
});
|
|
428
|
+
const { svg: renderedSvg } = await mermaid.render(diagramId, chart.trim());
|
|
429
|
+
if (!cancelled) {
|
|
430
|
+
setSvg(
|
|
431
|
+
needsManualRoughening(chart) ? roughenSvg(renderedSvg, diagramId) : renderedSvg
|
|
432
|
+
);
|
|
433
|
+
setIsLoading(false);
|
|
434
|
+
}
|
|
435
|
+
} catch (err) {
|
|
436
|
+
if (!cancelled) {
|
|
437
|
+
setError(
|
|
438
|
+
err instanceof Error ? err.message : t("diagramRenderFailed", "Failed to render diagram")
|
|
439
|
+
);
|
|
440
|
+
setIsLoading(false);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
renderDiagram();
|
|
445
|
+
return () => {
|
|
446
|
+
cancelled = true;
|
|
447
|
+
};
|
|
448
|
+
}, [chart, themeTick]);
|
|
449
|
+
useEffect(() => {
|
|
450
|
+
if (typeof document === "undefined") return;
|
|
451
|
+
const observer = new MutationObserver(() => setThemeTick((n) => n + 1));
|
|
452
|
+
observer.observe(document.documentElement, {
|
|
453
|
+
attributes: true,
|
|
454
|
+
attributeFilter: ["class"]
|
|
455
|
+
});
|
|
456
|
+
return () => observer.disconnect();
|
|
457
|
+
}, []);
|
|
458
|
+
if (error) {
|
|
459
|
+
return /* @__PURE__ */ jsx(
|
|
460
|
+
"div",
|
|
461
|
+
{
|
|
462
|
+
className: cn(
|
|
463
|
+
"my-4 p-4 rounded-xl border bg-error-soft border-error-soft",
|
|
464
|
+
className
|
|
465
|
+
),
|
|
466
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
467
|
+
/* @__PURE__ */ jsx("span", { className: "text-error", children: "\u26A0\uFE0F" }),
|
|
468
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
469
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-error", children: t("mermaidError", "Diagram error") }),
|
|
470
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-(--text-tertiary) mt-1", children: error }),
|
|
471
|
+
/* @__PURE__ */ jsxs("details", { className: "mt-2", children: [
|
|
472
|
+
/* @__PURE__ */ jsx("summary", { className: "text-xs text-(--text-tertiary) cursor-pointer hover:text-(--text-primary)", children: t("viewSource", "View source") }),
|
|
473
|
+
/* @__PURE__ */ jsx("pre", { className: "mt-2 p-2 bg-(--bg-elevated) rounded text-xs overflow-auto", tabIndex: 0, children: chart })
|
|
474
|
+
] })
|
|
475
|
+
] })
|
|
476
|
+
] })
|
|
477
|
+
}
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (isLoading) {
|
|
481
|
+
return /* @__PURE__ */ jsx(
|
|
482
|
+
"div",
|
|
483
|
+
{
|
|
484
|
+
className: cn(
|
|
485
|
+
"card my-4 p-8 flex items-center justify-center",
|
|
486
|
+
className
|
|
487
|
+
),
|
|
488
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-(--text-tertiary)", children: [
|
|
489
|
+
/* @__PURE__ */ jsx("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
|
|
490
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: t("renderingDiagram", "Rendering diagram\u2026") })
|
|
491
|
+
] })
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
496
|
+
/* @__PURE__ */ jsx(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
ref: containerRef,
|
|
500
|
+
onClick: enableZoom ? () => setZoomOpen(true) : void 0,
|
|
501
|
+
role: enableZoom ? "button" : void 0,
|
|
502
|
+
"aria-label": enableZoom ? t("zoomDiagram", "Zoom diagram") : void 0,
|
|
503
|
+
tabIndex: 0,
|
|
504
|
+
className: cn(
|
|
505
|
+
"mermaid-container card my-4 p-4 overflow-x-auto",
|
|
506
|
+
"flex items-center justify-center",
|
|
507
|
+
"[&_svg]:max-w-full [&_svg]:h-auto",
|
|
508
|
+
enableZoom && "cursor-zoom-in",
|
|
509
|
+
className
|
|
510
|
+
),
|
|
511
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
512
|
+
}
|
|
513
|
+
),
|
|
514
|
+
enableZoom && /* @__PURE__ */ jsx(ImageLightbox, { isOpen: zoomOpen, onClose: () => setZoomOpen(false), children: /* @__PURE__ */ jsx(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: "bg-(--bg-card) rounded-2xl p-6 shadow-2xl border border-white/10 w-[86vw] max-w-[1100px] [&_svg]:!max-w-none [&_svg]:w-full [&_svg]:h-auto [&_svg]:max-h-[80vh]",
|
|
518
|
+
dangerouslySetInnerHTML: { __html: svg }
|
|
519
|
+
}
|
|
520
|
+
) })
|
|
521
|
+
] });
|
|
522
|
+
}
|
|
523
|
+
var config = {
|
|
524
|
+
note: { variant: "info", icon: Info },
|
|
525
|
+
tip: { variant: "success", icon: Lightbulb },
|
|
526
|
+
important: { variant: "accent", icon: AlertCircle },
|
|
527
|
+
warning: { variant: "warning", icon: AlertTriangle },
|
|
528
|
+
caution: { variant: "error", icon: XOctagon },
|
|
529
|
+
success: { variant: "success", icon: CheckCircle2 }
|
|
530
|
+
};
|
|
531
|
+
var defaultTitles = {
|
|
532
|
+
note: "Note",
|
|
533
|
+
tip: "Tip",
|
|
534
|
+
important: "Important",
|
|
535
|
+
warning: "Warning",
|
|
536
|
+
caution: "Caution",
|
|
537
|
+
success: "Success"
|
|
538
|
+
};
|
|
539
|
+
function CalloutBlock({
|
|
540
|
+
type,
|
|
541
|
+
title,
|
|
542
|
+
children,
|
|
543
|
+
className
|
|
544
|
+
}) {
|
|
545
|
+
const t = useContentT();
|
|
546
|
+
const c = config[type] || config.note;
|
|
547
|
+
const Icon = c.icon;
|
|
548
|
+
const displayTitle = title || t(type, defaultTitles[type] || defaultTitles.note);
|
|
549
|
+
return /* @__PURE__ */ jsx(
|
|
550
|
+
Alert,
|
|
551
|
+
{
|
|
552
|
+
variant: c.variant,
|
|
553
|
+
title: displayTitle,
|
|
554
|
+
icon: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }),
|
|
555
|
+
className: cn("my-4 not-prose", className),
|
|
556
|
+
children: /* @__PURE__ */ jsx("div", { className: "[&>p]:my-1 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0", children })
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
function parseCalloutType(text) {
|
|
561
|
+
const match = text.match(
|
|
562
|
+
/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION|SUCCESS)\](?:\s+(.+))?$/i
|
|
563
|
+
);
|
|
564
|
+
if (match) {
|
|
565
|
+
return {
|
|
566
|
+
type: match[1].toLowerCase(),
|
|
567
|
+
title: match[2] || null
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return { type: null, title: null };
|
|
571
|
+
}
|
|
572
|
+
var ContentImage = React2.memo(function ContentImage2({
|
|
573
|
+
enableLightbox = true,
|
|
574
|
+
className,
|
|
575
|
+
alt = "",
|
|
576
|
+
src,
|
|
577
|
+
onError,
|
|
578
|
+
onLoad,
|
|
579
|
+
...rest
|
|
580
|
+
}) {
|
|
581
|
+
const [loaded, setLoaded] = useState(false);
|
|
582
|
+
const [failed, setFailed] = useState(false);
|
|
583
|
+
const [lightboxOpen, setLightboxOpen] = useState(false);
|
|
584
|
+
const imgRef = useRef(null);
|
|
585
|
+
const wrapperRef = useRef(null);
|
|
586
|
+
const t = useContentT();
|
|
587
|
+
const srcString = typeof src === "string" ? src : "";
|
|
588
|
+
const valid = srcString && srcString !== "#" && srcString !== "undefined" && srcString !== "null";
|
|
589
|
+
useEffect(() => {
|
|
590
|
+
if (!wrapperRef.current || !valid) return;
|
|
591
|
+
const container = document.querySelector('[data-scroll-container="true"]');
|
|
592
|
+
const root = container && container.contains(wrapperRef.current) ? container : null;
|
|
593
|
+
const observer = new IntersectionObserver(
|
|
594
|
+
(entries) => {
|
|
595
|
+
entries.forEach((entry) => {
|
|
596
|
+
if (entry.isIntersecting && imgRef.current) {
|
|
597
|
+
imgRef.current.src = srcString;
|
|
598
|
+
observer.unobserve(entry.target);
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
root,
|
|
604
|
+
rootMargin: "300px 0px",
|
|
605
|
+
threshold: 0.01
|
|
606
|
+
}
|
|
607
|
+
);
|
|
608
|
+
observer.observe(wrapperRef.current);
|
|
609
|
+
return () => observer.disconnect();
|
|
610
|
+
}, [srcString, valid]);
|
|
611
|
+
if (!valid) return null;
|
|
612
|
+
if (failed) {
|
|
613
|
+
return /* @__PURE__ */ jsx("span", { className: "inline-block", children: /* @__PURE__ */ jsx("span", { className: "bg-error-soft px-3 py-2 rounded-xl border border-error-soft text-center", children: /* @__PURE__ */ jsxs("span", { className: "text-error text-sm", children: [
|
|
614
|
+
"\u{1F5BC}\uFE0F ",
|
|
615
|
+
t("imageLoadingFailed", "Image failed to load")
|
|
616
|
+
] }) }) });
|
|
617
|
+
}
|
|
618
|
+
return /* @__PURE__ */ jsxs(
|
|
619
|
+
"span",
|
|
620
|
+
{
|
|
621
|
+
ref: wrapperRef,
|
|
622
|
+
className: "inline-block max-w-full overflow-hidden relative",
|
|
623
|
+
style: {
|
|
624
|
+
minHeight: loaded ? "auto" : "200px",
|
|
625
|
+
minWidth: loaded ? "auto" : "200px"
|
|
626
|
+
},
|
|
627
|
+
children: [
|
|
628
|
+
!loaded && /* @__PURE__ */ jsx("span", { className: "absolute inset-0 flex items-center justify-center bg-(--bg-elevated) rounded-xl", children: /* @__PURE__ */ jsx("span", { className: "w-6 h-6 border-2 border-primary border-t-transparent rounded-full animate-spin block" }) }),
|
|
629
|
+
/* @__PURE__ */ jsx(
|
|
630
|
+
"img",
|
|
631
|
+
{
|
|
632
|
+
ref: imgRef,
|
|
633
|
+
alt,
|
|
634
|
+
className: cn(
|
|
635
|
+
"max-w-full h-auto rounded-xl shadow-sm border border-(--border-hairline) transition-opacity duration-300",
|
|
636
|
+
loaded ? "opacity-100" : "opacity-0",
|
|
637
|
+
enableLightbox && loaded && "cursor-zoom-in",
|
|
638
|
+
className
|
|
639
|
+
),
|
|
640
|
+
style: { maxHeight: "80vh" },
|
|
641
|
+
onLoad: (e) => {
|
|
642
|
+
setLoaded(true);
|
|
643
|
+
onLoad?.(e);
|
|
644
|
+
},
|
|
645
|
+
onError: (e) => {
|
|
646
|
+
setFailed(true);
|
|
647
|
+
onError?.(e);
|
|
648
|
+
},
|
|
649
|
+
onClick: enableLightbox ? () => setLightboxOpen(true) : void 0,
|
|
650
|
+
...rest
|
|
651
|
+
}
|
|
652
|
+
),
|
|
653
|
+
enableLightbox && /* @__PURE__ */ jsx(
|
|
654
|
+
ImageLightbox,
|
|
655
|
+
{
|
|
656
|
+
src: srcString,
|
|
657
|
+
alt,
|
|
658
|
+
isOpen: lightboxOpen,
|
|
659
|
+
onClose: () => setLightboxOpen(false)
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
]
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
});
|
|
666
|
+
function MarkdownRenderer({
|
|
667
|
+
content,
|
|
668
|
+
className,
|
|
669
|
+
urlTransform,
|
|
670
|
+
onCodeEdit,
|
|
671
|
+
renderLink
|
|
672
|
+
}) {
|
|
673
|
+
const components = useMemo(
|
|
674
|
+
() => ({
|
|
675
|
+
p: ({ children }) => /* @__PURE__ */ jsx("div", { className: "mb-4 last:mb-0 leading-relaxed", children }),
|
|
676
|
+
h1: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
677
|
+
"h1",
|
|
678
|
+
{
|
|
679
|
+
id,
|
|
680
|
+
className: "group flex items-center gap-2 text-2xl font-bold mt-8 mb-4 first:mt-0 scroll-mt-20",
|
|
681
|
+
children: [
|
|
682
|
+
children,
|
|
683
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
684
|
+
]
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
h2: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
688
|
+
"h2",
|
|
689
|
+
{
|
|
690
|
+
id,
|
|
691
|
+
className: "group flex items-center gap-2 text-xl font-bold mt-6 mb-3 scroll-mt-20",
|
|
692
|
+
children: [
|
|
693
|
+
children,
|
|
694
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
),
|
|
698
|
+
h3: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
699
|
+
"h3",
|
|
700
|
+
{
|
|
701
|
+
id,
|
|
702
|
+
className: "group flex items-center gap-2 text-lg font-semibold mt-5 mb-2 scroll-mt-20",
|
|
703
|
+
children: [
|
|
704
|
+
children,
|
|
705
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
706
|
+
]
|
|
707
|
+
}
|
|
708
|
+
),
|
|
709
|
+
h4: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
710
|
+
"h4",
|
|
711
|
+
{
|
|
712
|
+
id,
|
|
713
|
+
className: "group flex items-center gap-2 text-base font-semibold mt-4 mb-2 scroll-mt-20",
|
|
714
|
+
children: [
|
|
715
|
+
children,
|
|
716
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
),
|
|
720
|
+
h5: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
721
|
+
"h5",
|
|
722
|
+
{
|
|
723
|
+
id,
|
|
724
|
+
className: "group flex items-center gap-2 text-sm font-semibold mt-3 mb-1 scroll-mt-20",
|
|
725
|
+
children: [
|
|
726
|
+
children,
|
|
727
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
h6: ({ children, id }) => /* @__PURE__ */ jsxs(
|
|
732
|
+
"h6",
|
|
733
|
+
{
|
|
734
|
+
id,
|
|
735
|
+
className: "group flex items-center gap-2 text-sm font-medium mt-3 mb-1 scroll-mt-20",
|
|
736
|
+
children: [
|
|
737
|
+
children,
|
|
738
|
+
id && /* @__PURE__ */ jsx(HeadingAnchor, { id })
|
|
739
|
+
]
|
|
740
|
+
}
|
|
741
|
+
),
|
|
742
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
743
|
+
code: ({ children, className: codeClass }) => {
|
|
744
|
+
const match = /language-(\w+)/.exec(codeClass || "");
|
|
745
|
+
const language = match ? match[1] : "";
|
|
746
|
+
const codeString = String(children).replace(/\n$/, "");
|
|
747
|
+
if (language === "mermaid") {
|
|
748
|
+
return /* @__PURE__ */ jsx(MermaidDiagram, { chart: codeString });
|
|
749
|
+
}
|
|
750
|
+
if (codeClass || codeString.includes("\n")) {
|
|
751
|
+
const showLineNumbers = codeClass?.includes("showLineNumbers");
|
|
752
|
+
const highlightMatch = codeClass?.match(/\{([^}]+)\}/);
|
|
753
|
+
const highlightLines = highlightMatch ? parseLineHighlights(highlightMatch[1]) : [];
|
|
754
|
+
return /* @__PURE__ */ jsx(
|
|
755
|
+
CodeBlock,
|
|
756
|
+
{
|
|
757
|
+
language,
|
|
758
|
+
showLineNumbers,
|
|
759
|
+
highlightLines,
|
|
760
|
+
onEdit: onCodeEdit,
|
|
761
|
+
children: codeString
|
|
762
|
+
}
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
return /* @__PURE__ */ jsx(InlineCode, { children });
|
|
766
|
+
},
|
|
767
|
+
pre: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children }),
|
|
768
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
769
|
+
img: ({ node, ...props }) => /* @__PURE__ */ jsx(ContentImage, { ...props }),
|
|
770
|
+
a: ({ href, children, ...props }) => {
|
|
771
|
+
const host = typeof window !== "undefined" ? window.location.host : "";
|
|
772
|
+
const isExternal = href?.startsWith("http") && !href?.includes(host);
|
|
773
|
+
const override = renderLink?.({ href, children, isExternal: Boolean(isExternal) });
|
|
774
|
+
if (override !== void 0) return override;
|
|
775
|
+
return /* @__PURE__ */ jsxs(
|
|
776
|
+
"a",
|
|
777
|
+
{
|
|
778
|
+
href,
|
|
779
|
+
target: isExternal ? "_blank" : void 0,
|
|
780
|
+
rel: isExternal ? "noopener noreferrer" : void 0,
|
|
781
|
+
className: "text-(--text-primary) underline decoration-(--border-default) underline-offset-2 hover:decoration-(--text-primary) inline-flex items-center gap-0.5",
|
|
782
|
+
...props,
|
|
783
|
+
children: [
|
|
784
|
+
children,
|
|
785
|
+
isExternal && /* @__PURE__ */ jsx(ExternalLink, { className: "w-3 h-3 inline-block ml-0.5" })
|
|
786
|
+
]
|
|
787
|
+
}
|
|
788
|
+
);
|
|
789
|
+
},
|
|
790
|
+
blockquote: ({ children }) => {
|
|
791
|
+
const childArray = React2.Children.toArray(children);
|
|
792
|
+
const firstEl = childArray.find((c) => React2.isValidElement(c));
|
|
793
|
+
if (React2.isValidElement(firstEl)) {
|
|
794
|
+
const paraKids = React2.Children.toArray(firstEl.props.children);
|
|
795
|
+
const leadStr = typeof paraKids[0] === "string" ? paraKids[0] : "";
|
|
796
|
+
const { type: calloutType, title } = parseCalloutType(
|
|
797
|
+
leadStr.split("\n")[0].trim()
|
|
798
|
+
);
|
|
799
|
+
if (calloutType) {
|
|
800
|
+
const rest = leadStr.includes("\n") ? leadStr.slice(leadStr.indexOf("\n") + 1) : "";
|
|
801
|
+
const body = [rest, ...paraKids.slice(1)];
|
|
802
|
+
const hasFirstPara = rest !== "" || paraKids.length > 1;
|
|
803
|
+
const otherBlocks = childArray.filter(
|
|
804
|
+
(c) => c !== firstEl && React2.isValidElement(c)
|
|
805
|
+
);
|
|
806
|
+
return /* @__PURE__ */ jsxs(CalloutBlock, { type: calloutType, title: title || void 0, children: [
|
|
807
|
+
hasFirstPara && /* @__PURE__ */ jsx("p", { children: body }),
|
|
808
|
+
otherBlocks
|
|
809
|
+
] });
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return /* @__PURE__ */ jsx("blockquote", { className: "border-l-4 border-(--border-default) pl-4 my-4 italic text-(--text-secondary)", children });
|
|
813
|
+
},
|
|
814
|
+
table: ({ children }) => /* @__PURE__ */ jsx("div", { className: "card my-4 overflow-x-auto", tabIndex: 0, children: /* @__PURE__ */ jsx("table", { className: "min-w-full divide-y divide-(--border-hairline)", children }) }),
|
|
815
|
+
thead: ({ children }) => /* @__PURE__ */ jsx("thead", { className: "bg-(--bg-elevated)", children }),
|
|
816
|
+
th: ({ children }) => /* @__PURE__ */ jsx("th", { className: "px-4 py-2 text-left text-sm font-semibold text-(--text-primary)", children }),
|
|
817
|
+
td: ({ children }) => /* @__PURE__ */ jsx("td", { className: "px-4 py-2 text-sm border-t border-(--border-hairline)", children }),
|
|
818
|
+
ul: ({ children }) => /* @__PURE__ */ jsx("ul", { className: "my-3 ml-6 list-disc space-y-1 [&>li]:pl-1", children }),
|
|
819
|
+
ol: ({ children }) => /* @__PURE__ */ jsx("ol", { className: "my-3 ml-6 list-decimal space-y-1 [&>li]:pl-1", children }),
|
|
820
|
+
li: ({ children, className: liClass }) => {
|
|
821
|
+
const isTaskItem = liClass?.includes("task-list-item");
|
|
822
|
+
return /* @__PURE__ */ jsx(
|
|
823
|
+
"li",
|
|
824
|
+
{
|
|
825
|
+
className: cn(
|
|
826
|
+
"leading-relaxed",
|
|
827
|
+
isTaskItem && "list-none -ml-6 flex items-start gap-2"
|
|
828
|
+
),
|
|
829
|
+
children
|
|
830
|
+
}
|
|
831
|
+
);
|
|
832
|
+
},
|
|
833
|
+
input: ({ type, checked, ...props }) => {
|
|
834
|
+
if (type === "checkbox") {
|
|
835
|
+
return /* @__PURE__ */ jsx(
|
|
836
|
+
"input",
|
|
837
|
+
{
|
|
838
|
+
type: "checkbox",
|
|
839
|
+
checked,
|
|
840
|
+
readOnly: true,
|
|
841
|
+
className: "mt-1 h-4 w-4 rounded border-(--border-hairline) accent-(--accent) focus:ring-ring",
|
|
842
|
+
...props
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
return /* @__PURE__ */ jsx("input", { type, ...props });
|
|
847
|
+
},
|
|
848
|
+
hr: () => /* @__PURE__ */ jsx("hr", { className: "my-6 border-t border-(--border-hairline)" }),
|
|
849
|
+
kbd: ({ children }) => /* @__PURE__ */ jsx("kbd", { className: "px-1.5 py-0.5 text-xs font-mono bg-(--bg-elevated) border border-(--border-default) rounded shadow-sm", children }),
|
|
850
|
+
mark: ({ children }) => /* @__PURE__ */ jsx("mark", { className: "bg-warning-soft text-(--text-primary) px-0.5 rounded", children }),
|
|
851
|
+
details: ({ children }) => /* @__PURE__ */ jsx("details", { className: "card my-4 overflow-hidden group", children }),
|
|
852
|
+
summary: ({ children }) => /* @__PURE__ */ jsx("summary", { className: "px-4 py-3 cursor-pointer select-none font-medium hover:bg-(--accent-subtle) transition-colors", children }),
|
|
853
|
+
abbr: ({ children, title }) => /* @__PURE__ */ jsx(
|
|
854
|
+
"abbr",
|
|
855
|
+
{
|
|
856
|
+
title,
|
|
857
|
+
className: "border-b border-dotted border-(--text-tertiary) cursor-help",
|
|
858
|
+
children
|
|
859
|
+
}
|
|
860
|
+
),
|
|
861
|
+
sub: ({ children }) => /* @__PURE__ */ jsx("sub", { className: "text-xs", children }),
|
|
862
|
+
sup: ({ children }) => /* @__PURE__ */ jsx("sup", { className: "text-xs", children }),
|
|
863
|
+
del: ({ children }) => /* @__PURE__ */ jsx("del", { className: "text-(--text-tertiary) line-through", children })
|
|
864
|
+
}),
|
|
865
|
+
[onCodeEdit, renderLink]
|
|
866
|
+
);
|
|
867
|
+
return /* @__PURE__ */ jsx(
|
|
868
|
+
"div",
|
|
869
|
+
{
|
|
870
|
+
className: cn(
|
|
871
|
+
// NOT prose. This renderer styles every element itself via the component
|
|
872
|
+
// map below, so Tailwind Typography would double-style everything — the
|
|
873
|
+
// table got a second frame + 28px dead-space margin, callout titles got
|
|
874
|
+
// shoved off their icon, and code blocks looked different inside prose vs
|
|
875
|
+
// out. `not-prose` makes our mappings the single source of truth, even
|
|
876
|
+
// when a host app wraps the output in `.prose`.
|
|
877
|
+
"not-prose text-sm leading-relaxed text-(--text-primary)",
|
|
878
|
+
className
|
|
879
|
+
),
|
|
880
|
+
children: /* @__PURE__ */ jsx(
|
|
881
|
+
ReactMarkdown,
|
|
882
|
+
{
|
|
883
|
+
remarkPlugins: [remarkGfm, remarkMath],
|
|
884
|
+
rehypePlugins: [rehypeRaw, rehypeKatex, rehypeSlug],
|
|
885
|
+
urlTransform,
|
|
886
|
+
components,
|
|
887
|
+
children: content
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
}
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
function HeadingAnchor({ id }) {
|
|
894
|
+
const [copied, setCopied] = useState(false);
|
|
895
|
+
const t = useContentT();
|
|
896
|
+
const handleClick = async (e) => {
|
|
897
|
+
e.preventDefault();
|
|
898
|
+
const url = `${window.location.origin}${window.location.pathname}#${id}`;
|
|
899
|
+
try {
|
|
900
|
+
await navigator.clipboard.writeText(url);
|
|
901
|
+
setCopied(true);
|
|
902
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
903
|
+
} catch {
|
|
904
|
+
window.location.hash = id;
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
return /* @__PURE__ */ jsx(
|
|
908
|
+
"a",
|
|
909
|
+
{
|
|
910
|
+
href: `#${id}`,
|
|
911
|
+
onClick: handleClick,
|
|
912
|
+
className: cn(
|
|
913
|
+
"opacity-0 group-hover:opacity-100 transition-opacity",
|
|
914
|
+
"text-(--text-tertiary) hover:text-(--text-primary)",
|
|
915
|
+
copied && "text-success"
|
|
916
|
+
),
|
|
917
|
+
"aria-label": t("linkToHeading", "Copy link to this heading"),
|
|
918
|
+
children: /* @__PURE__ */ jsx(Link2, { className: "w-4 h-4" })
|
|
919
|
+
}
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
function parseLineHighlights(input) {
|
|
923
|
+
const lines = [];
|
|
924
|
+
for (const part of input.split(",")) {
|
|
925
|
+
const trimmed = part.trim();
|
|
926
|
+
if (trimmed.includes("-")) {
|
|
927
|
+
const [start, end] = trimmed.split("-").map((n) => parseInt(n.trim(), 10));
|
|
928
|
+
if (!isNaN(start) && !isNaN(end)) {
|
|
929
|
+
for (let i = start; i <= end; i++) lines.push(i);
|
|
930
|
+
}
|
|
931
|
+
} else {
|
|
932
|
+
const num = parseInt(trimmed, 10);
|
|
933
|
+
if (!isNaN(num)) lines.push(num);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return lines;
|
|
937
|
+
}
|
|
938
|
+
function MathRenderer({ math, block = false, className }) {
|
|
939
|
+
const containerRef = useRef(null);
|
|
940
|
+
const [error, setError] = useState("");
|
|
941
|
+
const t = useContentT();
|
|
942
|
+
useEffect(() => {
|
|
943
|
+
if (!containerRef.current) return;
|
|
944
|
+
try {
|
|
945
|
+
katex.render(math, containerRef.current, {
|
|
946
|
+
displayMode: block,
|
|
947
|
+
throwOnError: false,
|
|
948
|
+
errorColor: "#cc0000",
|
|
949
|
+
strict: false,
|
|
950
|
+
// trust:false — untrusted math must not enable \href{javascript:...},
|
|
951
|
+
// \includegraphics, \htmlData etc. (KaTeX XSS surface).
|
|
952
|
+
trust: false,
|
|
953
|
+
macros: {
|
|
954
|
+
"\\RR": "\\mathbb{R}",
|
|
955
|
+
"\\NN": "\\mathbb{N}",
|
|
956
|
+
"\\ZZ": "\\mathbb{Z}",
|
|
957
|
+
"\\QQ": "\\mathbb{Q}",
|
|
958
|
+
"\\CC": "\\mathbb{C}"
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
setError("");
|
|
962
|
+
} catch (err) {
|
|
963
|
+
setError(
|
|
964
|
+
err instanceof Error ? err.message : t("formulaRenderFailed", "Formula render failed")
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
}, [math, block]);
|
|
968
|
+
if (error) {
|
|
969
|
+
return /* @__PURE__ */ jsx(
|
|
970
|
+
"span",
|
|
971
|
+
{
|
|
972
|
+
className: cn(
|
|
973
|
+
"text-error bg-error-soft px-1 rounded",
|
|
974
|
+
block ? "block my-2 p-2 text-center" : "inline",
|
|
975
|
+
className
|
|
976
|
+
),
|
|
977
|
+
children: /* @__PURE__ */ jsxs("span", { className: "text-xs", children: [
|
|
978
|
+
"\u26A0\uFE0F ",
|
|
979
|
+
error
|
|
980
|
+
] })
|
|
981
|
+
}
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
if (block) {
|
|
985
|
+
return /* @__PURE__ */ jsx(
|
|
986
|
+
"div",
|
|
987
|
+
{
|
|
988
|
+
tabIndex: 0,
|
|
989
|
+
className: cn(
|
|
990
|
+
"my-4 py-4 overflow-x-auto text-center",
|
|
991
|
+
"[&_.katex]:text-lg",
|
|
992
|
+
className
|
|
993
|
+
),
|
|
994
|
+
children: /* @__PURE__ */ jsx("span", { ref: containerRef })
|
|
995
|
+
}
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
return /* @__PURE__ */ jsx("span", { ref: containerRef, className: cn("inline-block align-middle", className) });
|
|
999
|
+
}
|
|
1000
|
+
function InlineMath({ value }) {
|
|
1001
|
+
return /* @__PURE__ */ jsx(MathRenderer, { math: value, block: false });
|
|
1002
|
+
}
|
|
1003
|
+
function BlockMath({ value }) {
|
|
1004
|
+
return /* @__PURE__ */ jsx(MathRenderer, { math: value, block: true });
|
|
1005
|
+
}
|
|
1006
|
+
function InlineCitation({
|
|
1007
|
+
label,
|
|
1008
|
+
title,
|
|
1009
|
+
meta,
|
|
1010
|
+
description,
|
|
1011
|
+
icon,
|
|
1012
|
+
onOpen,
|
|
1013
|
+
className
|
|
1014
|
+
}) {
|
|
1015
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 180, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1016
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1017
|
+
"button",
|
|
1018
|
+
{
|
|
1019
|
+
type: "button",
|
|
1020
|
+
"data-inline-citation": true,
|
|
1021
|
+
onClick: onOpen,
|
|
1022
|
+
className: cn(
|
|
1023
|
+
"mx-1 inline-flex h-6 max-w-40 translate-y-[1px] items-center gap-1 rounded-full",
|
|
1024
|
+
"border border-border/60 bg-muted/55 px-2 text-[11px] font-medium leading-none",
|
|
1025
|
+
"text-(--text-secondary) transition-colors hover:border-border hover:bg-muted hover:text-(--text-primary)",
|
|
1026
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",
|
|
1027
|
+
className
|
|
1028
|
+
),
|
|
1029
|
+
"aria-label": `${label}: ${title}${meta ? `, ${meta}` : ""}`,
|
|
1030
|
+
children: [
|
|
1031
|
+
icon ? /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center", children: icon }) : null,
|
|
1032
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: label })
|
|
1033
|
+
]
|
|
1034
|
+
}
|
|
1035
|
+
) }),
|
|
1036
|
+
/* @__PURE__ */ jsx(
|
|
1037
|
+
TooltipContent,
|
|
1038
|
+
{
|
|
1039
|
+
side: "top",
|
|
1040
|
+
align: "start",
|
|
1041
|
+
sideOffset: 8,
|
|
1042
|
+
className: cn(
|
|
1043
|
+
"w-[min(340px,calc(100vw-24px))] rounded-2xl border border-border",
|
|
1044
|
+
"bg-popover p-3 text-popover-foreground shadow-xl"
|
|
1045
|
+
),
|
|
1046
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-start gap-2.5", children: [
|
|
1047
|
+
icon ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-muted", children: icon }) : null,
|
|
1048
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1049
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
1050
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 text-xs font-semibold leading-snug", children: title }),
|
|
1051
|
+
onOpen ? /* @__PURE__ */ jsx(ExternalLink, { "aria-hidden": true, className: "mt-0.5 h-3 w-3 shrink-0 text-(--text-tertiary)" }) : null
|
|
1052
|
+
] }),
|
|
1053
|
+
meta ? /* @__PURE__ */ jsx("div", { className: "mt-0.5 text-[10px] text-(--text-tertiary)", children: meta }) : null,
|
|
1054
|
+
description ? /* @__PURE__ */ jsx("p", { className: "mt-2 line-clamp-4 text-[11px] font-normal leading-relaxed text-(--text-secondary)", children: description }) : null
|
|
1055
|
+
] })
|
|
1056
|
+
] })
|
|
1057
|
+
}
|
|
1058
|
+
)
|
|
1059
|
+
] }) });
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export { BlockMath, CalloutBlock, CodeBlock, ContentImage, InlineCitation, InlineCode, InlineMath, MarkdownRenderer, MathRenderer, MermaidDiagram, parseCalloutType };
|
|
1063
|
+
//# sourceMappingURL=content.js.map
|
|
1064
|
+
//# sourceMappingURL=content.js.map
|