chore: upgrade editor to 1.2.1 (#2997)

This commit is contained in:
Lucas.Xu 2023-07-14 16:08:40 +07:00 committed by GitHub
parent 39988f6785
commit 098c085d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 51 additions and 17 deletions

View File

@ -99,12 +99,12 @@ void main() {
// expect to the see the inline math equation button is highlighted // expect to the see the inline math equation button is highlighted
inlineMathEquationButton = find.byWidgetPredicate( inlineMathEquationButton = find.byWidgetPredicate(
(widget) => (widget) =>
widget is IconItemWidget && widget is SVGIconItemWidget &&
widget.tooltip == widget.tooltip ==
LocaleKeys.document_plugins_createInlineMathEquation.tr(), LocaleKeys.document_plugins_createInlineMathEquation.tr(),
); );
expect( expect(
tester.widget<IconItemWidget>(inlineMathEquationButton).isHighlight, tester.widget<SVGIconItemWidget>(inlineMathEquationButton).isHighlight,
isTrue, isTrue,
); );

View File

@ -310,9 +310,10 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
builder.showActions = (_) => true; builder.showActions = (_) => true;
builder.actionBuilder = (context, state) { builder.actionBuilder = (context, state) {
final top = builder.configuration.padding(context.node).top;
final padding = context.node.type == HeadingBlockKeys.type final padding = context.node.type == HeadingBlockKeys.type
? const EdgeInsets.only(top: 8.0) ? EdgeInsets.only(top: top + 8.0)
: EdgeInsets.zero; : EdgeInsets.only(top: top);
return Padding( return Padding(
padding: padding, padding: padding,
child: BlockActionList( child: BlockActionList(

View File

@ -114,6 +114,11 @@ class _CalloutBlockComponentWidgetState
@override @override
GlobalKey<State<StatefulWidget>> get containerKey => widget.node.key; GlobalKey<State<StatefulWidget>> get containerKey => widget.node.key;
@override
GlobalKey<State<StatefulWidget>> blockComponentKey = GlobalKey(
debugLabel: CalloutBlockKeys.type,
);
@override @override
BlockComponentConfiguration get configuration => widget.configuration; BlockComponentConfiguration get configuration => widget.configuration;
@ -177,6 +182,12 @@ class _CalloutBlockComponentWidgetState
), ),
); );
child = Padding(
key: blockComponentKey,
padding: padding,
child: child,
);
if (widget.actionBuilder != null) { if (widget.actionBuilder != null) {
child = BlockComponentActionWrapper( child = BlockComponentActionWrapper(
node: widget.node, node: widget.node,

View File

@ -101,6 +101,11 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
@override @override
final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text'); final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text');
@override
GlobalKey<State<StatefulWidget>> blockComponentKey = GlobalKey(
debugLabel: CodeBlockKeys.type,
);
@override @override
BlockComponentConfiguration get configuration => widget.configuration; BlockComponentConfiguration get configuration => widget.configuration;
@ -187,6 +192,12 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
), ),
); );
child = Padding(
key: blockComponentKey,
padding: padding,
child: child,
);
if (widget.actionBuilder != null) { if (widget.actionBuilder != null) {
child = BlockComponentActionWrapper( child = BlockComponentActionWrapper(
node: widget.node, node: widget.node,

View File

@ -9,7 +9,7 @@ final ToolbarItem inlineMathEquationItem = ToolbarItem(
id: 'editor.inline_math_equation', id: 'editor.inline_math_equation',
group: 2, group: 2,
isActive: onlyShowInSingleSelectionAndTextType, isActive: onlyShowInSingleSelectionAndTextType,
builder: (context, editorState) { builder: (context, editorState, highlightColor) {
final selection = editorState.selection!; final selection = editorState.selection!;
final nodes = editorState.getNodesInSelection(selection); final nodes = editorState.getNodesInSelection(selection);
final isHighlight = nodes.allSatisfyInSelection(selection, (delta) { final isHighlight = nodes.allSatisfyInSelection(selection, (delta) {
@ -17,13 +17,14 @@ final ToolbarItem inlineMathEquationItem = ToolbarItem(
(attributes) => attributes[InlineMathEquationKeys.formula] != null, (attributes) => attributes[InlineMathEquationKeys.formula] != null,
); );
}); });
return IconItemWidget( return SVGIconItemWidget(
iconBuilder: (_) => svgWidget( iconBuilder: (_) => svgWidget(
'editor/math', 'editor/math',
size: const Size.square(16), size: const Size.square(16),
color: isHighlight ? Colors.lightBlue : Colors.white, color: isHighlight ? highlightColor : Colors.white,
), ),
isHighlight: isHighlight, isHighlight: isHighlight,
highlightColor: highlightColor,
tooltip: LocaleKeys.document_plugins_createInlineMathEquation.tr(), tooltip: LocaleKeys.document_plugins_createInlineMathEquation.tr(),
onPressed: () async { onPressed: () async {
final selection = editorState.selection; final selection = editorState.selection;

View File

@ -21,7 +21,7 @@ final ToolbarItem smartEditItem = ToolbarItem(
final nodes = editorState.getNodesInSelection(selection); final nodes = editorState.getNodesInSelection(selection);
return nodes.every((element) => element.delta != null); return nodes.every((element) => element.delta != null);
}, },
builder: (context, editorState) => SmartEditActionList( builder: (context, editorState, _) => SmartEditActionList(
editorState: editorState, editorState: editorState,
), ),
); );

View File

@ -86,7 +86,7 @@ class _ToggleListBlockComponentWidgetState
SelectableMixin, SelectableMixin,
DefaultSelectableMixin, DefaultSelectableMixin,
BlockComponentConfigurable, BlockComponentConfigurable,
BackgroundColorMixin { BlockComponentBackgroundColorMixin {
// the key used to forward focus to the richtext child // the key used to forward focus to the richtext child
@override @override
final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text'); final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text');
@ -97,6 +97,11 @@ class _ToggleListBlockComponentWidgetState
@override @override
GlobalKey<State<StatefulWidget>> get containerKey => node.key; GlobalKey<State<StatefulWidget>> get containerKey => node.key;
@override
GlobalKey<State<StatefulWidget>> blockComponentKey = GlobalKey(
debugLabel: ToggleListBlockKeys.type,
);
@override @override
Node get node => widget.node; Node get node => widget.node;
@ -159,6 +164,12 @@ class _ToggleListBlockComponentWidgetState
], ],
); );
child = Padding(
key: blockComponentKey,
padding: padding,
child: child,
);
if (widget.actionBuilder != null) { if (widget.actionBuilder != null) {
child = BlockComponentActionWrapper( child = BlockComponentActionWrapper(
node: node, node: node,

View File

@ -53,11 +53,11 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "35394cd" ref: "33b18d9"
resolved-ref: "35394cd4f45f3f98afbec8d23d12fe0bf3cd3f6d" resolved-ref: "33b18d98dcc6db996eef3d6b869f293da3da3615"
url: "https://github.com/AppFlowy-IO/appflowy-editor.git" url: "https://github.com/AppFlowy-IO/appflowy-editor.git"
source: git source: git
version: "1.1.0" version: "1.2.0"
appflowy_popover: appflowy_popover:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -42,11 +42,10 @@ dependencies:
git: git:
url: https://github.com/AppFlowy-IO/appflowy-board.git url: https://github.com/AppFlowy-IO/appflowy-board.git
ref: a183c57 ref: a183c57
# appflowy_editor: ^1.0.4
appflowy_editor: appflowy_editor:
git: git:
url: https://github.com/AppFlowy-IO/appflowy-editor.git url: https://github.com/AppFlowy-IO/appflowy-editor.git
ref: 35394cd ref: 33b18d9
appflowy_popover: appflowy_popover:
path: packages/appflowy_popover path: packages/appflowy_popover

View File

@ -13,7 +13,7 @@ cd ..\..\..\appflowy_flutter
REM copy the resources/translations folder to REM copy the resources/translations folder to
REM the appflowy_flutter/assets/translation directory REM the appflowy_flutter/assets/translation directory
echo Copying resources/translations to appflowy_flutter/assets/translations echo Copying resources/translations to appflowy_flutter/assets/translations
xcopy /E /Y /I ..\resources\translations assets\translations xcopy /E /Y /I ..\resources\translations\ assets\translations\
call flutter packages pub get call flutter packages pub get

View File

@ -12,7 +12,7 @@ cd ../../../appflowy_flutter
# copy the resources/translations folder to # copy the resources/translations folder to
# the appflowy_flutter/assets/translation directory # the appflowy_flutter/assets/translation directory
cp -r ../resources/translations assets/translations cp -rf ../resources/translations/ assets/translations/
flutter packages pub get flutter packages pub get

View File

@ -168,7 +168,7 @@ script = [
script = [""" script = ["""
cd appflowy_flutter/ cd appflowy_flutter/
flutter pub get flutter pub get
flutter build ${TARGET_OS} --${BUILD_FLAG} flutter build ${TARGET_OS} --${BUILD_FLAG} --verbose
"""] """]
script_runner = "@shell" script_runner = "@shell"