feat: support overriding i18n (#550)

This commit is contained in:
Lucas.Xu 2023-10-24 12:12:46 +08:00 • committed by GitHub
commit 6d163b8897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 161 additions and 152 deletions

View file

@ -10,6 +10,7 @@ export 'src/editor/block_component/rich_text/default_selectable_mixin.dart';
// editor part, including editor component, block component, etc. // editor part, including editor component, block component, etc.
export 'src/editor/editor.dart'; export 'src/editor/editor.dart';
export 'src/editor/find_replace_menu/find_and_replace.dart'; export 'src/editor/find_replace_menu/find_and_replace.dart';
export 'src/editor/l10n/appflowy_editor_l10n.dart';
export 'src/editor/selection_menu/selection_menu.dart'; export 'src/editor/selection_menu/selection_menu.dart';
// editor state // editor state
export 'src/editor_state.dart'; export 'src/editor_state.dart';

View file

@ -2,7 +2,7 @@ import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
SelectionMenuItem dividerMenuItem = SelectionMenuItem( SelectionMenuItem dividerMenuItem = SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.divider, name: AppFlowyEditorL10n.current.divider,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
icon: Icons.horizontal_rule, icon: Icons.horizontal_rule,
isSelected: isSelected, isSelected: isSelected,

View file

@ -133,8 +133,8 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
height: 36, height: 36,
child: TabBar( child: TabBar(
tabs: [ tabs: [
Tab(text: AppFlowyEditorLocalizations.current.uploadImage), Tab(text: AppFlowyEditorL10n.current.uploadImage),
Tab(text: AppFlowyEditorLocalizations.current.urlImage), Tab(text: AppFlowyEditorL10n.current.urlImage),
], ],
labelColor: widget.headerColor, labelColor: widget.headerColor,
unselectedLabelColor: Colors.grey, unselectedLabelColor: Colors.grey,
@ -204,7 +204,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
Widget _buildInvalidLinkText() { Widget _buildInvalidLinkText() {
return Text( return Text(
AppFlowyEditorLocalizations.current.incorrectLink, AppFlowyEditorL10n.current.incorrectLink,
style: const TextStyle(color: Colors.red, fontSize: 12), style: const TextStyle(color: Colors.red, fontSize: 12),
); );
} }
@ -240,7 +240,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
} }
}, },
child: Text( child: Text(
AppFlowyEditorLocalizations.current.upload, AppFlowyEditorL10n.current.upload,
style: TextStyle( style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary, color: Theme.of(context).colorScheme.onPrimary,
fontSize: 14.0, fontSize: 14.0,
@ -339,7 +339,7 @@ class _UploadImageMenuState extends State<UploadImageMenu> {
), ),
const SizedBox(height: 8.0), const SizedBox(height: 8.0),
Text( Text(
AppFlowyEditorLocalizations.current.chooseImage, AppFlowyEditorL10n.current.chooseImage,
style: const TextStyle( style: const TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Color(0xff00BCF0), color: Color(0xff00BCF0),

View file

@ -147,7 +147,7 @@ class _ResizableImageState extends State<ResizableImage> {
SizedBox.fromSize( SizedBox.fromSize(
size: const Size(10, 10), size: const Size(10, 10),
), ),
Text(AppFlowyEditorLocalizations.current.loading), Text(AppFlowyEditorL10n.current.loading),
], ],
), ),
); );
@ -163,7 +163,7 @@ class _ResizableImageState extends State<ResizableImage> {
borderRadius: const BorderRadius.all(Radius.circular(4.0)), borderRadius: const BorderRadius.all(Radius.circular(4.0)),
border: Border.all(width: 1, color: Colors.black), border: Border.all(width: 1, color: Colors.black),
), ),
child: Text(AppFlowyEditorLocalizations.current.imageLoadFailed), child: Text(AppFlowyEditorL10n.current.imageLoadFailed),
); );
} }

View file

