mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
support order,bullet with list
This commit is contained in:
parent
2a42fd108c
commit
69c8eb09c5
3
app_flowy/.vscode/settings.json
vendored
3
app_flowy/.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
||||
{
|
||||
"svgviewer.enableautopreview": true,
|
||||
"svgviewer.previewcolumn": "Active",
|
||||
"svgviewer.showzoominout": true
|
||||
"svgviewer.showzoominout": true,
|
||||
"editor.wordWrapColumn": 120
|
||||
}
|
@ -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 {
|
||||
|
@ -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 {
|
||||
(
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user