|
|
@ -1,7 +1,7 @@ |
|
|
<script> |
|
|
<script> |
|
|
import { getContext, setContext } from "svelte" |
|
|
import { getContext, setContext } from "svelte" |
|
|
import { writable } from "svelte/store" |
|
|
import { writable } from "svelte/store" |
|
|
import { CoreRichTextField } from "@budibase/bbui" |
|
|
import { CoreRichTextField, CoreTextArea } from "@budibase/bbui" |
|
|
import Field from "./Field.svelte" |
|
|
import Field from "./Field.svelte" |
|
|
|
|
|
|
|
|
export let field |
|
|
export let field |
|
|
@ -10,15 +10,22 @@ |
|
|
export let disabled = false |
|
|
export let disabled = false |
|
|
export let validation |
|
|
export let validation |
|
|
export let defaultValue = "" |
|
|
export let defaultValue = "" |
|
|
|
|
|
export let format = "auto" |
|
|
|
|
|
|
|
|
let fieldState |
|
|
let fieldState |
|
|
let fieldApi |
|
|
let fieldApi |
|
|
|
|
|
let fieldSchema |
|
|
|
|
|
|
|
|
const context = getContext("context") |
|
|
const context = getContext("context") |
|
|
const component = getContext("component") |
|
|
const component = getContext("component") |
|
|
const newContext = writable($component) |
|
|
const newContext = writable($component) |
|
|
setContext("component", newContext) |
|
|
setContext("component", newContext) |
|
|
|
|
|
|
|
|
|
|
|
// Determine whether we should use a rich or plain text component. |
|
|
|
|
|
// We treat undefined as "auto". |
|
|
|
|
|
$: useRichText = |
|
|
|
|
|
format === "rich" || (format !== "plain" && fieldSchema?.useRichText) |
|
|
|
|
|
|
|
|
// Determine the offset needed for full screen mode |
|
|
// Determine the offset needed for full screen mode |
|
|
$: offset = $context.device.mobile ? "61px" : "137px" |
|
|
$: offset = $context.device.mobile ? "61px" : "137px" |
|
|
|
|
|
|
|
|
@ -27,7 +34,7 @@ |
|
|
// itself based on the height of the rich text field. |
|
|
// itself based on the height of the rich text field. |
|
|
let height |
|
|
let height |
|
|
$: { |
|
|
$: { |
|
|
height = $component.styles?.normal?.height |
|
|
height = $component.styles?.normal?.height || "150px" |
|
|
newContext.set({ |
|
|
newContext.set({ |
|
|
...$component, |
|
|
...$component, |
|
|
styles: { |
|
|
styles: { |
|
|
@ -50,20 +57,33 @@ |
|
|
type="longform" |
|
|
type="longform" |
|
|
bind:fieldState |
|
|
bind:fieldState |
|
|
bind:fieldApi |
|
|
bind:fieldApi |
|
|
|
|
|
bind:fieldSchema |
|
|
> |
|
|
> |
|
|
{#if fieldState} |
|
|
{#if fieldState} |
|
|
<CoreRichTextField |
|
|
{#if useRichText} |
|
|
value={fieldState.value} |
|
|
<CoreRichTextField |
|
|
on:change={e => fieldApi.setValue(e.detail)} |
|
|
value={fieldState.value} |
|
|
disabled={fieldState.disabled} |
|
|
on:change={e => fieldApi.setValue(e.detail)} |
|
|
error={fieldState.error} |
|
|
disabled={fieldState.disabled} |
|
|
id={fieldState.fieldId} |
|
|
error={fieldState.error} |
|
|
{placeholder} |
|
|
id={fieldState.fieldId} |
|
|
{height} |
|
|
{placeholder} |
|
|
fullScreenOffset={offset} |
|
|
{height} |
|
|
easyMDEOptions={{ |
|
|
fullScreenOffset={offset} |
|
|
hideIcons: $context.device.mobile ? ["side-by-side", "guide"] : [], |
|
|
easyMDEOptions={{ |
|
|
}} |
|
|
hideIcons: $context.device.mobile ? ["side-by-side", "guide"] : [], |
|
|
/> |
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
{:else} |
|
|
|
|
|
<CoreTextArea |
|
|
|
|
|
value={fieldState.value} |
|
|
|
|
|
on:change={e => fieldApi.setValue(e.detail)} |
|
|
|
|
|
disabled={fieldState.disabled} |
|
|
|
|
|
error={fieldState.error} |
|
|
|
|
|
id={fieldState.fieldId} |
|
|
|
|
|
{placeholder} |
|
|
|
|
|
minHeight={height} |
|
|
|
|
|
/> |
|
|
|
|
|
{/if} |
|
|
{/if} |
|
|
{/if} |
|
|
</Field> |
|
|
</Field> |
|
|
|