chore: add toolbar id
This commit is contained in:
parent
4c4cc415d5
commit
4536488faf
13 changed files with 33 additions and 8 deletions
|
|
@ -74,7 +74,7 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
...textDirectionItems,
|
||||
...alignmentItems,
|
||||
],
|
||||
tooltipBuilder: (context, message, child) {
|
||||
tooltipBuilder: (context, _, message, child) {
|
||||
return Tooltip(
|
||||
message: message,
|
||||
preferBelow: false,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ const floatingToolbarItemPrefixKey = 'appflowy_editor_floating_toolbar_item';
|
|||
|
||||
typedef ToolbarTooltipBuilder = Widget Function(
|
||||
BuildContext context,
|
||||
String id,
|
||||
String message,
|
||||
Widget child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ class _AlignmentToolbarItem extends ToolbarItem {
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
id,
|
||||
getTooltipText(id),
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kBulletedListItemId = 'editor.bulleted_list';
|
||||
|
||||
final ToolbarItem bulletedListItem = ToolbarItem(
|
||||
id: 'editor.bulleted_list',
|
||||
id: _kBulletedListItemId,
|
||||
group: 3,
|
||||
isActive: onlyShowInSingleSelectionAndTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -24,6 +26,7 @@ final ToolbarItem bulletedListItem = ToolbarItem(
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kBulletedListItemId,
|
||||
AppFlowyEditorL10n.current.bulletedList,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kHighlightColorItemId = 'editor.highlightColor';
|
||||
|
||||
ToolbarItem buildHighlightColorItem({List<ColorOption>? colorOptions}) {
|
||||
return ToolbarItem(
|
||||
id: 'editor.highlightColor',
|
||||
id: _kHighlightColorItemId,
|
||||
group: 4,
|
||||
isActive: onlyShowInTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -51,6 +53,7 @@ ToolbarItem buildHighlightColorItem({List<ColorOption>? colorOptions}) {
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kHighlightColorItemId,
|
||||
AppFlowyEditorL10n.current.highlightColor,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kTextColorItemId = 'editor.textColor';
|
||||
|
||||
ToolbarItem buildTextColorItem({
|
||||
List<ColorOption>? colorOptions,
|
||||
}) {
|
||||
return ToolbarItem(
|
||||
id: 'editor.textColor',
|
||||
id: _kTextColorItemId,
|
||||
group: 4,
|
||||
isActive: onlyShowInTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -55,6 +57,7 @@ ToolbarItem buildTextColorItem({
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kTextColorItemId,
|
||||
AppFlowyEditorL10n.current.textColor,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ class _FormatToolbarItem extends ToolbarItem {
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
id,
|
||||
getTooltipText(id),
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class _HeadingToolbarItem extends ToolbarItem {
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
'editor.h$level',
|
||||
levelToTooltips(level),
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ import 'package:string_validator/string_validator.dart';
|
|||
const _menuWidth = 300;
|
||||
const _hasTextHeight = 244;
|
||||
const _noTextHeight = 150;
|
||||
const _kLinkItemId = 'editor.link';
|
||||
|
||||
final linkItem = ToolbarItem(
|
||||
id: 'editor.link',
|
||||
id: _kLinkItemId,
|
||||
group: 4,
|
||||
isActive: onlyShowInSingleSelectionAndTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -33,6 +34,7 @@ final linkItem = ToolbarItem(
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kLinkItemId,
|
||||
AppFlowyEditorL10n.current.link,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kNumberedListItemId = 'editor.numbered_list';
|
||||
|
||||
final ToolbarItem numberedListItem = ToolbarItem(
|
||||
id: 'editor.numbered_list',
|
||||
id: _kNumberedListItemId,
|
||||
group: 3,
|
||||
isActive: onlyShowInSingleSelectionAndTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -24,6 +26,7 @@ final ToolbarItem numberedListItem = ToolbarItem(
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kNumberedListItemId,
|
||||
AppFlowyEditorL10n.current.numberedList,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kParagraphItemId = 'editor.paragraph';
|
||||
|
||||
final ToolbarItem paragraphItem = ToolbarItem(
|
||||
id: 'editor.paragraph',
|
||||
id: _kParagraphItemId,
|
||||
group: 1,
|
||||
isActive: onlyShowInSingleSelectionAndTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -32,6 +34,7 @@ final ToolbarItem paragraphItem = ToolbarItem(
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kParagraphItemId,
|
||||
AppFlowyEditorL10n.current.text,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:appflowy_editor/appflowy_editor.dart';
|
||||
|
||||
const _kQuoteItemId = 'editor.quote';
|
||||
|
||||
final ToolbarItem quoteItem = ToolbarItem(
|
||||
id: 'editor.quote',
|
||||
id: _kQuoteItemId,
|
||||
group: 3,
|
||||
isActive: onlyShowInSingleSelectionAndTextType,
|
||||
builder: (context, editorState, highlightColor, iconColor, tooltipBuilder) {
|
||||
|
|
@ -24,6 +26,7 @@ final ToolbarItem quoteItem = ToolbarItem(
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
_kQuoteItemId,
|
||||
AppFlowyEditorL10n.current.quote,
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class _TextDirectionToolbarItem extends ToolbarItem {
|
|||
if (tooltipBuilder != null) {
|
||||
return tooltipBuilder(
|
||||
context,
|
||||
id,
|
||||
getTooltipText(id),
|
||||
child,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue