@wandelbots/wandelbots-js-react-components 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandelbots/wandelbots-js-react-components",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "React UI toolkit for building applications on top of the Wandelbots platform",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -66,7 +66,7 @@ export const JoggingCartesianTab = observer(
66
66
  store.selectedDiscreteIncrement ? "increment" : "cartesian",
67
67
  {
68
68
  tcpId: store.selectedTcpId,
69
- coordSystemId: store.selectedCoordSystemId,
69
+ coordSystemId: store.activeCoordSystemId,
70
70
  },
71
71
  )
72
72
  }
@@ -90,7 +90,7 @@ export const JoggingCartesianTab = observer(
90
90
  await store.jogger.runIncrementalCartesianMotion({
91
91
  currentTcpPose: tcpPose,
92
92
  currentJoints: jointPosition,
93
- coordSystemId: store.selectedCoordSystemId,
93
+ coordSystemId: store.activeCoordSystemId,
94
94
  velocityInRelevantUnits: store.velocityInCurrentUnits,
95
95
  axis: opts.axis,
96
96
  direction: opts.direction,
@@ -1,13 +1,13 @@
1
- import Editor, { useMonaco, type Monaco } from "@monaco-editor/react"
2
- import { useEffect, useRef, useState } from "react"
1
+ import type { Monaco } from "@monaco-editor/react"
2
+ import { lazy, Suspense, useRef, useState } from "react"
3
3
  import type { BundledLanguage, HighlighterGeneric } from "shiki"
4
- import { createHighlighter, type BundledTheme } from "shiki"
5
- import { shikiToMonaco } from "@shikijs/monaco"
4
+ import type { BundledTheme } from "shiki"
6
5
 
7
6
  import wandelscriptTextmateGrammar from "./wandelscript.tmLanguage"
8
7
  import { useTheme } from "@mui/material"
9
8
  import type { editor } from "monaco-editor"
10
9
  import { externalizeComponent } from "../../externalizeComponent"
10
+ import { LoadingCover } from "../LoadingCover"
11
11
 
12
12
  type WandelscriptEditorProps = {
13
13
  /** The current Wandelscript content of the code editor (controlled component) */
@@ -26,20 +26,24 @@ type WandelscriptEditorProps = {
26
26
  /** A Monaco (VSCode-style) embedded code editor with Wandelscript syntax highlighting */
27
27
  export const WandelscriptEditor = externalizeComponent(
28
28
  (props: WandelscriptEditorProps) => {
29
- const monaco = useMonaco()
30
29
  const theme = useTheme()
31
30
  const shikiHighlighterRef = useRef<HighlighterGeneric<
32
31
  BundledLanguage,
33
32
  BundledTheme
34
33
  > | null>(null)
35
-
36
34
  const [activeShikiTheme, setActiveShikiTheme] =
37
35
  useState<BundledTheme>("dark-plus")
38
-
39
36
  const targetShikiTheme =
40
37
  theme.palette.mode === "dark" ? "dark-plus" : "light-plus"
41
38
 
39
+ const Editor = lazy(() => import("@monaco-editor/react"))
40
+
42
41
  async function setupEditor(monaco: Monaco) {
42
+ const [{ createHighlighter }, { shikiToMonaco }] = await Promise.all([
43
+ import("shiki"),
44
+ import("@shikijs/monaco"),
45
+ ])
46
+
43
47
  // Register and configure the Wandelscript language
44
48
  monaco.languages.register({ id: "wandelscript" })
45
49
 
@@ -99,29 +103,24 @@ export const WandelscriptEditor = externalizeComponent(
99
103
  setActiveShikiTheme(targetShikiTheme)
100
104
  }
101
105
 
102
- useEffect(() => {
103
- if (monaco) {
104
- setupEditor(monaco)
105
- }
106
- }, [monaco, targetShikiTheme])
107
-
108
- if (!monaco) {
109
- return null
110
- }
111
-
112
106
  return (
113
- <Editor
114
- value={props.code}
115
- onChange={props.onChange}
116
- defaultLanguage="wandelscript"
117
- theme={activeShikiTheme}
118
- options={{
119
- minimap: { enabled: false },
120
- wordWrap: "on",
121
- automaticLayout: true,
122
- ...props.monacoOptions,
123
- }}
124
- />
107
+ <Suspense fallback={<LoadingCover />}>
108
+ <Editor
109
+ value={props.code}
110
+ onMount={(_editor, monaco) => {
111
+ setupEditor(monaco)
112
+ }}
113
+ onChange={props.onChange}
114
+ defaultLanguage="wandelscript"
115
+ theme={activeShikiTheme}
116
+ options={{
117
+ minimap: { enabled: false },
118
+ wordWrap: "on",
119
+ automaticLayout: true,
120
+ ...props.monacoOptions,
121
+ }}
122
+ />
123
+ </Suspense>
125
124
  )
126
125
  },
127
126
  )