mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-27 01:02:14 +08:00
MarkdownEditor: Handle title change marking note as modified
This commit is contained in:
@ -104,7 +104,7 @@ class MarkdownEditorState extends State<MarkdownEditor>
|
||||
children: <Widget>[
|
||||
NoteTitleEditor(
|
||||
_titleTextController,
|
||||
_noteTextChanged,
|
||||
_noteTitleTextChanged,
|
||||
),
|
||||
NoteBodyEditor(
|
||||
textController: _textController,
|
||||
@ -176,6 +176,20 @@ class MarkdownEditorState extends State<MarkdownEditor>
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _noteTitleTextChanged() {
|
||||
if (_noteModified && !widget.editMode) return;
|
||||
|
||||
var newState =
|
||||
!(widget.editMode && _titleTextController.text.trim().isEmpty);
|
||||
if (newState != _noteModified) {
|
||||
setState(() {
|
||||
_noteModified = newState;
|
||||
});
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _applyHeuristics() {
|
||||
var selection = _textController.selection;
|
||||
if (selection.baseOffset != selection.extentOffset) {
|
||||
|
Reference in New Issue
Block a user