File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/dialtone-vue/components/rich_text_editor/extensions/table Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,29 @@ const createAttribute = (name) => ({
1010 } ,
1111} ) ;
1212
13+ const createTableStyleAttribute = ( ) => {
14+ let attribute = createAttribute ( 'style' ) ;
15+ attribute . renderHTML = ( attributes ) => {
16+ if ( ! attributes [ 'style' ] ) return { } ;
17+ return { [ 'style' ] : replaceZeroWidth ( attributes [ 'style' ] ) } ;
18+ }
19+ return attribute ;
20+ } ;
21+
22+ function replaceZeroWidth ( style ) {
23+ return style . replace ( / (?< ! [ a - z - ] ) w i d t h \s * : \s * ( [ ^ ; ] + ) ; ? / gi, ( match , value ) => {
24+ return / ^ \s * 0 \s * [ a - z % ] * \s * ( ! i m p o r t a n t ) ? \s * $ / i. test ( value ) ? 'width: 100%;' : match ;
25+ } ) ;
26+ }
27+
1328export const CustomTable = Table . extend ( {
1429 addAttributes ( ) {
1530 return {
1631 ...this . parent ?. ( ) ,
1732 border : createAttribute ( 'border' ) ,
1833 cellpadding : createAttribute ( 'cellpadding' ) ,
1934 cellspacing : createAttribute ( 'cellspacing' ) ,
20- style : createAttribute ( 'style' ) ,
35+ style : createTableStyleAttribute ( ) ,
2136 } ;
2237 } ,
2338
You can’t perform that action at this time.
0 commit comments