dsh-ris-ide 1.6.10 → 1.7.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/README.md +24 -21
- package/lib/client-codemirror.js +309 -35
- package/lib/client.js +2552 -367
- package/lib/index.js +545 -6
- package/package.json +1 -1
- package/test/client-viewer.test.mjs +562 -37
- package/test/host-search.test.mjs +383 -0
package/lib/client-codemirror.js
CHANGED
|
@@ -3,7 +3,7 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
3
3
|
var module = { exports: {} };
|
|
4
4
|
var exports = module.exports;
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
-
|
|
6
|
+
//#region ../../.dsh/profiles/web/node_modules/@marijn/find-cluster-break/src/index.js
|
|
7
7
|
let rangeFrom = [];
|
|
8
8
|
let rangeTo = [];
|
|
9
9
|
(() => {
|
|
@@ -73,7 +73,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
73
73
|
function codePointSize$1(code) {
|
|
74
74
|
return code < 65536 ? 1 : 2;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/state/dist/index.js
|
|
77
78
|
/**
|
|
78
79
|
The data structure for documents. @nonabstract
|
|
79
80
|
*/
|
|
@@ -3486,7 +3487,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
3486
3487
|
}
|
|
3487
3488
|
return strict === true ? -1 : string.length;
|
|
3488
3489
|
}
|
|
3489
|
-
|
|
3490
|
+
//#endregion
|
|
3491
|
+
//#region ../../.dsh/profiles/web/node_modules/style-mod/src/style-mod.js
|
|
3490
3492
|
const C = "ͼ";
|
|
3491
3493
|
const COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
|
|
3492
3494
|
const SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
|
|
@@ -3582,7 +3584,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
3582
3584
|
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
|
|
3583
3585
|
}
|
|
3584
3586
|
};
|
|
3585
|
-
|
|
3587
|
+
//#endregion
|
|
3588
|
+
//#region ../../.dsh/profiles/web/node_modules/w3c-keyname/index.js
|
|
3586
3589
|
var base = {
|
|
3587
3590
|
8: "Backspace",
|
|
3588
3591
|
9: "Tab",
|
|
@@ -3682,7 +3685,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
3682
3685
|
if (name == "Down") name = "ArrowDown";
|
|
3683
3686
|
return name;
|
|
3684
3687
|
}
|
|
3685
|
-
|
|
3688
|
+
//#endregion
|
|
3689
|
+
//#region ../../.dsh/profiles/web/node_modules/crelt/index.js
|
|
3686
3690
|
function crelt() {
|
|
3687
3691
|
var elt = arguments[0];
|
|
3688
3692
|
if (typeof elt == "string") elt = document.createElement(elt);
|
|
@@ -3704,7 +3708,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
3704
3708
|
else if (Array.isArray(child)) for (var i = 0; i < child.length; i++) add(elt, child[i]);
|
|
3705
3709
|
else throw new RangeError("Unsupported child node: " + child);
|
|
3706
3710
|
}
|
|
3707
|
-
|
|
3711
|
+
//#endregion
|
|
3712
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/view/dist/index.js
|
|
3708
3713
|
let nav = typeof navigator != "undefined" ? navigator : {
|
|
3709
3714
|
userAgent: "",
|
|
3710
3715
|
vendor: "",
|
|
@@ -12459,7 +12464,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
12459
12464
|
function highlightActiveLineGutter() {
|
|
12460
12465
|
return activeLineGutterHighlighter;
|
|
12461
12466
|
}
|
|
12462
|
-
|
|
12467
|
+
//#endregion
|
|
12468
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/common/dist/index.js
|
|
12463
12469
|
/**
|
|
12464
12470
|
The default maximum length of a `TreeBuffer` node.
|
|
12465
12471
|
*/
|
|
@@ -14352,7 +14358,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
14352
14358
|
}
|
|
14353
14359
|
return result;
|
|
14354
14360
|
}
|
|
14355
|
-
|
|
14361
|
+
//#endregion
|
|
14362
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/highlight/dist/index.js
|
|
14356
14363
|
let nextTagID = 0;
|
|
14357
14364
|
/**
|
|
14358
14365
|
Highlighting tags are markers that denote a highlighting category.
|
|
@@ -15224,7 +15231,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
15224
15231
|
class: "tok-punctuation"
|
|
15225
15232
|
}
|
|
15226
15233
|
]);
|
|
15227
|
-
|
|
15234
|
+
//#endregion
|
|
15235
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/language/dist/index.js
|
|
15228
15236
|
var _a;
|
|
15229
15237
|
/**
|
|
15230
15238
|
Node prop stored in a parser's top syntax node to provide the
|
|
@@ -16536,7 +16544,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
16536
16544
|
return type.id;
|
|
16537
16545
|
}
|
|
16538
16546
|
Direction.RTL, Direction.LTR;
|
|
16539
|
-
|
|
16547
|
+
//#endregion
|
|
16548
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/commands/dist/index.js
|
|
16540
16549
|
/**
|
|
16541
16550
|
Comment or uncomment the current selection. Will use line comments
|
|
16542
16551
|
if available, otherwise falling back to block comments.
|
|
@@ -18259,7 +18268,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
18259
18268
|
run: indentMore,
|
|
18260
18269
|
shift: indentLess
|
|
18261
18270
|
};
|
|
18262
|
-
|
|
18271
|
+
//#endregion
|
|
18272
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/lr/dist/index.js
|
|
18263
18273
|
/**
|
|
18264
18274
|
A parse stack. These are used internally by the parser to track
|
|
18265
18275
|
parsing progress. They also provide some properties and methods
|
|
@@ -19761,7 +19771,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
19761
19771
|
}
|
|
19762
19772
|
return spec.get;
|
|
19763
19773
|
}
|
|
19764
|
-
|
|
19774
|
+
//#endregion
|
|
19775
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/css/dist/index.js
|
|
19765
19776
|
const descendantOp = 148;
|
|
19766
19777
|
const Unit = 1;
|
|
19767
19778
|
const identifier$2 = 149;
|
|
@@ -20033,7 +20044,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
20033
20044
|
],
|
|
20034
20045
|
tokenPrec: 2433
|
|
20035
20046
|
});
|
|
20036
|
-
|
|
20047
|
+
//#endregion
|
|
20048
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-css/dist/index.js
|
|
20037
20049
|
let _properties = null;
|
|
20038
20050
|
function properties() {
|
|
20039
20051
|
if (!_properties && typeof document == "object" && document.body) {
|
|
@@ -20941,7 +20953,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
20941
20953
|
function css() {
|
|
20942
20954
|
return new LanguageSupport(cssLanguage, cssLanguage.data.of({ autocomplete: cssCompletionSource }));
|
|
20943
20955
|
}
|
|
20944
|
-
|
|
20956
|
+
//#endregion
|
|
20957
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/html/dist/index.js
|
|
20945
20958
|
const scriptText = 55;
|
|
20946
20959
|
const StartCloseScriptTag = 1;
|
|
20947
20960
|
const styleText = 56;
|
|
@@ -21411,7 +21424,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
21411
21424
|
return null;
|
|
21412
21425
|
});
|
|
21413
21426
|
}
|
|
21414
|
-
|
|
21427
|
+
//#endregion
|
|
21428
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/javascript/dist/index.js
|
|
21415
21429
|
const noSemi = 317;
|
|
21416
21430
|
const noSemiType = 318;
|
|
21417
21431
|
const incdec = 1;
|
|
@@ -21896,7 +21910,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
21896
21910
|
],
|
|
21897
21911
|
tokenPrec: 15205
|
|
21898
21912
|
});
|
|
21899
|
-
|
|
21913
|
+
//#endregion
|
|
21914
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/autocomplete/dist/index.js
|
|
21900
21915
|
/**
|
|
21901
21916
|
An instance of this is passed to completion source functions.
|
|
21902
21917
|
*/
|
|
@@ -22394,7 +22409,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
22394
22409
|
closedBracket.startSide = 1;
|
|
22395
22410
|
closedBracket.endSide = -1;
|
|
22396
22411
|
typeof navigator == "object" && navigator.userAgent;
|
|
22397
|
-
|
|
22412
|
+
//#endregion
|
|
22413
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-javascript/dist/index.js
|
|
22398
22414
|
/**
|
|
22399
22415
|
A collection of JavaScript-related
|
|
22400
22416
|
[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet).
|
|
@@ -22762,7 +22778,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
22762
22778
|
})]);
|
|
22763
22779
|
return true;
|
|
22764
22780
|
});
|
|
22765
|
-
|
|
22781
|
+
//#endregion
|
|
22782
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-html/dist/index.js
|
|
22766
22783
|
const Targets = [
|
|
22767
22784
|
"_blank",
|
|
22768
22785
|
"_self",
|
|
@@ -23757,7 +23774,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
23757
23774
|
})]);
|
|
23758
23775
|
return true;
|
|
23759
23776
|
});
|
|
23760
|
-
|
|
23777
|
+
//#endregion
|
|
23778
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/java/dist/index.js
|
|
23761
23779
|
const javaHighlighting = styleTags({
|
|
23762
23780
|
null: tags$1.null,
|
|
23763
23781
|
instanceof: tags$1.operatorKeyword,
|
|
@@ -23991,7 +24009,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
23991
24009
|
}],
|
|
23992
24010
|
tokenPrec: 9164
|
|
23993
24011
|
});
|
|
23994
|
-
|
|
24012
|
+
//#endregion
|
|
24013
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-java/dist/index.js
|
|
23995
24014
|
/**
|
|
23996
24015
|
A language provider based on the [Lezer Java
|
|
23997
24016
|
parser](https://github.com/lezer-parser/java), extended with
|
|
@@ -24036,7 +24055,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
24036
24055
|
function java() {
|
|
24037
24056
|
return new LanguageSupport(javaLanguage);
|
|
24038
24057
|
}
|
|
24039
|
-
|
|
24058
|
+
//#endregion
|
|
24059
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/json/dist/index.js
|
|
24040
24060
|
const jsonHighlighting = styleTags({
|
|
24041
24061
|
String: tags$1.string,
|
|
24042
24062
|
Number: tags$1.number,
|
|
@@ -24085,7 +24105,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
24085
24105
|
topRules: { "JsonText": [0, 1] },
|
|
24086
24106
|
tokenPrec: 0
|
|
24087
24107
|
});
|
|
24088
|
-
|
|
24108
|
+
//#endregion
|
|
24109
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-json/dist/index.js
|
|
24089
24110
|
/**
|
|
24090
24111
|
A language provider that provides JSON parsing.
|
|
24091
24112
|
*/
|
|
@@ -24110,7 +24131,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
24110
24131
|
function json() {
|
|
24111
24132
|
return new LanguageSupport(jsonLanguage);
|
|
24112
24133
|
}
|
|
24113
|
-
|
|
24134
|
+
//#endregion
|
|
24135
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/markdown/dist/index.js
|
|
24114
24136
|
var CompositeBlock = class CompositeBlock {
|
|
24115
24137
|
static create(type, value, from, parentHash, end) {
|
|
24116
24138
|
let hash = parentHash + (parentHash << 8) + type + (value << 4) | 0;
|
|
@@ -26069,7 +26091,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
26069
26091
|
}
|
|
26070
26092
|
}]
|
|
26071
26093
|
};
|
|
26072
|
-
|
|
26094
|
+
//#endregion
|
|
26095
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-markdown/dist/index.js
|
|
26073
26096
|
const data = /*@__PURE__*/ defineLanguageFacet({ commentTokens: { block: {
|
|
26074
26097
|
open: "<!--",
|
|
26075
26098
|
close: "-->"
|
|
@@ -26530,7 +26553,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
26530
26553
|
});
|
|
26531
26554
|
return true;
|
|
26532
26555
|
} });
|
|
26533
|
-
|
|
26556
|
+
//#endregion
|
|
26557
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-sql/dist/index.js
|
|
26534
26558
|
const whitespace = 36;
|
|
26535
26559
|
const LineComment = 1;
|
|
26536
26560
|
const BlockComment = 2;
|
|
@@ -27149,7 +27173,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
27149
27173
|
The standard SQL dialect.
|
|
27150
27174
|
*/
|
|
27151
27175
|
const StandardSQL = /*@__PURE__*/ SQLDialect.define({});
|
|
27152
|
-
|
|
27176
|
+
//#endregion
|
|
27177
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-vue/dist/index.js
|
|
27153
27178
|
const parser$3 = /*@__PURE__*/ LRParser.deserialize({
|
|
27154
27179
|
version: 14,
|
|
27155
27180
|
states: "%pOVOWOOObQPOOOpOSO'#C_OOOO'#Cp'#CpQVOWOOQxQPOOO!TQQOOQ!YQPOOOOOO,58y,58yO!_OSO,58yOOOO-E6n-E6nO!dQQO'#CqQ{QPOOO!iQPOOQ{QPOOO!qQPOOOOOO1G.e1G.eOOQO,59],59]OOQO-E6o-E6oO!yOpO'#CiO#RO`O'#CiQOQPOOO#ZO#tO'#CmO#fO!bO'#CmOOQO,59T,59TO#qOpO,59TO#vO`O,59TOOOO'#Cr'#CrO#{O#tO,59XOOQO,59X,59XOOOO'#Cs'#CsO$WO!bO,59XOOQO1G.o1G.oOOOO-E6p-E6pOOQO1G.s1G.sOOOO-E6q-E6q",
|
|
@@ -27233,7 +27258,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
27233
27258
|
}
|
|
27234
27259
|
return new LanguageSupport(base.language == baseHTML.language ? vueLanguage : makeVue(base.language), [base.support, base.language.data.of({ closeBrackets: { brackets: ["{", "\""] } })]);
|
|
27235
27260
|
}
|
|
27236
|
-
|
|
27261
|
+
//#endregion
|
|
27262
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/xml/dist/index.js
|
|
27237
27263
|
const StartTag = 1;
|
|
27238
27264
|
const StartCloseTag = 2;
|
|
27239
27265
|
const MissingCloseTag = 3;
|
|
@@ -27383,7 +27409,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
27383
27409
|
topRules: { "Document": [0, 6] },
|
|
27384
27410
|
tokenPrec: 0
|
|
27385
27411
|
});
|
|
27386
|
-
|
|
27412
|
+
//#endregion
|
|
27413
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/lang-xml/dist/index.js
|
|
27387
27414
|
function tagName(doc, tag) {
|
|
27388
27415
|
let name = tag && tag.getChild("TagName");
|
|
27389
27416
|
return name ? doc.sliceString(name.from, name.to) : "";
|
|
@@ -27693,7 +27720,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
27693
27720
|
})]);
|
|
27694
27721
|
return true;
|
|
27695
27722
|
});
|
|
27696
|
-
|
|
27723
|
+
//#endregion
|
|
27724
|
+
//#region ../../.dsh/profiles/web/node_modules/@lezer/yaml/dist/index.js
|
|
27697
27725
|
const blockEnd = 63;
|
|
27698
27726
|
const eof = 64;
|
|
27699
27727
|
const DirectiveEnd = 1;
|
|
@@ -28071,7 +28099,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
28071
28099
|
return new LanguageSupport(yamlLanguage);
|
|
28072
28100
|
}
|
|
28073
28101
|
tags$1.meta;
|
|
28074
|
-
|
|
28102
|
+
//#endregion
|
|
28103
|
+
//#region ../../.dsh/profiles/web/node_modules/@codemirror/search/dist/index.js
|
|
28075
28104
|
const basicNormalize = typeof String.prototype.normalize == "function" ? (x) => x.normalize("NFKD") : (x) => x;
|
|
28076
28105
|
/**
|
|
28077
28106
|
A search cursor provides an iterator over text matches in a
|
|
@@ -28781,6 +28810,13 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
28781
28810
|
},
|
|
28782
28811
|
provide: (f) => showPanel.from(f, (val) => val.panel)
|
|
28783
28812
|
});
|
|
28813
|
+
/**
|
|
28814
|
+
Get the current search query from an editor state.
|
|
28815
|
+
*/
|
|
28816
|
+
function getSearchQuery(state) {
|
|
28817
|
+
let curState = state.field(searchState, false);
|
|
28818
|
+
return curState ? curState.query.spec : defaultQuery(state);
|
|
28819
|
+
}
|
|
28784
28820
|
var SearchState = class {
|
|
28785
28821
|
constructor(query, panel) {
|
|
28786
28822
|
this.query = query;
|
|
@@ -29227,7 +29263,8 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29227
29263
|
/*@__PURE__*/ Prec.low(searchHighlighter),
|
|
29228
29264
|
baseTheme
|
|
29229
29265
|
];
|
|
29230
|
-
|
|
29266
|
+
//#endregion
|
|
29267
|
+
//#region src/chunks/codemirror.js
|
|
29231
29268
|
/**
|
|
29232
29269
|
* The IDE's editor chunk: CodeMirror 6 + Java syntax, breakpoint gutter, debug
|
|
29233
29270
|
* line highlight and the find/replace panel. Built by `tsdown` into
|
|
@@ -29260,6 +29297,47 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29260
29297
|
return true;
|
|
29261
29298
|
}
|
|
29262
29299
|
/**
|
|
29300
|
+
* Selects the FIRST match of the current query, searching from the top of the
|
|
29301
|
+
* file instead of from wherever the caret happens to be.
|
|
29302
|
+
*
|
|
29303
|
+
* Typing in the find box and the seeded (automatic) searches are both "find me
|
|
29304
|
+
* this text" actions: the user wants the first occurrence in the file, which is
|
|
29305
|
+
* also what a fresh Ctrl+F would show. The next/previous buttons keep their
|
|
29306
|
+
* relative behaviour — only the automatic paths reset to the document start.
|
|
29307
|
+
* @param {object} view - the `EditorView`.
|
|
29308
|
+
*/
|
|
29309
|
+
function findFirstFromStart(view) {
|
|
29310
|
+
view.dispatch({ selection: { anchor: 0 } });
|
|
29311
|
+
findNext(view);
|
|
29312
|
+
}
|
|
29313
|
+
/**
|
|
29314
|
+
* Opens the find panel seeded with `text` and jumps to the first match at/after
|
|
29315
|
+
* `line` — the workspace content search hands a hit over this way, so the editor
|
|
29316
|
+
* shows the same "content find" a Ctrl+F would, with the query already filled in.
|
|
29317
|
+
*
|
|
29318
|
+
* `line` (1-based) is optional: when the hit's line is known the caret starts
|
|
29319
|
+
* there first, so the next match is the one the user clicked instead of the
|
|
29320
|
+
* document's first occurrence. Literal (`literal: true`) because the query is
|
|
29321
|
+
* workspace text, not a regex.
|
|
29322
|
+
* @param {object} view - the `EditorView`.
|
|
29323
|
+
* @param {string} text - query to put in the panel.
|
|
29324
|
+
* @param {number} [line] - 1-based line the hit was on.
|
|
29325
|
+
*/
|
|
29326
|
+
function searchForText(view, text, line) {
|
|
29327
|
+
if (typeof text !== "string" || text === "") return false;
|
|
29328
|
+
if (typeof line === "number" && Number.isFinite(line) && line > 0) {
|
|
29329
|
+
const target = view.state.doc.line(Math.min(Math.max(1, Math.floor(line)), view.state.doc.lines));
|
|
29330
|
+
view.dispatch({ selection: { anchor: Math.max(0, target.from - 1) } });
|
|
29331
|
+
} else view.dispatch({ selection: { anchor: 0 } });
|
|
29332
|
+
view.dispatch({ effects: setSearchQuery.of(new SearchQuery({
|
|
29333
|
+
search: text,
|
|
29334
|
+
literal: true
|
|
29335
|
+
})) });
|
|
29336
|
+
openSearchPanel(view);
|
|
29337
|
+
findNext(view);
|
|
29338
|
+
return true;
|
|
29339
|
+
}
|
|
29340
|
+
/**
|
|
29263
29341
|
* Marks the editor while the document has a non-empty selection.
|
|
29264
29342
|
*
|
|
29265
29343
|
* The active-line tint is drawn on the line itself; a multi-line selection lies
|
|
@@ -29591,7 +29669,7 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29591
29669
|
{ separator: true },
|
|
29592
29670
|
{
|
|
29593
29671
|
label: "删除当前行",
|
|
29594
|
-
shortcut: "Ctrl+Shift+K",
|
|
29672
|
+
shortcut: "Ctrl+D / Ctrl+Shift+K",
|
|
29595
29673
|
disabled: readOnly,
|
|
29596
29674
|
run: run(deleteLine)
|
|
29597
29675
|
},
|
|
@@ -29618,8 +29696,9 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29618
29696
|
label: "查找 / 替换",
|
|
29619
29697
|
shortcut: "Ctrl+F",
|
|
29620
29698
|
run: run((instance) => {
|
|
29621
|
-
searchSelectedText(instance);
|
|
29699
|
+
const seeded = searchSelectedText(instance);
|
|
29622
29700
|
openSearchPanel(instance);
|
|
29701
|
+
if (seeded) findFirstFromStart(instance);
|
|
29623
29702
|
})
|
|
29624
29703
|
},
|
|
29625
29704
|
{
|
|
@@ -29642,6 +29721,181 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29642
29721
|
];
|
|
29643
29722
|
}
|
|
29644
29723
|
/**
|
|
29724
|
+
* The IDE's own find/replace panel: two rows (find, then replace), both inputs
|
|
29725
|
+
* sharing one grid column so they are the same width, and icon-only buttons that
|
|
29726
|
+
* line up with each other. CodeMirror's built-in panel puts everything on one
|
|
29727
|
+
* row with text labels; in a narrow embedded editor that wraps and reads nothing
|
|
29728
|
+
* like the rest of the plugin chrome.
|
|
29729
|
+
*
|
|
29730
|
+
* Wired through `search({createPanel})`, so it is still CodeMirror's own panel:
|
|
29731
|
+
* `findNext`/`replaceAll`, the query state and the key bindings keep working —
|
|
29732
|
+
* only the painting changes. The grid itself lives in `SEARCH_PANEL_CSS`
|
|
29733
|
+
* (`lib/client.js`), next to the other injected editor styles.
|
|
29734
|
+
* @param {object} view - the `EditorView` the panel belongs to.
|
|
29735
|
+
*/
|
|
29736
|
+
function ideFindPanel(view) {
|
|
29737
|
+
const dom = document.createElement("div");
|
|
29738
|
+
dom.className = "cm-search dsh-find-panel";
|
|
29739
|
+
dom.setAttribute("data-ide-find", "1");
|
|
29740
|
+
const makeInput = (name, placeholder) => {
|
|
29741
|
+
const input = document.createElement("input");
|
|
29742
|
+
input.type = "text";
|
|
29743
|
+
input.name = name;
|
|
29744
|
+
input.placeholder = placeholder;
|
|
29745
|
+
input.setAttribute("aria-label", placeholder);
|
|
29746
|
+
input.autocomplete = "off";
|
|
29747
|
+
input.spellcheck = false;
|
|
29748
|
+
dom.append(input);
|
|
29749
|
+
return input;
|
|
29750
|
+
};
|
|
29751
|
+
const makeButton = (action, label, title) => {
|
|
29752
|
+
const button = document.createElement("button");
|
|
29753
|
+
button.type = "button";
|
|
29754
|
+
button.setAttribute("data-find-action", action);
|
|
29755
|
+
button.title = title;
|
|
29756
|
+
button.textContent = label;
|
|
29757
|
+
dom.append(button);
|
|
29758
|
+
return button;
|
|
29759
|
+
};
|
|
29760
|
+
/** Puts the caret in the find field with its text selected (replace = type). */
|
|
29761
|
+
const focusInput = () => {
|
|
29762
|
+
searchInput.focus();
|
|
29763
|
+
searchInput.select();
|
|
29764
|
+
};
|
|
29765
|
+
const searchInput = makeInput("search", "查找");
|
|
29766
|
+
makeButton("previous", "↑", "上一个匹配(Shift+Enter)");
|
|
29767
|
+
makeButton("next", "↓", "下一个匹配(Enter)");
|
|
29768
|
+
const caseButton = makeButton("case", "Aa", "区分大小写");
|
|
29769
|
+
const regexpButton = makeButton("regexp", ".*", "正则表达式");
|
|
29770
|
+
const wordButton = makeButton("word", "ab", "全词匹配");
|
|
29771
|
+
makeButton("close", "✕", "关闭(Esc)");
|
|
29772
|
+
const replaceInput = makeInput("replace", "替换为");
|
|
29773
|
+
const replaceButton = makeButton("replace", "⇥", "替换(Enter)");
|
|
29774
|
+
const replaceAllButton = makeButton("replace-all", "⇥⇥", "全部替换(Shift+Enter)");
|
|
29775
|
+
replaceButton.style.gridRow = "2";
|
|
29776
|
+
replaceButton.style.gridColumn = "6";
|
|
29777
|
+
replaceAllButton.style.gridRow = "2";
|
|
29778
|
+
replaceAllButton.style.gridColumn = "7";
|
|
29779
|
+
const countLabel = document.createElement("span");
|
|
29780
|
+
countLabel.className = "dsh-find-count";
|
|
29781
|
+
countLabel.setAttribute("data-find-count", "1");
|
|
29782
|
+
dom.append(countLabel);
|
|
29783
|
+
const currentQuery = () => getSearchQuery(view.state);
|
|
29784
|
+
/**
|
|
29785
|
+
* Pushes one field of the query into the editor state. `jump` also selects the
|
|
29786
|
+
* next match, which is what typing in the find box should do; the replace box
|
|
29787
|
+
* commits without jumping so editing it never scrolls the document.
|
|
29788
|
+
*/
|
|
29789
|
+
const apply = (patch, jump) => {
|
|
29790
|
+
const current = currentQuery();
|
|
29791
|
+
const next = new SearchQuery({
|
|
29792
|
+
search: patch.search !== void 0 ? patch.search : current.search,
|
|
29793
|
+
caseSensitive: patch.caseSensitive !== void 0 ? patch.caseSensitive : current.caseSensitive,
|
|
29794
|
+
regexp: patch.regexp !== void 0 ? patch.regexp : current.regexp,
|
|
29795
|
+
wholeWord: patch.wholeWord !== void 0 ? patch.wholeWord : current.wholeWord,
|
|
29796
|
+
replace: patch.replace !== void 0 ? patch.replace : current.replace
|
|
29797
|
+
});
|
|
29798
|
+
const changed = next.search !== current.search || next.replace !== current.replace || next.caseSensitive !== current.caseSensitive || next.regexp !== current.regexp || next.wholeWord !== current.wholeWord;
|
|
29799
|
+
if (changed) {
|
|
29800
|
+
view.dispatch({ effects: setSearchQuery.of(next) });
|
|
29801
|
+
if (jump) findFirstFromStart(view);
|
|
29802
|
+
sync();
|
|
29803
|
+
}
|
|
29804
|
+
return changed;
|
|
29805
|
+
};
|
|
29806
|
+
/** Total matches of the current query, capped so a pathological regex stays cheap. */
|
|
29807
|
+
const countMatches = () => {
|
|
29808
|
+
const query = currentQuery();
|
|
29809
|
+
if (typeof query.search !== "string" || query.search === "") return 0;
|
|
29810
|
+
let total = 0;
|
|
29811
|
+
try {
|
|
29812
|
+
const cursor = query.getCursor(view.state);
|
|
29813
|
+
for (let next = cursor.next(); !next.done; next = cursor.next()) {
|
|
29814
|
+
total += 1;
|
|
29815
|
+
if (total > 9999) break;
|
|
29816
|
+
}
|
|
29817
|
+
} catch (error) {
|
|
29818
|
+
return -1;
|
|
29819
|
+
}
|
|
29820
|
+
return total;
|
|
29821
|
+
};
|
|
29822
|
+
/** Mirrors state → panel. Never moves the caret inside a focused input. */
|
|
29823
|
+
const sync = () => {
|
|
29824
|
+
const query = currentQuery();
|
|
29825
|
+
if (document.activeElement !== searchInput && searchInput.value !== query.search) searchInput.value = query.search;
|
|
29826
|
+
if (document.activeElement !== replaceInput && replaceInput.value !== query.replace) replaceInput.value = query.replace;
|
|
29827
|
+
caseButton.setAttribute("aria-pressed", query.caseSensitive ? "true" : "false");
|
|
29828
|
+
regexpButton.setAttribute("aria-pressed", query.regexp ? "true" : "false");
|
|
29829
|
+
wordButton.setAttribute("aria-pressed", query.wholeWord ? "true" : "false");
|
|
29830
|
+
const total = countMatches();
|
|
29831
|
+
countLabel.textContent = query.search === "" ? "" : total < 0 ? "正则无效" : total + " 个";
|
|
29832
|
+
};
|
|
29833
|
+
const close = () => closeSearchPanel(view);
|
|
29834
|
+
searchInput.addEventListener("input", () => {
|
|
29835
|
+
apply({ search: searchInput.value }, true);
|
|
29836
|
+
});
|
|
29837
|
+
replaceInput.addEventListener("input", () => {
|
|
29838
|
+
apply({ replace: replaceInput.value }, false);
|
|
29839
|
+
});
|
|
29840
|
+
searchInput.addEventListener("keydown", (event) => {
|
|
29841
|
+
if (event.key === "Enter") {
|
|
29842
|
+
event.preventDefault();
|
|
29843
|
+
if (event.shiftKey) findPrevious(view);
|
|
29844
|
+
else findNext(view);
|
|
29845
|
+
sync();
|
|
29846
|
+
} else if (event.key === "Escape") {
|
|
29847
|
+
event.preventDefault();
|
|
29848
|
+
close();
|
|
29849
|
+
}
|
|
29850
|
+
});
|
|
29851
|
+
replaceInput.addEventListener("keydown", (event) => {
|
|
29852
|
+
if (event.key === "Enter") {
|
|
29853
|
+
event.preventDefault();
|
|
29854
|
+
if (event.shiftKey) replaceAll(view);
|
|
29855
|
+
else replaceNext(view);
|
|
29856
|
+
sync();
|
|
29857
|
+
} else if (event.key === "Escape") {
|
|
29858
|
+
event.preventDefault();
|
|
29859
|
+
close();
|
|
29860
|
+
}
|
|
29861
|
+
});
|
|
29862
|
+
dom.addEventListener("click", (event) => {
|
|
29863
|
+
const target = event.target;
|
|
29864
|
+
const button = target !== null && target !== void 0 && typeof target.closest === "function" ? target.closest("[data-find-action]") : null;
|
|
29865
|
+
if (button === null) return;
|
|
29866
|
+
const action = button.getAttribute("data-find-action");
|
|
29867
|
+
const query = currentQuery();
|
|
29868
|
+
if (action === "previous") findPrevious(view);
|
|
29869
|
+
else if (action === "next") findNext(view);
|
|
29870
|
+
else if (action === "case") apply({ caseSensitive: !query.caseSensitive }, true);
|
|
29871
|
+
else if (action === "regexp") apply({ regexp: !query.regexp }, true);
|
|
29872
|
+
else if (action === "word") apply({ wholeWord: !query.wholeWord }, true);
|
|
29873
|
+
else if (action === "close") {
|
|
29874
|
+
close();
|
|
29875
|
+
return;
|
|
29876
|
+
} else if (action === "replace") replaceNext(view);
|
|
29877
|
+
else if (action === "replace-all") replaceAll(view);
|
|
29878
|
+
sync();
|
|
29879
|
+
if (action === "replace" || action === "replace-all") replaceInput.focus();
|
|
29880
|
+
else searchInput.focus();
|
|
29881
|
+
});
|
|
29882
|
+
return {
|
|
29883
|
+
dom,
|
|
29884
|
+
top: true,
|
|
29885
|
+
mount() {
|
|
29886
|
+
sync();
|
|
29887
|
+
focusInput();
|
|
29888
|
+
setTimeout(() => {
|
|
29889
|
+
const active = view.root.activeElement;
|
|
29890
|
+
if (active === view.contentDOM || active === null) focusInput();
|
|
29891
|
+
}, 0);
|
|
29892
|
+
},
|
|
29893
|
+
update(update) {
|
|
29894
|
+
if (update.docChanged || update.selectionSet) sync();
|
|
29895
|
+
}
|
|
29896
|
+
};
|
|
29897
|
+
}
|
|
29898
|
+
/**
|
|
29645
29899
|
* Mount CodeMirror into one element.
|
|
29646
29900
|
* @param {HTMLElement} parent - the host element (the React component owns it).
|
|
29647
29901
|
* @param {object} init - `{doc, readOnly, fontSize, dark, breakpoints, debugLine, onChange, onSave, onToggleBreakpoint}`.
|
|
@@ -29695,7 +29949,10 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29695
29949
|
indentUnit.of(" "),
|
|
29696
29950
|
languageCompartment.of(languageForPath(options.path) || []),
|
|
29697
29951
|
syntaxHighlighting(highlightStyle()),
|
|
29698
|
-
search({
|
|
29952
|
+
search({
|
|
29953
|
+
top: true,
|
|
29954
|
+
createPanel: ideFindPanel
|
|
29955
|
+
}),
|
|
29699
29956
|
highlightSelectionMatches(),
|
|
29700
29957
|
keymap.of([
|
|
29701
29958
|
{
|
|
@@ -29723,11 +29980,17 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29723
29980
|
key: "Mod-f",
|
|
29724
29981
|
preventDefault: true,
|
|
29725
29982
|
run: (instance) => {
|
|
29726
|
-
searchSelectedText(instance);
|
|
29983
|
+
const seeded = searchSelectedText(instance);
|
|
29727
29984
|
openSearchPanel(instance);
|
|
29985
|
+
if (seeded) findFirstFromStart(instance);
|
|
29728
29986
|
return true;
|
|
29729
29987
|
}
|
|
29730
29988
|
},
|
|
29989
|
+
{
|
|
29990
|
+
key: "Mod-d",
|
|
29991
|
+
preventDefault: true,
|
|
29992
|
+
run: deleteLine
|
|
29993
|
+
},
|
|
29731
29994
|
{
|
|
29732
29995
|
key: "Mod-Shift-k",
|
|
29733
29996
|
preventDefault: true,
|
|
@@ -29784,6 +30047,16 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29784
30047
|
focus() {
|
|
29785
30048
|
view.focus();
|
|
29786
30049
|
},
|
|
30050
|
+
/**
|
|
30051
|
+
* Workspace content-search hand-off: open the find panel on `text` and jump
|
|
30052
|
+
* to the hit on `line` (1-based, optional).
|
|
30053
|
+
* @param {string} text - the searched text.
|
|
30054
|
+
* @param {number} [line] - the hit's line number.
|
|
30055
|
+
*/
|
|
30056
|
+
searchFor(text, line) {
|
|
30057
|
+
searchForText(view, text, line);
|
|
30058
|
+
view.focus();
|
|
30059
|
+
},
|
|
29787
30060
|
getValue() {
|
|
29788
30061
|
return view.state.doc.toString();
|
|
29789
30062
|
},
|
|
@@ -29817,6 +30090,7 @@ globalThis.__dshRisIdeChunks__.codemirror = (require) => {
|
|
|
29817
30090
|
}
|
|
29818
30091
|
};
|
|
29819
30092
|
}
|
|
30093
|
+
//#endregion
|
|
29820
30094
|
exports.mount = mount;
|
|
29821
30095
|
return module.exports;
|
|
29822
30096
|
};
|