Support a customisable offset for fullscreen mode for rich text editors
This commit is contained in:
parent
5109975433
commit
fc009cc9b4
|
@ -7,6 +7,14 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let height = null
|
export let height = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
export let fullScreenOffset = 0
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<MarkdownEditor {value} {placeholder} {height} {id} on:change />
|
<MarkdownEditor
|
||||||
|
{value}
|
||||||
|
{placeholder}
|
||||||
|
{height}
|
||||||
|
{id}
|
||||||
|
{fullScreenOffset}
|
||||||
|
on:change
|
||||||
|
/>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
export let error = null
|
export let error = null
|
||||||
export let height = null
|
export let height = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
export let fullScreenOffset = 0
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{height}
|
{height}
|
||||||
{id}
|
{id}
|
||||||
|
{fullScreenOffset}
|
||||||
on:change={onChange}
|
on:change={onChange}
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let height = "300px"
|
export let height = "300px"
|
||||||
export let placeholder = null
|
export let placeholder = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
export let fullScreenOffset = 0
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
scroll={true}
|
scroll={true}
|
||||||
{height}
|
{height}
|
||||||
{id}
|
{id}
|
||||||
|
{fullScreenOffset}
|
||||||
easyMDEOptions={{
|
easyMDEOptions={{
|
||||||
initialValue: value,
|
initialValue: value,
|
||||||
placeholder,
|
placeholder,
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
export let easyMDEOptions = null
|
export let easyMDEOptions = null
|
||||||
export let mde = null
|
export let mde = null
|
||||||
export let id = null
|
export let id = null
|
||||||
|
export let fullScreenOffset = 0
|
||||||
|
|
||||||
let element
|
let element
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
unorderedListStyle: "-",
|
unorderedListStyle: "-",
|
||||||
maxHeight: scroll ? height : undefined,
|
maxHeight: scroll ? height : undefined,
|
||||||
minHeight: scroll ? undefined : height,
|
minHeight: scroll ? undefined : height,
|
||||||
hideIcons: ["fullscreen", "side-by-side"],
|
// hideIcons: ["fullscreen", "side-by-side"],
|
||||||
...easyMDEOptions,
|
...easyMDEOptions,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -31,7 +32,9 @@
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<textarea {id} bind:this={element} />
|
<div style={`--fullscreen-offset:${fullScreenOffset || "0px"}`}>
|
||||||
|
<textarea {id} bind:this={element} />
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* Toolbar container */
|
/* Toolbar container */
|
||||||
|
@ -133,4 +136,14 @@
|
||||||
:global(.EasyMDEContainer a:hover) {
|
:global(.EasyMDEContainer a:hover) {
|
||||||
color: var(--primaryColorHover);
|
color: var(--primaryColorHover);
|
||||||
}
|
}
|
||||||
|
/* Allow full screen offset */
|
||||||
|
:global(.EasyMDEContainer .editor-toolbar.fullscreen) {
|
||||||
|
top: var(--fullscreen-offset);
|
||||||
|
}
|
||||||
|
:global(.EasyMDEContainer .CodeMirror-fullscreen) {
|
||||||
|
top: calc(50px + var(--fullscreen-offset));
|
||||||
|
}
|
||||||
|
:global(.EasyMDEContainer .editor-preview-side) {
|
||||||
|
top: calc(50px + var(--fullscreen-offset));
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -14,10 +14,14 @@
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
|
||||||
|
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 the offset needed for full screen mode
|
||||||
|
$: offset = $context.device.mobile ? "61px" : "137px"
|
||||||
|
|
||||||
// Extract the settings height so we can pass it on to the rich text field.
|
// Extract the settings height so we can pass it on to the rich text field.
|
||||||
// We then wipe the height style so that the field will automatically size
|
// We then wipe the height style so that the field will automatically size
|
||||||
// itself based on the height of the rich text field.
|
// itself based on the height of the rich text field.
|
||||||
|
@ -56,6 +60,7 @@
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{height}
|
{height}
|
||||||
|
fullScreenOffset={offset}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
Loading…
Reference in New Issue