@@ -16,6 +16,8 @@ import {
1616 insertAtCursor , wrapSelection , headingLines , promoteHeading , demoteHeading , mergeSelection , splitAtCursor ,
1717 type EditResult ,
1818} from "./markdownEdit" ;
19+ // v0.16.1:正文多色荧光笔——色板复用(选中色 → 包裹 ==[色]…==)
20+ import NoteColorPicker from "./NoteColorPicker" ;
1921
2022interface Props {
2123 note : Note ;
@@ -45,6 +47,8 @@ const NoteEditView = forwardRef<NoteEditHandle, Props>(function NoteEditView({ n
4547 const [ dirty , setDirty ] = useState ( false ) ;
4648 const [ saving , setSaving ] = useState ( false ) ;
4749 const [ status , setStatus ] = useState ( "" ) ;
50+ // v0.16.1:荧光笔色板弹层开合(与 RichEditorView 同模式)
51+ const [ highlightOpen , setHighlightOpen ] = useState ( false ) ;
4852 const taRef = useRef < HTMLTextAreaElement > ( null ) ;
4953 // L14:双计时器 ref(idle debounce + maxWait,常量见文件头注释)
5054 const idleTimerRef = useRef < ReturnType < typeof setTimeout > | null > ( null ) ;
@@ -203,7 +207,7 @@ const NoteEditView = forwardRef<NoteEditHandle, Props>(function NoteEditView({ n
203207
204208 // 工具栏操作(v0.10.1:local-image 需异步导入——dialog 选文件后复制进
205209 // data_dir 再插入相对引用;import 失败明确提示不落脏数据)
206- const toolbarAction = async ( action : string ) => {
210+ const toolbarAction = async ( action : string , color ?: string | null ) => {
207211 const ta = taRef . current ;
208212 if ( ! ta ) return ;
209213 // 读取当前 DOM 值与选区(受控组件下与 content state 一致)
@@ -240,6 +244,11 @@ const NoteEditView = forwardRef<NoteEditHandle, Props>(function NoteEditView({ n
240244 break ;
241245 }
242246 case "latex" : applyEdit ( wrapSelection ( v , s , e , "$" , "$" ) ) ; break ;
247+ // v0.16.1:正文多色荧光笔——默认黄 / 指定色(==文本== / ==[色]文本==)
248+ case "highlight-default" : applyEdit ( wrapSelection ( v , s , e , "==" , "==" ) ) ; break ;
249+ case "highlight-color" :
250+ if ( color ) applyEdit ( wrapSelection ( v , s , e , `==[${ color } ]` , "==" ) ) ;
251+ break ;
243252 case "image" : {
244253 // v0.15:外链图自动下载复制(防源站删除丢资源)——失败降级插原 URL + 提示
245254 const alt = prompt ( "图片描述:" ) || "" ;
@@ -322,6 +331,34 @@ const NoteEditView = forwardRef<NoteEditHandle, Props>(function NoteEditView({ n
322331 < button style = { TOOLBAR_BTN } onClick = { ( ) => void toolbarAction ( "local-image" ) } title = "插入本地图片(复制进应用数据目录)" > 🖼 图片</ button >
323332 < button style = { TOOLBAR_BTN } onClick = { ( ) => void toolbarAction ( "image" ) } title = "插入外链图(自动下载为本地副本)" > 🌐 链接图</ button >
324333 < button style = { TOOLBAR_BTN } onClick = { ( ) => void toolbarAction ( "latex" ) } title = "LaTeX" > Σ</ button >
334+ { /* v0.16.1:正文多色荧光笔——默认黄 / 12 色板(降级 textarea 与 CM 版同入口) */ }
335+ < div style = { { position : "relative" } } >
336+ < button style = { TOOLBAR_BTN } data-testid = "highlight-open" onClick = { ( ) => setHighlightOpen ( ( v ) => ! v ) } title = "荧光笔:==文本==(默认黄);==[色]文本==" > 🖍 荧光</ button >
337+ { highlightOpen && (
338+ < >
339+ < div onClick = { ( ) => setHighlightOpen ( false ) } style = { { position : "fixed" , inset : 0 , zIndex : 30 , background : "transparent" } } />
340+ < div
341+ data-testid = "highlight-pop"
342+ style = { { position : "absolute" , top : "100%" , left : 0 , zIndex : 31 , background : "#fff" , border : "1px solid #e5e7eb" , borderRadius : 6 , padding : 8 , boxShadow : "0 4px 12px rgba(0,0,0,0.12)" , maxWidth : 200 } }
343+ >
344+ < button
345+ data-testid = "highlight-default"
346+ style = { { ...TOOLBAR_BTN , width : "100%" , marginBottom : 6 , background : "#fefce8" } }
347+ onClick = { ( ) => { void toolbarAction ( "highlight-default" ) ; setHighlightOpen ( false ) ; } }
348+ >
349+ 🖍 默认黄 ==文本==
350+ </ button >
351+ < NoteColorPicker
352+ value = { null }
353+ onChange = { ( c ) => {
354+ if ( c ) void toolbarAction ( "highlight-color" , c ) ;
355+ setHighlightOpen ( false ) ;
356+ } }
357+ />
358+ </ div >
359+ </ >
360+ ) }
361+ </ div >
325362 < span style = { { flex : 1 } } />
326363 { /* A1段落操作提示 */ }
327364 < span style = { { fontSize : 10 , color : "#9ca3af" } } > Ctrl+Shift+↑↓层级 · M合并 · S拆分</ span >
0 commit comments