2019-12-11 07:12:22 +02:00
|
|
|
use super::*;
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
#[derive(Debug)]
|
2020-01-24 12:44:43 +02:00
|
|
|
pub struct Level(docx_rs::Level);
|
2019-12-11 07:12:22 +02:00
|
|
|
|
|
|
|
#[wasm_bindgen(js_name = createLevel)]
|
|
|
|
pub fn create_level(id: usize, start: usize, format: &str, text: &str, jc: &str) -> Level {
|
2020-01-24 12:44:43 +02:00
|
|
|
let start = docx_rs::Start::new(start);
|
|
|
|
let format = docx_rs::NumberFormat::new(format);
|
|
|
|
let text = docx_rs::LevelText::new(text);
|
|
|
|
let jc = docx_rs::LevelJc::new(jc);
|
|
|
|
Level(docx_rs::Level::new(id, start, format, text, jc))
|
2019-12-11 07:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Level {
|
2020-01-24 12:44:43 +02:00
|
|
|
pub fn take(self) -> docx_rs::Level {
|
2019-12-11 07:12:22 +02:00
|
|
|
self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
|
|
|
impl Level {
|
|
|
|
pub fn indent(
|
|
|
|
mut self,
|
2020-02-28 12:52:41 +02:00
|
|
|
left: i32,
|
2020-01-24 12:44:43 +02:00
|
|
|
special_indent_kind: Option<docx_rs::SpecialIndentKind>,
|
2020-02-28 12:52:41 +02:00
|
|
|
special_indent_size: Option<i32>,
|
2019-12-11 07:12:22 +02:00
|
|
|
) -> Self {
|
|
|
|
let special_indent = create_special_indent(special_indent_kind, special_indent_size);
|
2020-03-10 04:56:12 +02:00
|
|
|
// end and start_chars is not supported fro wasm for now.
|
|
|
|
self.0.paragraph_property =
|
|
|
|
self.0
|
|
|
|
.paragraph_property
|
|
|
|
.indent(Some(left), special_indent, None, None);
|
2019-12-11 07:12:22 +02:00
|
|
|
self
|
|
|
|
}
|
|
|
|
}
|