@@ -18,15 +18,6 @@ import { Numeric } from '@components/form/textfield';
1818import styles from './style.module.css' ;
1919import type { Props } from './types' ;
2020
21- const pickers = [
22- new ColorPanel . TailwindVarsPickerPanel ( ) ,
23- new ColorPanel . HSLPickerPanel ( ) ,
24- new ColorPanel . OKLCHPickerPanel ( ) ,
25- new ColorPanel . PresetPickerPanel ( ) ,
26- new ColorPanel . RGBPickerPanel ( ) ,
27- new ColorPanel . WebSafePickerPanel ( ) ,
28- ] ;
29-
3021/**
3122 * 指定文本的颜色
3223 *
@@ -55,6 +46,8 @@ export function Color(props: Props): JSX.Element {
5546 if ( accessor . getValue ( ) === color ) {
5647 return ;
5748 }
49+
50+ isSelectUpdate = true ;
5851 accessor . setValue ( color ) ;
5952 } ;
6053 onMount ( ( ) => props . editor . on ( 'selectionUpdate' , selectionUpdate ) ) ;
@@ -77,7 +70,13 @@ export function Color(props: Props): JSX.Element {
7770 < ColorPicker . Root
7871 ref = { el => ( picker = el ) }
7972 accessor = { accessor }
80- pickers = { pickers }
73+ pickers = { [
74+ new ColorPanel . TailwindVarsPickerPanel ( ) ,
75+ new ColorPanel . HSLPickerPanel ( ) ,
76+ new ColorPanel . OKLCHPickerPanel ( ) ,
77+ new ColorPanel . RGBPickerPanel ( ) ,
78+ new ColorPanel . WebSafePickerPanel ( ) ,
79+ ] }
8180 activatorClass = { styles [ 'color-activator' ] }
8281 >
8382 < IconColor />
@@ -95,7 +94,7 @@ export function BackgroundColor(props: Props): JSX.Element {
9594 const l = useLocale ( ) ;
9695
9796 const accessor = fieldAccessor < string | undefined > (
98- 'bgcolor ' ,
97+ 'backgroundColor ' ,
9998 props . editor . getAttributes ( 'textStyle' ) . backgroundColor ,
10099 ) ;
101100 let isSelectUpdate = false ; // 是否来自 selectionUpdate 事件,如果是来自该事件,不需要执行 setColor 操作
@@ -117,6 +116,8 @@ export function BackgroundColor(props: Props): JSX.Element {
117116 if ( accessor . getValue ( ) === color ) {
118117 return ;
119118 }
119+
120+ isSelectUpdate = true ;
120121 accessor . setValue ( color ) ;
121122 } ;
122123 onMount ( ( ) => props . editor . on ( 'selectionUpdate' , selectionUpdate ) ) ;
@@ -139,7 +140,13 @@ export function BackgroundColor(props: Props): JSX.Element {
139140 < ColorPicker . Root
140141 ref = { el => ( picker = el ) }
141142 accessor = { accessor }
142- pickers = { pickers }
143+ pickers = { [
144+ new ColorPanel . TailwindVarsPickerPanel ( ) ,
145+ new ColorPanel . HSLPickerPanel ( ) ,
146+ new ColorPanel . OKLCHPickerPanel ( ) ,
147+ new ColorPanel . RGBPickerPanel ( ) ,
148+ new ColorPanel . WebSafePickerPanel ( ) ,
149+ ] }
143150 activatorClass = { styles [ 'color-activator' ] }
144151 >
145152 < IconBackgroundColor />
@@ -159,7 +166,6 @@ export function LineHeight(props: Props): JSX.Element {
159166 const lh = props . editor . getAttributes ( 'textStyle' ) . lineHeight ;
160167 const accessor = fieldAccessor < number | undefined > ( 'lineHeight' , lh ? parseFloat ( lh ) : undefined ) ;
161168 accessor . onChange ( v => {
162- // TODO
163169 if ( v ) {
164170 props . editor . chain ( ) . setLineHeight ( v . toString ( ) ) . run ( ) ;
165171 } else {
0 commit comments