From f36f615b36592e3fad69651a18cac903d9be9b65 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 21:15:48 +0000 Subject: [PATCH 1/2] Initial plan From bd2aed1bd15c06db7f653492f81e9f6c3d22c8f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 25 Mar 2026 21:19:03 +0000 Subject: [PATCH 2/2] Address PR review: custom typeRegistry test, CI version pin, example pubspec flutter section Co-authored-by: RZEROSTERN <3065243+RZEROSTERN@users.noreply.github.com> Agent-Logs-Url: https://github.com/RZEROSTERN/editorjs-flutter/sessions/913476ea-4c30-4220-b059-270bfa4fcc70 --- .github/workflows/ci.yml | 1 + example/pubspec.yaml | 3 +++ test/unit/editor_controller_test.dart | 32 +++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa66287..e0ed498 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: - uses: subosito/flutter-action@v2 with: + flutter-version: '3.41.5' channel: stable - name: Install dependencies diff --git a/example/pubspec.yaml b/example/pubspec.yaml index fc650fb..0200ead 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -11,3 +11,6 @@ dependencies: sdk: flutter editorjs_flutter: path: ../ + +flutter: + uses-material-design: true diff --git a/test/unit/editor_controller_test.dart b/test/unit/editor_controller_test.dart index ddea793..8a065d8 100644 --- a/test/unit/editor_controller_test.dart +++ b/test/unit/editor_controller_test.dart @@ -253,11 +253,39 @@ void main() { }); test('respects custom typeRegistry parameter', () { - // Using default registry — header should be parsed const json = '{"blocks":[{"type":"header","data":{"text":"Hi","level":1}}]}'; - final ctrl = EditorController.fromJson(json); + + // Custom registry that alters how header blocks are created + final customRegistry = BlockTypeRegistry() + ..register(_PrefixedHeaderMapper('Custom: ')); + + final ctrl = EditorController.fromJson( + json, + typeRegistry: customRegistry, + ); + expect(ctrl.blockCount, 1); + expect(ctrl.blocks.first, isA()); + final headerBlock = ctrl.blocks.first as HeaderBlock; + expect(headerBlock.text, 'Custom: Hi'); + expect(headerBlock.level, 1); }); }); } + +/// A [BlockMapper] that prefixes header text — used to verify custom +/// registries are respected by [EditorController.fromJson]. +class _PrefixedHeaderMapper implements BlockMapper { + final String prefix; + const _PrefixedHeaderMapper(this.prefix); + + @override + String get supportedType => 'header'; + + @override + HeaderBlock fromJson(Map data) => HeaderBlock( + text: '$prefix${data['text'] ?? ''}', + level: data['level'] is int ? data['level'] as int : 1, + ); +}