perf(native-ui): optimize database sort, image cache, icons, and web host

Extract database sort keys once per row and sort row indices with stable merge sort.
This keeps multi-column order, empty-tail placement, NFD collation, and linked page title resolution.

Add MoveLeftIcon, MoveRightIcon, and InvisibleIcon to ui-tokens and keep only static SVG strings in IconDef.
Use IconPaint::from_def in database column menus to fix blank icons and remove runtime lock lookups.

Clear stale active-page directory snapshots instead of cloning the active PageSnapshot in PlaygroundView::refresh_document.
Encapsulate image cache mutations in ImageStore with bounded Undo LRU and deferred cross-frame window.drop_image cleanup.
Defer Apple Metal atlas tile deallocation until in-flight MTLCommandBuffer submissions complete and remove unused ui helpers.

Share cached syntax highlight lines with Arc<[HighlightedLine]> and evict stale entries with LRU.
Remove unused render_breadcrumb_bar and BreadcrumbVisualStyle from ui-kit.

Move CRDT append projection into wasm_crdt_core with single-pass block ID checks and a delta-only path.
Surface durable openDoc errors in default-app-entry and clone returned snapshots in host.js.
Scan covered IndexedDB keys with openKeyCursor and use logical CSS properties in sign-in.html.
This commit is contained in:
DarkSky committed 2026-11-30 18:59:52 +09:00
1 parent c02056c82d
commit 4b3c175aba
33 files changed
+2646 -1214

No files matched your search

