feat: observe mention block change and support block navigation (#6568)

* feat: observe mentioned block changes and navigate to block

* test: add delete mentioned block test

* chore: update editor version

* feat: navigate block in same page

* fix: sometimes turn into menu doesn't work

* test: add test

* fix: integration test
This commit is contained in:
Lucas 2024-10-17 13:29:34 +08:00 committed by GitHub
parent 7cad04bbf4
commit 0413100e2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 296 additions and 34 deletions

View file

@ -51,6 +51,7 @@ class DocumentPlugin extends Plugin {
required ViewPB view,
required PluginType pluginType,
this.initialSelection,
this.initialBlockId,
}) : notifier = ViewPluginNotifier(view: view) {
_pluginType = pluginType;
}
@ -61,13 +62,18 @@ class DocumentPlugin extends Plugin {
@override
final ViewPluginNotifier notifier;
// the initial selection of the document
final Selection? initialSelection;
// the initial block id of the document
final String? initialBlockId;
@override
PluginWidgetBuilder get widgetBuilder => DocumentPluginWidgetBuilder(
bloc: _viewInfoBloc,
notifier: notifier,
initialSelection: initialSelection,
initialBlockId: initialBlockId,
);
@override
@ -95,6 +101,7 @@ class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
required this.bloc,
required this.notifier,
this.initialSelection,
this.initialBlockId,
});
final ViewInfoBloc bloc;
@ -102,6 +109,7 @@ class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
ViewPB get view => notifier.view;
int? deletedViewIndex;
final Selection? initialSelection;
final String? initialBlockId;
@override
EdgeInsets get contentPadding => EdgeInsets.zero;
@ -129,6 +137,7 @@ class DocumentPluginWidgetBuilder extends PluginWidgetBuilder
view: view,
onDeleted: () => context.onDeleted?.call(view, deletedViewIndex),
initialSelection: initialSelection,
initialBlockId: initialBlockId,
fixedTitle: fixedTitle,
),
),