mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-08 13:49:25 +00:00
Compare commits
4 Commits
a4d118e11f
...
a38b7a450a
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a38b7a450a | ||
![]() |
8ad5f39eab | ||
![]() |
83cfd2a3d8 | ||
![]() |
4840a87858 |
@@ -16,10 +16,12 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using Microsoft.Web.WebView2.Core;
|
using Microsoft.Web.WebView2.Core;
|
||||||
|
using QuickLook.Common.Helpers;
|
||||||
using QuickLook.Plugin.HtmlViewer;
|
using QuickLook.Plugin.HtmlViewer;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -78,7 +80,21 @@ public class MarkdownPanel : WebpagePanel
|
|||||||
var content = encoding.GetString(bytes);
|
var content = encoding.GetString(bytes);
|
||||||
|
|
||||||
var template = ReadString("/md2html.html");
|
var template = ReadString("/md2html.html");
|
||||||
var html = template.Replace("{{content}}", content);
|
|
||||||
|
// Support automatic RTL for markdown files
|
||||||
|
bool isRtl = false;
|
||||||
|
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
|
||||||
|
{
|
||||||
|
string isSupportRTL = TranslationHelper.Get("IsSupportRTL",
|
||||||
|
failsafe: bool.TrueString,
|
||||||
|
domain: Assembly.GetExecutingAssembly().GetName().Name);
|
||||||
|
|
||||||
|
if (bool.TrueString.Equals(isSupportRTL, StringComparison.OrdinalIgnoreCase))
|
||||||
|
isRtl = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var html = template.Replace("{{content}}", content)
|
||||||
|
.Replace("{{rtl}}", isRtl ? "rtl" : "ltr");
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html dir="{{rtl}}">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
@@ -144,6 +144,34 @@
|
|||||||
cursor: ew-resize;
|
cursor: ew-resize;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* RTL support */
|
||||||
|
html[dir="rtl"] .container {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[dir="rtl"] #toc {
|
||||||
|
right: 0;
|
||||||
|
left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[dir="rtl"] .table-of-contents a {
|
||||||
|
border-right: 2px solid transparent;
|
||||||
|
border-left: none;
|
||||||
|
margin-right: -1em;
|
||||||
|
margin-left: 0;
|
||||||
|
padding-right: calc(1em - 2px);
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html[dir="rtl"] .table-of-contents .active {
|
||||||
|
border-right: 2px solid var(--fgColor-accent);
|
||||||
|
border-left: none;
|
||||||
|
margin-right: -1em;
|
||||||
|
margin-left: 0;
|
||||||
|
padding-right: calc(1em - 2px);
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<textarea id="text-input" style="display: none">{{content}}</textarea>
|
<textarea id="text-input" style="display: none">{{content}}</textarea>
|
||||||
@@ -337,6 +365,21 @@
|
|||||||
if (e.code === "Space") {
|
if (e.code === "Space") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support keyboard shortcuts for RTL and LTR text direction
|
||||||
|
// RTL: Ctrl + RShift
|
||||||
|
// LTR: Ctrl + LShift
|
||||||
|
if ((e.ctrlKey || e.metaKey)) {
|
||||||
|
if (e.shiftKey && e.location === KeyboardEvent.DOM_KEY_LOCATION_RIGHT) {
|
||||||
|
// Right Shift + Ctrl: RTL
|
||||||
|
document.documentElement.setAttribute('dir', 'rtl');
|
||||||
|
e.preventDefault();
|
||||||
|
} else if (e.shiftKey && e.location === KeyboardEvent.DOM_KEY_LOCATION_LEFT) {
|
||||||
|
// Left Shift + Ctrl: LTR
|
||||||
|
document.documentElement.setAttribute('dir', 'ltr');
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user