Skip to content

Commit a41894a

Browse files
LucasXu0appflowy
andauthored
Fix: 1802 [Bug] Math Equation would be null. #1802 (#1806)
* fix: #1290 [Bug] 300ms delay on buttons in titlebar * fix: #1802 Math Equation would be null * fix: retain as a attribute value --------- Co-authored-by: nathan <[email protected]>
1 parent cc9bd30 commit a41894a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

frontend/rust-lib/flowy-document/tests/editor/attribute_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ fn delta_compose() {
775775
}
776776
assert_eq!(
777777
delta.json_str(),
778-
r#"[{"insert":"a"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"\n"}]"#
778+
r#"[{"insert":"a"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"\n","attributes":{"list":""}}]"#
779779
);
780780

781781
let ops = vec![

shared-lib/lib-ot/src/core/attributes/attribute.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl AttributeValue {
214214
pub fn none() -> Self {
215215
Self { ty: None, value: None }
216216
}
217+
217218
pub fn from_int(val: i64) -> Self {
218219
Self {
219220
ty: Some(ValueType::IntType),
@@ -235,8 +236,9 @@ impl AttributeValue {
235236
value: Some(val.to_string()),
236237
}
237238
}
238-
pub fn from_string(s: &str) -> Self {
239-
let value = if s.is_empty() { None } else { Some(s.to_string()) };
239+
240+
pub fn from_string<T: ToString>(s: T) -> Self {
241+
let value = Some(s.to_string());
240242
Self {
241243
ty: Some(ValueType::StrType),
242244
value,
@@ -283,7 +285,7 @@ impl std::convert::From<&str> for AttributeValue {
283285

284286
impl std::convert::From<String> for AttributeValue {
285287
fn from(value: String) -> Self {
286-
AttributeValue::from_string(&value)
288+
AttributeValue::from_string(value)
287289
}
288290
}
289291

shared-lib/lib-ot/src/text_delta/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(non_snake_case)]
2-
use crate::core::{AttributeEntry, AttributeHashMap, AttributeKey};
2+
use crate::core::{AttributeEntry, AttributeHashMap, AttributeKey, AttributeValue};
33
use crate::text_delta::DeltaTextOperation;
44
use crate::{inline_attribute_entry, inline_list_attribute_entry};
55
use lazy_static::lazy_static;

shared-lib/lib-ot/src/text_delta/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ macro_rules! inline_list_attribute_entry {
2121
) => {
2222
pub fn $key(b: bool) -> $crate::core::AttributeEntry {
2323
let value = match b {
24-
true => $value,
25-
false => "",
24+
true => $value.into(),
25+
false => AttributeValue::none(),
2626
};
2727

2828
AttributeEntry {
2929
key: BuildInTextAttributeKey::List.as_ref().to_string(),
30-
value: value.into(),
30+
value,
3131
}
3232
}
3333
};

0 commit comments

Comments
 (0)