mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
remove bullet,order,check,uncheck with list
This commit is contained in:
parent
09adad3875
commit
e4db7222f8
@ -29,10 +29,6 @@ impl Attribute {
|
|||||||
block_attribute!(Indent, usize);
|
block_attribute!(Indent, usize);
|
||||||
block_attribute!(Align, String);
|
block_attribute!(Align, String);
|
||||||
block_attribute!(List, String);
|
block_attribute!(List, String);
|
||||||
block_attribute!(Bullet, bool);
|
|
||||||
block_attribute!(Ordered, bool);
|
|
||||||
block_attribute!(Checked, bool);
|
|
||||||
block_attribute!(UnChecked, bool);
|
|
||||||
block_attribute!(CodeBlock, bool);
|
block_attribute!(CodeBlock, bool);
|
||||||
block_attribute!(QuoteBlock, bool);
|
block_attribute!(QuoteBlock, bool);
|
||||||
|
|
||||||
@ -94,14 +90,6 @@ pub enum AttributeKey {
|
|||||||
Height,
|
Height,
|
||||||
#[serde(rename = "header")]
|
#[serde(rename = "header")]
|
||||||
Header,
|
Header,
|
||||||
#[serde(rename = "bullet")]
|
|
||||||
Bullet,
|
|
||||||
#[serde(rename = "ordered")]
|
|
||||||
Ordered,
|
|
||||||
#[serde(rename = "checked")]
|
|
||||||
Checked,
|
|
||||||
#[serde(rename = "unchecked")]
|
|
||||||
UnChecked,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub trait AttributeValueData<'a>: Serialize + Deserialize<'a> {}
|
// pub trait AttributeValueData<'a>: Serialize + Deserialize<'a> {}
|
||||||
@ -127,7 +115,13 @@ impl std::convert::From<&str> for AttributeValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<String> for AttributeValue {
|
impl std::convert::From<String> for AttributeValue {
|
||||||
fn from(val: String) -> Self { AttributeValue(Some(val)) }
|
fn from(val: String) -> Self {
|
||||||
|
if val.is_empty() {
|
||||||
|
AttributeValue(None)
|
||||||
|
} else {
|
||||||
|
AttributeValue(Some(val))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::From<&bool> for AttributeValue {
|
impl std::convert::From<&bool> for AttributeValue {
|
||||||
@ -158,10 +152,6 @@ lazy_static! {
|
|||||||
AttributeKey::Align,
|
AttributeKey::Align,
|
||||||
AttributeKey::CodeBlock,
|
AttributeKey::CodeBlock,
|
||||||
AttributeKey::List,
|
AttributeKey::List,
|
||||||
AttributeKey::Bullet,
|
|
||||||
AttributeKey::Ordered,
|
|
||||||
AttributeKey::Checked,
|
|
||||||
AttributeKey::UnChecked,
|
|
||||||
AttributeKey::QuoteBlock,
|
AttributeKey::QuoteBlock,
|
||||||
]);
|
]);
|
||||||
static ref INLINE_KEYS: HashSet<AttributeKey> = HashSet::from_iter(vec![
|
static ref INLINE_KEYS: HashSet<AttributeKey> = HashSet::from_iter(vec![
|
||||||
|
@ -45,15 +45,7 @@ impl Serialize for Attributes {
|
|||||||
Err(e) => log::error!("Serial {:?} failed. {:?}", k, e),
|
Err(e) => log::error!("Serial {:?} failed. {:?}", k, e),
|
||||||
},
|
},
|
||||||
|
|
||||||
AttributeKey::Link
|
AttributeKey::Link | AttributeKey::Color | AttributeKey::Background | AttributeKey::Align | AttributeKey::List => {
|
||||||
| AttributeKey::Color
|
|
||||||
| AttributeKey::Background
|
|
||||||
| AttributeKey::Align
|
|
||||||
| AttributeKey::Bullet
|
|
||||||
| AttributeKey::Ordered
|
|
||||||
| AttributeKey::Checked
|
|
||||||
| AttributeKey::UnChecked
|
|
||||||
| AttributeKey::List => {
|
|
||||||
map.serialize_entry(k, v)?;
|
map.serialize_entry(k, v)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -601,7 +601,7 @@ fn attributes_bullet_added() {
|
|||||||
let ops = vec![
|
let ops = vec![
|
||||||
Insert(0, "12", 0),
|
Insert(0, "12", 0),
|
||||||
Bullet(0, Interval::new(0, 1), true),
|
Bullet(0, Interval::new(0, 1), true),
|
||||||
AssertOpsJson(0, r#"[{"insert":"12"},{"insert":"\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"12"},{"insert":"\n","attributes":{"list":"bullet"}}]"#),
|
||||||
];
|
];
|
||||||
|
|
||||||
TestBuilder::new().run_script::<FlowyDoc>(ops);
|
TestBuilder::new().run_script::<FlowyDoc>(ops);
|
||||||
@ -612,13 +612,13 @@ fn attributes_bullet_added_2() {
|
|||||||
let ops = vec![
|
let ops = vec![
|
||||||
Insert(0, "1", 0),
|
Insert(0, "1", 0),
|
||||||
Bullet(0, Interval::new(0, 1), true),
|
Bullet(0, Interval::new(0, 1), true),
|
||||||
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}}]"#),
|
||||||
Insert(0, NEW_LINE, 1),
|
Insert(0, NEW_LINE, 1),
|
||||||
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n\n","attributes":{"list":"bullet"}}]"#),
|
||||||
Insert(0, "2", 2),
|
Insert(0, "2", 2),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -635,7 +635,7 @@ fn attributes_bullet_remove_partial() {
|
|||||||
Bullet(0, Interval::new(2, 3), false),
|
Bullet(0, Interval::new(2, 3), false),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2\n"}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2\n"}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -651,7 +651,7 @@ fn attributes_bullet_auto_exit() {
|
|||||||
Insert(0, NEW_LINE, 2),
|
Insert(0, NEW_LINE, 2),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"\n"}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"\n"}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -664,30 +664,30 @@ fn attributes_preserve_block_when_insert_newline_inside() {
|
|||||||
Insert(0, "12", 0),
|
Insert(0, "12", 0),
|
||||||
Bullet(0, Interval::new(0, 2), true),
|
Bullet(0, Interval::new(0, 2), true),
|
||||||
Insert(0, NEW_LINE, 2),
|
Insert(0, NEW_LINE, 2),
|
||||||
AssertOpsJson(0, r#"[{"insert":"12"},{"insert":"\n\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"12"},{"insert":"\n\n","attributes":{"list":"bullet"}}]"#),
|
||||||
Insert(0, "34", 3),
|
Insert(0, "34", 3),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[
|
r#"[
|
||||||
{"insert":"12"},{"insert":"\n","attributes":{"bullet":"true"}},
|
{"insert":"12"},{"insert":"\n","attributes":{"list":"bullet"}},
|
||||||
{"insert":"34"},{"insert":"\n","attributes":{"bullet":"true"}}
|
{"insert":"34"},{"insert":"\n","attributes":{"list":"bullet"}}
|
||||||
]"#,
|
]"#,
|
||||||
),
|
),
|
||||||
Insert(0, NEW_LINE, 3),
|
Insert(0, NEW_LINE, 3),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[
|
r#"[
|
||||||
{"insert":"12"},{"insert":"\n\n","attributes":{"bullet":"true"}},
|
{"insert":"12"},{"insert":"\n\n","attributes":{"list":"bullet"}},
|
||||||
{"insert":"34"},{"insert":"\n","attributes":{"bullet":"true"}}
|
{"insert":"34"},{"insert":"\n","attributes":{"list":"bullet"}}
|
||||||
]"#,
|
]"#,
|
||||||
),
|
),
|
||||||
Insert(0, "ab", 3),
|
Insert(0, "ab", 3),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[
|
r#"[
|
||||||
{"insert":"12"},{"insert":"\n","attributes":{"bullet":"true"}},
|
{"insert":"12"},{"insert":"\n","attributes":{"list":"bullet"}},
|
||||||
{"insert":"ab"},{"insert":"\n","attributes":{"bullet":"true"}},
|
{"insert":"ab"},{"insert":"\n","attributes":{"list":"bullet"}},
|
||||||
{"insert":"34"},{"insert":"\n","attributes":{"bullet":"true"}}
|
{"insert":"34"},{"insert":"\n","attributes":{"list":"bullet"}}
|
||||||
]"#,
|
]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -720,10 +720,10 @@ fn attributes_preserve_list_format_on_merge() {
|
|||||||
Insert(0, NEW_LINE, 3),
|
Insert(0, NEW_LINE, 3),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"123"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"456"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"123"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"456"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
Delete(0, Interval::new(3, 4)),
|
Delete(0, Interval::new(3, 4)),
|
||||||
AssertOpsJson(0, r#"[{"insert":"123456"},{"insert":"\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"123456"},{"insert":"\n","attributes":{"list":"bullet"}}]"#),
|
||||||
];
|
];
|
||||||
|
|
||||||
TestBuilder::new().run_script::<FlowyDoc>(ops);
|
TestBuilder::new().run_script::<FlowyDoc>(ops);
|
||||||
|
@ -79,7 +79,7 @@ impl TestBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run_op(&mut self, op: &TestOp) {
|
fn run_op(&mut self, op: &TestOp) {
|
||||||
log::debug!("***************** 😈{} *******************", &op);
|
log::trace!("***************** 😈{} *******************", &op);
|
||||||
match op {
|
match op {
|
||||||
TestOp::Insert(delta_i, s, index) => {
|
TestOp::Insert(delta_i, s, index) => {
|
||||||
let document = &mut self.documents[*delta_i];
|
let document = &mut self.documents[*delta_i];
|
||||||
@ -123,7 +123,11 @@ impl TestBuilder {
|
|||||||
},
|
},
|
||||||
TestOp::Bullet(delta_i, iv, enable) => {
|
TestOp::Bullet(delta_i, iv, enable) => {
|
||||||
let document = &mut self.documents[*delta_i];
|
let document = &mut self.documents[*delta_i];
|
||||||
let attribute = Attribute::Bullet(*enable);
|
let value = match *enable {
|
||||||
|
true => "bullet",
|
||||||
|
false => "",
|
||||||
|
};
|
||||||
|
let attribute = Attribute::List(value.to_owned());
|
||||||
document.format(*iv, attribute).unwrap();
|
document.format(*iv, attribute).unwrap();
|
||||||
},
|
},
|
||||||
TestOp::Transform(delta_a_i, delta_b_i) => {
|
TestOp::Transform(delta_a_i, delta_b_i) => {
|
||||||
|
@ -306,14 +306,14 @@ fn history_bullet_undo() {
|
|||||||
Insert(0, "2", 2),
|
Insert(0, "2", 2),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
Undo(0),
|
Undo(0),
|
||||||
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
||||||
Redo(0),
|
Redo(0),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -331,17 +331,17 @@ fn history_bullet_undo_with_lagging() {
|
|||||||
Wait(RECORD_THRESHOLD),
|
Wait(RECORD_THRESHOLD),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
Undo(0),
|
Undo(0),
|
||||||
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}}]"#),
|
||||||
Undo(0),
|
Undo(0),
|
||||||
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
AssertOpsJson(0, r#"[{"insert":"\n"}]"#),
|
||||||
Redo(0),
|
Redo(0),
|
||||||
Redo(0),
|
Redo(0),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"1"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"2"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"1"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"2"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -358,14 +358,14 @@ fn history_undo_attribute_on_merge_between_line() {
|
|||||||
Wait(RECORD_THRESHOLD),
|
Wait(RECORD_THRESHOLD),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"123"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"456"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"123"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"456"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
Delete(0, Interval::new(3, 4)), // delete the newline
|
Delete(0, Interval::new(3, 4)), // delete the newline
|
||||||
AssertOpsJson(0, r#"[{"insert":"123456"},{"insert":"\n","attributes":{"bullet":"true"}}]"#),
|
AssertOpsJson(0, r#"[{"insert":"123456"},{"insert":"\n","attributes":{"list":"bullet"}}]"#),
|
||||||
Undo(0),
|
Undo(0),
|
||||||
AssertOpsJson(
|
AssertOpsJson(
|
||||||
0,
|
0,
|
||||||
r#"[{"insert":"123"},{"insert":"\n","attributes":{"bullet":"true"}},{"insert":"456"},{"insert":"\n","attributes":{"bullet":"true"}}]"#,
|
r#"[{"insert":"123"},{"insert":"\n","attributes":{"list":"bullet"}},{"insert":"456"},{"insert":"\n","attributes":{"list":"bullet"}}]"#,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user