Add support for disabling rich text fields

This commit is contained in:
Andrew Kingston 2022-02-03 14:28:15 +00:00
parent 0005b05829
commit a0c3ee1c8b
3 changed files with 23 additions and 2 deletions

View File

@ -17,6 +17,7 @@
{height}
{id}
{fullScreenOffset}
{disabled}
on:change
/>
</div>

View File

@ -7,6 +7,7 @@
export let placeholder = null
export let id = null
export let fullScreenOffset = 0
export let disabled = false
const dispatch = createEventDispatcher()
@ -48,6 +49,7 @@
{height}
{id}
{fullScreenOffset}
{disabled}
easyMDEOptions={{
initialValue: value,
placeholder,

View File

@ -9,6 +9,7 @@
export let mde = null
export let id = null
export let fullScreenOffset = 0
export let disabled = false
let element
@ -32,11 +33,28 @@
})
</script>
<div style={`--fullscreen-offset:${fullScreenOffset || "0px"}`}>
<textarea {id} bind:this={element} />
<div class:disabled style={`--fullscreen-offset:${fullScreenOffset || "0px"}`}>
<textarea disabled {id} bind:this={element} />
</div>
<style>
/* Disabled styles */
.disabled :global(textarea) {
display: none;
}
.disabled :global(.CodeMirror-cursor) {
display: none;
}
.disabled :global(.EasyMDEContainer) {
pointer-events: none;
}
.disabled :global(.editor-toolbar button i) {
color: var(--spectrum-global-color-gray-400);
}
.disabled :global(.CodeMirror) {
color: var(--spectrum-global-color-gray-600);
}
/* Toolbar container */
:global(.EasyMDEContainer .editor-toolbar) {
background: var(--spectrum-global-color-gray-50);