Skip to content

Commit 3553677

Browse files
authored
Merge branch 'master' into chore/pubspec-details
2 parents 877e15e + 6154d2b commit 3553677

14 files changed

Lines changed: 99 additions & 268 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515

1616
- uses: subosito/flutter-action@v2
1717
with:
18+
flutter-version: '3.41.5'
1819
channel: stable
1920

2021
- name: Install dependencies
File renamed without changes.

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# EditorJS viewer for Flutter
22

3-
A viewer and editor compatible with the EditorJS schema.
3+
A viewer and editor compatible with the [EditorJS](https://editorjs.io/) JSON schema. Supports 14 built-in block types with a Clean Architecture extension point for custom blocks.
4+
5+
[![pub package](https://img.shields.io/pub/v/editorjs_flutter.svg)](https://pub.dev/packages/editorjs_flutter)
6+
[![CI](https://github.com/DEV1-Softworks/editorjs-flutter/actions/workflows/ci.yml/badge.svg)](https://github.com/DEV1-Softworks/editorjs-flutter/actions/workflows/ci.yml)
7+
[![codecov](https://codecov.io/gh/DEV1-Softworks/editorjs-flutter/branch/master/graph/badge.svg)](https://codecov.io/gh/DEV1-Softworks/editorjs-flutter)
48

59
# DISCLAIMER
6-
This library is under active development. While the architecture is stable, some block types are still being added. Use with care in production environments.
10+
This package is in active development (pre-1.0). The public API is stable and the Clean Architecture foundation is solid, but some editor features are still being refined. Suitable for early production use with the understanding that minor API changes may occur in future minor versions.
711

812
Requires **Flutter 3.10+** and **Dart 3.0+**.
913

@@ -13,7 +17,7 @@ Add the following to your `pubspec.yaml` dependencies:
1317

1418
```yaml
1519
dependencies:
16-
editorjs_flutter: ^0.1.0
20+
editorjs_flutter: ^0.5.0
1721
```
1822
1923
Then run `flutter pub get`.
@@ -136,10 +140,16 @@ class CreateNoteState extends State<CreateNote> {
136140

137141
### Pre-loading existing content into the editor
138142

143+
Load a previously saved JSON string directly:
144+
139145
```dart
140-
_controller = EditorController(
141-
initialBlocks: parsedDocument.blocks, // List<BlockEntity>
142-
);
146+
_controller = EditorController.fromJson(savedJsonString);
147+
```
148+
149+
Or pass a parsed block list if you already have one:
150+
151+
```dart
152+
_controller = EditorController(initialBlocks: parsedDocument.blocks);
143153
```
144154

145155
### Registering custom block types

analysis_options.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
linter:
4+
rules:
5+
- avoid_print
6+
- prefer_const_constructors
7+
- prefer_const_declarations
8+
- prefer_final_fields
9+
- use_super_parameters
10+
- unnecessary_this
11+
- sort_child_properties_last

coverage/lcov.info

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ DA:16,1
354354
DA:19,2
355355
DA:20,1
356356
DA:21,5
357-
DA:29,5
357+
DA:29,8
358358
DA:34,3
359359
DA:37,1
360360
DA:38,1
@@ -418,7 +418,7 @@ LF:10
418418
LH:9
419419
end_of_record
420420
SF:lib/src/domain/entities/blocks/table_block.dart
421-
DA:10,5
421+
DA:10,8
422422
DA:15,3
423423
DA:18,1
424424
DA:19,1
@@ -1621,20 +1621,12 @@ DA:61,2
16211621
DA:64,3
16221622
DA:67,2
16231623
DA:70,3
1624-
DA:71,1
1625-
DA:73,1
16261624
DA:77,2
16271625
DA:80,3
1628-
DA:81,1
1629-
DA:83,1
16301626
DA:87,2
16311627
DA:90,3
16321628
DA:97,2
16331629
DA:100,3
1634-
DA:101,1
1635-
DA:102,1
1636-
DA:103,1
1637-
DA:104,1
16381630
DA:109,2
16391631
DA:112,3
16401632
DA:114,2
@@ -1683,6 +1675,6 @@ DA:230,2
16831675
DA:231,2
16841676
DA:232,2
16851677
DA:233,2
1686-
LF:87
1687-
LH:87
1678+
LF:79
1679+
LH:79
16881680
end_of_record

demo/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Lint configuration placeholder. Add local lint rules or includes here if needed.

demo/lib/main.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ class _MyHomePageState extends State<MyHomePage> {
4646
}
4747

4848
Future<void> _loadTestData() async {
49-
final data = await DefaultAssetBundle.of(context)
50-
.loadString('test_data/editorjsdatatest.json');
51-
final stylesJson = await DefaultAssetBundle.of(context)
52-
.loadString('test_data/editorjsstyles.json');
49+
final bundle = DefaultAssetBundle.of(context);
50+
final data = await bundle.loadString('test_data/editorjsdatatest.json');
51+
final stylesJson = await bundle.loadString('test_data/editorjsstyles.json');
5352

5453
final stylesMap = jsonDecode(stylesJson) as Map<String, dynamic>;
5554
final rawTags = stylesMap['cssTags'] as List<dynamic>? ?? [];

demo/test/widget_test.dart

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,11 @@
1-
// This is a basic Flutter widget test.
2-
//
3-
// To perform an interaction with a widget in your test, use the WidgetTester
4-
// utility that Flutter provides. For example, you can send tap and scroll
5-
// gestures. You can also use WidgetTester to find child widgets in the widget
6-
// tree, read text, and verify that the values of widget properties are correct.
7-
81
import 'package:flutter/material.dart';
92
import 'package:flutter_test/flutter_test.dart';
10-
import '../lib/main.dart';
113

4+
// Smoke test for the demo app shell.
5+
// Full integration tests live in the package's own test/ directory.
126
void main() {
13-
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
14-
// Build our app and trigger a frame.
15-
await tester.pumpWidget(MyApp());
16-
17-
// Verify that our counter starts at 0.
18-
expect(find.text('0'), findsOneWidget);
19-
expect(find.text('1'), findsNothing);
20-
21-
// Tap the '+' icon and trigger a frame.
22-
await tester.tap(find.byIcon(Icons.add));
23-
await tester.pump();
24-
25-
// Verify that our counter has incremented.
26-
expect(find.text('0'), findsNothing);
27-
expect(find.text('1'), findsOneWidget);
7+
testWidgets('MaterialApp renders without throwing', (tester) async {
8+
await tester.pumpWidget(const MaterialApp(home: Scaffold()));
9+
expect(find.byType(MaterialApp), findsOneWidget);
2810
});
2911
}

example/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ dependencies:
1111
sdk: flutter
1212
editorjs_flutter:
1313
path: ../
14+
15+
flutter:
16+
uses-material-design: true

lib/src/presentation/widgets/editorjs_toolbar.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ class EditorJSToolbar extends StatelessWidget {
6868
icon: Icons.format_list_bulleted,
6969
tooltip: 'Unordered list',
7070
onTap: () => controller.addBlock(
71-
ListBlock(
71+
const ListBlock(
7272
style: ListStyle.unordered,
73-
items: [const ListItem(content: '')],
73+
items: [ListItem(content: '')],
7474
),
7575
),
7676
),
7777
_ToolbarButton(
7878
icon: Icons.format_list_numbered,
7979
tooltip: 'Ordered list',
8080
onTap: () => controller.addBlock(
81-
ListBlock(
81+
const ListBlock(
8282
style: ListStyle.ordered,
83-
items: [const ListItem(content: '')],
83+
items: [ListItem(content: '')],
8484
),
8585
),
8686
),
@@ -98,7 +98,7 @@ class EditorJSToolbar extends StatelessWidget {
9898
icon: Icons.table_chart_outlined,
9999
tooltip: 'Table',
100100
onTap: () => controller.addBlock(
101-
TableBlock(
101+
const TableBlock(
102102
content: [
103103
['', ''],
104104
['', ''],

0 commit comments

Comments
 (0)