Skip to content

Commit 46561dd

Browse files
committed
New version
1 parent d0ba0b0 commit 46561dd

File tree

5 files changed

+62
-38
lines changed

5 files changed

+62
-38
lines changed

package-lock.json

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "jderobot-ide-interface",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"main": "dist/main.js",
55
"typings": "dist/index.d.ts",
66
"files": [
77
"dist"
88
],
99
"scripts": {
10-
"test": "echo \"Error: no test specified\" && exit 1",
10+
"test": "echo \"Error: no test specified\"",
1111
"storybook": "storybook dev -p 6006",
1212
"build-storybook": "storybook build",
1313
"start": "webpack serve --config ./webpack.config.js --mode development",

src/components/FileEditor/TextEditor.tsx

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { useEffect, useRef, useState } from "react";
22
import Editor, { Monaco } from "@monaco-editor/react";
33
import "./FileEditor.css";
4+
import type { editor } from "monaco-editor";
45

56
// import { OptionsContext } from "../../options/Options";
6-
import {CommsManager} from "jderobot-commsmanager";
7+
import { CommsManager } from "jderobot-commsmanager";
78
import { monacoEditorSnippet } from "./extras";
89

910
const pylint_error: string[] = ["E0401", "E1101"];
@@ -166,7 +167,7 @@ const FileEditor = ({
166167
if (commsManager && fileContent) {
167168
commsManager.code_format(fileContent);
168169
}
169-
},
170+
}
170171
);
171172

172173
return () => {
@@ -176,36 +177,51 @@ const FileEditor = ({
176177
};
177178
};
178179

180+
const lineNumbers: editor.LineNumbersType = "on";
181+
const scrollbar: editor.IEditorScrollbarOptions = {
182+
vertical: "auto",
183+
horizontal: "auto",
184+
verticalScrollbarSize: 8,
185+
horizontalScrollbarSize: 8,
186+
};
187+
const hover: editor.IEditorHoverOptions = {
188+
enabled: true,
189+
};
190+
const wordWrap: "on" | "off" | "wordWrapColumn" | "bounded" | undefined =
191+
"wordWrapColumn";
192+
const wrappingIndent: "indent" | "none" | "same" | "deepIndent" | undefined =
193+
"indent";
194+
const wordBasedSuggestions:
195+
| "off"
196+
| "currentDocument"
197+
| "matchingDocuments"
198+
| "allDocuments" = "currentDocument";
199+
179200
const editorOptions = {
180201
//
181202
fontSize: fontSize,
182-
lineNumbers: 'on',
203+
lineNumbers: lineNumbers,
183204
roundedSelection: false,
184205
scrollBeyondLastLine: true,
185206
// word warp
186-
wordWrap: "wordWrapColumn",
207+
wordWrap: wordWrap,
187208
wordWrapColumn: 80,
188-
wrappingIndent: "indent",
209+
wrappingIndent: wrappingIndent,
189210
//
190211
minimap: { enabled: false },
191212
automaticLayout: true,
192213
tabSize: 4,
193214
rulers: [80],
194215
suggestOnTriggerCharacters: true,
195216
quickSuggestions: true,
196-
wordBasedSuggestions: true,
217+
wordBasedSuggestions: wordBasedSuggestions,
197218
//
198-
hover: true,
219+
hover: hover,
199220
glyphMargin: true,
200221
lineNumbersMinChars: 3,
201222
// scroll
202223
smoothScrolling: true,
203-
scrollbar: {
204-
vertical: "auto",
205-
horizontal: "auto",
206-
verticalScrollbarSize: 8,
207-
horizontalScrollbarSize: 8,
208-
},
224+
scrollbar: scrollbar,
209225
};
210226

211227
useEffect(() => {
@@ -233,7 +249,7 @@ const FileEditor = ({
233249
if (commsManager && fileContent) {
234250
commsManager.code_format(fileContent);
235251
}
236-
},
252+
}
237253
);
238254

239255
if (language !== "python") return;
@@ -261,7 +277,6 @@ const FileEditor = ({
261277
onChange={(newContent: any) => {
262278
setFileContent(newContent);
263279
}}
264-
// @ts-ignore
265280
options={editorOptions}
266281
beforeMount={handleEditorDidMount}
267282
onMount={handleEditorMount}

src/components/FileEditor/extras.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Monaco } from "@monaco-editor/react";
22
import { my_snippets, Snippet } from "./snippets";
33
import {CommsManager} from "jderobot-commsmanager";
4-
import { ignoreSsrWarning } from "storybook/internal/theming";
4+
import type { languages } from 'monaco-editor';
55

66
interface Position {
77
lineNumber: number;
@@ -37,8 +37,7 @@ export const monacoEditorSnippet = (monaco: Monaco, manager: CommsManager| null)
3737
// Register a completion item provider for the new language
3838
monaco.languages.registerCompletionItemProvider("python", {
3939
triggerCharacters: [".", "("],
40-
// @ts-ignore
41-
provideCompletionItems: async (model: any, position: Position) => {
40+
provideCompletionItems: async (model: any, position: Position): Promise<languages.CompletionList> => {
4241
lock = true;
4342

4443
var word = model.getWordUntilPosition(position);
@@ -64,7 +63,7 @@ export const monacoEditorSnippet = (monaco: Monaco, manager: CommsManager| null)
6463
// Check if the Robotics Backend is connected
6564
// Call the RAM for autocompletion
6665
if (manager === null) {
67-
return snippets;
66+
return { suggestions: snippets };
6867
}
6968

7069
try {
@@ -74,7 +73,7 @@ export const monacoEditorSnippet = (monaco: Monaco, manager: CommsManager| null)
7473
word.endColumn - 1
7574
);
7675
} catch (error) {
77-
return snippets;
76+
return { suggestions: snippets };
7877
}
7978

8079
const callback = (message: any) => {

webpack.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module.exports = {
2121
output: {
2222
filename: "main.js",
2323
path: path.resolve(__dirname, "dist"),
24+
libraryTarget: 'umd',
25+
globalObject: 'this',
2426
},
2527
resolve: {
2628
alias: aliases(),

0 commit comments

Comments
 (0)