Fixed markdown list item with block children.
This commit is contained in:
parent
1b006d4ce4
commit
27cdc0207a
|
@ -1,9 +1,5 @@
|
|||
* Review doc mentions of view-process.
|
||||
|
||||
# Markdown
|
||||
|
||||
* Does not support paragraph in list items.
|
||||
|
||||
# Documentation
|
||||
|
||||
* Add build dependencies for each operating system on the main `README.md`.
|
||||
|
|
|
@ -16,7 +16,7 @@ Unordered lists:
|
|||
|
||||
* Item 1
|
||||
|
||||
Is a paragraph item.
|
||||
A paragraph item.
|
||||
* Item 2
|
||||
* Item 3
|
||||
|
||||
|
|
|
@ -217,6 +217,9 @@ fn markdown_view_fn(md: &str) -> impl UiNode {
|
|||
}
|
||||
Tag::Item => {
|
||||
last_txt_end = '\0';
|
||||
if let Some(list) = list_info.last_mut() {
|
||||
list.block_start = blocks.len();
|
||||
}
|
||||
}
|
||||
Tag::FootnoteDefinition(_) => {
|
||||
last_txt_end = '\0';
|
||||
|
@ -327,13 +330,6 @@ fn markdown_view_fn(md: &str) -> impl UiNode {
|
|||
None => None,
|
||||
};
|
||||
|
||||
let nested_list = if list.block_start < blocks.len() {
|
||||
debug_assert_eq!(blocks.len() - list.block_start, 1);
|
||||
blocks.pop()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let bullet_args = ListItemBulletFnArgs {
|
||||
depth: depth as u32,
|
||||
num,
|
||||
|
@ -343,7 +339,7 @@ fn markdown_view_fn(md: &str) -> impl UiNode {
|
|||
list_items.push(list_item_view(ListItemFnArgs {
|
||||
bullet: bullet_args,
|
||||
items: inlines.drain(list.inline_start..).collect(),
|
||||
nested_list,
|
||||
blocks: blocks.drain(list.block_start..).collect(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,8 +137,8 @@ pub struct ListItemFnArgs {
|
|||
/// Inline items of the list item.
|
||||
pub items: UiNodeVec,
|
||||
|
||||
/// Inner list defined inside this item.
|
||||
pub nested_list: Option<BoxedUiNode>,
|
||||
/// Inner block items, paragraphs and nested lists.
|
||||
pub blocks: UiNodeVec,
|
||||
}
|
||||
|
||||
/// Arguments for a markdown image view.
|
||||
|
@ -646,46 +646,34 @@ pub fn default_list_item_bullet_fn(args: ListItemBulletFnArgs) -> impl UiNode {
|
|||
///
|
||||
/// See [`LIST_ITEM_FN_VAR`] for more details.
|
||||
pub fn default_list_item_fn(args: ListItemFnArgs) -> impl UiNode {
|
||||
let mut blocks = args.blocks;
|
||||
let mut items = args.items;
|
||||
|
||||
if items.is_empty() {
|
||||
return if let Some(inner) = args.nested_list {
|
||||
inner
|
||||
} else {
|
||||
NilUiNode.boxed()
|
||||
};
|
||||
if blocks.is_empty() {
|
||||
return NilUiNode.boxed();
|
||||
}
|
||||
} else {
|
||||
let r = if items.len() == 1 { items.remove(0) } else { Wrap!(items).boxed() };
|
||||
blocks.insert(0, r);
|
||||
}
|
||||
|
||||
let mut r = if items.len() == 1 {
|
||||
Container! {
|
||||
access_role = AccessRole::ListItem;
|
||||
grid::cell::at = grid::cell::AT_AUTO;
|
||||
child = items.remove(0);
|
||||
}
|
||||
.boxed()
|
||||
} else {
|
||||
Wrap! {
|
||||
access_role = AccessRole::ListItem;
|
||||
grid::cell::at = grid::cell::AT_AUTO;
|
||||
children = items;
|
||||
}
|
||||
.boxed()
|
||||
};
|
||||
|
||||
if let Some(inner) = args.nested_list {
|
||||
r = Stack! {
|
||||
if blocks.len() > 1 {
|
||||
Stack! {
|
||||
access_role = AccessRole::ListItem;
|
||||
grid::cell::at = grid::cell::AT_AUTO;
|
||||
direction = StackDirection::top_to_bottom();
|
||||
children = ui_vec![
|
||||
r,
|
||||
inner
|
||||
]
|
||||
children = blocks;
|
||||
}
|
||||
.boxed();
|
||||
.boxed()
|
||||
} else {
|
||||
Container! {
|
||||
access_role = AccessRole::ListItem;
|
||||
grid::cell::at = grid::cell::AT_AUTO;
|
||||
child = blocks.remove(0);
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
|
||||
r
|
||||
}
|
||||
|
||||
/// Default image view.
|
||||
|
|
|
@ -3,17 +3,17 @@
|
|||
//! The window layers is a z-order stacking panel that fills the window content area, widgets can be inserted
|
||||
//! with a *z-index* that is the [`LayerIndex`]. Layers can be anchored to a normal widget, positioned relative
|
||||
//! to it with linked visibility.
|
||||
//!
|
||||
//!
|
||||
//! The [`LAYERS`] service can be used to insert and remove layers, the example below uses it to *toggle* a
|
||||
//! an adorner positioned relative to the button that inserts and removes it.
|
||||
//!
|
||||
//!
|
||||
//! ```
|
||||
//! use zero_ui::prelude::*;
|
||||
//! # let _scope = APP.defaults();
|
||||
//!
|
||||
//!
|
||||
//! let inserted = var(false);
|
||||
//! let anchored = WidgetId::new_unique();
|
||||
//! # let _ =
|
||||
//! # let _ =
|
||||
//! Button! {
|
||||
//! on_click = hn!(inserted, |_| {
|
||||
//! if !inserted.get() {
|
||||
|
@ -33,11 +33,11 @@
|
|||
//! }
|
||||
//! # ;
|
||||
//! ```
|
||||
//!
|
||||
//! Node operations always apply to the window content first then the layers, even with parallelism enabled,
|
||||
//! this means that layers always render over the window content and that layer widgets can react to normal widget
|
||||
//!
|
||||
//! Node operations always apply to the window content first then the layers, even with parallelism enabled,
|
||||
//! this means that layers always render over the window content and that layer widgets can react to normal widget
|
||||
//! updates within the same frame.
|
||||
//!
|
||||
//!
|
||||
//! # Full API
|
||||
//!
|
||||
//! See [`zero_ui_wgt_layer`] for the full layers API.
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
//! }
|
||||
//! # ;
|
||||
//! ```
|
||||
//!
|
||||
//!
|
||||
//! # Full API
|
||||
//!
|
||||
//! See [`zero_ui_wgt_markdown`] for the full widget API.
|
||||
|
|
Loading…
Reference in New Issue