mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 18:39:45 +00:00
Improved MarkdownViewer
#### Features - Uses the latest [github-markdown.css](https://github.com/sindresorhus/github-markdown-css/blob/main/github-markdown.css) file that contains styling support for both dark and light mode. - Table of Contents has an improved design, and: - The width can be resized. - TOC headings are automatically highlighted to help track your position in the file. - Improved fullscreen layout based on Github.com behavior. - External links clicked will open in default browser instead of doing nothing. - Uses [markdownItAnchor](https://github.com/valeriangalliat/markdown-it-anchor) to allow heading anchor links in the file to work. - Uses [highlight.js](https://github.com/highlightjs/highlight.js) to provide syntax highlighting to codeblocks. #### Changes - Made changes to allow the `md2html.html` file to use relative file imports for better maintainability. - MarkdownViewer can now easily be customized by users by modifying files in `<Quicklook data folder>/QuickLook.Plugin.MarkdownViewer/` - Caching and `localStorage` is now supported thanks to these changes. - Prevent default behavior of spacebar scrolling the page, while we use spacebar to dismiss the preview. - Sets `WebView` `DefaultBackgroundColor` to prevent white flash in dark mode. After the page has loaded, sets `DefaultBackgroundColor` back to white to have the expected default behavior on HTML pages that don't specify any background color. #### Clean up - Removed the need for `jQuery`. - Removed old polyfill code.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright © 2021 Paddy Xu and Frank Becker
|
||||
// Copyright © 2021 Paddy Xu and Frank Becker
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
@@ -29,8 +30,8 @@ namespace QuickLook.Plugin.HtmlViewer
|
||||
{
|
||||
public class WebpagePanel : UserControl
|
||||
{
|
||||
private Uri _currentUri;
|
||||
private WebView2 _webView;
|
||||
public Uri _currentUri;
|
||||
public WebView2 _webView;
|
||||
|
||||
public WebpagePanel()
|
||||
{
|
||||
@@ -44,10 +45,12 @@ namespace QuickLook.Plugin.HtmlViewer
|
||||
{
|
||||
CreationProperties = new CoreWebView2CreationProperties
|
||||
{
|
||||
UserDataFolder = Path.Combine(SettingHelper.LocalDataPath, @"WebView2_Data\\")
|
||||
}
|
||||
UserDataFolder = Path.Combine(SettingHelper.LocalDataPath, @"WebView2_Data\\"),
|
||||
},
|
||||
DefaultBackgroundColor = OSThemeHelper.AppsUseDarkTheme() ? Color.FromArgb(255, 32, 32, 32) : Color.White, // Prevent white flash in dark mode
|
||||
};
|
||||
_webView.NavigationStarting += NavigationStarting_CancelNavigation;
|
||||
_webView.NavigationCompleted += WebView_NavigationCompleted;
|
||||
Content = _webView;
|
||||
}
|
||||
}
|
||||
@@ -83,6 +86,11 @@ namespace QuickLook.Plugin.HtmlViewer
|
||||
if (newUri != _currentUri) e.Cancel = true;
|
||||
}
|
||||
|
||||
private void WebView_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
|
||||
{
|
||||
_webView.DefaultBackgroundColor = Color.White; // Reset to white after page load to match expected default behavior
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_webView?.Dispose();
|
||||
|
Reference in New Issue
Block a user