Skip to content

Commit 3540997

Browse files
authored
feat(text-editor): add enableTapOutsideToSave prop to text editor configs (#695)
1 parent d695f6b commit 3540997

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## X.X.X
4+
- **FEAT**(text-editor): Added `enableTapOutsideToSave` configuration to `TextEditorConfigs` to control whether tapping outside the text field saves the text annotation. When set to `false`, users must use the done button or other explicit save actions. Defaults to `true` for backward compatibility.
5+
36
## 11.11.0
47
- **FEAT**(dashDotLine): Added new paint-mode "dashDotLine".
58

lib/core/models/editor_configs/text_editor_configs.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class TextEditorConfigs
5454
this.showFontScaleButton = true,
5555
this.showBackgroundModeButton = true,
5656
this.enableMainEditorZoomFactor = false,
57+
this.enableTapOutsideToSave = true,
5758
this.enableAutoOverflow = true,
5859
this.initFontSize = 24.0,
5960
this.initialPrimaryColor = const Color(0xFF000000),
@@ -111,6 +112,14 @@ class TextEditorConfigs
111112
/// editor's zoom level.
112113
final bool enableMainEditorZoomFactor;
113114

115+
/// Whether tapping outside the text field saves the text annotation.
116+
///
117+
/// When `true` (default), tapping outside the text input area will save
118+
/// the current text and close the editor. When `false`, tapping outside
119+
/// will not trigger the save action, requiring users to use the done
120+
/// button or other explicit save actions.
121+
final bool enableTapOutsideToSave;
122+
114123
/// The initial font size for text.
115124
final double initFontSize;
116125

@@ -204,6 +213,7 @@ class TextEditorConfigs
204213
bool? enableEdit,
205214
bool? showSelectFontStyleBottomBar,
206215
bool? enableMainEditorZoomFactor,
216+
bool? enableTapOutsideToSave,
207217
bool? enableAutoOverflow,
208218
Color? initialPrimaryColor,
209219
Color? initialSecondaryColor,
@@ -236,6 +246,8 @@ class TextEditorConfigs
236246
showSelectFontStyleBottomBar ?? this.showSelectFontStyleBottomBar,
237247
enableMainEditorZoomFactor:
238248
enableMainEditorZoomFactor ?? this.enableMainEditorZoomFactor,
249+
enableTapOutsideToSave:
250+
enableTapOutsideToSave ?? this.enableTapOutsideToSave,
239251
enableAutoOverflow: enableAutoOverflow ?? this.enableAutoOverflow,
240252
initialPrimaryColor: initialPrimaryColor ?? this.initialPrimaryColor,
241253
initialSecondaryColor:

lib/features/text_editor/text_editor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class TextEditorState extends State<TextEditor>
396396

397397
return GestureDetector(
398398
behavior: HitTestBehavior.translucent,
399-
onTap: done,
399+
onTap: textEditorConfigs.enableTapOutsideToSave ? done : null,
400400
child: Stack(
401401
children: [
402402
if (textEditorConfigs.widgets.bodyItems != null)

0 commit comments

Comments
 (0)