editor_styles.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import 'package:appflowy_editor/appflowy_editor.dart';
  2. import 'package:flowy_infra/theme.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:provider/provider.dart';
  5. EditorStyle customEditorTheme(BuildContext context) {
  6. final theme = context.watch<AppTheme>();
  7. const baseFontSize = 14.0;
  8. const basePadding = 12.0;
  9. var editorStyle = theme.isDark ? EditorStyle.dark : EditorStyle.light;
  10. editorStyle = editorStyle.copyWith(
  11. textStyle: editorStyle.textStyle?.copyWith(
  12. fontFamily: 'poppins',
  13. fontSize: baseFontSize,
  14. ),
  15. bold: editorStyle.bold?.copyWith(
  16. fontWeight: FontWeight.w500,
  17. ),
  18. );
  19. return editorStyle;
  20. }
  21. Iterable<ThemeExtension<dynamic>> customPluginTheme(BuildContext context) {
  22. final theme = context.watch<AppTheme>();
  23. return theme.isDark ? darkPlguinStyleExtension : lightPlguinStyleExtension;
  24. }
  25. // return EditorStyle.defaultStyle().copyWith(
  26. // padding = const EdgeInsets.symmetric(horizontal: 80),
  27. // textStyle = textStyle,
  28. // pluginStyles = {
  29. // 'text/heading': builtInPluginStyle
  30. // ..update(
  31. // 'textStyle',
  32. // (_) => (EditorState editorState, Node node) {
  33. // final headingToFontSize = {
  34. // 'h1': baseFontSize + 12,
  35. // 'h2': baseFontSize + 8,
  36. // 'h3': baseFontSize + 4,
  37. // 'h4': baseFontSize,
  38. // 'h5': baseFontSize,
  39. // 'h6': baseFontSize,
  40. // };
  41. // final fontSize =
  42. // headingToFontSize[node.attributes.heading] ?? baseFontSize;
  43. // return TextStyle(fontSize: fontSize, fontWeight: FontWeight.w600);
  44. // },
  45. // )
  46. // ..update(
  47. // 'padding',
  48. // (_) => (EditorState editorState, Node node) {
  49. // final headingToPadding = {
  50. // 'h1': basePadding + 6,
  51. // 'h2': basePadding + 4,
  52. // 'h3': basePadding + 2,
  53. // 'h4': basePadding,
  54. // 'h5': basePadding,
  55. // 'h6': basePadding,
  56. // };
  57. // final padding =
  58. // headingToPadding[node.attributes.heading] ?? basePadding;
  59. // return EdgeInsets.only(bottom: padding);
  60. // },
  61. // ),
  62. // 'text/number-list': builtInPluginStyle
  63. // ..addAll(
  64. // {
  65. // 'numberColor': (EditorState editorState, Node node) {
  66. // final theme = context.watch<AppTheme>();
  67. // return theme.isDark ? Colors.white : Colors.black;
  68. // },
  69. // },
  70. // ),
  71. // 'text/bulleted-list': builtInPluginStyle
  72. // ..addAll(
  73. // {
  74. // 'bulletColor': (EditorState editorState, Node node) {
  75. // final theme = context.watch<AppTheme>();
  76. // return theme.isDark ? Colors.white : Colors.black;
  77. // },
  78. // },
  79. // ),
  80. // },
  81. // );
  82. // }