Fix long-form markdown editor scrolling and focus
Some checks failed
Dotnet build and test / build (push) Failing after 7m50s
Some checks failed
Dotnet build and test / build (push) Failing after 7m50s
This commit is contained in:
parent
bba5fe093c
commit
1897a6807d
1 changed files with 25 additions and 0 deletions
|
|
@ -38,6 +38,8 @@ public partial class MarkdownEditorControl : UserControl
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
PropertyChanged += OnPropertyChanged;
|
PropertyChanged += OnPropertyChanged;
|
||||||
|
SizeChanged += OnSizeChanged;
|
||||||
|
UpdateEditorLimits();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
|
@ -60,4 +62,27 @@ public partial class MarkdownEditorControl : UserControl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnSizeChanged(object? sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateEditorLimits();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateEditorLimits()
|
||||||
|
{
|
||||||
|
var visibleHeight = Bounds.Height > 0 ? Bounds.Height - 24 : 260;
|
||||||
|
visibleHeight = Math.Max(visibleHeight, 80);
|
||||||
|
|
||||||
|
if (SourceEditor is not null)
|
||||||
|
{
|
||||||
|
SourceEditor.MaxHeight = visibleHeight;
|
||||||
|
SourceEditor.Height = double.NaN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PreviewViewer is not null)
|
||||||
|
{
|
||||||
|
PreviewViewer.MaxHeight = visibleHeight;
|
||||||
|
PreviewViewer.Height = double.NaN;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue