|
1 | 1 | import { Editor, Monaco, OnChange } from "@monaco-editor/react"; |
2 | | -import { editor, KeyCode, KeyMod, languages, Range } from "monaco-editor"; |
| 2 | +import { editor, KeyCode, KeyMod } from "monaco-editor"; |
3 | 3 | import { RefObject, useImperativeHandle, useRef, useState } from "react"; |
4 | 4 | import { Button } from "@itwin/itwinui-react/bricks"; |
5 | 5 |
|
@@ -84,8 +84,6 @@ function SandcastleEditor({ |
84 | 84 | allowNonTsExtensions: true, |
85 | 85 | }); |
86 | 86 |
|
87 | | - setSnippets(monaco); |
88 | | - |
89 | 87 | setTypes(monaco); |
90 | 88 | } |
91 | 89 |
|
@@ -114,80 +112,6 @@ function SandcastleEditor({ |
114 | 112 | ); |
115 | 113 | } |
116 | 114 |
|
117 | | - function createDependencyProposals(range: Range) { |
118 | | - // returning a static list of proposals, not even looking at the prefix (filtering is done by the Monaco editor), |
119 | | - // here you could do a server side lookup |
120 | | - return [ |
121 | | - { |
122 | | - label: "scbutton", |
123 | | - kind: languages.CompletionItemKind.Function, |
124 | | - documentation: "Create a Sancastle button", |
125 | | - insertText: `Sandcastle.addToolbarButton(\${1:"New Button"}, function () { |
126 | | - \${0:// your code here} |
127 | | - });`, |
128 | | - insertTextRules: languages.CompletionItemInsertTextRule.InsertAsSnippet, |
129 | | - range: range, |
130 | | - }, |
131 | | - { |
132 | | - label: "sctoggle", |
133 | | - kind: languages.CompletionItemKind.Function, |
134 | | - documentation: "Create a Sancastle toggle button", |
135 | | - insertText: `let \${2:toggleValue} = \${3:true}; |
136 | | - Sandcastle.addToggleButton(\${1:"Toggle"}, \${2:toggleValue}, function (checked) { |
137 | | - \${2:toggleValue} = checked;$0 |
138 | | - });`, |
139 | | - insertTextRules: languages.CompletionItemInsertTextRule.InsertAsSnippet, |
140 | | - range: range, |
141 | | - }, |
142 | | - { |
143 | | - label: "scmenu", |
144 | | - kind: languages.CompletionItemKind.Function, |
145 | | - documentation: "Create a Sancastle select menu", |
146 | | - insertText: `const \${1:options} = [ |
147 | | - { |
148 | | - text: \${2:"Option 1"}, |
149 | | - onselect: function () { |
150 | | - \${0:// your code here, the first option is always run at load} |
151 | | - }, |
152 | | - }, |
153 | | - ]; |
154 | | - Sandcastle.addToolbarMenu(\${1:options});`, |
155 | | - insertTextRules: languages.CompletionItemInsertTextRule.InsertAsSnippet, |
156 | | - range: range, |
157 | | - }, |
158 | | - { |
159 | | - label: "scmenuitem", |
160 | | - kind: languages.CompletionItemKind.Function, |
161 | | - documentation: "Create a Sancastle select menu item", |
162 | | - insertText: `{ |
163 | | - text: \${1:"New Option"}, |
164 | | - onselect: function () { |
165 | | - \${0:// your code here, the first option is always run at load} |
166 | | - }, |
167 | | - },`, |
168 | | - insertTextRules: languages.CompletionItemInsertTextRule.InsertAsSnippet, |
169 | | - range: range, |
170 | | - }, |
171 | | - ]; |
172 | | - } |
173 | | - |
174 | | - function setSnippets(monaco: Monaco) { |
175 | | - monaco.languages.registerCompletionItemProvider("javascript", { |
176 | | - provideCompletionItems(model, position) { |
177 | | - const word = model.getWordUntilPosition(position); |
178 | | - const range = new Range( |
179 | | - position.lineNumber, |
180 | | - word.startColumn, |
181 | | - position.lineNumber, |
182 | | - word.endColumn, |
183 | | - ); |
184 | | - return { |
185 | | - suggestions: createDependencyProposals(range), |
186 | | - }; |
187 | | - }, |
188 | | - }); |
189 | | - } |
190 | | - |
191 | 115 | return ( |
192 | 116 | <div className="editor-container"> |
193 | 117 | <div className="tabs"> |
|
0 commit comments