@@ -135,7 +135,7 @@ pub(super) fn render_calendar_day_controls(
});
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(plus_rect.x + 3.0, plus_rect.y + 3.0, 12.0, 12.0),
icon: crate::theme::IconPaint::named("PlusIcon"),
icon: crate::theme::IconPaint::from_def(&ui_tokens::icons::PLUS),
color: ctx.palette.brand,
});
authoring_hits.push(DatabaseAuthoringHit {
@@ -435,7 +435,7 @@ pub(super) fn render_select_popover_at(
if is_selected {
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(row_rect.right() - 42.0, row_rect.y + 7.0, 14.0, 14.0),
icon: IconPaint::named("CheckBoxCheckLinearIcon"),
icon: IconPaint::from_def(&ui_tokens::icons::CHECKBOX_CHECKED_LINEAR),
color: ctx.palette.brand,
});
}
@@ -406,14 +406,14 @@ pub(super) fn render_column_menu_at(
});
}
}
let icon_name = match tag {
"ToggleTypeSubmenu" => column_icon_name(current_type),
"InsertLeft" | "InsertRight" => "PlusIcon",
"MoveLeft" => "ArrowLeftSmallIcon",
"MoveRight" => "ArrowRightSmallIcon",
"Hide" => "InvisibleIcon",
"Delete" => "DeleteIcon",
_ => "SquareIcon",
let icon = match tag {
"ToggleTypeSubmenu" => IconPaint::named(column_icon_name(current_type)),
"InsertLeft" | "InsertRight" => IconPaint::from_def(&ui_tokens::icons::PLUS),
"MoveLeft" => IconPaint::from_def(&ui_tokens::icons::MOVE_LEFT),
"MoveRight" => IconPaint::from_def(&ui_tokens::icons::MOVE_RIGHT),
"Hide" => IconPaint::from_def(&ui_tokens::icons::INVISIBLE),
"Delete" => IconPaint::from_def(&ui_tokens::icons::DELETE),
_ => IconPaint::from_def(&ui_tokens::icons::SQUARE),
};
let ink = if is_danger {
ctx.theme
@@ -424,7 +424,7 @@ pub(super) fn render_column_menu_at(
};
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(row_rect.x + 6.0, row_rect.y + 7.0, 14.0, 14.0),
icon: IconPaint::named(icon_name),
icon,
color: if is_danger { ink } else { ctx.palette.icon },
});
let label_w = if tag == "ToggleTypeSubmenu" {
@@ -601,3 +601,31 @@ pub(super) fn render_table_select_pills(
px_cursor += pill_w + 4.0;
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn column_menu_move_and_hide_icons_are_non_empty_valid_svgs() {
let icons = [
(
"MoveLeft",
IconPaint::from_def(&ui_tokens::icons::MOVE_LEFT),
),
(
"MoveRight",
IconPaint::from_def(&ui_tokens::icons::MOVE_RIGHT),
),
("Hide", IconPaint::from_def(&ui_tokens::icons::INVISIBLE)),
];
for (action, icon) in icons {
let svg = icon.svg_str();
assert!(!svg.is_empty(), "{action} icon svg must not be empty");
assert!(svg.starts_with("<svg "), "{action} svg: {svg}");
assert!(svg.ends_with("</svg>"), "{action} svg: {svg}");
assert!(svg.contains("<path "), "{action} svg missing path: {svg}");
assert!(!svg.contains("currentColor"), "{action} svg: {svg}");
}
}
}
+17 -11
View File
@@ -19,6 +19,7 @@ mod render_kanban;
mod render_kanban_card;
mod render_table;
mod render_types;
mod sort_key;
use std::collections::{BTreeSet, HashMap};
@@ -438,17 +439,22 @@ pub fn filter_and_sort_view_rows(
data: &blocksuite_playground_doc::read::DatabaseData,
page_titles: &std::collections::BTreeMap<String, String>,
) -> Vec<blocksuite_playground_doc::read::DatabaseRow> {
let filtered: Vec<blocksuite_playground_doc::read::DatabaseRow> = data
.rows
.iter()
.filter(|row| {
view.filter
.as_ref()
.is_none_or(|f| eval_database_filter_with_titles(f, data, row, page_titles))
})
.cloned()
.collect();
sort_database_rows_with_titles(&filtered, view.sort.as_ref(), data, page_titles)
let sort_rules = sort_key::parse_active_sort_rules(view.sort.as_ref());
if view.filter.is_none() && sort_rules.is_empty() {
return data.rows.clone();
}
let filtered: Vec<&blocksuite_playground_doc::read::DatabaseRow> = match view.filter.as_ref() {
Some(f) => data
.rows
.iter()
.filter(|row| eval_database_filter_with_titles(f, data, row, page_titles))
.collect(),
None => data.rows.iter().collect(),
};
if sort_rules.is_empty() {
return filtered.into_iter().cloned().collect();
}
sort_key::sort_row_refs_with_rules(&filtered, &sort_rules, data, page_titles)
}
/// Resolve `(group_by, visible_buckets, full_unfiltered_buckets)` for `view` from the single
+13 -281
View File
@@ -1,12 +1,15 @@
//! Pure Filter and Sort evaluation for `affine:database` views, aligned with
//! `0.27.5` `core/filter/filter-fn/*.ts` and `core/sort/eval.ts`.
use std::{cmp::Ordering, collections::BTreeMap};
use std::collections::BTreeMap;
use blocksuite_playground_doc::read::{DatabaseCellValue, DatabaseData, DatabaseRow};
use serde_json::Value as JsonValue;
use super::resolve_rich_text_query;
use super::{
resolve_rich_text_query,
sort_key::{parse_active_sort_rules, sort_row_refs_with_rules},
};
#[cfg(test)]
pub(crate) fn eval_database_filter(
@@ -261,286 +264,12 @@ pub fn sort_database_rows_with_titles(
data: &DatabaseData,
page_titles: &BTreeMap<String, String>,
) -> Vec<DatabaseRow> {
let mut out = rows.to_vec();
let Some(rules) = sort
.and_then(|s| s.get("sortBy"))
.and_then(JsonValue::as_array)
.filter(|list| !list.is_empty())
else {
return out;
};
let parsed: Vec<(&str, bool)> = rules
.iter()
.filter_map(|rule| {
let col_id = rule
.get("ref")
.and_then(|r| r.get("name"))
.and_then(JsonValue::as_str)?;
let desc = rule
.get("desc")
.and_then(JsonValue::as_bool)
.unwrap_or(false);
Some((col_id, desc))
})
.collect();
if parsed.is_empty() {
return out;
let rules = parse_active_sort_rules(sort);
if rows.len() < 2 || rules.is_empty() {
return rows.to_vec();
}
stable_merge_sort(&mut out, |a, b| {
for &(col_id, desc) in &parsed {
let ord = compare_row_cells_with_direction(data, a, b, col_id, desc, page_titles);
if ord != Ordering::Equal {
return ord;
}
}
Ordering::Equal
});
out
}
/// Deterministic stable merge sort mirroring ECMAScript `Array.prototype.sort` (never panicking
/// under Rust `slice::sort_by` strict-weak-order checks when `0.27.5` `compareList` returns `0`
/// on matching shorter dot-separated prefixes).
fn stable_merge_sort<T: Clone>(items: &mut [T], mut cmp: impl FnMut(&T, &T) -> Ordering) {
let n = items.len();
if n < 2 {
return;
}
let mut buf = items.to_vec();
let mut width = 1_usize;
while width < n {
let mut left = 0_usize;
while left < n {
let mid = (left + width).min(n);
let right = (left + 2 * width).min(n);
let (mut i, mut j, mut k) = (left, mid, left);
while i < mid && j < right {
if cmp(&items[i], &items[j]) != Ordering::Greater {
buf[k] = items[i].clone();
i += 1;
} else {
buf[k] = items[j].clone();
j += 1;
}
k += 1;
}
while i < mid {
buf[k] = items[i].clone();
i += 1;
k += 1;
}
while j < right {
buf[k] = items[j].clone();
j += 1;
k += 1;
}
left += 2 * width;
}
items.clone_from_slice(&buf);
width *= 2;
}
}
fn compare_row_cells_with_direction(
data: &DatabaseData,
a: &DatabaseRow,
b: &DatabaseRow,
col_id: &str,
desc: bool,
page_titles: &BTreeMap<String, String>,
) -> Ordering {
let col = data.columns.iter().find(|c| c.id == col_id);
let col_type = if col_id == "title" {
"title"
} else {
col.map_or("rich-text", |c| c.column_type.as_str())
};
let va = data.cells.get(&(a.row_id.clone(), col_id.to_string()));
let vb = data.cells.get(&(b.row_id.clone(), col_id.to_string()));
let ord_opt: Option<Ordering> = match col_type {
"number" | "progress" | "date" => compare_option_values(
va.and_then(DatabaseCellValue::as_f64),
vb.and_then(DatabaseCellValue::as_f64),
|x, y| x.total_cmp(&y),
desc,
),
"created-time" => {
let na = va
.and_then(DatabaseCellValue::as_f64)
.or(a.created_at.map(|ms| ms as f64));
let nb = vb
.and_then(DatabaseCellValue::as_f64)
.or(b.created_at.map(|ms| ms as f64));
compare_option_values(na, nb, |x, y| x.total_cmp(&y), desc)
}
"checkbox" => {
let ba = va.and_then(DatabaseCellValue::as_bool).unwrap_or(false);
let bb = vb.and_then(DatabaseCellValue::as_bool).unwrap_or(false);
let ord = (ba as u8).cmp(&(bb as u8));
Some(if desc { ord.reverse() } else { ord })
}
"select" => {
let sa = va.and_then(|v| match v {
DatabaseCellValue::Text(s) if !s.is_empty() => Some(s.as_str()),
_ => None,
});
let sb = vb.and_then(|v| match v {
DatabaseCellValue::Text(s) if !s.is_empty() => Some(s.as_str()),
_ => None,
});
let options = col.map(|c| c.select_options()).unwrap_or_default();
let idx = |id: &str| {
options
.iter()
.position(|o| o.id == id)
.map_or(-1_isize, |i| i as isize)
};
compare_option_values(sa, sb, |x, y| idx(x).cmp(&idx(y)), desc)
}
"multi-select" => {
let la = va
.map(DatabaseCellValue::as_string_list)
.filter(|v| !v.is_empty());
let lb = vb
.map(DatabaseCellValue::as_string_list)
.filter(|v| !v.is_empty());
let options = col.map(|c| c.select_options()).unwrap_or_default();
let idx = |id: &str| {
options
.iter()
.position(|o| o.id == id)
.map_or(-1_isize, |i| i as isize)
};
compare_option_values(
la,
lb,
|x, y| {
for (xi, yi) in x.iter().zip(y.iter()) {
let o = idx(xi).cmp(&idx(yi));
if o != Ordering::Equal {
return o;
}
}
x.len().cmp(&y.len())
},
desc,
)
}
_ => {
let ta = row_cell_text_with_titles(data, a, col_id, page_titles);
let tb = row_cell_text_with_titles(data, b, col_id, page_titles);
compare_option_values(
(!ta.is_empty()).then_some(ta),
(!tb.is_empty()).then_some(tb),
|x, y| compare_sort_string(&x, &y),
desc,
)
}
};
ord_opt.unwrap_or(Ordering::Equal)
}
fn compare_option_values<T>(
a: Option<T>,
b: Option<T>,
cmp: impl FnOnce(T, T) -> Ordering,
desc: bool,
) -> Option<Ordering> {
match (a, b) {
(None, None) => Some(Ordering::Equal),
(None, Some(_)) => Some(Ordering::Greater),
(Some(_), None) => Some(Ordering::Less),
(Some(va), Some(vb)) => {
let ord = cmp(va, vb);
Some(if desc { ord.reverse() } else { ord })
}
}
}
/// Aligns with `0.27.5` `core/sort/eval.ts` `compareString` & `compareList`:
/// dot-separated segments, lowercase, JS `Number.parseInt(low)` prefix integers
/// (including `0x`/`0X` hex prefixes) sort before non-numeric segments, NFD canonical
/// base-before-diacritic collation aligns `"École"` == `"E\u{0301}cole"` and `"École"` < `"Zulu"`,
/// and matching shorter prefixes return `Ordering::Equal` (`compareList` line 48).
fn compare_sort_string(a: &str, b: &str) -> Ordering {
for (sa, sb) in a.split('.').zip(b.split('.')) {
let la = sa.to_lowercase();
let lb = sb.to_lowercase();
let ord = match (js_parse_int_prefix(&la), js_parse_int_prefix(&lb)) {
(Some(na), Some(nb)) => na
.total_cmp(&nb)
.then_with(|| compare_nfd_collation(&la, &lb)),
(Some(_), None) => Ordering::Less,
(None, Some(_)) => Ordering::Greater,
(None, None) => compare_nfd_collation(&la, &lb),
};
if ord != Ordering::Equal {
return ord;
}
}
Ordering::Equal
}
fn is_combining_diacritic(ch: char) -> bool {
matches!(
ch as u32,
0x0300..=0x036F
| 0x1AB0..=0x1AFF
| 0x1DC0..=0x1DFF
| 0x20D0..=0x20FF
| 0xFE20..=0xFE2F
)
}
fn compare_nfd_collation(la: &str, lb: &str) -> Ordering {
use unicode_normalization::UnicodeNormalization as _;
let primary = la
.nfd()
.filter(|&c| !is_combining_diacritic(c))
.cmp(lb.nfd().filter(|&c| !is_combining_diacritic(c)));
if primary != Ordering::Equal {
return primary;
}
la.nfd().cmp(lb.nfd())
}
fn js_parse_int_prefix(s: &str) -> Option<f64> {
let trimmed = s.trim_start();
let bytes = trimmed.as_bytes();
if bytes.is_empty() {
return None;
}
let (sign, mut i) = match bytes[0] {
b'-' => (-1.0_f64, 1_usize),
b'+' => (1.0_f64, 1_usize),
_ => (1.0_f64, 0_usize),
};
let (radix, digit_pred): (f64, fn(u8) -> Option<u8>) =
if i + 2 <= bytes.len() && bytes[i] == b'0' && matches!(bytes[i + 1], b'x' | b'X') {
i += 2;
(16.0, |b| match b {
b'0'..=b'9' => Some(b - b'0'),
b'a'..=b'f' => Some(b - b'a' + 10),
b'A'..=b'F' => Some(b - b'A' + 10),
_ => None,
})
} else {
(10.0, |b| b.is_ascii_digit().then(|| b - b'0'))
};
let start = i;
let mut acc = 0.0_f64;
while i < bytes.len() {
let Some(d) = digit_pred(bytes[i]) else {
break;
};
acc = acc * radix + f64::from(d);
i += 1;
}
if i == start {
return None;
}
Some(if acc == 0.0 { 0.0 } else { sign * acc })
let refs: Vec<&DatabaseRow> = rows.iter().collect();
sort_row_refs_with_rules(&refs, &rules, data, page_titles)
}
pub(super) fn row_cell_text_with_titles(
@@ -571,7 +300,10 @@ pub(super) fn row_cell_text_with_titles(
#[cfg(test)]
mod tests {
use std::cmp::Ordering;
use super::*;
use crate::database::sort_key::compare_sort_string;
use blocksuite_playground_doc::read::{DatabaseColumn, RichText};
use serde_json::json;
use std::collections::BTreeMap;
@@ -218,7 +218,7 @@ pub(super) fn render_kanban_view(
let plus_rect = FlowRect::new(plus_x, cy + 1.0, 20.0, 20.0);
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(plus_rect.x + 3.0, plus_rect.y + 3.0, 14.0, 14.0),
icon: IconPaint::named("PlusIcon"),
icon: IconPaint::from_def(&ui_tokens::icons::PLUS),
color: ctx.palette.icon,
});
authoring_hits.push(DatabaseAuthoringHit {
@@ -274,7 +274,7 @@ pub(super) fn render_kanban_view(
};
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(icon_x, add_rect.y + 7.0, 14.0, 14.0),
icon: IconPaint::named("PlusIcon"),
icon: IconPaint::from_def(&ui_tokens::icons::PLUS),
color: ctx.palette.icon,
});
let text_x = if ctx.direction.is_rtl() {
@@ -168,7 +168,7 @@ pub(super) fn render_table_view(
let add_col_rect = FlowRect::new(col_x, y, add_col_w, HEADER_HEIGHT);
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(add_col_rect.x + 10.0, add_col_rect.y + 10.0, 14.0, 14.0),
icon: IconPaint::named("PlusIcon"),
icon: IconPaint::from_def(&ui_tokens::icons::PLUS),
color: ctx.palette.icon,
});
authoring_hits.push(DatabaseAuthoringHit {
@@ -535,10 +535,10 @@ fn render_table_row(
};
prims.push(DatabasePrim::Icon {
rect: FlowRect::new(box_x, cell_rect.y + 8.0, 18.0, 18.0),
icon: IconPaint::named(if checked {
"CheckBoxCheckSolidIcon"
icon: IconPaint::from_def(if checked {
&ui_tokens::icons::CHECKBOX_CHECKED_SOLID
} else {
"CheckBoxUnIcon"
&ui_tokens::icons::CHECKBOX_UNCHECKED
}),
color: if checked {
ctx.palette.brand
@@ -0,0 +1,754 @@
//! Single-pass typed sort-key extraction and stable index merge sort for `affine:database`
//! views, aligned with `0.27.5` `core/sort/eval.ts`.
use std::{
cmp::Ordering,
collections::{BTreeMap, HashMap},
};
use blocksuite_playground_doc::read::{DatabaseCellValue, DatabaseData, DatabaseRow};
use serde_json::Value as JsonValue;
use super::query::row_cell_text_with_titles;
/// One parsed `sortBy` rule referencing a column id and direction.
#[derive(Clone, Copy, Debug)]
pub(super) struct ParsedSortRule<'a> {
pub col_id: &'a str,
pub desc: bool,
}
/// Extract active `(col_id, desc)` sort rules from a BlockSuite `view.sort` JSON object.
pub(super) fn parse_active_sort_rules(sort: Option<&JsonValue>) -> Vec<ParsedSortRule<'_>> {
let Some(rules) = sort
.and_then(|s| s.get("sortBy"))
.and_then(JsonValue::as_array)
.filter(|list| !list.is_empty())
else {
return Vec::new();
};
rules
.iter()
.filter_map(|rule| {
let col_id = rule
.get("ref")
.and_then(|r| r.get("name"))
.and_then(JsonValue::as_str)?;
let desc = rule
.get("desc")
.and_then(JsonValue::as_bool)
.unwrap_or(false);
Some(ParsedSortRule { col_id, desc })
})
.collect()
}
#[derive(Debug)]
struct TextSegmentKey {
num_prefix: Option<f64>,
nfd_primary: String,
nfd_full: Option<String>,
}
/// Pre-extracted column sort keys for one active sort rule across all candidate rows.
enum SortColumnKeys {
Number(Vec<Option<f64>>),
Bool(Vec<bool>),
Select(Vec<Option<isize>>),
MultiSelect(Vec<Option<Vec<isize>>>),
Text(Vec<Option<Vec<TextSegmentKey>>>),
}
impl SortColumnKeys {
fn extract(
rows: &[&DatabaseRow],
col_id: &str,
data: &DatabaseData,
page_titles: &BTreeMap<String, String>,
) -> Self {
let col = data.columns.iter().find(|c| c.id == col_id);
let col_type = if col_id == "title" {
"title"
} else {
col.map_or("rich-text", |c| c.column_type.as_str())
};
let mut cell_key = (String::new(), col_id.to_string());
match col_type {
"number" | "progress" | "date" => {
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
cell_key.0.clear();
cell_key.0.push_str(&row.row_id);
keys.push(
data.cells
.get(&cell_key)
.and_then(DatabaseCellValue::as_f64),
);
}
Self::Number(keys)
}
"created-time" => {
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
cell_key.0.clear();
cell_key.0.push_str(&row.row_id);
let val = data
.cells
.get(&cell_key)
.and_then(DatabaseCellValue::as_f64)
.or(row.created_at.map(|ms| ms as f64));
keys.push(val);
}
Self::Number(keys)
}
"checkbox" => {
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
cell_key.0.clear();
cell_key.0.push_str(&row.row_id);
keys.push(
data.cells
.get(&cell_key)
.and_then(DatabaseCellValue::as_bool)
.unwrap_or(false),
);
}
Self::Bool(keys)
}
"select" => {
let options = col.map(|c| c.select_options()).unwrap_or_default();
let mut opt_idx: HashMap<&str, isize> = HashMap::with_capacity(options.len());
for (i, opt) in options.iter().enumerate() {
opt_idx.entry(opt.id.as_str()).or_insert(i as isize);
}
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
cell_key.0.clear();
cell_key.0.push_str(&row.row_id);
let val = data.cells.get(&cell_key).and_then(|v| match v {
DatabaseCellValue::Text(s) if !s.is_empty() => {
Some(opt_idx.get(s.as_str()).copied().unwrap_or(-1))
}
_ => None,
});
keys.push(val);
}
Self::Select(keys)
}
"multi-select" => {
let options = col.map(|c| c.select_options()).unwrap_or_default();
let mut opt_idx: HashMap<&str, isize> = HashMap::with_capacity(options.len());
for (i, opt) in options.iter().enumerate() {
opt_idx.entry(opt.id.as_str()).or_insert(i as isize);
}
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
cell_key.0.clear();
cell_key.0.push_str(&row.row_id);
let val = data
.cells
.get(&cell_key)
.map(DatabaseCellValue::as_string_list)
.filter(|list| !list.is_empty())
.map(|list| {
list.iter()
.map(|id| opt_idx.get(id.as_str()).copied().unwrap_or(-1))
.collect()
});
keys.push(val);
}
Self::MultiSelect(keys)
}
_ => {
let mut keys = Vec::with_capacity(rows.len());
for row in rows {
let text = row_cell_text_with_titles(data, row, col_id, page_titles);
let val = (!text.is_empty()).then(|| extract_text_segments(&text));
keys.push(val);
}
Self::Text(keys)
}
}
}
#[inline]
fn compare(&self, i: usize, j: usize, desc: bool) -> Ordering {
match self {
Self::Number(vals) => {
compare_option_values(vals[i], vals[j], |x, y| x.total_cmp(&y), desc)
}
Self::Bool(vals) => {
let ord = (vals[i] as u8).cmp(&(vals[j] as u8));
if desc { ord.reverse() } else { ord }
}
Self::Select(vals) => compare_option_values(vals[i], vals[j], |x, y| x.cmp(&y), desc),
Self::MultiSelect(vals) => {
compare_option_values(vals[i].as_deref(), vals[j].as_deref(), Ord::cmp, desc)
}
Self::Text(vals) => compare_option_values(
vals[i].as_deref(),
vals[j].as_deref(),
compare_text_segments,
desc,
),
}
}
}
/// Sort `rows` by `rules` using single-pass typed key extraction and deterministic
/// stable index merge sort, materializing each surviving `DatabaseRow` once.
pub(super) fn sort_row_refs_with_rules(
rows: &[&DatabaseRow],
rules: &[ParsedSortRule<'_>],
data: &DatabaseData,
page_titles: &BTreeMap<String, String>,
) -> Vec<DatabaseRow> {
if rows.len() < 2 || rules.is_empty() {
return rows.iter().map(|&r| r.clone()).collect();
}
let columns: Vec<(SortColumnKeys, bool)> = rules
.iter()
.map(|rule| {
(
SortColumnKeys::extract(rows, rule.col_id, data, page_titles),
rule.desc,
)
})
.collect();
let indices = stable_merge_sort_indices(rows.len(), |a, b| {
for (keys, desc) in &columns {
let ord = keys.compare(a, b, *desc);
if ord != Ordering::Equal {
return ord;
}
}
Ordering::Equal
});
indices.into_iter().map(|idx| rows[idx].clone()).collect()
}
/// Deterministic stable merge sort over row indices `0..n` mirroring ECMAScript
/// `Array.prototype.sort` (never panicking under Rust `slice::sort_by` strict-weak-order
/// checks when `0.27.5` `compareList` returns `0` on matching shorter dot-separated prefixes).
fn stable_merge_sort_indices(
n: usize,
mut cmp: impl FnMut(usize, usize) -> Ordering,
) -> Vec<usize> {
let mut items: Vec<usize> = (0..n).collect();
if n < 2 {
return items;
}
let mut buf = vec![0_usize; n];
let mut width = 1_usize;
while width < n {
let mut left = 0_usize;
while left < n {
let mid = (left + width).min(n);
let right = (left + 2 * width).min(n);
let (mut i, mut j, mut k) = (left, mid, left);
while i < mid && j < right {
if cmp(items[i], items[j]) != Ordering::Greater {
buf[k] = items[i];
i += 1;
} else {
buf[k] = items[j];
j += 1;
}
k += 1;
}
if i < mid {
let rem = mid - i;
buf[k..k + rem].copy_from_slice(&items[i..mid]);
k += rem;
}
if j < right {
let rem = right - j;
buf[k..k + rem].copy_from_slice(&items[j..right]);
}
left += 2 * width;
}
std::mem::swap(&mut items, &mut buf);
width *= 2;
}
items
}
#[inline]
fn compare_option_values<T>(
a: Option<T>,
b: Option<T>,
cmp: impl FnOnce(T, T) -> Ordering,
desc: bool,
) -> Ordering {
match (a, b) {
(None, None) => Ordering::Equal,
(None, Some(_)) => Ordering::Greater,
(Some(_), None) => Ordering::Less,
(Some(va), Some(vb)) => {
let ord = cmp(va, vb);
if desc { ord.reverse() } else { ord }
}
}
}
/// Aligns with `0.27.5` `core/sort/eval.ts` `compareString` & `compareList`:
/// dot-separated segments, lowercase, JS `Number.parseInt(low)` prefix integers
/// (including `0x`/`0X` hex prefixes) sort before non-numeric segments, NFD canonical
/// base-before-diacritic collation aligns `"École"` == `"E\u{0301}cole"` and `"École"` < `"Zulu"`,
/// and matching shorter prefixes return `Ordering::Equal` (`compareList` line 48).
fn extract_text_segments(text: &str) -> Vec<TextSegmentKey> {
use unicode_normalization::UnicodeNormalization as _;
text.split('.')
.map(|seg| {
let low = seg.to_lowercase();
let num_prefix = js_parse_int_prefix(&low);
if low.is_ascii() {
TextSegmentKey {
num_prefix,
nfd_primary: low,
nfd_full: None,
}
} else {
let full: String = low.nfd().collect();
let primary: String = full
.chars()
.filter(|&c| !is_combining_diacritic(c))
.collect();
let nfd_full = (full != primary).then_some(full);
TextSegmentKey {
num_prefix,
nfd_primary: primary,
nfd_full,
}
}
})
.collect()
}
#[inline]
fn compare_text_segments(a: &[TextSegmentKey], b: &[TextSegmentKey]) -> Ordering {
for (sa, sb) in a.iter().zip(b.iter()) {
let ord = match (sa.num_prefix, sb.num_prefix) {
(Some(na), Some(nb)) => na.total_cmp(&nb).then_with(|| compare_nfd_segment(sa, sb)),
(Some(_), None) => Ordering::Less,
(None, Some(_)) => Ordering::Greater,
(None, None) => compare_nfd_segment(sa, sb),
};
if ord != Ordering::Equal {
return ord;
}
}
Ordering::Equal
}
#[inline]
fn compare_nfd_segment(a: &TextSegmentKey, b: &TextSegmentKey) -> Ordering {
a.nfd_primary.cmp(&b.nfd_primary).then_with(|| {
a.nfd_full
.as_deref()
.unwrap_or(&a.nfd_primary)
.cmp(b.nfd_full.as_deref().unwrap_or(&b.nfd_primary))
})
}
fn is_combining_diacritic(ch: char) -> bool {
matches!(
ch as u32,
0x0300..=0x036F
| 0x1AB0..=0x1AFF
| 0x1DC0..=0x1DFF
| 0x20D0..=0x20FF
| 0xFE20..=0xFE2F
)
}
fn js_parse_int_prefix(s: &str) -> Option<f64> {
let trimmed = s.trim_start();
let bytes = trimmed.as_bytes();
if bytes.is_empty() {
return None;
}
let (sign, mut i) = match bytes[0] {
b'-' => (-1.0_f64, 1_usize),
b'+' => (1.0_f64, 1_usize),
_ => (1.0_f64, 0_usize),
};
let (radix, digit_pred): (f64, fn(u8) -> Option<u8>) =
if i + 2 <= bytes.len() && bytes[i] == b'0' && matches!(bytes[i + 1], b'x' | b'X') {
i += 2;
(16.0, |b| match b {
b'0'..=b'9' => Some(b - b'0'),
b'a'..=b'f' => Some(b - b'a' + 10),
b'A'..=b'F' => Some(b - b'A' + 10),
_ => None,
})
} else {
(10.0, |b| b.is_ascii_digit().then(|| b - b'0'))
};
let start = i;
let mut acc = 0.0_f64;
while i < bytes.len() {
let Some(d) = digit_pred(bytes[i]) else {
break;
};
acc = acc * radix + f64::from(d);
i += 1;
}
if i == start {
return None;
}
Some(if acc == 0.0 { 0.0 } else { sign * acc })
}
#[cfg(test)]
pub(super) fn compare_sort_string(a: &str, b: &str) -> Ordering {
let ka = extract_text_segments(a);
let kb = extract_text_segments(b);
compare_text_segments(&ka, &kb)
}
#[cfg(test)]
mod tests {
use std::collections::BTreeMap;
use blocksuite_playground_doc::read::{
DatabaseCellValue, DatabaseColumn, DatabaseData, DatabaseGroupBy, DatabaseGroupProperty,
DatabaseRow, DatabaseView, DatabaseViewMode, RichText,
};
use serde_json::json;
use crate::database::{filter_and_sort_view_rows, group_view_rows_with_titles};
fn rt(plain: &str) -> RichText {
RichText {
plain: plain.into(),
delta: vec![],
}
}
fn linked_rt(page_id: &str) -> RichText {
let mut m = y_octo::AHashMap::default();
m.insert("type".to_string(), y_octo::Any::String("LinkedPage".into()));
m.insert("pageId".to_string(), y_octo::Any::String(page_id.into()));
let mut fmt = BTreeMap::new();
fmt.insert("reference".to_string(), y_octo::Any::Object(Box::new(m)));
RichText {
plain: " ".into(),
delta: vec![y_octo::TextDeltaOp::Insert {
insert: y_octo::TextInsert::Text(" ".into()),
format: Some(fmt),
}],
}
}
#[test]
fn sort_key_table_driven_semantics_multi_col_empty_tail_nfd_stability_and_linked_titles() {
let mut cells = BTreeMap::new();
// Multi-column: priority (select: p0 < p1) then score (number), plus empty values.
cells.insert(
("r1".into(), "col-pri".into()),
DatabaseCellValue::Text("p1".into()),
);
cells.insert(
("r1".into(), "col-num".into()),
DatabaseCellValue::Number(10.0),
);
cells.insert(
("r1".into(), "col-txt".into()),
DatabaseCellValue::Text("Zulu".into()),
);
cells.insert(
("r2".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
cells.insert(
("r2".into(), "col-num".into()),
DatabaseCellValue::Number(20.0),
);
cells.insert(
("r2".into(), "col-txt".into()),
DatabaseCellValue::Text("École".into()),
);
cells.insert(
("r3".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
cells.insert(
("r3".into(), "col-num".into()),
DatabaseCellValue::Number(20.0),
);
cells.insert(
("r3".into(), "col-txt".into()),
DatabaseCellValue::Text("E\u{0301}cole".into()),
);
// r4 has p0 but empty number & text (must stay at tail in BOTH asc and desc).
cells.insert(
("r4".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
// r5 has empty priority & score 5.
cells.insert(
("r5".into(), "col-num".into()),
DatabaseCellValue::Number(5.0),
);
cells.insert(
("r5".into(), "col-txt".into()),
DatabaseCellValue::Text("1.2".into()),
);
// r6 has dot-prefix "1" to exercise non-strict-weak-order compareList without panic.
cells.insert(
("r6".into(), "col-txt".into()),
DatabaseCellValue::Text("1".into()),
);
let rows = vec![
DatabaseRow {
row_id: "r1".into(),
title: linked_rt("p-b"),
created_at: Some(100),
},
DatabaseRow {
row_id: "r2".into(),
title: linked_rt("p-a"),
created_at: Some(200),
},
DatabaseRow {
row_id: "r3".into(),
title: rt("Beta"),
created_at: Some(300),
},
DatabaseRow {
row_id: "r4".into(),
title: rt(""),
created_at: None,
},
DatabaseRow {
row_id: "r5".into(),
title: rt("Alpha"),
created_at: Some(50),
},
DatabaseRow {
row_id: "r6".into(),
title: rt("1.1"),
created_at: Some(75),
},
];
let data = DatabaseData {
title: rt("Sort Spec"),
columns: vec![
DatabaseColumn {
id: "title".into(),
column_type: "title".into(),
name: "Title".into(),
data: json!({}),
},
DatabaseColumn {
id: "col-pri".into(),
column_type: "select".into(),
name: "Priority".into(),
data: json!({ "options": [
{ "id": "p0", "value": "High", "color": "" },
{ "id": "p1", "value": "Low", "color": "" }
]}),
},
DatabaseColumn {
id: "col-num".into(),
column_type: "number".into(),
name: "Score".into(),
data: json!({}),
},
DatabaseColumn {
id: "col-txt".into(),
column_type: "rich-text".into(),
name: "Note".into(),
data: json!({}),
},
],
views: vec![],
cells,
rows,
};
let make_view = |sort: Option<serde_json::Value>| DatabaseView {
id: "v1".into(),
name: "Table".into(),
mode: DatabaseViewMode::Table,
columns: vec![],
filter: None,
sort,
group_by: None,
group_properties: vec![],
header: None,
date: None,
card: None,
ui: None,
extra: BTreeMap::new(),
};
let titles_v1 = BTreeMap::from([
("p-a".to_string(), "Gamma".to_string()),
("p-b".to_string(), "Delta".to_string()),
]);
let titles_v2 = BTreeMap::from([
("p-a".to_string(), "Zebra".to_string()),
("p-b".to_string(), "Aardvark".to_string()),
]);
let cases: Vec<(
&str,
Option<serde_json::Value>,
&BTreeMap<String, String>,
Vec<&str>,
)> = vec![
(
"no filter no sort preserves source order",
None,
&titles_v1,
vec!["r1", "r2", "r3", "r4", "r5", "r6"],
),
(
"multi-col priority asc + num desc keeps empty tail and equal stability",
Some(json!({ "sortBy": [
{ "ref": { "name": "col-pri" }, "desc": false },
{ "ref": { "name": "col-num" }, "desc": true }
]})),
&titles_v1,
vec!["r2", "r3", "r4", "r1", "r5", "r6"],
),
(
"number desc still puts empty rows at tail",
Some(json!({ "sortBy": [{ "ref": { "name": "col-num" }, "desc": true }] })),
&titles_v1,
vec!["r2", "r3", "r1", "r5", "r4", "r6"],
),
(
"nfd diacritic folding and dot-prefix non-strict-weak-order asc",
Some(json!({ "sortBy": [{ "ref": { "name": "col-txt" }, "desc": false }] })),
&titles_v1,
vec!["r5", "r6", "r2", "r3", "r1", "r4"],
),
(
"linked page title sort v1",
Some(json!({ "sortBy": [{ "ref": { "name": "title" }, "desc": false }] })),
&titles_v1,
vec!["r6", "r5", "r3", "r1", "r2", "r4"],
),
(
"linked page title sort reflects title update v2",
Some(json!({ "sortBy": [{ "ref": { "name": "title" }, "desc": false }] })),
&titles_v2,
vec!["r6", "r1", "r5", "r3", "r2", "r4"],
),
];
for (name, sort, titles, expected) in cases {
let view = make_view(sort);
let ordered = filter_and_sort_view_rows(&view, &data, titles);
let actual: Vec<&str> = ordered.iter().map(|r| r.row_id.as_str()).collect();
assert_eq!(actual, expected, "case: {name}");
}
}
#[test]
fn kanban_unsorted_lane_preserves_table_row_order() {
let mut cells = BTreeMap::new();
cells.insert(
("r1".into(), "col-pri".into()),
DatabaseCellValue::Text("p1".into()),
);
cells.insert(
("r2".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
cells.insert(
("r3".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
cells.insert(
("r4".into(), "col-pri".into()),
DatabaseCellValue::Text("p0".into()),
);
let data = DatabaseData {
title: rt("Board Order"),
columns: vec![DatabaseColumn {
id: "col-pri".into(),
column_type: "select".into(),
name: "Priority".into(),
data: json!({ "options": [
{ "id": "p0", "value": "High", "color": "" },
{ "id": "p1", "value": "Low", "color": "" }
]}),
}],
views: vec![],
cells,
rows: vec![
DatabaseRow {
row_id: "r1".into(),
title: rt("One"),
created_at: None,
},
DatabaseRow {
row_id: "r2".into(),
title: rt("Two"),
created_at: None,
},
DatabaseRow {
row_id: "r3".into(),
title: rt("Three"),
created_at: None,
},
DatabaseRow {
row_id: "r4".into(),
title: rt("Four"),
created_at: None,
},
],
};
let kanban_view = DatabaseView {
id: "v-kanban".into(),
name: "Board".into(),
mode: DatabaseViewMode::Kanban,
columns: vec![],
filter: None,
sort: None,
group_by: None,
group_properties: vec![DatabaseGroupProperty {
key: "p0".into(),
hide: false,
manually_card_sort: vec![],
}],
header: None,
date: None,
card: None,
ui: None,
extra: BTreeMap::new(),
};
let group_by = DatabaseGroupBy {
kind: "groupBy".into(),
column_id: "col-pri".into(),
name: "select".into(),
sort: None,
hide_empty: Some(false),
};
let titles = BTreeMap::new();
let ordered = filter_and_sort_view_rows(&kanban_view, &data, &titles);
let buckets = group_view_rows_with_titles(
&ordered,
&kanban_view,
&group_by,
&data,
0,
&|_| 0,
&titles,
);
let p0_bucket = buckets.iter().find(|b| b.key == "p0").expect("p0 bucket");
let p0_ids: Vec<&str> = p0_bucket.rows.iter().map(|r| r.row_id.as_str()).collect();
assert_eq!(p0_ids, vec!["r2", "r3", "r4"]);
}
}
@@ -390,6 +390,10 @@ impl InMemoryDocDirectory {
self.snapshots.insert(id, snapshot);
}
pub fn clear_doc_snapshot(&mut self, doc_id: &str) {
self.snapshots.remove(&EditorDocId::new(doc_id));
}
/// Synchronizes the directory's documents with `docs` while preserving `next_id`,
/// existing `intents` entries whose target documents remain present, and existing
/// `mode` / non-zero `updated_at_ms` metadata.
+74 -20
View File
@@ -8,7 +8,7 @@
mod languages;
mod lexer;
use std::ops::Range;
use std::{collections::HashMap, ops::Range, sync::Arc};
use ui::Hsla;
@@ -125,27 +125,61 @@ pub fn highlight_incremental_range(
struct CachedHighlight {
lang: LanguageId,
text: String,
lines: Vec<HighlightedLine>,
lines: Arc<[HighlightedLine]>,
last_used: u64,
}
#[derive(Default)]
struct BlockHighlightCache {
entries: HashMap<String, CachedHighlight>,
tick: u64,
}
impl BlockHighlightCache {
fn next_tick(&mut self) -> u64 {
self.tick = self.tick.wrapping_add(1);
self.tick
}
fn evict_lru_if_full(&mut self) {
if self.entries.len() < MAX_HIGHLIGHT_CACHE_ENTRIES {
return;
}
if let Some(oldest_key) = self
.entries
.iter()
.min_by_key(|(_, entry)| entry.last_used)
.map(|(k, _)| k.clone())
{
self.entries.remove(&oldest_key);
}
}
}
const MAX_HIGHLIGHT_CACHE_ENTRIES: usize = 128;
thread_local! {
static BLOCK_HIGHLIGHT_CACHE: std::cell::RefCell<std::collections::HashMap<String, CachedHighlight>> =
std::cell::RefCell::new(std::collections::HashMap::new());
static BLOCK_HIGHLIGHT_CACHE: std::cell::RefCell<BlockHighlightCache> =
std::cell::RefCell::new(BlockHighlightCache::default());
}
/// Highlight a code block by `block_id`, using [`highlight_incremental`] when the same
/// block's text is edited without changing language.
pub fn highlight_block_cached(block_id: &str, language: &str, text: &str) -> Vec<HighlightedLine> {
/// Highlight a code block by `block_id`, returning a shared [`Arc<[HighlightedLine]>`]
/// with exact source-text verification, incremental line convergence, and bounded LRU eviction.
pub fn highlight_block_cached(
block_id: &str,
language: &str,
text: &str,
) -> Arc<[HighlightedLine]> {
let lang = resolve_language(language);
BLOCK_HIGHLIGHT_CACHE.with(|cell| {
let mut cache = cell.borrow_mut();
if let Some(entry) = cache.get_mut(block_id)
let tick = cache.next_tick();
if let Some(entry) = cache.entries.get_mut(block_id)
&& entry.lang == lang
{
entry.last_used = tick;
if entry.text == text {
return entry.lines.clone();
return Arc::clone(&entry.lines);
}
let prev_lines: Vec<&str> = entry.text.split('\n').collect();
let new_lines: Vec<&str> = text.split('\n').collect();
@@ -163,32 +197,34 @@ pub fn highlight_block_cached(block_id: &str, language: &str, text: &str) -> Vec
.rposition(|(a, b)| a != b)
.unwrap_or(first_changed)
};
let mut buf: Vec<HighlightedLine> = entry.lines.to_vec();
if first_changed < new_lines.len() {
highlight_incremental_range(
language,
&new_lines,
&mut entry.lines,
&mut buf,
first_changed,
last_changed,
);
} else {
entry.lines.truncate(new_lines.len());
buf.truncate(new_lines.len());
}
let shared: Arc<[HighlightedLine]> = Arc::from(buf);
entry.text.clear();
entry.text.push_str(text);
return entry.lines.clone();
entry.lines = Arc::clone(&shared);
return shared;
}
if cache.len() >= MAX_HIGHLIGHT_CACHE_ENTRIES {
cache.clear();
}
let lines = highlight_document(language, text);
cache.insert(
cache.evict_lru_if_full();
let lines: Arc<[HighlightedLine]> = Arc::from(highlight_document(language, text));
cache.entries.insert(
block_id.to_string(),
CachedHighlight {
lang,
text: text.to_string(),
lines: lines.clone(),
lines: Arc::clone(&lines),
last_used: tick,
},
);
lines
@@ -356,14 +392,32 @@ mod tests {
let v1 = "/* comment */\nfn a() {}\nlet x = 1;\nlet y = 2;";
let v2 = "/* comment */\nfn a() {}\nlet x = 42;\nlet y = 2;";
let first = highlight_block_cached(block_id, "rust", v1);
let first_hit = highlight_block_cached(block_id, "rust", v1);
assert!(
Arc::ptr_eq(&first, &first_hit),
"cache hit must share Arc without cloning"
);
let second = highlight_block_cached(block_id, "rust", v2);
let expected = highlight_document("rust", v2);
assert_eq!(first.len(), 4);
assert_eq!(second, expected);
assert_eq!(second.as_ref(), expected.as_slice());
// Simultaneous non-contiguous edit on lines 0 and 2 while line 1 is unchanged.
let v3 = "let alpha = \"hi\";\nfn a() {}\nconst Z: usize = 99;\nlet y = 2;";
let third = highlight_block_cached(block_id, "rust", v3);
assert_eq!(third, highlight_document("rust", v3));
assert_eq!(third.as_ref(), highlight_document("rust", v3).as_slice());
// Bounded LRU eviction: inserting > 128 entries keeps hot entries warm instead of clearing all.
let hot_id = "test-code-block-lru-hot";
let hot = highlight_block_cached(hot_id, "rust", "let hot = 1;");
for i in 0..MAX_HIGHLIGHT_CACHE_ENTRIES + 8 {
let _ = highlight_block_cached(&format!("test-lru-filler-{i}"), "rust", "let x = 0;");
let _ = highlight_block_cached(hot_id, "rust", "let hot = 1;");
}
let hot_after = highlight_block_cached(hot_id, "rust", "let hot = 1;");
assert!(
Arc::ptr_eq(&hot, &hot_after),
"hot entry must survive bounded LRU eviction"
);
}
}
+18 -63
View File
@@ -443,65 +443,29 @@ impl Palette {
}
}
/// Serialize an icon definition as a standalone monochrome SVG document for the SVG renderer.
pub fn icon_svg(icon: &IconDef) -> String {
let mut svg = format!(
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="{}" fill="none">"#,
icon.view_box
);
for path in icon.paths {
svg.push_str(r#"<path d=""#);
svg.push_str(path.d);
svg.push('"');
let mut attr = |name: &str, value: &str| {
if !value.is_empty() {
svg.push_str(&format!(r#" {name}="{value}""#));
}
};
attr(
"fill",
match path.fill {
"" | "currentColor" => "#000",
other => other,
},
);
attr("fill-rule", path.fill_rule);
attr("clip-rule", path.clip_rule);
attr(
"stroke",
match path.stroke {
"currentColor" => "#000",
other => other,
},
);
attr("stroke-linecap", path.stroke_linecap);
attr("stroke-linejoin", path.stroke_linejoin);
if path.stroke_width > 0.0 {
svg.push_str(&format!(r#" stroke-width="{}""#, path.stroke_width));
}
svg.push_str("/>");
}
svg.push_str("</svg>");
svg
}
/// An icon ready to paint through the monochrome SVG renderer.
#[derive(Clone)]
pub struct IconPaint {
key: SharedString,
svg: Arc<str>,
svg: SharedString,
turn: f32,
}
impl IconPaint {
pub fn new(icon: &IconDef) -> Self {
/// Construct a zero-allocation icon paint directly from a static `ui-tokens` definition.
pub fn from_def(icon: &'static IconDef) -> Self {
Self {
key: SharedString::from(format!("playground-icon:{}", icon.name)),
svg: Arc::from(icon_svg(icon)),
key: SharedString::from(icon.name),
svg: SharedString::from(icon.svg),
turn: 0.0,
}
}
/// Return the pre-built monochrome SVG document, or `""` for a missing icon.
pub fn svg_str(&self) -> &str {
self.svg.as_ref()
}
/// Return a copy of this icon rotated clockwise by `turn` radians around its center.
pub fn rotated(mut self, turn: f32) -> Self {
self.turn = turn;
@@ -510,25 +474,12 @@ impl IconPaint {
/// Look a generated icon up by name from `ui-tokens`.
pub fn named(name: &str) -> Self {
static CACHE: OnceLock<RwLock<HashMap<&'static str, IconPaint>>> = OnceLock::new();
if let Some(icon) = icon_by_name(name) {
let cache = CACHE.get_or_init(|| RwLock::new(HashMap::new()));
if let Some(hit) = cache
.read()
.ok()
.and_then(|map| map.get(icon.name).cloned())
{
return hit;
}
let paint = Self::new(icon);
if let Ok(mut map) = cache.write() {
map.insert(icon.name, paint.clone());
}
return paint;
return Self::from_def(icon);
}
Self {
key: SharedString::from(format!("playground-icon:missing:{name}")),
svg: Arc::from(""),
svg: SharedString::from(""),
turn: 0.0,
}
}
@@ -754,12 +705,16 @@ mod tests {
"NumberedListIcon",
"CheckBoxCheckLinearIcon",
"CodeBlockIcon",
"MoveLeftIcon",
"MoveRightIcon",
"InvisibleIcon",
] {
let icon = icon_by_name(name).unwrap_or_else(|| panic!("icon {name} is generated"));
let svg = icon_svg(icon);
let paint = IconPaint::from_def(icon);
let svg = paint.svg_str();
assert!(svg.starts_with("<svg "), "{svg}");
assert!(svg.ends_with("</svg>"), "{svg}");
assert_eq!(svg.matches("<path ").count(), icon.paths.len());
assert!(svg.contains("<path "), "{svg}");
assert!(!svg.contains("currentColor"), "{svg}");
}
}
@@ -0,0 +1,480 @@
//! Bounded Undo LRU image store and cross-frame deferred GPU atlas reclamation.
use std::{
collections::{BTreeSet, HashMap, HashSet},
ops::Deref,
sync::Arc,
};
use ui::{ImageId, RenderImage, Window};
use crate::block_flow::ImageSlot;
/// Maximum number of unreferenced decoded images retained for instant Undo without re-decoding.
pub(crate) const UNREFERENCED_IMAGE_CACHE_MAX_ENTRIES: usize = 16;
/// Maximum total decoded BGRA pixel bytes of unreferenced images retained for instant Undo.
pub(crate) const UNREFERENCED_IMAGE_CACHE_MAX_BYTES: usize = 64 * 1024 * 1024;
pub(crate) fn render_image_pixel_bytes(image: &RenderImage) -> usize {
(0..image.frame_count())
.filter_map(|idx| image.as_bytes(idx).map(|bytes| bytes.len()))
.sum()
}
/// Encapsulated decoded-image store for [`crate::PlaygroundView`].
///
/// Exposes read-only map lookup via [`Deref`] (never `DerefMut`) so every mutation flows
/// through [`Self::insert`], [`Self::clear`], and [`Self::reconcile`]. Retired
/// [`RenderImage`] handles are deduplicated by [`ImageId`] and released via
/// `window.drop_image(...)` only after crossing at least one frame boundary with
/// `Arc::strong_count == 1`.
#[derive(Default)]
pub(crate) struct ImageStore {
slots: HashMap<String, ImageSlot>,
access_gen: HashMap<String, u64>,
gen_counter: u64,
frame_seq: u64,
pending_dropped: HashMap<ImageId, (u64, Arc<RenderImage>)>,
}
impl Deref for ImageStore {
type Target = HashMap<String, ImageSlot>;
fn deref(&self) -> &Self::Target {
&self.slots
}
}
impl ImageStore {
pub(crate) fn new() -> Self {
Self::default()
}
fn queue_retired(&mut self, img: Arc<RenderImage>) {
self.pending_dropped
.entry(img.id)
.or_insert((self.frame_seq, img));
}
/// Insert or replace an image slot, queueing any superseded decoded [`RenderImage`]
/// for cross-frame GPU atlas reclamation.
pub(crate) fn insert(&mut self, source_id: String, slot: ImageSlot) {
self.gen_counter = self.gen_counter.wrapping_add(1);
self.access_gen.insert(source_id.clone(), self.gen_counter);
let new_id = match &slot {
ImageSlot::Ready(img) => Some(img.id),
_ => None,
};
if let Some(ImageSlot::Ready(old)) = self.slots.insert(source_id, slot)
&& Some(old.id) != new_id
{
self.queue_retired(old);
}
}
/// Clear all slots on document switch and queue every decoded image for GPU reclamation.
pub(crate) fn clear(&mut self) {
let retired: Vec<Arc<RenderImage>> = self
.slots
.drain()
.filter_map(|(_, slot)| match slot {
ImageSlot::Ready(img) => Some(img),
_ => None,
})
.collect();
for img in retired {
self.queue_retired(img);
}
self.access_gen.clear();
}
/// Reconcile cached images against the active page's `referenced` blob set using the
/// default bounded Undo LRU budget (`<= 16` entries and `<= 64 MiB`).
pub(crate) fn reconcile(&mut self, referenced: &BTreeSet<String>) {
self.reconcile_with_limits(
referenced,
UNREFERENCED_IMAGE_CACHE_MAX_ENTRIES,
UNREFERENCED_IMAGE_CACHE_MAX_BYTES,
);
}
pub(crate) fn reconcile_with_limits(
&mut self,
referenced: &BTreeSet<String>,
max_entries: usize,
max_bytes: usize,
) {
self.gen_counter = self.gen_counter.wrapping_add(1);
let generation = self.gen_counter;
for source_id in referenced {
self.access_gen.insert(source_id.clone(), generation);
}
let mut unreferenced_placeholders = Vec::new();
let mut unreferenced_ready: Vec<(u64, String, usize)> = Vec::new();
for (source_id, slot) in &self.slots {
if referenced.contains(source_id) {
continue;
}
match slot {
ImageSlot::Ready(img) => {
let last_gen = self.access_gen.get(source_id).copied().unwrap_or(0);
unreferenced_ready.push((
last_gen,
source_id.clone(),
render_image_pixel_bytes(img),
));
}
ImageSlot::Loading | ImageSlot::Unavailable => {
unreferenced_placeholders.push(source_id.clone());
}
}
}
for source_id in unreferenced_placeholders {
self.slots.remove(&source_id);
self.access_gen.remove(&source_id);
}
// Most-recently-used first; tie-break deterministically by source_id.
unreferenced_ready.sort_by(|a, b| b.0.cmp(&a.0).then_with(|| a.1.cmp(&b.1)));
let mut kept_entries = 0_usize;
let mut kept_bytes = 0_usize;
for (_, source_id, pixel_bytes) in unreferenced_ready {
let fits_entries = kept_entries < max_entries;
let fits_bytes = kept_bytes.saturating_add(pixel_bytes) <= max_bytes;
if fits_entries && fits_bytes {
kept_entries += 1;
kept_bytes = kept_bytes.saturating_add(pixel_bytes);
} else {
if let Some(ImageSlot::Ready(img)) = self.slots.remove(&source_id) {
self.queue_retired(img);
}
self.access_gen.remove(&source_id);
}
}
let slots = &self.slots;
self.access_gen
.retain(|source_id, _| slots.contains_key(source_id) || referenced.contains(source_id));
}
/// Advance the frame counter and drain retired images strictly before any `paint_image`
/// call in the frame. An image is dropped only once it is no longer active in any slot,
/// has crossed at least one frame boundary (`retired_frame < frame_seq`), and has
/// `Arc::strong_count == 1`.
pub(crate) fn drain_pending_dropped(&mut self, window: &mut Window) {
self.frame_seq = self.frame_seq.wrapping_add(1);
if self.pending_dropped.is_empty() {
return;
}
let active_ids: HashSet<ImageId> = self
.slots
.values()
.filter_map(|slot| match slot {
ImageSlot::Ready(img) => Some(img.id),
_ => None,
})
.collect();
let queued = std::mem::take(&mut self.pending_dropped);
for (id, (retired_frame, img)) in queued {
if active_ids.contains(&id) {
continue;
}
if retired_frame < self.frame_seq && Arc::strong_count(&img) == 1 {
let _ = window.drop_image(img);
} else {
self.pending_dropped.insert(id, (retired_frame, img));
}
}
}
#[cfg(test)]
pub(crate) fn pending_dropped_count(&self) -> usize {
self.pending_dropped.len()
}
#[cfg(test)]
pub(crate) fn pending_dropped_contains(&self, id: ImageId) -> bool {
self.pending_dropped.contains_key(&id)
}
#[cfg(test)]
pub(crate) fn reset_pending_for_test(&mut self) {
self.pending_dropped.clear();
}
}
#[cfg(test)]
mod tests {
use std::{cell::RefCell, collections::BTreeSet, rc::Rc, sync::Arc};
use blocksuite_playground_doc::schema::{BlockSpec, ParagraphType};
use image::{Frame, RgbaImage};
use ui::{
AppContext as _, Application, HeadlessPlatform, RenderImage, WindowBounds, WindowHandle,
WindowOptions, bounds, point, px, size,
};
use super::*;
use crate::{DocState, PlaygroundOptions, PlaygroundView, theme::register_bundled_fonts};
fn synthetic_render_image(width: u32, height: u32) -> Arc<RenderImage> {
let buf = RgbaImage::from_pixel(width, height, image::Rgba([12, 34, 56, 255]));
Arc::new(RenderImage::new(vec![Frame::new(buf)]))
}
fn with_headless_view(f: impl FnOnce(&ui::ApplicationHandle, &WindowHandle<PlaygroundView>)) {
let platform = HeadlessPlatform::new(640, 480, 1.0);
let handle_cell: Rc<RefCell<Option<WindowHandle<PlaygroundView>>>> =
Rc::new(RefCell::new(None));
let handle_out = handle_cell.clone();
let app = Application::with_platform(platform).run_embedded(move |cx| {
register_bundled_fonts(cx).expect("register bundled fonts");
let window = cx
.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(bounds(
point(px(0.0), px(0.0)),
size(px(640.0), px(480.0)),
))),
..Default::default()
},
|_, cx| {
cx.new(|cx| PlaygroundView::with_options(PlaygroundOptions::default(), cx))
},
)
.expect("open headless window");
*handle_out.borrow_mut() = Some(window);
});
let window = handle_cell.borrow_mut().take().expect("window handle");
f(&app, &window);
}
#[test]
fn image_store_evicts_over_budget_preserves_undo_dedupes_shared_arc_and_waits_for_next_frame() {
with_headless_view(|app, window| {
let shared_img = synthetic_render_image(8, 8);
let shared_id = shared_img.id;
let img_a = synthetic_render_image(8, 8);
let img_b = synthetic_render_image(8, 8);
let id_a = img_a.id;
let id_b = img_b.id;
app.update(|cx| {
window
.update(cx, |view, window, cx| {
view.images.clear();
view.images.reset_pending_for_test();
// Advance to frame 1 so retired_frame is distinct from initial 0.
view.images.drain_pending_dropped(window);
view.images
.insert("blob-a".into(), ImageSlot::Ready(img_a));
view.images
.reconcile_with_limits(&BTreeSet::from(["blob-a".into()]), 2, 1024);
view.images
.insert("blob-b".into(), ImageSlot::Ready(img_b));
view.images
.reconcile_with_limits(&BTreeSet::from(["blob-b".into()]), 2, 1024);
// Both slots point to the SAME Arc<RenderImage>.
view.images.insert(
"shared-1".into(),
ImageSlot::Ready(Arc::clone(&shared_img)),
);
view.images.insert(
"shared-2".into(),
ImageSlot::Ready(Arc::clone(&shared_img)),
);
// Unreferencing blob-a and blob-b stays within Undo budget (2 <= 2).
view.images.reconcile_with_limits(
&BTreeSet::from(["shared-1".into(), "shared-2".into()]),
2,
1024,
);
assert!(
matches!(view.images.get("blob-a"), Some(ImageSlot::Ready(i)) if i.id == id_a)
);
assert_eq!(view.images.pending_dropped_count(), 0);
// Undo re-referencing blob-a reuses the exact cached RenderImage.
view.images.reconcile_with_limits(
&BTreeSet::from([
"blob-a".into(),
"shared-1".into(),
"shared-2".into(),
]),
2,
1024,
);
assert!(
matches!(view.images.get("blob-a"), Some(ImageSlot::Ready(i)) if i.id == id_a)
);
// Document switch clears all slots; shared-1 and shared-2 deduplicate by ImageId
// so pending_dropped holds only ONE Arc for shared_id (no strong_count==2 deadlock).
let mut next_doc = DocState::new("next-doc", 7).expect("doc state");
if let Some(page) = next_doc.workspace.page_mut("next-doc") {
let _ = page.add_block(
"p-next",
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text: "hello".into(),
},
None,
None,
1,
);
}
view.set_document(next_doc, cx);
assert!(view.images.is_empty());
assert!(view.images.pending_dropped_contains(id_a));
assert!(view.images.pending_dropped_contains(id_b));
assert!(view.images.pending_dropped_contains(shared_id));
assert_eq!(view.images.pending_dropped_count(), 3);
})
.expect("update view");
});
// Drop local test handle so only pending_dropped owns shared_img (strong_count == 1).
drop(shared_img);
// Next frame boundary advances frame_seq past retired_frame and reclaims all 3 images.
app.update(|cx| {
window
.update(cx, |view, window, _cx| {
// Also test cross-frame safety: an image retired on the CURRENT frame_seq
// must survive one more frame before window.drop_image is called.
let same_frame_img = synthetic_render_image(4, 4);
let same_frame_id = same_frame_img.id;
view.images.drain_pending_dropped(window);
assert_eq!(view.images.pending_dropped_count(), 0);
view.images
.insert("same-frame".into(), ImageSlot::Ready(same_frame_img));
view.images.clear();
assert!(view.images.pending_dropped_contains(same_frame_id));
// Still queued until next frame's drain_pending_dropped runs.
assert_eq!(view.images.pending_dropped_count(), 1);
view.images.drain_pending_dropped(window);
assert_eq!(view.images.pending_dropped_count(), 0);
})
.expect("drain dropped images");
});
});
}
#[test]
fn active_page_refresh_clears_stale_directory_snapshot_and_republishes_when_inactive() {
use blocksuite_editor::WorkspaceDocDirectory as _;
with_headless_view(|app, window| {
app.update(|cx| {
window
.update(cx, |view, _w, cx| {
let mut doc = DocState::new("ws-dir-test", 11).expect("doc state");
doc.workspace
.create_page("page-a", "Page A", 1)
.expect("create page-a");
doc.workspace
.create_page("page-b", "Page B", 1)
.expect("create page-b");
if let Some(pa) = doc.workspace.page_mut("page-a") {
let _ = pa.add_block(
"pa-root",
BlockSpec::Page {
title: "Page A".into(),
},
None,
None,
1,
);
let _ = pa.add_block(
"pa-note",
BlockSpec::Note { xywh: None },
Some("pa-root"),
None,
1,
);
let _ = pa.add_block(
"pa-p1",
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text: "initial A".into(),
},
Some("pa-note"),
None,
1,
);
}
if let Some(pb) = doc.workspace.page_mut("page-b") {
let _ = pb.add_block(
"pb-root",
BlockSpec::Page {
title: "Page B".into(),
},
None,
None,
1,
);
let _ = pb.add_block(
"pb-note",
BlockSpec::Note { xywh: None },
Some("pb-root"),
None,
1,
);
}
view.set_document(doc, cx);
// Switch to page-b so page-a becomes non-active and caches its PageSnapshot.
view.page_id = Some("page-b".into());
view.refresh_document();
let id_a = crate::directory::EditorDocId::new("page-a");
assert!(
view.default_doc_directory.doc_snapshot(&id_a).is_some(),
"non-active page-a should publish its snapshot"
);
// Switch back to page-a (now active): stale directory snapshot must be cleared.
view.page_id = Some("page-a".into());
view.refresh_document();
assert!(
view.default_doc_directory.doc_snapshot(&id_a).is_none(),
"active page-a must clear stale directory snapshot instead of cloning"
);
// Mutate page-a, then switch to page-b: directory must republish fresh snapshot.
if let Some(pa) = view.state.workspace.page_mut("page-a") {
let _ = pa.add_block(
"pa-p2",
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text: "updated A".into(),
},
Some("pa-note"),
None,
2,
);
}
view.page_id = Some("page-b".into());
view.refresh_document();
let republished = view
.default_doc_directory
.doc_snapshot(&id_a)
.expect("republished snapshot");
assert!(
republished.block("pa-p2").is_some(),
"republished snapshot must contain latest edit"
);
})
.expect("verify directory snapshot lifecycle");
});
});
}
}
@@ -5,9 +5,34 @@ use std::{
rc::Rc,
};
use blocksuite_playground_doc::read::BlockContent;
use blocksuite_playground_doc::read::{BlockContent, PageSnapshot};
use ui::{Motion, MotionCurve, ScrollEvent, Window, px};
fn extract_page_snippet(snap: &PageSnapshot) -> String {
snap.root
.as_ref()
.map(|root| {
let mut parts = Vec::new();
for node in root.walk() {
let text = match &node.content {
BlockContent::Paragraph { text, .. } | BlockContent::List { text, .. } => {
text.plain.trim()
}
BlockContent::Callout { text, .. } => text.plain.trim(),
_ => "",
};
if !text.is_empty() {
parts.push(text.replace("\r\n", " ").replace(['\r', '\n'], " "));
if parts.len() >= 2 {
break;
}
}
}
parts.join(" ")
})
.unwrap_or_default()
}
use crate::{
HOME_PAGE_ID, PILL_EDGELESS_X, PILL_PAGE_X, PILL_TRANSITION_MS, PlaygroundMode, PlaygroundView,
SCROLL_LINE,
@@ -123,45 +148,38 @@ impl PlaygroundView {
{
continue;
}
let next_snap = if is_active {
self.snapshot.as_deref().cloned()
} else {
self.state
.workspace
.page(&page.id)
.and_then(|s| s.read_page_snapshot().ok())
};
if let Some(snap) = next_snap {
if is_active {
self.cached_page_revisions.remove(&page.id);
self.default_doc_directory.clear_doc_snapshot(&page.id);
if let Some(snap) = self.snapshot.as_deref() {
let snippet = extract_page_snippet(snap);
let next_rev =
cached_preview.map_or(1, |prev| prev.revision.wrapping_add(1));
self.default_doc_directory.upsert_preview(
doc_id,
directory::EditorDocPreview {
title: page.title.clone(),
snippet,
updated_at_ms: page_updated_ms,
revision: next_rev,
},
);
}
continue;
}
if let Some(snap) = self
.state
.workspace
.page(&page.id)
.and_then(|s| s.read_page_snapshot().ok())
{
if let Some(rev) = current_rev {
self.cached_page_revisions.insert(page.id.clone(), rev);
}
let snippet = snap
.root
.as_ref()
.map(|root| {
let mut parts = Vec::new();
for node in root.walk() {
let text = match &node.content {
BlockContent::Paragraph { text, .. }
| BlockContent::List { text, .. } => text.plain.trim(),
BlockContent::Callout { text, .. } => text.plain.trim(),
_ => "",
};
if !text.is_empty() {
parts
.push(text.replace("\r\n", " ").replace(['\r', '\n'], " "));
if parts.len() >= 2 {
break;
}
}
}
parts.join(" ")
})
.unwrap_or_default();
let snippet = extract_page_snippet(&snap);
let next_rev = match cached_preview {
Some(prev)
if !is_active
&& prev.title == page.title
if prev.title == page.title
&& prev.snippet == snippet
&& prev.updated_at_ms == page_updated_ms
&& self.default_doc_directory.doc_snapshot(&doc_id).as_deref()
@@ -170,9 +188,7 @@ impl PlaygroundView {
prev.revision
}
Some(prev) => {
if !is_active {
self.env_rev += 1;
}
self.env_rev += 1;
prev.revision.wrapping_add(1)
}
None => 1,
@@ -229,14 +245,9 @@ impl PlaygroundView {
self.refresh_pdf_previews(&pdf_attachments);
// Fetches of blobs the page no longer references stop. An ordinary document
// update never restarts a fetch that is already tracked.
let images = &mut self.images;
self.blob_fetches.retain(|source_id, _| {
let keep = referenced.contains(source_id);
if !keep {
images.remove(source_id);
}
keep
});
self.blob_fetches
.retain(|source_id, _| referenced.contains(source_id));
self.images.reconcile(&referenced);
for source_id in referenced {
if let Some(bytes) = self.state.blobs.get(&source_id) {
// Decoded once; a blob that is no image stays unavailable.
+9 -4
View File
@@ -15,6 +15,7 @@ pub mod edgeless;
pub mod editor_session;
#[cfg(test)]
mod embed_preview_tests;
mod image_cache;
mod layout_cache;
mod media_picker;
pub mod overlays;
@@ -26,6 +27,7 @@ mod touch_selection;
mod view_room;
#[cfg(target_family = "wasm")]
pub mod wasm_crdt;
mod wasm_crdt_core;
#[cfg(target_family = "wasm")]
mod wasm_preview;
@@ -58,7 +60,7 @@ use ui::{Motion, ScrollEvent, Task, Window, point, prelude::*, px, size};
#[cfg(test)]
pub(crate) use crate::block_flow::page_geometry;
use crate::{
block_flow::{BlockFlow, FlowLayout, ImageSlot},
block_flow::{BlockFlow, FlowLayout},
overlays::Overlays,
room_client::{DocState, RoomConfig, RoomProtocol},
};
@@ -227,7 +229,7 @@ pub struct PlaygroundView {
pub(crate) pending_sync_since_sv: BTreeMap<String, Vec<u8>>,
/// What each referenced image shows. An entry without a pending fetch was decoded
/// from its blob and is final.
pub(crate) images: HashMap<String, ImageSlot>,
pub(crate) images: image_cache::ImageStore,
/// Rasterized PDF attachment previews keyed by attachment block id.
pub(crate) pdf_previews: HashMap<String, block_flow::PdfPreviewPage>,
/// Cache key `(source_id, page_index)` for each rendered PDF attachment block.
@@ -401,7 +403,7 @@ impl PlaygroundView {
custom_doc_directory: None,
preflight_renamed_title: None,
pending_sync_since_sv: BTreeMap::new(),
images: HashMap::new(),
images: image_cache::ImageStore::new(),
pdf_previews: HashMap::new(),
pdf_preview_keys: HashMap::new(),
failed_pdf_blobs: BTreeSet::new(),
@@ -2678,7 +2680,10 @@ pub(crate) mod tests {
"the uploaded blob",
);
session.view(|view, _| {
assert!(matches!(view.images.get(source), Some(ImageSlot::Ready(_))));
assert!(matches!(
view.images.get(source),
Some(crate::block_flow::ImageSlot::Ready(_))
));
assert!(view.blob_fetches.is_empty());
});
let (snapshot, _) = session.frame();
@@ -61,6 +61,9 @@ impl PlaygroundView {
}
pub(crate) fn handle_touch_gestures(&mut self, window: &mut Window, cx: &mut Context<Self>) {
// Invoked unconditionally at the start of `PlaygroundView::render` before any
// `paint_image` call, draining retired GPU atlas tiles across frame boundaries.
self.images.drain_pending_dropped(window);
if window.active_touch_count() > 0 {
self.cancel_flings();
} else {
+43 -182
View File
@@ -1,18 +1,18 @@
//! WebAssembly `#[wasm_bindgen]` CRDT exports served directly from the main `playground`
//! bundle, eliminating any redundant standalone `crdt-codec.wasm`.
use std::collections::BTreeSet;
use blocksuite_playground_doc::{
client_id_from_seed, crdt_v1,
read::{BlockContent, BlockNode, NoteDisplayMode},
schema::{BlockSpec, ParagraphType},
session::PageDocSession,
validate_client_id,
};
use serde::Serialize;
use wasm_bindgen::{JsCast, prelude::*};
use crate::wasm_crdt_core::{
append_paragraph_core, append_paragraph_with_snapshot_core, read_local_doc_snapshot_json,
};
fn collect_byte_frames(frames: &js_sys::Array) -> Result<Vec<Vec<u8>>, JsValue> {
let len = frames.length();
let mut out = Vec::with_capacity(len as usize);
@@ -51,76 +51,6 @@ pub fn extract_subdoc_ids(frames: js_sys::Array) -> Result<js_sys::Array, JsValu
Ok(out)
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct SnapshotBlockDto {
id: String,
flavour: String,
text: String,
depth: usize,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct LocalDocSnapshotDto {
doc_id: String,
title: String,
paragraphs: Vec<String>,
blocks: Vec<SnapshotBlockDto>,
}
fn is_visible_page_note(node: &BlockNode) -> bool {
matches!(
&node.content,
BlockContent::Note {
display_mode,
hidden,
..
} if !*hidden && *display_mode != NoteDisplayMode::EdgelessOnly
)
}
fn node_plain_text(node: &BlockNode) -> Option<&str> {
match &node.content {
BlockContent::Paragraph { text, .. }
| BlockContent::List { text, .. }
| BlockContent::Callout { text, .. } => Some(text.plain.as_str()),
BlockContent::Code { text, .. } => Some(text.as_str()),
_ => None,
}
}
fn collect_note_children(
node: &BlockNode,
depth: usize,
visited: &mut BTreeSet<String>,
paragraphs: &mut Vec<String>,
blocks: &mut Vec<SnapshotBlockDto>,
) {
for child in &node.children {
if !visited.insert(child.id.clone()) {
continue;
}
if let Some(text) = node_plain_text(child) {
paragraphs.push(text.to_string());
blocks.push(SnapshotBlockDto {
id: child.id.clone(),
flavour: child.flavour.clone(),
text: text.to_string(),
depth,
});
}
collect_note_children(child, depth + 1, visited, paragraphs, blocks);
}
}
fn collect_all_block_ids(node: &BlockNode, ids: &mut BTreeSet<String>) {
ids.insert(node.id.clone());
for child in &node.children {
collect_all_block_ids(child, ids);
}
}
/// Live WebAssembly BlockSuite document session backed by `PageDocSession` (`y-octo`).
/// Hydrates Yjs V1 frames from IndexedDB, produces typed `PageSnapshot` views for canvas
/// rendering, and emits incremental Yjs V1 deltas for local edits.
@@ -161,44 +91,8 @@ impl WasmLocalDocSession {
}
pub fn read_snapshot_json(&self) -> Result<String, JsValue> {
let snapshot = self
.session
.read_page_snapshot()
.map_err(|err| JsValue::from_str(&err.to_string()))?;
let mut title = String::new();
let mut paragraphs = Vec::new();
let mut blocks = Vec::new();
let mut visited = BTreeSet::new();
let mut page_roots: Vec<&BlockNode> = Vec::new();
if let Some(root) = snapshot.root.as_ref() {
page_roots.push(root);
}
for node in &snapshot.detached {
if matches!(node.content, BlockContent::Page { .. }) {
page_roots.push(node);
}
}
for page in page_roots {
if title.is_empty()
&& let BlockContent::Page { title: page_title } = &page.content
{
title = page_title.plain.clone();
}
for child in &page.children {
if is_visible_page_note(child) && visited.insert(child.id.clone()) {
collect_note_children(child, 0, &mut visited, &mut paragraphs, &mut blocks);
}
}
}
serde_json::to_string(&LocalDocSnapshotDto {
doc_id: self.doc_id.clone(),
title,
paragraphs,
blocks,
})
.map_err(|err| JsValue::from_str(&err.to_string()))
read_local_doc_snapshot_json(&self.doc_id, &self.session)
.map_err(|err| JsValue::from_str(&err))
}
pub fn append_paragraph(
@@ -206,79 +100,46 @@ impl WasmLocalDocSession {
text: String,
now_ms: f64,
) -> Result<js_sys::Uint8Array, JsValue> {
let ts = if now_ms.is_finite() && now_ms > 0.0 {
now_ms as u64
} else {
1
};
let prev_sv = self
.session
.encode_state_vector_v1()
.map_err(|err| JsValue::from_str(&err.to_string()))?;
let snapshot = self
.session
.read_page_snapshot()
.map_err(|err| JsValue::from_str(&err.to_string()))?;
let mut existing_ids = BTreeSet::new();
if let Some(root) = snapshot.root.as_ref() {
collect_all_block_ids(root, &mut existing_ids);
}
for node in &snapshot.detached {
collect_all_block_ids(node, &mut existing_ids);
}
let mut target_note_id: Option<String> = None;
if let Some(root) = snapshot.root.as_ref() {
for child in &root.children {
if is_visible_page_note(child) {
target_note_id = Some(child.id.clone());
}
}
}
let Some(note_id) = target_note_id else {
return Err(JsValue::from_str(&format!(
"Document '{}' has no initialized page note block",
self.doc_id
)));
};
self.edit_seq += 1;
let mut para_id = format!(
"para-native-{}-{ts}-{}",
self.session.client_id(),
self.edit_seq
);
while existing_ids.contains(&para_id) {
self.edit_seq += 1;
para_id = format!(
"para-native-{}-{ts}-{}",
self.session.client_id(),
self.edit_seq
);
}
self.session
.add_block(
para_id,
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text,
},
Some(&note_id),
None,
ts,
)
.map_err(|err| JsValue::from_str(&err.to_string()))?;
let delta = self
.session
.encode_diff_v1(&prev_sv)
.map_err(|err| JsValue::from_str(&err.to_string()))?;
let delta = append_paragraph_core(
&self.doc_id,
&mut self.session,
&mut self.edit_seq,
text,
now_ms,
)
.map_err(|err| JsValue::from_str(&err))?;
Ok(js_sys::Uint8Array::from(delta.as_slice()))
}
/// Append a paragraph and return `{ delta: Uint8Array, snapshotJson: string }` in a single
/// snapshot read, avoiding redundant tree reads and JSON parses in the Web host.
pub fn append_paragraph_with_snapshot(
&mut self,
text: String,
now_ms: f64,
) -> Result<js_sys::Object, JsValue> {
let (delta, snapshot_json) = append_paragraph_with_snapshot_core(
&self.doc_id,
&mut self.session,
&mut self.edit_seq,
text,
now_ms,
)
.map_err(|err| JsValue::from_str(&err))?;
let result = js_sys::Object::new();
js_sys::Reflect::set(
&result,
&JsValue::from_str("delta"),
&js_sys::Uint8Array::from(delta.as_slice()).into(),
)?;
js_sys::Reflect::set(
&result,
&JsValue::from_str("snapshotJson"),
&JsValue::from_str(&snapshot_json),
)?;
Ok(result)
}
/// Initializes an empty `WasmLocalDocSession` with the canonical BlockSuite page tree
/// (`affine:page` + `affine:surface` + `affine:note` + initial `affine:paragraph`) and
/// returns the incremental Yjs v1 update bytes. Rejects already-initialized documents.
@@ -0,0 +1,353 @@
//! Target-independent local document projection and paragraph-append helpers shared by
//! `wasm_crdt` (on `wasm32`) and native unit tests.
use std::collections::BTreeSet;
use blocksuite_playground_doc::{
read::{BlockContent, BlockNode, PageSnapshot},
schema::{BlockSpec, ParagraphType},
session::PageDocSession,
};
use serde::Serialize;
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct SnapshotBlockDto {
id: String,
flavour: String,
text: String,
depth: usize,
}
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct LocalDocSnapshotDto {
doc_id: String,
title: String,
paragraphs: Vec<String>,
blocks: Vec<SnapshotBlockDto>,
}
fn node_plain_text(node: &BlockNode) -> Option<&str> {
match &node.content {
BlockContent::Paragraph { text, .. }
| BlockContent::List { text, .. }
| BlockContent::Callout { text, .. } => Some(text.plain.as_str()),
BlockContent::Code { text, .. } => Some(text.as_str()),
_ => None,
}
}
fn collect_note_children(
node: &BlockNode,
depth: usize,
visited: &mut BTreeSet<String>,
paragraphs: &mut Vec<String>,
blocks: &mut Vec<SnapshotBlockDto>,
) {
for child in &node.children {
if !visited.insert(child.id.clone()) {
continue;
}
if let Some(text) = node_plain_text(child) {
paragraphs.push(text.to_string());
blocks.push(SnapshotBlockDto {
id: child.id.clone(),
flavour: child.flavour.clone(),
text: text.to_string(),
depth,
});
}
collect_note_children(child, depth + 1, visited, paragraphs, blocks);
}
}
fn build_snapshot_dto(
doc_id: &str,
snapshot: &PageSnapshot,
appended: Option<(&str, &str, &str)>,
) -> LocalDocSnapshotDto {
let mut title = String::new();
let mut paragraphs = Vec::new();
let mut blocks = Vec::new();
let mut visited = BTreeSet::new();
let mut page_roots: Vec<&BlockNode> = Vec::new();
if let Some(root) = snapshot.root.as_ref() {
page_roots.push(root);
}
for node in &snapshot.detached {
if matches!(node.content, BlockContent::Page { .. }) {
page_roots.push(node);
}
}
for page in page_roots {
if title.is_empty()
&& let BlockContent::Page { title: page_title } = &page.content
{
title = page_title.plain.clone();
}
for child in &page.children {
if child.is_page_visible_note() && visited.insert(child.id.clone()) {
collect_note_children(child, 0, &mut visited, &mut paragraphs, &mut blocks);
if let Some((target_note_id, para_id, para_text)) = appended
&& child.id == target_note_id
{
paragraphs.push(para_text.to_string());
blocks.push(SnapshotBlockDto {
id: para_id.to_string(),
flavour: "affine:paragraph".to_string(),
text: para_text.to_string(),
depth: 0,
});
}
}
}
}
LocalDocSnapshotDto {
doc_id: doc_id.to_string(),
title,
paragraphs,
blocks,
}
}
#[allow(dead_code)]
pub(crate) fn read_local_doc_snapshot_json(
doc_id: &str,
session: &PageDocSession,
) -> Result<String, String> {
let snapshot = session
.read_page_snapshot()
.map_err(|err| err.to_string())?;
serde_json::to_string(&build_snapshot_dto(doc_id, &snapshot, None))
.map_err(|err| err.to_string())
}
fn append_paragraph_inner(
doc_id: &str,
session: &mut PageDocSession,
edit_seq: &mut u64,
text: String,
now_ms: f64,
emit_snapshot_json: bool,
) -> Result<(Vec<u8>, Option<String>), String> {
let ts = if now_ms.is_finite() && now_ms > 0.0 {
now_ms as u64
} else {
1
};
let prev_sv = session
.encode_state_vector_v1()
.map_err(|err| err.to_string())?;
let snapshot = session
.read_page_snapshot()
.map_err(|err| err.to_string())?;
let target_note_id = snapshot.root.as_ref().and_then(|root| {
root.children
.iter()
.rev()
.find(|child| child.is_page_visible_note())
.map(|child| child.id.clone())
});
let Some(note_id) = target_note_id else {
return Err(format!(
"Document '{doc_id}' has no initialized page note block"
));
};
*edit_seq += 1;
let mut para_id = format!("para-native-{}-{ts}-{}", session.client_id(), *edit_seq);
// `PageSnapshot::block` already searches both `snapshot.root` and `snapshot.detached`.
while snapshot.block(&para_id).is_some() {
*edit_seq += 1;
para_id = format!("para-native-{}-{ts}-{}", session.client_id(), *edit_seq);
}
let snapshot_json = if emit_snapshot_json {
let dto = build_snapshot_dto(doc_id, &snapshot, Some((&note_id, &para_id, &text)));
Some(serde_json::to_string(&dto).map_err(|err| err.to_string())?)
} else {
None
};
session
.add_block(
para_id,
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text,
},
Some(&note_id),
None,
ts,
)
.map_err(|err| err.to_string())?;
let delta = session
.encode_diff_v1(&prev_sv)
.map_err(|err| err.to_string())?;
Ok((delta, snapshot_json))
}
/// Append a paragraph under the last visible page note and return only the Yjs v1 delta,
/// skipping snapshot DTO construction and JSON serialization.
#[allow(dead_code)]
pub(crate) fn append_paragraph_core(
doc_id: &str,
session: &mut PageDocSession,
edit_seq: &mut u64,
text: String,
now_ms: f64,
) -> Result<Vec<u8>, String> {
let (delta, _) = append_paragraph_inner(doc_id, session, edit_seq, text, now_ms, false)?;
Ok(delta)
}
/// Append a paragraph under the last visible page note and return `(delta_v1, snapshot_json)`
/// from a single `read_page_snapshot()` call.
#[allow(dead_code)]
pub(crate) fn append_paragraph_with_snapshot_core(
doc_id: &str,
session: &mut PageDocSession,
edit_seq: &mut u64,
text: String,
now_ms: f64,
) -> Result<(Vec<u8>, String), String> {
let (delta, snapshot_json) =
append_paragraph_inner(doc_id, session, edit_seq, text, now_ms, true)?;
Ok((
delta,
snapshot_json.ok_or_else(|| "missing projected snapshot JSON".to_string())?,
))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn append_paragraph_with_snapshot_matches_fresh_read_byte_for_byte_and_avoids_detached_id_collision()
{
let doc_id = "doc-parity";
let mut session = PageDocSession::new(doc_id, 42).expect("session");
session
.add_block(
"page:1",
BlockSpec::Page {
title: "Parity Title".into(),
},
None,
None,
1,
)
.expect("page");
session
.add_block("surface:1", BlockSpec::Surface, Some("page:1"), None, 1)
.expect("surface");
session
.add_block(
"note:visible-1",
BlockSpec::Note { xywh: None },
Some("page:1"),
None,
1,
)
.expect("note 1");
session
.add_block(
"para:initial",
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text: "First paragraph".into(),
},
Some("note:visible-1"),
None,
1,
)
.expect("initial para");
session
.add_block(
"note:visible-2",
BlockSpec::Note { xywh: None },
Some("page:1"),
None,
1,
)
.expect("note 2");
// Hidden note after note:visible-2 must be skipped so appends land in note:visible-2.
session
.add_block(
"note:hidden",
BlockSpec::Note { xywh: None },
Some("page:1"),
None,
1,
)
.expect("hidden note");
session
.set_block_prop(
"note:hidden",
"prop:hidden",
y_octo::SessionValue::Any(y_octo::Any::True),
1,
)
.expect("hide note");
// Pre-populate a detached block whose ID collides with the first generated para_id
// (`para-native-42-1000-1`) to verify collision avoidance against detached subtrees.
session
.add_block(
"para-native-42-1000-1",
BlockSpec::Paragraph {
paragraph_type: ParagraphType::Text,
text: "Detached colliding block".into(),
},
None,
None,
1,
)
.expect("detached colliding block");
let mut edit_seq = 0_u64;
for (idx, text) in ["Appended one", "Appended two", "Appended three"]
.into_iter()
.enumerate()
{
let (delta, projected_json) = append_paragraph_with_snapshot_core(
doc_id,
&mut session,
&mut edit_seq,
text.to_string(),
1000.0 + idx as f64,
)
.expect("append paragraph");
assert!(!delta.is_empty(), "delta must be non-empty");
let fresh_json =
read_local_doc_snapshot_json(doc_id, &session).expect("fresh snapshot");
assert_eq!(
projected_json, fresh_json,
"single-read projection must match fresh read_page_snapshot byte-for-byte on step {idx}"
);
}
// First append skipped colliding seq=1 -> seq=2, then 3, then 4.
assert_eq!(edit_seq, 4);
let delta_only = append_paragraph_core(
doc_id,
&mut session,
&mut edit_seq,
"Delta only".to_string(),
2000.0,
)
.expect("append delta only");
assert!(!delta_only.is_empty());
assert_eq!(edit_seq, 5);
let after_delta_only =
read_local_doc_snapshot_json(doc_id, &session).expect("snapshot after delta only");
assert!(after_delta_only.contains("Delta only"));
}
}
+2 -2
View File
@@ -264,12 +264,12 @@
}
.password-input-wrap input {
padding-right: 68px;
padding-inline-end: 68px;
}
button.password-toggle {
position: absolute;
right: 6px;
inset-inline-end: 6px;
width: auto;
min-height: 34px;
padding: 4px 10px;
@@ -707,11 +707,11 @@ function attachSelectionOverlayRuntime(host) {
* @param {{ docId: string, getSnapshot: () => { docId: string, title: string, blocks: Array<{ text: string, depth: number }> } }} docSession
* @returns {boolean}
*/
function renderLocalDocScene(host, docSession) {
function renderLocalDocScene(host, docSession, preloadedSnapshot = null) {
if (!host?.selectionOverlay?.setScene || !docSession) {
return false;
}
const snap = docSession.getSnapshot();
const snap = preloadedSnapshot ?? docSession.getSnapshot();
const title = snap.title || snap.docId || 'Untitled';
const blocks = Array.isArray(snap.blocks) ? snap.blocks : [];
return host.selectionOverlay.setScene({
@@ -782,11 +782,46 @@ export function resolveInitialOpenDocOptions(search) {
};
}
/**
* Renders a visible canvas error state when durable `host.openDoc(...)` fails,
* keeping permanent DOM strictly limited to `#app-canvas`.
*
* @param {any} host
* @param {string} docId
* @param {Error} err
* @returns {boolean}
*/
function renderLocalDocErrorScene(host, docId, err) {
if (!host?.selectionOverlay?.setScene) {
return false;
}
const detail = err?.message || String(err) || 'Failed to load document';
return host.selectionOverlay.setScene({
theme: 'light',
selection: null,
paint(ctx, vw, vh) {
ctx.fillStyle = '#ffffff';
ctx.fillRect(0, 0, vw, vh);
ctx.fillStyle = '#991b1b';
ctx.fillRect(0, 0, vw, 64);
ctx.fillStyle = '#ffffff';
ctx.font = '700 16px -apple-system, sans-serif';
ctx.fillText(`Unable to open ${docId || 'document'}`, 20, 40);
ctx.fillStyle = '#7f1d1d';
ctx.font = '400 14px -apple-system, sans-serif';
ctx.fillText(detail.slice(0, 160), 20, 96);
},
});
}
const host = /** @type {any} */ (
globalThis.window?.__AFFINE_WEB_HOST__ ?? globalThis.__AFFINE_WEB_HOST__
);
let firstFrameCleared = false;
let initialDocLoaded = false;
/** @type {Error | null} */
let initialDocError = null;
if (host) {
const overlayRuntime = attachSelectionOverlayRuntime(host);
host.onDispose?.(() => overlayRuntime.dispose());
@@ -804,8 +839,8 @@ if (host) {
return overlayRuntime.renderCompositeFrame();
},
});
host.setDocumentRenderHook?.(docSession => {
renderLocalDocScene(host, docSession);
host.setDocumentRenderHook?.((docSession, snapshot) => {
renderLocalDocScene(host, docSession, snapshot ?? null);
});
if (host.canvas) {
firstFrameCleared = await presentFirstFrameClear(
@@ -817,14 +852,25 @@ if (host) {
);
}
if (firstFrameCleared && host.workspaceBound && host.activeDocId) {
try {
const initialOpenOpts = resolveInitialOpenDocOptions(
String(globalThis.window?.location?.search ?? '')
);
await host.openDoc?.(host.activeDocId, initialOpenOpts);
} catch {
// Keep first-frame presentation if Wasm hydration is unavailable in minimal mocks.
if (typeof host.openDoc === 'function') {
try {
const initialOpenOpts = resolveInitialOpenDocOptions(
String(globalThis.window?.location?.search ?? '')
);
const docSession = await host.openDoc(
host.activeDocId,
initialOpenOpts
);
initialDocLoaded = docSession !== null && docSession !== undefined;
} catch (err) {
initialDocError = err instanceof Error ? err : new Error(String(err));
renderLocalDocErrorScene(host, host.activeDocId, initialDocError);
}
} else {
initialDocLoaded = true;
}
} else if (firstFrameCleared) {
initialDocLoaded = true;
}
if (firstFrameCleared) {
host.markFirstFrameReady?.();
@@ -833,4 +879,6 @@ if (host) {
}
}
export const defaultAppEntryReady = firstFrameCleared;
export const defaultAppEntryCanvasReady = firstFrameCleared;
export const defaultAppEntryDocError = initialDocError;
export const defaultAppEntryReady = firstFrameCleared && initialDocLoaded;
+22 -7
View File
@@ -1814,6 +1814,9 @@ export async function bootWebHost(env = {}) {
activeDocId = docId;
let sessionDisposed = false;
let sealedByOpenSeq = 0;
let snapshotProjectionSeq = 0;
/** @type {any} */
let cachedSnapshot = null;
const wrapped = {
docId,
sealForReopen(seq) {
@@ -1830,7 +1833,10 @@ export async function bootWebHost(env = {}) {
if (sessionDisposed) {
throw new Error('Document session is disposed');
}
return JSON.parse(wasmSession.read_snapshot_json());
if (cachedSnapshot === null) {
cachedSnapshot = JSON.parse(wasmSession.read_snapshot_json());
}
return structuredClone(cachedSnapshot);
},
async appendParagraph(text) {
if (
@@ -1841,11 +1847,15 @@ export async function bootWebHost(env = {}) {
) {
throw new Error('Document session is disposed');
}
const delta = wasmSession.append_paragraph(
const appended = wasmSession.append_paragraph_with_snapshot(
String(text),
Date.now()
);
const snapshot = JSON.parse(wasmSession.read_snapshot_json());
const delta = appended.delta;
const snapshot = JSON.parse(appended.snapshotJson);
snapshotProjectionSeq += 1;
const myProjectionSeq = snapshotProjectionSeq;
cachedSnapshot = snapshot;
const writeOp = (async () => {
if (sessionPendingWrites) {
sessionPendingWrites.enqueue({ docId, bin: delta });
@@ -1865,22 +1875,27 @@ export async function bootWebHost(env = {}) {
} finally {
inFlightSessionWrites.delete(writeOp);
}
if (!sessionDisposed && activeDocSession === wrapped) {
documentRenderHook?.(wrapped);
if (
!sessionDisposed &&
activeDocSession === wrapped &&
snapshotProjectionSeq === myProjectionSeq
) {
documentRenderHook?.(wrapped, structuredClone(snapshot));
}
return { snapshot, delta };
return { snapshot: structuredClone(snapshot), delta };
},
dispose() {
if (sessionDisposed) {
return;
}
sessionDisposed = true;
cachedSnapshot = null;
wasmSession.free?.();
},
};
handedOff = true;
activeDocSession = wrapped;
documentRenderHook?.(wrapped);
documentRenderHook?.(wrapped, wrapped.getSnapshot());
return wrapped;
} catch (err) {
if (
+38 -14
View File
@@ -1096,23 +1096,47 @@ export function createIdbWorkspaceStorage(options) {
const updatesStore = tx.objectStore('updates');
let compacted = false;
try {
const [currentSnapshot, currentUpdates] = await Promise.all([
requestToPromise(snapshotsStore.get(docId)),
requestToPromise(updatesStore.index('docId').getAll(docId)),
]);
const currentSnapshot = await requestToPromise(snapshotsStore.get(docId));
const currentSnapMs = currentSnapshot
? toDate(currentSnapshot.updatedAt).getTime()
: null;
if (currentSnapMs === expectedMs) {
const covered = currentUpdates.filter(
entry => toDate(entry.createdAt).getTime() <= cutoffMs
);
const nextTs = new Date(
Math.max(
currentSnapMs ?? 0,
...covered.map(e => toDate(e.createdAt).getTime())
)
let maxCoveredMs = currentSnapMs ?? 0;
/** @type {Array<[string, Date | number]>} */
const coveredKeys = [];
// Under W3C IndexedDB key ordering (number < Date < string < Array),
// `-Infinity` as lower bound covers both numeric and Date timestamps for
// `docId`, while `new Date(cutoffMs)` stops scanning before later Dates.
const range = globalThis.IDBKeyRange.bound(
[docId, -Infinity],
[docId, new Date(cutoffMs)],
false,
false
);
await new Promise((resolve, reject) => {
const req = updatesStore.openKeyCursor(range);
req.onsuccess = () => {
const cursor = req.result;
if (!cursor) {
resolve(undefined);
return;
}
const key = cursor.primaryKey ?? cursor.key;
if (Array.isArray(key) && key.length >= 2 && key[0] === docId) {
const ts = toDate(key[1]).getTime();
if (ts <= cutoffMs) {
if (ts > maxCoveredMs) {
maxCoveredMs = ts;
}
coveredKeys.push([docId, key[1]]);
}
}
cursor.continue();
};
req.onerror = () =>
reject(req.error || new Error('openKeyCursor failed'));
});
const nextTs = new Date(maxCoveredMs);
await requestToPromise(
snapshotsStore.put({
docId,
@@ -1123,8 +1147,8 @@ export function createIdbWorkspaceStorage(options) {
updatedAt: nextTs,
})
);
for (const entry of covered) {
await requestToPromise(updatesStore.delete([docId, entry.createdAt]));
for (const key of coveredKeys) {
await requestToPromise(updatesStore.delete(key));
}
compacted = true;
}
@@ -20,6 +20,17 @@ import {
V1_CONST_TIMESTAMP,
} from '../src/idb-storage.js';
if (!globalThis.IDBKeyRange) {
globalThis.IDBKeyRange = {
bound: (lower, upper, lowerOpen = false, upperOpen = false) => ({
lower,
upper,
lowerOpen,
upperOpen,
}),
};
}
/**
* Deterministic key serialization matching IndexedDB scalar, Date, and compound
* array keys for our W3C-semantics in-memory IDBFactory test harness.
@@ -334,6 +345,89 @@ function createMemoryIdbFactory() {
}
storeMeta.records.delete(serializeKey(key));
}),
openKeyCursor: range => {
const req = {
result: null,
error: null,
onsuccess: null,
onerror: null,
};
// W3C IndexedDB key type order: number (0) < Date (1) < string (2) < Array (3).
const keyTypeRank = v => {
if (typeof v === 'number') return 0;
if (v instanceof Date) return 1;
if (typeof v === 'string') return 2;
if (Array.isArray(v)) return 3;
return 4;
};
const cmpVal = (a, b) => {
const ra = keyTypeRank(a);
const rb = keyTypeRank(b);
if (ra !== rb) return ra - rb;
if (ra === 0) return a < b ? -1 : a > b ? 1 : 0;
if (ra === 1) {
const ta = a.getTime();
const tb = b.getTime();
return ta < tb ? -1 : ta > tb ? 1 : 0;
}
if (ra === 2) return a < b ? -1 : a > b ? 1 : 0;
if (ra === 3) {
const len = Math.min(a.length, b.length);
for (let i = 0; i < len; i += 1) {
const d = cmpVal(a[i], b[i]);
if (d !== 0) return d;
}
return a.length - b.length;
}
return 0;
};
const matchesRange = key => {
if (!range) return true;
if (range.lower !== undefined) {
const c = cmpVal(key, range.lower);
if (range.lowerOpen ? c <= 0 : c < 0) return false;
}
if (range.upper !== undefined) {
const c = cmpVal(key, range.upper);
if (range.upperOpen ? c >= 0 : c > 0) return false;
}
return true;
};
pendingOps += 1;
const keys = [...storeMeta.records.values()]
.map(r => r.key)
.filter(matchesRange)
.sort(cmpVal);
let idx = 0;
const step = () => {
if (finished) {
pendingOps -= 1;
return;
}
if (idx < keys.length) {
const k = keys[idx];
idx += 1;
req.result = {
key: k,
primaryKey: k,
continue: () => queueMicrotask(step),
};
req.onsuccess?.({ target: req });
} else {
req.result = null;
req.onsuccess?.({ target: req });
pendingOps -= 1;
maybeComplete();
}
};
const start = () => queueMicrotask(step);
if (rwGate) {
rwGate.then(start);
} else {
start();
}
return req;
},
index(indexName) {
const idx = storeMeta.indexes.get(indexName);
if (!idx) {
@@ -1661,3 +1755,68 @@ void test('idb-storage v3 schema stays 1:1 locked to packages/common/nbstore/src
}
assert.ok(raceSessions.every(s => s.freed === 1));
});
void test('compactDocWithMerged uses openKeyCursor with W3C key order across numeric and Date keys', async () => {
const idb = createMemoryIdbFactory();
const enc = new TextEncoder();
const dec = new TextDecoder();
const storage = createIdbWorkspaceStorage({
flavour: 'local',
type: 'workspace',
id: 'ws-keycursor',
indexedDB: idb,
BroadcastChannelImpl: createBroadcastBus(),
});
// Seed both numeric and Date createdAt keys directly into the `updates` store
// to verify W3C IndexedDB key ordering (`number < Date < string < Array`).
const dbName = formatIdbName({
flavour: 'local',
type: 'workspace',
id: 'ws-keycursor',
});
await storage.pushDocUpdate({ docId: 'd-other', bin: enc.encode('other') });
const rawDb = await new Promise((resolve, reject) => {
const req = idb.open(dbName, IDB_SCHEMA_VERSION);
req.onsuccess = () => resolve(req.result);
req.onerror = () => reject(req.error);
});
await new Promise((resolve, reject) => {
const tx = rawDb.transaction(['updates'], 'readwrite');
const store = tx.objectStore('updates');
store.put({ docId: 'd-k', createdAt: 999, bin: enc.encode('num-covered') });
store.put({
docId: 'd-k',
createdAt: new Date(1000),
bin: enc.encode('date-covered'),
});
store.put({ docId: 'd-k', createdAt: 1001, bin: enc.encode('num-late') });
store.put({
docId: 'd-k',
createdAt: new Date(1002),
bin: enc.encode('date-late'),
});
tx.oncomplete = () => resolve(undefined);
tx.onerror = () => reject(tx.error);
tx.onabort = () => reject(tx.error);
tx.commit();
});
const res = await storage.compactDocWithMerged({
docId: 'd-k',
mergedBin: enc.encode('merged-up-to-1000'),
expectedUpdatedAt: null,
coveredUpTo: 1000,
});
assert.equal(res.compacted, true);
const after = await storage.getDocRaw('d-k');
assert.equal(dec.decode(after.snapshot), 'merged-up-to-1000');
const remaining = after.updates.map(u => dec.decode(u)).sort();
assert.deepEqual(remaining, ['date-late', 'num-late']);
const other = await storage.getDocRaw('d-other');
assert.equal(other.updates.length, 1);
assert.equal(dec.decode(other.updates[0]), 'other');
storage.close();
});
@@ -4265,6 +4265,10 @@ void test('openDoc and appendParagraph share pendingWrites barrier, retry failed
this.paragraphs.push(text);
return new TextEncoder().encode(`delta:${this.docId}:${text}`);
}
append_paragraph_with_snapshot(text) {
const delta = this.append_paragraph(text);
return { delta, snapshotJson: this.read_snapshot_json() };
}
initialize_page(title, firstParagraph) {
if (this.paragraphs.length > 0) {
throw new Error(
@@ -4957,9 +4961,117 @@ void test('openDoc and appendParagraph share pendingWrites barrier, retry failed
const missingWasm = createdSessions.find(s => s.docId === 'doc-missing');
assert.equal(missingWasm?.freed, 1);
// Verify getSnapshot() returns a defensive clone so caller mutation cannot poison cache.
const snapCopy = restoredFast.getSnapshot();
snapCopy.paragraphs.push('mutated-by-caller');
assert.ok(
!restoredFast.getSnapshot().paragraphs.includes('mutated-by-caller'),
'getSnapshot must isolate cached snapshot from caller mutation'
);
fastSession.dispose();
fastSession.dispose();
host.dispose();
const fastWasm = createdSessions.find(s => s.docId === 'doc-fast');
assert.equal(fastWasm?.freed, 1);
});
void test('default-app-entry distinguishes canvas clear from openDoc failure and null openDoc result', async () => {
const prevWin = globalThis.window;
const prevHost = globalThis.__AFFINE_WEB_HOST__;
const prevDoc = globalThis.document;
const runCase = async (tag, openDocImpl) => {
const drawnText = [];
const fake2dCtx = {
fillStyle: '',
font: '',
setTransform() {},
save() {},
restore() {},
fillRect() {},
clearRect() {},
drawImage() {},
fillText(text) {
drawnText.push(String(text));
},
measureText(text) {
return { width: String(text).length * 8 };
},
};
const fakeCanvas = {
id: 'app-canvas',
width: 390,
height: 844,
getContext(kind) {
return kind === '2d' ? fake2dCtx : null;
},
addEventListener() {},
removeEventListener() {},
getBoundingClientRect() {
return { left: 0, top: 0, width: 390, height: 844 };
},
};
let firstFrameReadyCalled = false;
const mockHost = {
canvas: fakeCanvas,
workspaceBound: true,
activeDocId: `doc-${tag}`,
onDispose() {},
bindCanvas() {},
setGraphicsRecoveryHooks() {},
setDocumentRenderHook() {},
setSelectionOverlayActive() {},
markFirstFrameReady() {
firstFrameReadyCalled = true;
},
openDoc: openDocImpl,
};
globalThis.document = {
createElement(elTag) {
return elTag === 'canvas'
? { width: 390, height: 844, getContext: () => fake2dCtx }
: {};
},
};
globalThis.window = {
__AFFINE_WEB_HOST__: mockHost,
location: { search: '' },
devicePixelRatio: 1,
innerWidth: 390,
innerHeight: 844,
addEventListener() {},
removeEventListener() {},
};
globalThis.__AFFINE_WEB_HOST__ = mockHost;
const entry = await import(`../src/default-app-entry.js?case=${tag}`);
return { entry, drawnText, firstFrameReadyCalled };
};
try {
const errCase = await runCase('broken', async () => {
throw new Error('corrupt-idb-payload');
});
assert.equal(errCase.entry.defaultAppEntryCanvasReady, true);
assert.equal(errCase.firstFrameReadyCalled, true);
assert.equal(errCase.entry.defaultAppEntryReady, false);
assert.match(
errCase.entry.defaultAppEntryDocError?.message ?? '',
/corrupt-idb-payload/
);
assert.ok(
errCase.drawnText.some(t => t.includes('doc-broken')) &&
errCase.drawnText.some(t => t.includes('corrupt-idb-payload')),
`expected error scene on canvas, got ${JSON.stringify(errCase.drawnText)}`
);
const nullCase = await runCase('missing', async () => null);
assert.equal(nullCase.entry.defaultAppEntryCanvasReady, true);
assert.equal(nullCase.firstFrameReadyCalled, true);
assert.equal(nullCase.entry.defaultAppEntryDocError, null);
assert.equal(nullCase.entry.defaultAppEntryReady, false);
} finally {
globalThis.window = prevWin;
globalThis.__AFFINE_WEB_HOST__ = prevHost;
globalThis.document = prevDoc;
}
});
+2 -124
View File
@@ -1,4 +1,4 @@
//! Domain-neutral single-line `Breadcrumb` layout engine and element builder.
//! Domain-neutral single-line `Breadcrumb` layout engine.
//!
//! Guarantees:
//! - Single row, no wrapping, and zero horizontal scrolling (avoids back-gesture conflict).
@@ -12,9 +12,7 @@
//! `rtl_x + width == viewport_width - ltr_x`.
//! - Touch target height `>= 44.0` logical pixels.
use ui::{Direction, Hsla, IntoElement, ParentElement, Styled, div, px, svg};
use crate::logical::LogicalStyled;
use ui::Direction;
/// Unicode First Strong Isolate (`FSI`).
pub const BIDI_FSI: char = '\u{2068}';
@@ -590,123 +588,3 @@ pub fn layout_breadcrumb_bar_with_measurer(
direction: config.direction,
}
}
/// Visual theme colors for rendering a [`BreadcrumbBarLayout`] into `ui` elements.
#[derive(Clone, Copy, Debug)]
pub struct BreadcrumbVisualStyle {
pub text_color: Hsla,
pub muted_color: Hsla,
pub current_color: Hsla,
pub pill_bg: Hsla,
pub pill_border: Hsla,
}
const CHEVRON_RIGHT_SVG: &[u8] = br#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none"><path d="M6 3.5L10.5 8L6 12.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>"#;
const CHEVRON_DOWN_SVG: &[u8] = br#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none"><path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>"#;
/// Render a pre-laid-out [`BreadcrumbBarLayout`] using strictly logical inline layout helpers
/// and RTL-mirrored chevron separators.
pub fn render_breadcrumb_bar(
layout: &BreadcrumbBarLayout,
style: BreadcrumbVisualStyle,
) -> impl IntoElement {
let dir = layout.direction;
let mut row = div()
.w_full()
.h(px(layout.height))
.flex()
.flex_row()
.items_center()
.overflow_hidden()
.ps(px(12.0), dir)
.pe(px(12.0), dir);
if dir.is_rtl() {
row = row.dir_rtl();
} else {
row = row.dir_ltr();
}
for (idx, slot) in layout.slots.iter().enumerate() {
if idx > 0 {
row = row.child(
div()
.w(px(14.0))
.h(px(layout.height))
.flex_shrink(0.0)
.flex()
.items_center()
.justify_center()
.child(
svg()
.data(CHEVRON_RIGHT_SVG)
.mirror_in_rtl(true)
.w(px(12.0))
.h(px(12.0))
.text_color(style.muted_color),
),
);
}
let is_pill = matches!(
slot.kind,
BreadcrumbSlotKind::Ellipsis | BreadcrumbSlotKind::Switcher
);
let text_color = if slot.is_current {
style.current_color
} else {
style.text_color
};
let mut item_el = div()
.w(px(slot.width))
.h(px(layout.height))
.min_w(px(MIN_TOUCH_WIDTH))
.flex_shrink(0.0)
.overflow_hidden()
.flex()
.items_center()
.justify_center()
.ps(px(4.0), dir)
.pe(px(4.0), dir)
.text_color(text_color)
.text_size(px(13.0));
if is_pill {
let mut pill = div()
.h(px(28.0))
.px(px(8.0))
.rounded(px(8.0))
.bg(style.pill_bg)
.border_1()
.border_color(style.pill_border)
.flex()
.flex_row()
.items_center()
.justify_center()
.gap(px(4.0))
.child(slot.display_text.clone());
if dir.is_rtl() {
pill = pill.dir_rtl();
} else {
pill = pill.dir_ltr();
}
if slot.kind == BreadcrumbSlotKind::Switcher {
pill = pill.child(
svg()
.data(CHEVRON_DOWN_SVG)
.w(px(12.0))
.h(px(12.0))
.text_color(text_color),
);
}
item_el = item_el.child(pill);
} else {
item_el = item_el.child(slot.display_text.clone());
}
row = row.child(item_el);
}
row
}
+3 -3
View File
@@ -15,9 +15,9 @@ pub mod virtual_list;
pub use breadcrumb::{
BIDI_FSI, BIDI_PDI, BreadcrumbBarConfig, BreadcrumbBarLayout, BreadcrumbItem,
BreadcrumbItemKind, BreadcrumbSlotKind, BreadcrumbVisualStyle, LaidOutBreadcrumbSlot,
LaidOutSeparator, MIN_TOUCH_HEIGHT, MIN_TOUCH_WIDTH, bidi_isolate, layout_breadcrumb_bar,
layout_breadcrumb_bar_with_measurer, render_breadcrumb_bar,
BreadcrumbItemKind, BreadcrumbSlotKind, LaidOutBreadcrumbSlot, LaidOutSeparator,
MIN_TOUCH_HEIGHT, MIN_TOUCH_WIDTH, bidi_isolate, layout_breadcrumb_bar,
layout_breadcrumb_bar_with_measurer,
};
pub use logical::{LogicalEdges, LogicalStyled};
pub use micro_icon::{
+55 -47
View File
@@ -73,6 +73,10 @@ const CORE_ICONS = [
['ZOOM_OUT', 'ZoomDownIcon'],
['PLUS', 'PlusIcon'],
['MINUS', 'MinusIcon'],
// Database column menu
['MOVE_LEFT', 'MoveLeftIcon'],
['MOVE_RIGHT', 'MoveRightIcon'],
['INVISIBLE', 'InvisibleIcon'],
];
/**
@@ -660,6 +664,30 @@ function parseSvgAttributes(tagText) {
return attrs;
}
function buildMonochromeIconSvg(viewBox, paths) {
let svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}" fill="none">`;
for (const p of paths) {
svg += `<path d="${p.d}"`;
const attr = (name, value) => {
if (value) {
svg += ` ${name}="${value}"`;
}
};
attr('fill', p.fill === '' || p.fill === 'currentColor' ? '#000' : p.fill);
attr('fill-rule', p.fill_rule);
attr('clip-rule', p.clip_rule);
attr('stroke', p.stroke === 'currentColor' ? '#000' : p.stroke);
attr('stroke-linecap', p.stroke_linecap);
attr('stroke-linejoin', p.stroke_linejoin);
if (p.stroke_width > 0) {
svg += ` stroke-width="${p.stroke_width}"`;
}
svg += '/>';
}
svg += '</svg>';
return svg;
}
function generateIconsRs(nodeModulesDir) {
const iconsPkg = JSON.parse(
fs.readFileSync(
@@ -737,6 +765,7 @@ function generateIconsRs(nodeModulesDir) {
rustConstName,
exportName,
viewBox,
svg: buildMonochromeIconSvg(viewBox, paths),
paths,
});
}
@@ -745,29 +774,10 @@ function generateIconsRs(nodeModulesDir) {
cmpCodeUnit(a.exportName, b.exportName)
);
const renderIconDef = item => {
const pathLines = item.paths
.map(
p =>
` IconPath { d: ${rustStr(p.d)}, fill_rule: ${rustStr(
p.fill_rule
)}, clip_rule: ${rustStr(p.clip_rule)}, fill: ${rustStr(
p.fill
)}, stroke: ${rustStr(p.stroke)}, stroke_width: ${formatF32(
p.stroke_width
)}, stroke_linecap: ${rustStr(
p.stroke_linecap
)}, stroke_linejoin: ${rustStr(p.stroke_linejoin)} },`
)
.join('\n');
return `IconDef {
const renderIconDef = item => `IconDef {
name: ${rustStr(item.exportName)},
view_box: ${rustStr(item.viewBox)},
paths: &[
${pathLines}
],
svg: ${rustStr(item.svg)},
}`;
};
const constDefs = extracted
.map(
@@ -784,23 +794,10 @@ ${pathLines}
// Source: @blocksuite/icons@${iconsPkg.version} (dist/lit.mjs)
// Do not edit manually; regenerate with extract-tokens.mjs.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct IconPath {
pub d: &'static str,
pub fill_rule: &'static str,
pub clip_rule: &'static str,
pub fill: &'static str,
pub stroke: &'static str,
pub stroke_width: f32,
pub stroke_linecap: &'static str,
pub stroke_linejoin: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct IconDef {
pub name: &'static str,
pub view_box: &'static str,
pub paths: &'static [IconPath],
pub svg: &'static str,
}
${constDefs}
@@ -832,24 +829,35 @@ mod tests {
}
for icon in ALL_ICONS {
assert_eq!(icon_by_name(icon.name), Some(icon));
assert!(icon.svg.starts_with("<svg "), "invalid svg for {}", icon.name);
assert!(icon.svg.ends_with("</svg>"), "unclosed svg for {}", icon.name);
assert!(icon.svg.contains("<path "), "missing path in {}", icon.name);
assert!(!icon.svg.contains("currentColor"), "unresolved currentColor in {}", icon.name);
}
assert_eq!(icon_by_name("LinkIcon"), Some(&LINK));
assert_eq!(icon_by_name("LinkedPageIcon"), Some(&LINKED_PAGE));
assert_eq!(icon_by_name("MoveLeftIcon"), Some(&MOVE_LEFT));
assert_eq!(icon_by_name("MoveRightIcon"), Some(&MOVE_RIGHT));
assert_eq!(icon_by_name("InvisibleIcon"), Some(&INVISIBLE));
}
#[test]
fn drag_handle_preserves_inherited_fill_none_and_stroke_attributes() {
assert!(!DRAG_HANDLE.paths.is_empty());
let stroked: Vec<&IconPath> = DRAG_HANDLE
.paths
.iter()
.filter(|p| !p.stroke.is_empty())
.collect();
assert!(!stroked.is_empty(), "DRAG_HANDLE must contain stroked paths");
for path in stroked {
assert_eq!(path.fill, "none");
assert!((path.stroke_width - 0.5).abs() < 1e-6);
}
assert!(
DRAG_HANDLE.svg.contains(r#"fill="none""#),
"DRAG_HANDLE must preserve inherited fill=none: {}",
DRAG_HANDLE.svg
);
assert!(
DRAG_HANDLE.svg.contains(r##"stroke="#000""##),
"DRAG_HANDLE must contain stroked paths: {}",
DRAG_HANDLE.svg
);
assert!(
DRAG_HANDLE.svg.contains(r#"stroke-width="0.5""#),
"DRAG_HANDLE must preserve stroke-width=0.5: {}",
DRAG_HANDLE.svg
);
}
}
`;
+102 -273
View File
@@ -2,510 +2,325 @@
// Source: @blocksuite/icons@2.2.17 (dist/lit.mjs)
// Do not edit manually; regenerate with extract-tokens.mjs.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct IconPath {
pub d: &'static str,
pub fill_rule: &'static str,
pub clip_rule: &'static str,
pub fill: &'static str,
pub stroke: &'static str,
pub stroke_width: f32,
pub stroke_linecap: &'static str,
pub stroke_linejoin: &'static str,
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct IconDef {
pub name: &'static str,
pub view_box: &'static str,
pub paths: &'static [IconPath],
pub svg: &'static str,
}
pub const PAGE: IconDef = IconDef {
name: "PageIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M7 3.25A2.75 2.75 0 0 0 4.25 6v12A2.75 2.75 0 0 0 7 20.75h10A2.75 2.75 0 0 0 19.75 18V6A2.75 2.75 0 0 0 17 3.25zM5.75 6c0-.69.56-1.25 1.25-1.25h10c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H7c-.69 0-1.25-.56-1.25-1.25zM9 7.25a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5zm-.75 4.25a.75.75 0 0 1 .75-.75h6a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75M9 14.25a.75.75 0 0 0 0 1.5h5a.75.75 0 0 0 0-1.5z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M7 3.25A2.75 2.75 0 0 0 4.25 6v12A2.75 2.75 0 0 0 7 20.75h10A2.75 2.75 0 0 0 19.75 18V6A2.75 2.75 0 0 0 17 3.25zM5.75 6c0-.69.56-1.25 1.25-1.25h10c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H7c-.69 0-1.25-.56-1.25-1.25zM9 7.25a.75.75 0 0 0 0 1.5h3.5a.75.75 0 0 0 0-1.5zm-.75 4.25a.75.75 0 0 1 .75-.75h6a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75M9 14.25a.75.75 0 0 0 0 1.5h5a.75.75 0 0 0 0-1.5z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const EDGELESS: IconDef = IconDef {
name: "EdgelessIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M7.168 4.75a1.868 1.868 0 1 0 0 3.736 1.868 1.868 0 0 0 0-3.736M3.8 6.618a3.368 3.368 0 0 1 6.729-.226c.842 0 1.651.014 2.493.217.933.226 1.865.672 2.975 1.504l.02.015.02.017c1.566 1.35 2.35 3.533 2.354 5.578h1.66a.75.75 0 0 1 .75.75v4.713a.75.75 0 0 1-.75.75h-4.714a.75.75 0 0 1-.75-.75v-4.713a.75.75 0 0 1 .75-.75h1.554c-.004-1.705-.663-3.42-1.815-4.426-.975-.728-1.719-1.064-2.406-1.23-.712-.172-1.407-.175-2.36-.175v-.057a3.38 3.38 0 0 1-2.392 2.068v3.904a3.37 3.37 0 0 1-.75 6.652 3.368 3.368 0 0 1-.75-6.652V9.903A3.37 3.37 0 0 1 3.8 6.618m3.368 8.605a1.868 1.868 0 1 0 0 3.736 1.868 1.868 0 0 0 0-3.736m8.92 3.213v-3.213H19.3v3.213z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M7.168 4.75a1.868 1.868 0 1 0 0 3.736 1.868 1.868 0 0 0 0-3.736M3.8 6.618a3.368 3.368 0 0 1 6.729-.226c.842 0 1.651.014 2.493.217.933.226 1.865.672 2.975 1.504l.02.015.02.017c1.566 1.35 2.35 3.533 2.354 5.578h1.66a.75.75 0 0 1 .75.75v4.713a.75.75 0 0 1-.75.75h-4.714a.75.75 0 0 1-.75-.75v-4.713a.75.75 0 0 1 .75-.75h1.554c-.004-1.705-.663-3.42-1.815-4.426-.975-.728-1.719-1.064-2.406-1.23-.712-.172-1.407-.175-2.36-.175v-.057a3.38 3.38 0 0 1-2.392 2.068v3.904a3.37 3.37 0 0 1-.75 6.652 3.368 3.368 0 0 1-.75-6.652V9.903A3.37 3.37 0 0 1 3.8 6.618m3.368 8.605a1.868 1.868 0 1 0 0 3.736 1.868 1.868 0 0 0 0-3.736m8.92 3.213v-3.213H19.3v3.213z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_1: IconDef = IconDef {
name: "Heading1Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M17.926 6.578v10.898c0 .602.33.963.862.963.541 0 .862-.351.862-.963V5.726c0-.682-.451-1.153-1.093-1.153-.39 0-.742.15-1.373.622l-2.026 1.504c-.4.29-.591.561-.591.852 0 .38.3.692.672.692.22 0 .43-.08.721-.291l1.885-1.374zM4.42 4.903a.77.77 0 0 1 .77.77v5.35h6.168v-5.35a.77.77 0 1 1 1.54 0v12.242a.77.77 0 0 1-1.54 0v-5.351H5.19v5.351a.77.77 0 1 1-1.54 0V5.673a.77.77 0 0 1 .77-.77", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M17.926 6.578v10.898c0 .602.33.963.862.963.541 0 .862-.351.862-.963V5.726c0-.682-.451-1.153-1.093-1.153-.39 0-.742.15-1.373.622l-2.026 1.504c-.4.29-.591.561-.591.852 0 .38.3.692.672.692.22 0 .43-.08.721-.291l1.885-1.374zM4.42 4.903a.77.77 0 0 1 .77.77v5.35h6.168v-5.35a.77.77 0 1 1 1.54 0v12.242a.77.77 0 0 1-1.54 0v-5.351H5.19v5.351a.77.77 0 1 1-1.54 0V5.673a.77.77 0 0 1 .77-.77\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_2: IconDef = IconDef {
name: "Heading2Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M14.159 16c-.562.638-.725.905-.725 1.248 0 .553.439.886 1.135.886h6.289c.524 0 .829-.276.829-.724 0-.457-.324-.734-.83-.734H15.57v-.114l3.526-4.031c1.715-1.953 2.201-2.859 2.201-4.098 0-2.096-1.648-3.583-3.993-3.583-2.515 0-4.088 1.697-4.088 3.317 0 .514.305.867.772.867.39 0 .658-.258.791-.763.286-1.238 1.191-1.972 2.42-1.972 1.449 0 2.411.896 2.411 2.24 0 .895-.41 1.695-1.486 2.925zM3.419 5.364c.404 0 .731.327.731.731v5.087h5.863V6.095a.732.732 0 1 1 1.464 0v11.637a.732.732 0 0 1-1.464 0v-5.087H4.15v5.087a.732.732 0 1 1-1.463 0V6.095c0-.404.327-.731.732-.731", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M14.159 16c-.562.638-.725.905-.725 1.248 0 .553.439.886 1.135.886h6.289c.524 0 .829-.276.829-.724 0-.457-.324-.734-.83-.734H15.57v-.114l3.526-4.031c1.715-1.953 2.201-2.859 2.201-4.098 0-2.096-1.648-3.583-3.993-3.583-2.515 0-4.088 1.697-4.088 3.317 0 .514.305.867.772.867.39 0 .658-.258.791-.763.286-1.238 1.191-1.972 2.42-1.972 1.449 0 2.411.896 2.411 2.24 0 .895-.41 1.695-1.486 2.925zM3.419 5.364c.404 0 .731.327.731.731v5.087h5.863V6.095a.732.732 0 1 1 1.464 0v11.637a.732.732 0 0 1-1.464 0v-5.087H4.15v5.087a.732.732 0 1 1-1.463 0V6.095c0-.404.327-.731.732-.731\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_3: IconDef = IconDef {
name: "Heading3Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.05 5.856a.75.75 0 0 0-1.5 0v11.921a.75.75 0 1 0 1.5 0v-5.21h6.006v5.21a.75.75 0 0 0 1.5 0V5.856a.75.75 0 0 0-1.5 0v5.21H4.05zm9.479 9.234c-.418 0-.713.304-.713.732 0 1.454 1.796 2.936 4.248 2.936 2.642 0 4.486-1.558 4.486-3.782 0-1.635-1.226-3.041-2.832-3.222v-.095c1.321-.228 2.395-1.596 2.395-3.031 0-1.977-1.692-3.393-4.068-3.393-2.338 0-3.925 1.425-3.925 2.898 0 .476.285.79.723.79.37 0 .608-.2.798-.723.38-.979 1.235-1.54 2.366-1.54 1.454 0 2.433.875 2.433 2.177s-1.007 2.242-2.395 2.242h-1.121c-.456 0-.76.295-.76.713 0 .409.323.723.76.723h1.188c1.654 0 2.765.978 2.765 2.432s-1.083 2.386-2.784 2.386c-1.293 0-2.281-.57-2.775-1.587-.247-.485-.456-.656-.789-.656", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.05 5.856a.75.75 0 0 0-1.5 0v11.921a.75.75 0 1 0 1.5 0v-5.21h6.006v5.21a.75.75 0 0 0 1.5 0V5.856a.75.75 0 0 0-1.5 0v5.21H4.05zm9.479 9.234c-.418 0-.713.304-.713.732 0 1.454 1.796 2.936 4.248 2.936 2.642 0 4.486-1.558 4.486-3.782 0-1.635-1.226-3.041-2.832-3.222v-.095c1.321-.228 2.395-1.596 2.395-3.031 0-1.977-1.692-3.393-4.068-3.393-2.338 0-3.925 1.425-3.925 2.898 0 .476.285.79.723.79.37 0 .608-.2.798-.723.38-.979 1.235-1.54 2.366-1.54 1.454 0 2.433.875 2.433 2.177s-1.007 2.242-2.395 2.242h-1.121c-.456 0-.76.295-.76.713 0 .409.323.723.76.723h1.188c1.654 0 2.765.978 2.765 2.432s-1.083 2.386-2.784 2.386c-1.293 0-2.281-.57-2.775-1.587-.247-.485-.456-.656-.789-.656\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_4: IconDef = IconDef {
name: "Heading4Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M18.793 15.755v1.931c0 .552.286.866.79.866.514 0 .8-.314.8-.866v-1.931h.989c.542 0 .847-.267.847-.723 0-.467-.314-.733-.847-.733h-.99V6.696c0-.885-.485-1.38-1.35-1.38-.657 0-1.095.286-1.657 1.114-2.16 3.235-3.016 4.605-4.377 7.013-.333.609-.447.942-.447 1.294 0 .628.495 1.018 1.237 1.018zm0-1.456H14.15v-.095c1.246-2.16 2.94-4.882 4.558-7.27h.085zM2.95 5.705a.73.73 0 0 1 .73.731v5.079h5.855V6.436a.73.73 0 0 1 1.461 0v11.62a.73.73 0 0 1-1.461 0v-5.08H3.68v5.08a.73.73 0 0 1-1.461 0V6.435a.73.73 0 0 1 .73-.73", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M18.793 15.755v1.931c0 .552.286.866.79.866.514 0 .8-.314.8-.866v-1.931h.989c.542 0 .847-.267.847-.723 0-.467-.314-.733-.847-.733h-.99V6.696c0-.885-.485-1.38-1.35-1.38-.657 0-1.095.286-1.657 1.114-2.16 3.235-3.016 4.605-4.377 7.013-.333.609-.447.942-.447 1.294 0 .628.495 1.018 1.237 1.018zm0-1.456H14.15v-.095c1.246-2.16 2.94-4.882 4.558-7.27h.085zM2.95 5.705a.73.73 0 0 1 .73.731v5.079h5.855V6.436a.73.73 0 0 1 1.461 0v11.62a.73.73 0 0 1-1.461 0v-5.08H3.68v5.08a.73.73 0 0 1-1.461 0V6.435a.73.73 0 0 1 .73-.73\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_5: IconDef = IconDef {
name: "Heading5Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M13.615 15.053c-.409 0-.678.316-.678.78 0 1.302 1.534 2.799 3.988 2.799 2.593 0 4.443-1.822 4.443-4.388 0-2.408-1.664-4.1-4.025-4.1-1.07 0-2.157.447-2.575 1.07h-.093l.353-4.137h5.01c.55 0 .856-.251.856-.698 0-.455-.316-.725-.855-.725h-5.215c-.8 0-1.2.326-1.255 1.014l-.41 5.205c-.046.716.224 1.135.754 1.135.297 0 .483-.112 1.162-.744a2.77 2.77 0 0 1 1.905-.725c1.609 0 2.752 1.152 2.752 2.789 0 1.71-1.18 2.9-2.872 2.9-1.116 0-1.971-.54-2.482-1.534-.242-.474-.447-.641-.763-.641M3.082 5.903c.394 0 .714.32.714.715v4.962h5.72V6.618a.714.714 0 1 1 1.427 0v11.351a.714.714 0 1 1-1.428 0v-4.961H3.796v4.961a.714.714 0 1 1-1.428 0V6.618c0-.395.32-.714.714-.714", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M13.615 15.053c-.409 0-.678.316-.678.78 0 1.302 1.534 2.799 3.988 2.799 2.593 0 4.443-1.822 4.443-4.388 0-2.408-1.664-4.1-4.025-4.1-1.07 0-2.157.447-2.575 1.07h-.093l.353-4.137h5.01c.55 0 .856-.251.856-.698 0-.455-.316-.725-.855-.725h-5.215c-.8 0-1.2.326-1.255 1.014l-.41 5.205c-.046.716.224 1.135.754 1.135.297 0 .483-.112 1.162-.744a2.77 2.77 0 0 1 1.905-.725c1.609 0 2.752 1.152 2.752 2.789 0 1.71-1.18 2.9-2.872 2.9-1.116 0-1.971-.54-2.482-1.534-.242-.474-.447-.641-.763-.641M3.082 5.903c.394 0 .714.32.714.715v4.962h5.72V6.618a.714.714 0 1 1 1.427 0v11.351a.714.714 0 1 1-1.428 0v-4.961H3.796v4.961a.714.714 0 1 1-1.428 0V6.618c0-.395.32-.714.714-.714\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HEADING_6: IconDef = IconDef {
name: "Heading6Icon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M17.65 5.517c-3.098 0-4.825 2.491-4.825 6.98 0 1.932.318 3.379.961 4.406.766 1.203 2.026 1.857 3.603 1.857 2.594 0 4.349-1.746 4.349-4.312 0-2.436-1.661-4.144-4.032-4.144-1.456 0-2.79.803-3.22 1.941h-.074c.028-3.49 1.129-5.32 3.21-5.32.83 0 1.53.3 2.203.962.336.327.532.43.793.43.401 0 .69-.3.69-.7 0-.43-.373-.943-.989-1.344-.709-.486-1.67-.756-2.669-.756m-.196 11.843c-1.652 0-2.809-1.186-2.809-2.856 0-1.652 1.13-2.81 2.744-2.81 1.661 0 2.744 1.12 2.744 2.82 0 1.717-1.074 2.846-2.679 2.846m-14-11.369c.396 0 .717.321.717.717v4.981h5.742V6.708a.717.717 0 0 1 1.434 0v11.396a.717.717 0 1 1-1.434 0v-4.981H4.171v4.981a.717.717 0 1 1-1.433 0V6.708c0-.396.32-.717.717-.717", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M17.65 5.517c-3.098 0-4.825 2.491-4.825 6.98 0 1.932.318 3.379.961 4.406.766 1.203 2.026 1.857 3.603 1.857 2.594 0 4.349-1.746 4.349-4.312 0-2.436-1.661-4.144-4.032-4.144-1.456 0-2.79.803-3.22 1.941h-.074c.028-3.49 1.129-5.32 3.21-5.32.83 0 1.53.3 2.203.962.336.327.532.43.793.43.401 0 .69-.3.69-.7 0-.43-.373-.943-.989-1.344-.709-.486-1.67-.756-2.669-.756m-.196 11.843c-1.652 0-2.809-1.186-2.809-2.856 0-1.652 1.13-2.81 2.744-2.81 1.661 0 2.744 1.12 2.744 2.82 0 1.717-1.074 2.846-2.679 2.846m-14-11.369c.396 0 .717.321.717.717v4.981h5.742V6.708a.717.717 0 0 1 1.434 0v11.396a.717.717 0 1 1-1.434 0v-4.981H4.171v4.981a.717.717 0 1 1-1.433 0V6.708c0-.396.32-.717.717-.717\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const BULLETED_LIST: IconDef = IconDef {
name: "BulletedListIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.3 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2m4.033-1.75a.75.75 0 0 0 0 1.5l11.917.001a.75.75 0 0 0 0-1.5zm0 5.5a.75.75 0 1 0 0 1.5l11.917.002a.75.75 0 1 0 0-1.5zm0 5.5a.75.75 0 1 0 0 1.5l11.917.002a.75.75 0 0 0 0-1.5zM5.3 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-1 6.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.3 7.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2m4.033-1.75a.75.75 0 0 0 0 1.5l11.917.001a.75.75 0 0 0 0-1.5zm0 5.5a.75.75 0 1 0 0 1.5l11.917.002a.75.75 0 1 0 0-1.5zm0 5.5a.75.75 0 1 0 0 1.5l11.917.002a.75.75 0 0 0 0-1.5zM5.3 12a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-1 6.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const NUMBERED_LIST: IconDef = IconDef {
name: "NumberedListIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.129 5.762a.6.6 0 0 0 .15-.08l.255-.177V7.64c0 .188.063.35.181.466a.66.66 0 0 0 .47.177c.186 0 .35-.061.468-.177a.64.64 0 0 0 .182-.466V4.934a.7.7 0 0 0-.197-.52c-.13-.13-.316-.195-.534-.195-.221 0-.434.022-.675.183l-.677.452a.53.53 0 0 0-.252.46c0 .273.203.472.464.472a.5.5 0 0 0 .165-.024m5.277-.16a.768.768 0 0 0 0 1.536h10.326a.768.768 0 1 0 0-1.536zm0 5.632a.768.768 0 0 0 0 1.536h10.326a.768.768 0 1 0 0-1.535zm0 5.633a.768.768 0 1 0 0 1.536h10.326a.768.768 0 1 0 0-1.536zm-2.782-5.753q.018-.099.018-.21c0-.678-.58-1.136-1.486-1.136-.652 0-1.176.277-1.373.721.197-.444.721-.72 1.373-.72.907 0 1.486.457 1.486 1.134q0 .112-.018.211m-1.5 1.64v.02h1.184c.274 0 .43.163.43.414 0-.25-.156-.414-.43-.414H5.126zm-1.384.237c.035-.14.126-.26.284-.393l1.026-.878c.338-.29.48-.453.523-.622-.042.17-.185.331-.523.622l-1.026.879c-.158.131-.25.253-.284.392m.763-1.81a.8.8 0 0 0 .251-.254.7.7 0 0 1 .184-.193.36.36 0 0 1 .202-.054c.113 0 .199.034.255.085.056.05.09.12.09.21 0 .17-.079.304-.502.667l-1.026.878c-.219.184-.336.365-.336.608 0 .156.045.303.152.412.108.108.265.164.463.164h2.073a.54.54 0 0 0 .389-.145.51.51 0 0 0 .142-.371.5.5 0 0 0-.142-.374.54.54 0 0 0-.39-.142h-.932l.496-.428c.287-.25.506-.447.651-.65.15-.207.221-.419.221-.691 0-.37-.16-.684-.442-.902-.281-.217-.677-.335-1.146-.335-.676 0-1.248.288-1.467.783a.7.7 0 0 0-.057.283c0 .155.05.29.152.387.1.095.24.142.4.142a.6.6 0 0 0 .32-.08m-.832 4.897c.152-.414.67-.853 1.557-.853.457 0 .865.096 1.16.29a1 1 0 0 1 .478.865c0 .483-.308.804-.692.941.234.05.43.143.576.279.184.17.285.404.285.687 0 .405-.174.737-.49.966-.313.228-.762.352-1.311.352-.96 0-1.495-.458-1.641-.868a.7.7 0 0 1-.04-.228.5.5 0 0 1 .155-.387.6.6 0 0 1 .413-.142q.174-.001.305.064.13.066.223.203a.8.8 0 0 0 .236.245c.09.055.206.087.377.087.278 0 .46-.165.46-.379a.33.33 0 0 0-.14-.288c-.096-.066-.242-.104-.444-.104H5.11a.48.48 0 0 1-.35-.122.44.44 0 0 1-.12-.323c0-.124.039-.236.12-.317.082-.08.2-.125.35-.125h.028c.178 0 .311-.038.399-.102a.32.32 0 0 0 .131-.268.32.32 0 0 0-.112-.258.5.5 0 0 0-.322-.098.57.57 0 0 0-.286.068.53.53 0 0 0-.198.207.7.7 0 0 1-.241.27.64.64 0 0 1-.343.082.55.55 0 0 1-.401-.144.5.5 0 0 1-.136-.363c0-.085.012-.153.042-.237", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.129 5.762a.6.6 0 0 0 .15-.08l.255-.177V7.64c0 .188.063.35.181.466a.66.66 0 0 0 .47.177c.186 0 .35-.061.468-.177a.64.64 0 0 0 .182-.466V4.934a.7.7 0 0 0-.197-.52c-.13-.13-.316-.195-.534-.195-.221 0-.434.022-.675.183l-.677.452a.53.53 0 0 0-.252.46c0 .273.203.472.464.472a.5.5 0 0 0 .165-.024m5.277-.16a.768.768 0 0 0 0 1.536h10.326a.768.768 0 1 0 0-1.536zm0 5.632a.768.768 0 0 0 0 1.536h10.326a.768.768 0 1 0 0-1.535zm0 5.633a.768.768 0 1 0 0 1.536h10.326a.768.768 0 1 0 0-1.536zm-2.782-5.753q.018-.099.018-.21c0-.678-.58-1.136-1.486-1.136-.652 0-1.176.277-1.373.721.197-.444.721-.72 1.373-.72.907 0 1.486.457 1.486 1.134q0 .112-.018.211m-1.5 1.64v.02h1.184c.274 0 .43.163.43.414 0-.25-.156-.414-.43-.414H5.126zm-1.384.237c.035-.14.126-.26.284-.393l1.026-.878c.338-.29.48-.453.523-.622-.042.17-.185.331-.523.622l-1.026.879c-.158.131-.25.253-.284.392m.763-1.81a.8.8 0 0 0 .251-.254.7.7 0 0 1 .184-.193.36.36 0 0 1 .202-.054c.113 0 .199.034.255.085.056.05.09.12.09.21 0 .17-.079.304-.502.667l-1.026.878c-.219.184-.336.365-.336.608 0 .156.045.303.152.412.108.108.265.164.463.164h2.073a.54.54 0 0 0 .389-.145.51.51 0 0 0 .142-.371.5.5 0 0 0-.142-.374.54.54 0 0 0-.39-.142h-.932l.496-.428c.287-.25.506-.447.651-.65.15-.207.221-.419.221-.691 0-.37-.16-.684-.442-.902-.281-.217-.677-.335-1.146-.335-.676 0-1.248.288-1.467.783a.7.7 0 0 0-.057.283c0 .155.05.29.152.387.1.095.24.142.4.142a.6.6 0 0 0 .32-.08m-.832 4.897c.152-.414.67-.853 1.557-.853.457 0 .865.096 1.16.29a1 1 0 0 1 .478.865c0 .483-.308.804-.692.941.234.05.43.143.576.279.184.17.285.404.285.687 0 .405-.174.737-.49.966-.313.228-.762.352-1.311.352-.96 0-1.495-.458-1.641-.868a.7.7 0 0 1-.04-.228.5.5 0 0 1 .155-.387.6.6 0 0 1 .413-.142q.174-.001.305.064.13.066.223.203a.8.8 0 0 0 .236.245c.09.055.206.087.377.087.278 0 .46-.165.46-.379a.33.33 0 0 0-.14-.288c-.096-.066-.242-.104-.444-.104H5.11a.48.48 0 0 1-.35-.122.44.44 0 0 1-.12-.323c0-.124.039-.236.12-.317.082-.08.2-.125.35-.125h.028c.178 0 .311-.038.399-.102a.32.32 0 0 0 .131-.268.32.32 0 0 0-.112-.258.5.5 0 0 0-.322-.098.57.57 0 0 0-.286.068.53.53 0 0 0-.198.207.7.7 0 0 1-.241.27.64.64 0 0 1-.343.082.55.55 0 0 1-.401-.144.5.5 0 0 1-.136-.363c0-.085.012-.153.042-.237\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const CHECKBOX_UNCHECKED: IconDef = IconDef {
name: "CheckBoxUnIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 6c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 6c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const CHECKBOX_CHECKED_SOLID: IconDef = IconDef {
name: "CheckBoxCheckSolidIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.25 6A2.75 2.75 0 0 1 6 3.25h12A2.75 2.75 0 0 1 20.75 6v12A2.75 2.75 0 0 1 18 20.75H6A2.75 2.75 0 0 1 3.25 18zm13.28 3.53a.75.75 0 0 0-1.06-1.06l-4.97 4.97-1.47-1.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.25 6A2.75 2.75 0 0 1 6 3.25h12A2.75 2.75 0 0 1 20.75 6v12A2.75 2.75 0 0 1 18 20.75H6A2.75 2.75 0 0 1 3.25 18zm13.28 3.53a.75.75 0 0 0-1.06-1.06l-4.97 4.97-1.47-1.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const CHECKBOX_CHECKED_LINEAR: IconDef = IconDef {
name: "CheckBoxCheckLinearIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 6c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25zm11.78 3.53a.75.75 0 0 0-1.06-1.06l-4.97 4.97-1.47-1.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 6c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v12c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25zm11.78 3.53a.75.75 0 0 0-1.06-1.06l-4.97 4.97-1.47-1.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.06 0z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const TOGGLE_DOWN: IconDef = IconDef {
name: "ToggleDownIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M13.15 15.132a.757.757 0 0 1-1.3 0L8.602 9.605c-.29-.491.072-1.105.65-1.105h6.497c.577 0 .938.614.65 1.105z", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M13.15 15.132a.757.757 0 0 1-1.3 0L8.602 9.605c-.29-.491.072-1.105.65-1.105h6.497c.577 0 .938.614.65 1.105z\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const TOGGLE_RIGHT: IconDef = IconDef {
name: "ToggleRightIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M15.632 11.35a.757.757 0 0 1 0 1.3l-5.527 3.248c-.491.29-1.105-.072-1.105-.65V8.752c0-.577.614-.938 1.105-.65z", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M15.632 11.35a.757.757 0 0 1 0 1.3l-5.527 3.248c-.491.29-1.105-.072-1.105-.65V8.752c0-.577.614-.938 1.105-.65z\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const QUOTE: IconDef = IconDef {
name: "QuoteIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M5 10.966v4.095c0 .565.458 1.024 1.024 1.024h4.095c.566 0 1.024-.459 1.024-1.024v-4.095c0-.566-.459-1.024-1.024-1.024H6.704A3.35 3.35 0 0 1 9.845 7.75v-1.5A4.845 4.845 0 0 0 5 10.966m8 0v4.095c0 .565.458 1.024 1.024 1.024h4.095c.566 0 1.024-.459 1.024-1.024v-4.095c0-.566-.459-1.024-1.024-1.024h-3.415a3.35 3.35 0 0 1 3.141-2.192v-1.5A4.845 4.845 0 0 0 13 10.966", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M5 10.966v4.095c0 .565.458 1.024 1.024 1.024h4.095c.566 0 1.024-.459 1.024-1.024v-4.095c0-.566-.459-1.024-1.024-1.024H6.704A3.35 3.35 0 0 1 9.845 7.75v-1.5A4.845 4.845 0 0 0 5 10.966m8 0v4.095c0 .565.458 1.024 1.024 1.024h4.095c.566 0 1.024-.459 1.024-1.024v-4.095c0-.566-.459-1.024-1.024-1.024h-3.415a3.35 3.35 0 0 1 3.141-2.192v-1.5A4.845 4.845 0 0 0 13 10.966\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const DIVIDER: IconDef = IconDef {
name: "DividerIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4 4.25a.75.75 0 0 1 .75.75v1c0 .69.56 1.25 1.25 1.25h12c.69 0 1.25-.56 1.25-1.25V5a.75.75 0 0 1 1.5 0v1A2.75 2.75 0 0 1 18 8.75H6A2.75 2.75 0 0 1 3.25 6V5A.75.75 0 0 1 4 4.25m0 15.5a.75.75 0 0 0 .75-.75v-1c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v1a.75.75 0 0 0 1.5 0v-1A2.75 2.75 0 0 0 18 15.25H6A2.75 2.75 0 0 0 3.25 18v1c0 .414.336.75.75.75m-1-8.5a.75.75 0 0 0 0 1.5h1.2a.75.75 0 0 0 0-1.5H3m3.45.75a.75.75 0 0 1 .75-.75h1.2a.75.75 0 0 1 0 1.5H7.2a.75.75 0 0 1-.75-.75m4.95-.75a.75.75 0 0 0 0 1.5h1.2a.75.75 0 0 0 0-1.5h-1.2m3.45.75a.75.75 0 0 1 .75-.75h1.2a.75.75 0 0 1 0 1.5h-1.2a.75.75 0 0 1-.75-.75m4.95-.75a.75.75 0 0 0 0 1.5H21a.75.75 0 0 0 0-1.5h-1.2", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4 4.25a.75.75 0 0 1 .75.75v1c0 .69.56 1.25 1.25 1.25h12c.69 0 1.25-.56 1.25-1.25V5a.75.75 0 0 1 1.5 0v1A2.75 2.75 0 0 1 18 8.75H6A2.75 2.75 0 0 1 3.25 6V5A.75.75 0 0 1 4 4.25m0 15.5a.75.75 0 0 0 .75-.75v-1c0-.69.56-1.25 1.25-1.25h12c.69 0 1.25.56 1.25 1.25v1a.75.75 0 0 0 1.5 0v-1A2.75 2.75 0 0 0 18 15.25H6A2.75 2.75 0 0 0 3.25 18v1c0 .414.336.75.75.75m-1-8.5a.75.75 0 0 0 0 1.5h1.2a.75.75 0 0 0 0-1.5H3m3.45.75a.75.75 0 0 1 .75-.75h1.2a.75.75 0 0 1 0 1.5H7.2a.75.75 0 0 1-.75-.75m4.95-.75a.75.75 0 0 0 0 1.5h1.2a.75.75 0 0 0 0-1.5h-1.2m3.45.75a.75.75 0 0 1 .75-.75h1.2a.75.75 0 0 1 0 1.5h-1.2a.75.75 0 0 1-.75-.75m4.95-.75a.75.75 0 0 0 0 1.5H21a.75.75 0 0 0 0-1.5h-1.2\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const CODE_BLOCK: IconDef = IconDef {
name: "CodeBlockIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M2.25 6A2.75 2.75 0 0 1 5 3.25h14A2.75 2.75 0 0 1 21.75 6v12A2.75 2.75 0 0 1 19 20.75H5A2.75 2.75 0 0 1 2.25 18zM5 4.75c-.69 0-1.25.56-1.25 1.25v12c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V6c0-.69-.56-1.25-1.25-1.25zm5.53 4.62a.75.75 0 0 1 0 1.06l-1.59 1.591 1.59 1.591a.75.75 0 0 1-1.06 1.06l-2.122-2.12a.75.75 0 0 1 0-1.061L9.47 9.37a.75.75 0 0 1 1.06 0m2.94 1.06a.75.75 0 1 1 1.06-1.06l2.122 2.12a.75.75 0 0 1 0 1.062l-2.122 2.12a.75.75 0 1 1-1.06-1.06l1.59-1.59z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M2.25 6A2.75 2.75 0 0 1 5 3.25h14A2.75 2.75 0 0 1 21.75 6v12A2.75 2.75 0 0 1 19 20.75H5A2.75 2.75 0 0 1 2.25 18zM5 4.75c-.69 0-1.25.56-1.25 1.25v12c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V6c0-.69-.56-1.25-1.25-1.25zm5.53 4.62a.75.75 0 0 1 0 1.06l-1.59 1.591 1.59 1.591a.75.75 0 0 1-1.06 1.06l-2.122-2.12a.75.75 0 0 1 0-1.061L9.47 9.37a.75.75 0 0 1 1.06 0m2.94 1.06a.75.75 0 1 1 1.06-1.06l2.122 2.12a.75.75 0 0 1 0 1.062l-2.122 2.12a.75.75 0 1 1-1.06-1.06l1.59-1.59z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const INLINE_CODE: IconDef = IconDef {
name: "CodeIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M13.982 4.272a.75.75 0 0 1 .546.91l-3.6 14.4a.75.75 0 1 1-1.456-.364l3.6-14.4a.75.75 0 0 1 .91-.546M7.13 8.07a.75.75 0 0 1 0 1.06L4.06 12.2l3.07 3.07a.75.75 0 0 1-1.06 1.06l-3.6-3.6a.75.75 0 0 1 0-1.06l3.6-3.6a.75.75 0 0 1 1.06 0m9.74 0a.75.75 0 0 1 1.06 0l3.6 3.6a.75.75 0 0 1 0 1.06l-3.6 3.6a.75.75 0 1 1-1.06-1.06l3.07-3.07-3.07-3.07a.75.75 0 0 1 0-1.06", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M13.982 4.272a.75.75 0 0 1 .546.91l-3.6 14.4a.75.75 0 1 1-1.456-.364l3.6-14.4a.75.75 0 0 1 .91-.546M7.13 8.07a.75.75 0 0 1 0 1.06L4.06 12.2l3.07 3.07a.75.75 0 0 1-1.06 1.06l-3.6-3.6a.75.75 0 0 1 0-1.06l3.6-3.6a.75.75 0 0 1 1.06 0m9.74 0a.75.75 0 0 1 1.06 0l3.6 3.6a.75.75 0 0 1 0 1.06l-3.6 3.6a.75.75 0 1 1-1.06-1.06l3.07-3.07-3.07-3.07a.75.75 0 0 1 0-1.06\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const IMAGE: IconDef = IconDef {
name: "ImageIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 18v-1.69l4.366-4.365a1.25 1.25 0 0 1 1.768 0l2.586 2.585 2 2a.75.75 0 1 0 1.06-1.06L15.06 14l1.056-1.056a1.25 1.25 0 0 1 1.768 0l1.366 1.367V18c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25m7.195-7.116L14 12.939l1.056-1.055a2.75 2.75 0 0 1 3.889 0l.305.305V6c0-.69-.56-1.25-1.25-1.25H6c-.69 0-1.25.56-1.25 1.25v8.19l3.305-3.306a2.75 2.75 0 0 1 3.89 0M14 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 3.25A2.75 2.75 0 0 0 3.25 6v12A2.75 2.75 0 0 0 6 20.75h12A2.75 2.75 0 0 0 20.75 18V6A2.75 2.75 0 0 0 18 3.25zM4.75 18v-1.69l4.366-4.365a1.25 1.25 0 0 1 1.768 0l2.586 2.585 2 2a.75.75 0 1 0 1.06-1.06L15.06 14l1.056-1.056a1.25 1.25 0 0 1 1.768 0l1.366 1.367V18c0 .69-.56 1.25-1.25 1.25H6c-.69 0-1.25-.56-1.25-1.25m7.195-7.116L14 12.939l1.056-1.055a2.75 2.75 0 0 1 3.889 0l.305.305V6c0-.69-.56-1.25-1.25-1.25H6c-.69 0-1.25.56-1.25 1.25v8.19l3.305-3.306a2.75 2.75 0 0 1 3.89 0M14 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ATTACHMENT: IconDef = IconDef {
name: "AttachmentIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "m12.218 5.608-6.04 6.04a4.65 4.65 0 0 0 0 6.704c1.913 1.864 5.025 1.864 6.939 0l5.89-5.723a.75.75 0 1 1 1.045 1.076l-5.889 5.721c-2.496 2.432-6.536 2.432-9.032 0a6.15 6.15 0 0 1-.004-8.849l6.04-6.04c1.762-1.716 4.61-1.716 6.371 0a4.35 4.35 0 0 1 .004 6.256l-6.04 6.04c-1.027 1-2.683 1-3.71 0a2.55 2.55 0 0 1 0-3.667l6.2-6.037a.75.75 0 0 1 1.046 1.075l-6.199 6.037a1.05 1.05 0 0 0 0 1.518 1.17 1.17 0 0 0 1.613.003l6.04-6.04a2.85 2.85 0 0 0 0-4.11 3.086 3.086 0 0 0-4.275-.004", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"m12.218 5.608-6.04 6.04a4.65 4.65 0 0 0 0 6.704c1.913 1.864 5.025 1.864 6.939 0l5.89-5.723a.75.75 0 1 1 1.045 1.076l-5.889 5.721c-2.496 2.432-6.536 2.432-9.032 0a6.15 6.15 0 0 1-.004-8.849l6.04-6.04c1.762-1.716 4.61-1.716 6.371 0a4.35 4.35 0 0 1 .004 6.256l-6.04 6.04c-1.027 1-2.683 1-3.71 0a2.55 2.55 0 0 1 0-3.667l6.2-6.037a.75.75 0 0 1 1.046 1.075l-6.199 6.037a1.05 1.05 0 0 0 0 1.518 1.17 1.17 0 0 0 1.613.003l6.04-6.04a2.85 2.85 0 0 0 0-4.11 3.086 3.086 0 0 0-4.275-.004\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const COPY: IconDef = IconDef {
name: "CopyIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.25 6A2.75 2.75 0 0 1 6 3.25h8A2.75 2.75 0 0 1 16.75 6v1.25H18A2.75 2.75 0 0 1 20.75 10v8A2.75 2.75 0 0 1 18 20.75h-8A2.75 2.75 0 0 1 7.25 18v-1.25H6A2.75 2.75 0 0 1 3.25 14zm5.5 12c0 .69.56 1.25 1.25 1.25h8c.69 0 1.25-.56 1.25-1.25v-8c0-.69-.56-1.25-1.25-1.25h-8c-.69 0-1.25.56-1.25 1.25zm6.5-10.75H10A2.75 2.75 0 0 0 7.25 10v5.25H6c-.69 0-1.25-.56-1.25-1.25V6c0-.69.56-1.25 1.25-1.25h8c.69 0 1.25.56 1.25 1.25z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.25 6A2.75 2.75 0 0 1 6 3.25h8A2.75 2.75 0 0 1 16.75 6v1.25H18A2.75 2.75 0 0 1 20.75 10v8A2.75 2.75 0 0 1 18 20.75h-8A2.75 2.75 0 0 1 7.25 18v-1.25H6A2.75 2.75 0 0 1 3.25 14zm5.5 12c0 .69.56 1.25 1.25 1.25h8c.69 0 1.25-.56 1.25-1.25v-8c0-.69-.56-1.25-1.25-1.25h-8c-.69 0-1.25.56-1.25 1.25zm6.5-10.75H10A2.75 2.75 0 0 0 7.25 10v5.25H6c-.69 0-1.25-.56-1.25-1.25V6c0-.69.56-1.25 1.25-1.25h8c.69 0 1.25.56 1.25 1.25z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const DUPLICATE: IconDef = IconDef {
name: "DuplicateIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6 3.25A2.75 2.75 0 0 0 3.25 6v8A2.75 2.75 0 0 0 6 16.75h1.25V18A2.75 2.75 0 0 0 10 20.75h8A2.75 2.75 0 0 0 20.75 18v-8A2.75 2.75 0 0 0 18 7.25h-1.25V6A2.75 2.75 0 0 0 14 3.25zm4 4h5.25V6c0-.69-.56-1.25-1.25-1.25H6c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h2a.75.75 0 0 1 .75.75v2c0 .69.56 1.25 1.25 1.25h8c.69 0 1.25-.56 1.25-1.25v-8c0-.69-.56-1.25-1.25-1.25h-8a1.25 1.25 0 0 0-1.17.81.75.75 0 0 1-1.405-.528A2.75 2.75 0 0 1 10 7.25m2.887 3.239a.75.75 0 1 0-1.098 1.022l.688.739H7.8a.75.75 0 0 0 0 1.5h4.677l-.688.739a.75.75 0 0 0 1.098 1.022l1.862-2a.75.75 0 0 0 0-1.022z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 3.25A2.75 2.75 0 0 0 3.25 6v8A2.75 2.75 0 0 0 6 16.75h1.25V18A2.75 2.75 0 0 0 10 20.75h8A2.75 2.75 0 0 0 20.75 18v-8A2.75 2.75 0 0 0 18 7.25h-1.25V6A2.75 2.75 0 0 0 14 3.25zm4 4h5.25V6c0-.69-.56-1.25-1.25-1.25H6c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h2a.75.75 0 0 1 .75.75v2c0 .69.56 1.25 1.25 1.25h8c.69 0 1.25-.56 1.25-1.25v-8c0-.69-.56-1.25-1.25-1.25h-8a1.25 1.25 0 0 0-1.17.81.75.75 0 0 1-1.405-.528A2.75 2.75 0 0 1 10 7.25m2.887 3.239a.75.75 0 1 0-1.098 1.022l.688.739H7.8a.75.75 0 0 0 0 1.5h4.677l-.688.739a.75.75 0 0 0 1.098 1.022l1.862-2a.75.75 0 0 0 0-1.022z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const LINK: IconDef = IconDef {
name: "LinkIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M18.428 5.572a2.806 2.806 0 0 0-3.967 0l-.978.977a.75.75 0 0 1-1.06-1.06l.977-.978a4.305 4.305 0 1 1 6.089 6.089l-3.556 3.556a4.306 4.306 0 0 1-6.089 0 .75.75 0 0 1 1.061-1.061 2.805 2.805 0 0 0 3.968 0l3.555-3.556a2.806 2.806 0 0 0 0-3.967m-5.333 5.333a2.805 2.805 0 0 0-3.968 0l-3.555 3.556a2.806 2.806 0 0 0 3.967 3.967l.98-.979a.75.75 0 0 1 1.06 1.06l-.979.98A4.305 4.305 0 1 1 4.511 13.4l3.556-3.556a4.306 4.306 0 0 1 6.089 0 .75.75 0 0 1-1.061 1.061", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M18.428 5.572a2.806 2.806 0 0 0-3.967 0l-.978.977a.75.75 0 0 1-1.06-1.06l.977-.978a4.305 4.305 0 1 1 6.089 6.089l-3.556 3.556a4.306 4.306 0 0 1-6.089 0 .75.75 0 0 1 1.061-1.061 2.805 2.805 0 0 0 3.968 0l3.555-3.556a2.806 2.806 0 0 0 0-3.967m-5.333 5.333a2.805 2.805 0 0 0-3.968 0l-3.555 3.556a2.806 2.806 0 0 0 3.967 3.967l.98-.979a.75.75 0 0 1 1.06 1.06l-.979.98A4.305 4.305 0 1 1 4.511 13.4l3.556-3.556a4.306 4.306 0 0 1 6.089 0 .75.75 0 0 1-1.061 1.061\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const LINKED_PAGE: IconDef = IconDef {
name: "LinkedPageIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.25 6A2.75 2.75 0 0 1 7 3.25h10A2.75 2.75 0 0 1 19.75 6v6a.75.75 0 0 1-1.5 0V6c0-.69-.56-1.25-1.25-1.25H7c-.69 0-1.25.56-1.25 1.25v12c0 .69.56 1.25 1.25 1.25h5a.75.75 0 0 1 0 1.5H7A2.75 2.75 0 0 1 4.25 18zm4 2A.75.75 0 0 1 9 7.25h3a.75.75 0 0 1 0 1.5H9A.75.75 0 0 1 8.25 8M9 10.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5zM8.25 15a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75m7.25-.75a.75.75 0 0 0 0 1.5h2.69l-3.72 3.72a.75.75 0 1 0 1.06 1.06l3.72-3.72v2.69a.75.75 0 0 0 1.5 0V15a.75.75 0 0 0-.75-.75z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.25 6A2.75 2.75 0 0 1 7 3.25h10A2.75 2.75 0 0 1 19.75 6v6a.75.75 0 0 1-1.5 0V6c0-.69-.56-1.25-1.25-1.25H7c-.69 0-1.25.56-1.25 1.25v12c0 .69.56 1.25 1.25 1.25h5a.75.75 0 0 1 0 1.5H7A2.75 2.75 0 0 1 4.25 18zm4 2A.75.75 0 0 1 9 7.25h3a.75.75 0 0 1 0 1.5H9A.75.75 0 0 1 8.25 8M9 10.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5zM8.25 15a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5H9a.75.75 0 0 1-.75-.75m7.25-.75a.75.75 0 0 0 0 1.5h2.69l-3.72 3.72a.75.75 0 1 0 1.06 1.06l3.72-3.72v2.69a.75.75 0 0 0 1.5 0V15a.75.75 0 0 0-.75-.75z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const BOLD: IconDef = IconDef {
name: "BoldIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6.25 4A.75.75 0 0 1 7 3.25h5.958c2.67 0 4.875 2.105 4.875 4.75 0 1.515-.723 2.853-1.843 3.72 1.626.764 2.76 2.383 2.76 4.28 0 2.645-2.204 4.75-4.875 4.75H7a.75.75 0 0 1-.75-.75zm1.5 8.75v6.5h6.125c1.886 0 3.375-1.477 3.375-3.25s-1.49-3.25-3.375-3.25zm0-1.5h5.208c1.886 0 3.375-1.477 3.375-3.25s-1.489-3.25-3.375-3.25H7.75z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6.25 4A.75.75 0 0 1 7 3.25h5.958c2.67 0 4.875 2.105 4.875 4.75 0 1.515-.723 2.853-1.843 3.72 1.626.764 2.76 2.383 2.76 4.28 0 2.645-2.204 4.75-4.875 4.75H7a.75.75 0 0 1-.75-.75zm1.5 8.75v6.5h6.125c1.886 0 3.375-1.477 3.375-3.25s-1.49-3.25-3.375-3.25zm0-1.5h5.208c1.886 0 3.375-1.477 3.375-3.25s-1.489-3.25-3.375-3.25H7.75z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ITALIC: IconDef = IconDef {
name: "ItalicIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M14.608 3.25H10.25a.75.75 0 0 0 0 1.5h3.34l-4.758 14.5H5a.75.75 0 0 0 0 1.5h8.75a.75.75 0 0 0 0-1.5h-3.34l4.758-14.5H19a.75.75 0 0 0 0-1.5h-4.392", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M14.608 3.25H10.25a.75.75 0 0 0 0 1.5h3.34l-4.758 14.5H5a.75.75 0 0 0 0 1.5h8.75a.75.75 0 0 0 0-1.5h-3.34l4.758-14.5H19a.75.75 0 0 0 0-1.5h-4.392\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const UNDERLINE: IconDef = IconDef {
name: "UnderLineIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M7.744 3.968a.808.808 0 1 0-1.616 0v7.003a5.656 5.656 0 1 0 11.313 0V3.968a.808.808 0 1 0-1.616 0v7.003a4.04 4.04 0 1 1-8.08 0zM4.458 19.32a.808.808 0 0 0 0 1.616h15.084a.808.808 0 1 0 0-1.616z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M7.744 3.968a.808.808 0 1 0-1.616 0v7.003a5.656 5.656 0 1 0 11.313 0V3.968a.808.808 0 1 0-1.616 0v7.003a4.04 4.04 0 1 1-8.08 0zM4.458 19.32a.808.808 0 0 0 0 1.616h15.084a.808.808 0 1 0 0-1.616z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const STRIKETHROUGH: IconDef = IconDef {
name: "StrikeThroughIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M8.406 7.464a3.468 3.468 0 0 1 6.59-1.513.77.77 0 0 0 1.385-.673 5.009 5.009 0 0 0-9.05 4.3h1.793a3.45 3.45 0 0 1-.718-2.114m6.512 8.476c0-.795-.268-1.528-.718-2.113h1.792a5.008 5.008 0 0 1-9.05 4.299.77.77 0 1 1 1.387-.673 3.468 3.468 0 0 0 6.589-1.513M4.297 10.905a.797.797 0 0 0 0 1.594h15.406a.797.797 0 0 0 0-1.594z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M8.406 7.464a3.468 3.468 0 0 1 6.59-1.513.77.77 0 0 0 1.385-.673 5.009 5.009 0 0 0-9.05 4.3h1.793a3.45 3.45 0 0 1-.718-2.114m6.512 8.476c0-.795-.268-1.528-.718-2.113h1.792a5.008 5.008 0 0 1-9.05 4.299.77.77 0 1 1 1.387-.673 3.468 3.468 0 0 0 6.589-1.513M4.297 10.905a.797.797 0 0 0 0 1.594h15.406a.797.797 0 0 0 0-1.594z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const DELETE: IconDef = IconDef {
name: "DeleteIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M10.75 11a.75.75 0 0 0-1.5 0v6a.75.75 0 0 0 1.5 0zM14 10.25a.75.75 0 0 1 .75.75v6a.75.75 0 0 1-1.5 0v-6a.75.75 0 0 1 .75-.75", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M11 2.25A2.75 2.75 0 0 0 8.25 5v1.15H4a.85.85 0 0 0 0 1.7h.309l.81 11.346a2.75 2.75 0 0 0 2.743 2.554h8.276a2.75 2.75 0 0 0 2.743-2.554l.81-11.346H20a.85.85 0 1 0 0-1.7h-4.25V5A2.75 2.75 0 0 0 13 2.25zm3.25 3.9V5c0-.69-.56-1.25-1.25-1.25h-2c-.69 0-1.25.56-1.25 1.25v1.15zm3.937 1.7H5.813l.802 11.24a1.25 1.25 0 0 0 1.247 1.16h8.276c.656 0 1.2-.507 1.247-1.16z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M10.75 11a.75.75 0 0 0-1.5 0v6a.75.75 0 0 0 1.5 0zM14 10.25a.75.75 0 0 1 .75.75v6a.75.75 0 0 1-1.5 0v-6a.75.75 0 0 1 .75-.75\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/><path d=\"M11 2.25A2.75 2.75 0 0 0 8.25 5v1.15H4a.85.85 0 0 0 0 1.7h.309l.81 11.346a2.75 2.75 0 0 0 2.743 2.554h8.276a2.75 2.75 0 0 0 2.743-2.554l.81-11.346H20a.85.85 0 1 0 0-1.7h-4.25V5A2.75 2.75 0 0 0 13 2.25zm3.25 3.9V5c0-.69-.56-1.25-1.25-1.25h-2c-.69 0-1.25.56-1.25 1.25v1.15zm3.937 1.7H5.813l.802 11.24a1.25 1.25 0 0 0 1.247 1.16h8.276c.656 0 1.2-.507 1.247-1.16z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const DRAG_HANDLE: IconDef = IconDef {
name: "DragCursorIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M10.694 3.62c.271-.661.934-1.12 1.693-1.12.993 0 1.823.786 1.823 1.786v.12c.248-.123.528-.192.822-.192.993 0 1.823.786 1.823 1.786v.978c.248-.123.528-.192.822-.192.994 0 1.823.786 1.823 1.785v6c0 3.84-3.198 6.929-7.113 6.929-.96 0-1.884-.131-2.777-.547-.893-.415-1.717-1.098-2.505-2.146l-3.208-4.001a1.755 1.755 0 0 1 .14-2.376 1.845 1.845 0 0 1 2.592.031l.563.653c.308.376.54.631.714.795v-.01c.015-.235.014-.525.013-.875V5.142c0-.999.83-1.785 1.823-1.785.347 0 .674.096.952.264m.87 7.523a.5.5 0 1 1-1 0v-6c0-.42-.354-.786-.822-.786s-.823.365-.823.786v7.865c.001.352.002.683-.015.952-.01.164-.027.329-.062.475a1 1 0 0 1-.236.467.69.69 0 0 1-.64.196 1.2 1.2 0 0 1-.497-.246c-.28-.214-.623-.582-1.046-1.099l-.535-.62a.845.845 0 0 0-1.153.014.756.756 0 0 0-.062 1.028l.003.003 3.214 4.01.01.012c.71.948 1.415 1.513 2.132 1.847.719.334 1.488.453 2.355.453 3.39 0 6.113-2.668 6.113-5.929v-6c0-.42-.355-.785-.823-.785s-.822.365-.822.785V12a.5.5 0 0 1-1 0V6c0-.42-.355-.786-.823-.786s-.822.365-.822.786v5.143a.5.5 0 0 1-1 0V4.286c0-.421-.355-.786-.823-.786s-.823.365-.823.786z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M11.064 11.643a.5.5 0 0 0 .5-.5V4.286c0-.421.355-.786.823-.786s.823.365.823.786v6.857a.5.5 0 1 0 1 0V6c0-.42.354-.786.822-.786s.823.365.823.786v6a.5.5 0 1 0 1 0V8.571c0-.42.355-.785.822-.785.468 0 .823.365.823.785v6c0 3.261-2.724 5.929-6.113 5.929-.867 0-1.636-.119-2.355-.453-.717-.334-1.421-.9-2.132-1.847l-.01-.013-3.214-4.009-.003-.003a.756.756 0 0 1 .062-1.028.845.845 0 0 1 1.153-.014l.535.62c.423.517.766.885 1.046 1.099.138.104.306.209.496.246a.69.69 0 0 0 .641-.196 1 1 0 0 0 .236-.467c.035-.146.052-.31.062-.475.017-.27.016-.6.015-.952V5.143c0-.42.355-.785.823-.785s.822.365.822.786v6a.5.5 0 0 0 .5.5", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M10.694 3.62c.271-.661.934-1.12 1.693-1.12.993 0 1.823.786 1.823 1.786v.12c.248-.123.528-.192.822-.192.993 0 1.823.786 1.823 1.786v.978c.248-.123.528-.192.822-.192.994 0 1.823.786 1.823 1.785v6c0 3.84-3.198 6.929-7.113 6.929-.96 0-1.884-.131-2.777-.547-.893-.415-1.717-1.098-2.505-2.146l-3.208-4.001a1.755 1.755 0 0 1 .14-2.376 1.845 1.845 0 0 1 2.592.031l.563.653c.308.376.54.631.714.795v-.01c.015-.235.014-.525.013-.875V5.142c0-.999.83-1.785 1.823-1.785.347 0 .674.096.952.264m.87 7.523a.5.5 0 1 1-1 0v-6c0-.42-.354-.786-.822-.786s-.823.365-.823.786v7.865c.001.352.002.683-.015.952-.01.164-.027.329-.062.475a1 1 0 0 1-.236.467.69.69 0 0 1-.64.196 1.2 1.2 0 0 1-.497-.246c-.28-.214-.623-.582-1.046-1.099l-.535-.62a.845.845 0 0 0-1.153.014.756.756 0 0 0-.062 1.028l.003.003 3.214 4.01.01.012c.71.948 1.415 1.513 2.132 1.847.719.334 1.488.453 2.355.453 3.39 0 6.113-2.668 6.113-5.929v-6c0-.42-.355-.785-.823-.785s-.822.365-.822.785V12a.5.5 0 0 1-1 0V6c0-.42-.355-.786-.823-.786s-.822.365-.822.786v5.143a.5.5 0 0 1-1 0V4.286c0-.421-.355-.786-.823-.786s-.823.365-.823.786z", fill_rule: "nonzero", clip_rule: "evenodd", fill: "none", stroke: "currentColor", stroke_width: 0.5_f32, stroke_linecap: "round", stroke_linejoin: "round" },
IconPath { d: "M11.064 11.643a.5.5 0 0 0 .5-.5V4.286c0-.421.355-.786.823-.786s.823.365.823.786v6.857a.5.5 0 1 0 1 0V6c0-.42.354-.786.822-.786s.823.365.823.786v6a.5.5 0 1 0 1 0V8.571c0-.42.355-.785.822-.785.468 0 .823.365.823.785v6c0 3.261-2.724 5.929-6.113 5.929-.867 0-1.636-.119-2.355-.453-.717-.334-1.421-.9-2.132-1.847l-.01-.013-3.214-4.009-.003-.003a.756.756 0 0 1 .062-1.028.845.845 0 0 1 1.153-.014l.535.62c.423.517.766.885 1.046 1.099.138.104.306.209.496.246a.69.69 0 0 0 .641-.196 1 1 0 0 0 .236-.467c.035-.146.052-.31.062-.475.017-.27.016-.6.015-.952V5.143c0-.42.355-.785.823-.785s.822.365.822.786v6a.5.5 0 0 0 .5.5", fill_rule: "nonzero", clip_rule: "nonzero", fill: "none", stroke: "currentColor", stroke_width: 0.5_f32, stroke_linecap: "round", stroke_linejoin: "round" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M10.694 3.62c.271-.661.934-1.12 1.693-1.12.993 0 1.823.786 1.823 1.786v.12c.248-.123.528-.192.822-.192.993 0 1.823.786 1.823 1.786v.978c.248-.123.528-.192.822-.192.994 0 1.823.786 1.823 1.785v6c0 3.84-3.198 6.929-7.113 6.929-.96 0-1.884-.131-2.777-.547-.893-.415-1.717-1.098-2.505-2.146l-3.208-4.001a1.755 1.755 0 0 1 .14-2.376 1.845 1.845 0 0 1 2.592.031l.563.653c.308.376.54.631.714.795v-.01c.015-.235.014-.525.013-.875V5.142c0-.999.83-1.785 1.823-1.785.347 0 .674.096.952.264m.87 7.523a.5.5 0 1 1-1 0v-6c0-.42-.354-.786-.822-.786s-.823.365-.823.786v7.865c.001.352.002.683-.015.952-.01.164-.027.329-.062.475a1 1 0 0 1-.236.467.69.69 0 0 1-.64.196 1.2 1.2 0 0 1-.497-.246c-.28-.214-.623-.582-1.046-1.099l-.535-.62a.845.845 0 0 0-1.153.014.756.756 0 0 0-.062 1.028l.003.003 3.214 4.01.01.012c.71.948 1.415 1.513 2.132 1.847.719.334 1.488.453 2.355.453 3.39 0 6.113-2.668 6.113-5.929v-6c0-.42-.355-.785-.823-.785s-.822.365-.822.785V12a.5.5 0 0 1-1 0V6c0-.42-.355-.786-.823-.786s-.822.365-.822.786v5.143a.5.5 0 0 1-1 0V4.286c0-.421-.355-.786-.823-.786s-.823.365-.823.786z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/><path d=\"M11.064 11.643a.5.5 0 0 0 .5-.5V4.286c0-.421.355-.786.823-.786s.823.365.823.786v6.857a.5.5 0 1 0 1 0V6c0-.42.354-.786.822-.786s.823.365.823.786v6a.5.5 0 1 0 1 0V8.571c0-.42.355-.785.822-.785.468 0 .823.365.823.785v6c0 3.261-2.724 5.929-6.113 5.929-.867 0-1.636-.119-2.355-.453-.717-.334-1.421-.9-2.132-1.847l-.01-.013-3.214-4.009-.003-.003a.756.756 0 0 1 .062-1.028.845.845 0 0 1 1.153-.014l.535.62c.423.517.766.885 1.046 1.099.138.104.306.209.496.246a.69.69 0 0 0 .641-.196 1 1 0 0 0 .236-.467c.035-.146.052-.31.062-.475.017-.27.016-.6.015-.952V5.143c0-.42.355-.785.823-.785s.822.365.822.786v6a.5.5 0 0 0 .5.5\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/><path d=\"M10.694 3.62c.271-.661.934-1.12 1.693-1.12.993 0 1.823.786 1.823 1.786v.12c.248-.123.528-.192.822-.192.993 0 1.823.786 1.823 1.786v.978c.248-.123.528-.192.822-.192.994 0 1.823.786 1.823 1.785v6c0 3.84-3.198 6.929-7.113 6.929-.96 0-1.884-.131-2.777-.547-.893-.415-1.717-1.098-2.505-2.146l-3.208-4.001a1.755 1.755 0 0 1 .14-2.376 1.845 1.845 0 0 1 2.592.031l.563.653c.308.376.54.631.714.795v-.01c.015-.235.014-.525.013-.875V5.142c0-.999.83-1.785 1.823-1.785.347 0 .674.096.952.264m.87 7.523a.5.5 0 1 1-1 0v-6c0-.42-.354-.786-.822-.786s-.823.365-.823.786v7.865c.001.352.002.683-.015.952-.01.164-.027.329-.062.475a1 1 0 0 1-.236.467.69.69 0 0 1-.64.196 1.2 1.2 0 0 1-.497-.246c-.28-.214-.623-.582-1.046-1.099l-.535-.62a.845.845 0 0 0-1.153.014.756.756 0 0 0-.062 1.028l.003.003 3.214 4.01.01.012c.71.948 1.415 1.513 2.132 1.847.719.334 1.488.453 2.355.453 3.39 0 6.113-2.668 6.113-5.929v-6c0-.42-.355-.785-.823-.785s-.822.365-.822.785V12a.5.5 0 0 1-1 0V6c0-.42-.355-.786-.823-.786s-.822.365-.822.786v5.143a.5.5 0 0 1-1 0V4.286c0-.421-.355-.786-.823-.786s-.823.365-.823.786z\" fill=\"none\" fill-rule=\"nonzero\" clip-rule=\"evenodd\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"0.5\"/><path d=\"M11.064 11.643a.5.5 0 0 0 .5-.5V4.286c0-.421.355-.786.823-.786s.823.365.823.786v6.857a.5.5 0 1 0 1 0V6c0-.42.354-.786.822-.786s.823.365.823.786v6a.5.5 0 1 0 1 0V8.571c0-.42.355-.785.822-.785.468 0 .823.365.823.785v6c0 3.261-2.724 5.929-6.113 5.929-.867 0-1.636-.119-2.355-.453-.717-.334-1.421-.9-2.132-1.847l-.01-.013-3.214-4.009-.003-.003a.756.756 0 0 1 .062-1.028.845.845 0 0 1 1.153-.014l.535.62c.423.517.766.885 1.046 1.099.138.104.306.209.496.246a.69.69 0 0 0 .641-.196 1 1 0 0 0 .236-.467c.035-.146.052-.31.062-.475.017-.27.016-.6.015-.952V5.143c0-.42.355-.785.823-.785s.822.365.822.786v6a.5.5 0 0 0 .5.5\" fill=\"none\" fill-rule=\"nonzero\" clip-rule=\"nonzero\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"0.5\"/></svg>",
};
pub const UNDO: IconDef = IconDef {
name: "UndoIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M8.53 4.47a.75.75 0 0 1 0 1.06L5.81 8.25h4.624c1.651 0 2.937 0 3.968.084 1.047.086 1.897.262 2.662.652a6.75 6.75 0 0 1 2.95 2.95c.39.765.566 1.615.652 2.662.084 1.031.084 2.317.084 3.968v.034a.75.75 0 0 1-1.5 0c0-1.693 0-2.917-.08-3.88-.077-.954-.228-1.585-.492-2.104a5.25 5.25 0 0 0-2.295-2.294c-.518-.264-1.15-.415-2.103-.493-.963-.078-2.187-.079-3.88-.079H5.81l2.72 2.72a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 0", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M8.53 4.47a.75.75 0 0 1 0 1.06L5.81 8.25h4.624c1.651 0 2.937 0 3.968.084 1.047.086 1.897.262 2.662.652a6.75 6.75 0 0 1 2.95 2.95c.39.765.566 1.615.652 2.662.084 1.031.084 2.317.084 3.968v.034a.75.75 0 0 1-1.5 0c0-1.693 0-2.917-.08-3.88-.077-.954-.228-1.585-.492-2.104a5.25 5.25 0 0 0-2.295-2.294c-.518-.264-1.15-.415-2.103-.493-.963-.078-2.187-.079-3.88-.079H5.81l2.72 2.72a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 0\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const REDO: IconDef = IconDef {
name: "RedoIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M15.47 4.47a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 1 1-1.06-1.06l2.72-2.72H13.6c-1.692 0-2.917 0-3.88.08-.954.077-1.585.228-2.103.492a5.25 5.25 0 0 0-2.295 2.295c-.264.518-.415 1.15-.493 2.103-.078.963-.079 2.187-.079 3.88a.75.75 0 0 1-1.5 0v-.034c0-1.651 0-2.937.084-3.968.086-1.047.262-1.897.652-2.662a6.75 6.75 0 0 1 2.95-2.95c.765-.39 1.615-.566 2.662-.652 1.031-.084 2.317-.084 3.968-.084h4.623l-2.72-2.72a.75.75 0 0 1 0-1.06", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M15.47 4.47a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 1 1-1.06-1.06l2.72-2.72H13.6c-1.692 0-2.917 0-3.88.08-.954.077-1.585.228-2.103.492a5.25 5.25 0 0 0-2.295 2.295c-.264.518-.415 1.15-.493 2.103-.078.963-.079 2.187-.079 3.88a.75.75 0 0 1-1.5 0v-.034c0-1.651 0-2.937.084-3.968.086-1.047.262-1.897.652-2.662a6.75 6.75 0 0 1 2.95-2.95c.765-.39 1.615-.566 2.662-.652 1.031-.084 2.317-.084 3.968-.084h4.623l-2.72-2.72a.75.75 0 0 1 0-1.06\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const RIGHT_TAB: IconDef = IconDef {
name: "RightTabIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M9.09 5.884a.75.75 0 0 1 .75-.75h10.146a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M9.09 10.196a.75.75 0 0 1 .75-.75h10.146a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M9.84 13.758a.75.75 0 0 0 0 1.5h10.146a.75.75 0 0 0 0-1.5zM9.09 18.82a.75.75 0 0 1 .75-.75h5.099a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M3 10.514v3.597c0 .441.486.71.86.476l2.877-1.798a.562.562 0 0 0 0-.953L3.86 10.038a.562.562 0 0 0-.86.476", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M9.09 5.884a.75.75 0 0 1 .75-.75h10.146a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M9.09 10.196a.75.75 0 0 1 .75-.75h10.146a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M9.84 13.758a.75.75 0 0 0 0 1.5h10.146a.75.75 0 0 0 0-1.5zM9.09 18.82a.75.75 0 0 1 .75-.75h5.099a.75.75 0 0 1 0 1.5H9.84a.75.75 0 0 1-.75-.75M3 10.514v3.597c0 .441.486.71.86.476l2.877-1.798a.562.562 0 0 0 0-.953L3.86 10.038a.562.562 0 0 0-.86.476\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const COLLAPSE_TAB: IconDef = IconDef {
name: "CollapseTabIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M14.91 5.884a.75.75 0 0 0-.75-.75H4.014a.75.75 0 0 0 0 1.5H14.16a.75.75 0 0 0 .75-.75M14.91 10.196a.75.75 0 0 0-.75-.75H4.014a.75.75 0 0 0 0 1.5H14.16a.75.75 0 0 0 .75-.75M14.16 13.758a.75.75 0 1 1 0 1.5H4.014a.75.75 0 0 1 0-1.5zM9.91 18.82a.75.75 0 0 0-.75-.75H4.06a.75.75 0 0 0 0 1.5H9.16a.75.75 0 0 0 .75-.75M21 10.514v3.597c0 .441-.486.71-.86.476l-2.877-1.798a.562.562 0 0 1 0-.953l2.877-1.798a.562.562 0 0 1 .86.476", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M14.91 5.884a.75.75 0 0 0-.75-.75H4.014a.75.75 0 0 0 0 1.5H14.16a.75.75 0 0 0 .75-.75M14.91 10.196a.75.75 0 0 0-.75-.75H4.014a.75.75 0 0 0 0 1.5H14.16a.75.75 0 0 0 .75-.75M14.16 13.758a.75.75 0 1 1 0 1.5H4.014a.75.75 0 0 1 0-1.5zM9.91 18.82a.75.75 0 0 0-.75-.75H4.06a.75.75 0 0 0 0 1.5H9.16a.75.75 0 0 0 .75-.75M21 10.514v3.597c0 .441-.486.71-.86.476l-2.877-1.798a.562.562 0 0 1 0-.953l2.877-1.798a.562.562 0 0 1 .86.476\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const KEYBOARD: IconDef = IconDef {
name: "KeyboardIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6.997 8.92a1 1 0 1 0-1.993.16 1 1 0 0 0 1.993-.16m8.508 3.16a1 1 0 1 0 1.993-.16 1 1 0 0 0-1.993.16m-1.001-.16a1 1 0 1 0-1.993.16 1 1 0 0 0 1.993-.16M7.999 9.08a1 1 0 1 0 1.993-.16 1 1 0 0 0-1.993.16M2.25 7A2.75 2.75 0 0 1 5 4.25h14A2.75 2.75 0 0 1 21.75 7v10A2.75 2.75 0 0 1 19 19.75H5A2.75 2.75 0 0 1 2.25 17zM5 5.75c-.69 0-1.25.56-1.25 1.25v10c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V7c0-.69-.56-1.25-1.25-1.25zm1 9.5a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H6.75a.75.75 0 0 1-.75-.75m5.213-3.958A1 1 0 1 0 9.8 12.708a1 1 0 0 0 1.414-1.416m-3 0a1 1 0 1 0-1.415 1.415 1 1 0 0 0 1.415-1.415m4.49-3a1 1 0 1 0-1.414 1.416 1 1 0 0 0 1.415-1.415m3.001 0a1 1 0 1 0-1.414 1.415 1 1 0 0 0 1.414-1.414m3.001 0a1 1 0 1 0-1.415 1.416 1 1 0 0 0 1.415-1.415", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6.997 8.92a1 1 0 1 0-1.993.16 1 1 0 0 0 1.993-.16m8.508 3.16a1 1 0 1 0 1.993-.16 1 1 0 0 0-1.993.16m-1.001-.16a1 1 0 1 0-1.993.16 1 1 0 0 0 1.993-.16M7.999 9.08a1 1 0 1 0 1.993-.16 1 1 0 0 0-1.993.16M2.25 7A2.75 2.75 0 0 1 5 4.25h14A2.75 2.75 0 0 1 21.75 7v10A2.75 2.75 0 0 1 19 19.75H5A2.75 2.75 0 0 1 2.25 17zM5 5.75c-.69 0-1.25.56-1.25 1.25v10c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V7c0-.69-.56-1.25-1.25-1.25zm1 9.5a.75.75 0 0 1 .75-.75h10.5a.75.75 0 0 1 0 1.5H6.75a.75.75 0 0 1-.75-.75m5.213-3.958A1 1 0 1 0 9.8 12.708a1 1 0 0 0 1.414-1.416m-3 0a1 1 0 1 0-1.415 1.415 1 1 0 0 0 1.415-1.415m4.49-3a1 1 0 1 0-1.414 1.416 1 1 0 0 0 1.415-1.415m3.001 0a1 1 0 1 0-1.414 1.415 1 1 0 0 0 1.414-1.414m3.001 0a1 1 0 1 0-1.415 1.416 1 1 0 0 0 1.415-1.415\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const TEX: IconDef = IconDef {
name: "TeXIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "m21.63 7.299-2.115 3.107 3.142 4.671c.284.41.428.481 1.343.481v.351c-.347-.028-1.061-.028-1.43-.028-.472 0-1.17 0-1.628.028v-.35c.5-.03.628-.28.628-.395 0-.043 0-.087-.112-.247l-2.486-3.714-2.286 3.39a.62.62 0 0 0-.142.395c0 .234.128.524.57.568v.35c-.356-.027-1.027-.027-1.413-.027h-.106l-.446 3.187H7.713v-.35c1.014 0 1.174 0 1.174-.654v-7.837c0-.653-.162-.653-1.174-.653v-.4h.752c-.183-2.354-.412-2.766-2.58-2.766h-.784c-.257.06-.257.234-.257.554v7.906c0 .525.042.685 1.228.685h.399v.35h-.015c-.68-.013-1.392-.027-2.085-.027s-1.4.014-2.079.027H2.27v-.35h.405c1.204 0 1.247-.16 1.247-.685V6.96c0-.334 0-.51-.273-.554H2.86c-2.216 0-2.418.421-2.603 2.827H0L.241 6.02h8.251l.23 3.152h6.226l.343 3.212h-.257c-.2-1.92-.458-2.813-2.67-2.813h-1.953c-.57 0-.598.073-.598.563v3.6h1.349c1.347 0 1.476-.493 1.476-1.698h.23v3.778h-.23c0-1.226-.128-1.728-1.476-1.728H9.814v4.06c0 .5.026.573.597.573h1.984c2.318 0 2.655-.996 2.939-2.84-.294.002-.621.008-.846.027v-.351c.273 0 1.202-.016 1.815-.919l2.486-3.69-2.757-4.115c-.315-.451-.572-.481-1.357-.481V6c.345.028 1.06.028 1.43.028.47 0 1.17 0 1.627-.028v.35c-.473.014-.63.262-.63.392 0 .044.015.09.114.248l2.114 3.145 1.887-2.78c.1-.145.17-.262.17-.436 0-.234-.112-.525-.57-.568V6c.357.028.943.028 1.414.028.343 0 .886 0 1.213-.028v.35c-1.168.016-1.6.639-1.812.945z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"m21.63 7.299-2.115 3.107 3.142 4.671c.284.41.428.481 1.343.481v.351c-.347-.028-1.061-.028-1.43-.028-.472 0-1.17 0-1.628.028v-.35c.5-.03.628-.28.628-.395 0-.043 0-.087-.112-.247l-2.486-3.714-2.286 3.39a.62.62 0 0 0-.142.395c0 .234.128.524.57.568v.35c-.356-.027-1.027-.027-1.413-.027h-.106l-.446 3.187H7.713v-.35c1.014 0 1.174 0 1.174-.654v-7.837c0-.653-.162-.653-1.174-.653v-.4h.752c-.183-2.354-.412-2.766-2.58-2.766h-.784c-.257.06-.257.234-.257.554v7.906c0 .525.042.685 1.228.685h.399v.35h-.015c-.68-.013-1.392-.027-2.085-.027s-1.4.014-2.079.027H2.27v-.35h.405c1.204 0 1.247-.16 1.247-.685V6.96c0-.334 0-.51-.273-.554H2.86c-2.216 0-2.418.421-2.603 2.827H0L.241 6.02h8.251l.23 3.152h6.226l.343 3.212h-.257c-.2-1.92-.458-2.813-2.67-2.813h-1.953c-.57 0-.598.073-.598.563v3.6h1.349c1.347 0 1.476-.493 1.476-1.698h.23v3.778h-.23c0-1.226-.128-1.728-1.476-1.728H9.814v4.06c0 .5.026.573.597.573h1.984c2.318 0 2.655-.996 2.939-2.84-.294.002-.621.008-.846.027v-.351c.273 0 1.202-.016 1.815-.919l2.486-3.69-2.757-4.115c-.315-.451-.572-.481-1.357-.481V6c.345.028 1.06.028 1.43.028.47 0 1.17 0 1.627-.028v.35c-.473.014-.63.262-.63.392 0 .044.015.09.114.248l2.114 3.145 1.887-2.78c.1-.145.17-.262.17-.436 0-.234-.112-.525-.57-.568V6c.357.028.943.028 1.414.028.343 0 .886 0 1.213-.028v.35c-1.168.016-1.6.639-1.812.945z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const MORE_HORIZONTAL: IconDef = IconDef {
name: "MoreHorizontalIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.5 12a1.73 1.73 0 1 0 3.462 0A1.73 1.73 0 0 0 4.5 12m7.5 1.73a1.73 1.73 0 1 1 0-3.46 1.73 1.73 0 0 1 0 3.46m5.77 0a1.73 1.73 0 1 1 0-3.46 1.73 1.73 0 0 1 0 3.46", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.5 12a1.73 1.73 0 1 0 3.462 0A1.73 1.73 0 0 0 4.5 12m7.5 1.73a1.73 1.73 0 1 1 0-3.46 1.73 1.73 0 0 1 0 3.46m5.77 0a1.73 1.73 0 1 1 0-3.46 1.73 1.73 0 0 1 0 3.46\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const INFORMATION: IconDef = IconDef {
name: "InformationIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.75 12a8.25 8.25 0 1 1 16.5 0 8.25 8.25 0 0 1-16.5 0M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25M13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-1 2.75a.75.75 0 0 1 .75.75v5a.75.75 0 0 1-1.5 0v-5a.75.75 0 0 1 .75-.75", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.75 12a8.25 8.25 0 1 1 16.5 0 8.25 8.25 0 0 1-16.5 0M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25M13 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0m-1 2.75a.75.75 0 0 1 .75.75v5a.75.75 0 0 1-1.5 0v-5a.75.75 0 0 1 .75-.75\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const WARNING: IconDef = IconDef {
name: "WarningIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M12 4.75a7.25 7.25 0 1 0 0 14.5 7.25 7.25 0 0 0 0-14.5M3.25 12a8.75 8.75 0 1 1 17.5 0 8.75 8.75 0 0 1-17.5 0M12 7.694a.75.75 0 0 1 .75.75V12a.75.75 0 0 1-1.5 0V8.444a.75.75 0 0 1 .75-.75m-.75 7.862a.75.75 0 0 1 .75-.75h.009a.75.75 0 1 1 0 1.5H12a.75.75 0 0 1-.75-.75", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M12 4.75a7.25 7.25 0 1 0 0 14.5 7.25 7.25 0 0 0 0-14.5M3.25 12a8.75 8.75 0 1 1 17.5 0 8.75 8.75 0 0 1-17.5 0M12 7.694a.75.75 0 0 1 .75.75V12a.75.75 0 0 1-1.5 0V8.444a.75.75 0 0 1 .75-.75m-.75 7.862a.75.75 0 0 1 .75-.75h.009a.75.75 0 1 1 0 1.5H12a.75.75 0 0 1-.75-.75\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const SHAPE: IconDef = IconDef {
name: "ShapeIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M12 3.25a.75.75 0 0 1 .651.378l3.556 6.222a.75.75 0 0 1-.651 1.122H8.444a.75.75 0 0 1-.65-1.122l3.555-6.222A.75.75 0 0 1 12 3.25M9.737 9.472h4.526L12 5.512zM7.11 14.528a2.361 2.361 0 1 0 0 4.722 2.361 2.361 0 0 0 0-4.722m-3.861 2.36a3.861 3.861 0 1 1 7.722 0 3.861 3.861 0 0 1-7.722 0m9.778-3.11a.75.75 0 0 1 .75-.75H20a.75.75 0 0 1 .75.75V20a.75.75 0 0 1-.75.75h-6.222a.75.75 0 0 1-.75-.75zm1.5.75v4.722h4.722v-4.722z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M12 3.25a.75.75 0 0 1 .651.378l3.556 6.222a.75.75 0 0 1-.651 1.122H8.444a.75.75 0 0 1-.65-1.122l3.555-6.222A.75.75 0 0 1 12 3.25M9.737 9.472h4.526L12 5.512zM7.11 14.528a2.361 2.361 0 1 0 0 4.722 2.361 2.361 0 0 0 0-4.722m-3.861 2.36a3.861 3.861 0 1 1 7.722 0 3.861 3.861 0 0 1-7.722 0m9.778-3.11a.75.75 0 0 1 .75-.75H20a.75.75 0 0 1 .75.75V20a.75.75 0 0 1-.75.75h-6.222a.75.75 0 0 1-.75-.75zm1.5.75v4.722h4.722v-4.722z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const SQUARE: IconDef = IconDef {
name: "SquareIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.25 3.25h17.5v17.5H3.25zm1.5 1.5v14.5h14.5V4.75z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.25 3.25h17.5v17.5H3.25zm1.5 1.5v14.5h14.5V4.75z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ROUNDED_RECTANGLE: IconDef = IconDef {
name: "RoundedRectangleIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M2.25 7A2.75 2.75 0 0 1 5 4.25h14A2.75 2.75 0 0 1 21.75 7v10A2.75 2.75 0 0 1 19 19.75H5A2.75 2.75 0 0 1 2.25 17zM5 5.75c-.69 0-1.25.56-1.25 1.25v10c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V7c0-.69-.56-1.25-1.25-1.25z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M2.25 7A2.75 2.75 0 0 1 5 4.25h14A2.75 2.75 0 0 1 21.75 7v10A2.75 2.75 0 0 1 19 19.75H5A2.75 2.75 0 0 1 2.25 17zM5 5.75c-.69 0-1.25.56-1.25 1.25v10c0 .69.56 1.25 1.25 1.25h14c.69 0 1.25-.56 1.25-1.25V7c0-.69-.56-1.25-1.25-1.25z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const DIAMOND: IconDef = IconDef {
name: "DiamondIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M12 1.94 22.06 12 12 22.06 1.94 12zM4.06 12 12 19.94 19.94 12 12 4.06z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M12 1.94 22.06 12 12 22.06 1.94 12zM4.06 12 12 19.94 19.94 12 12 4.06z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const TRIANGLE: IconDef = IconDef {
name: "TriangleIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "m12 2.5 9.96 17.25H2.04zm0 3L4.64 18.25H19.36z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"m12 2.5 9.96 17.25H2.04zm0 3L4.64 18.25H19.36z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const CONNECTOR_STRAIGHT: IconDef = IconDef {
name: "ConnectorLIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M13 3.25a.75.75 0 0 0 0 1.5h5.19L3.47 19.47a.75.75 0 1 0 1.06 1.06L19.25 5.81V11a.75.75 0 0 0 1.5 0V4.1a.85.85 0 0 0-.85-.85z", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M13 3.25a.75.75 0 0 0 0 1.5h5.19L3.47 19.47a.75.75 0 1 0 1.06 1.06L19.25 5.81V11a.75.75 0 0 0 1.5 0V4.1a.85.85 0 0 0-.85-.85z\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const CONNECTOR_ELBOW: IconDef = IconDef {
name: "ConnectorEIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M17.03 2.02a.75.75 0 1 0-1.06 1.06l3.67 3.67H14a2.75 2.75 0 0 0-2.75 2.75V18c0 .69-.56 1.25-1.25 1.25H3a.75.75 0 0 0 0 1.5h7A2.75 2.75 0 0 0 12.75 18V9.5c0-.69.56-1.25 1.25-1.25h5.64l-3.67 3.67a.75.75 0 1 0 1.06 1.06l4.88-4.879a.85.85 0 0 0 0-1.202z", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M17.03 2.02a.75.75 0 1 0-1.06 1.06l3.67 3.67H14a2.75 2.75 0 0 0-2.75 2.75V18c0 .69-.56 1.25-1.25 1.25H3a.75.75 0 0 0 0 1.5h7A2.75 2.75 0 0 0 12.75 18V9.5c0-.69.56-1.25 1.25-1.25h5.64l-3.67 3.67a.75.75 0 1 0 1.06 1.06l4.88-4.879a.85.85 0 0 0 0-1.202z\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const CONNECTOR_CURVE: IconDef = IconDef {
name: "ConnectorCIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M15.97 2.02a.75.75 0 0 1 1.06 0l4.88 4.879a.85.85 0 0 1 0 1.202l-4.88 4.88a.75.75 0 1 1-1.06-1.062l3.67-3.669H18c-3.151 0-4.552.758-5.25 1.662-.745.963-.873 2.28-1.002 3.898l-.008.101c-.119 1.486-.259 3.245-1.303 4.595C9.323 19.946 7.349 20.75 4 20.75a.75.75 0 0 1 0-1.5c3.151 0 4.552-.758 5.25-1.662.745-.963.873-2.28 1.002-3.898l.008-.101c.119-1.486.259-3.245 1.303-4.595C12.677 7.554 14.651 6.75 18 6.75h1.64l-3.67-3.67a.75.75 0 0 1 0-1.06", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M15.97 2.02a.75.75 0 0 1 1.06 0l4.88 4.879a.85.85 0 0 1 0 1.202l-4.88 4.88a.75.75 0 1 1-1.06-1.062l3.67-3.669H18c-3.151 0-4.552.758-5.25 1.662-.745.963-.873 2.28-1.002 3.898l-.008.101c-.119 1.486-.259 3.245-1.303 4.595C9.323 19.946 7.349 20.75 4 20.75a.75.75 0 0 1 0-1.5c3.151 0 4.552-.758 5.25-1.662.745-.963.873-2.28 1.002-3.898l.008-.101c.119-1.486.259-3.245 1.303-4.595C12.677 7.554 14.651 6.75 18 6.75h1.64l-3.67-3.67a.75.75 0 0 1 0-1.06\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const BRUSH: IconDef = IconDef {
name: "BrushIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.25 4.968a.75.75 0 0 1 .782-.717 84 84 0 0 1 7.141.63c1.323.178 2.63.398 3.77.664 1.127.263 2.15.585 2.873.987.228.127.444.275.61.453.164.177.347.461.322.832s-.243.623-.417.766a2.2 2.2 0 0 1-.582.327c-.759.302-2.052.501-3.404.663-.818.098-1.716.187-2.593.275-.594.06-1.178.118-1.723.177q-.416.045-.797.091l.953.142c2.324.342 5.287.777 7.09 1.48.16.064.41.177.585.394a.88.88 0 0 1 .198.551.9.9 0 0 1-.18.532 1.4 1.4 0 0 1-.513.393 4 4 0 0 1-.543.208c-.767.242-1.994.482-3.266.725l-.406.078c-1.175.223-2.39.454-3.412.701a14 14 0 0 0-1.443.413 5 5 0 0 0-.37.15c.295.23.799.507 1.466.801 1.43.631 3.34 1.232 4.669 1.592a.75.75 0 0 1-.393 1.448c-1.361-.37-3.352-.993-4.88-1.668-.75-.33-1.46-.703-1.921-1.102-.222-.192-.478-.467-.58-.828a1.13 1.13 0 0 1 .002-.636c.065-.217.188-.391.327-.527.293-.286.746-.487 1.17-.64a16 16 0 0 1 1.602-.461c1.06-.256 2.312-.494 3.48-.716l.408-.078a75 75 0 0 0 1.951-.392c-1.57-.39-3.545-.681-5.299-.94l-.605-.09c-1.197-.178-2.29-.35-2.908-.545a2.2 2.2 0 0 1-.483-.206c-.098-.06-.459-.292-.473-.755-.015-.48.35-.732.46-.802.159-.102.352-.177.54-.239.76-.247 2.049-.417 3.408-.565.577-.063 1.172-.122 1.767-.182.86-.086 1.722-.171 2.534-.269 1.066-.127 1.954-.264 2.556-.42-.527-.231-1.248-.453-2.12-.657-1.08-.252-2.335-.464-3.63-.64a82 82 0 0 0-7.005-.617.75.75 0 0 1-.717-.78m13.543 8.197-.006-.004zm-.035-.931", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.25 4.968a.75.75 0 0 1 .782-.717 84 84 0 0 1 7.141.63c1.323.178 2.63.398 3.77.664 1.127.263 2.15.585 2.873.987.228.127.444.275.61.453.164.177.347.461.322.832s-.243.623-.417.766a2.2 2.2 0 0 1-.582.327c-.759.302-2.052.501-3.404.663-.818.098-1.716.187-2.593.275-.594.06-1.178.118-1.723.177q-.416.045-.797.091l.953.142c2.324.342 5.287.777 7.09 1.48.16.064.41.177.585.394a.88.88 0 0 1 .198.551.9.9 0 0 1-.18.532 1.4 1.4 0 0 1-.513.393 4 4 0 0 1-.543.208c-.767.242-1.994.482-3.266.725l-.406.078c-1.175.223-2.39.454-3.412.701a14 14 0 0 0-1.443.413 5 5 0 0 0-.37.15c.295.23.799.507 1.466.801 1.43.631 3.34 1.232 4.669 1.592a.75.75 0 0 1-.393 1.448c-1.361-.37-3.352-.993-4.88-1.668-.75-.33-1.46-.703-1.921-1.102-.222-.192-.478-.467-.58-.828a1.13 1.13 0 0 1 .002-.636c.065-.217.188-.391.327-.527.293-.286.746-.487 1.17-.64a16 16 0 0 1 1.602-.461c1.06-.256 2.312-.494 3.48-.716l.408-.078a75 75 0 0 0 1.951-.392c-1.57-.39-3.545-.681-5.299-.94l-.605-.09c-1.197-.178-2.29-.35-2.908-.545a2.2 2.2 0 0 1-.483-.206c-.098-.06-.459-.292-.473-.755-.015-.48.35-.732.46-.802.159-.102.352-.177.54-.239.76-.247 2.049-.417 3.408-.565.577-.063 1.172-.122 1.767-.182.86-.086 1.722-.171 2.534-.269 1.066-.127 1.954-.264 2.556-.42-.527-.231-1.248-.453-2.12-.657-1.08-.252-2.335-.464-3.63-.64a82 82 0 0 0-7.005-.617.75.75 0 0 1-.717-.78m13.543 8.197-.006-.004zm-.035-.931\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const PEN: IconDef = IconDef {
name: "PenIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M19.279 4.721a1.614 1.614 0 0 0-2.28 0l-.885.883 2.278 2.273.887-.885a1.603 1.603 0 0 0 0-2.271M17.33 8.937l-2.277-2.273L4.25 17.445v2.305h2.245zm-1.39-5.278a3.114 3.114 0 0 1 4.398 0 3.103 3.103 0 0 1 0 4.395L7.335 21.03a.75.75 0 0 1-.53.22H3.5a.75.75 0 0 1-.75-.75v-3.367c0-.2.08-.39.22-.53z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M19.279 4.721a1.614 1.614 0 0 0-2.28 0l-.885.883 2.278 2.273.887-.885a1.603 1.603 0 0 0 0-2.271M17.33 8.937l-2.277-2.273L4.25 17.445v2.305h2.245zm-1.39-5.278a3.114 3.114 0 0 1 4.398 0 3.103 3.103 0 0 1 0 4.395L7.335 21.03a.75.75 0 0 1-.53.22H3.5a.75.75 0 0 1-.75-.75v-3.367c0-.2.08-.39.22-.53z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const HAND: IconDef = IconDef {
name: "HandIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M14.733 20.75a11.3 11.3 0 0 1-4.415-.993l-5.44-2.56a2.238 2.238 0 0 1-1.06-2.967c.251-.533.703-.944 1.256-1.144a2.2 2.2 0 0 1 1.694.081l1.016.479c-.477-1.621-1.431-4.305-2.862-5.873l-.883-.717a2.145 2.145 0 0 1 1.014-3.78 2.14 2.14 0 0 1 1.565.36A12.1 12.1 0 0 1 9.39 6.4c.26-.389.637-.684 1.077-.841a2.15 2.15 0 0 1 1.687.08c.235.11.45.26.636.442.238-.27.542-.475.883-.593a2.02 2.02 0 0 1 1.572.08c.279.126.524.318.715.558q.148-.097.318-.15a1.55 1.55 0 0 1 1.987.938l2.11 5.881a6.5 6.5 0 0 1 0 4.35 5.32 5.32 0 0 1-3.223 3.232c-.78.26-1.598.385-2.42.372m-8.802-6.414c-.128-.027-.32-.035-.417 0a.88.88 0 0 0-.512.461.89.89 0 0 0 .433 1.196l5.404 2.613s3.197 1.488 5.828.54a3.9 3.9 0 0 0 2.438-2.41 5.13 5.13 0 0 0 0-3.445l-2.12-5.881a.22.22 0 0 0-.202-.157.23.23 0 0 0-.222.307l.3.886a.664.664 0 0 1-.397.886.66.66 0 0 1-.883-.399l-.583-1.63a.8.8 0 0 0-.38-.416.71.71 0 0 0-.556 0 .725.725 0 0 0-.468.886l.247.93a.657.657 0 0 1-.45.797.65.65 0 0 1-.812-.407l-.583-1.612a.885.885 0 0 0-1.122-.523.884.884 0 0 0-.52 1.125l.423 1.187a.67.67 0 0 1-.397.886.66.66 0 0 1-.883-.399A10.23 10.23 0 0 0 5.77 4.921a.793.793 0 0 0-1.104.177c-.127.168-.116.326-.091.536.024.21.13.402.293.536l.883.744.061.062C8.223 9.57 9.345 14.637 9.39 14.85a.67.67 0 0 1-.239.664.67.67 0 0 1-.688.08l-1.54-.797c-.385-.21-.466-.282-.991-.46", fill_rule: "nonzero", clip_rule: "nonzero", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M14.733 20.75a11.3 11.3 0 0 1-4.415-.993l-5.44-2.56a2.238 2.238 0 0 1-1.06-2.967c.251-.533.703-.944 1.256-1.144a2.2 2.2 0 0 1 1.694.081l1.016.479c-.477-1.621-1.431-4.305-2.862-5.873l-.883-.717a2.145 2.145 0 0 1 1.014-3.78 2.14 2.14 0 0 1 1.565.36A12.1 12.1 0 0 1 9.39 6.4c.26-.389.637-.684 1.077-.841a2.15 2.15 0 0 1 1.687.08c.235.11.45.26.636.442.238-.27.542-.475.883-.593a2.02 2.02 0 0 1 1.572.08c.279.126.524.318.715.558q.148-.097.318-.15a1.55 1.55 0 0 1 1.987.938l2.11 5.881a6.5 6.5 0 0 1 0 4.35 5.32 5.32 0 0 1-3.223 3.232c-.78.26-1.598.385-2.42.372m-8.802-6.414c-.128-.027-.32-.035-.417 0a.88.88 0 0 0-.512.461.89.89 0 0 0 .433 1.196l5.404 2.613s3.197 1.488 5.828.54a3.9 3.9 0 0 0 2.438-2.41 5.13 5.13 0 0 0 0-3.445l-2.12-5.881a.22.22 0 0 0-.202-.157.23.23 0 0 0-.222.307l.3.886a.664.664 0 0 1-.397.886.66.66 0 0 1-.883-.399l-.583-1.63a.8.8 0 0 0-.38-.416.71.71 0 0 0-.556 0 .725.725 0 0 0-.468.886l.247.93a.657.657 0 0 1-.45.797.65.65 0 0 1-.812-.407l-.583-1.612a.885.885 0 0 0-1.122-.523.884.884 0 0 0-.52 1.125l.423 1.187a.67.67 0 0 1-.397.886.66.66 0 0 1-.883-.399A10.23 10.23 0 0 0 5.77 4.921a.793.793 0 0 0-1.104.177c-.127.168-.116.326-.091.536.024.21.13.402.293.536l.883.744.061.062C8.223 9.57 9.345 14.637 9.39 14.85a.67.67 0 0 1-.239.664.67.67 0 0 1-.688.08l-1.54-.797c-.385-.21-.466-.282-.991-.46\" fill=\"#000\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const SELECT: IconDef = IconDef {
name: "SelectIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.012 4.35c-.17-1.5 1.514-2.496 2.748-1.625l13.222 9.336c1.383.976.712 3.15-.98 3.179l-6.661.11a.25.25 0 0 0-.213.127L9.066 20.88c-.836 1.475-3.071 1.019-3.261-.666zm1.883-.4a.25.25 0 0 0-.393.232l1.793 15.863a.25.25 0 0 0 .466.095l3.061-5.403a1.75 1.75 0 0 1 1.494-.887l6.66-.11a.25.25 0 0 0 .141-.454z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.012 4.35c-.17-1.5 1.514-2.496 2.748-1.625l13.222 9.336c1.383.976.712 3.15-.98 3.179l-6.661.11a.25.25 0 0 0-.213.127L9.066 20.88c-.836 1.475-3.071 1.019-3.261-.666zm1.883-.4a.25.25 0 0 0-.393.232l1.793 15.863a.25.25 0 0 0 .466.095l3.061-5.403a1.75 1.75 0 0 1 1.494-.887l6.66-.11a.25.25 0 0 0 .141-.454z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const NOTE: IconDef = IconDef {
name: "NoteShadowDuotoneIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.25 5A2.75 2.75 0 0 1 6 2.25h9A2.75 2.75 0 0 1 17.75 5v10.857a2.75 2.75 0 0 1-2.75 2.75H6a2.75 2.75 0 0 1-2.75-2.75zM6 3.75c-.69 0-1.25.56-1.25 1.25v10.857c0 .69.56 1.25 1.25 1.25h9c.69 0 1.25-.56 1.25-1.25V5c0-.69-.56-1.25-1.25-1.25z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "#7A7A7A", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M6.25 18.607H15a2.75 2.75 0 0 0 2.75-2.75V5.25H18A2.75 2.75 0 0 1 20.75 8v10.857a2.75 2.75 0 0 1-2.75 2.75H9a2.75 2.75 0 0 1-2.75-2.75z", fill_rule: "nonzero", clip_rule: "nonzero", fill: "#B3B3B3", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.25 5A2.75 2.75 0 0 1 6 2.25h9A2.75 2.75 0 0 1 17.75 5v10.857a2.75 2.75 0 0 1-2.75 2.75H6a2.75 2.75 0 0 1-2.75-2.75zM6 3.75c-.69 0-1.25.56-1.25 1.25v10.857c0 .69.56 1.25 1.25 1.25h9c.69 0 1.25-.56 1.25-1.25V5c0-.69-.56-1.25-1.25-1.25z\" fill=\"#7A7A7A\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/><path d=\"M6.25 18.607H15a2.75 2.75 0 0 0 2.75-2.75V5.25H18A2.75 2.75 0 0 1 20.75 8v10.857a2.75 2.75 0 0 1-2.75 2.75H9a2.75 2.75 0 0 1-2.75-2.75z\" fill=\"#B3B3B3\" fill-rule=\"nonzero\" clip-rule=\"nonzero\"/></svg>",
};
pub const FRAME: IconDef = IconDef {
name: "FrameIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M7 20.75a.75.75 0 0 1-.75-.75v-2.25H4a.75.75 0 0 1 0-1.5h2.25v-8.5H4a.75.75 0 0 1 0-1.5h2.25V4a.75.75 0 0 1 1.5 0v2.25h8.5V4a.75.75 0 0 1 1.5 0v2.25H20a.75.75 0 0 1 0 1.5h-2.25v8.5H20a.75.75 0 0 1 0 1.5h-2.25V20a.75.75 0 0 1-1.5 0v-2.25h-8.5V20a.75.75 0 0 1-.75.75m9.25-4.5v-8.5h-8.5v8.5z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M7 20.75a.75.75 0 0 1-.75-.75v-2.25H4a.75.75 0 0 1 0-1.5h2.25v-8.5H4a.75.75 0 0 1 0-1.5h2.25V4a.75.75 0 0 1 1.5 0v2.25h8.5V4a.75.75 0 0 1 1.5 0v2.25H20a.75.75 0 0 1 0 1.5h-2.25v8.5H20a.75.75 0 0 1 0 1.5h-2.25V20a.75.75 0 0 1-1.5 0v-2.25h-8.5V20a.75.75 0 0 1-.75.75m9.25-4.5v-8.5h-8.5v8.5z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const TEXT: IconDef = IconDef {
name: "TextIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M3.25 4A.75.75 0 0 1 4 3.25h16a.75.75 0 0 1 .75.75v2.667a.75.75 0 0 1-1.5 0V4.75h-6.5v14.5H16a.75.75 0 0 1 0 1.5H8a.75.75 0 0 1 0-1.5h3.25V4.75h-6.5v1.917a.75.75 0 0 1-1.5 0z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M3.25 4A.75.75 0 0 1 4 3.25h16a.75.75 0 0 1 .75.75v2.667a.75.75 0 0 1-1.5 0V4.75h-6.5v14.5H16a.75.75 0 0 1 0 1.5H8a.75.75 0 0 1 0-1.5h3.25V4.75h-6.5v1.917a.75.75 0 0 1-1.5 0z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ADD_TEXT: IconDef = IconDef {
name: "AddTextIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M6.25 5A.75.75 0 0 1 7 4.25h14a.75.75 0 0 1 .75.75v2.333a.75.75 0 0 1-1.5 0V5.75h-5.5v12.5h2.75a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1 0-1.5h2.75V5.75h-5.5v1.583a.75.75 0 1 1-1.5 0z", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M1.25 13a.75.75 0 0 1 .75-.75h5a.75.75 0 0 1 0 1.5H2a.75.75 0 0 1-.75-.75", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
IconPath { d: "M4.5 16.25a.75.75 0 0 1-.75-.75v-5a.75.75 0 0 1 1.5 0v5a.75.75 0 0 1-.75.75", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6.25 5A.75.75 0 0 1 7 4.25h14a.75.75 0 0 1 .75.75v2.333a.75.75 0 0 1-1.5 0V5.75h-5.5v12.5h2.75a.75.75 0 0 1 0 1.5h-7a.75.75 0 0 1 0-1.5h2.75V5.75h-5.5v1.583a.75.75 0 1 1-1.5 0z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/><path d=\"M1.25 13a.75.75 0 0 1 .75-.75h5a.75.75 0 0 1 0 1.5H2a.75.75 0 0 1-.75-.75\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/><path d=\"M4.5 16.25a.75.75 0 0 1-.75-.75v-5a.75.75 0 0 1 1.5 0v5a.75.75 0 0 1-.75.75\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ZOOM_IN: IconDef = IconDef {
name: "ZoomUpIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M11.115 4.885a6.23 6.23 0 1 0 4.408 10.634 6.23 6.23 0 0 0-4.408-10.634m5.854 11.102a7.615 7.615 0 1 0-.979.98l4.328 4.33a.692.692 0 1 0 .98-.979zm-5.854-8.333c.383 0 .693.31.693.692v2.077h2.077a.692.692 0 1 1 0 1.385h-2.077v2.077a.692.692 0 1 1-1.385 0v-2.077H8.346a.692.692 0 0 1 0-1.385h2.077V8.346c0-.382.31-.692.692-.692", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M11.115 4.885a6.23 6.23 0 1 0 4.408 10.634 6.23 6.23 0 0 0-4.408-10.634m5.854 11.102a7.615 7.615 0 1 0-.979.98l4.328 4.33a.692.692 0 1 0 .98-.979zm-5.854-8.333c.383 0 .693.31.693.692v2.077h2.077a.692.692 0 1 1 0 1.385h-2.077v2.077a.692.692 0 1 1-1.385 0v-2.077H8.346a.692.692 0 0 1 0-1.385h2.077V8.346c0-.382.31-.692.692-.692\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ZOOM_OUT: IconDef = IconDef {
name: "ZoomDownIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M11.115 4.885a6.23 6.23 0 1 0 0 12.461 6.23 6.23 0 0 0 0-12.461M3.5 11.115a7.615 7.615 0 1 1 13.468 4.874l4.33 4.33a.692.692 0 1 1-.98.978l-4.33-4.33A7.615 7.615 0 0 1 3.5 11.116m4.154 0c0-.382.31-.692.692-.692h5.539a.692.692 0 1 1 0 1.385H8.346a.69.69 0 0 1-.692-.693", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M11.115 4.885a6.23 6.23 0 1 0 0 12.461 6.23 6.23 0 0 0 0-12.461M3.5 11.115a7.615 7.615 0 1 1 13.468 4.874l4.33 4.33a.692.692 0 1 1-.98.978l-4.33-4.33A7.615 7.615 0 0 1 3.5 11.116m4.154 0c0-.382.31-.692.692-.692h5.539a.692.692 0 1 1 0 1.385H8.346a.69.69 0 0 1-.692-.693\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const PLUS: IconDef = IconDef {
name: "PlusIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M12 4.5c.46 0 .833.373.833.833v5.834h5.834a.833.833 0 0 1 0 1.666h-5.834v5.834a.833.833 0 0 1-1.666 0v-5.834H5.333a.833.833 0 0 1 0-1.666h5.834V5.333c0-.46.373-.833.833-.833", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M12 4.5c.46 0 .833.373.833.833v5.834h5.834a.833.833 0 0 1 0 1.666h-5.834v5.834a.833.833 0 0 1-1.666 0v-5.834H5.333a.833.833 0 0 1 0-1.666h5.834V5.333c0-.46.373-.833.833-.833\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const MINUS: IconDef = IconDef {
name: "MinusIcon",
view_box: "0 0 24 24",
paths: &[
IconPath { d: "M4.5 12c0-.46.373-.833.833-.833h13.334a.833.833 0 0 1 0 1.666H5.333A.833.833 0 0 1 4.5 12", fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", stroke: "", stroke_width: 0.0_f32, stroke_linecap: "", stroke_linejoin: "" },
],
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.5 12c0-.46.373-.833.833-.833h13.334a.833.833 0 0 1 0 1.666H5.333A.833.833 0 0 1 4.5 12\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const MOVE_LEFT: IconDef = IconDef {
name: "MoveLeftIcon",
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.75 4a.75.75 0 0 0-1.5 0v16a.75.75 0 0 0 1.5 0zm8.405 4.57a.75.75 0 1 0-.976-1.14l-4.667 4a.75.75 0 0 0 0 1.14l4.667 4a.75.75 0 1 0 .976-1.14l-3.128-2.68H20a.75.75 0 0 0 0-1.5h-9.973z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const MOVE_RIGHT: IconDef = IconDef {
name: "MoveRightIcon",
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M20.75 4a.75.75 0 0 0-1.5 0v16a.75.75 0 0 0 1.5 0zm-9.905 4.57a.75.75 0 1 1 .976-1.14l4.667 4a.75.75 0 0 1 0 1.14l-4.667 4a.75.75 0 1 1-.976-1.14l3.128-2.68H4a.75.75 0 0 1 0-1.5h9.973z\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const INVISIBLE: IconDef = IconDef {
name: "InvisibleIcon",
svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M4.6 7.55a.75.75 0 0 0-1.2.9 10.8 10.8 0 0 0 2.939 2.69l-1.963 2.944a.75.75 0 0 0 1.248.832l2-3a1 1 0 0 0 .044-.075c1.108.489 2.315.796 3.582.883V17.5a.75.75 0 1 0 1.5 0v-4.776a10.7 10.7 0 0 0 3.582-.883q.02.038.044.075l2 3a.75.75 0 0 0 1.248-.832l-1.962-2.944A10.8 10.8 0 0 0 20.6 8.45a.75.75 0 1 0-1.2-.9 9.24 9.24 0 0 1-7.4 3.7 9.24 9.24 0 0 1-7.402-3.7\" fill=\"#000\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"/></svg>",
};
pub const ALL_ICONS: &[IconDef] = &[
@@ -540,12 +355,15 @@ pub const ALL_ICONS: &[IconDef] = &[
HEADING_6,
IMAGE,
INFORMATION,
INVISIBLE,
ITALIC,
KEYBOARD,
LINK,
LINKED_PAGE,
MINUS,
MORE_HORIZONTAL,
MOVE_LEFT,
MOVE_RIGHT,
NOTE,
NUMBERED_LIST,
PAGE,
@@ -594,23 +412,34 @@ mod tests {
}
for icon in ALL_ICONS {
assert_eq!(icon_by_name(icon.name), Some(icon));
assert!(icon.svg.starts_with("<svg "), "invalid svg for {}", icon.name);
assert!(icon.svg.ends_with("</svg>"), "unclosed svg for {}", icon.name);
assert!(icon.svg.contains("<path "), "missing path in {}", icon.name);
assert!(!icon.svg.contains("currentColor"), "unresolved currentColor in {}", icon.name);
}
assert_eq!(icon_by_name("LinkIcon"), Some(&LINK));
assert_eq!(icon_by_name("LinkedPageIcon"), Some(&LINKED_PAGE));
assert_eq!(icon_by_name("MoveLeftIcon"), Some(&MOVE_LEFT));
assert_eq!(icon_by_name("MoveRightIcon"), Some(&MOVE_RIGHT));
assert_eq!(icon_by_name("InvisibleIcon"), Some(&INVISIBLE));
}
#[test]
fn drag_handle_preserves_inherited_fill_none_and_stroke_attributes() {
assert!(!DRAG_HANDLE.paths.is_empty());
let stroked: Vec<&IconPath> = DRAG_HANDLE
.paths
.iter()
.filter(|p| !p.stroke.is_empty())
.collect();
assert!(!stroked.is_empty(), "DRAG_HANDLE must contain stroked paths");
for path in stroked {
assert_eq!(path.fill, "none");
assert!((path.stroke_width - 0.5).abs() < 1e-6);
}
assert!(
DRAG_HANDLE.svg.contains(r#"fill="none""#),
"DRAG_HANDLE must preserve inherited fill=none: {}",
DRAG_HANDLE.svg
);
assert!(
DRAG_HANDLE.svg.contains(r##"stroke="#000""##),
"DRAG_HANDLE must contain stroked paths: {}",
DRAG_HANDLE.svg
);
assert!(
DRAG_HANDLE.svg.contains(r#"stroke-width="0.5""#),
"DRAG_HANDLE must preserve stroke-width=0.5: {}",
DRAG_HANDLE.svg
);
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ pub mod icons {
include!("../icons.rs");
}
pub use icons::{IconDef, IconPath, icon_by_name};
pub use icons::{IconDef, icon_by_name};
pub use tokens::{DARK_THEME, LIGHT_THEME, Rgba, TYPOGRAPHY, ThemeMode, ThemeTokens};
/// Base UI and document font family.
@@ -10,10 +10,21 @@ use objc2_metal::{
MTLTextureDescriptor, MTLTextureUsage,
};
use parking_lot::Mutex;
use std::{borrow::Cow, ptr::NonNull};
use std::{borrow::Cow, collections::BTreeSet, ptr::NonNull, sync::Arc};
pub struct MetalAtlas(Mutex<AtlasState<MetalAtlasTextures>>);
pub(crate) struct AtlasSubmissionGuard {
atlas: Arc<MetalAtlas>,
id: u64,
}
impl Drop for AtlasSubmissionGuard {
fn drop(&mut self) {
self.atlas.complete_submission(self.id);
}
}
impl MetalAtlas {
pub(crate) fn new(
device: Retained<ProtocolObject<dyn MTLDevice>>,
@@ -24,9 +35,39 @@ impl MetalAtlas {
supports_shared_storage,
monochrome_textures: AtlasTextureList::default(),
polychrome_textures: AtlasTextureList::default(),
next_submission_id: 0,
in_flight_submissions: BTreeSet::new(),
deferred_removals: Vec::new(),
})))
}
pub(crate) fn begin_submission(self: &Arc<Self>) -> AtlasSubmissionGuard {
let mut state = self.0.lock();
state.backend.next_submission_id += 1;
let id = state.backend.next_submission_id;
state.backend.in_flight_submissions.insert(id);
AtlasSubmissionGuard {
atlas: Arc::clone(self),
id,
}
}
fn complete_submission(&self, id: u64) {
let mut state = self.0.lock();
state.backend.in_flight_submissions.remove(&id);
let oldest = state.backend.in_flight_submissions.first().copied();
let mut i = 0;
while i < state.backend.deferred_removals.len() {
let fence_id = state.backend.deferred_removals[i].0;
if oldest.is_none_or(|oldest| oldest > fence_id) {
let (_, tile) = state.backend.deferred_removals.swap_remove(i);
state.backend.reclaim_tile(tile);
} else {
i += 1;
}
}
}
/// Returns the GPU texture backing `id`, or `None` once every tile in it
/// has been removed. A scene can still reference such a texture when a
/// cached view replays a paint from before the image was dropped, so
@@ -44,6 +85,9 @@ struct MetalAtlasTextures {
supports_shared_storage: bool,
monochrome_textures: AtlasTextureList<MetalAtlasTexture>,
polychrome_textures: AtlasTextureList<MetalAtlasTexture>,
next_submission_id: u64,
in_flight_submissions: BTreeSet<u64>,
deferred_removals: Vec<(u64, AtlasTile)>,
}
impl PlatformAtlas for MetalAtlas {
@@ -77,6 +121,16 @@ impl AtlasBackend for MetalAtlasTextures {
}
fn remove(&mut self, tile: AtlasTile) {
if let Some(&fence_id) = self.in_flight_submissions.last() {
self.deferred_removals.push((fence_id, tile));
} else {
self.reclaim_tile(tile);
}
}
}
impl MetalAtlasTextures {
fn reclaim_tile(&mut self, tile: AtlasTile) {
let id = tile.texture_id;
let textures = match id.kind {
@@ -103,9 +157,6 @@ impl AtlasBackend for MetalAtlasTextures {
}
}
}
}
impl MetalAtlasTextures {
fn allocate(
&mut self,
size: Size<DevicePixels>,
@@ -691,10 +691,16 @@ impl MetalRenderer {
)?;
let instance_buffer_pool = self.instance_buffer_pool.clone();
let frame_resources = Cell::new(Some((writer.finish(), surface_textures)));
let frame_resources = Cell::new(Some((
writer.finish(),
surface_textures,
self.sprite_atlas.begin_submission(),
)));
let block = RcBlock::new(
move |_: ptr::NonNull<ProtocolObject<dyn MTLCommandBuffer>>| {
if let Some((instance_buffer, _surface_textures)) = frame_resources.take() {
if let Some((instance_buffer, _surface_textures, _atlas_submission)) =
frame_resources.take()
{
instance_buffer_pool.lock().release(instance_buffer);
}
},
@@ -751,10 +757,19 @@ impl MetalRenderer {
})
}
/// Renders a scene into a new offscreen texture of `size` and reads it
/// back, without presenting anything.
/// Encodes a scene into a new offscreen texture and returns `(target_texture, command_buffer, uses_shared_storage)`
/// without committing the command buffer.
#[cfg(any(test, feature = "harness"))]
fn render_offscreen(&mut self, scene: &Scene, size: Size<DevicePixels>) -> Result<RgbaImage> {
#[allow(clippy::type_complexity)]
pub fn encode_offscreen_frame(
&mut self,
scene: &Scene,
size: Size<DevicePixels>,
) -> Result<(
Retained<ProtocolObject<dyn MTLTexture>>,
Retained<ProtocolObject<dyn MTLCommandBuffer>>,
bool,
)> {
if size.width.0 <= 0 || size.height.0 <= 0 {
anyhow::bail!("Invalid size for render_offscreen: {:?}", size);
}
@@ -781,6 +796,15 @@ impl MetalRenderer {
.context("allocating offscreen render target")?;
let command_buffer = self.render_frame(scene, &target_texture, size)?;
Ok((target_texture, command_buffer, uses_shared_storage))
}
/// Renders a scene into a new offscreen texture of `size` and reads it
/// back, without presenting anything.
#[cfg(any(test, feature = "harness"))]
fn render_offscreen(&mut self, scene: &Scene, size: Size<DevicePixels>) -> Result<RgbaImage> {
let (target_texture, command_buffer, uses_shared_storage) =
self.encode_offscreen_frame(scene, size)?;
// Managed textures require an explicit blit synchronize before the CPU
// can read back the rendered data. Without this, get_bytes returns
@@ -1926,6 +1950,10 @@ impl MetalHeadlessRenderer {
let renderer = MetalRenderer::new_headless(instance_buffer_pool)?;
Ok(Self { renderer })
}
pub fn renderer_mut(&mut self) -> &mut MetalRenderer {
&mut self.renderer
}
}
#[cfg(any(test, feature = "harness"))]
-51
View File
@@ -6,7 +6,6 @@
use std::{
collections::VecDeque,
fmt,
iter::FusedIterator,
sync::{Arc, Condvar, Mutex, MutexGuard, PoisonError, TryLockError, atomic::AtomicUsize},
};
@@ -353,9 +352,6 @@ impl<T> PriorityQueueReceiver<T> {
/// Pops an element from the priority queue blocking if necessary.
///
/// This method is best suited if you only intend to pop one element, for better performance
/// on large queues see [`Self::iter`].
///
/// # Errors
///
/// If the sender was dropped
@@ -363,21 +359,6 @@ impl<T> PriorityQueueReceiver<T> {
self.pop_inner(true).map(|e| e.unwrap())
}
/// Returns an iterator over the elements of the queue
/// this iterator will end when all elements have been consumed and will not wait for new ones.
pub fn try_iter(self) -> TryIter<T> {
TryIter {
receiver: self,
ended: false,
}
}
/// Returns an iterator over the elements of the queue
/// this iterator will wait for new elements if the queue is empty.
pub fn iter(self) -> Iter<T> {
Iter(self)
}
#[inline(always)]
// algorithm is the loaded die from biased coin from
// https://www.keithschwarz.com/darts-dice-coins/
@@ -432,35 +413,3 @@ impl<T> Drop for PriorityQueueReceiver<T> {
.fetch_sub(1, std::sync::atomic::Ordering::AcqRel);
}
}
#[doc(hidden)]
pub struct Iter<T>(PriorityQueueReceiver<T>);
impl<T> Iterator for Iter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.pop().ok()
}
}
impl<T> FusedIterator for Iter<T> {}
#[doc(hidden)]
pub struct TryIter<T> {
receiver: PriorityQueueReceiver<T>,
ended: bool,
}
impl<T> Iterator for TryIter<T> {
type Item = Result<T, RecvError>;
fn next(&mut self) -> Option<Self::Item> {
if self.ended {
return None;
}
let res = self.receiver.try_pop();
self.ended = res.is_err();
res.transpose()
}
}
impl<T> FusedIterator for TryIter<T> {}
-47
View File
@@ -115,53 +115,6 @@ impl TaffyLayoutEngine {
crate::fast::layout::stretch_retained_auto_size_to_fill(self, id, size, scale_factor);
}
// Used to understand performance
#[allow(dead_code)]
fn count_all_children(&self, parent: LayoutId) -> anyhow::Result<u32> {
let mut count = 0;
for child in self.taffy.children(parent.0)? {
// Count this child.
count += 1;
// Count all of this child's children.
count += self.count_all_children(LayoutId(child))?
}
Ok(count)
}
// Used to understand performance
#[allow(dead_code)]
fn max_depth(&self, depth: u32, parent: LayoutId) -> anyhow::Result<u32> {
println!(
"{parent:?} at depth {depth} has {} children",
self.taffy.child_count(parent.0)
);
let mut max_child_depth = 0;
for child in self.taffy.children(parent.0)? {
max_child_depth = std::cmp::max(max_child_depth, self.max_depth(0, LayoutId(child))?);
}
Ok(depth + 1 + max_child_depth)
}
// Used to understand performance
#[allow(dead_code)]
fn get_edges(&self, parent: LayoutId) -> anyhow::Result<Vec<(LayoutId, LayoutId)>> {
let mut edges = Vec::new();
for child in self.taffy.children(parent.0)? {
edges.push((parent, LayoutId(child)));
edges.extend(self.get_edges(LayoutId(child))?);
}
Ok(edges)
}
pub fn compute_layout(
&mut self,
id: LayoutId,
+132
View File
@@ -0,0 +1,132 @@
#![cfg(all(target_os = "macos", feature = "harness"))]
use std::{
borrow::Cow,
ptr,
sync::{Arc, mpsc},
time::Duration,
};
use block2::RcBlock;
use objc2::runtime::ProtocolObject;
use objc2_metal::MTLCommandBuffer;
use ui::{
AtlasKey, DevicePixels, ImageId, MetalHeadlessRenderer, PlatformHeadlessRenderer as _,
RenderImageParams, Scene, Size, size,
};
fn image_key(id: usize) -> AtlasKey {
AtlasKey::Image(RenderImageParams {
image_id: ImageId(id),
frame_index: 0,
})
}
fn insert_polychrome(
atlas: &Arc<dyn ui::PlatformAtlas>,
id: usize,
width: i32,
height: i32,
) -> ui::AtlasTile {
let tile_size: Size<DevicePixels> = size(DevicePixels(width), DevicePixels(height));
let bytes = vec![0xABu8; (width as usize) * (height as usize) * 4];
atlas
.get_or_insert_with(image_key(id), &mut || {
Ok(Some((tile_size, Cow::Borrowed(bytes.as_slice()))))
})
.expect("atlas insert should succeed")
.expect("atlas insert should return tile")
}
#[test]
fn metal_atlas_defers_tile_reuse_until_command_buffer_completes() {
let mut renderer = MetalHeadlessRenderer::new().expect("headless MetalRenderer");
let atlas = renderer.sprite_atlas();
// Insert a 64x64 image A and a 128x128 image B on the same polychrome atlas texture.
// B keeps texture 0 referenced while A is the sole occupant of its 64x64 shelf.
let tile_a = insert_polychrome(&atlas, 1, 64, 64);
let tile_b = insert_polychrome(&atlas, 2, 128, 128);
assert_eq!(tile_a.texture_id, tile_b.texture_id);
assert_ne!(tile_a.bounds, tile_b.bounds);
// Encode submission N (registers render_frame's completion handler with AtlasSubmissionGuard)
// without committing it yet so submission N remains in flight.
let frame_size: Size<DevicePixels> = size(DevicePixels(64), DevicePixels(64));
let (_target, command_buffer, _) = renderer
.renderer_mut()
.encode_offscreen_frame(&Scene::default(), frame_size)
.expect("encode offscreen frame");
let (tx, rx) = mpsc::sync_channel::<()>(1);
let done_block = RcBlock::new(
move |_: ptr::NonNull<ProtocolObject<dyn MTLCommandBuffer>>| {
let _ = tx.send(());
},
);
// SAFETY: Metal copies the live block and invokes it once after command_buffer completes.
unsafe {
command_buffer.addCompletedHandler(RcBlock::as_ptr(&done_block));
}
// While submission N is in flight, removing A and inserting same-size C must NOT reuse A's
// bounds on texture 0.
atlas.remove(&image_key(1));
let tile_c = insert_polychrome(&atlas, 3, 64, 64);
assert_eq!(tile_c.texture_id, tile_a.texture_id);
assert_ne!(
tile_c.bounds, tile_a.bounds,
"tile A's region must not be overwritten while submission N is still in flight"
);
// Commit and wait for GPU + completion handler execution.
command_buffer.commit();
command_buffer.waitUntilCompleted();
rx.recv_timeout(Duration::from_secs(5))
.expect("Metal completion handler should release atlas submission guard");
// Remove C (no submission in flight -> immediately freed). Because A was reclaimed by
// submission N's completion handler, the 64x64 shelf is now empty and D reuses A's exact
// bounds on texture 0.
atlas.remove(&image_key(3));
let tile_d = insert_polychrome(&atlas, 4, 64, 64);
assert_eq!(tile_d.texture_id, tile_a.texture_id);
assert_eq!(
tile_d.bounds, tile_a.bounds,
"tile A's region should be reclaimed and reused after submission N completes"
);
}
#[test]
fn metal_atlas_releases_fence_when_uncommitted_command_buffer_is_dropped() {
let mut renderer = MetalHeadlessRenderer::new().expect("headless MetalRenderer");
let atlas = renderer.sprite_atlas();
let tile_a = insert_polychrome(&atlas, 10, 64, 64);
let tile_b = insert_polychrome(&atlas, 11, 128, 128);
assert_eq!(tile_a.texture_id, tile_b.texture_id);
let frame_size: Size<DevicePixels> = size(DevicePixels(64), DevicePixels(64));
let tile_c = objc2::rc::autoreleasepool(|_| {
let (_target, command_buffer, _) = renderer
.renderer_mut()
.encode_offscreen_frame(&Scene::default(), frame_size)
.expect("encode offscreen frame");
atlas.remove(&image_key(10));
let tile_c = insert_polychrome(&atlas, 12, 64, 64);
assert_eq!(tile_c.texture_id, tile_a.texture_id);
assert_ne!(tile_c.bounds, tile_a.bounds);
drop(command_buffer);
tile_c
});
assert_eq!(tile_c.texture_id, tile_a.texture_id);
// Dropping the uncommitted command buffer must drop AtlasSubmissionGuard and reclaim tile A.
atlas.remove(&image_key(12));
let tile_d = insert_polychrome(&atlas, 13, 64, 64);
assert_eq!(tile_d.texture_id, tile_a.texture_id);
assert_eq!(
tile_d.bounds, tile_a.bounds,
"dropping uncommitted command buffer must release fence and reclaim tile A"
);
}