File tree Expand file tree Collapse file tree 1 file changed +12
-23
lines changed
src/components/text-editor/prosemirror-adapter/plugins Expand file tree Collapse file tree 1 file changed +12
-23
lines changed Original file line number Diff line number Diff line change @@ -9,34 +9,23 @@ export const getTableEditingPlugins = (tablesEnabled: boolean): Plugin[] => {
99 return [ ] ;
1010} ;
1111
12+ const createStyleAttribute = ( cssProperty : string ) => ( {
13+ default : null ,
14+ getFromDOM : ( dom : HTMLElement ) => dom . style [ cssProperty ] || null ,
15+ setDOMAttr : ( value : string , attrs : Record < string , any > ) => {
16+ if ( value ) {
17+ attrs . style = ( attrs . style || '' ) + `${ cssProperty } : ${ value } ;` ;
18+ }
19+ } ,
20+ } ) ;
21+
1222export const getTableNodes = ( ) => {
1323 return tableNodes ( {
1424 tableGroup : 'block' ,
1525 cellContent : 'block+' ,
1626 cellAttributes : {
17- background : {
18- default : null ,
19- getFromDOM : ( dom ) => {
20- return dom . style . backgroundColor || null ;
21- } ,
22- setDOMAttr : ( value : string , attrs : Record < string , string > ) => {
23- if ( value ) {
24- attrs . style =
25- ( attrs . style || '' ) + `background-color: ${ value } ;` ;
26- }
27- } ,
28- } ,
29- color : {
30- default : null ,
31- getFromDOM : ( dom ) => {
32- return dom . style . color || null ;
33- } ,
34- setDOMAttr : ( value : string , attrs : Record < string , string > ) => {
35- if ( value ) {
36- attrs . style = ( attrs . style || '' ) + `color: ${ value } ;` ;
37- }
38- } ,
39- } ,
27+ background : createStyleAttribute ( 'background-color' ) ,
28+ color : createStyleAttribute ( 'color' ) ,
4029 } ,
4130 } ) ;
4231} ;
You can’t perform that action at this time.
0 commit comments