mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[rust]: fix compile issue on release mode
This commit is contained in:
parent
5cf47e9f55
commit
22b93f0343
@ -122,10 +122,6 @@ class DocBloc extends Bloc<DocEvent, DocState> {
|
||||
}
|
||||
|
||||
Document _decodeJsonToDocument(String data) {
|
||||
// String d = r'''
|
||||
// "[{"insert":"\n👋 Welcome to AppFlowy!\n"},{"insert":"\n","attributes":{"header":1}},{"insert":"Here are the basics\n"},{"insert":"C","attributes":{"header":2}},{"insert":"lick anywhere and just start typing\n"},{"insert":"H","attributes":{"list":"unchecked"}},{"insert":"ighlight any text, and use the menu at the bottom to style your writing however you like\n"},{"insert":"C","attributes":{"list":"unchecked"}},{"insert":"lick + New Page button at the bottom of your sidebar to add a new page\n"},{"insert":"C","attributes":{"list":"unchecked"}},{"insert":"lick the + next to any page title in the sidebar to quickly add a new subpage\n"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"Have a question? \n"},{"insert":"C","attributes":{"header":2}},{"insert":"lick the '?' at the bottom right for help and support.\n\nLike AppFlowy? Follow us:\n"},{"insert":"G","attributes":{"header":2}},{"insert":"ithub: https://github.com/AppFlowy-IO/appflowy\n"},{"insert":"T","attributes":{"blockquote":true}},{"insert":"witter: https://twitter.com/appflowy\n"},{"insert":"N","attributes":{"blockquote":true}},{"insert":"ewsletter: https://www.appflowy.io/blog\n"},{"retain":1,"attributes":{"blockquote":true}},{"insert":"\n"}]"
|
||||
// ''';
|
||||
|
||||
final json = jsonDecode(data);
|
||||
final document = Document.fromJson(json);
|
||||
return document;
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit 3e121c546fe40f91e9817ad0e0f04910315db681
|
1
rust-lib/flowy-document/src/READ_ME.json
Normal file
1
rust-lib/flowy-document/src/READ_ME.json
Normal file
@ -0,0 +1 @@
|
||||
[{"insert":"\n👋 Welcome to AppFlowy!"},{"insert":"\n","attributes":{"header":1}},{"insert":"\nHere are the basics"},{"insert":"\n","attributes":{"header":2}},{"insert":"Click anywhere and just start typing"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"Highlight","attributes":{"background":"#fff2cd"}},{"insert":" any text, and use the menu at the bottom to "},{"insert":"style","attributes":{"italic":true}},{"insert":" "},{"insert":"your","attributes":{"bold":true}},{"insert":" "},{"insert":"writing","attributes":{"underline":true}},{"insert":" "},{"insert":"however","attributes":{"code":true}},{"insert":" "},{"insert":"you","attributes":{"strike":true}},{"insert":" "},{"insert":"like","attributes":{"background":"#e8e0ff"}},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"Click "},{"insert":"+ New Page","attributes":{"background":"#defff1","bold":true}},{"insert":" button at the bottom of your sidebar to add a new page"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"Click the "},{"insert":"'","attributes":{"background":"#defff1"}},{"insert":"+'","attributes":{"background":"#defff1","bold":true}},{"insert":" next to any page title in the sidebar to quickly add a new subpage"},{"insert":"\n","attributes":{"list":"unchecked"}},{"insert":"\nHave a question? "},{"insert":"\n","attributes":{"header":2}},{"insert":"Click the "},{"insert":"'?'","attributes":{"background":"#defff1","bold":true}},{"insert":" at the bottom right for help and support.\n\nLike AppFlowy? Follow us:"},{"insert":"\n","attributes":{"header":2}},{"insert":"Github: https://github.com/AppFlowy-IO/appflowy"},{"insert":"\n","attributes":{"blockquote":true}},{"insert":"Twitter: https://twitter.com/appflowy"},{"insert":"\n","attributes":{"blockquote":true}},{"insert":"Newsletter: https://www.appflowy.io/blog"},{"insert":"\n","attributes":{"blockquote":true}}]
|
@ -218,3 +218,15 @@ pub fn trim(delta: &mut Delta) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use flowy_ot::core::Delta;
|
||||
|
||||
#[test]
|
||||
fn load_read_me() {
|
||||
let json = include_str!("../../../READ_ME.json");
|
||||
let delta = Delta::from_json(json).unwrap();
|
||||
assert_eq!(delta.to_json(), json);
|
||||
}
|
||||
}
|
||||
|
@ -191,14 +191,11 @@ async fn fetch_from_local(doc_id: &str, persistence: Arc<Persistence>) -> DocRes
|
||||
let rev_id: RevId = revisions.last().unwrap().rev_id.into();
|
||||
let mut delta = Delta::new();
|
||||
let mut pre_rev_id = 0;
|
||||
for (index, revision) in revisions.into_iter().enumerate() {
|
||||
if cfg!(debug_assertions) {
|
||||
if index == 0 {
|
||||
pre_rev_id = revision.rev_id;
|
||||
} else {
|
||||
validate_rev_id(pre_rev_id, revision.rev_id);
|
||||
}
|
||||
}
|
||||
for (_, revision) in revisions.into_iter().enumerate() {
|
||||
pre_rev_id = revision.rev_id;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
validate_rev_id(pre_rev_id, revision.rev_id);
|
||||
|
||||
match Delta::from_bytes(revision.delta_data) {
|
||||
Ok(local_delta) => {
|
||||
@ -210,9 +207,8 @@ async fn fetch_from_local(doc_id: &str, persistence: Arc<Persistence>) -> DocRes
|
||||
}
|
||||
}
|
||||
|
||||
if cfg!(debug_assertions) {
|
||||
validate_delta(&doc_id, persistence, conn, &delta);
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
validate_delta(&doc_id, persistence, conn, &delta);
|
||||
|
||||
match delta.ops.last() {
|
||||
None => {},
|
||||
|
@ -7,7 +7,9 @@ pub struct FlowyStr(pub String);
|
||||
impl FlowyStr {
|
||||
pub fn count_utf16_code_units(&self) -> usize { count_utf16_code_units(&self.0) }
|
||||
|
||||
pub fn iter(&self) -> FlowyUtf16Iterator { FlowyUtf16Iterator::new(self, 0) }
|
||||
pub fn utf16_iter(&self) -> FlowyUtf16Iterator { FlowyUtf16Iterator::new(self, 0) }
|
||||
|
||||
pub fn code_point_iter(&self) -> CodePointIterator { CodePointIterator::new(self) }
|
||||
|
||||
pub fn sub_str(&self, interval: Interval) -> String {
|
||||
match self.with_interval(interval) {
|
||||
@ -230,7 +232,7 @@ mod tests {
|
||||
#[test]
|
||||
fn flowy_str_utf16_test() {
|
||||
let s: FlowyStr = "👋😁👋😁".into();
|
||||
let mut iter = s.iter();
|
||||
let mut iter = s.utf16_iter();
|
||||
assert_eq!(iter.next().unwrap(), "👋".to_string());
|
||||
assert_eq!(iter.next().unwrap(), "😁".to_string());
|
||||
assert_eq!(iter.next().unwrap(), "👋".to_string());
|
||||
@ -241,7 +243,7 @@ mod tests {
|
||||
#[test]
|
||||
fn flowy_str_utf16_iter_test() {
|
||||
let s: FlowyStr = "👋👋😁😁👋👋".into();
|
||||
let iter = s.iter();
|
||||
let iter = s.utf16_iter();
|
||||
let result = iter.skip(2).take(2).collect::<String>();
|
||||
assert_eq!(result, "😁😁".to_string());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user