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,
|
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: [
|
children: [
|
||||||
if (header != null) header!,
|
if (header != null) header!,
|
||||||
...items.map(
|
...items.map(
|
||||||
(e) => Padding(
|
(e) => Container(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth:
|
||||||
|
editorState.editorStyle.maxWidth ?? double.infinity,
|
||||||
|
),
|
||||||
padding: editorState.editorStyle.padding,
|
padding: editorState.editorStyle.padding,
|
||||||
child: editorState.renderer.build(context, e),
|
child: editorState.renderer.build(context, e),
|
||||||
),
|
),
|
||||||
|
|
@ -97,11 +101,16 @@ class PageBlockComponent extends BlockComponentStatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Center(
|
||||||
padding: editorState.editorStyle.padding,
|
child: Container(
|
||||||
child: editorState.renderer.build(
|
constraints: BoxConstraints(
|
||||||
context,
|
maxWidth: editorState.editorStyle.maxWidth ?? double.infinity,
|
||||||
items[index - (header != null ? 1 : 0)],
|
),
|
||||||
|
padding: editorState.editorStyle.padding,
|
||||||
|
child: editorState.renderer.build(
|
||||||
|
context,
|
||||||
|
items[index - (header != null ? 1 : 0)],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,15 @@ class EditorStyle {
|
||||||
this.defaultTextDirection,
|
this.defaultTextDirection,
|
||||||
this.enableHapticFeedbackOnAndroid = true,
|
this.enableHapticFeedbackOnAndroid = true,
|
||||||
this.textScaleFactor = 1.0,
|
this.textScaleFactor = 1.0,
|
||||||
|
this.maxWidth,
|
||||||
});
|
});
|
||||||
|
|
||||||
// The padding of the editor.
|
// The padding of the editor.
|
||||||
final EdgeInsets padding;
|
final EdgeInsets padding;
|
||||||
|
|
||||||
|
// The max width of the editor.
|
||||||
|
final double? maxWidth;
|
||||||
|
|
||||||
// The cursor color
|
// The cursor color
|
||||||
final Color cursorColor;
|
final Color cursorColor;
|
||||||
|
|
||||||
|
|
@ -82,6 +86,7 @@ class EditorStyle {
|
||||||
this.defaultTextDirection,
|
this.defaultTextDirection,
|
||||||
this.cursorWidth = 2.0,
|
this.cursorWidth = 2.0,
|
||||||
this.textScaleFactor = 1.0,
|
this.textScaleFactor = 1.0,
|
||||||
|
this.maxWidth,
|
||||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 100),
|
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 100),
|
||||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||||
selectionColor =
|
selectionColor =
|
||||||
|
|
@ -112,6 +117,7 @@ class EditorStyle {
|
||||||
this.cursorWidth = 2.0,
|
this.cursorWidth = 2.0,
|
||||||
this.enableHapticFeedbackOnAndroid = true,
|
this.enableHapticFeedbackOnAndroid = true,
|
||||||
this.textScaleFactor = 1.0,
|
this.textScaleFactor = 1.0,
|
||||||
|
this.maxWidth,
|
||||||
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 20),
|
}) : padding = padding ?? const EdgeInsets.symmetric(horizontal: 20),
|
||||||
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
cursorColor = cursorColor ?? const Color(0xFF00BCF0),
|
||||||
dragHandleColor = dragHandleColor ?? const Color(0xFF00BCF0),
|
dragHandleColor = dragHandleColor ?? const Color(0xFF00BCF0),
|
||||||
|
|
@ -138,6 +144,7 @@ class EditorStyle {
|
||||||
bool? enableHapticFeedbackOnAndroid,
|
bool? enableHapticFeedbackOnAndroid,
|
||||||
double? cursorWidth,
|
double? cursorWidth,
|
||||||
double? textScaleFactor,
|
double? textScaleFactor,
|
||||||
|
double? maxWidth,
|
||||||
}) {
|
}) {
|
||||||
return EditorStyle(
|
return EditorStyle(
|
||||||
padding: padding ?? this.padding,
|
padding: padding ?? this.padding,
|
||||||
|
|
@ -157,6 +164,7 @@ class EditorStyle {
|
||||||
enableHapticFeedbackOnAndroid ?? this.enableHapticFeedbackOnAndroid,
|
enableHapticFeedbackOnAndroid ?? this.enableHapticFeedbackOnAndroid,
|
||||||
cursorWidth: cursorWidth ?? this.cursorWidth,
|
cursorWidth: cursorWidth ?? this.cursorWidth,
|
||||||
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
|
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
|
||||||
|
maxWidth: maxWidth ?? this.maxWidth,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue