diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 2adfd96626..63ac7b1c7f 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -589,6 +589,7 @@ "icon": "TextParagraph", "illegalChildren": ["section"], "showSettingsBar": true, + "editable": true, "settings": [ { "type": "text", @@ -695,6 +696,7 @@ "description": "A component for displaying heading text", "illegalChildren": ["section"], "showSettingsBar": true, + "editable": true, "settings": [ { "type": "text", diff --git a/packages/client/src/components/Component.svelte b/packages/client/src/components/Component.svelte index faf0226604..8200812477 100644 --- a/packages/client/src/components/Component.svelte +++ b/packages/client/src/components/Component.svelte @@ -60,21 +60,32 @@ $: instanceKey = JSON.stringify(rawProps) $: updateComponentProps(rawProps, instanceKey, $context) $: selected = - $builderStore.inBuilder && - $builderStore.selectedComponentId === instance._id + $builderStore.inBuilder && $builderStore.selectedComponentId === id $: inSelectedPath = $builderStore.selectedComponentPath?.includes(id) $: evaluateConditions(enrichedSettings?._conditions) $: componentSettings = { ...enrichedSettings, ...conditionalSettings } $: renderKey = `${propsHash}-${emptyState}` + $: editable = definition.editable + $: editing = editable && selected && $builderStore.editMode + $: draggable = interactive && !isLayout && !isScreen && !editing + $: droppable = interactive && !isLayout && !isScreen // Update component context $: componentStore.set({ id, children: children.length, - styles: { ...instance._styles, id, empty: emptyState, interactive }, + styles: { + ...instance._styles, + id, + empty: emptyState, + interactive, + draggable, + editable, + }, empty: emptyState, selected, name, + editing, }) const getRawProps = instance => { @@ -171,10 +182,6 @@ conditionalSettings = result.settingUpdates visible = nextVisible } - - // Drag and drop helper tags - $: draggable = interactive && !isLayout && !isScreen - $: droppable = interactive && !isLayout && !isScreen {#key renderKey} @@ -187,6 +194,7 @@ class:droppable class:empty class:interactive + class:editing data-id={id} data-name={name} > @@ -213,4 +221,7 @@ .draggable :global(*:hover) { cursor: grab; } + .editing :global(*:hover) { + cursor: auto; + } diff --git a/packages/client/src/components/app/Heading.svelte b/packages/client/src/components/app/Heading.svelte index bf4d902017..f3e283cf97 100644 --- a/packages/client/src/components/app/Heading.svelte +++ b/packages/client/src/components/app/Heading.svelte @@ -36,21 +36,34 @@ }, } } + + // Convert contenteditable HTML to text and save + const updateText = e => { + const html = e.target.innerHTML + const sanitized = html + .replace(/<\/div>
/gi, "\n") + .replace(/
/gi, "") + .replace(/<\/div>/gi, "") + .replace(/
/gi, "") + builderStore.actions.updateProp("text", sanitized) + } -

{componentText} -

+