feat: add keyboard shortcuts for notes, the note list and the app
This commit is contained in:
parent
ed2de5e67f
commit
722390ecec
9 changed files with 532 additions and 60 deletions
|
|
@ -9,6 +9,7 @@ class MarkdownView extends StatefulWidget {
|
|||
final bool readOnly;
|
||||
final double fontSize;
|
||||
final FocusNode? focusNode;
|
||||
final ScrollController? scrollController;
|
||||
|
||||
const MarkdownView({
|
||||
super.key,
|
||||
|
|
@ -16,6 +17,7 @@ class MarkdownView extends StatefulWidget {
|
|||
this.readOnly = true,
|
||||
this.fontSize = 16,
|
||||
this.focusNode,
|
||||
this.scrollController,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -40,6 +42,16 @@ class MarkdownViewState extends State<MarkdownView> {
|
|||
);
|
||||
}
|
||||
|
||||
/// Text offset at the top-left of the visible area.
|
||||
int firstVisibleOffset() {
|
||||
final box = _fieldKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
final editable = _findEditable(box);
|
||||
if (box == null || editable == null) return 0;
|
||||
return editable
|
||||
.getPositionForPoint(box.localToGlobal(const Offset(1, 1)))
|
||||
.offset;
|
||||
}
|
||||
|
||||
RenderEditable? _findEditable(RenderObject? node) {
|
||||
if (node is RenderEditable) return node;
|
||||
RenderEditable? found;
|
||||
|
|
@ -68,6 +80,7 @@ class MarkdownViewState extends State<MarkdownView> {
|
|||
key: _fieldKey,
|
||||
controller: widget.controller,
|
||||
focusNode: widget.focusNode,
|
||||
scrollController: widget.scrollController,
|
||||
readOnly: widget.readOnly,
|
||||
showCursor: !widget.readOnly,
|
||||
expands: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue