|
@@ -3,7 +3,7 @@ import 'package:appflowy/plugins/document/presentation/editor_plugins/base/selec
|
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/string_extension.dart';
|
|
import 'package:appflowy/plugins/document/presentation/editor_plugins/base/string_extension.dart';
|
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
|
import 'package:appflowy_editor/appflowy_editor.dart';
|
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
|
import 'package:appflowy_popover/appflowy_popover.dart';
|
|
-import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
|
+import 'package:easy_localization/easy_localization.dart' hide TextDirection;
|
|
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/material.dart';
|
|
import 'package:highlight/highlight.dart' as highlight;
|
|
import 'package:highlight/highlight.dart' as highlight;
|
|
@@ -98,7 +98,11 @@ class CodeBlockComponentWidget extends BlockComponentStatefulWidget {
|
|
}
|
|
}
|
|
|
|
|
|
class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
- with SelectableMixin, DefaultSelectableMixin, BlockComponentConfigurable {
|
|
|
|
|
|
+ with
|
|
|
|
+ SelectableMixin,
|
|
|
|
+ DefaultSelectableMixin,
|
|
|
|
+ BlockComponentConfigurable,
|
|
|
|
+ BlockComponentTextDirectionMixin {
|
|
// the key used to forward focus to the richtext child
|
|
// the key used to forward focus to the richtext child
|
|
@override
|
|
@override
|
|
final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text');
|
|
final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text');
|
|
@@ -175,6 +179,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
..add('c')
|
|
..add('c')
|
|
..sort();
|
|
..sort();
|
|
|
|
|
|
|
|
+ @override
|
|
late final editorState = context.read<EditorState>();
|
|
late final editorState = context.read<EditorState>();
|
|
|
|
|
|
String? get language => node.attributes[CodeBlockKeys.language] as String?;
|
|
String? get language => node.attributes[CodeBlockKeys.language] as String?;
|
|
@@ -182,6 +187,9 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
|
|
+ final textDirection = calculateTextDirection(
|
|
|
|
+ layoutDirection: Directionality.maybeOf(context),
|
|
|
|
+ );
|
|
Widget child = Container(
|
|
Widget child = Container(
|
|
decoration: BoxDecoration(
|
|
decoration: BoxDecoration(
|
|
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
|
borderRadius: const BorderRadius.all(Radius.circular(8.0)),
|
|
@@ -191,9 +199,10 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
child: Column(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
+ textDirection: textDirection,
|
|
children: [
|
|
children: [
|
|
_buildSwitchLanguageButton(context),
|
|
_buildSwitchLanguageButton(context),
|
|
- _buildCodeBlock(context),
|
|
|
|
|
|
+ _buildCodeBlock(context, textDirection),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -226,7 +235,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
return child;
|
|
return child;
|
|
}
|
|
}
|
|
|
|
|
|
- Widget _buildCodeBlock(BuildContext context) {
|
|
|
|
|
|
+ Widget _buildCodeBlock(BuildContext context, TextDirection textDirection) {
|
|
final delta = node.delta ?? Delta();
|
|
final delta = node.delta ?? Delta();
|
|
final content = delta.toPlainText();
|
|
final content = delta.toPlainText();
|
|
|
|
|
|
@@ -258,6 +267,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
|
|
placeholderTextSpanDecorator: (textSpan) => TextSpan(
|
|
placeholderTextSpanDecorator: (textSpan) => TextSpan(
|
|
style: textStyle,
|
|
style: textStyle,
|
|
),
|
|
),
|
|
|
|
+ textDirection: textDirection,
|
|
cursorColor: editorState.editorStyle.cursorColor,
|
|
cursorColor: editorState.editorStyle.cursorColor,
|
|
selectionColor: editorState.editorStyle.selectionColor,
|
|
selectionColor: editorState.editorStyle.selectionColor,
|
|
),
|
|
),
|