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} {height}
{id} {id}
{fullScreenOffset} {fullScreenOffset}
{disabled}
on:change on:change
/> />
</div> </div>

View File

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

View File

@ -9,6 +9,7 @@
export let mde = null export let mde = null
export let id = null export let id = null
export let fullScreenOffset = 0 export let fullScreenOffset = 0
export let disabled = false
let element let element
@ -32,11 +33,28 @@
}) })
</script> </script>
<div style={`--fullscreen-offset:${fullScreenOffset || "0px"}`}> <div class:disabled style={`--fullscreen-offset:${fullScreenOffset || "0px"}`}>
<textarea {id} bind:this={element} /> <textarea disabled {id} bind:this={element} />
</div> </div>
<style> <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 */ /* Toolbar container */
:global(.EasyMDEContainer .editor-toolbar) { :global(.EasyMDEContainer .editor-toolbar) {
background: var(--spectrum-global-color-gray-50); background: var(--spectrum-global-color-gray-50);