Change how context is passed through to binding drawers to ensure it's always available
This commit is contained in:
parent
9371661f0b
commit
461418390d
|
@ -135,13 +135,10 @@
|
||||||
selected={mode}
|
selected={mode}
|
||||||
on:select={onChangeMode}
|
on:select={onChangeMode}
|
||||||
beforeSwitch={selectedMode => {
|
beforeSwitch={selectedMode => {
|
||||||
if (selectedMode == mode) {
|
if (selectedMode === mode) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the current mode value
|
|
||||||
const editorValue = usingJS ? decodeJSBinding(jsValue) : hbsValue
|
const editorValue = usingJS ? decodeJSBinding(jsValue) : hbsValue
|
||||||
|
|
||||||
if (editorValue) {
|
if (editorValue) {
|
||||||
targetMode = selectedMode
|
targetMode = selectedMode
|
||||||
return false
|
return false
|
||||||
|
@ -204,9 +201,9 @@
|
||||||
<div class="syntax-error">
|
<div class="syntax-error">
|
||||||
Current Handlebars syntax is invalid, please check the
|
Current Handlebars syntax is invalid, please check the
|
||||||
guide
|
guide
|
||||||
<a href="https://handlebarsjs.com/guide/" target="_blank"
|
<a href="https://handlebarsjs.com/guide/" target="_blank">
|
||||||
>here</a
|
here
|
||||||
>
|
</a>
|
||||||
for more details.
|
for more details.
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
@ -523,9 +520,10 @@
|
||||||
border-radius: var(--border-radius-s);
|
border-radius: var(--border-radius-s);
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
border: 1px solid var(--spectrum-global-color-gray-300);
|
border: 1px solid var(--spectrum-global-color-gray-300);
|
||||||
max-height: 200px;
|
overflow-y: scroll;
|
||||||
overflow: auto;
|
overflow-x: hidden;
|
||||||
white-space: pre;
|
white-space: pre-wrap;
|
||||||
word-wrap: anywhere;
|
word-wrap: break-word;
|
||||||
|
max-height: 92px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
export let mode
|
export let mode
|
||||||
export let allowHelpers
|
export let allowHelpers
|
||||||
export let context = null
|
export let context = null
|
||||||
export let noPaddingTop = false
|
|
||||||
|
|
||||||
let search = ""
|
let search = ""
|
||||||
let popover
|
let popover
|
||||||
|
@ -70,6 +69,8 @@
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: console.log(context)
|
||||||
|
|
||||||
const getBindingValue = binding => {
|
const getBindingValue = binding => {
|
||||||
const hbs = `{{ ${binding.runtimeBinding} }}`
|
const hbs = `{{ ${binding.runtimeBinding} }}`
|
||||||
return processStringSync(hbs, context)
|
return processStringSync(hbs, context)
|
||||||
|
@ -165,15 +166,13 @@
|
||||||
class="binding"
|
class="binding"
|
||||||
on:mouseenter={e => {
|
on:mouseenter={e => {
|
||||||
let val = getBindingValue(binding)
|
let val = getBindingValue(binding)
|
||||||
if (val === "") {
|
if (val !== "") {
|
||||||
val = " "
|
popoverAnchor = e.target
|
||||||
|
hoverTarget = {
|
||||||
|
code: val,
|
||||||
|
}
|
||||||
|
popover.show()
|
||||||
}
|
}
|
||||||
popoverAnchor = e.target
|
|
||||||
hoverTarget = {
|
|
||||||
code: val,
|
|
||||||
}
|
|
||||||
popover.show()
|
|
||||||
e.stopPropagation()
|
|
||||||
}}
|
}}
|
||||||
on:mouseleave={() => {
|
on:mouseleave={() => {
|
||||||
popover.hide()
|
popover.hide()
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<script>
|
<script>
|
||||||
import BindingPanel from "./BindingPanel.svelte"
|
import BindingPanel from "./BindingPanel.svelte"
|
||||||
|
import { previewStore } from "stores/builder"
|
||||||
|
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
export let valid
|
export let valid
|
||||||
export let value = ""
|
export let value = ""
|
||||||
export let allowJS = false
|
export let allowJS = false
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
export let context = null
|
|
||||||
export let autofocusEditor = false
|
export let autofocusEditor = false
|
||||||
|
|
||||||
$: enrichedBindings = enrichBindings(bindings)
|
$: enrichedBindings = enrichBindings(bindings)
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<BindingPanel
|
<BindingPanel
|
||||||
bind:valid
|
bind:valid
|
||||||
bindings={enrichedBindings}
|
bindings={enrichedBindings}
|
||||||
{context}
|
context={$previewStore.selectedComponentContext}
|
||||||
{value}
|
{value}
|
||||||
{allowJS}
|
{allowJS}
|
||||||
{allowHelpers}
|
{allowHelpers}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
export let drawerLeft
|
export let drawerLeft
|
||||||
export let key
|
export let key
|
||||||
export let disableBindings = false
|
export let disableBindings = false
|
||||||
export let context = null
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -106,7 +105,6 @@
|
||||||
bind:valid
|
bind:valid
|
||||||
value={readableValue}
|
value={readableValue}
|
||||||
on:change={event => (tempValue = event.detail)}
|
on:change={event => (tempValue = event.detail)}
|
||||||
{context}
|
|
||||||
{bindings}
|
{bindings}
|
||||||
{allowJS}
|
{allowJS}
|
||||||
{allowHelpers}
|
{allowHelpers}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
export let key
|
export let key
|
||||||
export let nested
|
export let nested
|
||||||
export let max
|
export let max
|
||||||
|
export let context
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
export let propertyFocus = false
|
export let propertyFocus = false
|
||||||
export let info = null
|
export let info = null
|
||||||
export let disableBindings = false
|
export let disableBindings = false
|
||||||
export let context = null
|
|
||||||
export let wide
|
export let wide
|
||||||
|
|
||||||
$: nullishValue = value == null || value === ""
|
$: nullishValue = value == null || value === ""
|
||||||
|
@ -99,7 +98,6 @@
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
bindings={allBindings}
|
bindings={allBindings}
|
||||||
name={key}
|
name={key}
|
||||||
{context}
|
|
||||||
{nested}
|
{nested}
|
||||||
{key}
|
{key}
|
||||||
{type}
|
{type}
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
tag,
|
tag,
|
||||||
includeHidden
|
includeHidden
|
||||||
)
|
)
|
||||||
$: context = $previewStore.selectedComponentContext
|
|
||||||
|
|
||||||
const getSections = (instance, definition, isScreen, tag, includeHidden) => {
|
const getSections = (instance, definition, isScreen, tag, includeHidden) => {
|
||||||
const settings = definition?.settings ?? []
|
const settings = definition?.settings ?? []
|
||||||
|
@ -199,7 +198,6 @@
|
||||||
min: setting.min ?? null,
|
min: setting.min ?? null,
|
||||||
max: setting.max ?? null,
|
max: setting.max ?? null,
|
||||||
}}
|
}}
|
||||||
{context}
|
|
||||||
{bindings}
|
{bindings}
|
||||||
{componentBindings}
|
{componentBindings}
|
||||||
{componentInstance}
|
{componentInstance}
|
||||||
|
|
Loading…
Reference in New Issue