Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

support order,bullet with list

appflowy69c8eb09c5a9
diff --git a/app_flowy/.vscode/settings.json b/app_flowy/.vscode/settings.json
index ba5e072c20..ebe5624e99 100644
--- a/app_flowy/.vscode/settings.json
+++ b/app_flowy/.vscode/settings.json
@@ -1,5 +1,6 @@
{
"svgviewer.enableautopreview": true,
"svgviewer.previewcolumn": "Active",
- "svgviewer.showzoominout": true
+ "svgviewer.showzoominout": true,
+ "editor.wordWrapColumn": 120
}
\ No newline at end of file
diff --git a/rust-lib/flowy-ot/src/core/attributes/attribute.rs b/rust-lib/flowy-ot/src/core/attributes/attribute.rs
index c790b0efe6..5616f8c1b1 100644
--- a/rust-lib/flowy-ot/src/core/attributes/attribute.rs
+++ b/rust-lib/flowy-ot/src/core/attributes/attribute.rs
@@ -1,6 +1,6 @@
#![allow(non_snake_case)]
-use crate::{block_attribute, core::Attributes, ignore_attribute, inline_attribute};
+use crate::{block_attribute, core::Attributes, ignore_attribute, inline_attribute, list_attribute};
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use std::{collections::HashSet, fmt, fmt::Formatter, iter::FromIterator};
@@ -28,13 +28,19 @@ impl Attribute {
block_attribute!(Header, usize);
block_attribute!(Indent, usize);
block_attribute!(Align, String);
- block_attribute!(List, String);
+ block_attribute!(List, &str);
block_attribute!(CodeBlock, bool);
block_attribute!(QuoteBlock, bool);
// ignore
ignore_attribute!(Width, usize);
ignore_attribute!(Height, usize);
+
+ // List extension
+ list_attribute!(Bullet, "bullet");
+ list_attribute!(Ordered, "ordered");
+ list_attribute!(Checked, "checked");
+ list_attribute!(UnChecked, "unchecked");
}
impl fmt::Display for Attribute {
@@ -111,7 +117,7 @@ impl std::convert::From<usize> for AttributeValue {
}
impl std::convert::From<&str> for AttributeValue {
- fn from(val: &str) -> Self { AttributeValue(Some(val.to_owned())) }
+ fn from(val: &str) -> Self { val.to_owned().into() }
}
impl std::convert::From<String> for AttributeValue {
diff --git a/rust-lib/flowy-ot/src/core/attributes/macros.rs b/rust-lib/flowy-ot/src/core/attributes/macros.rs
index 971efd19f2..dcdaf50f42 100644
--- a/rust-lib/flowy-ot/src/core/attributes/macros.rs
+++ b/rust-lib/flowy-ot/src/core/attributes/macros.rs
@@ -18,7 +18,7 @@ macro_rules! inline_attribute {
macro_rules! block_attribute {
(
$key: ident,
- $value: ident
+ $value: ty
) => {
pub fn $key(value: $value) -> Self {
Self {
@@ -30,6 +30,22 @@ macro_rules! block_attribute {
};
}
+#[macro_export]
+macro_rules! list_attribute {
+ (
+ $key: ident,
+ $value: expr
+ ) => {
+ pub fn $key(b: bool) -> Self {
+ let value = match b {
+ true => $value,
+ false => "",
+ };
+ Attribute::List(value)
+ }
+ };
+}
+
#[macro_export]
macro_rules! ignore_attribute {
(
diff --git a/rust-lib/flowy-ot/tests/helper/mod.rs b/rust-lib/flowy-ot/tests/helper/mod.rs
index 9933159df8..31394412bd 100644
--- a/rust-lib/flowy-ot/tests/helper/mod.rs
+++ b/rust-lib/flowy-ot/tests/helper/mod.rs
@@ -123,11 +123,7 @@ impl TestBuilder {
},
TestOp::Bullet(delta_i, iv, enable) => {
let document = &mut self.documents[*delta_i];
- let value = match *enable {
- true => "bullet",
- false => "",
- };
- let attribute = Attribute::List(value.to_owned());
+ let attribute = Attribute::Bullet(*enable);
document.format(*iv, attribute).unwrap();
},
TestOp::Transform(delta_a_i, delta_b_i) => {