More QOL changes

This commit is contained in:
ZXY101
2024-02-11 08:45:21 +02:00
parent 04dd68b242
commit 491c4efab2
5 changed files with 49 additions and 12 deletions

View File

@@ -45,6 +45,8 @@
$: border = $settings.textBoxBorders ? '1px solid red' : 'none';
$: contenteditable = $settings.textEditable;
$: triggerMethod = $settings.ankiConnectSettings.triggerMethod || 'both';
async function onUpdateCard(lines: string[]) {
if ($settings.ankiConnectSettings.enabled) {
const sentence = lines.join(' ');
@@ -60,7 +62,14 @@
}
function onContextMenu(event: Event, lines: string[]) {
if ($settings.ankiConnectSettings.enabled) {
if (triggerMethod === 'both' || triggerMethod === 'rightClick') {
event.preventDefault();
onUpdateCard(lines);
}
}
function onDoubleTap(event: Event, lines: string[]) {
if (triggerMethod === 'both' || triggerMethod === 'doubleTap') {
event.preventDefault();
onUpdateCard(lines);
}
@@ -81,7 +90,7 @@
style:writing-mode={writingMode}
role="none"
on:contextmenu={(e) => onContextMenu(e, lines)}
on:dblclick={() => onUpdateCard(lines)}
on:dblclick={(e) => onDoubleTap(e, lines)}
{contenteditable}
>
{#each lines as line}