Skip to main content

stella_docx_kernel/projection/
container.rs

1//! Paragraph containers emitted by the current projection producer.
2
3macro_rules! paragraph_containers {
4    ($first:ident => $first_wire:literal $(, $variant:ident => $wire:literal)* $(,)?) => {
5        #[derive(Clone, Copy, Debug, Eq, PartialEq)]
6        pub enum ParagraphContainer {
7            $first,
8            $($variant,)*
9        }
10
11        #[cfg(all(target_arch = "wasm32", feature = "wasm"))]
12        impl ParagraphContainer {
13            pub(crate) const fn wire_name(self) -> &'static str {
14                match self {
15                    Self::$first => $first_wire,
16                    $(Self::$variant => $wire,)*
17                }
18            }
19        }
20
21        #[cfg(all(target_arch = "wasm32", feature = "wasm"))]
22        #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)]
23        const TYPESCRIPT_CONTAINER: &str = concat!(
24            "export type DocxProjectionContainer = ",
25            stringify!($first_wire),
26            $(" | ", stringify!($wire),)*
27            ";",
28        );
29    };
30}
31
32// Textboxes and non-body stories remain outside this projection producer.
33paragraph_containers!(Body => "body", TableCell => "tableCell");