2017-12-30 20:25:16 +00:00
import { Attributes , XmlComponent } from "file/xml-components" ;
2016-03-30 02:55:11 +01:00
2016-04-09 20:16:35 +01:00
export class NumberProperties extends XmlComponent {
2019-11-06 20:54:39 +00:00
constructor ( numberId : number | string , indentLevel : number ) {
2016-04-09 20:16:35 +01:00
super ( "w:numPr" ) ;
2017-03-07 19:14:57 +01:00
this . root . push ( new IndentLevel ( indentLevel ) ) ;
this . root . push ( new NumberId ( numberId ) ) ;
2016-03-30 02:55:11 +01:00
}
}
2016-07-17 16:28:54 +01:00
class IndentLevel extends XmlComponent {
2016-03-30 02:55:11 +01:00
constructor ( level : number ) {
2016-04-09 20:16:35 +01:00
super ( "w:ilvl" ) ;
2021-12-18 15:42:35 +00:00
if ( level > 9 ) {
2021-12-18 15:43:05 +00:00
throw new Error (
"Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7" ,
) ;
2021-12-18 15:42:35 +00:00
}
2018-01-23 01:33:12 +00:00
this . root . push (
new Attributes ( {
val : level ,
} ) ,
) ;
2016-03-30 02:55:11 +01:00
}
}
2016-07-17 16:28:54 +01:00
class NumberId extends XmlComponent {
2019-11-06 20:54:39 +00:00
constructor ( id : number | string ) {
2016-04-09 20:16:35 +01:00
super ( "w:numId" ) ;
2018-01-23 01:33:12 +00:00
this . root . push (
new Attributes ( {
2019-11-08 03:11:19 +00:00
val : typeof id === "string" ? ` { ${ id } } ` : id ,
2018-01-23 01:33:12 +00:00
} ) ,
) ;
2016-03-30 02:55:11 +01:00
}
2017-03-08 21:36:09 +00:00
}