Skip to content

Commit

Permalink
Make sure that the template data editor overwrites previous data and …
Browse files Browse the repository at this point in the history
…use JSON as its language

Signed-off-by: Axel Boberg <[email protected]>
  • Loading branch information
axelboberg committed Mar 18, 2024
1 parent 2f777f4 commit dbf8568
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugins/caspar/app/components/Monaco/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const Monaco = ({ defaultValue = '', value = '', onChange = () => {} }) =

const editor = monaco.editor.create(elRef.current, {
value: defaultValue,
language: 'bridgeLang',
language: 'json',
scrollbar: {
verticalScrollbarSize: 5,
horizontalScrollbarSize: 5
Expand Down
21 changes: 14 additions & 7 deletions plugins/caspar/app/views/InspectorTemplate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ export const InspectorTemplate = () => {
}

function handleChange(newValue) {
handleNewValue({
data: {
caspar: {
templateData: JSON.parse(newValue),
templateDataString: newValue
try {
const parsed = JSON.parse(newValue)
handleNewValue({
data: {
caspar: {
templateData: { $replace: parsed },
templateDataString: newValue
}
}
}
})
})
} catch (_) {
/*
Invalid JSON data was passed from Monaco
*/
}
}

return (
Expand Down

0 comments on commit dbf8568

Please sign in to comment.