Update client app long form text component to be rich text and add new markdown viewer component

This commit is contained in:
Andrew Kingston 2022-02-02 21:23:28 +00:00
parent 283b59d5fe
commit 7f064598a6
4 changed files with 42 additions and 27 deletions

View File

@ -2340,7 +2340,6 @@
"icon": "TextParagraph", "icon": "TextParagraph",
"styles": ["size"], "styles": ["size"],
"editable": true, "editable": true,
"illegalChildren": ["section"],
"settings": [ "settings": [
{ {
"type": "field/longform", "type": "field/longform",
@ -3385,5 +3384,18 @@
"key": "validation" "key": "validation"
} }
] ]
},
"markdownviewer": {
"name": "Markdown Viewer",
"icon": "TaskList",
"styles": ["size"],
"editable": true,
"settings": [
{
"type": "text",
"label": "Value",
"key": "value"
}
]
} }
} }

View File

@ -0,0 +1,19 @@
<script>
import { MarkdownViewer } from "@budibase/bbui"
import { getContext } from "svelte"
import Placeholder from "./Placeholder.svelte"
export let value
const component = getContext("component")
const { builderStore, styleable } = getContext("sdk")
const height = $component.styles?.normal?.height
</script>
<div use:styleable={$component.styles}>
{#if value}
<MarkdownViewer {value} {height} />
{:else if $builderStore.inBuilder}
<Placeholder />
{/if}
</div>

View File

@ -1,7 +1,6 @@
<script> <script>
import { CoreTextArea } from "@budibase/bbui" import { CoreRichTextField } from "@budibase/bbui"
import Field from "./Field.svelte" import Field from "./Field.svelte"
import { getContext } from "svelte"
export let field export let field
export let label export let label
@ -12,9 +11,6 @@
let fieldState let fieldState
let fieldApi let fieldApi
const component = getContext("component")
$: height = $component.styles?.normal?.height || "124px"
</script> </script>
<Field <Field
@ -28,26 +24,13 @@
bind:fieldApi bind:fieldApi
> >
{#if fieldState} {#if fieldState}
<div style="--height: {height};"> <CoreRichTextField
<CoreTextArea value={fieldState.value}
value={fieldState.value} on:change={e => fieldApi.setValue(e.detail)}
on:change={e => fieldApi.setValue(e.detail)} disabled={fieldState.disabled}
disabled={fieldState.disabled} error={fieldState.error}
error={fieldState.error} id={fieldState.fieldId}
id={fieldState.fieldId} {placeholder}
{placeholder} />
/>
</div>
{/if} {/if}
</Field> </Field>
<style>
:global(.spectrum-Form-itemField .spectrum-Textfield--multiline) {
min-height: calc(var(--height) - 24px);
}
:global(.spectrum-Form--labelsAbove
.spectrum-Form-itemField
.spectrum-Textfield--multiline) {
min-height: calc(var(--height) - 24px);
}
</style>

View File

@ -30,6 +30,7 @@ export { default as daterangepicker } from "./DateRangePicker.svelte"
export { default as cardstat } from "./CardStat.svelte" export { default as cardstat } from "./CardStat.svelte"
export { default as spectrumcard } from "./SpectrumCard.svelte" export { default as spectrumcard } from "./SpectrumCard.svelte"
export { default as tag } from "./Tag.svelte" export { default as tag } from "./Tag.svelte"
export { default as markdownviewer } from "./MarkdownViewer.svelte"
export * from "./charts" export * from "./charts"
export * from "./forms" export * from "./forms"
export * from "./table" export * from "./table"