Skip to content

Commit 1195b98

Browse files
committed
adding extensions property to CodeEditor
1 parent 15356bb commit 1195b98

File tree

2 files changed

+37
-28
lines changed

2 files changed

+37
-28
lines changed

src/Frontend/src/components/CodeEditor.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,38 @@ const props = withDefaults(
1919
showGutter?: boolean;
2020
showCopyToClipboard?: boolean;
2121
ariaLabel?: string;
22-
css?: string;
22+
extensions?: Extension[];
2323
}>(),
24-
{ readOnly: true, showGutter: true, showCopyToClipboard: true }
24+
{ readOnly: true, showGutter: true, showCopyToClipboard: true, extensions: () => [] }
2525
);
2626
2727
const extensions = computed(() => {
28-
const extensions: Extension[] = [];
28+
const allExtensions: Extension[] = [...(props.extensions || [])];
2929
3030
switch (props.language) {
3131
case "json":
32-
extensions.push(json());
32+
allExtensions.push(json());
3333
break;
3434
case "xml":
35-
extensions.push(xml());
35+
allExtensions.push(xml());
3636
break;
3737
case "shell":
38-
extensions.push(StreamLanguage.define(shell));
38+
allExtensions.push(StreamLanguage.define(shell));
3939
break;
4040
case "powershell":
41-
extensions.push(StreamLanguage.define(powerShell));
41+
allExtensions.push(StreamLanguage.define(powerShell));
4242
break;
4343
case "csharp":
44-
extensions.push(StreamLanguage.define(csharp));
44+
allExtensions.push(StreamLanguage.define(csharp));
4545
break;
4646
}
4747
48-
return extensions;
48+
return allExtensions;
4949
});
5050
</script>
5151

5252
<template>
53-
<div class="wrapper" :aria-label="ariaLabel" :class="css">
53+
<div class="wrapper" :aria-label="ariaLabel">
5454
<div v-if="props.showCopyToClipboard || $slots.toolbarLeft || $slots.toolbarRight" class="toolbar">
5555
<div><slot name="toolbarLeft"></slot></div>
5656
<div>

src/Frontend/src/components/messages2/SagaDiagram/SagaUpdateNode.vue

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DiffViewer from "@/components/messages2/DiffViewer.vue";
77
import CodeEditor from "@/components/CodeEditor.vue";
88
import { useSagaDiagramStore } from "@/stores/SagaDiagramStore";
99
import { ref, watch, computed } from "vue";
10+
import { EditorView } from "@codemirror/view";
1011
1112
// Import the images directly
1213
import CommandIcon from "@/assets/command.svg";
@@ -16,6 +17,23 @@ import TimeoutIcon from "@/assets/timeout.svg";
1617
import EventIcon from "@/assets/event.svg";
1718
import SagaTimeoutIcon from "@/assets/SagaTimeoutIcon.svg";
1819
20+
// Define the monospace theme for CodeEditor
21+
const monospaceTheme = EditorView.baseTheme({
22+
"&": {
23+
fontFamily: "monospace",
24+
fontSize: "0.75rem",
25+
backgroundColor: "#f2f2f2",
26+
},
27+
".cm-editor": {
28+
fontFamily: "monospace",
29+
fontSize: "0.75rem",
30+
backgroundColor: "#f2f2f2",
31+
},
32+
".cm-scroller": {
33+
backgroundColor: "#f2f2f2",
34+
},
35+
});
36+
1937
// Define types for JSON values and properties
2038
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
2139
interface JsonObject {
@@ -181,7 +199,7 @@ const hasStateChanges = computed(() => {
181199

182200
<!-- Initial state display -->
183201
<div v-else-if="update.IsFirstNode" class="json-container">
184-
<CodeEditor css="monospace-code" :model-value="sagaUpdateStateChanges.formattedState || ''" language="json" :showCopyToClipboard="false" :showGutter="false" />
202+
<CodeEditor :model-value="sagaUpdateStateChanges.formattedState || ''" language="json" :showCopyToClipboard="false" :showGutter="false" :extensions="[monospaceTheme]" />
185203
</div>
186204

187205
<!-- No changes message -->
@@ -408,6 +426,14 @@ const hasStateChanges = computed(() => {
408426
background-color: transparent;
409427
}
410428
429+
/* Override CodeEditor wrapper styles */
430+
.json-container :deep(.wrapper) {
431+
border-radius: 0;
432+
border: none;
433+
background-color: #f2f2f2;
434+
margin-top: 0;
435+
}
436+
411437
.no-changes-message {
412438
padding: 1rem;
413439
text-align: center;
@@ -422,23 +448,6 @@ const hasStateChanges = computed(() => {
422448
color: #a94442;
423449
}
424450
425-
/* Monospace font styling that matches DiffViewer */
426-
:deep(.monospace-code) {
427-
border-radius: 0;
428-
border: none;
429-
background-color: #f2f2f2;
430-
}
431-
432-
:deep(.monospace-code) .cm-editor {
433-
font-family: monospace;
434-
font-size: 0.75rem;
435-
background-color: #f2f2f2;
436-
}
437-
438-
:deep(.monospace-code) .cm-scroller {
439-
background-color: #f2f2f2;
440-
}
441-
442451
@-webkit-keyframes blink-border {
443452
0%,
444453
100% {

0 commit comments

Comments
 (0)