Skip to content

Commit

Permalink
Removed unused code and replace inline css with class
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Mar 25, 2024
1 parent dcad4fc commit 29fe9aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
43 changes: 2 additions & 41 deletions kraken_frontend/src/components/model-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,6 @@ export default function ModelEditor(props: ModelEditorProps) {
return () => (editorRef.current ? editorRef.current.dispose() : cancelable.cancel());
}, []);

/*
useUpdate(
() => {
if (!editorRef.current || value === undefined) return;
if (editorRef.current.getOption(monacoRef.current!.editor.EditorOption.readOnly)) {
editorRef.current.setValue(value);
} else if (value !== editorRef.current.getValue()) {
preventTriggerChangeEvent.current = true;
editorRef.current.executeEdits("", [
{
range: editorRef.current.getModel()!.getFullModelRange(),
text: value,
forceMoveMarkers: true,
},
]);
editorRef.current.pushUndoStop();
preventTriggerChangeEvent.current = false;
}
},
[value],
isEditorReady,
);
*/

React.useEffect(() => {
if (!containerRef.current || !monacoRef.current) return;
if (!editorRef.current) {
Expand All @@ -73,26 +48,12 @@ export default function ModelEditor(props: ModelEditorProps) {
}
}, [model]);

/*
// onChange
useEffect(() => {
if (isEditorReady && onChange) {
subscriptionRef.current?.dispose();
subscriptionRef.current = editorRef.current?.onDidChangeModelContent((event) => {
if (!preventTriggerChangeEvent.current) {
onChange(editorRef.current!.getValue(), event);
}
});
}
}, [isEditorReady, onChange]);
*/

return (
<section style={{ display: "flex", position: "relative", textAlign: "initial", width: "100%", height: "100%" }}>
<section className={"model-editor"}>
{(!isEditorReady || model === null) && <Loading />}
<div
ref={containerRef}
style={{ width: "100%", display: !isEditorReady || model === null ? "none" : undefined }}
style={{ display: !isEditorReady || model === null ? "none" : undefined }}
className={"knowledge-base-editor"}
/>
</section>
Expand Down
12 changes: 12 additions & 0 deletions kraken_frontend/src/styling/components.css
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,15 @@ form:invalid .start-attack path:last-of-type {
.dropdown {
z-index: 10;
}

.model-editor {
display: flex;
position: relative;
text-align: initial;
width: 100%;
height: 100%;
}

.model-editor > div {
width: 100%;
}

0 comments on commit 29fe9aa

Please sign in to comment.