feat: add placeholder to card editor (#3870)

This commit is contained in:
Mathias Mogensen 2023-11-07 15:58:22 +01:00 committed by GitHub
parent 8116ea1dba
commit fe23183aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -116,6 +116,10 @@ class _RowEditorState extends State<RowEditor> {
context: context,
padding: const EdgeInsets.symmetric(horizontal: 10),
),
showParagraphPlaceholder: (editorState, node) =>
editorState.document.isEmpty,
placeholderText: (node) =>
LocaleKeys.cardDetails_notesPlaceholder.tr(),
),
),
);

View File

@ -11,6 +11,8 @@ Map<String, BlockComponentBuilder> getEditorBuilderMap({
required EditorStyleCustomizer styleCustomizer,
List<SelectionMenuItem>? slashMenuItems,
bool editable = true,
ShowPlaceholder? showParagraphPlaceholder,
String Function(Node)? placeholderText,
}) {
final standardActions = [
OptionAction.delete,
@ -29,7 +31,8 @@ Map<String, BlockComponentBuilder> getEditorBuilderMap({
final customBlockComponentBuilderMap = {
PageBlockKeys.type: PageBlockComponentBuilder(),
ParagraphBlockKeys.type: ParagraphBlockComponentBuilder(
configuration: configuration,
configuration: configuration.copyWith(placeholderText: placeholderText),
showPlaceholder: showParagraphPlaceholder,
),
TodoListBlockKeys.type: TodoListBlockComponentBuilder(
configuration: configuration.copyWith(

View File

@ -47,6 +47,8 @@ class AppFlowyEditorPage extends StatefulWidget {
this.scrollController,
this.autoFocus,
required this.styleCustomizer,
this.showParagraphPlaceholder,
this.placeholderText,
});
final Widget? header;
@ -55,6 +57,8 @@ class AppFlowyEditorPage extends StatefulWidget {
final bool shrinkWrap;
final bool? autoFocus;
final EditorStyleCustomizer styleCustomizer;
final ShowPlaceholder? showParagraphPlaceholder;
final String Function(Node)? placeholderText;
@override
State<AppFlowyEditorPage> createState() => _AppFlowyEditorPageState();
@ -112,6 +116,8 @@ class _AppFlowyEditorPageState extends State<AppFlowyEditorPage> {
context: context,
editorState: widget.editorState,
styleCustomizer: widget.styleCustomizer,
showParagraphPlaceholder: widget.showParagraphPlaceholder,
placeholderText: widget.placeholderText,
);
List<CharacterShortcutEvent> get characterShortcutEvents => [

View File

@ -1040,5 +1040,8 @@
"favorite": {
"noFavorite": "No favorite page",
"noFavoriteHintText": "Swipe the page to the left to add it to your favorites"
},
"cardDetails": {
"notesPlaceholder": "Enter a / to insert a block, or start typing"
}
}