@@ -8,6 +8,7 @@ import 'package:appflowy_editor/src/render/link_menu/link_menu.dart';
88import 'package:appflowy_editor/src/extensions/text_node_extensions.dart' ;
99import 'package:appflowy_editor/src/extensions/editor_state_extensions.dart' ;
1010import 'package:appflowy_editor/src/service/default_text_operations/format_rich_text_style.dart' ;
11+ import 'package:flutter/foundation.dart' ;
1112import 'dart:io' show Platform;
1213
1314import 'package:flutter/material.dart' hide Overlay, OverlayEntry;
@@ -129,7 +130,7 @@ List<ToolbarItem> defaultToolbarItems = [
129130 id: 'appflowy.toolbar.bold' ,
130131 type: 2 ,
131132 tooltipsMessage:
132- "${AppFlowyEditorLocalizations .current .bold }\n ${ Platform . isMacOS ? "⌘ + B" : " CTRL + B" }" ,
133+ "${AppFlowyEditorLocalizations .current .bold }${ _shortcutTooltips ( "⌘ + B" , "CTRL + B" , " CTRL + B") }" ,
133134 iconBuilder: (isHighlight) => FlowySvg (
134135 name: 'toolbar/bold' ,
135136 color: isHighlight ? Colors .lightBlue : null ,
@@ -146,7 +147,7 @@ List<ToolbarItem> defaultToolbarItems = [
146147 id: 'appflowy.toolbar.italic' ,
147148 type: 2 ,
148149 tooltipsMessage:
149- "${AppFlowyEditorLocalizations .current .italic }\n ${ Platform . isMacOS ? "⌘ + I" : " CTRL + I" }" ,
150+ "${AppFlowyEditorLocalizations .current .italic }${ _shortcutTooltips ( "⌘ + I" , "CTRL + I" , " CTRL + I") }" ,
150151 iconBuilder: (isHighlight) => FlowySvg (
151152 name: 'toolbar/italic' ,
152153 color: isHighlight ? Colors .lightBlue : null ,
@@ -163,7 +164,7 @@ List<ToolbarItem> defaultToolbarItems = [
163164 id: 'appflowy.toolbar.underline' ,
164165 type: 2 ,
165166 tooltipsMessage:
166- "${AppFlowyEditorLocalizations .current .underline }\n ${ Platform . isMacOS ? "⌘ + U" : " CTRL + U" }" ,
167+ "${AppFlowyEditorLocalizations .current .underline }${ _shortcutTooltips ( "⌘ + U" , "CTRL + U" , " CTRL + U") }" ,
167168 iconBuilder: (isHighlight) => FlowySvg (
168169 name: 'toolbar/underline' ,
169170 color: isHighlight ? Colors .lightBlue : null ,
@@ -180,7 +181,7 @@ List<ToolbarItem> defaultToolbarItems = [
180181 id: 'appflowy.toolbar.strikethrough' ,
181182 type: 2 ,
182183 tooltipsMessage:
183- "${AppFlowyEditorLocalizations .current .strikethrough }\n ${ Platform . isMacOS ? "⌘ + SHIFT + S" : " CTRL + SHIFT + S" }" ,
184+ "${AppFlowyEditorLocalizations .current .strikethrough }${ _shortcutTooltips ( "⌘ + SHIFT + S" , "CTRL + SHIFT + S" , " CTRL + SHIFT + S") }" ,
184185 iconBuilder: (isHighlight) => FlowySvg (
185186 name: 'toolbar/strikethrough' ,
186187 color: isHighlight ? Colors .lightBlue : null ,
@@ -197,7 +198,7 @@ List<ToolbarItem> defaultToolbarItems = [
197198 id: 'appflowy.toolbar.code' ,
198199 type: 2 ,
199200 tooltipsMessage:
200- "${AppFlowyEditorLocalizations .current .embedCode }\n ${ Platform . isMacOS ? "⌘ + E" : " CTRL + E" }" ,
201+ "${AppFlowyEditorLocalizations .current .embedCode }${ _shortcutTooltips ( "⌘ + E" , "CTRL + E" , " CTRL + E") }" ,
201202 iconBuilder: (isHighlight) => FlowySvg (
202203 name: 'toolbar/code' ,
203204 color: isHighlight ? Colors .lightBlue : null ,
@@ -248,7 +249,7 @@ List<ToolbarItem> defaultToolbarItems = [
248249 id: 'appflowy.toolbar.link' ,
249250 type: 4 ,
250251 tooltipsMessage:
251- "${AppFlowyEditorLocalizations .current .link }\n ${ Platform . isMacOS ? "⌘ + K" : " CTRL + K" }" ,
252+ "${AppFlowyEditorLocalizations .current .link }${ _shortcutTooltips ( "⌘ + K" , "CTRL + K" , " CTRL + K") }" ,
252253 iconBuilder: (isHighlight) => FlowySvg (
253254 name: 'toolbar/link' ,
254255 color: isHighlight ? Colors .lightBlue : null ,
@@ -265,7 +266,7 @@ List<ToolbarItem> defaultToolbarItems = [
265266 id: 'appflowy.toolbar.highlight' ,
266267 type: 4 ,
267268 tooltipsMessage:
268- "${AppFlowyEditorLocalizations .current .highlight }\n ${ Platform . isMacOS ? "⌘ + SHIFT + H" : " CTRL + SHIFT + H" }" ,
269+ "${AppFlowyEditorLocalizations .current .highlight }${ _shortcutTooltips ( "⌘ + SHIFT + H" , "CTRL + SHIFT + H" , " CTRL + SHIFT + H") }" ,
269270 iconBuilder: (isHighlight) => FlowySvg (
270271 name: 'toolbar/highlight' ,
271272 color: isHighlight ? Colors .lightBlue : null ,
@@ -316,6 +317,22 @@ List<ToolbarItem> defaultToolbarItems = [
316317 ),
317318];
318319
320+ String _shortcutTooltips (
321+ String ? macOSString,
322+ String ? windowsString,
323+ String ? linuxString,
324+ ) {
325+ if (kIsWeb) return '' ;
326+ if (Platform .isMacOS && macOSString != null ) {
327+ return '\n $macOSString ' ;
328+ } else if (Platform .isWindows && windowsString != null ) {
329+ return '\n $windowsString ' ;
330+ } else if (Platform .isLinux && linuxString != null ) {
331+ return '\n $linuxString ' ;
332+ }
333+ return '' ;
334+ }
335+
319336ToolbarItemValidator _onlyShowInSingleTextSelection = (editorState) {
320337 final result = _showInBuiltInTextSelection (editorState);
321338 if (! result) {
0 commit comments