fix: resolve all TS errors, ESLint warnings, and npm warnings bump to v0.3.12
- Pin all @milkdown/* packages to exact 7.21.1, add phantom-dep plugins as direct deps - Fix TextSelection.create type error in useMilkdown.ts - Fix Backspace auto-pair dead-code bug (unreachable due to PAIRS check order) - Extract parseHeadings/Heading to outlineUtils.ts (react-refresh fix) - Extract StatusBar item components to StatusBarItems.tsx (react-refresh fix) - Configure npm allowScripts for electron and esbuild postinstall - Update QUALITY_REVIEW_REPORT.json with all fixes applied - Bump version to 0.3.12
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export interface Heading {
|
||||
level: number
|
||||
text: string
|
||||
/** Position in document (character offset from markdown source) */
|
||||
pos: number
|
||||
}
|
||||
|
||||
const HEADING_RE = /^(#{1,6})\s+(.+)$/gm
|
||||
|
||||
/**
|
||||
* Parse headings from raw markdown content using regex.
|
||||
*/
|
||||
export function parseHeadings(markdown: string): Heading[] {
|
||||
const headings: Heading[] = []
|
||||
let match: RegExpExecArray | null
|
||||
|
||||
// Reset regex state
|
||||
HEADING_RE.lastIndex = 0
|
||||
|
||||
while ((match = HEADING_RE.exec(markdown)) !== null) {
|
||||
const level = match[1].length
|
||||
const text = match[2].trim()
|
||||
headings.push({ level, text, pos: match.index })
|
||||
}
|
||||
|
||||
return headings
|
||||
}
|
||||
Reference in New Issue
Block a user