@@ -32,6 +32,61 @@ export default class ModifyTextHelper {
3232 }
3333 } ;
3434
35+ static setBulletList =
36+ ( list ) => ( element : XmlElement ) : void => {
37+ const namespaceURIs = {
38+ 'a' : 'http://schemas.openxmlformats.org/drawingml/2006/main' ,
39+ 'p' : 'http://schemas.openxmlformats.org/presentationml/2006/main'
40+ } ;
41+ const doc = element . ownerDocument ;
42+
43+ let txBody = element . getElementsByTagName ( 'p:txBody' ) [ 0 ] ;
44+ if ( ! txBody ) {
45+ txBody = doc . createElementNS ( namespaceURIs [ 'p' ] , 'p:txBody' ) ;
46+ element . appendChild ( txBody ) ;
47+ } else {
48+ while ( txBody . firstChild ) {
49+ txBody . removeChild ( txBody . firstChild ) ;
50+ }
51+ }
52+
53+ const bodyPr = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:bodyPr' ) ;
54+ txBody . appendChild ( bodyPr ) ;
55+ const lstStyle = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:lstStyle' ) ;
56+ txBody . appendChild ( lstStyle ) ;
57+
58+ const processList = ( items , level ) => {
59+ items . forEach ( ( item ) => {
60+ if ( Array . isArray ( item ) ) {
61+ processList ( item , level + 1 ) ;
62+ } else {
63+ const p = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:p' ) ;
64+
65+ const pPr = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:pPr' ) ;
66+ if ( level > 0 ) {
67+ pPr . setAttribute ( 'lvl' , String ( level ) ) ;
68+ }
69+ p . appendChild ( pPr ) ;
70+
71+ const r = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:r' ) ;
72+
73+ const rPr = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:rPr' ) ;
74+ r . appendChild ( rPr ) ;
75+
76+ const t = doc . createElementNS ( namespaceURIs [ 'a' ] , 'a:t' ) ;
77+ const textNode = doc . createTextNode ( String ( item ) ) ;
78+ t . appendChild ( textNode ) ;
79+
80+ r . appendChild ( t ) ;
81+ p . appendChild ( r ) ;
82+ txBody . appendChild ( p ) ;
83+ }
84+ } ) ;
85+ } ;
86+
87+ processList ( list , 0 ) ;
88+ } ;
89+
3590 static content =
3691 ( label : number | string ) =>
3792 ( element : XmlElement ) : void => {
@@ -41,7 +96,7 @@ export default class ModifyTextHelper {
4196 } ;
4297
4398 /**
44- * Set text style insinde an <a:rPr> element
99+ * Set text style inside an <a:rPr> element
45100 */
46101 static style =
47102 ( style : TextStyle ) =>
@@ -71,7 +126,7 @@ export default class ModifyTextHelper {
71126 } ;
72127
73128 /**
74- * Set size of text insinde an <a:rPr> element
129+ * Set size of text inside an <a:rPr> element
75130 */
76131 static setSize =
77132 ( size : number ) =>
0 commit comments