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
12 changed files with 51 additions and 17 deletions

View File

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

View File

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

View File

@ -101,6 +101,11 @@ class _CodeBlockComponentWidgetState extends State<CodeBlockComponentWidget>
@override
final forwardKey = GlobalKey(debugLabel: 'flowy_rich_text');
@override
GlobalKey<State<StatefulWidget>> blockComponentKey = GlobalKey(
debugLabel: CodeBlockKeys.type,
);
@override
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) {
child = BlockComponentActionWrapper(
node: widget.node,

View File

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

View File

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

View File

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