mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-02 19:13:28 +00:00
feat: use font name instead of name_regular (#5163)
This commit is contained in:
parent
3fce5eebf8
commit
3c446d5e78
@ -51,8 +51,7 @@ class FontFamilyItem extends StatelessWidget {
|
|||||||
if (newFont != null && !selection.isCollapsed) {
|
if (newFont != null && !selection.isCollapsed) {
|
||||||
if (newFont != fontFamily) {
|
if (newFont != fontFamily) {
|
||||||
await editorState.formatDelta(selection, {
|
await editorState.formatDelta(selection, {
|
||||||
AppFlowyRichTextKeys.fontFamily:
|
AppFlowyRichTextKeys.fontFamily: newFont,
|
||||||
GoogleFonts.getFont(newFont).fontFamily,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:appflowy/core/helpers/url_launcher.dart';
|
import 'package:appflowy/core/helpers/url_launcher.dart';
|
||||||
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
||||||
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mention_block.dart';
|
||||||
@ -15,6 +12,8 @@ import 'package:appflowy/workspace/application/settings/appearance/appearance_cu
|
|||||||
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
|
import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
|
||||||
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
|
import 'package:appflowy_editor/appflowy_editor.dart' hide Log;
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
import 'package:flutter/gestures.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
@ -248,7 +247,16 @@ class EditorStyleCustomizer {
|
|||||||
// try to refresh font here.
|
// try to refresh font here.
|
||||||
if (attributes.fontFamily != null) {
|
if (attributes.fontFamily != null) {
|
||||||
try {
|
try {
|
||||||
GoogleFonts.getFont(attributes.fontFamily!.parseFontFamilyName());
|
if (before.text?.contains('_regular') == true) {
|
||||||
|
GoogleFonts.getFont(attributes.fontFamily!.parseFontFamilyName());
|
||||||
|
} else {
|
||||||
|
return TextSpan(
|
||||||
|
text: before.text,
|
||||||
|
style: after.style?.merge(
|
||||||
|
GoogleFonts.getFont(attributes.fontFamily!),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
||||||
import 'package:appflowy/generated/locale_keys.g.dart';
|
import 'package:appflowy/generated/locale_keys.g.dart';
|
||||||
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
|
||||||
@ -10,6 +8,7 @@ import 'package:appflowy_popover/appflowy_popover.dart';
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
@ -186,7 +185,7 @@ class _FontFamilyDropDownState extends State<FontFamilyDropDown> {
|
|||||||
: null,
|
: null,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.onFontFamilyChanged != null) {
|
if (widget.onFontFamilyChanged != null) {
|
||||||
widget.onFontFamilyChanged!(style.fontFamily!);
|
widget.onFontFamilyChanged!(buttonFontFamily);
|
||||||
} else {
|
} else {
|
||||||
final fontFamily = style.fontFamily!.parseFontFamilyName();
|
final fontFamily = style.fontFamily!.parseFontFamilyName();
|
||||||
if (widget.currentFontFamily.parseFontFamilyName() !=
|
if (widget.currentFontFamily.parseFontFamilyName() !=
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user