@codingame/monaco-editor-wrapper 3.2.1 → 3.3.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/dist/main.js +65 -1
- package/dist/tools.d.ts +4 -0
- package/package.json +1 -1
- package/stats.html +1 -1
package/dist/main.js
CHANGED
|
@@ -4393,5 +4393,69 @@ function hideCodeWithoutDecoration(editor, decorations) {
|
|
|
4393
4393
|
editor.setHiddenAreas(otherHiddenAreas);
|
|
4394
4394
|
};
|
|
4395
4395
|
}
|
|
4396
|
+
/**
|
|
4397
|
+
* Collapse everything between startToken and endToken
|
|
4398
|
+
*/
|
|
4399
|
+
|
|
4400
|
+
async function collapseCodeSections(editor, startToken, endToken) {
|
|
4401
|
+
let isRegex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
4402
|
+
const editorModel = editor.getModel();
|
|
4403
|
+
const ranges = [];
|
|
4404
|
+
|
|
4405
|
+
if (editorModel != null) {
|
|
4406
|
+
let currentPosition = editorModel.getFullModelRange().getStartPosition();
|
|
4407
|
+
let match;
|
|
4408
|
+
|
|
4409
|
+
while ((match = editorModel.findNextMatch(startToken,
|
|
4410
|
+
/* searchStart */
|
|
4411
|
+
currentPosition,
|
|
4412
|
+
/* isRegex */
|
|
4413
|
+
isRegex,
|
|
4414
|
+
/* matchCase */
|
|
4415
|
+
true,
|
|
4416
|
+
/* wordSeparators */
|
|
4417
|
+
null,
|
|
4418
|
+
/* captureMatches */
|
|
4419
|
+
false)) != null) {
|
|
4420
|
+
var _matchEnd$range$getEn;
|
|
4421
|
+
|
|
4422
|
+
if (match.range.getStartPosition().isBefore(currentPosition)) {
|
|
4423
|
+
break;
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4426
|
+
const matchEnd = editorModel.findNextMatch(endToken,
|
|
4427
|
+
/* searchStart */
|
|
4428
|
+
match.range.getEndPosition(),
|
|
4429
|
+
/* isRegex */
|
|
4430
|
+
isRegex,
|
|
4431
|
+
/* matchCase */
|
|
4432
|
+
true,
|
|
4433
|
+
/* wordSeparators */
|
|
4434
|
+
null,
|
|
4435
|
+
/* captureMatches */
|
|
4436
|
+
false);
|
|
4437
|
+
|
|
4438
|
+
if (matchEnd != null && matchEnd.range.getStartPosition().isBefore(match.range.getStartPosition())) {
|
|
4439
|
+
break;
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
currentPosition = (_matchEnd$range$getEn = matchEnd === null || matchEnd === void 0 ? void 0 : matchEnd.range.getEndPosition()) !== null && _matchEnd$range$getEn !== void 0 ? _matchEnd$range$getEn : editorModel.getFullModelRange().getEndPosition();
|
|
4443
|
+
ranges.push(monaco.Range.fromPositions(match.range.getStartPosition(), currentPosition));
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
const selections = editor.getSelections();
|
|
4447
|
+
editor.setSelections(ranges.map(r => ({
|
|
4448
|
+
selectionStartLineNumber: r.startLineNumber,
|
|
4449
|
+
selectionStartColumn: r.startColumn,
|
|
4450
|
+
positionLineNumber: r.endLineNumber,
|
|
4451
|
+
positionColumn: r.endColumn
|
|
4452
|
+
})));
|
|
4453
|
+
await editor.getAction('editor.createFoldingRangeFromSelection').run();
|
|
4454
|
+
|
|
4455
|
+
if (selections != null) {
|
|
4456
|
+
editor.setSelections(selections);
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4396
4460
|
|
|
4397
|
-
export { createEditor, defineVSCodeTheme, getMonacoLanguage, hideCodeWithoutDecoration, loadLanguage, lockCodeWithoutDecoration, registerEditorOpenHandler, registerTextModelContentProvider, updateEditorKeybindingsMode, updateKeybindings };
|
|
4461
|
+
export { collapseCodeSections, createEditor, defineVSCodeTheme, getMonacoLanguage, hideCodeWithoutDecoration, loadLanguage, lockCodeWithoutDecoration, registerEditorOpenHandler, registerTextModelContentProvider, updateEditorKeybindingsMode, updateKeybindings };
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import * as monaco from 'monaco-editor';
|
|
2
2
|
export declare function lockCodeWithoutDecoration(editor: monaco.editor.IStandaloneCodeEditor, decorations: string[], allowChangeFromSources: string[], errorMessage?: string): () => void;
|
|
3
3
|
export declare function hideCodeWithoutDecoration(editor: monaco.editor.IStandaloneCodeEditor, decorations: string[]): () => void;
|
|
4
|
+
/**
|
|
5
|
+
* Collapse everything between startToken and endToken
|
|
6
|
+
*/
|
|
7
|
+
export declare function collapseCodeSections(editor: monaco.editor.IStandaloneCodeEditor, startToken: string, endToken: string, isRegex?: boolean): Promise<void>;
|