@elice/material-exercise 1.220919.0 → 1.221026.0
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/cjs/components/material-exercise/exercise-room/ExerciseRoomDetail.js +5 -5
- package/cjs/components/shared/monaco-editor/utils/emmet/abbreviationActions.d.ts +6 -0
- package/cjs/components/shared/monaco-editor/utils/emmet/abbreviationActions.js +65 -0
- package/cjs/components/shared/monaco-editor/utils/emmet/emmet.d.ts +4 -4
- package/cjs/components/shared/monaco-editor/utils/emmet/emmet.js +6 -6
- package/cjs/components/shared/monaco-editor/utils/emmet/registerProvider.d.ts +2 -2
- package/cjs/components/shared/monaco-editor/utils/emmet/registerProvider.js +5 -4
- package/cjs/components/shared/monaco-editor/vendors/vscode-emmet-helper/emmetHelper.d.ts +7 -11
- package/cjs/components/shared/monaco-editor/vendors/vscode-emmet-helper/emmetHelper.js +13 -17
- package/cjs/components/shared/monaco-editor/vendors/vscode-emmet-helper/utils.d.ts +9 -4
- package/cjs/components/shared/monaco-editor/vendors/vscode-emmet-helper/utils.js +13 -7
- package/es/components/material-exercise/exercise-room/ExerciseRoomDetail.js +5 -5
- package/es/components/shared/monaco-editor/utils/emmet/abbreviationActions.d.ts +6 -0
- package/es/components/shared/monaco-editor/utils/emmet/abbreviationActions.js +61 -0
- package/es/components/shared/monaco-editor/utils/emmet/emmet.d.ts +4 -4
- package/es/components/shared/monaco-editor/utils/emmet/emmet.js +6 -6
- package/es/components/shared/monaco-editor/utils/emmet/registerProvider.d.ts +2 -2
- package/es/components/shared/monaco-editor/utils/emmet/registerProvider.js +5 -4
- package/es/components/shared/monaco-editor/vendors/vscode-emmet-helper/emmetHelper.d.ts +7 -11
- package/es/components/shared/monaco-editor/vendors/vscode-emmet-helper/emmetHelper.js +13 -17
- package/es/components/shared/monaco-editor/vendors/vscode-emmet-helper/utils.d.ts +9 -4
- package/es/components/shared/monaco-editor/vendors/vscode-emmet-helper/utils.js +13 -7
- package/package.json +8 -8
|
@@ -34,7 +34,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
34
34
|
goToList,
|
|
35
35
|
onHide
|
|
36
36
|
}) => {
|
|
37
|
-
var _a, _b, _c, _d, _e;
|
|
37
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
38
|
|
|
39
39
|
const intl = reactIntl.useIntl();
|
|
40
40
|
const {
|
|
@@ -52,7 +52,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
52
52
|
const [isLeaveDialogOpen, setIsLeaveDialogOpen] = React__default["default"].useState(false);
|
|
53
53
|
const [isDeleting, setIsDeleting] = React__default["default"].useState(false);
|
|
54
54
|
const isThisChatRoomOwner = (_b = ((_a = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.roomUsers.find(roomUser => roomUser.user.id === (user === null || user === void 0 ? void 0 : user.id))) === null || _a === void 0 ? void 0 : _a.permission) === types.enums.ExerciseRoomPermission.Owner) !== null && _b !== void 0 ? _b : false;
|
|
55
|
-
const shareLink = materialExercise ? `https://${window.location.host}/courses/${materialExercise.courseId}/lectures/${materialExercise.lectureId}/materials/${materialExercise.mainOrderNo}/projects/${selectedExerciseRoomId}` : '';
|
|
55
|
+
const shareLink = materialExercise ? `https://${window.location.host}/courses/${materialExercise.courseId}/lectures/${materialExercise.lectureId}/materials/${(_c = materialExercise === null || materialExercise === void 0 ? void 0 : materialExercise.mainOrderNo) !== null && _c !== void 0 ? _c : 0}/projects/${selectedExerciseRoomId}` : '';
|
|
56
56
|
const [, copyToClipboard] = reactUse.useCopyToClipboard();
|
|
57
57
|
const doGetOrgMaterialExerciseExerciseRoomGet = React__default["default"].useCallback(() => {
|
|
58
58
|
return apiClient.getOrgMaterialExerciseExerciseRoomGet({
|
|
@@ -174,7 +174,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
174
174
|
return React__default["default"].createElement(StyledModal, {
|
|
175
175
|
theme: "dark",
|
|
176
176
|
onHide: onHide,
|
|
177
|
-
title: (
|
|
177
|
+
title: (_d = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.title) !== null && _d !== void 0 ? _d : '',
|
|
178
178
|
headerIcon: icons.eilArrowLeftwardsSingle,
|
|
179
179
|
onHeaderIconClick: goToList,
|
|
180
180
|
footerChild: exerciseRoom ? exerciseRoom.isDefaultRoom ? React__default["default"].createElement(blocks.Flex, {
|
|
@@ -217,7 +217,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
217
217
|
label: intl.formatMessage({
|
|
218
218
|
id: 'materialExerciseExerciseRoom.leave'
|
|
219
219
|
}),
|
|
220
|
-
disabled: (
|
|
220
|
+
disabled: (_e = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.isDefaultRoom) !== null && _e !== void 0 ? _e : false,
|
|
221
221
|
role: 'gray6',
|
|
222
222
|
onClick: () => {
|
|
223
223
|
setIsLeaveDialogOpen(true);
|
|
@@ -449,7 +449,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
449
449
|
}), isThisChatRoomOwner ? React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(blocks.Select, {
|
|
450
450
|
size: "small",
|
|
451
451
|
width: "small",
|
|
452
|
-
value: (
|
|
452
|
+
value: (_f = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.publicPermission) !== null && _f !== void 0 ? _f : types.enums.ExerciseRoomPermission.Nothing,
|
|
453
453
|
onChange: value => {
|
|
454
454
|
doPostOrgMaterialExerciseExerciseRoomEdit(value);
|
|
455
455
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
+
/**
|
|
3
|
+
* VSCode did a complex node analysis, just use monaco's built-in tokenizer here.
|
|
4
|
+
* @see https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/abbreviationActions.ts#L438
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidLocationForEmmetAbbreviation(model: monaco.editor.ITextModel, position: monaco.Position, syntax: string, language: string): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Validate if the given position is valid for emmet abbreviation.
|
|
7
|
+
*/
|
|
8
|
+
function isValidEmmetToken(tokens, index, syntax, language) {
|
|
9
|
+
const currentTokenType = tokens[index].type;
|
|
10
|
+
|
|
11
|
+
switch (syntax) {
|
|
12
|
+
case 'html':
|
|
13
|
+
return currentTokenType === 'text.html.basic';
|
|
14
|
+
|
|
15
|
+
case 'css':
|
|
16
|
+
return true;
|
|
17
|
+
|
|
18
|
+
case 'jsx':
|
|
19
|
+
return !currentTokenType.endsWith('.type.tsx');
|
|
20
|
+
|
|
21
|
+
default:
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* VSCode did a complex node analysis, just use monaco's built-in tokenizer here.
|
|
27
|
+
* @see https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/abbreviationActions.ts#L438
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
function isValidLocationForEmmetAbbreviation(model, position, syntax, language) {
|
|
32
|
+
const {
|
|
33
|
+
column,
|
|
34
|
+
lineNumber
|
|
35
|
+
} = position; // get current line's tokens
|
|
36
|
+
|
|
37
|
+
const _tokenization = // monaco-editor < 0.34.0
|
|
38
|
+
model._tokenization || // monaco-editor >= 0.34.0
|
|
39
|
+
model.tokenization._tokenization;
|
|
40
|
+
|
|
41
|
+
const _tokenizationStateStore = _tokenization._tokenizationStateStore;
|
|
42
|
+
|
|
43
|
+
const _tokenizationSupport = // monaco-editor >= 0.32.0
|
|
44
|
+
_tokenizationStateStore.tokenizationSupport || // monaco-editor < 0.32.0
|
|
45
|
+
_tokenization._tokenizationSupport;
|
|
46
|
+
|
|
47
|
+
const state = _tokenizationStateStore.getBeginState(lineNumber - 1).clone();
|
|
48
|
+
|
|
49
|
+
const tokenizationResult = _tokenizationSupport.tokenize(model.getLineContent(lineNumber), true, state, 0);
|
|
50
|
+
|
|
51
|
+
const tokens = tokenizationResult.tokens; // get token type at current column
|
|
52
|
+
|
|
53
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
54
|
+
if (column - 1 > tokens[i].offset) {
|
|
55
|
+
// return true if current token is valid for emmet
|
|
56
|
+
if (isValidEmmetToken(tokens, i, syntax)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
exports.isValidLocationForEmmetAbbreviation = isValidLocationForEmmetAbbreviation;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
/**
|
|
3
3
|
* Enable emmet feature for HTML.
|
|
4
4
|
*/
|
|
5
|
-
export declare function emmetHTML(
|
|
5
|
+
export declare function emmetHTML(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* Enable emmet feature for CSS.
|
|
8
8
|
*/
|
|
9
|
-
export declare function emmetCSS(
|
|
9
|
+
export declare function emmetCSS(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Enable emmet feature for JSX.
|
|
12
12
|
*/
|
|
13
|
-
export declare function emmetJSX(
|
|
13
|
+
export declare function emmetJSX(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
@@ -8,22 +8,22 @@ var registerProvider = require('./registerProvider.js');
|
|
|
8
8
|
* Enable emmet feature for HTML.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
function emmetHTML(
|
|
12
|
-
return registerProvider.registerProvider(
|
|
11
|
+
function emmetHTML(_monaco, languages) {
|
|
12
|
+
return registerProvider.registerProvider(_monaco, languages, 'html');
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Enable emmet feature for CSS.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
function emmetCSS(
|
|
19
|
-
return registerProvider.registerProvider(
|
|
18
|
+
function emmetCSS(_monaco, languages) {
|
|
19
|
+
return registerProvider.registerProvider(_monaco, languages, 'css');
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Enable emmet feature for JSX.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
function emmetJSX(
|
|
26
|
-
return registerProvider.registerProvider(
|
|
25
|
+
function emmetJSX(_monaco, languages) {
|
|
26
|
+
return registerProvider.registerProvider(_monaco, languages, 'jsx');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
exports.emmetCSS = emmetCSS;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
/**
|
|
3
3
|
* Register completion provider of emmet.
|
|
4
4
|
*/
|
|
5
|
-
export declare function registerProvider(
|
|
5
|
+
export declare function registerProvider(_monaco: typeof monaco, languages: string[], syntax: string): (() => void) | undefined;
|
|
@@ -4,19 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var emmetHelper = require('../../vendors/vscode-emmet-helper/emmetHelper.js');
|
|
6
6
|
var utils = require('../../vendors/vscode-emmet-helper/utils.js');
|
|
7
|
+
var abbreviationActions = require('./abbreviationActions.js');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Register completion provider of emmet.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
|
-
function registerProvider(
|
|
13
|
-
if (!
|
|
13
|
+
function registerProvider(_monaco, languages, syntax) {
|
|
14
|
+
if (!_monaco) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const providers = languages.map(language =>
|
|
18
|
+
const providers = languages.map(language => _monaco.languages.registerCompletionItemProvider(language, {
|
|
18
19
|
triggerCharacters: utils.LANGUAGE_MODES[utils.MAPPED_MODES[language] || language],
|
|
19
|
-
provideCompletionItems: (model, position) => emmetHelper.doComplete(
|
|
20
|
+
provideCompletionItems: (model, position) => abbreviationActions.isValidLocationForEmmetAbbreviation(model, position, syntax) ? emmetHelper.doComplete(_monaco, model, position, syntax, utils.DEFAULT_CONFIG) : undefined
|
|
20
21
|
}));
|
|
21
22
|
return () => {
|
|
22
23
|
providers.forEach(provider => provider.dispose());
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
import type { ExtractOptions, MarkupAbbreviation, Options, StylesheetAbbreviation, SyntaxType, UserConfig } from 'emmet';
|
|
3
3
|
import type { SnippetsMap } from './configCompat';
|
|
4
|
-
declare type TextModel =
|
|
5
|
-
declare type CompletionList =
|
|
6
|
-
declare type Position =
|
|
7
|
-
declare type Range =
|
|
4
|
+
declare type TextModel = monaco.editor.ITextModel;
|
|
5
|
+
declare type CompletionList = monaco.languages.CompletionList;
|
|
6
|
+
declare type Position = monaco.IPosition;
|
|
7
|
+
declare type Range = monaco.IRange;
|
|
8
8
|
/**
|
|
9
9
|
* Emmet configuration as derived from the Emmet related VS Code settings
|
|
10
10
|
*/
|
|
@@ -19,12 +19,8 @@ export interface VSCodeEmmetConfig {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
|
|
22
|
-
* @param document TextDocument in which completions are requested
|
|
23
|
-
* @param position Position in the document at which completions are requested
|
|
24
|
-
* @param syntax Emmet supported language
|
|
25
|
-
* @param emmetConfig Emmet Configurations as derived from VS Code
|
|
26
22
|
*/
|
|
27
|
-
export declare function doComplete(
|
|
23
|
+
export declare function doComplete(_monaco: typeof monaco, model: TextModel, position: Position, syntax: string, emmetConfig: VSCodeEmmetConfig): CompletionList | undefined;
|
|
28
24
|
export declare const emmetSnippetField: (index: number, placeholder: string) => string;
|
|
29
25
|
/** Returns whether or not syntax is a supported stylesheet syntax, like CSS */
|
|
30
26
|
export declare function isStyleSheet(syntax: string): boolean;
|
|
@@ -37,7 +33,7 @@ export declare function getDefaultSnippets(syntax: string): SnippetsMap;
|
|
|
37
33
|
/**
|
|
38
34
|
* Extracts abbreviation from the given position in the given document
|
|
39
35
|
*/
|
|
40
|
-
export declare function extractAbbreviation(
|
|
36
|
+
export declare function extractAbbreviation(_monaco: typeof monaco, model: TextModel, position: Position, options?: Partial<ExtractOptions>): {
|
|
41
37
|
abbreviation: string;
|
|
42
38
|
abbreviationRange: Range;
|
|
43
39
|
filter: string | undefined;
|
|
@@ -37,13 +37,9 @@ const commentFilterSuffix = 'c';
|
|
|
37
37
|
const maxFilters = 3;
|
|
38
38
|
/**
|
|
39
39
|
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
|
|
40
|
-
* @param document TextDocument in which completions are requested
|
|
41
|
-
* @param position Position in the document at which completions are requested
|
|
42
|
-
* @param syntax Emmet supported language
|
|
43
|
-
* @param emmetConfig Emmet Configurations as derived from VS Code
|
|
44
40
|
*/
|
|
45
41
|
|
|
46
|
-
function doComplete(
|
|
42
|
+
function doComplete(_monaco, model, position, syntax, emmetConfig) {
|
|
47
43
|
var _a, _b;
|
|
48
44
|
|
|
49
45
|
if (emmetConfig.showExpandedAbbreviation === 'never' || !getEmmetMode(syntax, emmetConfig.excludeLanguages)) {
|
|
@@ -66,7 +62,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
66
62
|
lookAhead: !isStyleSheetRes,
|
|
67
63
|
type: isStyleSheetRes ? 'stylesheet' : 'markup'
|
|
68
64
|
};
|
|
69
|
-
const extractedValue = extractAbbreviation(
|
|
65
|
+
const extractedValue = extractAbbreviation(_monaco, model, position, extractOptions);
|
|
70
66
|
|
|
71
67
|
if (!extractedValue) {
|
|
72
68
|
return;
|
|
@@ -108,11 +104,11 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
108
104
|
}
|
|
109
105
|
|
|
110
106
|
expandedAbbr = {
|
|
111
|
-
kind:
|
|
107
|
+
kind: _monaco.languages.CompletionItemKind.Property,
|
|
112
108
|
label: abbreviation + (filter ? '|' + filter.replace(',', '|') : ''),
|
|
113
109
|
documentation: replaceTabStopsWithCursors(expandedText),
|
|
114
110
|
detail: 'Emmet abbreviation',
|
|
115
|
-
insertTextRules:
|
|
111
|
+
insertTextRules: _monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
116
112
|
range: abbreviationRange,
|
|
117
113
|
insertText: escapeNonTabStopDollar(addFinalTabStop(expandedText))
|
|
118
114
|
};
|
|
@@ -137,7 +133,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
137
133
|
expandedAbbr.filterText = abbreviation; // Custom snippets should show up in completions if abbreviation is a prefix
|
|
138
134
|
|
|
139
135
|
const stylesheetCustomSnippetsKeys = stylesheetCustomSnippetsKeyCache.has(syntax) ? stylesheetCustomSnippetsKeyCache.get(syntax) : stylesheetCustomSnippetsKeyCache.get('css');
|
|
140
|
-
completionItems = makeSnippetSuggestion(
|
|
136
|
+
completionItems = makeSnippetSuggestion(_monaco, stylesheetCustomSnippetsKeys !== null && stylesheetCustomSnippetsKeys !== void 0 ? stylesheetCustomSnippetsKeys : [], abbreviation, abbreviation, abbreviationRange, expandOptions, 'Emmet Custom Snippet', false);
|
|
141
137
|
|
|
142
138
|
if (!completionItems.find(x => x.insertText === (expandedAbbr === null || expandedAbbr === void 0 ? void 0 : expandedAbbr.insertText))) {
|
|
143
139
|
// Fix for https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
|
|
@@ -160,12 +156,12 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
if (syntax !== 'xml') {
|
|
163
|
-
const commonlyUsedTagSuggestions = makeSnippetSuggestion(
|
|
159
|
+
const commonlyUsedTagSuggestions = makeSnippetSuggestion(_monaco, commonlyUsedTags, tagToFindMoreSuggestionsFor, abbreviation, abbreviationRange, expandOptions, 'Emmet Abbreviation');
|
|
164
160
|
completionItems = completionItems.concat(commonlyUsedTagSuggestions);
|
|
165
161
|
}
|
|
166
162
|
|
|
167
163
|
if (emmetConfig.showAbbreviationSuggestions === true) {
|
|
168
|
-
const abbreviationSuggestions = makeSnippetSuggestion(
|
|
164
|
+
const abbreviationSuggestions = makeSnippetSuggestion(_monaco, markupSnippetKeys.filter(x => !commonlyUsedTags.includes(x)), tagToFindMoreSuggestionsFor, abbreviation, abbreviationRange, expandOptions, 'Emmet Abbreviation'); // Workaround for the main expanded abbr not appearing before the snippet suggestions
|
|
169
165
|
|
|
170
166
|
if (expandedAbbr && abbreviationSuggestions.length > 0 && tagToFindMoreSuggestionsFor !== abbreviation) {
|
|
171
167
|
expandedAbbr.sortText = '0' + expandedAbbr.label;
|
|
@@ -187,7 +183,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
187
183
|
}
|
|
188
184
|
|
|
189
185
|
if (emmetConfig.showSuggestionsAsSnippets === true) {
|
|
190
|
-
completionItems.forEach(x => x.kind =
|
|
186
|
+
completionItems.forEach(x => x.kind = _monaco.languages.CompletionItemKind.Snippet);
|
|
191
187
|
}
|
|
192
188
|
|
|
193
189
|
return completionItems.length ? {
|
|
@@ -199,7 +195,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
199
195
|
* Create & return snippets for snippet keys that start with given prefix
|
|
200
196
|
*/
|
|
201
197
|
|
|
202
|
-
function makeSnippetSuggestion(
|
|
198
|
+
function makeSnippetSuggestion(_monaco, snippetKeys, prefix, abbreviation, abbreviationRange, expandOptions, snippetDetail, skipFullMatch = true) {
|
|
203
199
|
if (!prefix || !snippetKeys) {
|
|
204
200
|
return [];
|
|
205
201
|
}
|
|
@@ -222,11 +218,11 @@ function makeSnippetSuggestion(monaco, snippetKeys, prefix, abbreviation, abbrev
|
|
|
222
218
|
}
|
|
223
219
|
|
|
224
220
|
const item = {
|
|
225
|
-
kind:
|
|
221
|
+
kind: _monaco.languages.CompletionItemKind.Property,
|
|
226
222
|
label: prefix + snippetKey.substr(prefix.length),
|
|
227
223
|
documentation: replaceTabStopsWithCursors(expandedAbbr),
|
|
228
224
|
detail: snippetDetail,
|
|
229
|
-
insertTextRules:
|
|
225
|
+
insertTextRules: _monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
230
226
|
range: abbreviationRange,
|
|
231
227
|
insertText: escapeNonTabStopDollar(addFinalTabStop(expandedAbbr))
|
|
232
228
|
};
|
|
@@ -407,7 +403,7 @@ function getFilters(text, pos) {
|
|
|
407
403
|
*/
|
|
408
404
|
|
|
409
405
|
|
|
410
|
-
function extractAbbreviation(
|
|
406
|
+
function extractAbbreviation(_monaco, model, position, options) {
|
|
411
407
|
const currentLine = model.getLineContent(position.lineNumber);
|
|
412
408
|
const currentLineTillPosition = currentLine.substr(0, position.column - 1);
|
|
413
409
|
const {
|
|
@@ -421,7 +417,7 @@ function extractAbbreviation(monaco, model, position, options) {
|
|
|
421
417
|
return;
|
|
422
418
|
}
|
|
423
419
|
|
|
424
|
-
const rangeToReplace = new
|
|
420
|
+
const rangeToReplace = new _monaco.Range(position.lineNumber, result.location + 1, position.lineNumber, result.location + result.abbreviation.length + lengthOccupiedByFilter + 1);
|
|
425
421
|
return {
|
|
426
422
|
abbreviationRange: rangeToReplace,
|
|
427
423
|
abbreviation: result.abbreviation,
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { VSCodeEmmetConfig } from
|
|
1
|
+
import type { VSCodeEmmetConfig } from './emmetHelper';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Default emmet configuration.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CONFIG: VSCodeEmmetConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Mapping between languages that support Emmet and completion trigger characters.
|
|
8
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L86
|
|
4
9
|
*/
|
|
5
10
|
export declare const LANGUAGE_MODES: {
|
|
6
11
|
[id: string]: string[];
|
|
7
12
|
};
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* Language specific extensions can provide emmet completion support.
|
|
15
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L124
|
|
10
16
|
*/
|
|
11
17
|
export declare const MAPPED_MODES: Record<string, string>;
|
|
12
|
-
export declare const DEFAULT_CONFIG: VSCodeEmmetConfig;
|
|
@@ -5,8 +5,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
/* eslint-disable */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Default emmet configuration.
|
|
9
9
|
*/
|
|
10
|
+
const DEFAULT_CONFIG = {
|
|
11
|
+
showExpandedAbbreviation: 'always',
|
|
12
|
+
showAbbreviationSuggestions: true,
|
|
13
|
+
showSuggestionsAsSnippets: false
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Mapping between languages that support Emmet and completion trigger characters.
|
|
17
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L86
|
|
18
|
+
*/
|
|
19
|
+
|
|
10
20
|
const LANGUAGE_MODES = {
|
|
11
21
|
html: ['!', '.', '}', ':', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
12
22
|
jade: ['!', '.', '}', ':', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
@@ -23,7 +33,8 @@ const LANGUAGE_MODES = {
|
|
|
23
33
|
typescript: ['!', '.', '}', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
|
24
34
|
};
|
|
25
35
|
/**
|
|
26
|
-
*
|
|
36
|
+
* Language specific extensions can provide emmet completion support.
|
|
37
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L124
|
|
27
38
|
*/
|
|
28
39
|
|
|
29
40
|
const MAPPED_MODES = {
|
|
@@ -31,11 +42,6 @@ const MAPPED_MODES = {
|
|
|
31
42
|
php: 'html',
|
|
32
43
|
twig: 'html'
|
|
33
44
|
};
|
|
34
|
-
const DEFAULT_CONFIG = {
|
|
35
|
-
showExpandedAbbreviation: 'always',
|
|
36
|
-
showAbbreviationSuggestions: true,
|
|
37
|
-
showSuggestionsAsSnippets: false
|
|
38
|
-
};
|
|
39
45
|
|
|
40
46
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
41
47
|
exports.LANGUAGE_MODES = LANGUAGE_MODES;
|
|
@@ -26,7 +26,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
26
26
|
goToList,
|
|
27
27
|
onHide
|
|
28
28
|
}) => {
|
|
29
|
-
var _a, _b, _c, _d, _e;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
30
|
|
|
31
31
|
const intl = useIntl();
|
|
32
32
|
const {
|
|
@@ -44,7 +44,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
44
44
|
const [isLeaveDialogOpen, setIsLeaveDialogOpen] = React.useState(false);
|
|
45
45
|
const [isDeleting, setIsDeleting] = React.useState(false);
|
|
46
46
|
const isThisChatRoomOwner = (_b = ((_a = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.roomUsers.find(roomUser => roomUser.user.id === (user === null || user === void 0 ? void 0 : user.id))) === null || _a === void 0 ? void 0 : _a.permission) === enums.ExerciseRoomPermission.Owner) !== null && _b !== void 0 ? _b : false;
|
|
47
|
-
const shareLink = materialExercise ? `https://${window.location.host}/courses/${materialExercise.courseId}/lectures/${materialExercise.lectureId}/materials/${materialExercise.mainOrderNo}/projects/${selectedExerciseRoomId}` : '';
|
|
47
|
+
const shareLink = materialExercise ? `https://${window.location.host}/courses/${materialExercise.courseId}/lectures/${materialExercise.lectureId}/materials/${(_c = materialExercise === null || materialExercise === void 0 ? void 0 : materialExercise.mainOrderNo) !== null && _c !== void 0 ? _c : 0}/projects/${selectedExerciseRoomId}` : '';
|
|
48
48
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
49
49
|
const doGetOrgMaterialExerciseExerciseRoomGet = React.useCallback(() => {
|
|
50
50
|
return getOrgMaterialExerciseExerciseRoomGet({
|
|
@@ -166,7 +166,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
166
166
|
return React.createElement(StyledModal, {
|
|
167
167
|
theme: "dark",
|
|
168
168
|
onHide: onHide,
|
|
169
|
-
title: (
|
|
169
|
+
title: (_d = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.title) !== null && _d !== void 0 ? _d : '',
|
|
170
170
|
headerIcon: eilArrowLeftwardsSingle,
|
|
171
171
|
onHeaderIconClick: goToList,
|
|
172
172
|
footerChild: exerciseRoom ? exerciseRoom.isDefaultRoom ? React.createElement(Flex, {
|
|
@@ -209,7 +209,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
209
209
|
label: intl.formatMessage({
|
|
210
210
|
id: 'materialExerciseExerciseRoom.leave'
|
|
211
211
|
}),
|
|
212
|
-
disabled: (
|
|
212
|
+
disabled: (_e = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.isDefaultRoom) !== null && _e !== void 0 ? _e : false,
|
|
213
213
|
role: 'gray6',
|
|
214
214
|
onClick: () => {
|
|
215
215
|
setIsLeaveDialogOpen(true);
|
|
@@ -441,7 +441,7 @@ const MaterialExerciseExerciseRoomDetail = ({
|
|
|
441
441
|
}), isThisChatRoomOwner ? React.createElement(React.Fragment, null, React.createElement(Select, {
|
|
442
442
|
size: "small",
|
|
443
443
|
width: "small",
|
|
444
|
-
value: (
|
|
444
|
+
value: (_f = exerciseRoom === null || exerciseRoom === void 0 ? void 0 : exerciseRoom.publicPermission) !== null && _f !== void 0 ? _f : enums.ExerciseRoomPermission.Nothing,
|
|
445
445
|
onChange: value => {
|
|
446
446
|
doPostOrgMaterialExerciseExerciseRoomEdit(value);
|
|
447
447
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
|
+
/**
|
|
3
|
+
* VSCode did a complex node analysis, just use monaco's built-in tokenizer here.
|
|
4
|
+
* @see https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/abbreviationActions.ts#L438
|
|
5
|
+
*/
|
|
6
|
+
export declare function isValidLocationForEmmetAbbreviation(model: monaco.editor.ITextModel, position: monaco.Position, syntax: string, language: string): boolean;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate if the given position is valid for emmet abbreviation.
|
|
3
|
+
*/
|
|
4
|
+
function isValidEmmetToken(tokens, index, syntax, language) {
|
|
5
|
+
const currentTokenType = tokens[index].type;
|
|
6
|
+
|
|
7
|
+
switch (syntax) {
|
|
8
|
+
case 'html':
|
|
9
|
+
return currentTokenType === 'text.html.basic';
|
|
10
|
+
|
|
11
|
+
case 'css':
|
|
12
|
+
return true;
|
|
13
|
+
|
|
14
|
+
case 'jsx':
|
|
15
|
+
return !currentTokenType.endsWith('.type.tsx');
|
|
16
|
+
|
|
17
|
+
default:
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* VSCode did a complex node analysis, just use monaco's built-in tokenizer here.
|
|
23
|
+
* @see https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/abbreviationActions.ts#L438
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
function isValidLocationForEmmetAbbreviation(model, position, syntax, language) {
|
|
28
|
+
const {
|
|
29
|
+
column,
|
|
30
|
+
lineNumber
|
|
31
|
+
} = position; // get current line's tokens
|
|
32
|
+
|
|
33
|
+
const _tokenization = // monaco-editor < 0.34.0
|
|
34
|
+
model._tokenization || // monaco-editor >= 0.34.0
|
|
35
|
+
model.tokenization._tokenization;
|
|
36
|
+
|
|
37
|
+
const _tokenizationStateStore = _tokenization._tokenizationStateStore;
|
|
38
|
+
|
|
39
|
+
const _tokenizationSupport = // monaco-editor >= 0.32.0
|
|
40
|
+
_tokenizationStateStore.tokenizationSupport || // monaco-editor < 0.32.0
|
|
41
|
+
_tokenization._tokenizationSupport;
|
|
42
|
+
|
|
43
|
+
const state = _tokenizationStateStore.getBeginState(lineNumber - 1).clone();
|
|
44
|
+
|
|
45
|
+
const tokenizationResult = _tokenizationSupport.tokenize(model.getLineContent(lineNumber), true, state, 0);
|
|
46
|
+
|
|
47
|
+
const tokens = tokenizationResult.tokens; // get token type at current column
|
|
48
|
+
|
|
49
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
50
|
+
if (column - 1 > tokens[i].offset) {
|
|
51
|
+
// return true if current token is valid for emmet
|
|
52
|
+
if (isValidEmmetToken(tokens, i, syntax)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { isValidLocationForEmmetAbbreviation };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
/**
|
|
3
3
|
* Enable emmet feature for HTML.
|
|
4
4
|
*/
|
|
5
|
-
export declare function emmetHTML(
|
|
5
|
+
export declare function emmetHTML(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* Enable emmet feature for CSS.
|
|
8
8
|
*/
|
|
9
|
-
export declare function emmetCSS(
|
|
9
|
+
export declare function emmetCSS(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Enable emmet feature for JSX.
|
|
12
12
|
*/
|
|
13
|
-
export declare function emmetJSX(
|
|
13
|
+
export declare function emmetJSX(_monaco: typeof monaco, languages: string[]): (() => void) | undefined;
|
|
@@ -4,22 +4,22 @@ import { registerProvider } from './registerProvider.js';
|
|
|
4
4
|
* Enable emmet feature for HTML.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
function emmetHTML(
|
|
8
|
-
return registerProvider(
|
|
7
|
+
function emmetHTML(_monaco, languages) {
|
|
8
|
+
return registerProvider(_monaco, languages, 'html');
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Enable emmet feature for CSS.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
function emmetCSS(
|
|
15
|
-
return registerProvider(
|
|
14
|
+
function emmetCSS(_monaco, languages) {
|
|
15
|
+
return registerProvider(_monaco, languages, 'css');
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Enable emmet feature for JSX.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
function emmetJSX(
|
|
22
|
-
return registerProvider(
|
|
21
|
+
function emmetJSX(_monaco, languages) {
|
|
22
|
+
return registerProvider(_monaco, languages, 'jsx');
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export { emmetCSS, emmetHTML, emmetJSX };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
/**
|
|
3
3
|
* Register completion provider of emmet.
|
|
4
4
|
*/
|
|
5
|
-
export declare function registerProvider(
|
|
5
|
+
export declare function registerProvider(_monaco: typeof monaco, languages: string[], syntax: string): (() => void) | undefined;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { doComplete } from '../../vendors/vscode-emmet-helper/emmetHelper.js';
|
|
2
2
|
import { LANGUAGE_MODES, MAPPED_MODES, DEFAULT_CONFIG } from '../../vendors/vscode-emmet-helper/utils.js';
|
|
3
|
+
import { isValidLocationForEmmetAbbreviation } from './abbreviationActions.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Register completion provider of emmet.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
function registerProvider(
|
|
9
|
-
if (!
|
|
9
|
+
function registerProvider(_monaco, languages, syntax) {
|
|
10
|
+
if (!_monaco) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
const providers = languages.map(language =>
|
|
14
|
+
const providers = languages.map(language => _monaco.languages.registerCompletionItemProvider(language, {
|
|
14
15
|
triggerCharacters: LANGUAGE_MODES[MAPPED_MODES[language] || language],
|
|
15
|
-
provideCompletionItems: (model, position) => doComplete(
|
|
16
|
+
provideCompletionItems: (model, position) => isValidLocationForEmmetAbbreviation(model, position, syntax) ? doComplete(_monaco, model, position, syntax, DEFAULT_CONFIG) : undefined
|
|
16
17
|
}));
|
|
17
18
|
return () => {
|
|
18
19
|
providers.forEach(provider => provider.dispose());
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
|
|
2
2
|
import type { ExtractOptions, MarkupAbbreviation, Options, StylesheetAbbreviation, SyntaxType, UserConfig } from 'emmet';
|
|
3
3
|
import type { SnippetsMap } from './configCompat';
|
|
4
|
-
declare type TextModel =
|
|
5
|
-
declare type CompletionList =
|
|
6
|
-
declare type Position =
|
|
7
|
-
declare type Range =
|
|
4
|
+
declare type TextModel = monaco.editor.ITextModel;
|
|
5
|
+
declare type CompletionList = monaco.languages.CompletionList;
|
|
6
|
+
declare type Position = monaco.IPosition;
|
|
7
|
+
declare type Range = monaco.IRange;
|
|
8
8
|
/**
|
|
9
9
|
* Emmet configuration as derived from the Emmet related VS Code settings
|
|
10
10
|
*/
|
|
@@ -19,12 +19,8 @@ export interface VSCodeEmmetConfig {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
|
|
22
|
-
* @param document TextDocument in which completions are requested
|
|
23
|
-
* @param position Position in the document at which completions are requested
|
|
24
|
-
* @param syntax Emmet supported language
|
|
25
|
-
* @param emmetConfig Emmet Configurations as derived from VS Code
|
|
26
22
|
*/
|
|
27
|
-
export declare function doComplete(
|
|
23
|
+
export declare function doComplete(_monaco: typeof monaco, model: TextModel, position: Position, syntax: string, emmetConfig: VSCodeEmmetConfig): CompletionList | undefined;
|
|
28
24
|
export declare const emmetSnippetField: (index: number, placeholder: string) => string;
|
|
29
25
|
/** Returns whether or not syntax is a supported stylesheet syntax, like CSS */
|
|
30
26
|
export declare function isStyleSheet(syntax: string): boolean;
|
|
@@ -37,7 +33,7 @@ export declare function getDefaultSnippets(syntax: string): SnippetsMap;
|
|
|
37
33
|
/**
|
|
38
34
|
* Extracts abbreviation from the given position in the given document
|
|
39
35
|
*/
|
|
40
|
-
export declare function extractAbbreviation(
|
|
36
|
+
export declare function extractAbbreviation(_monaco: typeof monaco, model: TextModel, position: Position, options?: Partial<ExtractOptions>): {
|
|
41
37
|
abbreviation: string;
|
|
42
38
|
abbreviationRange: Range;
|
|
43
39
|
filter: string | undefined;
|
|
@@ -29,13 +29,9 @@ const commentFilterSuffix = 'c';
|
|
|
29
29
|
const maxFilters = 3;
|
|
30
30
|
/**
|
|
31
31
|
* Returns all applicable emmet expansions for abbreviation at given position in a CompletionList
|
|
32
|
-
* @param document TextDocument in which completions are requested
|
|
33
|
-
* @param position Position in the document at which completions are requested
|
|
34
|
-
* @param syntax Emmet supported language
|
|
35
|
-
* @param emmetConfig Emmet Configurations as derived from VS Code
|
|
36
32
|
*/
|
|
37
33
|
|
|
38
|
-
function doComplete(
|
|
34
|
+
function doComplete(_monaco, model, position, syntax, emmetConfig) {
|
|
39
35
|
var _a, _b;
|
|
40
36
|
|
|
41
37
|
if (emmetConfig.showExpandedAbbreviation === 'never' || !getEmmetMode(syntax, emmetConfig.excludeLanguages)) {
|
|
@@ -58,7 +54,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
58
54
|
lookAhead: !isStyleSheetRes,
|
|
59
55
|
type: isStyleSheetRes ? 'stylesheet' : 'markup'
|
|
60
56
|
};
|
|
61
|
-
const extractedValue = extractAbbreviation(
|
|
57
|
+
const extractedValue = extractAbbreviation(_monaco, model, position, extractOptions);
|
|
62
58
|
|
|
63
59
|
if (!extractedValue) {
|
|
64
60
|
return;
|
|
@@ -100,11 +96,11 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
100
96
|
}
|
|
101
97
|
|
|
102
98
|
expandedAbbr = {
|
|
103
|
-
kind:
|
|
99
|
+
kind: _monaco.languages.CompletionItemKind.Property,
|
|
104
100
|
label: abbreviation + (filter ? '|' + filter.replace(',', '|') : ''),
|
|
105
101
|
documentation: replaceTabStopsWithCursors(expandedText),
|
|
106
102
|
detail: 'Emmet abbreviation',
|
|
107
|
-
insertTextRules:
|
|
103
|
+
insertTextRules: _monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
108
104
|
range: abbreviationRange,
|
|
109
105
|
insertText: escapeNonTabStopDollar(addFinalTabStop(expandedText))
|
|
110
106
|
};
|
|
@@ -129,7 +125,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
129
125
|
expandedAbbr.filterText = abbreviation; // Custom snippets should show up in completions if abbreviation is a prefix
|
|
130
126
|
|
|
131
127
|
const stylesheetCustomSnippetsKeys = stylesheetCustomSnippetsKeyCache.has(syntax) ? stylesheetCustomSnippetsKeyCache.get(syntax) : stylesheetCustomSnippetsKeyCache.get('css');
|
|
132
|
-
completionItems = makeSnippetSuggestion(
|
|
128
|
+
completionItems = makeSnippetSuggestion(_monaco, stylesheetCustomSnippetsKeys !== null && stylesheetCustomSnippetsKeys !== void 0 ? stylesheetCustomSnippetsKeys : [], abbreviation, abbreviation, abbreviationRange, expandOptions, 'Emmet Custom Snippet', false);
|
|
133
129
|
|
|
134
130
|
if (!completionItems.find(x => x.insertText === (expandedAbbr === null || expandedAbbr === void 0 ? void 0 : expandedAbbr.insertText))) {
|
|
135
131
|
// Fix for https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
|
|
@@ -152,12 +148,12 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
if (syntax !== 'xml') {
|
|
155
|
-
const commonlyUsedTagSuggestions = makeSnippetSuggestion(
|
|
151
|
+
const commonlyUsedTagSuggestions = makeSnippetSuggestion(_monaco, commonlyUsedTags, tagToFindMoreSuggestionsFor, abbreviation, abbreviationRange, expandOptions, 'Emmet Abbreviation');
|
|
156
152
|
completionItems = completionItems.concat(commonlyUsedTagSuggestions);
|
|
157
153
|
}
|
|
158
154
|
|
|
159
155
|
if (emmetConfig.showAbbreviationSuggestions === true) {
|
|
160
|
-
const abbreviationSuggestions = makeSnippetSuggestion(
|
|
156
|
+
const abbreviationSuggestions = makeSnippetSuggestion(_monaco, markupSnippetKeys.filter(x => !commonlyUsedTags.includes(x)), tagToFindMoreSuggestionsFor, abbreviation, abbreviationRange, expandOptions, 'Emmet Abbreviation'); // Workaround for the main expanded abbr not appearing before the snippet suggestions
|
|
161
157
|
|
|
162
158
|
if (expandedAbbr && abbreviationSuggestions.length > 0 && tagToFindMoreSuggestionsFor !== abbreviation) {
|
|
163
159
|
expandedAbbr.sortText = '0' + expandedAbbr.label;
|
|
@@ -179,7 +175,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
179
175
|
}
|
|
180
176
|
|
|
181
177
|
if (emmetConfig.showSuggestionsAsSnippets === true) {
|
|
182
|
-
completionItems.forEach(x => x.kind =
|
|
178
|
+
completionItems.forEach(x => x.kind = _monaco.languages.CompletionItemKind.Snippet);
|
|
183
179
|
}
|
|
184
180
|
|
|
185
181
|
return completionItems.length ? {
|
|
@@ -191,7 +187,7 @@ function doComplete(monaco, model, position, syntax, emmetConfig) {
|
|
|
191
187
|
* Create & return snippets for snippet keys that start with given prefix
|
|
192
188
|
*/
|
|
193
189
|
|
|
194
|
-
function makeSnippetSuggestion(
|
|
190
|
+
function makeSnippetSuggestion(_monaco, snippetKeys, prefix, abbreviation, abbreviationRange, expandOptions, snippetDetail, skipFullMatch = true) {
|
|
195
191
|
if (!prefix || !snippetKeys) {
|
|
196
192
|
return [];
|
|
197
193
|
}
|
|
@@ -214,11 +210,11 @@ function makeSnippetSuggestion(monaco, snippetKeys, prefix, abbreviation, abbrev
|
|
|
214
210
|
}
|
|
215
211
|
|
|
216
212
|
const item = {
|
|
217
|
-
kind:
|
|
213
|
+
kind: _monaco.languages.CompletionItemKind.Property,
|
|
218
214
|
label: prefix + snippetKey.substr(prefix.length),
|
|
219
215
|
documentation: replaceTabStopsWithCursors(expandedAbbr),
|
|
220
216
|
detail: snippetDetail,
|
|
221
|
-
insertTextRules:
|
|
217
|
+
insertTextRules: _monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
222
218
|
range: abbreviationRange,
|
|
223
219
|
insertText: escapeNonTabStopDollar(addFinalTabStop(expandedAbbr))
|
|
224
220
|
};
|
|
@@ -399,7 +395,7 @@ function getFilters(text, pos) {
|
|
|
399
395
|
*/
|
|
400
396
|
|
|
401
397
|
|
|
402
|
-
function extractAbbreviation(
|
|
398
|
+
function extractAbbreviation(_monaco, model, position, options) {
|
|
403
399
|
const currentLine = model.getLineContent(position.lineNumber);
|
|
404
400
|
const currentLineTillPosition = currentLine.substr(0, position.column - 1);
|
|
405
401
|
const {
|
|
@@ -413,7 +409,7 @@ function extractAbbreviation(monaco, model, position, options) {
|
|
|
413
409
|
return;
|
|
414
410
|
}
|
|
415
411
|
|
|
416
|
-
const rangeToReplace = new
|
|
412
|
+
const rangeToReplace = new _monaco.Range(position.lineNumber, result.location + 1, position.lineNumber, result.location + result.abbreviation.length + lengthOccupiedByFilter + 1);
|
|
417
413
|
return {
|
|
418
414
|
abbreviationRange: rangeToReplace,
|
|
419
415
|
abbreviation: result.abbreviation,
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { VSCodeEmmetConfig } from
|
|
1
|
+
import type { VSCodeEmmetConfig } from './emmetHelper';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Default emmet configuration.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CONFIG: VSCodeEmmetConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Mapping between languages that support Emmet and completion trigger characters.
|
|
8
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L86
|
|
4
9
|
*/
|
|
5
10
|
export declare const LANGUAGE_MODES: {
|
|
6
11
|
[id: string]: string[];
|
|
7
12
|
};
|
|
8
13
|
/**
|
|
9
|
-
*
|
|
14
|
+
* Language specific extensions can provide emmet completion support.
|
|
15
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L124
|
|
10
16
|
*/
|
|
11
17
|
export declare const MAPPED_MODES: Record<string, string>;
|
|
12
|
-
export declare const DEFAULT_CONFIG: VSCodeEmmetConfig;
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Default emmet configuration.
|
|
5
5
|
*/
|
|
6
|
+
const DEFAULT_CONFIG = {
|
|
7
|
+
showExpandedAbbreviation: 'always',
|
|
8
|
+
showAbbreviationSuggestions: true,
|
|
9
|
+
showSuggestionsAsSnippets: false
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Mapping between languages that support Emmet and completion trigger characters.
|
|
13
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L86
|
|
14
|
+
*/
|
|
15
|
+
|
|
6
16
|
const LANGUAGE_MODES = {
|
|
7
17
|
html: ['!', '.', '}', ':', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
8
18
|
jade: ['!', '.', '}', ':', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
|
|
@@ -19,7 +29,8 @@ const LANGUAGE_MODES = {
|
|
|
19
29
|
typescript: ['!', '.', '}', '*', '$', ']', '/', '>', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
|
20
30
|
};
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
32
|
+
* Language specific extensions can provide emmet completion support.
|
|
33
|
+
* - ref: https://github.com/microsoft/vscode/blob/50140a53cc2088f478a5560683ccd354f2d5f431/extensions/emmet/src/util.ts#L124
|
|
23
34
|
*/
|
|
24
35
|
|
|
25
36
|
const MAPPED_MODES = {
|
|
@@ -27,10 +38,5 @@ const MAPPED_MODES = {
|
|
|
27
38
|
php: 'html',
|
|
28
39
|
twig: 'html'
|
|
29
40
|
};
|
|
30
|
-
const DEFAULT_CONFIG = {
|
|
31
|
-
showExpandedAbbreviation: 'always',
|
|
32
|
-
showAbbreviationSuggestions: true,
|
|
33
|
-
showSuggestionsAsSnippets: false
|
|
34
|
-
};
|
|
35
41
|
|
|
36
42
|
export { DEFAULT_CONFIG, LANGUAGE_MODES, MAPPED_MODES };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elice/material-exercise",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.221026.0",
|
|
4
4
|
"description": "User view and editing components of Elice material exercise",
|
|
5
5
|
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@elice/design-tokens": "^1.220803.0",
|
|
35
35
|
"@elice/icons": "^1.220803.0",
|
|
36
36
|
"@elice/markdown": "^1.220803.0",
|
|
37
|
-
"@elice/material-shared-types": "
|
|
38
|
-
"@elice/material-shared-utils": "
|
|
39
|
-
"@elice/types": "^1.
|
|
37
|
+
"@elice/material-shared-types": "*",
|
|
38
|
+
"@elice/material-shared-utils": "*",
|
|
39
|
+
"@elice/types": "^1.221026.1",
|
|
40
40
|
"@elice/websocket": "^1.220803.0",
|
|
41
41
|
"humps": "^2.0.1",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
@@ -116,9 +116,9 @@
|
|
|
116
116
|
"@elice/design-tokens": "^1.220803.0",
|
|
117
117
|
"@elice/icons": "^1.220803.0",
|
|
118
118
|
"@elice/markdown": "^1.220803.0",
|
|
119
|
-
"@elice/material-shared-types": "1.
|
|
120
|
-
"@elice/material-shared-utils": "1.
|
|
121
|
-
"@elice/types": "^1.
|
|
119
|
+
"@elice/material-shared-types": "1.221026.0",
|
|
120
|
+
"@elice/material-shared-utils": "1.221026.0",
|
|
121
|
+
"@elice/types": "^1.221026.1",
|
|
122
122
|
"@elice/websocket": "^1.220803.0",
|
|
123
123
|
"@types/classnames": "^2.3.1",
|
|
124
124
|
"@types/color": "^3.0.3",
|
|
@@ -139,5 +139,5 @@
|
|
|
139
139
|
"recoil": "^0.6.1",
|
|
140
140
|
"styled-components": "^5.2.0"
|
|
141
141
|
},
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "7de772c5b7ffa0c09afe214c732b3557f5958471"
|
|
143
143
|
}
|