@ -8,7 +8,7 @@ final Map<String, BlockComponentBuilder> standardBlockComponentBuilderMap = {
ParagraphBlockKeys.type: ParagraphBlockComponentBuilder( ParagraphBlockKeys.type: ParagraphBlockComponentBuilder(
configuration: standardBlockComponentConfiguration.copyWith( configuration: standardBlockComponentConfiguration.copyWith(
placeholderText: (_) => PlatformExtension.isDesktopOrWeb placeholderText: (_) => PlatformExtension.isDesktopOrWeb
? AppFlowyEditorLocalizations.current.slashPlaceHolder ? AppFlowyEditorL10n.current.slashPlaceHolder
: ' ', : ' ',
), ),
), ),

View file

@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
import 'package:appflowy_editor/src/editor/block_component/table_block_component/util.dart'; import 'package:appflowy_editor/src/editor/block_component/table_block_component/util.dart';
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
import 'package:flutter/material.dart';
void showActionMenu( void showActionMenu(
BuildContext context, BuildContext context,
@ -41,8 +41,8 @@ void showActionMenu(
_menuItem( _menuItem(
context, context,
dir == TableDirection.col dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colAddAfter ? AppFlowyEditorL10n.current.colAddAfter
: AppFlowyEditorLocalizations.current.rowAddAfter, : AppFlowyEditorL10n.current.rowAddAfter,
dir == TableDirection.col dir == TableDirection.col
? Icons.last_page ? Icons.last_page
: Icons.vertical_align_bottom, () { : Icons.vertical_align_bottom, () {
@ -52,8 +52,8 @@ void showActionMenu(
_menuItem( _menuItem(
context, context,
dir == TableDirection.col dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colAddBefore ? AppFlowyEditorL10n.current.colAddBefore
: AppFlowyEditorLocalizations.current.rowAddBefore, : AppFlowyEditorL10n.current.rowAddBefore,
dir == TableDirection.col dir == TableDirection.col
? Icons.first_page ? Icons.first_page
: Icons.vertical_align_top, () { : Icons.vertical_align_top, () {
@ -63,8 +63,8 @@ void showActionMenu(
_menuItem( _menuItem(
context, context,
dir == TableDirection.col dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colRemove ? AppFlowyEditorL10n.current.colRemove
: AppFlowyEditorLocalizations.current.rowRemove, : AppFlowyEditorL10n.current.rowRemove,
Icons.delete, () { Icons.delete, () {
TableActions.delete(node, position, editorState, dir); TableActions.delete(node, position, editorState, dir);
dismissOverlay(); dismissOverlay();
@ -72,15 +72,15 @@ void showActionMenu(
_menuItem( _menuItem(
context, context,
dir == TableDirection.col dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colDuplicate ? AppFlowyEditorL10n.current.colDuplicate
: AppFlowyEditorLocalizations.current.rowDuplicate, : AppFlowyEditorL10n.current.rowDuplicate,
Icons.content_copy, () { Icons.content_copy, () {
TableActions.duplicate(node, position, editorState, dir); TableActions.duplicate(node, position, editorState, dir);
dismissOverlay(); dismissOverlay();
}), }),
_menuItem( _menuItem(
context, context,
AppFlowyEditorLocalizations.current.backgroundColor, AppFlowyEditorL10n.current.backgroundColor,
Icons.format_color_fill, Icons.format_color_fill,
() { () {
final cell = dir == TableDirection.col final cell = dir == TableDirection.col
@ -112,8 +112,8 @@ void showActionMenu(
_menuItem( _menuItem(
context, context,
dir == TableDirection.col dir == TableDirection.col
? AppFlowyEditorLocalizations.current.colClear ? AppFlowyEditorL10n.current.colClear
: AppFlowyEditorLocalizations.current.rowClear, : AppFlowyEditorL10n.current.rowClear,
Icons.clear, () { Icons.clear, () {
TableActions.clear(node, position, editorState, dir); TableActions.clear(node, position, editorState, dir);
dismissOverlay(); dismissOverlay();
@ -180,14 +180,14 @@ void _showColorMenu(
left: left, left: left,
builder: (context) { builder: (context) {
return ColorPicker( return ColorPicker(
title: AppFlowyEditorLocalizations.current.highlightColor, title: AppFlowyEditorL10n.current.highlightColor,
selectedColorHex: selectedColorHex, selectedColorHex: selectedColorHex,
colorOptions: generateHighlightColorOptions(), colorOptions: generateHighlightColorOptions(),
onSubmittedColorHex: (color) { onSubmittedColorHex: (color) {
action(color); action(color);
dismissOverlay(); dismissOverlay();
}, },
resetText: AppFlowyEditorLocalizations.current.clearHighlightColor, resetText: AppFlowyEditorL10n.current.clearHighlightColor,
resetIconName: 'clear_highlight_color', resetIconName: 'clear_highlight_color',
); );
}, },

View file

@ -251,7 +251,7 @@ class _TableBlockComponentWidgetState extends State<TableBlockComponentWidget>
} }
SelectionMenuItem tableMenuItem = SelectionMenuItem( SelectionMenuItem tableMenuItem = SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.table, name: AppFlowyEditorL10n.current.table,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
icon: Icons.table_view, icon: Icons.table_view,
isSelected: isSelected, isSelected: isSelected,

View file

@ -2,7 +2,6 @@ import 'dart:async';
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -52,7 +51,7 @@ TextSpan mobileTextSpanDecoratorForAttribute(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
title: Text(AppFlowyEditorLocalizations.current.editLink), title: Text(AppFlowyEditorL10n.current.editLink),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
@ -122,12 +121,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return AppFlowyEditorLocalizations.current.linkTextHint; return AppFlowyEditorL10n.current.linkTextHint;
} }
return null; return null;
}, },
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppFlowyEditorLocalizations.current.linkText, hintText: AppFlowyEditorL10n.current.linkText,
suffixIcon: IconButton( suffixIcon: IconButton(
icon: const Icon( icon: const Icon(
Icons.clear_rounded, Icons.clear_rounded,
@ -143,12 +142,12 @@ class _LinkEditFormState extends State<LinkEditForm> {
keyboardType: TextInputType.url, keyboardType: TextInputType.url,
validator: (value) { validator: (value) {
if (value == null || value.isEmpty) { if (value == null || value.isEmpty) {
return AppFlowyEditorLocalizations.current.linkAddressHint; return AppFlowyEditorL10n.current.linkAddressHint;
} }
return null; return null;
}, },
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppFlowyEditorLocalizations.current.urlHint, hintText: AppFlowyEditorL10n.current.urlHint,
suffixIcon: IconButton( suffixIcon: IconButton(
icon: const Icon( icon: const Icon(
Icons.clear_rounded, Icons.clear_rounded,
@ -164,7 +163,7 @@ class _LinkEditFormState extends State<LinkEditForm> {
children: [ children: [
TextButton( TextButton(
child: Text( child: Text(
AppFlowyEditorLocalizations.current.removeLink, AppFlowyEditorL10n.current.removeLink,
style: TextStyle(color: Theme.of(context).colorScheme.error), style: TextStyle(color: Theme.of(context).colorScheme.error),
), ),
onPressed: () async { onPressed: () async {
@ -184,7 +183,7 @@ class _LinkEditFormState extends State<LinkEditForm> {
style: TextButton.styleFrom( style: TextButton.styleFrom(
textStyle: Theme.of(context).textTheme.labelLarge, textStyle: Theme.of(context).textTheme.labelLarge,
), ),
child: Text(AppFlowyEditorLocalizations.current.done), child: Text(AppFlowyEditorL10n.current.done),
onPressed: () async { onPressed: () async {
if (_formKey.currentState!.validate()) { if (_formKey.currentState!.validate()) {
final bool textChanged = final bool textChanged =

View file

@ -1,7 +1,8 @@
import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'find_replace_menu_icon_button.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'find_replace_menu_icon_button.dart';
const double _iconButtonSize = 30; const double _iconButtonSize = 30;
class FindAndReplaceMenuWidget extends StatefulWidget { class FindAndReplaceMenuWidget extends StatefulWidget {
@ -239,8 +240,7 @@ class _FindMenuState extends State<FindMenu> {
}); });
}, },
decoration: _buildInputDecoration( decoration: _buildInputDecoration(
widget.localizations?.find ?? widget.localizations?.find ?? AppFlowyEditorL10n.current.find,
AppFlowyEditorLocalizations.current.find,
), ),
), ),
), ),
@ -261,7 +261,7 @@ class _FindMenuState extends State<FindMenu> {
onPressed: () => widget.searchService.navigateToMatch(moveUp: true), onPressed: () => widget.searchService.navigateToMatch(moveUp: true),
icon: const Icon(Icons.arrow_upward), icon: const Icon(Icons.arrow_upward),
tooltip: widget.localizations?.previousMatch ?? tooltip: widget.localizations?.previousMatch ??
AppFlowyEditorLocalizations.current.previousMatch, AppFlowyEditorL10n.current.previousMatch,
), ),
// next match button // next match button
FindAndReplaceMenuIconButton( FindAndReplaceMenuIconButton(
@ -269,14 +269,14 @@ class _FindMenuState extends State<FindMenu> {
onPressed: () => widget.searchService.navigateToMatch(), onPressed: () => widget.searchService.navigateToMatch(),
icon: const Icon(Icons.arrow_downward), icon: const Icon(Icons.arrow_downward),
tooltip: widget.localizations?.nextMatch ?? tooltip: widget.localizations?.nextMatch ??
AppFlowyEditorLocalizations.current.nextMatch, AppFlowyEditorL10n.current.nextMatch,
), ),
FindAndReplaceMenuIconButton( FindAndReplaceMenuIconButton(
iconButtonKey: const Key('closeButton'), iconButtonKey: const Key('closeButton'),
onPressed: widget.onDismiss, onPressed: widget.onDismiss,
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
tooltip: widget.localizations?.close ?? tooltip: widget.localizations?.close ??
AppFlowyEditorLocalizations.current.closeFind, AppFlowyEditorL10n.current.closeFind,
), ),
// regex button // regex button
if (showRegexButton) if (showRegexButton)
@ -294,7 +294,7 @@ class _FindMenuState extends State<FindMenu> {
height: 20, height: 20,
color: widget.searchService.regex ? Colors.black : Colors.grey, color: widget.searchService.regex ? Colors.black : Colors.grey,
), ),
tooltip: AppFlowyEditorLocalizations.current.regex, tooltip: AppFlowyEditorL10n.current.regex,
), ),
// case sensitive button // case sensitive button
if (showCaseSensitiveButton) if (showCaseSensitiveButton)
@ -315,7 +315,7 @@ class _FindMenuState extends State<FindMenu> {
? Colors.black ? Colors.black
: Colors.grey, : Colors.grey,
), ),
tooltip: AppFlowyEditorLocalizations.current.caseSensitive, tooltip: AppFlowyEditorL10n.current.caseSensitive,
), ),
], ],
); );
@ -384,7 +384,7 @@ class _ReplaceMenuState extends State<ReplaceMenu> {
}, },
decoration: _buildInputDecoration( decoration: _buildInputDecoration(
widget.localizations?.replace ?? widget.localizations?.replace ??
AppFlowyEditorLocalizations.current.replace, AppFlowyEditorL10n.current.replace,
), ),
), ),
), ),
@ -393,7 +393,7 @@ class _ReplaceMenuState extends State<ReplaceMenu> {
onPressed: _replaceSelectedWord, onPressed: _replaceSelectedWord,
icon: const Icon(Icons.find_replace), icon: const Icon(Icons.find_replace),
tooltip: widget.localizations?.replace ?? tooltip: widget.localizations?.replace ??
AppFlowyEditorLocalizations.current.replace, AppFlowyEditorL10n.current.replace,
), ),
FindAndReplaceMenuIconButton( FindAndReplaceMenuIconButton(
iconButtonKey: const Key('replaceAllButton'), iconButtonKey: const Key('replaceAllButton'),
@ -402,7 +402,7 @@ class _ReplaceMenuState extends State<ReplaceMenu> {
), ),
icon: const Icon(Icons.change_circle_outlined), icon: const Icon(Icons.change_circle_outlined),
tooltip: widget.localizations?.replaceAll ?? tooltip: widget.localizations?.replaceAll ??
AppFlowyEditorLocalizations.current.replaceAll, AppFlowyEditorL10n.current.replaceAll,
), ),
], ],
); );

View file

@ -0,0 +1,5 @@
import 'package:appflowy_editor/appflowy_editor.dart';
class AppFlowyEditorL10n extends AppFlowyEditorLocalizations {
static AppFlowyEditorLocalizations current = AppFlowyEditorL10n();
}

View file

@ -238,7 +238,7 @@ class SelectionMenu extends SelectionMenuService {
final List<SelectionMenuItem> standardSelectionMenuItems = [ final List<SelectionMenuItem> standardSelectionMenuItems = [
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.text, name: AppFlowyEditorL10n.current.text,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'text', name: 'text',
isSelected: isSelected, isSelected: isSelected,
@ -250,7 +250,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.heading1, name: AppFlowyEditorL10n.current.heading1,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'h1', name: 'h1',
isSelected: isSelected, isSelected: isSelected,
@ -262,7 +262,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.heading2, name: AppFlowyEditorL10n.current.heading2,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'h2', name: 'h2',
isSelected: isSelected, isSelected: isSelected,
@ -274,7 +274,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.heading3, name: AppFlowyEditorL10n.current.heading3,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'h3', name: 'h3',
isSelected: isSelected, isSelected: isSelected,
@ -286,7 +286,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.image, name: AppFlowyEditorL10n.current.image,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'image', name: 'image',
isSelected: isSelected, isSelected: isSelected,
@ -299,7 +299,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.bulletedList, name: AppFlowyEditorL10n.current.bulletedList,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'bulleted_list', name: 'bulleted_list',
isSelected: isSelected, isSelected: isSelected,
@ -311,7 +311,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.numberedList, name: AppFlowyEditorL10n.current.numberedList,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'number', name: 'number',
isSelected: isSelected, isSelected: isSelected,
@ -323,7 +323,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.checkbox, name: AppFlowyEditorL10n.current.checkbox,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'checkbox', name: 'checkbox',
isSelected: isSelected, isSelected: isSelected,
@ -335,7 +335,7 @@ final List<SelectionMenuItem> standardSelectionMenuItems = [
}, },
), ),
SelectionMenuItem( SelectionMenuItem(
name: AppFlowyEditorLocalizations.current.quote, name: AppFlowyEditorL10n.current.quote,
icon: (editorState, isSelected, style) => SelectionMenuIconWidget( icon: (editorState, isSelected, style) => SelectionMenuIconWidget(
name: 'quote', name: 'quote',
isSelected: isSelected, isSelected: isSelected,

View file

@ -13,7 +13,7 @@ final ToolbarItem bulletedListItem = ToolbarItem(
isHighlight: isHighlight, isHighlight: isHighlight,
highlightColor: highlightColor, highlightColor: highlightColor,
iconColor: iconColor, iconColor: iconColor,
tooltip: AppFlowyEditorLocalizations.current.bulletedList, tooltip: AppFlowyEditorL10n.current.bulletedList,
onPressed: () => editorState.formatNode( onPressed: () => editorState.formatNode(
selection, selection,
(node) => node.copyWith( (node) => node.copyWith(

View file

@ -45,8 +45,8 @@ void showColorMenu(
builder: (context) { builder: (context) {
return ColorPicker( return ColorPicker(
title: isTextColor title: isTextColor
? AppFlowyEditorLocalizations.current.textColor ? AppFlowyEditorL10n.current.textColor
: AppFlowyEditorLocalizations.current.highlightColor, : AppFlowyEditorL10n.current.highlightColor,
showClearButton: showClearButton, showClearButton: showClearButton,
selectedColorHex: currentColorHex, selectedColorHex: currentColorHex,
colorOptions: isTextColor colorOptions: isTextColor
@ -70,8 +70,8 @@ void showColorMenu(
keepEditorFocusNotifier.decrease(); keepEditorFocusNotifier.decrease();
}, },
resetText: isTextColor resetText: isTextColor
? AppFlowyEditorLocalizations.current.resetToDefaultColor ? AppFlowyEditorL10n.current.resetToDefaultColor
: AppFlowyEditorLocalizations.current.clearHighlightColor, : AppFlowyEditorL10n.current.clearHighlightColor,
resetIconName: resetIconName:
isTextColor ? 'reset_text_color' : 'clear_highlight_color', isTextColor ? 'reset_text_color' : 'clear_highlight_color',
); );

View file

@ -231,7 +231,7 @@ class _CustomColorItemState extends State<CustomColorItem> {
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
AppFlowyEditorLocalizations.current.customColor, AppFlowyEditorL10n.current.customColor,
style: Theme.of(context).textTheme.labelLarge, style: Theme.of(context).textTheme.labelLarge,
// same style as TextButton.icon // same style as TextButton.icon
), ),
@ -241,7 +241,7 @@ class _CustomColorItemState extends State<CustomColorItem> {
children: [ children: [
const SizedBox(height: 6), const SizedBox(height: 6),
_customColorDetailsTextField( _customColorDetailsTextField(
labelText: AppFlowyEditorLocalizations.current.hexValue, labelText: AppFlowyEditorL10n.current.hexValue,
controller: widget.colorController, controller: widget.colorController,
// update the color sample box when the text changes // update the color sample box when the text changes
onChanged: (_) => setState(() {}), onChanged: (_) => setState(() {}),
@ -249,7 +249,7 @@ class _CustomColorItemState extends State<CustomColorItem> {
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
_customColorDetailsTextField( _customColorDetailsTextField(
labelText: AppFlowyEditorLocalizations.current.opacity, labelText: AppFlowyEditorL10n.current.opacity,
controller: widget.opacityController, controller: widget.opacityController,
// update the color sample box when the text changes // update the color sample box when the text changes
onChanged: (_) => setState(() {}), onChanged: (_) => setState(() {}),

View file

@ -21,7 +21,7 @@ ToolbarItem buildHighlightColorItem({List<ColorOption>? colorOptions}) {
isHighlight: isHighlight, isHighlight: isHighlight,
highlightColor: highlightColor, highlightColor: highlightColor,
iconColor: iconColor, iconColor: iconColor,
tooltip: AppFlowyEditorLocalizations.current.highlightColor, tooltip: AppFlowyEditorL10n.current.highlightColor,
onPressed: () { onPressed: () {
bool showClearButton = false; bool showClearButton = false;
nodes.allSatisfyInSelection(selection, (delta) { nodes.allSatisfyInSelection(selection, (delta) {

View file

@ -22,7 +22,7 @@ ToolbarItem buildTextColorItem({
isHighlight: isHighlight, isHighlight: isHighlight,
highlightColor: highlightColor, highlightColor: highlightColor,
iconColor: iconColor, iconColor: iconColor,
tooltip: AppFlowyEditorLocalizations.current.textColor, tooltip: AppFlowyEditorL10n.current.textColor,
onPressed: () { onPressed: () {
bool showClearButton = false; bool showClearButton = false;
nodes.allSatisfyInSelection( nodes.allSatisfyInSelection(

View file

@ -6,31 +6,31 @@ final List<ToolbarItem> markdownFormatItems = [
id: 'underline', id: 'underline',
name: 'underline', name: 'underline',
tooltip: tooltip:
'${AppFlowyEditorLocalizations.current.underline}${shortcutTooltips('⌘ + U', 'CTRL + U', 'CTRL + U')}', '${AppFlowyEditorL10n.current.underline}${shortcutTooltips('⌘ + U', 'CTRL + U', 'CTRL + U')}',
), ),
_FormatToolbarItem( _FormatToolbarItem(
id: 'bold', id: 'bold',
name: 'bold', name: 'bold',
tooltip: tooltip:
'${AppFlowyEditorLocalizations.current.bold}${shortcutTooltips('⌘ + B', 'CTRL + B', 'CTRL + B')}', '${AppFlowyEditorL10n.current.bold}${shortcutTooltips('⌘ + B', 'CTRL + B', 'CTRL + B')}',
), ),
_FormatToolbarItem( _FormatToolbarItem(
id: 'italic', id: 'italic',
name: 'italic', name: 'italic',
tooltip: tooltip:
'${AppFlowyEditorLocalizations.current.italic}${shortcutTooltips('⌘ + I', 'CTRL + I', 'CTRL + I')}', '${AppFlowyEditorL10n.current.italic}${shortcutTooltips('⌘ + I', 'CTRL + I', 'CTRL + I')}',
), ),
_FormatToolbarItem( _FormatToolbarItem(
id: 'strikethrough', id: 'strikethrough',
name: 'strikethrough', name: 'strikethrough',
tooltip: tooltip:
'${AppFlowyEditorLocalizations.current.strikethrough}${shortcutTooltips('⌘ + SHIFT + S', 'CTRL + SHIFT + S', 'CTRL + SHIFT + S')}', '${AppFlowyEditorL10n.current.strikethrough}${shortcutTooltips('⌘ + SHIFT + S', 'CTRL + SHIFT + S', 'CTRL + SHIFT + S')}',
), ),
_FormatToolbarItem( _FormatToolbarItem(
id: 'code', id: 'code',
name: 'code', name: 'code',
tooltip: tooltip:
'${AppFlowyEditorLocalizations.current.embedCode}${shortcutTooltips('⌘ + E', 'CTRL + E', 'CTRL + E')}', '${AppFlowyEditorL10n.current.embedCode}${shortcutTooltips('⌘ + E', 'CTRL + E', 'CTRL + E')}',
), ),
]; ];

View file

@ -46,11 +46,11 @@ class _HeadingToolbarItem extends ToolbarItem {
static String levelToTooltips(int level) { static String levelToTooltips(int level) {
if (level == 1) { if (level == 1) {
return AppFlowyEditorLocalizations.current.heading1; return AppFlowyEditorL10n.current.heading1;
} else if (level == 2) { } else if (level == 2) {
return AppFlowyEditorLocalizations.current.heading2; return AppFlowyEditorL10n.current.heading2;
} else if (level == 3) { } else if (level == 3) {
return AppFlowyEditorLocalizations.current.heading3; return AppFlowyEditorL10n.current.heading3;
} }
return ''; return '';
} }

View file

@ -1,9 +1,7 @@
import 'package:appflowy_editor/src/editor_state.dart'; import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/infra/flowy_svg.dart'; import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
import 'package:appflowy_editor/src/l10n/l10n.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:appflowy_editor/src/editor/toolbar/desktop/items/utils/overlay_util.dart';
class LinkMenu extends StatefulWidget { class LinkMenu extends StatefulWidget {
const LinkMenu({ const LinkMenu({
@ -56,7 +54,7 @@ class _LinkMenuState extends State<LinkMenu> {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
EditorOverlayTitle( EditorOverlayTitle(
text: AppFlowyEditorLocalizations.current.addYourLink, text: AppFlowyEditorL10n.current.addYourLink,
), ),
const SizedBox(height: 16.0), const SizedBox(height: 16.0),
_buildInput(), _buildInput(),
@ -64,17 +62,17 @@ class _LinkMenuState extends State<LinkMenu> {
if (widget.linkText != null) ...[ if (widget.linkText != null) ...[
_buildIconButton( _buildIconButton(
iconName: 'link', iconName: 'link',
text: AppFlowyEditorLocalizations.current.openLink, text: AppFlowyEditorL10n.current.openLink,
onPressed: widget.onOpenLink, onPressed: widget.onOpenLink,
), ),
_buildIconButton( _buildIconButton(
iconName: 'copy', iconName: 'copy',
text: AppFlowyEditorLocalizations.current.copyLink, text: AppFlowyEditorL10n.current.copyLink,
onPressed: widget.onCopyLink, onPressed: widget.onCopyLink,
), ),
_buildIconButton( _buildIconButton(
iconName: 'delete', iconName: 'delete',
text: AppFlowyEditorLocalizations.current.removeLink, text: AppFlowyEditorL10n.current.removeLink,
onPressed: widget.onRemoveLink, onPressed: widget.onRemoveLink,
), ),
], ],
@ -98,7 +96,7 @@ class _LinkMenuState extends State<LinkMenu> {
controller: _textEditingController, controller: _textEditingController,
onSubmitted: widget.onSubmitted, onSubmitted: widget.onSubmitted,
decoration: InputDecoration( decoration: InputDecoration(
hintText: AppFlowyEditorLocalizations.current.urlHint, hintText: AppFlowyEditorL10n.current.urlHint,
contentPadding: const EdgeInsets.all(16.0), contentPadding: const EdgeInsets.all(16.0),
isDense: true, isDense: true,
suffixIcon: IconButton( suffixIcon: IconButton(

View file

@ -24,7 +24,7 @@ final linkItem = ToolbarItem(
isHighlight: isHref, isHighlight: isHref,
highlightColor: highlightColor, highlightColor: highlightColor,
iconColor: iconColor, iconColor: iconColor,
tooltip: AppFlowyEditorLocalizations.current.link, tooltip: AppFlowyEditorL10n.current.link,
onPressed: () { onPressed: () {
showLinkMenu(context, editorState, selection, isHref); showLinkMenu(context, editorState, selection, isHref);
}, },

Some files were not shown because too many files have changed in this diff Show more