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
Feat embed code (#985)
Sean Riley Hawkinsf4cf5d0808f6
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dartindex 2cd03fe389..5140e70daf 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/rich_text/rich_text_style.dart@@ -255,6 +255,9 @@ class RichTextStyle {if (attributes.href != null) {return Colors.lightBlue;}+ if (attributes.code) {+ return Colors.lightBlue.withOpacity(0.8);+ }return attributes.color ?? Colors.black;}@@ -262,7 +265,7 @@ class RichTextStyle {if (attributes.backgroundColor != null) {return attributes.backgroundColor!;} else if (attributes.code) {- return Colors.grey.withOpacity(0.4);+ return Colors.blue.shade300.withOpacity(0.3);}return null;}diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dartindex ff94dfc111..1b028abf50 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/render/toolbar/toolbar_item.dart@@ -172,6 +172,22 @@ List<ToolbarItem> defaultToolbarItems = [),handler: (editorState, context) => formatStrikethrough(editorState),),+ ToolbarItem(+ id: 'appflowy.toolbar.code',+ type: 2,+ tooltipsMessage: 'Embed Code',+ iconBuilder: (isHighlight) => FlowySvg(+ name: 'toolbar/code',+ color: isHighlight ? Colors.lightBlue : null,+ ),+ validator: _showInTextSelection,+ highlightCallback: (editorState) => _allSatisfy(+ editorState,+ StyleKey.code,+ (value) => value == StyleKey.code,+ ),+ handler: (editorState, context) => formatEmbedCode(editorState),+ ),ToolbarItem(id: 'appflowy.toolbar.quote',type: 3,diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dartindex 038f3119af..b832f149b1 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/service/default_text_operations/format_rich_text_style.dart@@ -139,6 +139,10 @@ bool formatStrikethrough(EditorState editorState) {return formatRichTextPartialStyle(editorState, StyleKey.strikethrough);}+bool formatEmbedCode(EditorState editorState) {+ return formatRichTextPartialStyle(editorState, StyleKey.code);+}+bool formatHighlight(EditorState editorState) {bool value = _allSatisfyInSelection(editorState, StyleKey.backgroundColor, defaultHighlightColor);