2023-12-29 15:03:36 -05:00
|
|
|
use serde::Deserialize;
|
2023-12-25 11:33:43 -05:00
|
|
|
use serde::Serialize;
|
|
|
|
|
2023-12-29 15:03:36 -05:00
|
|
|
use super::ast_node::WasmAstNode;
|
2023-12-25 11:33:43 -05:00
|
|
|
use super::macros::to_wasm;
|
|
|
|
use super::to_wasm::ToWasm;
|
2023-12-29 15:03:36 -05:00
|
|
|
use crate::compare::ElispFact;
|
2023-12-29 23:06:45 -05:00
|
|
|
use crate::types::CheckboxType;
|
2023-12-27 11:36:47 -05:00
|
|
|
use crate::types::PlainListItem;
|
2023-12-29 23:06:45 -05:00
|
|
|
use crate::types::PlainListItemCounter;
|
2023-12-29 23:21:30 -05:00
|
|
|
use crate::types::PlainListItemPreBlank;
|
2023-12-25 11:33:43 -05:00
|
|
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|
|
|
|
2023-12-29 15:03:36 -05:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2023-12-29 12:49:43 -05:00
|
|
|
pub struct WasmPlainListItem {
|
2023-12-29 23:06:45 -05:00
|
|
|
pub(crate) tag: Vec<WasmAstNode>,
|
|
|
|
pub(crate) bullet: String,
|
|
|
|
pub(crate) counter: Option<PlainListItemCounter>,
|
|
|
|
pub(crate) checkbox: Option<String>,
|
|
|
|
#[serde(rename = "pre-blank")]
|
2023-12-29 23:21:30 -05:00
|
|
|
pub(crate) pre_blank: PlainListItemPreBlank,
|
2023-12-25 11:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
to_wasm!(
|
2023-12-29 12:49:43 -05:00
|
|
|
WasmPlainListItem,
|
2023-12-25 11:51:39 -05:00
|
|
|
PlainListItem<'s>,
|
2023-12-25 12:32:35 -05:00
|
|
|
original,
|
2023-12-25 11:33:43 -05:00
|
|
|
wasm_context,
|
2023-12-29 15:03:36 -05:00
|
|
|
{ WasmAstNode::PlainListItem(original) },
|
2023-12-29 23:06:45 -05:00
|
|
|
{ "item".into() },
|
2023-12-25 11:33:43 -05:00
|
|
|
{
|
2023-12-29 15:03:36 -05:00
|
|
|
let children = original
|
|
|
|
.children
|
|
|
|
.iter()
|
|
|
|
.map(|child| {
|
|
|
|
child
|
|
|
|
.to_wasm(wasm_context.clone())
|
|
|
|
.map(Into::<WasmAstNode>::into)
|
|
|
|
})
|
|
|
|
.collect::<Result<Vec<_>, _>>()?;
|
|
|
|
|
|
|
|
Ok((
|
|
|
|
children,
|
|
|
|
WasmPlainListItem {
|
2023-12-29 23:06:45 -05:00
|
|
|
tag: Vec::new(),
|
|
|
|
bullet: original.bullet.to_owned(),
|
|
|
|
counter: original.counter.clone(),
|
|
|
|
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {
|
|
|
|
match checkbox_type {
|
|
|
|
CheckboxType::On => "on",
|
|
|
|
CheckboxType::Trans => "trans",
|
|
|
|
CheckboxType::Off => "off",
|
|
|
|
}
|
|
|
|
.to_owned()
|
|
|
|
}),
|
2023-12-29 23:21:30 -05:00
|
|
|
pre_blank: original.pre_blank,
|
2023-12-29 15:03:36 -05:00
|
|
|
},
|
|
|
|
))
|
2023-12-25 11:33:43 -05:00
|
|
|
}
|
|
|
|
);
|