mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-18 22:52:37 +00:00
Add RTL support for markdown files
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:

committed by
ema

parent
a4d118e11f
commit
4840a87858
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html dir="{{rtl}}">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
||||
@@ -144,6 +144,34 @@
|
||||
cursor: ew-resize;
|
||||
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>
|
||||
|
||||
<textarea id="text-input" style="display: none">{{content}}</textarea>
|
||||
@@ -337,6 +365,21 @@
|
||||
if (e.code === "Space") {
|
||||
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>
|
||||
|
Reference in New Issue
Block a user