2022-08-15 05:34:16 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
|
|
|
import { getContext } from "svelte";
|
|
|
|
import type { Readable } from "svelte/store";
|
|
|
|
|
|
|
|
import { directionKey, fontFamilyKey, fontSizeKey } from "../lib/context-keys";
|
|
|
|
import { context } from "./EditingArea.svelte";
|
|
|
|
|
|
|
|
const { content } = context.get();
|
|
|
|
|
|
|
|
const fontFamily = getContext<Readable<string>>(fontFamilyKey);
|
|
|
|
const fontSize = getContext<Readable<number>>(fontSizeKey);
|
|
|
|
const direction = getContext<Readable<"ltr" | "rtl">>(directionKey);
|
|
|
|
|
|
|
|
$: empty = $content.length === 0;
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if empty}
|
|
|
|
<div
|
|
|
|
class="field-description"
|
|
|
|
style:font-family={$fontFamily}
|
|
|
|
style:font-size="{$fontSize}px"
|
|
|
|
style:direction={$direction}
|
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.field-description {
|
|
|
|
position: absolute;
|
2022-08-17 09:21:13 +02:00
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
2022-08-15 05:34:16 +02:00
|
|
|
|
2022-11-02 09:30:13 +01:00
|
|
|
color: var(--fg-subtle);
|
2022-08-17 09:21:13 +02:00
|
|
|
pointer-events: none;
|
2022-08-15 05:34:16 +02:00
|
|
|
|
2022-09-05 09:20:00 +02:00
|
|
|
/* Stay a on single line */
|
2022-08-15 05:34:16 +02:00
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
2022-09-12 11:22:22 +02:00
|
|
|
|
|
|
|
/* The field description is placed absolutely on top of the editor field */
|
|
|
|
/* So we need to make sure it does not escape the editor field if the */
|
|
|
|
/* description is too long */
|
|
|
|
overflow: hidden;
|
2022-08-15 05:34:16 +02:00
|
|
|
}
|
|
|
|
</style>
|