forked from Tsuzat/Edra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioPlaceholder.svelte
More file actions
29 lines (27 loc) · 867 Bytes
/
AudioPlaceholder.svelte
File metadata and controls
29 lines (27 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script lang="ts">
import type { NodeViewProps } from '@tiptap/core';
import AudioLines from 'lucide-svelte/icons/audio-lines';
import { NodeViewWrapper } from 'svelte-tiptap';
const { editor }: NodeViewProps = $props();
function handleClick(e: MouseEvent) {
e.preventDefault();
const audioUrl = prompt('Enter the URL of an audio:');
if (!audioUrl) {
return;
}
editor.chain().focus().setAudio(audioUrl).run();
}
</script>
<NodeViewWrapper class="edra-media-placeholder-wrapper" contenteditable="false">
<!-- svelte-ignore a11y_click_events_have_key_events -->
<span
class="edra-media-placeholder-content"
onclick={handleClick}
tabindex="0"
role="button"
aria-label="Insert An Audio"
>
<AudioLines class="edra-media-placeholder-icon" />
<span class="edra-media-placeholder-text">Insert An Audio</span>
</span>
</NodeViewWrapper>