Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/frontend/lib/providers/note_editor_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,16 @@ class NoteEditorProvider with ChangeNotifier implements NoteEditorViewModel {
return blockId;
}

@override
void redo() {
_documentBuilder.redo();
}

@override
void undo() {
_documentBuilder.undo();
}

@override
void resetState() {
_logger.info('Resetting NoteEditorProvider state');
Expand Down
15 changes: 12 additions & 3 deletions src/frontend/lib/screens/note_editor_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,20 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
// Add AppBarCommon with ONLY theme switching functionality
appBar: AppBarCommon(
title: '', // Empty title as we have our own title field
showBackButton: false, // No back button in app bar
title: '',
showBackButton: true,
actions: [
IconButton(
icon: const Icon(Icons.undo_outlined),
tooltip: 'Undo last edit',
onPressed: () => _noteEditorViewModel.undo(),
),
IconButton(
icon: const Icon(Icons.redo_outlined),
tooltip: 'Redo last edit',
onPressed: () => _noteEditorViewModel.redo(),
),
IconButton(
icon: const Icon(Icons.refresh_outlined),
tooltip: 'Refresh note content',
Expand Down
3 changes: 0 additions & 3 deletions src/frontend/lib/screens/user_profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class UserProfileScreen extends StatefulWidget {

class _UserProfileScreenState extends State<UserProfileScreen> {
final Logger _logger = Logger('UserProfileScreen');
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
final _formKey = GlobalKey<FormState>();
final _passwordFormKey = GlobalKey<FormState>();

Expand Down Expand Up @@ -176,12 +175,10 @@ class _UserProfileScreenState extends State<UserProfileScreen> {
final theme = Theme.of(context);

return Scaffold(
key: _scaffoldKey,
appBar: AppBarCommon(
title: 'Profile',
onBackPressed: () => context.go('/'),
showBackButton: true,
onMenuPressed: () => _scaffoldKey.currentState?.openDrawer(),
actions: const [ThemeSwitcher()],
),
drawer: const SidebarDrawer(),
Expand Down
15 changes: 13 additions & 2 deletions src/frontend/lib/utils/document_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ class DocumentBuilder {
_composer.selectionNotifier.addListener(_updateToolbarDisplay);

// Create editor with our document and composer
_editor =
createDefaultDocumentEditor(document: _document, composer: _composer);
_editor = createDefaultDocumentEditor(
document: _document,
composer: _composer,
isHistoryEnabled: true,
);

// Add action tags listener for inline commands
_inlineCommandsPlugin = ActionTagsPlugin();
Expand Down Expand Up @@ -1318,6 +1321,14 @@ class DocumentBuilder {
return document;
}

void redo() {
_editor.redo();
}

void undo() {
_editor.undo();
}

// Create Super Editor with configured components for SuperEditor 0.3.0
Widget createSuperEditor({
required bool readOnly,
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/lib/viewmodel/note_editor_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ abstract class NoteEditorViewModel extends BaseViewModel {
void setFocusToBlock(String blockId);
String? consumeFocusRequest();

void redo() {}
void undo() {}

// User modified blocks tracking
Set<String> get userModifiedBlockIds;

Expand Down
46 changes: 25 additions & 21 deletions src/frontend/lib/widgets/app_bar_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart';
class AppBarCommon extends StatelessWidget implements PreferredSizeWidget {
final String? title;
final List<Widget>? actions;
final Widget? leading;
final bool showBackButton;
final VoidCallback? onBackPressed;
final VoidCallback? onMenuPressed;
Expand All @@ -13,12 +12,12 @@ class AppBarCommon extends StatelessWidget implements PreferredSizeWidget {
final Color? backgroundColor;
final Color? foregroundColor;
final bool showProfileButton;

final bool showUndoRedoButtons;

const AppBarCommon({
Key? key,
this.title,
this.actions,
this.leading,
this.showBackButton = true,
this.onBackPressed,
this.onMenuPressed,
Expand All @@ -27,31 +26,31 @@ class AppBarCommon extends StatelessWidget implements PreferredSizeWidget {
this.backgroundColor,
this.foregroundColor,
this.showProfileButton = true,
this.showUndoRedoButtons = false,
}) : super(key: key);

@override
Widget build(BuildContext context) {
Widget? leadingWidget = leading;
List<Widget>? leadingWidgets = [];

// If leading is not provided and showBackButton is true, show back button
if (leading == null) {
if (showBackButton) {
leadingWidget = IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: onBackPressed ?? () => Navigator.of(context).pop(),
);
} else if (onMenuPressed != null) {
// Show menu button if onMenuPressed callback is provided
leadingWidget = IconButton(
icon: const Icon(Icons.menu),
onPressed: onMenuPressed,
);
}
if (onMenuPressed != null) {
// Show menu button if onMenuPressed callback is provided
leadingWidgets.add(IconButton(
icon: const Icon(Icons.menu),
onPressed: onMenuPressed,
));
}

if (showBackButton) {
leadingWidgets.add(IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: onBackPressed ?? () => Navigator.of(context).pop(),
));
}

// Create a copy of the actions list to modify if needed
List<Widget>? actionWidgets = actions != null ? List<Widget>.from(actions!) : [];

// Add profile button to actions if showProfileButton is true
if (showProfileButton) {
actionWidgets.add(
Expand All @@ -67,13 +66,18 @@ class AppBarCommon extends StatelessWidget implements PreferredSizeWidget {
}

return AppBar(
leading: Builder(builder: (context) => Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: leadingWidgets,
),
),
actions: actionWidgets,
title: title != null ? Text(title!) : null,
centerTitle: centerTitle,
elevation: elevation,
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,
leading: leadingWidget,
actions: actionWidgets,
);
}

Expand Down