Skip to content

Notes Markdown 编辑器的 4 项修复 - #3214

Open
Sammsai wants to merge 7 commits into
binaricat:mainfrom
Sammsai:main
Open

Notes Markdown 编辑器的 4 项修复#3214
Sammsai wants to merge 7 commits into
binaricat:mainfrom
Sammsai:main

Conversation

@Sammsai

@Sammsai Sammsai commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 代码块和数学公式块底框恢复:

恢复了 index.css 中代码块包裹层(_codeMirrorWrapper_)、渲染态 <pre>、独立数学公式段落(p.netcatty-math-block-p)以及数学公式阅读模式预览容器(netcatty-math-formula-preview)的 1px solid hsl(var(--border) / 0.6) 边框底框,确保结构层次与边界清晰可见。

  • 代码预测/补全框透明度与对比度修复:

在 index.css 中将 CodeMirror 的 .cm-tooltip、.cm-tooltip.cm-tooltip-autocomplete 以及子列表项配置为 hsl(var(--popover)) 实体不透明背景、明确的边框与阴影,并设置 opacity: 1 !important; z-index: 99999 !important;,保证在深色/浅色模式下均清晰可见且不透底。

  • 代码补全框避免被代码块边界裁剪:

在 InlineMarkdownEditor.tsx 中引入 CodeMirror @codemirror/state 的 Prec.highest,将 tooltips({ parent: document.body }) 提升至最高优先级,覆盖 @mdxeditor/editor 内部 basicSetup 的默认挂载行为,使代码提示悬浮窗直接挂载至 document.body,不再受限于简短或行数较少的代码框高度和 overflow 范围。

  • 语法高亮脱离主题色,采用独立高对比度配色:

移除基于 hsl(var(--primary)) 混合的单色调语法高亮计算,改用独立的多色高对比度语法配色方案(浅色/深色主题下关键字采用红/珊瑚色、类型与属性采用经典蓝/天蓝色、字符串采用绿色、常量/数值采用橙色、变量与标识符采用清晰文字色),避免与选中文本、当前行高亮或主题色发生混淆重合。

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Build / CI change
  • Other (please describe):

Related Issue (optional)

N/A

Changes Made

Screenshots / Demo

Testing

  • I have tested these changes locally (npm run dev)
  • Linting passes (npm run lint)
  • Tests pass (npm test)
  • Generated capability tool specs are updated when applicable (npm run generate:capability-tools)
  • No new console errors or warnings, if this affects app behavior

Checklist

  • My code follows the existing project style
  • I have added or updated relevant documentation
  • I have not introduced any breaking changes (or I have described them above)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9baa5f0f7d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +836 to +843
if (content) {
const trimmed = content.trim();
if (trimmed.startsWith("$$") && trimmed.endsWith("$$") && trimmed.length >= 4) {
return true;
}
if (trimmed.startsWith("\\[") && trimmed.endsWith("\\]") && trimmed.length >= 4) {
return true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require an explicit math language before replacing code blocks

When a plain-text or unlabeled fenced block literally contains $$...$$ or \[...\]—for example, documentation showing Markdown syntax—this content-only fallback now classifies it as math. In preview, annotateMathFormulaBlocks consequently hides the CodeMirror block and its copy action and substitutes a KaTeX rendering, even though the user did not select latex or tex; keep formula rendering gated by an explicit math language.

Useful? React with 👍 / 👎.

Comment on lines 305 to 307
shell: "Shell",
sql: "SQL",
tex: "TeX",
toml: "TOML",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the existing TeX language alias registered

Existing or imported notes can contain fenced tex blocks, and the surrounding detection and CSS still explicitly support tex, but removing it from NOTE_CODE_BLOCK_LANGUAGES means codeMirrorPlugin no longer recognizes or offers that language through its supported-language registry. Such blocks can therefore lose their CodeMirror editor/formula-preview path; retain the tex: "TeX" alias alongside latex for backward compatibility.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant