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

Line attributes revert to the previous line's state after a line break in Korean input #439

Open
mooneff opened this issue Dec 15, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mooneff
Copy link

mooneff commented Dec 15, 2024

Steps to Reproduce

Hello, thank you for developing fleather-editor. It has been a great help in our development.

There is a bug in Korean language(한국어) input where the line's formatting reverts to the previous line's state after a line break and subsequent text input.

Korean is a language where letters are formed by combining consonants and vowels. Consonants are located on the left side of the keyboard, and vowels are on the right.
For example:

"ㄱ" + "ㅏ" = "가"
"ㅇ" + "ㅓ" + "ㅇ" = "엉"
Unlike other languages, typing in Korean often requires pressing the keyboard multiple times to create a single character.

The issue occurs in the following scenarios, all scenarios start with the editor in an empty state.

Input "ㄱㄱㄱ" → (line break) → Add formatting such as a checklist or list → Type "ㄱ" → Type "ㅏ".

Add formatting such as a checklist or list, type any string → (line break) → (line break) → Type "ㄱ" → Type "ㅏ".

Set indentation to level 1 → (line break) → Change indentation to level 2 → Type "ㄱ" → Type "ㅏ".

Start with an empty line → Apply formatting such as bold, italic, or underline → Type "ㄱ" → Type "ㅏ".

Summary:
In cases 1, 2, and 3, the issue occurs when the keyboard is pressed multiple times, but the actual character count does not increase after a line break. However, this does not happen when a complete character is formed after the line break (e.g., typing "ㅇ" + "ㅇ" + "ㅏ" after a line break works fine).
In case 4, although no line break is involved, the issue seems similar in that the formatting attempts to revert to its previous state.

This issue occurs only in the iOS environment and does not happen on Android.

Thank you for developing fleather-editor.

Environment

  • OS [iOS]
  • Flutter version [3.22.3]
  • Fleather version [e.g. 1.19.0]

fleather_report

Logs

import 'dart:convert';
import 'dart:io';

import 'package:fleather/fleather.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});


  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  final FleatherController _controller = FleatherController();
  final GlobalKey<EditorState> _editorKey = GlobalKey();


  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
              children: [
                FleatherToolbar.basic(
                    controller: _controller, editorKey: _editorKey),
                Divider(height: 1, thickness: 1, color: Colors.grey.shade200),
                Expanded(
                  child: FleatherEditor(
                    controller: _controller,
                    editorKey: _editorKey,
                    padding: EdgeInsets.only(
                      left: 16,
                      right: 16,
                      bottom: MediaQuery.of(context).padding.bottom,
                    ),
                    maxContentWidth: 800,
                  ),
                ),
              ],
            ),
      ),
    );
  }
}
@Amir-P
Copy link
Member

Amir-P commented Jan 1, 2025

Hi @mooneff , thanks for reporting the issue. After carefully looking into text deltas received on iOS platform, it seems like a Flutter issue to me. Here are text editing deltas received after entering "ㅏ" in two different scenarios:

  1. It's on the first line
TextEditingDeltaNonTextUpdate#df33a(oldText:

  , selection: TextSelection(baseOffset: 0, extentOffset: 1, isDirectional: false), composing: TextRange(start: -1, end: -1))
TextEditingDeltaDeletion#6b0f0(oldText:

  , textDeleted: ㄱ, deletedRange: TextRange(start: 0, end: 1), selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
TextEditingDeltaInsertion#353ad(oldText:
  , textInserted: 가, insertionOffset: 0, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
  1. It's on the second line
TextEditingDeltaNonTextUpdate#c400d(oldText:


  , selection: TextSelection(baseOffset: 1, extentOffset: 3, isDirectional: false), composing: TextRange(start: -1, end: -1))
TextEditingDeltaDeletion#f18fa(oldText:


  , textDeleted:


  , deletedRange: TextRange(start: 1, end: 3), selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
TextEditingDeltaInsertion#f968e(oldText:

  , textInserted:
  , insertionOffset: 1, selection: TextSelection.collapsed(offset: 2, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: TextEditingDeltaInsertion#df078(oldText:

  , textInserted: 가, insertionOffset: 2, selection: TextSelection.collapsed(offset: 3, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))

As it can be seen, in the second scenario, the TextEditingDeltaDeletion removes a new line character too which causes the issue. Will create a Flutter issue.

@Amir-P Amir-P self-assigned this Jan 1, 2025
@Amir-P Amir-P added the bug Something isn't working label Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants