mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 10:51:36 +01:00
Add disable attribute for no permission buttons and shorten query param names
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { deserialize, applyAction } from "$app/forms";
|
||||
import { textareaScrollTop, previewContent } from "$lib/runes.svelte";
|
||||
import LoadingSpinner from "$lib/components/LoadingSpinner.svelte";
|
||||
import { LOADING_DELAY } from "$lib/utils";
|
||||
|
||||
const {
|
||||
apiPrefix,
|
||||
@@ -10,6 +12,8 @@
|
||||
}: { apiPrefix: string; label: string; name: string; content: string } = $props();
|
||||
|
||||
let mainContentTextarea: HTMLTextAreaElement;
|
||||
let loadingDelay: number;
|
||||
let pasting = $state(false);
|
||||
|
||||
const updateScrollPercentage = () => {
|
||||
const { scrollTop, scrollHeight, clientHeight } = mainContentTextarea;
|
||||
@@ -28,6 +32,8 @@
|
||||
|
||||
if (!fileObject) return;
|
||||
|
||||
loadingDelay = window.setTimeout(() => (pasting = true), LOADING_DELAY);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", fileObject);
|
||||
|
||||
@@ -48,20 +54,29 @@
|
||||
const target = event.target as HTMLTextAreaElement;
|
||||
const markdownToInsert = ``;
|
||||
const cursorPosition = target.selectionStart;
|
||||
const newContent = target.value.slice(0, target.selectionStart) + markdownToInsert;
|
||||
target.value.slice(target.selectionStart);
|
||||
const newContent =
|
||||
target.value.slice(0, cursorPosition) +
|
||||
markdownToInsert +
|
||||
target.value.slice(cursorPosition);
|
||||
|
||||
target.value = newContent;
|
||||
previewContent.value = newContent;
|
||||
|
||||
const newCursorPosition = cursorPosition + markdownToInsert.length;
|
||||
target.setSelectionRange(newCursorPosition, newCursorPosition);
|
||||
target.focus();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
window.clearTimeout(loadingDelay);
|
||||
pasting = false;
|
||||
return;
|
||||
};
|
||||
</script>
|
||||
|
||||
{#if pasting}
|
||||
<LoadingSpinner />
|
||||
{/if}
|
||||
|
||||
<label>
|
||||
{label}:
|
||||
<textarea
|
||||
|
||||
Reference in New Issue
Block a user