Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - selectedTextColorStrategy's originalTextColor ignores ColorAttributions #2093

Open
KevinBrendel opened this issue Jun 12, 2024 · 0 comments · May be fixed by #2122
Open

[BUG] - selectedTextColorStrategy's originalTextColor ignores ColorAttributions #2093

KevinBrendel opened this issue Jun 12, 2024 · 0 comments · May be fixed by #2122
Assignees
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior f:superlist Funded by Superlist time: 5 type_bug Something isn't working

Comments

@KevinBrendel
Copy link
Contributor

Package Version
super_editor, GitHub, stable branch

User Info
coneno GmbH, QuikFlow

To Reproduce
Steps to reproduce the behavior:

  1. Select the colored text

Minimal Reproduction Code

Minimal, Runnable Code Sample
import 'package:flutter/material.dart';
import 'package:super_editor/super_editor.dart';

void main() {
runApp(const MainApp());
}

class MainApp extends StatefulWidget {
const MainApp({super.key});

@override
State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
static const _colorAttribution = ColorAttribution(Colors.red);
final _document = MutableDocument(nodes: [
  ParagraphNode(
    id: Editor.createNodeId(),
    text: AttributedText(
        'Hello, world!',
        AttributedSpans(attributions: const [
          SpanMarker(attribution: _colorAttribution, offset: 0, markerType: SpanMarkerType.start),
          SpanMarker(attribution: _colorAttribution, offset: 4, markerType: SpanMarkerType.end),
        ])),
  ),
]);
final _composer = MutableDocumentComposer();
late final Editor _editor;

@override
void initState() {
  super.initState();
  _editor = createDefaultDocumentEditor(document: _document, composer: _composer);
}

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      body: Center(
        child: SuperEditor(
          editor: _editor,
          document: _document,
          composer: _composer,
          stylesheet: defaultStylesheet.copyWith(
            selectedTextColorStrategy: ({required originalTextColor, required selectionHighlightColor}) =>
                originalTextColor,
          ),
        ),
      ),
    ),
  );
}
}

Actual behavior
The selectedTextColorStrategy, which just returns the originalTextColor, returns the text color as if there were no ColorAttributions.

Expected behavior
The originalTextColor is provided with the ColorAttributions applied so that it reflects the actually visible color to the user and can be correctly modified to stay visible with regard to the selectionHighlightColor. Alternatively, the Attributions should be made available in this function as a parameter, so that it can itself implement the desired behavior.

Platform
macOS

Flutter version
Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 761747bfc5 (7 days ago) • 2024-06-05 22:15:13 +0200
Engine • revision edd8546116
Tools • Dart 3.4.3 • DevTools 2.34.3

Screenshots
Screenshot 2024-06-12 at 14 52 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area_super_reader Related to SuperReader area_supereditor Pertains to SuperEditor area_supertextfield Pertains to SuperTextField bounty_junior f:superlist Funded by Superlist time: 5 type_bug Something isn't working
Projects
None yet
3 participants