pub struct ExtensionBlock {
pub namespace: String,
pub block_type: String,
pub id: Option<String>,
pub attributes: Value,
pub children: Vec<Block>,
pub fallback: Option<Box<Block>>,
}Expand description
An extension block for unsupported or unknown block types.
When parsing a document with extension blocks (e.g., “forms:textInput”), this struct preserves the raw data so it can be:
- Passed through unchanged when saving
- Rendered using fallback content
- Processed by extension-aware applications
Fields§
§namespace: StringThe extension namespace (e.g., “forms”, “semantic”, “collaboration”).
block_type: StringThe block type within the namespace (e.g., “textInput”, “citation”).
id: Option<String>Optional unique identifier.
attributes: ValueRaw attributes from the original block.
This preserves all extension-specific properties without interpretation.
children: Vec<Block>Child blocks (if the extension is a container).
fallback: Option<Box<Block>>Fallback content for renderers that don’t support this extension.
Implementations§
Source§impl ExtensionBlock
impl ExtensionBlock
Sourcepub fn new(namespace: impl Into<String>, block_type: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>, block_type: impl Into<String>) -> Self
Create a new extension block.
Sourcepub fn parse_type(type_str: &str) -> Option<(&str, &str)>
pub fn parse_type(type_str: &str) -> Option<(&str, &str)>
Parse an extension type string like “forms:textInput” into (namespace, block_type).
Returns None if the type doesn’t contain a colon.
Sourcepub fn is_namespace(&self, namespace: &str) -> bool
pub fn is_namespace(&self, namespace: &str) -> bool
Check if this extension is from a specific namespace.
Sourcepub fn is_type(&self, namespace: &str, block_type: &str) -> bool
pub fn is_type(&self, namespace: &str, block_type: &str) -> bool
Check if this is a specific extension type.
Sourcepub fn with_attributes(self, attributes: Value) -> Self
pub fn with_attributes(self, attributes: Value) -> Self
Set the attributes.
Sourcepub fn with_children(self, children: Vec<Block>) -> Self
pub fn with_children(self, children: Vec<Block>) -> Self
Set the children.
Sourcepub fn with_fallback(self, fallback: Block) -> Self
pub fn with_fallback(self, fallback: Block) -> Self
Set fallback content.
Sourcepub fn fallback_content(&self) -> Option<&Block>
pub fn fallback_content(&self) -> Option<&Block>
Get the fallback content, if any.
Sourcepub fn get_attribute(&self, key: &str) -> Option<&Value>
pub fn get_attribute(&self, key: &str) -> Option<&Value>
Get an attribute value by key.
Sourcepub fn get_string_attribute(&self, key: &str) -> Option<&str>
pub fn get_string_attribute(&self, key: &str) -> Option<&str>
Get a string attribute.
Sourcepub fn get_string_array_attribute(&self, key: &str) -> Option<Vec<&str>>
pub fn get_string_array_attribute(&self, key: &str) -> Option<Vec<&str>>
Get an array-of-strings attribute.
Sourcepub fn get_bool_attribute(&self, key: &str) -> Option<bool>
pub fn get_bool_attribute(&self, key: &str) -> Option<bool>
Get a boolean attribute.
Sourcepub fn get_i64_attribute(&self, key: &str) -> Option<i64>
pub fn get_i64_attribute(&self, key: &str) -> Option<i64>
Get an integer attribute.
Sourcepub fn as_form_field(&self) -> Option<FormField>
pub fn as_form_field(&self) -> Option<FormField>
Try to convert this extension block to a specific form field type.
Returns None if this is not a forms extension or conversion fails.
Trait Implementations§
Source§impl Clone for ExtensionBlock
impl Clone for ExtensionBlock
Source§fn clone(&self) -> ExtensionBlock
fn clone(&self) -> ExtensionBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more