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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
[rust]: support blockqutoe and code attribute
appflowy99d39e30f81a
diff --git a/app_flowy/.vscode/settings.json b/app_flowy/.vscode/settings.jsonindex 3af73866a3..cdfa99888f 100644--- a/app_flowy/.vscode/settings.json+++ b/app_flowy/.vscode/settings.json@@ -18,5 +18,8 @@"editor.minimap.maxColumn": 140,"prettier.printWidth": 140,"editor.wordWrap": "wordWrapColumn",- "dart.lineLength": 120+ "dart.lineLength": 120,+ "files.associations": {+ "*.log.*": "log"+ },}\ No newline at end of filediff --git a/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/app_flowy/lib/workspace/application/doc/doc_bloc.dartindex fb972ba6bf..303f3872d6 100644--- a/app_flowy/lib/workspace/application/doc/doc_bloc.dart+++ b/app_flowy/lib/workspace/application/doc/doc_bloc.dart@@ -20,7 +20,7 @@ class DocBloc extends Bloc<DocEvent, DocState> {final IViewListener listener;final ITrash trasnManager;late Document document;- late StreamSubscription _subscription;+ late StreamSubscription? _subscription;DocBloc({required this.view,@@ -57,7 +57,8 @@ class DocBloc extends Bloc<DocEvent, DocState> {@overrideFuture<void> close() async {await listener.stop();- await _subscription.cancel();++ await _subscription?.cancel();docManager.closeDoc();return super.close();}@@ -104,7 +105,7 @@ class DocBloc extends Bloc<DocEvent, DocState> {void _composeDelta(Delta composedDelta, Delta documentDelta) async {final json = jsonEncode(composedDelta.toJson());- Log.debug("Send json: $json");+ Log.debug("doc_id: $view.id - Send json: $json");final result = await docManager.composeDelta(json: json);result.fold((rustDoc) {diff --git a/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/tool_bar.dart b/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/tool_bar.dartindex 86694e7e03..b1c038d40b 100644--- a/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/tool_bar.dart+++ b/app_flowy/lib/workspace/presentation/stack_page/doc/widget/toolbar/tool_bar.dart@@ -93,14 +93,14 @@ class EditorToolbar extends StatelessWidget implements PreferredSizeWidget {controller: controller,background: true,),- FlowyImageButton(- iconSize: toolbarIconSize,- controller: controller,- onImagePickCallback: onImagePickCallback,- filePickImpl: filePickImpl,- webImagePickImpl: webImagePickImpl,- mediaPickSettingSelector: mediaPickSettingSelector,- ),+ // FlowyImageButton(+ // iconSize: toolbarIconSize,+ // controller: controller,+ // onImagePickCallback: onImagePickCallback,+ // filePickImpl: filePickImpl,+ // webImagePickImpl: webImagePickImpl,+ // mediaPickSettingSelector: mediaPickSettingSelector,+ // ),FlowyHeaderStyleButton(controller: controller,iconSize: toolbarIconSize,diff --git a/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs b/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rsindex 16b75cc26d..a1b08eea48 100644--- a/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs+++ b/rust-lib/flowy-document/src/services/doc/edit/doc_actor.rs@@ -13,14 +13,16 @@ use std::{convert::TryFrom, sync::Arc};use tokio::sync::{mpsc, RwLock};pub struct DocumentActor {+ doc_id: String,document: Arc<RwLock<Document>>,receiver: Option<mpsc::UnboundedReceiver<DocumentMsg>>,}impl DocumentActor {- pub fn new(delta: Delta, receiver: mpsc::UnboundedReceiver<DocumentMsg>) -> Self {+ pub fn new(doc_id: &str, delta: Delta, receiver: mpsc::UnboundedReceiver<DocumentMsg>) -> Self {let document = Arc::new(RwLock::new(Document::from_delta(delta)));Self {+ doc_id: doc_id.to_owned(),document,receiver: Some(receiver),}@@ -114,11 +116,7 @@ impl DocumentActor {// tracing::debug!("{:?} thread handle_message", thread::current(),);let mut document = self.document.write().await;let result = document.compose_delta(&delta);- tracing::debug!(- "Compose push delta: {}. result: {}",- delta.to_json(),- document.to_json()- );+ tracing::debug!("doc_id:{} - Compose push delta: {}", &self.doc_id, delta.to_json(),);drop(document);resultdiff --git a/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs b/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rsindex dc70a72617..49b5fed9a3 100644--- a/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs+++ b/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs@@ -321,9 +321,9 @@ async fn save_document(document: UnboundedSender<DocumentMsg>, rev_id: RevId) ->result}-fn spawn_doc_edit_actor(_doc_id: &str, delta: Delta, _pool: Arc<ConnectionPool>) -> UnboundedSender<DocumentMsg> {+fn spawn_doc_edit_actor(doc_id: &str, delta: Delta, _pool: Arc<ConnectionPool>) -> UnboundedSender<DocumentMsg> {let (sender, receiver) = mpsc::unbounded_channel::<DocumentMsg>();- let actor = DocumentActor::new(delta, receiver);+ let actor = DocumentActor::new(doc_id, delta, receiver);tokio::spawn(actor.run());sender}diff --git a/rust-lib/flowy-document/tests/editor/attribute_test.rs b/rust-lib/flowy-document/tests/editor/attribute_test.rsindex 8de8550dda..0879a90d85 100644--- a/rust-lib/flowy-document/tests/editor/attribute_test.rs+++ b/rust-lib/flowy-document/tests/editor/attribute_test.rs@@ -1,3 +1,4 @@+#![cfg_attr(rustfmt, rustfmt::skip)]use crate::editor::{TestBuilder, TestOp::*};use flowy_document::services::doc::{FlowyDoc, PlainDoc};use flowy_ot::core::{Delta, DeltaBuilder, Interval, OperationTransformable, NEW_LINE, WHITESPACE};diff --git a/rust-lib/flowy-log/src/lib.rs b/rust-lib/flowy-log/src/lib.rsindex fd8cd3cfbe..46f54d9cac 100644--- a/rust-lib/flowy-log/src/lib.rs+++ b/rust-lib/flowy-log/src/lib.rs@@ -39,7 +39,7 @@ impl Builder {pub fn local(mut self, directory: impl AsRef<Path>) -> Self {let directory = directory.as_ref().to_str().unwrap().to_owned();let local_file_name = format!("{}.log", &self.name);- self.file_appender = Some(tracing_appender::rolling::hourly(directory, local_file_name));+ self.file_appender = Some(tracing_appender::rolling::daily(directory, local_file_name));self}@@ -48,29 +48,22 @@ impl Builder {let env_filter = EnvFilter::new(self.env_filter);let file_appender = self.file_appender.unwrap();let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);- let formatting_layer = FlowyFormattingLayer::new(std::io::stdout);-- let formatter =- // Construct a custom formatter for `Debug` fields- format::debug_fn(|writer, field, value| write!(writer, "{}: {:?}", field, value))- // Use the `tracing_subscriber::MakeFmtExt` trait to wrap the- // formatter so that a delimiter is added between fields.- .delimited(", ");-let subscriber = tracing_subscriber::fmt()// .with_span_events(FmtSpan::NEW | FmtSpan::CLOSE)- // .without_time().with_ansi(false).with_target(false).with_max_level(tracing::Level::TRACE).with_writer(std::io::stderr)- .fmt_fields(formatter)- // .with_thread_ids(true)- .with_writer(non_blocking)+ .with_thread_ids(true)+ // .with_writer(non_blocking).json()+ .with_current_span(true)+ .with_span_list(true).compact().finish()- .with(env_filter).with(JsonStorageLayer).with(formatting_layer);+ .with(env_filter).with(JsonStorageLayer)+ .with(FlowyFormattingLayer::new(std::io::stdout))+ .with(FlowyFormattingLayer::new(non_blocking));// if cfg!(feature = "use_bunyan") {// let formatting_layer = BunyanFormattingLayer::new(self.name.clone(),diff --git a/rust-lib/flowy-ot/src/core/attributes/attribute.rs b/rust-lib/flowy-ot/src/core/attributes/attribute.rsindex 651532b058..4509031198 100644--- a/rust-lib/flowy-ot/src/core/attributes/attribute.rs+++ b/rust-lib/flowy-ot/src/core/attributes/attribute.rs@@ -24,6 +24,7 @@ impl Attribute {inline_attribute!(Font, usize);inline_attribute!(Size, usize);inline_attribute!(Background, String);+ inline_attribute!(InlineCode, bool);// blockblock_attribute!(Header, usize);@@ -31,7 +32,7 @@ impl Attribute {block_attribute!(Align, String);block_attribute!(List, &str);block_attribute!(CodeBlock, bool);- block_attribute!(QuoteBlock, bool);+ block_attribute!(BlockQuote, bool);// ignoreignore_attribute!(Width, usize);@@ -97,10 +98,12 @@ pub enum AttributeKey {Align,#[serde(rename = "code_block")]CodeBlock,+ #[serde(rename = "code")]+ InlineCode,#[serde(rename = "list")]List,- #[serde(rename = "quote_block")]- QuoteBlock,+ #[serde(rename = "blockquote")]+ BlockQuote,#[serde(rename = "width")]Width,#[serde(rename = "height")]@@ -169,7 +172,7 @@ lazy_static! {AttributeKey::Align,AttributeKey::CodeBlock,AttributeKey::List,- AttributeKey::QuoteBlock,+ AttributeKey::BlockQuote,]);static ref INLINE_KEYS: HashSet<AttributeKey> = HashSet::from_iter(vec![AttributeKey::Bold,@@ -181,6 +184,7 @@ lazy_static! {AttributeKey::Font,AttributeKey::Size,AttributeKey::Background,+ AttributeKey::InlineCode,]);static ref INGORE_KEYS: HashSet<AttributeKey> =HashSet::from_iter(vec![AttributeKey::Width, AttributeKey::Height,]);diff --git a/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs b/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rsindex 2493be0918..c3e911bbc1 100644--- a/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs+++ b/rust-lib/flowy-ot/src/core/attributes/attributes_serde.rs@@ -52,7 +52,8 @@ where| AttributeKey::Underline| AttributeKey::StrikeThrough| AttributeKey::CodeBlock- | AttributeKey::QuoteBlock => match &v.parse::<bool>() {+ | AttributeKey::InlineCode+ | AttributeKey::BlockQuote => match &v.parse::<bool>() {Ok(value) => map_serializer.serialize_entry(&key, value)?,Err(e) => log::error!("Serial {:?} failed. {:?}", &key, e),},