feat: support customizing max width
This commit is contained in:
parent
ea494df556
commit
0a0154ff7d
3 changed files with 25 additions and 7 deletions
|
|
@ -129,7 +129,8 @@ class _DesktopEditorState extends State<DesktopEditor> {
|
|||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 200.0),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 40),
|
||||
maxWidth: 640,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,11 @@ class PageBlockComponent extends BlockComponentStatelessWidget {
|
|||
children: [
|
||||
if (header != null) header!,
|
||||
...items.map(
|
||||
(e) => Padding(
|
||||
(e) => Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth:
|
||||
editorState.editorStyle.maxWidth ?? double.infinity,
|
||||
),
|
||||
padding: editorState.editorStyle.padding,
|
||||
child: editorState.renderer.build(context, e),
|
||||
),
|
||||
|
|
@ -97,11 +101,16 @@ class PageBlockComponent extends BlockComponentStatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: editorState.editorStyle.padding,
|
||||
child: editorState.renderer.build(
|
||||
context,
|
||||
items[index - (header != null ? 1 : 0)],
|
||||
return Center(
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: editorState.editorStyle.maxWidth ?? double.infinity,
|
||||
),
|
||||
padding: editorState.editorStyle.padding,
|
||||
child: editorState.renderer.build(
|
||||
context,
|
||||
items[index - (header != null ? 1 : 0)],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -21,11 +21,15 @@ class EditorStyle {
|
|||
this.defaultTextDirection,
|
||||
this.enableHapticFeedbackOnAndroid = true,
|
||||
this.textScaleFactor = 1.0,
|
||||
this.maxWidth,
|
||||
});
|
||||
|
||||
// The padding of the editor.
|
||||
final EdgeInsets padding;
|
||||
|
||||
// The max width of the editor.
|
||||
final double? maxWidth;
|
||||
|
||||
// The cursor color
|
||||
final Color cursorColor;
|
||||
|
||||
|
|
@ -82,6 +86,7 @@ class EditorStyle {
|
|||
this.defaultTextDirection,
|
||||
this.cursorWidth = 2.0,
|
||||
this.textScaleFactor = 1.0,
|
||||
this.maxWidth,
|
||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 100),
|
||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||
selectionColor =
|
||||
|
|
@ -112,6 +117,7 @@ class EditorStyle {
|
|||
this.cursorWidth = 2.0,
|
||||
this.enableHapticFeedbackOnAndroid = true,
|
||||
this.textScaleFactor = 1.0,
|
||||
this.maxWidth,
|
||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 20),
|
||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||
dragHandleColor = dragHandleColor ?? const Color(0xFF00BCF0),
|
||||
|
|
@ -138,6 +144,7 @@ class EditorStyle {
|
|||
bool? enableHapticFeedbackOnAndroid,
|
||||
double? cursorWidth,
|
||||
double? textScaleFactor,
|
||||
double? maxWidth,
|
||||
}) {
|
||||
return EditorStyle(
|
||||
padding: padding ?? this.padding,
|
||||
|
|
@ -157,6 +164,7 @@ class EditorStyle {
|
|||
enableHapticFeedbackOnAndroid ?? this.enableHapticFeedbackOnAndroid,
|
||||
cursorWidth: cursorWidth ?? this.cursorWidth,
|
||||
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
|
||||
maxWidth: maxWidth ?? this.maxWidth,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue