瀏覽代碼

feat(编辑器): 优化富文本工具栏样式切换逻辑,支持多种标签格式

Zhang Yice 1 月之前
父節點
當前提交
1624e9b03e

+ 1 - 1
src/components/Editor/RichTextEditor/RichTextEditor.tsx

@@ -455,7 +455,7 @@ export const RichTextEditor: React.FC<RichTextEditorProps> = ({
455 455
       />
456 456
 
457 457
       {/* 浮动工具栏放在编辑内容之后,避免 contenteditable 重绘时覆盖面板。 */}
458
-      {!readOnly && hasContent !== false && !tableContext && (
458
+      {!readOnly && hasContent !== false && (
459 459
         <RichTextToolbar
460 460
           position={toolbarPosition}
461 461
           editorElement={editorElement}

+ 5 - 1
src/components/Editor/RichTextEditor/RichTextToolbar.tsx

@@ -563,7 +563,11 @@ export const RichTextToolbar: React.FC<RichTextToolbarProps> = ({
563 563
   const toggleFormat = useCallback((tagName: string) => {
564 564
     if (isTableMode && tableContext) {
565 565
       // 表格模式:切换单元格样式
566
-      const styleKey = tagName === 'strong' ? 'bold' : tagName === 'em' ? 'italic' : 'underline';
566
+      const tagLower = tagName.toLowerCase();
567
+      const styleKey = tagLower === 'strong' || tagLower === 'b' ? 'bold' 
568
+        : tagLower === 'em' || tagLower === 'i' ? 'italic' 
569
+        : 'underline';
570
+      
567 571
       const currentValue = styleKey === 'bold'
568 572
         ? allSelectedCellsHaveBold
569 573
         : styleKey === 'italic'