Update editable components to trim whitespace when editing inline

This commit is contained in:
Andrew Kingston 2021-11-18 20:32:57 +00:00
parent df29ad1092
commit 90b3e2a16d
5 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@
} }
const updateText = e => { const updateText = e => {
builderStore.actions.updateProp("text", e.target.textContent) builderStore.actions.updateProp("text", e.target.textContent.trim())
} }
</script> </script>

View File

@ -47,7 +47,7 @@
// Convert contenteditable HTML to text and save // Convert contenteditable HTML to text and save
const updateText = e => { const updateText = e => {
const sanitized = e.target.innerHTML.replace(/<br>/gi, "\n") const sanitized = e.target.innerHTML.replace(/<br>/gi, "\n").trim()
builderStore.actions.updateProp("text", sanitized) builderStore.actions.updateProp("text", sanitized)
} }
</script> </script>

View File

@ -47,7 +47,7 @@
} }
const updateText = e => { const updateText = e => {
builderStore.actions.updateProp("text", e.target.textContent) builderStore.actions.updateProp("text", e.target.textContent.trim())
} }
</script> </script>

View File

@ -46,7 +46,7 @@
// Convert contenteditable HTML to text and save // Convert contenteditable HTML to text and save
const updateText = e => { const updateText = e => {
const sanitized = e.target.innerHTML.replace(/<br>/gi, "\n") const sanitized = e.target.innerHTML.replace(/<br>/gi, "\n").trim()
builderStore.actions.updateProp("text", sanitized) builderStore.actions.updateProp("text", sanitized)
} }
</script> </script>

View File

@ -49,7 +49,7 @@
$: labelClass = labelPos === "above" ? "" : `spectrum-FieldLabel--${labelPos}` $: labelClass = labelPos === "above" ? "" : `spectrum-FieldLabel--${labelPos}`
const updateLabel = e => { const updateLabel = e => {
builderStore.actions.updateProp("label", e.target.textContent) builderStore.actions.updateProp("label", e.target.textContent.trim())
} }
</script> </script>