fleather-editor / fleather

Soft and gentle rich text editing for Flutter applications.
https://fleather-editor.github.io
Other
205 stars 37 forks source link

Markdown encoding throws exception for multi level lists #361

Closed simonbengtsson closed 3 months ago

simonbengtsson commented 5 months ago

Steps to Reproduce

With editor

With code

final doc = ParchmentDocument.fromDelta(
  Delta()
    ..insert('Hello')
    ..insert('\n', {'block': 'ul'})
    ..insert('World')
    ..insert('\n', {'block': 'ul', 'indent': 1})
    ..insert('\n'),
  );
final markdown = parchmentMarkdown.encode(doc); // Throws exception (see below)
print('Markdown: $markdown');

Environment

Logs

Unhandled Exception: Invalid argument(s): Cannot handle indent: 1
#0      _ParchmentMarkdownEncoder._writeAttribute (package:parchment/src/codecs/markdown.dart:495:7)
#1      _ParchmentMarkdownEncoder.convert.handleLine (package:parchment/src/codecs/markdown.dart:412:11)
[...]
amantoux commented 3 months ago

@simonbengtsson thank you for reporting this Can you please try with the below and tell me if it covers all your use cases

  fleather:
    git:
      url: https://github.com/fleather-editor/fleather
      ref: fix/fix/mardown_codec_list_with_indent
      path: packages/fleather
simonbengtsson commented 3 months ago

Worked perfectly! Awesome! Had to use the following dependency override, but might be related to my setup.

dependency_overrides:
  parchment:
    git:
      url: https://github.com/fleather-editor/fleather
      ref: fix/mardown_codec_list_with_indent
      path: packages/parchment
  fleather:
    git:
      url: https://github.com/fleather-editor/fleather
      ref: fix/mardown_codec_list_with_indent
      path: packages/fleather
amantoux commented 3 months ago

Worked perfectly! Awesome! Had to use the following dependency override, but might be related to my setup.

dependency_overrides:
  parchment:
    git:
      url: https://github.com/fleather-editor/fleather
      ref: fix/mardown_codec_list_with_indent
      path: packages/parchment
  fleather:
    git:
      url: https://github.com/fleather-editor/fleather
      ref: fix/mardown_codec_list_with_indent
      path: packages/fleather

My bad!

Thanks