This commit is contained in:
0x8664b2
2025-06-20 17:47:44 -07:00
parent 6df66ebbef
commit 9aea81e035
2 changed files with 18 additions and 1 deletions

View File

@@ -185,8 +185,10 @@ struct MarkdownEditor: NSViewRepresentable {
textView.font = NSFont.monospacedSystemFont(ofSize: 14, weight: .regular)
textView.textColor = NSColor.textColor
textView.backgroundColor = NSColor.textBackgroundColor
textView.allowsUndo = true
textView.string = text
// Properly set up the scroll view hierarchy first
scrollView.borderType = .noBorder
scrollView.hasVerticalScroller = true
@@ -217,6 +219,7 @@ struct MarkdownEditor: NSViewRepresentable {
if textView.string != text {
print("MarkdownEditor: Updating text from \(textView.string.count) to \(text.count) characters")
textView.string = text
}
}

View File

@@ -62,6 +62,20 @@ struct MarkdownViewerApp: App {
}
}
}
CommandGroup(replacing: .undoRedo) {
Button("Undo") {
print("Menu: Undo clicked, sending action to: \(NSApp.keyWindow?.firstResponder?.className ?? "nil")")
NSApp.sendAction(#selector(UndoManager.undo), to: nil, from: nil)
}
.keyboardShortcut("z", modifiers: .command)
Button("Redo") {
print("Menu: Redo clicked, sending action to: \(NSApp.keyWindow?.firstResponder?.className ?? "nil")")
NSApp.sendAction(#selector(UndoManager.redo), to: nil, from: nil)
}
.keyboardShortcut("z", modifiers: [.command, .shift])
}
}
}