budibase/packages/standard-components/src/forms/LongFormField.svelte

63 lines
1.3 KiB
Svelte
Raw Normal View History

2021-01-28 19:03:44 +01:00
<script>
import { onMount } from "svelte"
2021-01-28 19:03:44 +01:00
import { RichText } from "@budibase/bbui"
import SpectrumField from "./SpectrumField.svelte"
export let field
export let label
export let placeholder
let fieldState
let fieldApi
2021-01-29 11:28:13 +01:00
// Update form value from bound value after we've mounted
let value
let mounted = false
$: mounted && fieldApi?.setValue(value)
// Get the fields initial value after initialising
onMount(() => {
value = $fieldState?.value
mounted = true
})
2021-01-28 19:03:44 +01:00
// Options for rich text component
const options = {
modules: {
toolbar: [
[
{
header: [1, 2, 3, false],
},
],
["bold", "italic", "underline", "strike"],
],
},
placeholder: placeholder || "Type something...",
theme: "snow",
}
</script>
<SpectrumField {label} {field} bind:fieldState bind:fieldApi defaultValue="">
{#if mounted}
2021-01-28 19:03:44 +01:00
<div>
<RichText bind:value {options} />
</div>
{/if}
</SpectrumField>
<style>
div {
background-color: white;
}
2021-02-01 19:00:38 +01:00
div :global(> div) {
width: auto !important;
}
2021-01-28 19:03:44 +01:00
div :global(.ql-snow.ql-toolbar:after, .ql-snow .ql-toolbar:after) {
display: none;
}
div :global(.ql-snow .ql-formats:after) {
display: none;
}
</style>