[Peek]Add wrap and formatting options for Monaco previewer (#29378)

* add options for monaco previewer

* fix formatting
This commit is contained in:
Davide Giacometti
2023-10-24 15:32:35 +02:00
committed by GitHub
parent 9693fd7035
commit 5a06bcb473
14 changed files with 313 additions and 24 deletions

View File

@@ -13,13 +13,14 @@ using Peek.Common.Extensions;
using Peek.Common.Helpers;
using Peek.Common.Models;
using Peek.FilePreviewer.Models;
using Windows.Foundation;
namespace Peek.FilePreviewer.Previewers
{
public partial class WebBrowserPreviewer : ObservableObject, IBrowserPreviewer, IDisposable
{
private static readonly HashSet<string> _supportedFileTypes = new HashSet<string>
private readonly IPreviewSettings _previewSettings;
private static readonly HashSet<string> _supportedFileTypes = new()
{
// Web
".html",
@@ -43,8 +44,9 @@ namespace Peek.FilePreviewer.Previewers
private bool disposed;
public WebBrowserPreviewer(IFileSystemItem file)
public WebBrowserPreviewer(IFileSystemItem file, IPreviewSettings previewSettings)
{
_previewSettings = previewSettings;
File = file;
Dispatcher = DispatcherQueue.GetForCurrentThread();
}
@@ -109,7 +111,7 @@ namespace Peek.FilePreviewer.Previewers
if (IsDevFilePreview && !isHtml && !isMarkdown)
{
var raw = await ReadHelper.Read(File.Path.ToString());
Preview = new Uri(MonacoHelper.PreviewTempFile(raw, File.Extension, TempFolderPath.Path));
Preview = new Uri(MonacoHelper.PreviewTempFile(raw, File.Extension, TempFolderPath.Path, _previewSettings.SourceCodeTryFormat, _previewSettings.SourceCodeWrapText));
}
else if (isMarkdown)
{