Focus contenteditable node when starting editing a component in the preview
This commit is contained in:
parent
9bf5d50d4f
commit
d3839f2f91
|
@ -13,6 +13,9 @@
|
||||||
export let underline
|
export let underline
|
||||||
export let size
|
export let size
|
||||||
|
|
||||||
|
let node
|
||||||
|
|
||||||
|
$: $component.editing && node?.focus()
|
||||||
$: placeholder = $builderStore.inBuilder && !text && !$component.editing
|
$: placeholder = $builderStore.inBuilder && !text && !$component.editing
|
||||||
$: componentText = getComponentText(text, $builderStore, $component)
|
$: componentText = getComponentText(text, $builderStore, $component)
|
||||||
$: sizeClass = `spectrum-Heading--size${size || "M"}`
|
$: sizeClass = `spectrum-Heading--size${size || "M"}`
|
||||||
|
@ -55,6 +58,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
bind:this={node}
|
||||||
contenteditable={$component.editing}
|
contenteditable={$component.editing}
|
||||||
use:styleable={styles}
|
use:styleable={styles}
|
||||||
class:placeholder
|
class:placeholder
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
export let underline
|
export let underline
|
||||||
export let size
|
export let size
|
||||||
|
|
||||||
|
let node
|
||||||
|
|
||||||
|
$: $component.editing && node?.focus()
|
||||||
$: externalLink = url && typeof url === "string" && !url.startsWith("/")
|
$: externalLink = url && typeof url === "string" && !url.startsWith("/")
|
||||||
$: target = openInNewTab ? "_blank" : "_self"
|
$: target = openInNewTab ? "_blank" : "_self"
|
||||||
$: placeholder = $builderStore.inBuilder && !text
|
$: placeholder = $builderStore.inBuilder && !text
|
||||||
|
@ -57,6 +60,7 @@
|
||||||
|
|
||||||
{#if $component.editing}
|
{#if $component.editing}
|
||||||
<div
|
<div
|
||||||
|
bind:this={node}
|
||||||
contenteditable
|
contenteditable
|
||||||
use:styleable={styles}
|
use:styleable={styles}
|
||||||
class:bold
|
class:bold
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
export let underline
|
export let underline
|
||||||
export let size
|
export let size
|
||||||
|
|
||||||
|
let node
|
||||||
|
|
||||||
|
$: $component.editing && node?.focus()
|
||||||
$: placeholder = $builderStore.inBuilder && !text && !$component.editing
|
$: placeholder = $builderStore.inBuilder && !text && !$component.editing
|
||||||
$: componentText = getComponentText(text, $builderStore, $component)
|
$: componentText = getComponentText(text, $builderStore, $component)
|
||||||
$: sizeClass = `spectrum-Body--size${size || "M"}`
|
$: sizeClass = `spectrum-Body--size${size || "M"}`
|
||||||
|
@ -54,6 +57,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
bind:this={node}
|
||||||
contenteditable={$component.editing}
|
contenteditable={$component.editing}
|
||||||
use:styleable={styles}
|
use:styleable={styles}
|
||||||
class:placeholder
|
class:placeholder
|
||||||
|
|
Loading…
Reference in New Issue