Skip to content

Commit

Permalink
Merge pull request #12 from AppFlowy-IO/fix/editorstate-code-block
Browse files Browse the repository at this point in the history
fix: editorstate code block + release 0.0.5
  • Loading branch information
Xazin authored May 13, 2024
2 parents b8b1a58 + b0990cc commit 8c6f98d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Looking for a plugin but cannot find it on the list? Submit a [Plugin request](h

To make it easier to manage a federated package approach, we use [Melos](https://pub.dev/packages/melos). If you need to develop across multiple packages, you can bootstrap melos by running `melos bootstrap`.

To setup the `melos` CLI and make it globally available, run this command: `dart pub global activate melos`

Scripts available:

- `melos run analyze`: Run `dart analyze .` in all packages.
Expand Down
4 changes: 4 additions & 0 deletions packages/appflowy_editor_plugins/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.5

- Fix a possibly critical bug with the editorState logic in the Code Block component

## 0.0.4

- Add placeholder and error widget builders to Video Block
Expand Down
2 changes: 1 addition & 1 deletion packages/appflowy_editor_plugins/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.3"
version: "0.0.4"
archive:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
Node get node => widget.node;

@override
EditorState get editorState => context.read<EditorState>();
late EditorState editorState;

final scrollController = ScrollController();

Expand All @@ -313,6 +313,7 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
@override
void initState() {
super.initState();
editorState = context.read<EditorState>();
editorState.selectionService.registerGestureInterceptor(interceptor);
editorState.selectionNotifier.addListener(calculateScrollPosition);
transactionSubscription = editorState.transactionStream.listen((event) {
Expand All @@ -322,6 +323,17 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
});
}

@override
void didChangeDependencies() {
super.didChangeDependencies();

editorState.selectionService.currentSelection
.removeListener(calculateScrollPosition);
editorState.selectionService.unregisterGestureInterceptor(_interceptorKey);

editorState = context.read<EditorState>();
}

@override
void dispose() {
scrollController.dispose();
Expand Down
2 changes: 1 addition & 1 deletion packages/appflowy_editor_plugins/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: appflowy_editor_plugins
description: "A collection of plugins and custom block components for the AppFlowy Editor."
version: 0.0.4
version: 0.0.5
homepage: https://github.com/AppFlowy-IO/appflowy-plugins

topics:
Expand Down

0 comments on commit 8c6f98d

Please sign in to comment.