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 <nathan@appflowy.io>
This commit is contained in:
Lucas.Xu 2023-02-06 10:21:05 +07:00 committed by GitHub
parent cc9bd30356
commit a41894a5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 8 deletions

View File

@ -775,7 +775,7 @@ fn delta_compose() {
}
assert_eq!(
delta.json_str(),
r#"[{"insert":"a"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"\n"}]"#
r#"[{"insert":"a"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"\n","attributes":{"list":""}}]"#
);
let ops = vec![

View File

@ -214,6 +214,7 @@ impl AttributeValue {
pub fn none() -> Self {
Self { ty: None, value: None }
}
pub fn from_int(val: i64) -> Self {
Self {
ty: Some(ValueType::IntType),
@ -235,8 +236,9 @@ impl AttributeValue {
value: Some(val.to_string()),
}
}
pub fn from_string(s: &str) -> Self {
let value = if s.is_empty() { None } else { Some(s.to_string()) };
pub fn from_string<T: ToString>(s: T) -> Self {
let value = Some(s.to_string());
Self {
ty: Some(ValueType::StrType),
value,
@ -283,7 +285,7 @@ impl std::convert::From<&str> for AttributeValue {
impl std::convert::From<String> for AttributeValue {
fn from(value: String) -> Self {
AttributeValue::from_string(&value)
AttributeValue::from_string(value)
}
}

View File

@ -1,5 +1,5 @@
#![allow(non_snake_case)]
use crate::core::{AttributeEntry, AttributeHashMap, AttributeKey};
use crate::core::{AttributeEntry, AttributeHashMap, AttributeKey, AttributeValue};
use crate::text_delta::DeltaTextOperation;
use crate::{inline_attribute_entry, inline_list_attribute_entry};
use lazy_static::lazy_static;

View File

@ -21,13 +21,13 @@ macro_rules! inline_list_attribute_entry {
) => {
pub fn $key(b: bool) -> $crate::core::AttributeEntry {
let value = match b {
true => $value,
false => "",
true => $value.into(),
false => AttributeValue::none(),
};
AttributeEntry {
key: BuildInTextAttributeKey::List.as_ref().to_string(),
value: value.into(),
value,
}
}
};