mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Fix RTL text display being off + Update PlainTextInput RTL on save (#1448)
This commit is contained in:
parent
3cdb3d72c1
commit
02409d083b
2 changed files with 17 additions and 2 deletions
|
@ -39,3 +39,7 @@ button {
|
||||||
/* override transition for instant hover response */
|
/* override transition for instant hover response */
|
||||||
transition: color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
|
transition: color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre, code, kbd, samp {
|
||||||
|
unicode-bidi: normal !important;
|
||||||
|
}
|
||||||
|
|
|
@ -11,14 +11,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher, getContext } from "svelte";
|
||||||
import type { Writable } from "svelte/store";
|
import type { Writable } from "svelte/store";
|
||||||
import storeSubscribe from "../sveltelib/store-subscribe";
|
import storeSubscribe from "../sveltelib/store-subscribe";
|
||||||
|
import { directionKey } from "../lib/context-keys";
|
||||||
|
|
||||||
export let configuration: CodeMirror.EditorConfiguration;
|
export let configuration: CodeMirror.EditorConfiguration;
|
||||||
export let code: Writable<string>;
|
export let code: Writable<string>;
|
||||||
|
|
||||||
|
const direction = getContext<Writable<"ltr" | "rtl">>(directionKey);
|
||||||
|
const defaultConfiguration = {
|
||||||
|
direction: $direction,
|
||||||
|
rtlMoveVisually: true,
|
||||||
|
};
|
||||||
|
|
||||||
let codeMirror: CodeMirror.EditorFromTextArea;
|
let codeMirror: CodeMirror.EditorFromTextArea;
|
||||||
|
$: codeMirror?.setOption("direction", $direction);
|
||||||
|
|
||||||
function setValue(content: string): void {
|
function setValue(content: string): void {
|
||||||
codeMirror.setValue(content);
|
codeMirror.setValue(content);
|
||||||
|
@ -28,7 +36,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
function openCodeMirror(textarea: HTMLTextAreaElement): void {
|
function openCodeMirror(textarea: HTMLTextAreaElement): void {
|
||||||
codeMirror = CodeMirrorLib.fromTextArea(textarea, configuration);
|
codeMirror = CodeMirrorLib.fromTextArea(textarea, {
|
||||||
|
...defaultConfiguration,
|
||||||
|
...configuration,
|
||||||
|
});
|
||||||
|
|
||||||
// TODO passing in the tabindex option does not do anything: bug?
|
// TODO passing in the tabindex option does not do anything: bug?
|
||||||
codeMirror.getInputField().tabIndex = 0;
|
codeMirror.getInputField().tabIndex = 0;
|
||||||
|
|
Loading…
Reference in a new issue