@marimo-team/islands 0.17.4 → 0.17.6
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/{ConnectedDataExplorerComponent-DY9cADKc.js → ConnectedDataExplorerComponent-BC1bAfWX.js} +4 -4
- package/dist/{any-language-editor-Bs2c1bKU.js → any-language-editor-BpWjHMW2.js} +22 -22
- package/dist/{dist-DlSZED-1.js → dist-1NPzctn9.js} +2 -2
- package/dist/{dist-qGpLTiEi.js → dist-59eZyXwa.js} +3 -3
- package/dist/dist-8Gr13wFT.js +6 -0
- package/dist/{dist-D4LUTYHc.js → dist-8IZEIZE_.js} +2 -2
- package/dist/dist-BA1Ol0Yn.js +6 -0
- package/dist/{dist-DzKKEoge.js → dist-BGBHvY7x.js} +3 -3
- package/dist/{dist-8v4BI_h_.js → dist-BJKL0WEK.js} +1 -1
- package/dist/{dist-B3CNaJau.js → dist-BPwzuLH_.js} +119 -119
- package/dist/{dist-D08oiinq.js → dist-BRfGeCYG.js} +77 -77
- package/dist/{dist-CxRajUZ6.js → dist-BXNAv-Y6.js} +1 -1
- package/dist/{dist-7CqcJssH.js → dist-BZrCuBDi.js} +6 -6
- package/dist/{dist-C02gS--y.js → dist-Bevt_gzr.js} +41 -41
- package/dist/{dist-DGKjHTv9.js → dist-C1xRKkqR.js} +5 -5
- package/dist/{dist-DSDOMDNR.js → dist-C8SV9SiM.js} +4 -4
- package/dist/{dist-HKzG1oF6.js → dist-CCFXVP1F.js} +1 -1
- package/dist/{dist-BgsDu-bU.js → dist-CLkbwjpG.js} +1 -1
- package/dist/{dist-BMhv6XDi.js → dist-CP1MdHH-.js} +27 -27
- package/dist/{dist-Dh7gw0Ay.js → dist-CWyLmhAN.js} +2 -2
- package/dist/{dist-CXimnGhI.js → dist-C_BPvPwx.js} +2 -2
- package/dist/dist-CbNrcsEy.js +10 -0
- package/dist/{dist-DiO9ni9a.js → dist-Cba8uTcG.js} +2 -2
- package/dist/{dist-C5Ns3q-m.js → dist-Cf1Q6zai.js} +31 -31
- package/dist/{dist-_tHnp24J.js → dist-CiMy2-5u.js} +3 -3
- package/dist/dist-CkXa7yhd.js +10 -0
- package/dist/dist-CoHj7yHI.js +6 -0
- package/dist/{dist-XkGsOiy0.js → dist-CqG4DwQn.js} +2 -2
- package/dist/{dist-owpR56zn.js → dist-Ct4F6_s2.js} +1 -1
- package/dist/{dist-DTNqkRGE.js → dist-DG9oMdD2.js} +3 -3
- package/dist/{dist-CawOxmKh.js → dist-DKdtgJ4Q.js} +5 -5
- package/dist/{dist-K_AqLCfS.js → dist-DQOkkAzs.js} +3 -3
- package/dist/dist-DVuYVZws.js +6 -0
- package/dist/{dist-DvsjKDQ4.js → dist-DgnYtm7R.js} +1 -1
- package/dist/dist-DjH2J8yO.js +6 -0
- package/dist/{dist-DGnWQOnS.js → dist-Djl1P_Vh.js} +3 -3
- package/dist/{dist-DbHWFmjZ.js → dist-Kh7kDIJB.js} +1 -1
- package/dist/dist-MCqj0bEP.js +12 -0
- package/dist/{dist-eSnWVS11.js → dist-k6dhIy0O.js} +3 -3
- package/dist/dist-l9YJLCkC.js +6 -0
- package/dist/{dist-BYS0EtbC.js → dist-m4uUGntS.js} +2 -2
- package/dist/{dist-D_GkrgWD.js → dist-qXlX_Isq.js} +2 -2
- package/dist/{dist-CBu8cgzz.js → dist-t5bQPtMZ.js} +43 -45
- package/dist/{esm-CQIOyi5v.js → esm-HxIp3fzy.js} +1387 -1435
- package/dist/{formats-kyFd0DPJ.js → formats-b5g0iERd.js} +1 -1
- package/dist/{glide-data-editor-1bUl_mRe.js → glide-data-editor-hF8NzJm2.js} +2 -2
- package/dist/main.js +93 -1074
- package/dist/{mermaid-DIjoC4T4.js → mermaid-BAe4A_1z.js} +2 -2
- package/dist/{react-vega-DM3e8kar.js → react-vega-BhZaW0DJ.js} +1 -1
- package/dist/{react-vega-B9eMrRW1.js → react-vega-C3G6aCB7.js} +1560 -869
- package/dist/{spec-rqRnkIf4.js → spec-9eipa51K.js} +1 -1
- package/dist/{types-Bt7p5SYB.js → types-O1gHduIo.js} +1 -1
- package/dist/{useAsyncData-Dp2V69OV.js → useAsyncData-D8_fNj6a.js} +1 -1
- package/dist/{useTheme-D7vlj42b.js → useTheme-BzICL4qs.js} +23 -24
- package/dist/{vega-component-C58Jk3ub.js → vega-component-B26vOtT-.js} +4 -4
- package/package.json +2 -2
- package/src/components/app-config/data-form.tsx +3 -3
- package/src/core/codemirror/language/__tests__/markdown.test.ts +36 -13
- package/src/core/codemirror/language/__tests__/utils.test.ts +6 -2
- package/src/core/codemirror/language/languages/sql/sql.ts +2 -1
- package/src/plugins/layout/TexPlugin.tsx +33 -5
- package/dist/dist-B9JCXzyv.js +0 -6
- package/dist/dist-C6QrJGYr.js +0 -10
- package/dist/dist-CFZ32udY.js +0 -6
- package/dist/dist-CmgxQNWN.js +0 -10
- package/dist/dist-Cr6Cu8sC.js +0 -6
- package/dist/dist-NxHLuq7w.js +0 -6
- package/dist/dist-S2JcqPPB.js +0 -12
- package/dist/dist-hcPlrsR9.js +0 -6
- package/dist/dist-poXa8G8m.js +0 -6
- package/dist/node-sql-parser-IKID_dZE.js +0 -70437
- /package/dist/{esm-CopBBL2y.js → esm-CS8JKDQL.js} +0 -0
- /package/dist/{react-plotly-Cs07wkly.js → react-plotly-YQqow0sD.js} +0 -0
|
@@ -6,27 +6,27 @@ import { t as Check } from "./check-BZnPxXnd.js";
|
|
|
6
6
|
import { d as cn, u as Events } from "./button-B8zS4Mtw.js";
|
|
7
7
|
import { t as require_jsx_runtime } from "./jsx-runtime-CvL6gNI-.js";
|
|
8
8
|
import { c as Tooltip } from "./error-banner-B7LmpmGT.js";
|
|
9
|
-
import { $ as
|
|
10
|
-
import { a as closeBracketsKeymap, c as completionKeymap, f as snippetCompletion, i as closeBrackets, l as ifNotIn, r as autocompletion, s as completeFromList } from "./dist-
|
|
11
|
-
import { i as markdown } from "./dist-
|
|
12
|
-
import { n as html, r as htmlCompletionSource } from "./dist-
|
|
13
|
-
import { r as cssLanguage, t as css } from "./dist-
|
|
14
|
-
import { c as typescriptLanguage, n as javascript, r as javascriptLanguage, u as parser$1 } from "./dist-
|
|
15
|
-
import { r as python } from "./dist-
|
|
9
|
+
import { $ as WidgetType, A as indentString, B as tags, Bt as fromCodePoint, C as foldKeymap, Ct as EditorSelection, D as getIndentation, Dt as Prec, E as getIndentUnit, F as syntaxHighlighting, Ft as codePointAt, H as NodeProp, I as syntaxTree, It as codePointSize, J as parseMixed, Lt as combineConfig, Mt as StateField, N as matchBrackets, Nt as Text, O as indentNodeProp, Ot as RangeSet, Pt as Transaction, Q as ViewPlugin, R as Tag, Rt as countColumn, S as foldInside, Tt as Facet, X as Direction, Y as Decoration, Z as EditorView, _t as crelt, a as HighlightStyle, at as highlightActiveLine, bt as ChangeSet, ct as hoverTooltip, et as crosshairCursor, f as StreamLanguage, ft as placeholder, g as defaultHighlightStyle, h as continuedIndent, ht as showPanel, j as indentUnit, jt as StateEffect, k as indentOnInput, kt as RangeSetBuilder, lt as keymap, mt as runScopeHandlers, n as ExternalTokenizer, nt as dropCursor, o as IndentContext, ot as highlightActiveLineGutter, p as bracketMatching, pt as rectangularSelection, r as LRParser, rt as getPanel, s as LRLanguage, st as highlightSpecialChars, t as ContextTracker, tt as drawSelection, u as LanguageSupport, ut as lineNumbers, v as delimitedIndent, vt as Annotation, w as foldNodeProp, wt as EditorState, x as foldGutter, xt as CharCategory, yt as ChangeDesc, z as styleTags, zt as findClusterBreak } from "./dist-t5bQPtMZ.js";
|
|
10
|
+
import { a as closeBracketsKeymap, c as completionKeymap, f as snippetCompletion, i as closeBrackets, l as ifNotIn, r as autocompletion, s as completeFromList } from "./dist-BRfGeCYG.js";
|
|
11
|
+
import { i as markdown } from "./dist-Bevt_gzr.js";
|
|
12
|
+
import { n as html, r as htmlCompletionSource } from "./dist-Cf1Q6zai.js";
|
|
13
|
+
import { r as cssLanguage, t as css } from "./dist-BXNAv-Y6.js";
|
|
14
|
+
import { c as typescriptLanguage, n as javascript, r as javascriptLanguage, u as parser$1 } from "./dist-BPwzuLH_.js";
|
|
15
|
+
import { r as python } from "./dist-qXlX_Isq.js";
|
|
16
16
|
import { t as stex } from "./stex-BmcrV7cx.js";
|
|
17
|
-
import { a as PLSQL, f as sql, l as StandardSQL, t as Cassandra } from "./dist-
|
|
18
|
-
import { t as cpp } from "./dist-
|
|
19
|
-
import { t as go } from "./dist-
|
|
20
|
-
import { t as java } from "./dist-
|
|
21
|
-
import { t as json } from "./dist-
|
|
22
|
-
import { t as less } from "./dist-
|
|
23
|
-
import { n as liquid } from "./dist-
|
|
24
|
-
import { t as php } from "./dist-
|
|
25
|
-
import { t as rust } from "./dist-
|
|
26
|
-
import { t as sass } from "./dist-
|
|
27
|
-
import { t as wast } from "./dist-
|
|
28
|
-
import { r as xml } from "./dist-
|
|
29
|
-
import { t as yaml } from "./dist-
|
|
17
|
+
import { a as PLSQL, f as sql, l as StandardSQL, t as Cassandra } from "./dist-8IZEIZE_.js";
|
|
18
|
+
import { t as cpp } from "./dist-Ct4F6_s2.js";
|
|
19
|
+
import { t as go } from "./dist-C_BPvPwx.js";
|
|
20
|
+
import { t as java } from "./dist-DgnYtm7R.js";
|
|
21
|
+
import { t as json } from "./dist-CLkbwjpG.js";
|
|
22
|
+
import { t as less } from "./dist-Cba8uTcG.js";
|
|
23
|
+
import { n as liquid } from "./dist-C8SV9SiM.js";
|
|
24
|
+
import { t as php } from "./dist-CqG4DwQn.js";
|
|
25
|
+
import { t as rust } from "./dist-Kh7kDIJB.js";
|
|
26
|
+
import { t as sass } from "./dist-1NPzctn9.js";
|
|
27
|
+
import { t as wast } from "./dist-CCFXVP1F.js";
|
|
28
|
+
import { r as xml } from "./dist-CP1MdHH-.js";
|
|
29
|
+
import { t as yaml } from "./dist-BJKL0WEK.js";
|
|
30
30
|
import { t as apl } from "./apl-Css595_H.js";
|
|
31
31
|
import { t as asciiArmor } from "./asciiarmor-BTCuJwxh.js";
|
|
32
32
|
import { t as asn1 } from "./asn1-DXjhS5QI.js";
|
|
@@ -110,159 +110,159 @@ import { t as xQuery } from "./xquery-BErHIIc-.js";
|
|
|
110
110
|
import { t as yacas } from "./yacas-BBBJNs0h.js";
|
|
111
111
|
import { t as z80 } from "./z80-nG9RRukG.js";
|
|
112
112
|
import { n as msgenny, r as xu, t as mscgen } from "./mscgen-DWWpdZnb.js";
|
|
113
|
-
import { t as vue } from "./dist-
|
|
113
|
+
import { t as vue } from "./dist-DG9oMdD2.js";
|
|
114
114
|
var import_compiler_runtime = /* @__PURE__ */ __toESM(require_compiler_runtime(), 1), import_react = /* @__PURE__ */ __toESM(require_react(), 1), import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1);
|
|
115
115
|
const CopyClipboardIcon = (e6) => {
|
|
116
|
-
let
|
|
117
|
-
|
|
118
|
-
await copyToClipboard(typeof
|
|
119
|
-
|
|
116
|
+
let x = (0, import_compiler_runtime.c)(13), { value: S, className: k, tooltip: j, toastTitle: M, ariaLabel: N } = e6, [P, F] = (0, import_react.useState)(false), I;
|
|
117
|
+
x[0] !== M || x[1] !== S ? (I = Events.stopPropagation(async (e7) => {
|
|
118
|
+
await copyToClipboard(typeof S == "function" ? S(e7) : S).then(() => {
|
|
119
|
+
F(true), setTimeout(() => F(false), 2e3), M && toast({ title: M });
|
|
120
120
|
});
|
|
121
|
-
}),
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
let
|
|
125
|
-
|
|
121
|
+
}), x[0] = M, x[1] = S, x[2] = I) : I = x[2];
|
|
122
|
+
let L = I, R = N ?? "Copy to clipboard", z;
|
|
123
|
+
x[3] !== k || x[4] !== P ? (z = P ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Check, { className: cn(k, "text-(--grass-11)") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Copy, { className: k }), x[3] = k, x[4] = P, x[5] = z) : z = x[5];
|
|
124
|
+
let B;
|
|
125
|
+
x[6] !== L || x[7] !== R || x[8] !== z ? (B = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
126
126
|
type: "button",
|
|
127
|
-
onClick:
|
|
128
|
-
"aria-label":
|
|
129
|
-
children: L
|
|
130
|
-
}), y[6] = F, y[7] = I, y[8] = L, y[9] = R) : R = y[9];
|
|
131
|
-
let z = R;
|
|
132
|
-
if (k === false) return z;
|
|
133
|
-
let B = M ? "Copied!" : k ?? "Copy to clipboard", V;
|
|
134
|
-
return y[10] !== z || y[11] !== B ? (V = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
|
|
135
|
-
content: B,
|
|
136
|
-
delayDuration: 400,
|
|
127
|
+
onClick: L,
|
|
128
|
+
"aria-label": R,
|
|
137
129
|
children: z
|
|
138
|
-
}),
|
|
130
|
+
}), x[6] = L, x[7] = R, x[8] = z, x[9] = B) : B = x[9];
|
|
131
|
+
let V = B;
|
|
132
|
+
if (j === false) return V;
|
|
133
|
+
let H = P ? "Copied!" : j ?? "Copy to clipboard", U;
|
|
134
|
+
return x[10] !== V || x[11] !== H ? (U = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
|
|
135
|
+
content: H,
|
|
136
|
+
delayDuration: 400,
|
|
137
|
+
children: V
|
|
138
|
+
}), x[10] = V, x[11] = H, x[12] = U) : U = x[12], U;
|
|
139
139
|
};
|
|
140
140
|
var toggleComment = (e6) => {
|
|
141
|
-
let { state:
|
|
142
|
-
return
|
|
141
|
+
let { state: x } = e6, S = x.doc.lineAt(x.selection.main.from), C = getConfig(e6.state, S.from);
|
|
142
|
+
return C.line ? toggleLineComment(e6) : C.block ? toggleBlockCommentByLine(e6) : false;
|
|
143
143
|
};
|
|
144
|
-
function command(e6,
|
|
145
|
-
return ({ state:
|
|
146
|
-
if (
|
|
147
|
-
let
|
|
148
|
-
return
|
|
144
|
+
function command(e6, x) {
|
|
145
|
+
return ({ state: S, dispatch: C }) => {
|
|
146
|
+
if (S.readOnly) return false;
|
|
147
|
+
let w = e6(x, S);
|
|
148
|
+
return w ? (C(S.update(w)), true) : false;
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
var toggleLineComment = /* @__PURE__ */ command(changeLineComment, 0), toggleBlockComment = /* @__PURE__ */ command(changeBlockComment, 0), toggleBlockCommentByLine = /* @__PURE__ */ command((e6,
|
|
152
|
-
function getConfig(e6,
|
|
153
|
-
let
|
|
154
|
-
return
|
|
151
|
+
var toggleLineComment = /* @__PURE__ */ command(changeLineComment, 0), toggleBlockComment = /* @__PURE__ */ command(changeBlockComment, 0), toggleBlockCommentByLine = /* @__PURE__ */ command((e6, x) => changeBlockComment(e6, x, selectedLineRanges(x)), 0);
|
|
152
|
+
function getConfig(e6, x) {
|
|
153
|
+
let S = e6.languageDataAt("commentTokens", x, 1);
|
|
154
|
+
return S.length ? S[0] : {};
|
|
155
155
|
}
|
|
156
156
|
var SearchMargin = 50;
|
|
157
|
-
function findBlockComment(e6, { open:
|
|
158
|
-
let
|
|
159
|
-
if (
|
|
157
|
+
function findBlockComment(e6, { open: x, close: S }, C, w) {
|
|
158
|
+
let T = e6.sliceDoc(C - SearchMargin, C), E = e6.sliceDoc(w, w + SearchMargin), D = /\s*$/.exec(T)[0].length, O = /^\s*/.exec(E)[0].length, k = T.length - D;
|
|
159
|
+
if (T.slice(k - x.length, k) == x && E.slice(O, O + S.length) == S) return {
|
|
160
160
|
open: {
|
|
161
|
-
pos:
|
|
162
|
-
margin:
|
|
161
|
+
pos: C - D,
|
|
162
|
+
margin: D && 1
|
|
163
163
|
},
|
|
164
164
|
close: {
|
|
165
|
-
pos:
|
|
166
|
-
margin:
|
|
165
|
+
pos: w + O,
|
|
166
|
+
margin: O && 1
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
return
|
|
169
|
+
let A, j;
|
|
170
|
+
w - C <= 2 * SearchMargin ? A = j = e6.sliceDoc(C, w) : (A = e6.sliceDoc(C, C + SearchMargin), j = e6.sliceDoc(w - SearchMargin, w));
|
|
171
|
+
let M = /^\s*/.exec(A)[0].length, N = /\s*$/.exec(j)[0].length, P = j.length - N - S.length;
|
|
172
|
+
return A.slice(M, M + x.length) == x && j.slice(P, P + S.length) == S ? {
|
|
173
173
|
open: {
|
|
174
|
-
pos:
|
|
175
|
-
margin: /\s/.test(
|
|
174
|
+
pos: C + M + x.length,
|
|
175
|
+
margin: /\s/.test(A.charAt(M + x.length)) ? 1 : 0
|
|
176
176
|
},
|
|
177
177
|
close: {
|
|
178
|
-
pos:
|
|
179
|
-
margin: /\s/.test(
|
|
178
|
+
pos: w - N - S.length,
|
|
179
|
+
margin: /\s/.test(j.charAt(P - 1)) ? 1 : 0
|
|
180
180
|
}
|
|
181
181
|
} : null;
|
|
182
182
|
}
|
|
183
183
|
function selectedLineRanges(e6) {
|
|
184
|
-
let
|
|
185
|
-
for (let
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
from:
|
|
191
|
-
to:
|
|
184
|
+
let x = [];
|
|
185
|
+
for (let S of e6.selection.ranges) {
|
|
186
|
+
let C = e6.doc.lineAt(S.from), w = S.to <= C.to ? C : e6.doc.lineAt(S.to);
|
|
187
|
+
w.from > C.from && w.from == S.to && (w = S.to == C.to + 1 ? C : e6.doc.lineAt(S.to - 1));
|
|
188
|
+
let T = x.length - 1;
|
|
189
|
+
T >= 0 && x[T].to > C.from ? x[T].to = w.to : x.push({
|
|
190
|
+
from: C.from + /^\s*/.exec(C.text)[0].length,
|
|
191
|
+
to: w.to
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return x;
|
|
195
195
|
}
|
|
196
|
-
function changeBlockComment(e6,
|
|
197
|
-
let
|
|
198
|
-
if (!
|
|
199
|
-
let
|
|
200
|
-
if (e6 != 2 && !
|
|
196
|
+
function changeBlockComment(e6, x, S = x.selection.ranges) {
|
|
197
|
+
let C = S.map((e7) => getConfig(x, e7.from).block);
|
|
198
|
+
if (!C.every((e7) => e7)) return null;
|
|
199
|
+
let w = S.map((e7, S2) => findBlockComment(x, C[S2], e7.from, e7.to));
|
|
200
|
+
if (e6 != 2 && !w.every((e7) => e7)) return { changes: x.changes(S.map((e7, x2) => w[x2] ? [] : [{
|
|
201
201
|
from: e7.from,
|
|
202
|
-
insert:
|
|
202
|
+
insert: C[x2].open + " "
|
|
203
203
|
}, {
|
|
204
204
|
from: e7.to,
|
|
205
|
-
insert: " " +
|
|
205
|
+
insert: " " + C[x2].close
|
|
206
206
|
}])) };
|
|
207
|
-
if (e6 != 1 &&
|
|
207
|
+
if (e6 != 1 && w.some((e7) => e7)) {
|
|
208
208
|
let e7 = [];
|
|
209
|
-
for (let
|
|
210
|
-
let
|
|
209
|
+
for (let x2 = 0, S2; x2 < w.length; x2++) if (S2 = w[x2]) {
|
|
210
|
+
let w2 = C[x2], { open: T, close: E } = S2;
|
|
211
211
|
e7.push({
|
|
212
|
-
from:
|
|
213
|
-
to:
|
|
212
|
+
from: T.pos - w2.open.length,
|
|
213
|
+
to: T.pos + T.margin
|
|
214
214
|
}, {
|
|
215
|
-
from:
|
|
216
|
-
to:
|
|
215
|
+
from: E.pos - E.margin,
|
|
216
|
+
to: E.pos + w2.close.length
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
219
|
return { changes: e7 };
|
|
220
220
|
}
|
|
221
221
|
return null;
|
|
222
222
|
}
|
|
223
|
-
function changeLineComment(e6,
|
|
224
|
-
let
|
|
225
|
-
for (let { from: e7, to:
|
|
226
|
-
let
|
|
227
|
-
if (
|
|
228
|
-
for (let
|
|
229
|
-
let
|
|
230
|
-
if (
|
|
231
|
-
|
|
232
|
-
let e8 = /^\s*/.exec(
|
|
233
|
-
e8 <
|
|
234
|
-
line:
|
|
235
|
-
comment:
|
|
236
|
-
token:
|
|
223
|
+
function changeLineComment(e6, x, S = x.selection.ranges) {
|
|
224
|
+
let C = [], w = -1;
|
|
225
|
+
for (let { from: e7, to: T } of S) {
|
|
226
|
+
let S2 = C.length, E = 1e9, D = getConfig(x, e7).line;
|
|
227
|
+
if (D) {
|
|
228
|
+
for (let S3 = e7; S3 <= T; ) {
|
|
229
|
+
let O = x.doc.lineAt(S3);
|
|
230
|
+
if (O.from > w && (e7 == T || T > O.from)) {
|
|
231
|
+
w = O.from;
|
|
232
|
+
let e8 = /^\s*/.exec(O.text)[0].length, x2 = e8 == O.length, S4 = O.text.slice(e8, e8 + D.length) == D ? e8 : -1;
|
|
233
|
+
e8 < O.text.length && e8 < E && (E = e8), C.push({
|
|
234
|
+
line: O,
|
|
235
|
+
comment: S4,
|
|
236
|
+
token: D,
|
|
237
237
|
indent: e8,
|
|
238
|
-
empty:
|
|
238
|
+
empty: x2,
|
|
239
239
|
single: false
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
S3 = O.to + 1;
|
|
243
243
|
}
|
|
244
|
-
if (
|
|
245
|
-
|
|
244
|
+
if (E < 1e9) for (let e8 = S2; e8 < C.length; e8++) C[e8].indent < C[e8].line.text.length && (C[e8].indent = E);
|
|
245
|
+
C.length == S2 + 1 && (C[S2].single = true);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
if (e6 != 2 &&
|
|
248
|
+
if (e6 != 2 && C.some((e7) => e7.comment < 0 && (!e7.empty || e7.single))) {
|
|
249
249
|
let e7 = [];
|
|
250
|
-
for (let { line:
|
|
251
|
-
from:
|
|
252
|
-
insert:
|
|
250
|
+
for (let { line: x2, token: S3, indent: w2, empty: T, single: E } of C) (E || !T) && e7.push({
|
|
251
|
+
from: x2.from + w2,
|
|
252
|
+
insert: S3 + " "
|
|
253
253
|
});
|
|
254
|
-
let
|
|
254
|
+
let S2 = x.changes(e7);
|
|
255
255
|
return {
|
|
256
|
-
changes:
|
|
257
|
-
selection:
|
|
256
|
+
changes: S2,
|
|
257
|
+
selection: x.selection.map(S2, 1)
|
|
258
258
|
};
|
|
259
|
-
} else if (e6 != 1 &&
|
|
259
|
+
} else if (e6 != 1 && C.some((e7) => e7.comment >= 0)) {
|
|
260
260
|
let e7 = [];
|
|
261
|
-
for (let { line:
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
from:
|
|
265
|
-
to:
|
|
261
|
+
for (let { line: x2, comment: S2, token: w2 } of C) if (S2 >= 0) {
|
|
262
|
+
let C2 = x2.from + S2, T = C2 + w2.length;
|
|
263
|
+
x2.text[T - x2.from] == " " && T++, e7.push({
|
|
264
|
+
from: C2,
|
|
265
|
+
to: T
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
return { changes: e7 };
|
|
@@ -273,26 +273,26 @@ var fromHistory = /* @__PURE__ */ Annotation.define(), isolateHistory = /* @__PU
|
|
|
273
273
|
return combineConfig(e6, {
|
|
274
274
|
minDepth: 100,
|
|
275
275
|
newGroupDelay: 500,
|
|
276
|
-
joinToEvent: (e7,
|
|
276
|
+
joinToEvent: (e7, x) => x
|
|
277
277
|
}, {
|
|
278
278
|
minDepth: Math.max,
|
|
279
279
|
newGroupDelay: Math.min,
|
|
280
|
-
joinToEvent: (e7,
|
|
280
|
+
joinToEvent: (e7, x) => (S, C) => e7(S, C) || x(S, C)
|
|
281
281
|
});
|
|
282
282
|
} }), historyField_ = /* @__PURE__ */ StateField.define({
|
|
283
283
|
create() {
|
|
284
284
|
return HistoryState.empty;
|
|
285
285
|
},
|
|
286
|
-
update(e6,
|
|
287
|
-
let
|
|
288
|
-
if (
|
|
289
|
-
let
|
|
290
|
-
return
|
|
286
|
+
update(e6, x) {
|
|
287
|
+
let S = x.state.facet(historyConfig), C = x.annotation(fromHistory);
|
|
288
|
+
if (C) {
|
|
289
|
+
let w2 = HistEvent.fromTransaction(x, C.selection), T2 = C.side, E2 = T2 == 0 ? e6.undone : e6.done;
|
|
290
|
+
return E2 = w2 ? updateBranch(E2, E2.length, S.minDepth, w2) : addSelection(E2, x.startState.selection), new HistoryState(T2 == 0 ? C.rest : E2, T2 == 0 ? E2 : C.rest);
|
|
291
291
|
}
|
|
292
|
-
let
|
|
293
|
-
if ((
|
|
294
|
-
let
|
|
295
|
-
return
|
|
292
|
+
let w = x.annotation(isolateHistory);
|
|
293
|
+
if ((w == "full" || w == "before") && (e6 = e6.isolate()), x.annotation(Transaction.addToHistory) === false) return x.changes.empty ? e6 : e6.addMapping(x.changes.desc);
|
|
294
|
+
let T = HistEvent.fromTransaction(x), E = x.annotation(Transaction.time), D = x.annotation(Transaction.userEvent);
|
|
295
|
+
return T ? e6 = e6.addChanges(T, E, D, S, x) : x.selection && (e6 = e6.addSelection(x.startState.selection, E, D, S.newGroupDelay)), (w == "full" || w == "after") && (e6 = e6.isolate()), e6;
|
|
296
296
|
},
|
|
297
297
|
toJSON(e6) {
|
|
298
298
|
return {
|
|
@@ -308,28 +308,28 @@ function history(e6 = {}) {
|
|
|
308
308
|
return [
|
|
309
309
|
historyField_,
|
|
310
310
|
historyConfig.of(e6),
|
|
311
|
-
EditorView.domEventHandlers({ beforeinput(e7,
|
|
312
|
-
let
|
|
313
|
-
return
|
|
311
|
+
EditorView.domEventHandlers({ beforeinput(e7, x) {
|
|
312
|
+
let S = e7.inputType == "historyUndo" ? undo : e7.inputType == "historyRedo" ? redo : null;
|
|
313
|
+
return S ? (e7.preventDefault(), S(x)) : false;
|
|
314
314
|
} })
|
|
315
315
|
];
|
|
316
316
|
}
|
|
317
317
|
var historyField = historyField_;
|
|
318
|
-
function cmd(e6,
|
|
319
|
-
return function({ state:
|
|
320
|
-
if (!
|
|
321
|
-
let
|
|
322
|
-
if (!
|
|
323
|
-
let
|
|
324
|
-
return
|
|
318
|
+
function cmd(e6, x) {
|
|
319
|
+
return function({ state: S, dispatch: C }) {
|
|
320
|
+
if (!x && S.readOnly) return false;
|
|
321
|
+
let w = S.field(historyField_, false);
|
|
322
|
+
if (!w) return false;
|
|
323
|
+
let T = w.pop(e6, S, x);
|
|
324
|
+
return T ? (C(T), true) : false;
|
|
325
325
|
};
|
|
326
326
|
}
|
|
327
327
|
var undo = /* @__PURE__ */ cmd(0, false), redo = /* @__PURE__ */ cmd(1, false), undoSelection = /* @__PURE__ */ cmd(0, true), redoSelection = /* @__PURE__ */ cmd(1, true), HistEvent = class e {
|
|
328
|
-
constructor(e6,
|
|
329
|
-
this.changes = e6, this.effects =
|
|
328
|
+
constructor(e6, x, S, C, w) {
|
|
329
|
+
this.changes = e6, this.effects = x, this.mapped = S, this.startSelection = C, this.selectionsAfter = w;
|
|
330
330
|
}
|
|
331
|
-
setSelAfter(
|
|
332
|
-
return new e(this.changes, this.effects, this.mapped, this.startSelection,
|
|
331
|
+
setSelAfter(x) {
|
|
332
|
+
return new e(this.changes, this.effects, this.mapped, this.startSelection, x);
|
|
333
333
|
}
|
|
334
334
|
toJSON() {
|
|
335
335
|
var _a, _b, _c;
|
|
@@ -340,111 +340,111 @@ var undo = /* @__PURE__ */ cmd(0, false), redo = /* @__PURE__ */ cmd(1, false),
|
|
|
340
340
|
selectionsAfter: this.selectionsAfter.map((e6) => e6.toJSON())
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
|
-
static fromJSON(
|
|
344
|
-
return new e(
|
|
343
|
+
static fromJSON(x) {
|
|
344
|
+
return new e(x.changes && ChangeSet.fromJSON(x.changes), [], x.mapped && ChangeDesc.fromJSON(x.mapped), x.startSelection && EditorSelection.fromJSON(x.startSelection), x.selectionsAfter.map(EditorSelection.fromJSON));
|
|
345
345
|
}
|
|
346
|
-
static fromTransaction(
|
|
347
|
-
let
|
|
348
|
-
for (let e6 of
|
|
349
|
-
let
|
|
350
|
-
|
|
346
|
+
static fromTransaction(x, S) {
|
|
347
|
+
let C = none;
|
|
348
|
+
for (let e6 of x.startState.facet(invertedEffects)) {
|
|
349
|
+
let S2 = e6(x);
|
|
350
|
+
S2.length && (C = C.concat(S2));
|
|
351
351
|
}
|
|
352
|
-
return !
|
|
352
|
+
return !C.length && x.changes.empty ? null : new e(x.changes.invert(x.startState.doc), C, void 0, S || x.startState.selection, none);
|
|
353
353
|
}
|
|
354
|
-
static selection(
|
|
355
|
-
return new e(void 0, none, void 0, void 0,
|
|
354
|
+
static selection(x) {
|
|
355
|
+
return new e(void 0, none, void 0, void 0, x);
|
|
356
356
|
}
|
|
357
357
|
};
|
|
358
|
-
function updateBranch(e6,
|
|
359
|
-
let
|
|
360
|
-
return
|
|
358
|
+
function updateBranch(e6, x, S, C) {
|
|
359
|
+
let w = x + 1 > S + 20 ? x - S - 1 : 0, T = e6.slice(w, x);
|
|
360
|
+
return T.push(C), T;
|
|
361
361
|
}
|
|
362
|
-
function isAdjacent(e6,
|
|
363
|
-
let
|
|
364
|
-
return e6.iterChangedRanges((e7,
|
|
365
|
-
for (let e8 = 0; e8 <
|
|
366
|
-
let
|
|
367
|
-
|
|
362
|
+
function isAdjacent(e6, x) {
|
|
363
|
+
let S = [], C = false;
|
|
364
|
+
return e6.iterChangedRanges((e7, x2) => S.push(e7, x2)), x.iterChangedRanges((e7, x2, w, T) => {
|
|
365
|
+
for (let e8 = 0; e8 < S.length; ) {
|
|
366
|
+
let x3 = S[e8++], E = S[e8++];
|
|
367
|
+
T >= x3 && w <= E && (C = true);
|
|
368
368
|
}
|
|
369
|
-
}),
|
|
369
|
+
}), C;
|
|
370
370
|
}
|
|
371
|
-
function eqSelectionShape(e6,
|
|
372
|
-
return e6.ranges.length ==
|
|
371
|
+
function eqSelectionShape(e6, x) {
|
|
372
|
+
return e6.ranges.length == x.ranges.length && e6.ranges.filter((e7, S) => e7.empty != x.ranges[S].empty).length === 0;
|
|
373
373
|
}
|
|
374
|
-
function conc(e6,
|
|
375
|
-
return e6.length ?
|
|
374
|
+
function conc(e6, x) {
|
|
375
|
+
return e6.length ? x.length ? e6.concat(x) : e6 : x;
|
|
376
376
|
}
|
|
377
377
|
var none = [], MaxSelectionsPerEvent = 200;
|
|
378
|
-
function addSelection(e6,
|
|
378
|
+
function addSelection(e6, x) {
|
|
379
379
|
if (e6.length) {
|
|
380
|
-
let
|
|
381
|
-
return
|
|
382
|
-
} else return [HistEvent.selection([
|
|
380
|
+
let S = e6[e6.length - 1], C = S.selectionsAfter.slice(Math.max(0, S.selectionsAfter.length - MaxSelectionsPerEvent));
|
|
381
|
+
return C.length && C[C.length - 1].eq(x) ? e6 : (C.push(x), updateBranch(e6, e6.length - 1, 1e9, S.setSelAfter(C)));
|
|
382
|
+
} else return [HistEvent.selection([x])];
|
|
383
383
|
}
|
|
384
384
|
function popSelection(e6) {
|
|
385
|
-
let
|
|
386
|
-
return
|
|
385
|
+
let x = e6[e6.length - 1], S = e6.slice();
|
|
386
|
+
return S[e6.length - 1] = x.setSelAfter(x.selectionsAfter.slice(0, x.selectionsAfter.length - 1)), S;
|
|
387
387
|
}
|
|
388
|
-
function addMappingToBranch(e6,
|
|
388
|
+
function addMappingToBranch(e6, x) {
|
|
389
389
|
if (!e6.length) return e6;
|
|
390
|
-
let
|
|
391
|
-
for (;
|
|
392
|
-
let
|
|
393
|
-
if (
|
|
394
|
-
let
|
|
395
|
-
return
|
|
396
|
-
} else
|
|
397
|
-
}
|
|
398
|
-
return
|
|
390
|
+
let S = e6.length, C = none;
|
|
391
|
+
for (; S; ) {
|
|
392
|
+
let w = mapEvent(e6[S - 1], x, C);
|
|
393
|
+
if (w.changes && !w.changes.empty || w.effects.length) {
|
|
394
|
+
let x2 = e6.slice(0, S);
|
|
395
|
+
return x2[S - 1] = w, x2;
|
|
396
|
+
} else x = w.mapped, S--, C = w.selectionsAfter;
|
|
397
|
+
}
|
|
398
|
+
return C.length ? [HistEvent.selection(C)] : none;
|
|
399
399
|
}
|
|
400
|
-
function mapEvent(e6,
|
|
401
|
-
let
|
|
402
|
-
if (!e6.changes) return HistEvent.selection(
|
|
403
|
-
let
|
|
404
|
-
return new HistEvent(
|
|
400
|
+
function mapEvent(e6, x, S) {
|
|
401
|
+
let C = conc(e6.selectionsAfter.length ? e6.selectionsAfter.map((e7) => e7.map(x)) : none, S);
|
|
402
|
+
if (!e6.changes) return HistEvent.selection(C);
|
|
403
|
+
let w = e6.changes.map(x), T = x.mapDesc(e6.changes, true), E = e6.mapped ? e6.mapped.composeDesc(T) : T;
|
|
404
|
+
return new HistEvent(w, StateEffect.mapEffects(e6.effects, x), E, e6.startSelection.map(T), C);
|
|
405
405
|
}
|
|
406
406
|
var joinableUserEvent = /^(input\.type|delete)($|\.)/, HistoryState = class e2 {
|
|
407
|
-
constructor(e6,
|
|
408
|
-
this.done = e6, this.undone =
|
|
407
|
+
constructor(e6, x, S = 0, C = void 0) {
|
|
408
|
+
this.done = e6, this.undone = x, this.prevTime = S, this.prevUserEvent = C;
|
|
409
409
|
}
|
|
410
410
|
isolate() {
|
|
411
411
|
return this.prevTime ? new e2(this.done, this.undone) : this;
|
|
412
412
|
}
|
|
413
|
-
addChanges(
|
|
414
|
-
let
|
|
415
|
-
return
|
|
413
|
+
addChanges(x, S, C, w, T) {
|
|
414
|
+
let E = this.done, D = E[E.length - 1];
|
|
415
|
+
return E = D && D.changes && !D.changes.empty && x.changes && (!C || joinableUserEvent.test(C)) && (!D.selectionsAfter.length && S - this.prevTime < w.newGroupDelay && w.joinToEvent(T, isAdjacent(D.changes, x.changes)) || C == "input.type.compose") ? updateBranch(E, E.length - 1, w.minDepth, new HistEvent(x.changes.compose(D.changes), conc(StateEffect.mapEffects(x.effects, D.changes), D.effects), D.mapped, D.startSelection, none)) : updateBranch(E, E.length, w.minDepth, x), new e2(E, none, S, C);
|
|
416
416
|
}
|
|
417
|
-
addSelection(
|
|
418
|
-
let
|
|
419
|
-
return
|
|
417
|
+
addSelection(x, S, C, w) {
|
|
418
|
+
let T = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none;
|
|
419
|
+
return T.length > 0 && S - this.prevTime < w && C == this.prevUserEvent && C && /^select($|\.)/.test(C) && eqSelectionShape(T[T.length - 1], x) ? this : new e2(addSelection(this.done, x), this.undone, S, C);
|
|
420
420
|
}
|
|
421
|
-
addMapping(
|
|
422
|
-
return new e2(addMappingToBranch(this.done,
|
|
421
|
+
addMapping(x) {
|
|
422
|
+
return new e2(addMappingToBranch(this.done, x), addMappingToBranch(this.undone, x), this.prevTime, this.prevUserEvent);
|
|
423
423
|
}
|
|
424
|
-
pop(e6,
|
|
425
|
-
let
|
|
426
|
-
if (
|
|
427
|
-
let
|
|
428
|
-
if (
|
|
429
|
-
selection:
|
|
424
|
+
pop(e6, x, S) {
|
|
425
|
+
let C = e6 == 0 ? this.done : this.undone;
|
|
426
|
+
if (C.length == 0) return null;
|
|
427
|
+
let w = C[C.length - 1], T = w.selectionsAfter[0] || x.selection;
|
|
428
|
+
if (S && w.selectionsAfter.length) return x.update({
|
|
429
|
+
selection: w.selectionsAfter[w.selectionsAfter.length - 1],
|
|
430
430
|
annotations: fromHistory.of({
|
|
431
431
|
side: e6,
|
|
432
|
-
rest: popSelection(
|
|
433
|
-
selection:
|
|
432
|
+
rest: popSelection(C),
|
|
433
|
+
selection: T
|
|
434
434
|
}),
|
|
435
435
|
userEvent: e6 == 0 ? "select.undo" : "select.redo",
|
|
436
436
|
scrollIntoView: true
|
|
437
437
|
});
|
|
438
|
-
if (
|
|
439
|
-
let
|
|
440
|
-
return
|
|
441
|
-
changes:
|
|
442
|
-
selection:
|
|
443
|
-
effects:
|
|
438
|
+
if (w.changes) {
|
|
439
|
+
let S2 = C.length == 1 ? none : C.slice(0, C.length - 1);
|
|
440
|
+
return w.mapped && (S2 = addMappingToBranch(S2, w.mapped)), x.update({
|
|
441
|
+
changes: w.changes,
|
|
442
|
+
selection: w.startSelection,
|
|
443
|
+
effects: w.effects,
|
|
444
444
|
annotations: fromHistory.of({
|
|
445
445
|
side: e6,
|
|
446
|
-
rest:
|
|
447
|
-
selection:
|
|
446
|
+
rest: S2,
|
|
447
|
+
selection: T
|
|
448
448
|
}),
|
|
449
449
|
filter: false,
|
|
450
450
|
userEvent: e6 == 0 ? "undo" : "redo",
|
|
@@ -483,244 +483,244 @@ var historyKeymap = [
|
|
|
483
483
|
preventDefault: true
|
|
484
484
|
}
|
|
485
485
|
];
|
|
486
|
-
function updateSel(e6,
|
|
487
|
-
return EditorSelection.create(e6.ranges.map(
|
|
486
|
+
function updateSel(e6, x) {
|
|
487
|
+
return EditorSelection.create(e6.ranges.map(x), e6.mainIndex);
|
|
488
488
|
}
|
|
489
|
-
function setSel(e6,
|
|
489
|
+
function setSel(e6, x) {
|
|
490
490
|
return e6.update({
|
|
491
|
-
selection:
|
|
491
|
+
selection: x,
|
|
492
492
|
scrollIntoView: true,
|
|
493
493
|
userEvent: "select"
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
|
-
function moveSel({ state: e6, dispatch:
|
|
497
|
-
let
|
|
498
|
-
return
|
|
496
|
+
function moveSel({ state: e6, dispatch: x }, S) {
|
|
497
|
+
let C = updateSel(e6.selection, S);
|
|
498
|
+
return C.eq(e6.selection, true) ? false : (x(setSel(e6, C)), true);
|
|
499
499
|
}
|
|
500
|
-
function rangeEnd(e6,
|
|
501
|
-
return EditorSelection.cursor(
|
|
500
|
+
function rangeEnd(e6, x) {
|
|
501
|
+
return EditorSelection.cursor(x ? e6.to : e6.from);
|
|
502
502
|
}
|
|
503
|
-
function cursorByChar(e6,
|
|
504
|
-
return moveSel(e6, (
|
|
503
|
+
function cursorByChar(e6, x) {
|
|
504
|
+
return moveSel(e6, (S) => S.empty ? e6.moveByChar(S, x) : rangeEnd(S, x));
|
|
505
505
|
}
|
|
506
506
|
function ltrAtCursor(e6) {
|
|
507
507
|
return e6.textDirectionAt(e6.state.selection.main.head) == Direction.LTR;
|
|
508
508
|
}
|
|
509
509
|
var cursorCharLeft = (e6) => cursorByChar(e6, !ltrAtCursor(e6)), cursorCharRight = (e6) => cursorByChar(e6, ltrAtCursor(e6));
|
|
510
|
-
function cursorByGroup(e6,
|
|
511
|
-
return moveSel(e6, (
|
|
510
|
+
function cursorByGroup(e6, x) {
|
|
511
|
+
return moveSel(e6, (S) => S.empty ? e6.moveByGroup(S, x) : rangeEnd(S, x));
|
|
512
512
|
}
|
|
513
513
|
var cursorGroupLeft = (e6) => cursorByGroup(e6, !ltrAtCursor(e6)), cursorGroupRight = (e6) => cursorByGroup(e6, ltrAtCursor(e6));
|
|
514
514
|
typeof Intl < "u" && Intl.Segmenter;
|
|
515
|
-
function interestingNode(e6,
|
|
516
|
-
if (
|
|
517
|
-
let
|
|
518
|
-
return
|
|
515
|
+
function interestingNode(e6, x, S) {
|
|
516
|
+
if (x.type.prop(S)) return true;
|
|
517
|
+
let C = x.to - x.from;
|
|
518
|
+
return C && (C > 2 || /[^\s,.;:]/.test(e6.sliceDoc(x.from, x.to))) || x.firstChild;
|
|
519
519
|
}
|
|
520
|
-
function moveBySyntax(e6,
|
|
521
|
-
let
|
|
522
|
-
for (let
|
|
523
|
-
let
|
|
524
|
-
if (!
|
|
525
|
-
interestingNode(e6,
|
|
526
|
-
}
|
|
527
|
-
let
|
|
528
|
-
return
|
|
520
|
+
function moveBySyntax(e6, x, S) {
|
|
521
|
+
let C = syntaxTree(e6).resolveInner(x.head), w = S ? NodeProp.closedBy : NodeProp.openedBy;
|
|
522
|
+
for (let T2 = x.head; ; ) {
|
|
523
|
+
let x2 = S ? C.childAfter(T2) : C.childBefore(T2);
|
|
524
|
+
if (!x2) break;
|
|
525
|
+
interestingNode(e6, x2, w) ? C = x2 : T2 = S ? x2.to : x2.from;
|
|
526
|
+
}
|
|
527
|
+
let T = C.type.prop(w), E, D;
|
|
528
|
+
return D = T && (E = S ? matchBrackets(e6, C.from, 1) : matchBrackets(e6, C.to, -1)) && E.matched ? S ? E.end.to : E.end.from : S ? C.to : C.from, EditorSelection.cursor(D, S ? -1 : 1);
|
|
529
529
|
}
|
|
530
|
-
var cursorSyntaxLeft = (e6) => moveSel(e6, (
|
|
531
|
-
function cursorByLine(e6,
|
|
532
|
-
return moveSel(e6, (
|
|
533
|
-
if (!
|
|
534
|
-
let
|
|
535
|
-
return
|
|
530
|
+
var cursorSyntaxLeft = (e6) => moveSel(e6, (x) => moveBySyntax(e6.state, x, !ltrAtCursor(e6))), cursorSyntaxRight = (e6) => moveSel(e6, (x) => moveBySyntax(e6.state, x, ltrAtCursor(e6)));
|
|
531
|
+
function cursorByLine(e6, x) {
|
|
532
|
+
return moveSel(e6, (S) => {
|
|
533
|
+
if (!S.empty) return rangeEnd(S, x);
|
|
534
|
+
let C = e6.moveVertically(S, x);
|
|
535
|
+
return C.head == S.head ? e6.moveToLineBoundary(S, x) : C;
|
|
536
536
|
});
|
|
537
537
|
}
|
|
538
538
|
var cursorLineUp = (e6) => cursorByLine(e6, false), cursorLineDown = (e6) => cursorByLine(e6, true);
|
|
539
539
|
function pageInfo(e6) {
|
|
540
|
-
let
|
|
541
|
-
if (
|
|
542
|
-
for (let
|
|
543
|
-
let
|
|
544
|
-
(
|
|
540
|
+
let x = e6.scrollDOM.clientHeight < e6.scrollDOM.scrollHeight - 2, S = 0, C = 0, w;
|
|
541
|
+
if (x) {
|
|
542
|
+
for (let x2 of e6.state.facet(EditorView.scrollMargins)) {
|
|
543
|
+
let w2 = x2(e6);
|
|
544
|
+
(w2 == null ? void 0 : w2.top) && (S = Math.max(w2 == null ? void 0 : w2.top, S)), (w2 == null ? void 0 : w2.bottom) && (C = Math.max(w2 == null ? void 0 : w2.bottom, C));
|
|
545
545
|
}
|
|
546
|
-
|
|
547
|
-
} else
|
|
546
|
+
w = e6.scrollDOM.clientHeight - S - C;
|
|
547
|
+
} else w = (e6.dom.ownerDocument.defaultView || window).innerHeight;
|
|
548
548
|
return {
|
|
549
|
-
marginTop:
|
|
550
|
-
marginBottom:
|
|
551
|
-
selfScroll:
|
|
552
|
-
height: Math.max(e6.defaultLineHeight,
|
|
549
|
+
marginTop: S,
|
|
550
|
+
marginBottom: C,
|
|
551
|
+
selfScroll: x,
|
|
552
|
+
height: Math.max(e6.defaultLineHeight, w - 5)
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
|
-
function cursorByPage(e6,
|
|
556
|
-
let
|
|
557
|
-
if (
|
|
558
|
-
let
|
|
559
|
-
if (
|
|
560
|
-
let
|
|
561
|
-
|
|
555
|
+
function cursorByPage(e6, x) {
|
|
556
|
+
let S = pageInfo(e6), { state: C } = e6, w = updateSel(C.selection, (C2) => C2.empty ? e6.moveVertically(C2, x, S.height) : rangeEnd(C2, x));
|
|
557
|
+
if (w.eq(C.selection)) return false;
|
|
558
|
+
let T;
|
|
559
|
+
if (S.selfScroll) {
|
|
560
|
+
let x2 = e6.coordsAtPos(C.selection.main.head), E = e6.scrollDOM.getBoundingClientRect(), D = E.top + S.marginTop, O = E.bottom - S.marginBottom;
|
|
561
|
+
x2 && x2.top > D && x2.bottom < O && (T = EditorView.scrollIntoView(w.main.head, {
|
|
562
562
|
y: "start",
|
|
563
|
-
yMargin:
|
|
563
|
+
yMargin: x2.top - D
|
|
564
564
|
}));
|
|
565
565
|
}
|
|
566
|
-
return e6.dispatch(setSel(
|
|
566
|
+
return e6.dispatch(setSel(C, w), { effects: T }), true;
|
|
567
567
|
}
|
|
568
568
|
var cursorPageUp = (e6) => cursorByPage(e6, false), cursorPageDown = (e6) => cursorByPage(e6, true);
|
|
569
|
-
function moveByLineBoundary(e6,
|
|
570
|
-
let
|
|
571
|
-
if (
|
|
572
|
-
let
|
|
573
|
-
|
|
569
|
+
function moveByLineBoundary(e6, x, S) {
|
|
570
|
+
let C = e6.lineBlockAt(x.head), w = e6.moveToLineBoundary(x, S);
|
|
571
|
+
if (w.head == x.head && w.head != (S ? C.to : C.from) && (w = e6.moveToLineBoundary(x, S, false)), !S && w.head == C.from && C.length) {
|
|
572
|
+
let S2 = /^\s*/.exec(e6.state.sliceDoc(C.from, Math.min(C.from + 100, C.to)))[0].length;
|
|
573
|
+
S2 && x.head != C.from + S2 && (w = EditorSelection.cursor(C.from + S2));
|
|
574
574
|
}
|
|
575
|
-
return
|
|
575
|
+
return w;
|
|
576
576
|
}
|
|
577
|
-
var cursorLineBoundaryForward = (e6) => moveSel(e6, (
|
|
578
|
-
function toMatchingBracket(e6,
|
|
579
|
-
let
|
|
580
|
-
let
|
|
581
|
-
if (!
|
|
582
|
-
|
|
583
|
-
let
|
|
584
|
-
return
|
|
577
|
+
var cursorLineBoundaryForward = (e6) => moveSel(e6, (x) => moveByLineBoundary(e6, x, true)), cursorLineBoundaryBackward = (e6) => moveSel(e6, (x) => moveByLineBoundary(e6, x, false)), cursorLineBoundaryLeft = (e6) => moveSel(e6, (x) => moveByLineBoundary(e6, x, !ltrAtCursor(e6))), cursorLineBoundaryRight = (e6) => moveSel(e6, (x) => moveByLineBoundary(e6, x, ltrAtCursor(e6))), cursorLineStart = (e6) => moveSel(e6, (x) => EditorSelection.cursor(e6.lineBlockAt(x.head).from, 1)), cursorLineEnd = (e6) => moveSel(e6, (x) => EditorSelection.cursor(e6.lineBlockAt(x.head).to, -1));
|
|
578
|
+
function toMatchingBracket(e6, x, S) {
|
|
579
|
+
let C = false, w = updateSel(e6.selection, (x2) => {
|
|
580
|
+
let w2 = matchBrackets(e6, x2.head, -1) || matchBrackets(e6, x2.head, 1) || x2.head > 0 && matchBrackets(e6, x2.head - 1, 1) || x2.head < e6.doc.length && matchBrackets(e6, x2.head + 1, -1);
|
|
581
|
+
if (!w2 || !w2.end) return x2;
|
|
582
|
+
C = true;
|
|
583
|
+
let T = w2.start.from == x2.head ? w2.end.to : w2.end.from;
|
|
584
|
+
return S ? EditorSelection.range(x2.anchor, T) : EditorSelection.cursor(T);
|
|
585
585
|
});
|
|
586
|
-
return
|
|
586
|
+
return C ? (x(setSel(e6, w)), true) : false;
|
|
587
587
|
}
|
|
588
|
-
var cursorMatchingBracket = ({ state: e6, dispatch:
|
|
589
|
-
function extendSel(e6,
|
|
590
|
-
let
|
|
591
|
-
let
|
|
592
|
-
return EditorSelection.range(e7.anchor,
|
|
588
|
+
var cursorMatchingBracket = ({ state: e6, dispatch: x }) => toMatchingBracket(e6, x, false);
|
|
589
|
+
function extendSel(e6, x) {
|
|
590
|
+
let S = updateSel(e6.state.selection, (e7) => {
|
|
591
|
+
let S2 = x(e7);
|
|
592
|
+
return EditorSelection.range(e7.anchor, S2.head, S2.goalColumn, S2.bidiLevel || void 0);
|
|
593
593
|
});
|
|
594
|
-
return
|
|
594
|
+
return S.eq(e6.state.selection) ? false : (e6.dispatch(setSel(e6.state, S)), true);
|
|
595
595
|
}
|
|
596
|
-
function selectByChar(e6,
|
|
597
|
-
return extendSel(e6, (
|
|
596
|
+
function selectByChar(e6, x) {
|
|
597
|
+
return extendSel(e6, (S) => e6.moveByChar(S, x));
|
|
598
598
|
}
|
|
599
599
|
var selectCharLeft = (e6) => selectByChar(e6, !ltrAtCursor(e6)), selectCharRight = (e6) => selectByChar(e6, ltrAtCursor(e6));
|
|
600
|
-
function selectByGroup(e6,
|
|
601
|
-
return extendSel(e6, (
|
|
600
|
+
function selectByGroup(e6, x) {
|
|
601
|
+
return extendSel(e6, (S) => e6.moveByGroup(S, x));
|
|
602
602
|
}
|
|
603
|
-
var selectGroupLeft = (e6) => selectByGroup(e6, !ltrAtCursor(e6)), selectGroupRight = (e6) => selectByGroup(e6, ltrAtCursor(e6)), selectSyntaxLeft = (e6) => extendSel(e6, (
|
|
604
|
-
function selectByLine(e6,
|
|
605
|
-
return extendSel(e6, (
|
|
603
|
+
var selectGroupLeft = (e6) => selectByGroup(e6, !ltrAtCursor(e6)), selectGroupRight = (e6) => selectByGroup(e6, ltrAtCursor(e6)), selectSyntaxLeft = (e6) => extendSel(e6, (x) => moveBySyntax(e6.state, x, !ltrAtCursor(e6))), selectSyntaxRight = (e6) => extendSel(e6, (x) => moveBySyntax(e6.state, x, ltrAtCursor(e6)));
|
|
604
|
+
function selectByLine(e6, x) {
|
|
605
|
+
return extendSel(e6, (S) => e6.moveVertically(S, x));
|
|
606
606
|
}
|
|
607
607
|
var selectLineUp = (e6) => selectByLine(e6, false), selectLineDown = (e6) => selectByLine(e6, true);
|
|
608
|
-
function selectByPage(e6,
|
|
609
|
-
return extendSel(e6, (
|
|
608
|
+
function selectByPage(e6, x) {
|
|
609
|
+
return extendSel(e6, (S) => e6.moveVertically(S, x, pageInfo(e6).height));
|
|
610
610
|
}
|
|
611
|
-
var selectPageUp = (e6) => selectByPage(e6, false), selectPageDown = (e6) => selectByPage(e6, true), selectLineBoundaryForward = (e6) => extendSel(e6, (
|
|
611
|
+
var selectPageUp = (e6) => selectByPage(e6, false), selectPageDown = (e6) => selectByPage(e6, true), selectLineBoundaryForward = (e6) => extendSel(e6, (x) => moveByLineBoundary(e6, x, true)), selectLineBoundaryBackward = (e6) => extendSel(e6, (x) => moveByLineBoundary(e6, x, false)), selectLineBoundaryLeft = (e6) => extendSel(e6, (x) => moveByLineBoundary(e6, x, !ltrAtCursor(e6))), selectLineBoundaryRight = (e6) => extendSel(e6, (x) => moveByLineBoundary(e6, x, ltrAtCursor(e6))), selectLineStart = (e6) => extendSel(e6, (x) => EditorSelection.cursor(e6.lineBlockAt(x.head).from)), selectLineEnd = (e6) => extendSel(e6, (x) => EditorSelection.cursor(e6.lineBlockAt(x.head).to)), cursorDocStart = ({ state: e6, dispatch: x }) => (x(setSel(e6, { anchor: 0 })), true), cursorDocEnd = ({ state: e6, dispatch: x }) => (x(setSel(e6, { anchor: e6.doc.length })), true), selectDocStart = ({ state: e6, dispatch: x }) => (x(setSel(e6, {
|
|
612
612
|
anchor: e6.selection.main.anchor,
|
|
613
613
|
head: 0
|
|
614
|
-
})), true), selectDocEnd = ({ state: e6, dispatch:
|
|
614
|
+
})), true), selectDocEnd = ({ state: e6, dispatch: x }) => (x(setSel(e6, {
|
|
615
615
|
anchor: e6.selection.main.anchor,
|
|
616
616
|
head: e6.doc.length
|
|
617
|
-
})), true), selectAll = ({ state: e6, dispatch:
|
|
617
|
+
})), true), selectAll = ({ state: e6, dispatch: x }) => (x(e6.update({
|
|
618
618
|
selection: {
|
|
619
619
|
anchor: 0,
|
|
620
620
|
head: e6.doc.length
|
|
621
621
|
},
|
|
622
622
|
userEvent: "select"
|
|
623
|
-
})), true), selectLine = ({ state: e6, dispatch:
|
|
624
|
-
let
|
|
625
|
-
return
|
|
626
|
-
selection: EditorSelection.create(
|
|
623
|
+
})), true), selectLine = ({ state: e6, dispatch: x }) => {
|
|
624
|
+
let S = selectedLineBlocks(e6).map(({ from: x2, to: S2 }) => EditorSelection.range(x2, Math.min(S2 + 1, e6.doc.length)));
|
|
625
|
+
return x(e6.update({
|
|
626
|
+
selection: EditorSelection.create(S),
|
|
627
627
|
userEvent: "select"
|
|
628
628
|
})), true;
|
|
629
|
-
}, selectParentSyntax = ({ state: e6, dispatch:
|
|
630
|
-
let
|
|
631
|
-
let
|
|
632
|
-
if (
|
|
633
|
-
let e7 =
|
|
634
|
-
e7.node.from >=
|
|
629
|
+
}, selectParentSyntax = ({ state: e6, dispatch: x }) => {
|
|
630
|
+
let S = updateSel(e6.selection, (x2) => {
|
|
631
|
+
let S2 = syntaxTree(e6), C = S2.resolveStack(x2.from, 1);
|
|
632
|
+
if (x2.empty) {
|
|
633
|
+
let e7 = S2.resolveStack(x2.from, -1);
|
|
634
|
+
e7.node.from >= C.node.from && e7.node.to <= C.node.to && (C = e7);
|
|
635
635
|
}
|
|
636
|
-
for (let e7 =
|
|
637
|
-
let { node:
|
|
638
|
-
if ((
|
|
636
|
+
for (let e7 = C; e7; e7 = e7.next) {
|
|
637
|
+
let { node: S3 } = e7;
|
|
638
|
+
if ((S3.from < x2.from && S3.to >= x2.to || S3.to > x2.to && S3.from <= x2.from) && e7.next) return EditorSelection.range(S3.to, S3.from);
|
|
639
639
|
}
|
|
640
|
-
return
|
|
640
|
+
return x2;
|
|
641
641
|
});
|
|
642
|
-
return
|
|
642
|
+
return S.eq(e6.selection) ? false : (x(setSel(e6, S)), true);
|
|
643
643
|
};
|
|
644
|
-
function addCursorVertically(e6,
|
|
645
|
-
let { state:
|
|
646
|
-
for (let
|
|
647
|
-
let
|
|
648
|
-
if (
|
|
649
|
-
let
|
|
650
|
-
if (
|
|
651
|
-
|
|
644
|
+
function addCursorVertically(e6, x) {
|
|
645
|
+
let { state: S } = e6, C = S.selection, w = S.selection.ranges.slice();
|
|
646
|
+
for (let C2 of S.selection.ranges) {
|
|
647
|
+
let T = S.doc.lineAt(C2.head);
|
|
648
|
+
if (x ? T.to < e6.state.doc.length : T.from > 0) for (let S2 = C2; ; ) {
|
|
649
|
+
let C3 = e6.moveVertically(S2, x);
|
|
650
|
+
if (C3.head < T.from || C3.head > T.to) {
|
|
651
|
+
w.some((e7) => e7.head == C3.head) || w.push(C3);
|
|
652
652
|
break;
|
|
653
|
-
} else if (
|
|
654
|
-
else
|
|
653
|
+
} else if (C3.head == S2.head) break;
|
|
654
|
+
else S2 = C3;
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
return
|
|
657
|
+
return w.length == C.ranges.length ? false : (e6.dispatch(setSel(S, EditorSelection.create(w, w.length - 1))), true);
|
|
658
658
|
}
|
|
659
|
-
var addCursorAbove = (e6) => addCursorVertically(e6, false), addCursorBelow = (e6) => addCursorVertically(e6, true), simplifySelection = ({ state: e6, dispatch:
|
|
660
|
-
let
|
|
661
|
-
return
|
|
659
|
+
var addCursorAbove = (e6) => addCursorVertically(e6, false), addCursorBelow = (e6) => addCursorVertically(e6, true), simplifySelection = ({ state: e6, dispatch: x }) => {
|
|
660
|
+
let S = e6.selection, C = null;
|
|
661
|
+
return S.ranges.length > 1 ? C = EditorSelection.create([S.main]) : S.main.empty || (C = EditorSelection.create([EditorSelection.cursor(S.main.head)])), C ? (x(setSel(e6, C)), true) : false;
|
|
662
662
|
};
|
|
663
|
-
function deleteBy(e6,
|
|
663
|
+
function deleteBy(e6, x) {
|
|
664
664
|
if (e6.state.readOnly) return false;
|
|
665
|
-
let
|
|
666
|
-
let { from:
|
|
667
|
-
if (
|
|
668
|
-
let
|
|
669
|
-
|
|
670
|
-
} else
|
|
671
|
-
return
|
|
665
|
+
let S = "delete.selection", { state: C } = e6, w = C.changeByRange((C2) => {
|
|
666
|
+
let { from: w2, to: T } = C2;
|
|
667
|
+
if (w2 == T) {
|
|
668
|
+
let E = x(C2);
|
|
669
|
+
E < w2 ? (S = "delete.backward", E = skipAtomic(e6, E, false)) : E > w2 && (S = "delete.forward", E = skipAtomic(e6, E, true)), w2 = Math.min(w2, E), T = Math.max(T, E);
|
|
670
|
+
} else w2 = skipAtomic(e6, w2, false), T = skipAtomic(e6, T, true);
|
|
671
|
+
return w2 == T ? { range: C2 } : {
|
|
672
672
|
changes: {
|
|
673
|
-
from:
|
|
674
|
-
to:
|
|
673
|
+
from: w2,
|
|
674
|
+
to: T
|
|
675
675
|
},
|
|
676
|
-
range: EditorSelection.cursor(
|
|
676
|
+
range: EditorSelection.cursor(w2, w2 < C2.head ? -1 : 1)
|
|
677
677
|
};
|
|
678
678
|
});
|
|
679
|
-
return
|
|
679
|
+
return w.changes.empty ? false : (e6.dispatch(C.update(w, {
|
|
680
680
|
scrollIntoView: true,
|
|
681
|
-
userEvent:
|
|
682
|
-
effects:
|
|
681
|
+
userEvent: S,
|
|
682
|
+
effects: S == "delete.selection" ? EditorView.announce.of(C.phrase("Selection deleted")) : void 0
|
|
683
683
|
})), true);
|
|
684
684
|
}
|
|
685
|
-
function skipAtomic(e6,
|
|
686
|
-
if (e6 instanceof EditorView) for (let
|
|
687
|
-
e7 <
|
|
685
|
+
function skipAtomic(e6, x, S) {
|
|
686
|
+
if (e6 instanceof EditorView) for (let C of e6.state.facet(EditorView.atomicRanges).map((x2) => x2(e6))) C.between(x, x, (e7, C2) => {
|
|
687
|
+
e7 < x && C2 > x && (x = S ? C2 : e7);
|
|
688
688
|
});
|
|
689
|
-
return
|
|
689
|
+
return x;
|
|
690
690
|
}
|
|
691
|
-
var deleteByChar = (e6,
|
|
692
|
-
let
|
|
693
|
-
if (
|
|
694
|
-
if (
|
|
695
|
-
let e7 = countColumn(
|
|
696
|
-
for (let
|
|
697
|
-
|
|
698
|
-
} else
|
|
699
|
-
return
|
|
700
|
-
}), deleteCharBackward = (e6) => deleteByChar(e6, false, true), deleteCharForward = (e6) => deleteByChar(e6, true, false), deleteByGroup = (e6,
|
|
701
|
-
let
|
|
691
|
+
var deleteByChar = (e6, x, S) => deleteBy(e6, (C) => {
|
|
692
|
+
let w = C.from, { state: T } = e6, E = T.doc.lineAt(w), D, O;
|
|
693
|
+
if (S && !x && w > E.from && w < E.from + 200 && !/[^ \t]/.test(D = E.text.slice(0, w - E.from))) {
|
|
694
|
+
if (D[D.length - 1] == " ") return w - 1;
|
|
695
|
+
let e7 = countColumn(D, T.tabSize) % getIndentUnit(T) || getIndentUnit(T);
|
|
696
|
+
for (let x2 = 0; x2 < e7 && D[D.length - 1 - x2] == " "; x2++) w--;
|
|
697
|
+
O = w;
|
|
698
|
+
} else O = findClusterBreak(E.text, w - E.from, x, x) + E.from, O == w && E.number != (x ? T.doc.lines : 1) ? O += x ? 1 : -1 : !x && /[\ufe00-\ufe0f]/.test(E.text.slice(O - E.from, w - E.from)) && (O = findClusterBreak(E.text, O - E.from, false, false) + E.from);
|
|
699
|
+
return O;
|
|
700
|
+
}), deleteCharBackward = (e6) => deleteByChar(e6, false, true), deleteCharForward = (e6) => deleteByChar(e6, true, false), deleteByGroup = (e6, x) => deleteBy(e6, (S) => {
|
|
701
|
+
let C = S.head, { state: w } = e6, T = w.doc.lineAt(C), E = w.charCategorizer(C);
|
|
702
702
|
for (let e7 = null; ; ) {
|
|
703
|
-
if (
|
|
704
|
-
|
|
703
|
+
if (C == (x ? T.to : T.from)) {
|
|
704
|
+
C == S.head && T.number != (x ? w.doc.lines : 1) && (C += x ? 1 : -1);
|
|
705
705
|
break;
|
|
706
706
|
}
|
|
707
|
-
let
|
|
708
|
-
if (e7 != null &&
|
|
709
|
-
(
|
|
710
|
-
}
|
|
711
|
-
return
|
|
712
|
-
}), deleteGroupBackward = (e6) => deleteByGroup(e6, false), deleteGroupForward = (e6) => deleteByGroup(e6, true), deleteToLineEnd = (e6) => deleteBy(e6, (
|
|
713
|
-
let
|
|
714
|
-
return
|
|
715
|
-
}), deleteLineBoundaryBackward = (e6) => deleteBy(e6, (
|
|
716
|
-
let
|
|
717
|
-
return
|
|
718
|
-
}), deleteLineBoundaryForward = (e6) => deleteBy(e6, (
|
|
719
|
-
let
|
|
720
|
-
return
|
|
721
|
-
}), splitLine = ({ state: e6, dispatch:
|
|
707
|
+
let D = findClusterBreak(T.text, C - T.from, x) + T.from, O = T.text.slice(Math.min(C, D) - T.from, Math.max(C, D) - T.from), k = E(O);
|
|
708
|
+
if (e7 != null && k != e7) break;
|
|
709
|
+
(O != " " || C != S.head) && (e7 = k), C = D;
|
|
710
|
+
}
|
|
711
|
+
return C;
|
|
712
|
+
}), deleteGroupBackward = (e6) => deleteByGroup(e6, false), deleteGroupForward = (e6) => deleteByGroup(e6, true), deleteToLineEnd = (e6) => deleteBy(e6, (x) => {
|
|
713
|
+
let S = e6.lineBlockAt(x.head).to;
|
|
714
|
+
return x.head < S ? S : Math.min(e6.state.doc.length, x.head + 1);
|
|
715
|
+
}), deleteLineBoundaryBackward = (e6) => deleteBy(e6, (x) => {
|
|
716
|
+
let S = e6.moveToLineBoundary(x, false).head;
|
|
717
|
+
return x.head > S ? S : Math.max(0, x.head - 1);
|
|
718
|
+
}), deleteLineBoundaryForward = (e6) => deleteBy(e6, (x) => {
|
|
719
|
+
let S = e6.moveToLineBoundary(x, true).head;
|
|
720
|
+
return x.head < S ? S : Math.min(e6.state.doc.length, x.head + 1);
|
|
721
|
+
}), splitLine = ({ state: e6, dispatch: x }) => {
|
|
722
722
|
if (e6.readOnly) return false;
|
|
723
|
-
let
|
|
723
|
+
let S = e6.changeByRange((e7) => ({
|
|
724
724
|
changes: {
|
|
725
725
|
from: e7.from,
|
|
726
726
|
to: e7.to,
|
|
@@ -728,203 +728,203 @@ var deleteByChar = (e6, y, b) => deleteBy(e6, (x) => {
|
|
|
728
728
|
},
|
|
729
729
|
range: EditorSelection.cursor(e7.from)
|
|
730
730
|
}));
|
|
731
|
-
return
|
|
731
|
+
return x(e6.update(S, {
|
|
732
732
|
scrollIntoView: true,
|
|
733
733
|
userEvent: "input"
|
|
734
734
|
})), true;
|
|
735
|
-
}, transposeChars = ({ state: e6, dispatch:
|
|
735
|
+
}, transposeChars = ({ state: e6, dispatch: x }) => {
|
|
736
736
|
if (e6.readOnly) return false;
|
|
737
|
-
let
|
|
738
|
-
if (!
|
|
739
|
-
let
|
|
737
|
+
let S = e6.changeByRange((x2) => {
|
|
738
|
+
if (!x2.empty || x2.from == 0 || x2.from == e6.doc.length) return { range: x2 };
|
|
739
|
+
let S2 = x2.from, C = e6.doc.lineAt(S2), w = S2 == C.from ? S2 - 1 : findClusterBreak(C.text, S2 - C.from, false) + C.from, T = S2 == C.to ? S2 + 1 : findClusterBreak(C.text, S2 - C.from, true) + C.from;
|
|
740
740
|
return {
|
|
741
741
|
changes: {
|
|
742
|
-
from:
|
|
743
|
-
to:
|
|
744
|
-
insert: e6.doc.slice(
|
|
742
|
+
from: w,
|
|
743
|
+
to: T,
|
|
744
|
+
insert: e6.doc.slice(S2, T).append(e6.doc.slice(w, S2))
|
|
745
745
|
},
|
|
746
|
-
range: EditorSelection.cursor(
|
|
746
|
+
range: EditorSelection.cursor(T)
|
|
747
747
|
};
|
|
748
748
|
});
|
|
749
|
-
return
|
|
749
|
+
return S.changes.empty ? false : (x(e6.update(S, {
|
|
750
750
|
scrollIntoView: true,
|
|
751
751
|
userEvent: "move.character"
|
|
752
752
|
})), true);
|
|
753
753
|
};
|
|
754
754
|
function selectedLineBlocks(e6) {
|
|
755
|
-
let
|
|
756
|
-
for (let
|
|
757
|
-
let
|
|
758
|
-
if (!
|
|
759
|
-
let e7 =
|
|
760
|
-
e7.to =
|
|
761
|
-
} else
|
|
762
|
-
from:
|
|
763
|
-
to:
|
|
764
|
-
ranges: [
|
|
755
|
+
let x = [], S = -1;
|
|
756
|
+
for (let C of e6.selection.ranges) {
|
|
757
|
+
let w = e6.doc.lineAt(C.from), T = e6.doc.lineAt(C.to);
|
|
758
|
+
if (!C.empty && C.to == T.from && (T = e6.doc.lineAt(C.to - 1)), S >= w.number) {
|
|
759
|
+
let e7 = x[x.length - 1];
|
|
760
|
+
e7.to = T.to, e7.ranges.push(C);
|
|
761
|
+
} else x.push({
|
|
762
|
+
from: w.from,
|
|
763
|
+
to: T.to,
|
|
764
|
+
ranges: [C]
|
|
765
765
|
});
|
|
766
|
-
|
|
766
|
+
S = T.number + 1;
|
|
767
767
|
}
|
|
768
|
-
return
|
|
768
|
+
return x;
|
|
769
769
|
}
|
|
770
|
-
function moveLine(e6,
|
|
770
|
+
function moveLine(e6, x, S) {
|
|
771
771
|
if (e6.readOnly) return false;
|
|
772
|
-
let
|
|
773
|
-
for (let
|
|
774
|
-
if (
|
|
775
|
-
let
|
|
776
|
-
if (
|
|
777
|
-
|
|
778
|
-
from:
|
|
779
|
-
to:
|
|
772
|
+
let C = [], w = [];
|
|
773
|
+
for (let x2 of selectedLineBlocks(e6)) {
|
|
774
|
+
if (S ? x2.to == e6.doc.length : x2.from == 0) continue;
|
|
775
|
+
let T = e6.doc.lineAt(S ? x2.to + 1 : x2.from - 1), E = T.length + 1;
|
|
776
|
+
if (S) {
|
|
777
|
+
C.push({
|
|
778
|
+
from: x2.to,
|
|
779
|
+
to: T.to
|
|
780
780
|
}, {
|
|
781
|
-
from:
|
|
782
|
-
insert:
|
|
781
|
+
from: x2.from,
|
|
782
|
+
insert: T.text + e6.lineBreak
|
|
783
783
|
});
|
|
784
|
-
for (let
|
|
784
|
+
for (let S2 of x2.ranges) w.push(EditorSelection.range(Math.min(e6.doc.length, S2.anchor + E), Math.min(e6.doc.length, S2.head + E)));
|
|
785
785
|
} else {
|
|
786
|
-
|
|
787
|
-
from:
|
|
788
|
-
to:
|
|
786
|
+
C.push({
|
|
787
|
+
from: T.from,
|
|
788
|
+
to: x2.from
|
|
789
789
|
}, {
|
|
790
|
-
from:
|
|
791
|
-
insert: e6.lineBreak +
|
|
790
|
+
from: x2.to,
|
|
791
|
+
insert: e6.lineBreak + T.text
|
|
792
792
|
});
|
|
793
|
-
for (let e7 of
|
|
793
|
+
for (let e7 of x2.ranges) w.push(EditorSelection.range(e7.anchor - E, e7.head - E));
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
|
-
return
|
|
797
|
-
changes:
|
|
796
|
+
return C.length ? (x(e6.update({
|
|
797
|
+
changes: C,
|
|
798
798
|
scrollIntoView: true,
|
|
799
|
-
selection: EditorSelection.create(
|
|
799
|
+
selection: EditorSelection.create(w, e6.selection.mainIndex),
|
|
800
800
|
userEvent: "move.line"
|
|
801
801
|
})), true) : false;
|
|
802
802
|
}
|
|
803
|
-
var moveLineUp = ({ state: e6, dispatch:
|
|
804
|
-
function copyLine(e6,
|
|
803
|
+
var moveLineUp = ({ state: e6, dispatch: x }) => moveLine(e6, x, false), moveLineDown = ({ state: e6, dispatch: x }) => moveLine(e6, x, true);
|
|
804
|
+
function copyLine(e6, x, S) {
|
|
805
805
|
if (e6.readOnly) return false;
|
|
806
|
-
let
|
|
807
|
-
for (let
|
|
808
|
-
from:
|
|
809
|
-
insert: e6.doc.slice(
|
|
810
|
-
}) :
|
|
811
|
-
from:
|
|
812
|
-
insert: e6.lineBreak + e6.doc.slice(
|
|
806
|
+
let C = [];
|
|
807
|
+
for (let x2 of selectedLineBlocks(e6)) S ? C.push({
|
|
808
|
+
from: x2.from,
|
|
809
|
+
insert: e6.doc.slice(x2.from, x2.to) + e6.lineBreak
|
|
810
|
+
}) : C.push({
|
|
811
|
+
from: x2.to,
|
|
812
|
+
insert: e6.lineBreak + e6.doc.slice(x2.from, x2.to)
|
|
813
813
|
});
|
|
814
|
-
return
|
|
815
|
-
changes:
|
|
814
|
+
return x(e6.update({
|
|
815
|
+
changes: C,
|
|
816
816
|
scrollIntoView: true,
|
|
817
817
|
userEvent: "input.copyline"
|
|
818
818
|
})), true;
|
|
819
819
|
}
|
|
820
|
-
var copyLineUp = ({ state: e6, dispatch:
|
|
820
|
+
var copyLineUp = ({ state: e6, dispatch: x }) => copyLine(e6, x, false), copyLineDown = ({ state: e6, dispatch: x }) => copyLine(e6, x, true), deleteLine = (e6) => {
|
|
821
821
|
if (e6.state.readOnly) return false;
|
|
822
|
-
let { state:
|
|
822
|
+
let { state: x } = e6, S = x.changes(selectedLineBlocks(x).map(({ from: e7, to: S2 }) => (e7 > 0 ? e7-- : S2 < x.doc.length && S2++, {
|
|
823
823
|
from: e7,
|
|
824
|
-
to:
|
|
825
|
-
}))),
|
|
826
|
-
let
|
|
824
|
+
to: S2
|
|
825
|
+
}))), C = updateSel(x.selection, (x2) => {
|
|
826
|
+
let S2;
|
|
827
827
|
if (e6.lineWrapping) {
|
|
828
|
-
let
|
|
829
|
-
|
|
828
|
+
let C2 = e6.lineBlockAt(x2.head), w = e6.coordsAtPos(x2.head, x2.assoc || 1);
|
|
829
|
+
w && (S2 = C2.bottom + e6.documentTop - w.bottom + e6.defaultLineHeight / 2);
|
|
830
830
|
}
|
|
831
|
-
return e6.moveVertically(
|
|
832
|
-
}).map(
|
|
831
|
+
return e6.moveVertically(x2, true, S2);
|
|
832
|
+
}).map(S);
|
|
833
833
|
return e6.dispatch({
|
|
834
|
-
changes:
|
|
835
|
-
selection:
|
|
834
|
+
changes: S,
|
|
835
|
+
selection: C,
|
|
836
836
|
scrollIntoView: true,
|
|
837
837
|
userEvent: "delete.line"
|
|
838
838
|
}), true;
|
|
839
839
|
};
|
|
840
|
-
function isBetweenBrackets(e6,
|
|
841
|
-
if (/\(\)|\[\]|\{\}/.test(e6.sliceDoc(
|
|
842
|
-
from:
|
|
843
|
-
to:
|
|
840
|
+
function isBetweenBrackets(e6, x) {
|
|
841
|
+
if (/\(\)|\[\]|\{\}/.test(e6.sliceDoc(x - 1, x + 1))) return {
|
|
842
|
+
from: x,
|
|
843
|
+
to: x
|
|
844
844
|
};
|
|
845
|
-
let
|
|
846
|
-
return
|
|
847
|
-
from:
|
|
848
|
-
to:
|
|
845
|
+
let S = syntaxTree(e6).resolveInner(x), C = S.childBefore(x), w = S.childAfter(x), T;
|
|
846
|
+
return C && w && C.to <= x && w.from >= x && (T = C.type.prop(NodeProp.closedBy)) && T.indexOf(w.name) > -1 && e6.doc.lineAt(C.to).from == e6.doc.lineAt(w.from).from && !/\S/.test(e6.sliceDoc(C.to, w.from)) ? {
|
|
847
|
+
from: C.to,
|
|
848
|
+
to: w.from
|
|
849
849
|
} : null;
|
|
850
850
|
}
|
|
851
851
|
var insertNewlineAndIndent = /* @__PURE__ */ newlineAndIndent(false), insertBlankLine = /* @__PURE__ */ newlineAndIndent(true);
|
|
852
852
|
function newlineAndIndent(e6) {
|
|
853
|
-
return ({ state:
|
|
854
|
-
if (
|
|
855
|
-
let
|
|
856
|
-
let { from:
|
|
857
|
-
e6 && (
|
|
858
|
-
let
|
|
859
|
-
simulateBreak:
|
|
860
|
-
simulateDoubleBreak: !!
|
|
861
|
-
}),
|
|
862
|
-
for (
|
|
863
|
-
|
|
864
|
-
let
|
|
865
|
-
return
|
|
853
|
+
return ({ state: x, dispatch: S }) => {
|
|
854
|
+
if (x.readOnly) return false;
|
|
855
|
+
let C = x.changeByRange((S2) => {
|
|
856
|
+
let { from: C2, to: w } = S2, T = x.doc.lineAt(C2), E = !e6 && C2 == w && isBetweenBrackets(x, C2);
|
|
857
|
+
e6 && (C2 = w = (w <= T.to ? T : x.doc.lineAt(w)).to);
|
|
858
|
+
let D = new IndentContext(x, {
|
|
859
|
+
simulateBreak: C2,
|
|
860
|
+
simulateDoubleBreak: !!E
|
|
861
|
+
}), O = getIndentation(D, C2);
|
|
862
|
+
for (O ?? (O = countColumn(/^\s*/.exec(x.doc.lineAt(C2).text)[0], x.tabSize)); w < T.to && /\s/.test(T.text[w - T.from]); ) w++;
|
|
863
|
+
E ? { from: C2, to: w } = E : C2 > T.from && C2 < T.from + 100 && !/\S/.test(T.text.slice(0, C2)) && (C2 = T.from);
|
|
864
|
+
let k = ["", indentString(x, O)];
|
|
865
|
+
return E && k.push(indentString(x, D.lineIndent(T.from, -1))), {
|
|
866
866
|
changes: {
|
|
867
|
-
from:
|
|
868
|
-
to:
|
|
869
|
-
insert: Text.of(
|
|
867
|
+
from: C2,
|
|
868
|
+
to: w,
|
|
869
|
+
insert: Text.of(k)
|
|
870
870
|
},
|
|
871
|
-
range: EditorSelection.cursor(
|
|
871
|
+
range: EditorSelection.cursor(C2 + 1 + k[1].length)
|
|
872
872
|
};
|
|
873
873
|
});
|
|
874
|
-
return
|
|
874
|
+
return S(x.update(C, {
|
|
875
875
|
scrollIntoView: true,
|
|
876
876
|
userEvent: "input"
|
|
877
877
|
})), true;
|
|
878
878
|
};
|
|
879
879
|
}
|
|
880
|
-
function changeBySelectedLine(e6,
|
|
881
|
-
let
|
|
882
|
-
return e6.changeByRange((
|
|
883
|
-
let
|
|
884
|
-
for (let
|
|
885
|
-
let
|
|
886
|
-
|
|
880
|
+
function changeBySelectedLine(e6, x) {
|
|
881
|
+
let S = -1;
|
|
882
|
+
return e6.changeByRange((C) => {
|
|
883
|
+
let w = [];
|
|
884
|
+
for (let T2 = C.from; T2 <= C.to; ) {
|
|
885
|
+
let E = e6.doc.lineAt(T2);
|
|
886
|
+
E.number > S && (C.empty || C.to > E.from) && (x(E, w, C), S = E.number), T2 = E.to + 1;
|
|
887
887
|
}
|
|
888
|
-
let
|
|
888
|
+
let T = e6.changes(w);
|
|
889
889
|
return {
|
|
890
|
-
changes:
|
|
891
|
-
range: EditorSelection.range(
|
|
890
|
+
changes: w,
|
|
891
|
+
range: EditorSelection.range(T.mapPos(C.anchor, 1), T.mapPos(C.head, 1))
|
|
892
892
|
};
|
|
893
893
|
});
|
|
894
894
|
}
|
|
895
|
-
var indentSelection = ({ state: e6, dispatch:
|
|
895
|
+
var indentSelection = ({ state: e6, dispatch: x }) => {
|
|
896
896
|
if (e6.readOnly) return false;
|
|
897
|
-
let
|
|
898
|
-
let
|
|
899
|
-
if (
|
|
900
|
-
/\S/.test(
|
|
901
|
-
let
|
|
902
|
-
(
|
|
903
|
-
from:
|
|
904
|
-
to:
|
|
905
|
-
insert:
|
|
897
|
+
let S = /* @__PURE__ */ Object.create(null), C = new IndentContext(e6, { overrideIndentation: (e7) => S[e7] ?? -1 }), w = changeBySelectedLine(e6, (x2, w2, T) => {
|
|
898
|
+
let E = getIndentation(C, x2.from);
|
|
899
|
+
if (E == null) return;
|
|
900
|
+
/\S/.test(x2.text) || (E = 0);
|
|
901
|
+
let D = /^\s*/.exec(x2.text)[0], O = indentString(e6, E);
|
|
902
|
+
(D != O || T.from < x2.from + D.length) && (S[x2.from] = E, w2.push({
|
|
903
|
+
from: x2.from,
|
|
904
|
+
to: x2.from + D.length,
|
|
905
|
+
insert: O
|
|
906
906
|
}));
|
|
907
907
|
});
|
|
908
|
-
return
|
|
909
|
-
}, indentMore = ({ state: e6, dispatch:
|
|
910
|
-
|
|
911
|
-
from:
|
|
908
|
+
return w.changes.empty || x(e6.update(w, { userEvent: "indent" })), true;
|
|
909
|
+
}, indentMore = ({ state: e6, dispatch: x }) => e6.readOnly ? false : (x(e6.update(changeBySelectedLine(e6, (x2, S) => {
|
|
910
|
+
S.push({
|
|
911
|
+
from: x2.from,
|
|
912
912
|
insert: e6.facet(indentUnit)
|
|
913
913
|
});
|
|
914
|
-
}), { userEvent: "input.indent" })), true), indentLess = ({ state: e6, dispatch:
|
|
915
|
-
let
|
|
916
|
-
if (!
|
|
917
|
-
let
|
|
918
|
-
for (;
|
|
919
|
-
|
|
920
|
-
from:
|
|
921
|
-
to:
|
|
922
|
-
insert:
|
|
914
|
+
}), { userEvent: "input.indent" })), true), indentLess = ({ state: e6, dispatch: x }) => e6.readOnly ? false : (x(e6.update(changeBySelectedLine(e6, (x2, S) => {
|
|
915
|
+
let C = /^\s*/.exec(x2.text)[0];
|
|
916
|
+
if (!C) return;
|
|
917
|
+
let w = countColumn(C, e6.tabSize), T = 0, E = indentString(e6, Math.max(0, w - getIndentUnit(e6)));
|
|
918
|
+
for (; T < C.length && T < E.length && C.charCodeAt(T) == E.charCodeAt(T); ) T++;
|
|
919
|
+
S.push({
|
|
920
|
+
from: x2.from + T,
|
|
921
|
+
to: x2.from + C.length,
|
|
922
|
+
insert: E.slice(T)
|
|
923
923
|
});
|
|
924
|
-
}), { userEvent: "delete.dedent" })), true), toggleTabFocusMode = (e6) => (e6.setTabFocusMode(), true), insertTab = ({ state: e6, dispatch:
|
|
924
|
+
}), { userEvent: "delete.dedent" })), true), toggleTabFocusMode = (e6) => (e6.setTabFocusMode(), true), insertTab = ({ state: e6, dispatch: x }) => e6.selection.ranges.some((e7) => !e7.empty) ? indentMore({
|
|
925
925
|
state: e6,
|
|
926
|
-
dispatch:
|
|
927
|
-
}) : (
|
|
926
|
+
dispatch: x
|
|
927
|
+
}) : (x(e6.update(e6.replaceSelection(" "), {
|
|
928
928
|
scrollIntoView: true,
|
|
929
929
|
userEvent: "input"
|
|
930
930
|
})), true), emacsStyleKeymap = [
|
|
@@ -1229,11 +1229,11 @@ var indentSelection = ({ state: e6, dispatch: y }) => {
|
|
|
1229
1229
|
run: indentMore,
|
|
1230
1230
|
shift: indentLess
|
|
1231
1231
|
}, basicNormalize = typeof String.prototype.normalize == "function" ? (e6) => e6.normalize("NFKD") : (e6) => e6, SearchCursor = class {
|
|
1232
|
-
constructor(e6,
|
|
1233
|
-
this.test =
|
|
1232
|
+
constructor(e6, x, S = 0, C = e6.length, w, T) {
|
|
1233
|
+
this.test = T, this.value = {
|
|
1234
1234
|
from: 0,
|
|
1235
1235
|
to: 0
|
|
1236
|
-
}, this.done = false, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e6.iterRange(
|
|
1236
|
+
}, this.done = false, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e6.iterRange(S, C), this.bufferStart = S, this.normalize = w ? (e7) => w(basicNormalize(e7)) : basicNormalize, this.query = this.normalize(x);
|
|
1237
1237
|
}
|
|
1238
1238
|
peek() {
|
|
1239
1239
|
if (this.bufferPos == this.buffer.length) {
|
|
@@ -1250,32 +1250,32 @@ var indentSelection = ({ state: e6, dispatch: y }) => {
|
|
|
1250
1250
|
for (; ; ) {
|
|
1251
1251
|
let e6 = this.peek();
|
|
1252
1252
|
if (e6 < 0) return this.done = true, this;
|
|
1253
|
-
let
|
|
1253
|
+
let x = fromCodePoint(e6), S = this.bufferStart + this.bufferPos;
|
|
1254
1254
|
this.bufferPos += codePointSize(e6);
|
|
1255
|
-
let
|
|
1256
|
-
if (
|
|
1257
|
-
let
|
|
1258
|
-
if (e7 ==
|
|
1259
|
-
if (
|
|
1255
|
+
let C = this.normalize(x);
|
|
1256
|
+
if (C.length) for (let e7 = 0, w = S; ; e7++) {
|
|
1257
|
+
let T = C.charCodeAt(e7), E = this.match(T, w, this.bufferPos + this.bufferStart);
|
|
1258
|
+
if (e7 == C.length - 1) {
|
|
1259
|
+
if (E) return this.value = E, this;
|
|
1260
1260
|
break;
|
|
1261
1261
|
}
|
|
1262
|
-
|
|
1262
|
+
w == S && e7 < x.length && x.charCodeAt(e7) == T && w++;
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
|
-
match(e6,
|
|
1267
|
-
let
|
|
1268
|
-
for (let
|
|
1269
|
-
let
|
|
1270
|
-
this.query.charCodeAt(
|
|
1271
|
-
from: this.matches[
|
|
1272
|
-
to:
|
|
1273
|
-
} : (this.matches[
|
|
1266
|
+
match(e6, x, S) {
|
|
1267
|
+
let C = null;
|
|
1268
|
+
for (let x2 = 0; x2 < this.matches.length; x2 += 2) {
|
|
1269
|
+
let w = this.matches[x2], T = false;
|
|
1270
|
+
this.query.charCodeAt(w) == e6 && (w == this.query.length - 1 ? C = {
|
|
1271
|
+
from: this.matches[x2 + 1],
|
|
1272
|
+
to: S
|
|
1273
|
+
} : (this.matches[x2]++, T = true)), T || (this.matches.splice(x2, 2), x2 -= 2);
|
|
1274
1274
|
}
|
|
1275
|
-
return this.query.charCodeAt(0) == e6 && (this.query.length == 1 ?
|
|
1276
|
-
from:
|
|
1277
|
-
to:
|
|
1278
|
-
} : this.matches.push(1,
|
|
1275
|
+
return this.query.charCodeAt(0) == e6 && (this.query.length == 1 ? C = {
|
|
1276
|
+
from: x,
|
|
1277
|
+
to: S
|
|
1278
|
+
} : this.matches.push(1, x)), C && this.test && !this.test(C.from, C.to, this.buffer, this.bufferStart) && (C = null), C;
|
|
1279
1279
|
}
|
|
1280
1280
|
};
|
|
1281
1281
|
typeof Symbol < "u" && (SearchCursor.prototype[Symbol.iterator] = function() {
|
|
@@ -1286,9 +1286,9 @@ var empty = {
|
|
|
1286
1286
|
to: -1,
|
|
1287
1287
|
match: /* @__PURE__ */ /.*/.exec("")
|
|
1288
1288
|
}, baseFlags = "gm" + (/x/.unicode == null ? "" : "u"), RegExpCursor = class {
|
|
1289
|
-
constructor(e6,
|
|
1290
|
-
if (this.text = e6, this.to =
|
|
1291
|
-
this.re = new RegExp(
|
|
1289
|
+
constructor(e6, x, S, C = 0, w = e6.length) {
|
|
1290
|
+
if (this.text = e6, this.to = w, this.curLine = "", this.done = false, this.value = empty, /\\[sWDnr]|\n|\r|\[\^/.test(x)) return new MultilineRegExpCursor(e6, x, S, C, w);
|
|
1291
|
+
this.re = new RegExp(x, baseFlags + ((S == null ? void 0 : S.ignoreCase) ? "i" : "")), this.test = S == null ? void 0 : S.test, this.iter = e6.iter(), this.curLineStart = e6.lineAt(C).from, this.matchPos = toCharEnd(e6, C), this.getLine(this.curLineStart);
|
|
1292
1292
|
}
|
|
1293
1293
|
getLine(e6) {
|
|
1294
1294
|
this.iter.next(e6), this.iter.lineBreak ? this.curLine = "" : (this.curLine = this.iter.value, this.curLineStart + this.curLine.length > this.to && (this.curLine = this.curLine.slice(0, this.to - this.curLineStart)), this.iter.next());
|
|
@@ -1299,13 +1299,13 @@ var empty = {
|
|
|
1299
1299
|
next() {
|
|
1300
1300
|
for (let e6 = this.matchPos - this.curLineStart; ; ) {
|
|
1301
1301
|
this.re.lastIndex = e6;
|
|
1302
|
-
let
|
|
1303
|
-
if (
|
|
1304
|
-
let
|
|
1305
|
-
if (this.matchPos = toCharEnd(this.text,
|
|
1306
|
-
from:
|
|
1307
|
-
to:
|
|
1308
|
-
match:
|
|
1302
|
+
let x = this.matchPos <= this.to && this.re.exec(this.curLine);
|
|
1303
|
+
if (x) {
|
|
1304
|
+
let S = this.curLineStart + x.index, C = S + x[0].length;
|
|
1305
|
+
if (this.matchPos = toCharEnd(this.text, C + (S == C ? 1 : 0)), S == this.curLineStart + this.curLine.length && this.nextLine(), (S < C || S > this.value.to) && (!this.test || this.test(S, C, x))) return this.value = {
|
|
1306
|
+
from: S,
|
|
1307
|
+
to: C,
|
|
1308
|
+
match: x
|
|
1309
1309
|
}, this;
|
|
1310
1310
|
e6 = this.matchPos - this.curLineStart;
|
|
1311
1311
|
} else if (this.curLineStart + this.curLine.length < this.to) this.nextLine(), e6 = 0;
|
|
@@ -1313,39 +1313,39 @@ var empty = {
|
|
|
1313
1313
|
}
|
|
1314
1314
|
}
|
|
1315
1315
|
}, flattened = /* @__PURE__ */ new WeakMap(), FlattenedDoc = class e3 {
|
|
1316
|
-
constructor(e6,
|
|
1317
|
-
this.from = e6, this.text =
|
|
1316
|
+
constructor(e6, x) {
|
|
1317
|
+
this.from = e6, this.text = x;
|
|
1318
1318
|
}
|
|
1319
1319
|
get to() {
|
|
1320
1320
|
return this.from + this.text.length;
|
|
1321
1321
|
}
|
|
1322
|
-
static get(
|
|
1323
|
-
let
|
|
1324
|
-
if (!
|
|
1325
|
-
let
|
|
1326
|
-
return flattened.set(
|
|
1322
|
+
static get(x, S, C) {
|
|
1323
|
+
let w = flattened.get(x);
|
|
1324
|
+
if (!w || w.from >= C || w.to <= S) {
|
|
1325
|
+
let w2 = new e3(S, x.sliceString(S, C));
|
|
1326
|
+
return flattened.set(x, w2), w2;
|
|
1327
1327
|
}
|
|
1328
|
-
if (
|
|
1329
|
-
let { text:
|
|
1330
|
-
return
|
|
1328
|
+
if (w.from == S && w.to == C) return w;
|
|
1329
|
+
let { text: T, from: E } = w;
|
|
1330
|
+
return E > S && (T = x.sliceString(S, E) + T, E = S), w.to < C && (T += x.sliceString(w.to, C)), flattened.set(x, new e3(E, T)), new e3(S, T.slice(S - E, C - E));
|
|
1331
1331
|
}
|
|
1332
1332
|
}, MultilineRegExpCursor = class {
|
|
1333
|
-
constructor(e6,
|
|
1334
|
-
this.text = e6, this.to =
|
|
1333
|
+
constructor(e6, x, S, C, w) {
|
|
1334
|
+
this.text = e6, this.to = w, this.done = false, this.value = empty, this.matchPos = toCharEnd(e6, C), this.re = new RegExp(x, baseFlags + ((S == null ? void 0 : S.ignoreCase) ? "i" : "")), this.test = S == null ? void 0 : S.test, this.flat = FlattenedDoc.get(e6, C, this.chunkEnd(C + 5e3));
|
|
1335
1335
|
}
|
|
1336
1336
|
chunkEnd(e6) {
|
|
1337
1337
|
return e6 >= this.to ? this.to : this.text.lineAt(e6).to;
|
|
1338
1338
|
}
|
|
1339
1339
|
next() {
|
|
1340
1340
|
for (; ; ) {
|
|
1341
|
-
let e6 = this.re.lastIndex = this.matchPos - this.flat.from,
|
|
1342
|
-
if (
|
|
1343
|
-
let e7 = this.flat.from +
|
|
1344
|
-
if ((this.flat.to >= this.to ||
|
|
1341
|
+
let e6 = this.re.lastIndex = this.matchPos - this.flat.from, x = this.re.exec(this.flat.text);
|
|
1342
|
+
if (x && !x[0] && x.index == e6 && (this.re.lastIndex = e6 + 1, x = this.re.exec(this.flat.text)), x) {
|
|
1343
|
+
let e7 = this.flat.from + x.index, S = e7 + x[0].length;
|
|
1344
|
+
if ((this.flat.to >= this.to || x.index + x[0].length <= this.flat.text.length - 10) && (!this.test || this.test(e7, S, x))) return this.value = {
|
|
1345
1345
|
from: e7,
|
|
1346
|
-
to:
|
|
1347
|
-
match:
|
|
1348
|
-
}, this.matchPos = toCharEnd(this.text,
|
|
1346
|
+
to: S,
|
|
1347
|
+
match: x
|
|
1348
|
+
}, this.matchPos = toCharEnd(this.text, S + (e7 == S ? 1 : 0)), this;
|
|
1349
1349
|
}
|
|
1350
1350
|
if (this.flat.to == this.to) return this.done = true, this;
|
|
1351
1351
|
this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
@@ -1362,26 +1362,26 @@ function validRegExp(e6) {
|
|
|
1362
1362
|
return false;
|
|
1363
1363
|
}
|
|
1364
1364
|
}
|
|
1365
|
-
function toCharEnd(e6,
|
|
1366
|
-
if (
|
|
1367
|
-
let
|
|
1368
|
-
for (;
|
|
1369
|
-
return
|
|
1365
|
+
function toCharEnd(e6, x) {
|
|
1366
|
+
if (x >= e6.length) return x;
|
|
1367
|
+
let S = e6.lineAt(x), C;
|
|
1368
|
+
for (; x < S.to && (C = S.text.charCodeAt(x - S.from)) >= 56320 && C < 57344; ) x++;
|
|
1369
|
+
return x;
|
|
1370
1370
|
}
|
|
1371
1371
|
function createLineDialog(e6) {
|
|
1372
|
-
let
|
|
1372
|
+
let x = crelt("input", {
|
|
1373
1373
|
class: "cm-textfield",
|
|
1374
1374
|
name: "line",
|
|
1375
1375
|
value: String(e6.state.doc.lineAt(e6.state.selection.main.head).number)
|
|
1376
|
-
}),
|
|
1376
|
+
}), S = crelt("form", {
|
|
1377
1377
|
class: "cm-gotoLine",
|
|
1378
|
-
onkeydown: (
|
|
1379
|
-
|
|
1378
|
+
onkeydown: (x2) => {
|
|
1379
|
+
x2.keyCode == 27 ? (x2.preventDefault(), e6.dispatch({ effects: dialogEffect.of(false) }), e6.focus()) : x2.keyCode == 13 && (x2.preventDefault(), C());
|
|
1380
1380
|
},
|
|
1381
1381
|
onsubmit: (e7) => {
|
|
1382
|
-
e7.preventDefault(),
|
|
1382
|
+
e7.preventDefault(), C();
|
|
1383
1383
|
}
|
|
1384
|
-
}, crelt("label", e6.state.phrase("Go to line"), ": ",
|
|
1384
|
+
}, crelt("label", e6.state.phrase("Go to line"), ": ", x), " ", crelt("button", {
|
|
1385
1385
|
class: "cm-button",
|
|
1386
1386
|
type: "submit"
|
|
1387
1387
|
}, e6.state.phrase("go")), crelt("button", {
|
|
@@ -1392,38 +1392,38 @@ function createLineDialog(e6) {
|
|
|
1392
1392
|
"aria-label": e6.state.phrase("close"),
|
|
1393
1393
|
type: "button"
|
|
1394
1394
|
}, ["\xD7"]));
|
|
1395
|
-
function
|
|
1396
|
-
let
|
|
1397
|
-
if (!
|
|
1398
|
-
let { state:
|
|
1399
|
-
if (
|
|
1400
|
-
let e7 =
|
|
1401
|
-
|
|
1402
|
-
} else
|
|
1403
|
-
let
|
|
1395
|
+
function C() {
|
|
1396
|
+
let S2 = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(x.value);
|
|
1397
|
+
if (!S2) return;
|
|
1398
|
+
let { state: C2 } = e6, w = C2.doc.lineAt(C2.selection.main.head), [, T, E, D, O] = S2, k = D ? +D.slice(1) : 0, A = E ? +E : w.number;
|
|
1399
|
+
if (E && O) {
|
|
1400
|
+
let e7 = A / 100;
|
|
1401
|
+
T && (e7 = e7 * (T == "-" ? -1 : 1) + w.number / C2.doc.lines), A = Math.round(C2.doc.lines * e7);
|
|
1402
|
+
} else E && T && (A = A * (T == "-" ? -1 : 1) + w.number);
|
|
1403
|
+
let j = C2.doc.line(Math.max(1, Math.min(C2.doc.lines, A))), M = EditorSelection.cursor(j.from + Math.max(0, Math.min(k, j.length)));
|
|
1404
1404
|
e6.dispatch({
|
|
1405
|
-
effects: [dialogEffect.of(false), EditorView.scrollIntoView(
|
|
1406
|
-
selection:
|
|
1405
|
+
effects: [dialogEffect.of(false), EditorView.scrollIntoView(M.from, { y: "center" })],
|
|
1406
|
+
selection: M
|
|
1407
1407
|
}), e6.focus();
|
|
1408
1408
|
}
|
|
1409
|
-
return { dom:
|
|
1409
|
+
return { dom: S };
|
|
1410
1410
|
}
|
|
1411
1411
|
var dialogEffect = /* @__PURE__ */ StateEffect.define(), dialogField = /* @__PURE__ */ StateField.define({
|
|
1412
1412
|
create() {
|
|
1413
1413
|
return true;
|
|
1414
1414
|
},
|
|
1415
|
-
update(e6,
|
|
1416
|
-
for (let
|
|
1415
|
+
update(e6, x) {
|
|
1416
|
+
for (let S of x.effects) S.is(dialogEffect) && (e6 = S.value);
|
|
1417
1417
|
return e6;
|
|
1418
1418
|
},
|
|
1419
1419
|
provide: (e6) => showPanel.from(e6, (e7) => e7 ? createLineDialog : null)
|
|
1420
1420
|
}), gotoLine = (e6) => {
|
|
1421
|
-
let
|
|
1422
|
-
if (!
|
|
1423
|
-
let
|
|
1424
|
-
e6.state.field(dialogField, false) ??
|
|
1421
|
+
let x = getPanel(e6, createLineDialog);
|
|
1422
|
+
if (!x) {
|
|
1423
|
+
let S = [dialogEffect.of(true)];
|
|
1424
|
+
e6.state.field(dialogField, false) ?? S.push(StateEffect.appendConfig.of([dialogField, baseTheme$1])), e6.dispatch({ effects: S }), x = getPanel(e6, createLineDialog);
|
|
1425
1425
|
}
|
|
1426
|
-
return
|
|
1426
|
+
return x && x.dom.querySelector("input").select(), true;
|
|
1427
1427
|
}, baseTheme$1 = /* @__PURE__ */ EditorView.baseTheme({ ".cm-panel.cm-gotoLine": {
|
|
1428
1428
|
padding: "2px 6px 4px",
|
|
1429
1429
|
position: "relative",
|
|
@@ -1445,21 +1445,21 @@ var dialogEffect = /* @__PURE__ */ StateEffect.define(), dialogField = /* @__PUR
|
|
|
1445
1445
|
wholeWords: false
|
|
1446
1446
|
}, highlightConfig = /* @__PURE__ */ Facet.define({ combine(e6) {
|
|
1447
1447
|
return combineConfig(e6, defaultHighlightOptions, {
|
|
1448
|
-
highlightWordAroundCursor: (e7,
|
|
1448
|
+
highlightWordAroundCursor: (e7, x) => e7 || x,
|
|
1449
1449
|
minSelectionLength: Math.min,
|
|
1450
1450
|
maxMatches: Math.min
|
|
1451
1451
|
});
|
|
1452
1452
|
} });
|
|
1453
1453
|
function highlightSelectionMatches(e6) {
|
|
1454
|
-
let
|
|
1455
|
-
return e6 &&
|
|
1454
|
+
let x = [defaultTheme, matchHighlighter];
|
|
1455
|
+
return e6 && x.push(highlightConfig.of(e6)), x;
|
|
1456
1456
|
}
|
|
1457
1457
|
var matchDeco = /* @__PURE__ */ Decoration.mark({ class: "cm-selectionMatch" }), mainMatchDeco = /* @__PURE__ */ Decoration.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
|
|
1458
|
-
function insideWordBoundaries(e6,
|
|
1459
|
-
return (
|
|
1458
|
+
function insideWordBoundaries(e6, x, S, C) {
|
|
1459
|
+
return (S == 0 || e6(x.sliceDoc(S - 1, S)) != CharCategory.Word) && (C == x.doc.length || e6(x.sliceDoc(C, C + 1)) != CharCategory.Word);
|
|
1460
1460
|
}
|
|
1461
|
-
function insideWord(e6,
|
|
1462
|
-
return e6(
|
|
1461
|
+
function insideWord(e6, x, S, C) {
|
|
1462
|
+
return e6(x.sliceDoc(S, S + 1)) == CharCategory.Word && e6(x.sliceDoc(C - 1, C)) == CharCategory.Word;
|
|
1463
1463
|
}
|
|
1464
1464
|
var matchHighlighter = /* @__PURE__ */ ViewPlugin.fromClass(class {
|
|
1465
1465
|
constructor(e6) {
|
|
@@ -1469,64 +1469,64 @@ var matchHighlighter = /* @__PURE__ */ ViewPlugin.fromClass(class {
|
|
|
1469
1469
|
(e6.selectionSet || e6.docChanged || e6.viewportChanged) && (this.decorations = this.getDeco(e6.view));
|
|
1470
1470
|
}
|
|
1471
1471
|
getDeco(e6) {
|
|
1472
|
-
let
|
|
1473
|
-
if (
|
|
1474
|
-
let
|
|
1475
|
-
if (
|
|
1476
|
-
if (!
|
|
1477
|
-
let e7 =
|
|
1472
|
+
let x = e6.state.facet(highlightConfig), { state: S } = e6, C = S.selection;
|
|
1473
|
+
if (C.ranges.length > 1) return Decoration.none;
|
|
1474
|
+
let w = C.main, T, E = null;
|
|
1475
|
+
if (w.empty) {
|
|
1476
|
+
if (!x.highlightWordAroundCursor) return Decoration.none;
|
|
1477
|
+
let e7 = S.wordAt(w.head);
|
|
1478
1478
|
if (!e7) return Decoration.none;
|
|
1479
|
-
|
|
1479
|
+
E = S.charCategorizer(w.head), T = S.sliceDoc(e7.from, e7.to);
|
|
1480
1480
|
} else {
|
|
1481
|
-
let e7 =
|
|
1482
|
-
if (e7 <
|
|
1483
|
-
if (
|
|
1484
|
-
if (
|
|
1485
|
-
} else if (
|
|
1481
|
+
let e7 = w.to - w.from;
|
|
1482
|
+
if (e7 < x.minSelectionLength || e7 > 200) return Decoration.none;
|
|
1483
|
+
if (x.wholeWords) {
|
|
1484
|
+
if (T = S.sliceDoc(w.from, w.to), E = S.charCategorizer(w.head), !(insideWordBoundaries(E, S, w.from, w.to) && insideWord(E, S, w.from, w.to))) return Decoration.none;
|
|
1485
|
+
} else if (T = S.sliceDoc(w.from, w.to), !T) return Decoration.none;
|
|
1486
1486
|
}
|
|
1487
|
-
let
|
|
1488
|
-
for (let
|
|
1489
|
-
let e7 = new SearchCursor(
|
|
1487
|
+
let D = [];
|
|
1488
|
+
for (let C2 of e6.visibleRanges) {
|
|
1489
|
+
let e7 = new SearchCursor(S.doc, T, C2.from, C2.to);
|
|
1490
1490
|
for (; !e7.next().done; ) {
|
|
1491
|
-
let { from:
|
|
1492
|
-
if ((!
|
|
1491
|
+
let { from: C3, to: T2 } = e7.value;
|
|
1492
|
+
if ((!E || insideWordBoundaries(E, S, C3, T2)) && (w.empty && C3 <= w.from && T2 >= w.to ? D.push(mainMatchDeco.range(C3, T2)) : (C3 >= w.to || T2 <= w.from) && D.push(matchDeco.range(C3, T2)), D.length > x.maxMatches)) return Decoration.none;
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
return Decoration.set(
|
|
1495
|
+
return Decoration.set(D);
|
|
1496
1496
|
}
|
|
1497
1497
|
}, { decorations: (e6) => e6.decorations }), defaultTheme = /* @__PURE__ */ EditorView.baseTheme({
|
|
1498
1498
|
".cm-selectionMatch": { backgroundColor: "#99ff7780" },
|
|
1499
1499
|
".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
|
|
1500
|
-
}), selectWord = ({ state: e6, dispatch:
|
|
1501
|
-
let { selection:
|
|
1502
|
-
return
|
|
1500
|
+
}), selectWord = ({ state: e6, dispatch: x }) => {
|
|
1501
|
+
let { selection: S } = e6, C = EditorSelection.create(S.ranges.map((x2) => e6.wordAt(x2.head) || EditorSelection.cursor(x2.head)), S.mainIndex);
|
|
1502
|
+
return C.eq(S) ? false : (x(e6.update({ selection: C })), true);
|
|
1503
1503
|
};
|
|
1504
|
-
function findNextOccurrence(e6,
|
|
1505
|
-
let { main:
|
|
1506
|
-
for (let
|
|
1507
|
-
if (
|
|
1508
|
-
|
|
1504
|
+
function findNextOccurrence(e6, x) {
|
|
1505
|
+
let { main: S, ranges: C } = e6.selection, w = e6.wordAt(S.head), T = w && w.from == S.from && w.to == S.to;
|
|
1506
|
+
for (let S2 = false, w2 = new SearchCursor(e6.doc, x, C[C.length - 1].to); ; ) if (w2.next(), w2.done) {
|
|
1507
|
+
if (S2) return null;
|
|
1508
|
+
w2 = new SearchCursor(e6.doc, x, 0, Math.max(0, C[C.length - 1].from - 1)), S2 = true;
|
|
1509
1509
|
} else {
|
|
1510
|
-
if (
|
|
1511
|
-
if (
|
|
1512
|
-
let
|
|
1513
|
-
if (!
|
|
1510
|
+
if (S2 && C.some((e7) => e7.from == w2.value.from)) continue;
|
|
1511
|
+
if (T) {
|
|
1512
|
+
let x2 = e6.wordAt(w2.value.from);
|
|
1513
|
+
if (!x2 || x2.from != w2.value.from || x2.to != w2.value.to) continue;
|
|
1514
1514
|
}
|
|
1515
|
-
return
|
|
1515
|
+
return w2.value;
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
var selectNextOccurrence = ({ state: e6, dispatch:
|
|
1519
|
-
let { ranges:
|
|
1520
|
-
if (
|
|
1518
|
+
var selectNextOccurrence = ({ state: e6, dispatch: x }) => {
|
|
1519
|
+
let { ranges: S } = e6.selection;
|
|
1520
|
+
if (S.some((e7) => e7.from === e7.to)) return selectWord({
|
|
1521
1521
|
state: e6,
|
|
1522
|
-
dispatch:
|
|
1522
|
+
dispatch: x
|
|
1523
1523
|
});
|
|
1524
|
-
let
|
|
1525
|
-
if (e6.selection.ranges.some((
|
|
1526
|
-
let
|
|
1527
|
-
return
|
|
1528
|
-
selection: e6.selection.addRange(EditorSelection.range(
|
|
1529
|
-
effects: EditorView.scrollIntoView(
|
|
1524
|
+
let C = e6.sliceDoc(S[0].from, S[0].to);
|
|
1525
|
+
if (e6.selection.ranges.some((x2) => e6.sliceDoc(x2.from, x2.to) != C)) return false;
|
|
1526
|
+
let w = findNextOccurrence(e6, C);
|
|
1527
|
+
return w ? (x(e6.update({
|
|
1528
|
+
selection: e6.selection.addRange(EditorSelection.range(w.from, w.to), false),
|
|
1529
|
+
effects: EditorView.scrollIntoView(w.to)
|
|
1530
1530
|
})), true) : false;
|
|
1531
1531
|
}, searchConfigFacet = /* @__PURE__ */ Facet.define({ combine(e6) {
|
|
1532
1532
|
return combineConfig(e6, {
|
|
@@ -1543,7 +1543,7 @@ var selectNextOccurrence = ({ state: e6, dispatch: y }) => {
|
|
|
1543
1543
|
this.search = e6.search, this.caseSensitive = !!e6.caseSensitive, this.literal = !!e6.literal, this.regexp = !!e6.regexp, this.replace = e6.replace || "", this.valid = !!this.search && (!this.regexp || validRegExp(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e6.wholeWord;
|
|
1544
1544
|
}
|
|
1545
1545
|
unquote(e6) {
|
|
1546
|
-
return this.literal ? e6 : e6.replace(/\\([nrt\\])/g, (e7,
|
|
1546
|
+
return this.literal ? e6 : e6.replace(/\\([nrt\\])/g, (e7, x) => x == "n" ? "\n" : x == "r" ? "\r" : x == "t" ? " " : "\\");
|
|
1547
1547
|
}
|
|
1548
1548
|
eq(e6) {
|
|
1549
1549
|
return this.search == e6.search && this.replace == e6.replace && this.caseSensitive == e6.caseSensitive && this.regexp == e6.regexp && this.wholeWord == e6.wholeWord;
|
|
@@ -1551,267 +1551,267 @@ var selectNextOccurrence = ({ state: e6, dispatch: y }) => {
|
|
|
1551
1551
|
create() {
|
|
1552
1552
|
return this.regexp ? new RegExpQuery(this) : new StringQuery(this);
|
|
1553
1553
|
}
|
|
1554
|
-
getCursor(e6,
|
|
1555
|
-
let
|
|
1556
|
-
return
|
|
1554
|
+
getCursor(e6, x = 0, S) {
|
|
1555
|
+
let C = e6.doc ? e6 : EditorState.create({ doc: e6 });
|
|
1556
|
+
return S ?? (S = C.doc.length), this.regexp ? regexpCursor(this, C, x, S) : stringCursor(this, C, x, S);
|
|
1557
1557
|
}
|
|
1558
1558
|
}, QueryType = class {
|
|
1559
1559
|
constructor(e6) {
|
|
1560
1560
|
this.spec = e6;
|
|
1561
1561
|
}
|
|
1562
1562
|
};
|
|
1563
|
-
function stringCursor(e6,
|
|
1564
|
-
return new SearchCursor(
|
|
1563
|
+
function stringCursor(e6, x, S, C) {
|
|
1564
|
+
return new SearchCursor(x.doc, e6.unquoted, S, C, e6.caseSensitive ? void 0 : (e7) => e7.toLowerCase(), e6.wholeWord ? stringWordTest(x.doc, x.charCategorizer(x.selection.main.head)) : void 0);
|
|
1565
1565
|
}
|
|
1566
|
-
function stringWordTest(e6,
|
|
1567
|
-
return (
|
|
1566
|
+
function stringWordTest(e6, x) {
|
|
1567
|
+
return (S, C, w, T) => ((T > S || T + w.length < C) && (T = Math.max(0, S - 2), w = e6.sliceString(T, Math.min(e6.length, C + 2))), (x(charBefore(w, S - T)) != CharCategory.Word || x(charAfter(w, S - T)) != CharCategory.Word) && (x(charAfter(w, C - T)) != CharCategory.Word || x(charBefore(w, C - T)) != CharCategory.Word));
|
|
1568
1568
|
}
|
|
1569
1569
|
var StringQuery = class extends QueryType {
|
|
1570
1570
|
constructor(e6) {
|
|
1571
1571
|
super(e6);
|
|
1572
1572
|
}
|
|
1573
|
-
nextMatch(e6,
|
|
1574
|
-
let
|
|
1575
|
-
if (
|
|
1576
|
-
let
|
|
1577
|
-
|
|
1573
|
+
nextMatch(e6, x, S) {
|
|
1574
|
+
let C = stringCursor(this.spec, e6, S, e6.doc.length).nextOverlapping();
|
|
1575
|
+
if (C.done) {
|
|
1576
|
+
let S2 = Math.min(e6.doc.length, x + this.spec.unquoted.length);
|
|
1577
|
+
C = stringCursor(this.spec, e6, 0, S2).nextOverlapping();
|
|
1578
1578
|
}
|
|
1579
|
-
return
|
|
1580
|
-
}
|
|
1581
|
-
prevMatchInRange(e6,
|
|
1582
|
-
for (let
|
|
1583
|
-
let
|
|
1584
|
-
for (; !
|
|
1585
|
-
if (
|
|
1586
|
-
if (
|
|
1587
|
-
|
|
1579
|
+
return C.done || C.value.from == x && C.value.to == S ? null : C.value;
|
|
1580
|
+
}
|
|
1581
|
+
prevMatchInRange(e6, x, S) {
|
|
1582
|
+
for (let C = S; ; ) {
|
|
1583
|
+
let S2 = Math.max(x, C - 1e4 - this.spec.unquoted.length), w = stringCursor(this.spec, e6, S2, C), T = null;
|
|
1584
|
+
for (; !w.nextOverlapping().done; ) T = w.value;
|
|
1585
|
+
if (T) return T;
|
|
1586
|
+
if (S2 == x) return null;
|
|
1587
|
+
C -= 1e4;
|
|
1588
1588
|
}
|
|
1589
1589
|
}
|
|
1590
|
-
prevMatch(e6,
|
|
1591
|
-
let
|
|
1592
|
-
return
|
|
1590
|
+
prevMatch(e6, x, S) {
|
|
1591
|
+
let C = this.prevMatchInRange(e6, 0, x);
|
|
1592
|
+
return C || (C = this.prevMatchInRange(e6, Math.max(0, S - this.spec.unquoted.length), e6.doc.length)), C && (C.from != x || C.to != S) ? C : null;
|
|
1593
1593
|
}
|
|
1594
1594
|
getReplacement(e6) {
|
|
1595
1595
|
return this.spec.unquote(this.spec.replace);
|
|
1596
1596
|
}
|
|
1597
|
-
matchAll(e6,
|
|
1598
|
-
let
|
|
1599
|
-
for (; !
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
1597
|
+
matchAll(e6, x) {
|
|
1598
|
+
let S = stringCursor(this.spec, e6, 0, e6.doc.length), C = [];
|
|
1599
|
+
for (; !S.next().done; ) {
|
|
1600
|
+
if (C.length >= x) return null;
|
|
1601
|
+
C.push(S.value);
|
|
1602
1602
|
}
|
|
1603
|
-
return
|
|
1603
|
+
return C;
|
|
1604
1604
|
}
|
|
1605
|
-
highlight(e6,
|
|
1606
|
-
let
|
|
1607
|
-
for (; !
|
|
1605
|
+
highlight(e6, x, S, C) {
|
|
1606
|
+
let w = stringCursor(this.spec, e6, Math.max(0, x - this.spec.unquoted.length), Math.min(S + this.spec.unquoted.length, e6.doc.length));
|
|
1607
|
+
for (; !w.next().done; ) C(w.value.from, w.value.to);
|
|
1608
1608
|
}
|
|
1609
1609
|
};
|
|
1610
|
-
function regexpCursor(e6,
|
|
1611
|
-
return new RegExpCursor(
|
|
1610
|
+
function regexpCursor(e6, x, S, C) {
|
|
1611
|
+
return new RegExpCursor(x.doc, e6.search, {
|
|
1612
1612
|
ignoreCase: !e6.caseSensitive,
|
|
1613
|
-
test: e6.wholeWord ? regexpWordTest(
|
|
1614
|
-
},
|
|
1613
|
+
test: e6.wholeWord ? regexpWordTest(x.charCategorizer(x.selection.main.head)) : void 0
|
|
1614
|
+
}, S, C);
|
|
1615
1615
|
}
|
|
1616
|
-
function charBefore(e6,
|
|
1617
|
-
return e6.slice(findClusterBreak(e6,
|
|
1616
|
+
function charBefore(e6, x) {
|
|
1617
|
+
return e6.slice(findClusterBreak(e6, x, false), x);
|
|
1618
1618
|
}
|
|
1619
|
-
function charAfter(e6,
|
|
1620
|
-
return e6.slice(
|
|
1619
|
+
function charAfter(e6, x) {
|
|
1620
|
+
return e6.slice(x, findClusterBreak(e6, x));
|
|
1621
1621
|
}
|
|
1622
1622
|
function regexpWordTest(e6) {
|
|
1623
|
-
return (
|
|
1623
|
+
return (x, S, C) => !C[0].length || (e6(charBefore(C.input, C.index)) != CharCategory.Word || e6(charAfter(C.input, C.index)) != CharCategory.Word) && (e6(charAfter(C.input, C.index + C[0].length)) != CharCategory.Word || e6(charBefore(C.input, C.index + C[0].length)) != CharCategory.Word);
|
|
1624
1624
|
}
|
|
1625
1625
|
var RegExpQuery = class extends QueryType {
|
|
1626
|
-
nextMatch(e6,
|
|
1627
|
-
let
|
|
1628
|
-
return
|
|
1629
|
-
}
|
|
1630
|
-
prevMatchInRange(e6,
|
|
1631
|
-
for (let
|
|
1632
|
-
let
|
|
1633
|
-
for (; !
|
|
1634
|
-
if (
|
|
1635
|
-
if (
|
|
1626
|
+
nextMatch(e6, x, S) {
|
|
1627
|
+
let C = regexpCursor(this.spec, e6, S, e6.doc.length).next();
|
|
1628
|
+
return C.done && (C = regexpCursor(this.spec, e6, 0, x).next()), C.done ? null : C.value;
|
|
1629
|
+
}
|
|
1630
|
+
prevMatchInRange(e6, x, S) {
|
|
1631
|
+
for (let C = 1; ; C++) {
|
|
1632
|
+
let w = Math.max(x, S - C * 1e4), T = regexpCursor(this.spec, e6, w, S), E = null;
|
|
1633
|
+
for (; !T.next().done; ) E = T.value;
|
|
1634
|
+
if (E && (w == x || E.from > w + 10)) return E;
|
|
1635
|
+
if (w == x) return null;
|
|
1636
1636
|
}
|
|
1637
1637
|
}
|
|
1638
|
-
prevMatch(e6,
|
|
1639
|
-
return this.prevMatchInRange(e6, 0,
|
|
1638
|
+
prevMatch(e6, x, S) {
|
|
1639
|
+
return this.prevMatchInRange(e6, 0, x) || this.prevMatchInRange(e6, S, e6.doc.length);
|
|
1640
1640
|
}
|
|
1641
1641
|
getReplacement(e6) {
|
|
1642
|
-
return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (
|
|
1643
|
-
if (
|
|
1644
|
-
if (
|
|
1645
|
-
for (let
|
|
1646
|
-
let
|
|
1647
|
-
if (
|
|
1642
|
+
return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g, (x, S) => {
|
|
1643
|
+
if (S == "&") return e6.match[0];
|
|
1644
|
+
if (S == "$") return "$";
|
|
1645
|
+
for (let x2 = S.length; x2 > 0; x2--) {
|
|
1646
|
+
let C = +S.slice(0, x2);
|
|
1647
|
+
if (C > 0 && C < e6.match.length) return e6.match[C] + S.slice(x2);
|
|
1648
1648
|
}
|
|
1649
|
-
return
|
|
1649
|
+
return x;
|
|
1650
1650
|
});
|
|
1651
1651
|
}
|
|
1652
|
-
matchAll(e6,
|
|
1653
|
-
let
|
|
1654
|
-
for (; !
|
|
1655
|
-
if (
|
|
1656
|
-
|
|
1652
|
+
matchAll(e6, x) {
|
|
1653
|
+
let S = regexpCursor(this.spec, e6, 0, e6.doc.length), C = [];
|
|
1654
|
+
for (; !S.next().done; ) {
|
|
1655
|
+
if (C.length >= x) return null;
|
|
1656
|
+
C.push(S.value);
|
|
1657
1657
|
}
|
|
1658
|
-
return
|
|
1658
|
+
return C;
|
|
1659
1659
|
}
|
|
1660
|
-
highlight(e6,
|
|
1661
|
-
let
|
|
1662
|
-
for (; !
|
|
1660
|
+
highlight(e6, x, S, C) {
|
|
1661
|
+
let w = regexpCursor(this.spec, e6, Math.max(0, x - 250), Math.min(S + 250, e6.doc.length));
|
|
1662
|
+
for (; !w.next().done; ) C(w.value.from, w.value.to);
|
|
1663
1663
|
}
|
|
1664
1664
|
}, setSearchQuery = /* @__PURE__ */ StateEffect.define(), togglePanel$1 = /* @__PURE__ */ StateEffect.define(), searchState = /* @__PURE__ */ StateField.define({
|
|
1665
1665
|
create(e6) {
|
|
1666
1666
|
return new SearchState(defaultQuery(e6).create(), null);
|
|
1667
1667
|
},
|
|
1668
|
-
update(e6,
|
|
1669
|
-
for (let
|
|
1668
|
+
update(e6, x) {
|
|
1669
|
+
for (let S of x.effects) S.is(setSearchQuery) ? e6 = new SearchState(S.value.create(), e6.panel) : S.is(togglePanel$1) && (e6 = new SearchState(e6.query, S.value ? createSearchPanel : null));
|
|
1670
1670
|
return e6;
|
|
1671
1671
|
},
|
|
1672
1672
|
provide: (e6) => showPanel.from(e6, (e7) => e7.panel)
|
|
1673
1673
|
}), SearchState = class {
|
|
1674
|
-
constructor(e6,
|
|
1675
|
-
this.query = e6, this.panel =
|
|
1674
|
+
constructor(e6, x) {
|
|
1675
|
+
this.query = e6, this.panel = x;
|
|
1676
1676
|
}
|
|
1677
1677
|
}, matchMark = /* @__PURE__ */ Decoration.mark({ class: "cm-searchMatch" }), selectedMatchMark = /* @__PURE__ */ Decoration.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), searchHighlighter = /* @__PURE__ */ ViewPlugin.fromClass(class {
|
|
1678
1678
|
constructor(e6) {
|
|
1679
1679
|
this.view = e6, this.decorations = this.highlight(e6.state.field(searchState));
|
|
1680
1680
|
}
|
|
1681
1681
|
update(e6) {
|
|
1682
|
-
let
|
|
1683
|
-
(
|
|
1684
|
-
}
|
|
1685
|
-
highlight({ query: e6, panel:
|
|
1686
|
-
if (!
|
|
1687
|
-
let { view:
|
|
1688
|
-
for (let
|
|
1689
|
-
let { from:
|
|
1690
|
-
for (;
|
|
1691
|
-
e6.highlight(
|
|
1692
|
-
let
|
|
1693
|
-
|
|
1682
|
+
let x = e6.state.field(searchState);
|
|
1683
|
+
(x != e6.startState.field(searchState) || e6.docChanged || e6.selectionSet || e6.viewportChanged) && (this.decorations = this.highlight(x));
|
|
1684
|
+
}
|
|
1685
|
+
highlight({ query: e6, panel: x }) {
|
|
1686
|
+
if (!x || !e6.spec.valid) return Decoration.none;
|
|
1687
|
+
let { view: S } = this, C = new RangeSetBuilder();
|
|
1688
|
+
for (let x2 = 0, w = S.visibleRanges, T = w.length; x2 < T; x2++) {
|
|
1689
|
+
let { from: E, to: D } = w[x2];
|
|
1690
|
+
for (; x2 < T - 1 && D > w[x2 + 1].from - 500; ) D = w[++x2].to;
|
|
1691
|
+
e6.highlight(S.state, E, D, (e7, x3) => {
|
|
1692
|
+
let w2 = S.state.selection.ranges.some((S2) => S2.from == e7 && S2.to == x3);
|
|
1693
|
+
C.add(e7, x3, w2 ? selectedMatchMark : matchMark);
|
|
1694
1694
|
});
|
|
1695
1695
|
}
|
|
1696
|
-
return
|
|
1696
|
+
return C.finish();
|
|
1697
1697
|
}
|
|
1698
1698
|
}, { decorations: (e6) => e6.decorations });
|
|
1699
1699
|
function searchCommand(e6) {
|
|
1700
|
-
return (
|
|
1701
|
-
let
|
|
1702
|
-
return
|
|
1700
|
+
return (x) => {
|
|
1701
|
+
let S = x.state.field(searchState, false);
|
|
1702
|
+
return S && S.query.spec.valid ? e6(x, S) : openSearchPanel(x);
|
|
1703
1703
|
};
|
|
1704
1704
|
}
|
|
1705
|
-
var findNext = /* @__PURE__ */ searchCommand((e6, { query:
|
|
1706
|
-
let { to:
|
|
1707
|
-
if (!
|
|
1708
|
-
let
|
|
1705
|
+
var findNext = /* @__PURE__ */ searchCommand((e6, { query: x }) => {
|
|
1706
|
+
let { to: S } = e6.state.selection.main, C = x.nextMatch(e6.state, S, S);
|
|
1707
|
+
if (!C) return false;
|
|
1708
|
+
let w = EditorSelection.single(C.from, C.to), T = e6.state.facet(searchConfigFacet);
|
|
1709
1709
|
return e6.dispatch({
|
|
1710
|
-
selection:
|
|
1711
|
-
effects: [announceMatch(e6,
|
|
1710
|
+
selection: w,
|
|
1711
|
+
effects: [announceMatch(e6, C), T.scrollToMatch(w.main, e6)],
|
|
1712
1712
|
userEvent: "select.search"
|
|
1713
1713
|
}), selectSearchInput(e6), true;
|
|
1714
|
-
}), findPrevious = /* @__PURE__ */ searchCommand((e6, { query:
|
|
1715
|
-
let { state:
|
|
1716
|
-
if (!
|
|
1717
|
-
let
|
|
1714
|
+
}), findPrevious = /* @__PURE__ */ searchCommand((e6, { query: x }) => {
|
|
1715
|
+
let { state: S } = e6, { from: C } = S.selection.main, w = x.prevMatch(S, C, C);
|
|
1716
|
+
if (!w) return false;
|
|
1717
|
+
let T = EditorSelection.single(w.from, w.to), E = e6.state.facet(searchConfigFacet);
|
|
1718
1718
|
return e6.dispatch({
|
|
1719
|
-
selection:
|
|
1720
|
-
effects: [announceMatch(e6,
|
|
1719
|
+
selection: T,
|
|
1720
|
+
effects: [announceMatch(e6, w), E.scrollToMatch(T.main, e6)],
|
|
1721
1721
|
userEvent: "select.search"
|
|
1722
1722
|
}), selectSearchInput(e6), true;
|
|
1723
|
-
}), selectMatches = /* @__PURE__ */ searchCommand((e6, { query:
|
|
1724
|
-
let
|
|
1725
|
-
return !
|
|
1726
|
-
selection: EditorSelection.create(
|
|
1723
|
+
}), selectMatches = /* @__PURE__ */ searchCommand((e6, { query: x }) => {
|
|
1724
|
+
let S = x.matchAll(e6.state, 1e3);
|
|
1725
|
+
return !S || !S.length ? false : (e6.dispatch({
|
|
1726
|
+
selection: EditorSelection.create(S.map((e7) => EditorSelection.range(e7.from, e7.to))),
|
|
1727
1727
|
userEvent: "select.search.matches"
|
|
1728
1728
|
}), true);
|
|
1729
|
-
}), selectSelectionMatches = ({ state: e6, dispatch:
|
|
1730
|
-
let
|
|
1731
|
-
if (
|
|
1732
|
-
let { from:
|
|
1733
|
-
for (let
|
|
1734
|
-
if (
|
|
1735
|
-
|
|
1736
|
-
}
|
|
1737
|
-
return
|
|
1738
|
-
selection: EditorSelection.create(
|
|
1729
|
+
}), selectSelectionMatches = ({ state: e6, dispatch: x }) => {
|
|
1730
|
+
let S = e6.selection;
|
|
1731
|
+
if (S.ranges.length > 1 || S.main.empty) return false;
|
|
1732
|
+
let { from: C, to: w } = S.main, T = [], E = 0;
|
|
1733
|
+
for (let x2 = new SearchCursor(e6.doc, e6.sliceDoc(C, w)); !x2.next().done; ) {
|
|
1734
|
+
if (T.length > 1e3) return false;
|
|
1735
|
+
x2.value.from == C && (E = T.length), T.push(EditorSelection.range(x2.value.from, x2.value.to));
|
|
1736
|
+
}
|
|
1737
|
+
return x(e6.update({
|
|
1738
|
+
selection: EditorSelection.create(T, E),
|
|
1739
1739
|
userEvent: "select.search.matches"
|
|
1740
1740
|
})), true;
|
|
1741
|
-
}, replaceNext = /* @__PURE__ */ searchCommand((e6, { query:
|
|
1742
|
-
let { state:
|
|
1743
|
-
if (
|
|
1744
|
-
let
|
|
1745
|
-
if (!
|
|
1746
|
-
let
|
|
1747
|
-
|
|
1748
|
-
from:
|
|
1749
|
-
to:
|
|
1750
|
-
insert:
|
|
1751
|
-
}),
|
|
1752
|
-
let
|
|
1753
|
-
return
|
|
1754
|
-
changes:
|
|
1755
|
-
selection:
|
|
1756
|
-
effects:
|
|
1741
|
+
}, replaceNext = /* @__PURE__ */ searchCommand((e6, { query: x }) => {
|
|
1742
|
+
let { state: S } = e6, { from: C, to: w } = S.selection.main;
|
|
1743
|
+
if (S.readOnly) return false;
|
|
1744
|
+
let T = x.nextMatch(S, C, C);
|
|
1745
|
+
if (!T) return false;
|
|
1746
|
+
let E = T, D = [], O, k, A = [];
|
|
1747
|
+
E.from == C && E.to == w && (k = S.toText(x.getReplacement(E)), D.push({
|
|
1748
|
+
from: E.from,
|
|
1749
|
+
to: E.to,
|
|
1750
|
+
insert: k
|
|
1751
|
+
}), E = x.nextMatch(S, E.from, E.to), A.push(EditorView.announce.of(S.phrase("replaced match on line $", S.doc.lineAt(C).number) + ".")));
|
|
1752
|
+
let j = e6.state.changes(D);
|
|
1753
|
+
return E && (O = EditorSelection.single(E.from, E.to).map(j), A.push(announceMatch(e6, E)), A.push(S.facet(searchConfigFacet).scrollToMatch(O.main, e6))), e6.dispatch({
|
|
1754
|
+
changes: j,
|
|
1755
|
+
selection: O,
|
|
1756
|
+
effects: A,
|
|
1757
1757
|
userEvent: "input.replace"
|
|
1758
1758
|
}), true;
|
|
1759
|
-
}), replaceAll = /* @__PURE__ */ searchCommand((e6, { query:
|
|
1759
|
+
}), replaceAll = /* @__PURE__ */ searchCommand((e6, { query: x }) => {
|
|
1760
1760
|
if (e6.state.readOnly) return false;
|
|
1761
|
-
let
|
|
1762
|
-
let { from:
|
|
1761
|
+
let S = x.matchAll(e6.state, 1e9).map((e7) => {
|
|
1762
|
+
let { from: S2, to: C2 } = e7;
|
|
1763
1763
|
return {
|
|
1764
|
-
from:
|
|
1765
|
-
to:
|
|
1766
|
-
insert:
|
|
1764
|
+
from: S2,
|
|
1765
|
+
to: C2,
|
|
1766
|
+
insert: x.getReplacement(e7)
|
|
1767
1767
|
};
|
|
1768
1768
|
});
|
|
1769
|
-
if (!
|
|
1770
|
-
let
|
|
1769
|
+
if (!S.length) return false;
|
|
1770
|
+
let C = e6.state.phrase("replaced $ matches", S.length) + ".";
|
|
1771
1771
|
return e6.dispatch({
|
|
1772
|
-
changes:
|
|
1773
|
-
effects: EditorView.announce.of(
|
|
1772
|
+
changes: S,
|
|
1773
|
+
effects: EditorView.announce.of(C),
|
|
1774
1774
|
userEvent: "input.replace.all"
|
|
1775
1775
|
}), true;
|
|
1776
1776
|
});
|
|
1777
1777
|
function createSearchPanel(e6) {
|
|
1778
1778
|
return e6.state.facet(searchConfigFacet).createPanel(e6);
|
|
1779
1779
|
}
|
|
1780
|
-
function defaultQuery(e6,
|
|
1781
|
-
let
|
|
1782
|
-
if (
|
|
1783
|
-
let
|
|
1780
|
+
function defaultQuery(e6, x) {
|
|
1781
|
+
let S = e6.selection.main, C = S.empty || S.to > S.from + 100 ? "" : e6.sliceDoc(S.from, S.to);
|
|
1782
|
+
if (x && !C) return x;
|
|
1783
|
+
let w = e6.facet(searchConfigFacet);
|
|
1784
1784
|
return new SearchQuery({
|
|
1785
|
-
search: (
|
|
1786
|
-
caseSensitive: (
|
|
1787
|
-
literal: (
|
|
1788
|
-
regexp: (
|
|
1789
|
-
wholeWord: (
|
|
1785
|
+
search: (x == null ? void 0 : x.literal) ?? w.literal ? C : C.replace(/\n/g, "\\n"),
|
|
1786
|
+
caseSensitive: (x == null ? void 0 : x.caseSensitive) ?? w.caseSensitive,
|
|
1787
|
+
literal: (x == null ? void 0 : x.literal) ?? w.literal,
|
|
1788
|
+
regexp: (x == null ? void 0 : x.regexp) ?? w.regexp,
|
|
1789
|
+
wholeWord: (x == null ? void 0 : x.wholeWord) ?? w.wholeWord
|
|
1790
1790
|
});
|
|
1791
1791
|
}
|
|
1792
1792
|
function getSearchInput(e6) {
|
|
1793
|
-
let
|
|
1794
|
-
return
|
|
1793
|
+
let x = getPanel(e6, createSearchPanel);
|
|
1794
|
+
return x && x.dom.querySelector("[main-field]");
|
|
1795
1795
|
}
|
|
1796
1796
|
function selectSearchInput(e6) {
|
|
1797
|
-
let
|
|
1798
|
-
|
|
1797
|
+
let x = getSearchInput(e6);
|
|
1798
|
+
x && x == e6.root.activeElement && x.select();
|
|
1799
1799
|
}
|
|
1800
1800
|
var openSearchPanel = (e6) => {
|
|
1801
|
-
let
|
|
1802
|
-
if (
|
|
1803
|
-
let
|
|
1804
|
-
if (
|
|
1805
|
-
let
|
|
1806
|
-
|
|
1801
|
+
let x = e6.state.field(searchState, false);
|
|
1802
|
+
if (x && x.panel) {
|
|
1803
|
+
let S = getSearchInput(e6);
|
|
1804
|
+
if (S && S != e6.root.activeElement) {
|
|
1805
|
+
let C = defaultQuery(e6.state, x.query.spec);
|
|
1806
|
+
C.valid && e6.dispatch({ effects: setSearchQuery.of(C) }), S.focus(), S.select();
|
|
1807
1807
|
}
|
|
1808
|
-
} else e6.dispatch({ effects: [togglePanel$1.of(true),
|
|
1808
|
+
} else e6.dispatch({ effects: [togglePanel$1.of(true), x ? setSearchQuery.of(defaultQuery(e6.state, x.query.spec)) : StateEffect.appendConfig.of(searchExtensions)] });
|
|
1809
1809
|
return true;
|
|
1810
1810
|
}, closeSearchPanel = (e6) => {
|
|
1811
|
-
let
|
|
1812
|
-
if (!
|
|
1813
|
-
let
|
|
1814
|
-
return
|
|
1811
|
+
let x = e6.state.field(searchState, false);
|
|
1812
|
+
if (!x || !x.panel) return false;
|
|
1813
|
+
let S = getPanel(e6, createSearchPanel);
|
|
1814
|
+
return S && S.dom.contains(e6.root.activeElement) && e6.focus(), e6.dispatch({ effects: togglePanel$1.of(false) }), true;
|
|
1815
1815
|
}, searchKeymap = [
|
|
1816
1816
|
{
|
|
1817
1817
|
key: "Mod-f",
|
|
@@ -1853,9 +1853,9 @@ var openSearchPanel = (e6) => {
|
|
|
1853
1853
|
], SearchPanel = class {
|
|
1854
1854
|
constructor(e6) {
|
|
1855
1855
|
this.view = e6;
|
|
1856
|
-
let
|
|
1856
|
+
let x = this.query = e6.state.field(searchState).query.spec;
|
|
1857
1857
|
this.commit = this.commit.bind(this), this.searchField = crelt("input", {
|
|
1858
|
-
value:
|
|
1858
|
+
value: x.search,
|
|
1859
1859
|
placeholder: phrase(e6, "Find"),
|
|
1860
1860
|
"aria-label": phrase(e6, "Find"),
|
|
1861
1861
|
class: "cm-textfield",
|
|
@@ -1865,7 +1865,7 @@ var openSearchPanel = (e6) => {
|
|
|
1865
1865
|
onchange: this.commit,
|
|
1866
1866
|
onkeyup: this.commit
|
|
1867
1867
|
}), this.replaceField = crelt("input", {
|
|
1868
|
-
value:
|
|
1868
|
+
value: x.replace,
|
|
1869
1869
|
placeholder: phrase(e6, "Replace"),
|
|
1870
1870
|
"aria-label": phrase(e6, "Replace"),
|
|
1871
1871
|
class: "cm-textfield",
|
|
@@ -1877,45 +1877,45 @@ var openSearchPanel = (e6) => {
|
|
|
1877
1877
|
type: "checkbox",
|
|
1878
1878
|
name: "case",
|
|
1879
1879
|
form: "",
|
|
1880
|
-
checked:
|
|
1880
|
+
checked: x.caseSensitive,
|
|
1881
1881
|
onchange: this.commit
|
|
1882
1882
|
}), this.reField = crelt("input", {
|
|
1883
1883
|
type: "checkbox",
|
|
1884
1884
|
name: "re",
|
|
1885
1885
|
form: "",
|
|
1886
|
-
checked:
|
|
1886
|
+
checked: x.regexp,
|
|
1887
1887
|
onchange: this.commit
|
|
1888
1888
|
}), this.wordField = crelt("input", {
|
|
1889
1889
|
type: "checkbox",
|
|
1890
1890
|
name: "word",
|
|
1891
1891
|
form: "",
|
|
1892
|
-
checked:
|
|
1892
|
+
checked: x.wholeWord,
|
|
1893
1893
|
onchange: this.commit
|
|
1894
1894
|
});
|
|
1895
|
-
function
|
|
1895
|
+
function S(e7, x2, S2) {
|
|
1896
1896
|
return crelt("button", {
|
|
1897
1897
|
class: "cm-button",
|
|
1898
1898
|
name: e7,
|
|
1899
|
-
onclick:
|
|
1899
|
+
onclick: x2,
|
|
1900
1900
|
type: "button"
|
|
1901
|
-
},
|
|
1901
|
+
}, S2);
|
|
1902
1902
|
}
|
|
1903
1903
|
this.dom = crelt("div", {
|
|
1904
1904
|
onkeydown: (e7) => this.keydown(e7),
|
|
1905
1905
|
class: "cm-search"
|
|
1906
1906
|
}, [
|
|
1907
1907
|
this.searchField,
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1908
|
+
S("next", () => findNext(e6), [phrase(e6, "next")]),
|
|
1909
|
+
S("prev", () => findPrevious(e6), [phrase(e6, "previous")]),
|
|
1910
|
+
S("select", () => selectMatches(e6), [phrase(e6, "all")]),
|
|
1911
1911
|
crelt("label", null, [this.caseField, phrase(e6, "match case")]),
|
|
1912
1912
|
crelt("label", null, [this.reField, phrase(e6, "regexp")]),
|
|
1913
1913
|
crelt("label", null, [this.wordField, phrase(e6, "by word")]),
|
|
1914
1914
|
...e6.state.readOnly ? [] : [
|
|
1915
1915
|
crelt("br"),
|
|
1916
1916
|
this.replaceField,
|
|
1917
|
-
|
|
1918
|
-
|
|
1917
|
+
S("replace", () => replaceNext(e6), [phrase(e6, "replace")]),
|
|
1918
|
+
S("replaceAll", () => replaceAll(e6), [phrase(e6, "replace all")])
|
|
1919
1919
|
],
|
|
1920
1920
|
crelt("button", {
|
|
1921
1921
|
name: "close",
|
|
@@ -1939,7 +1939,7 @@ var openSearchPanel = (e6) => {
|
|
|
1939
1939
|
runScopeHandlers(this.view, e6, "search-panel") ? e6.preventDefault() : e6.keyCode == 13 && e6.target == this.searchField ? (e6.preventDefault(), (e6.shiftKey ? findPrevious : findNext)(this.view)) : e6.keyCode == 13 && e6.target == this.replaceField && (e6.preventDefault(), replaceNext(this.view));
|
|
1940
1940
|
}
|
|
1941
1941
|
update(e6) {
|
|
1942
|
-
for (let
|
|
1942
|
+
for (let x of e6.transactions) for (let e7 of x.effects) e7.is(setSearchQuery) && !e7.value.eq(this.query) && this.setQuery(e7.value);
|
|
1943
1943
|
}
|
|
1944
1944
|
setQuery(e6) {
|
|
1945
1945
|
this.query = e6, this.searchField.value = e6.search, this.replaceField.value = e6.replace, this.caseField.checked = e6.caseSensitive, this.reField.checked = e6.regexp, this.wordField.checked = e6.wholeWord;
|
|
@@ -1954,25 +1954,25 @@ var openSearchPanel = (e6) => {
|
|
|
1954
1954
|
return this.view.state.facet(searchConfigFacet).top;
|
|
1955
1955
|
}
|
|
1956
1956
|
};
|
|
1957
|
-
function phrase(e6,
|
|
1958
|
-
return e6.state.phrase(
|
|
1957
|
+
function phrase(e6, x) {
|
|
1958
|
+
return e6.state.phrase(x);
|
|
1959
1959
|
}
|
|
1960
1960
|
var AnnounceMargin = 30, Break = /[\s\.,:;?!]/;
|
|
1961
|
-
function announceMatch(e6, { from:
|
|
1962
|
-
let
|
|
1963
|
-
if (
|
|
1964
|
-
for (let e7 = 0; e7 < AnnounceMargin; e7++) if (!Break.test(
|
|
1965
|
-
|
|
1961
|
+
function announceMatch(e6, { from: x, to: S }) {
|
|
1962
|
+
let C = e6.state.doc.lineAt(x), w = e6.state.doc.lineAt(S).to, T = Math.max(C.from, x - AnnounceMargin), E = Math.min(w, S + AnnounceMargin), D = e6.state.sliceDoc(T, E);
|
|
1963
|
+
if (T != C.from) {
|
|
1964
|
+
for (let e7 = 0; e7 < AnnounceMargin; e7++) if (!Break.test(D[e7 + 1]) && Break.test(D[e7])) {
|
|
1965
|
+
D = D.slice(e7);
|
|
1966
1966
|
break;
|
|
1967
1967
|
}
|
|
1968
1968
|
}
|
|
1969
|
-
if (
|
|
1970
|
-
for (let e7 =
|
|
1971
|
-
|
|
1969
|
+
if (E != w) {
|
|
1970
|
+
for (let e7 = D.length - 1; e7 > D.length - AnnounceMargin; e7--) if (!Break.test(D[e7 - 1]) && Break.test(D[e7])) {
|
|
1971
|
+
D = D.slice(0, e7);
|
|
1972
1972
|
break;
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
|
-
return EditorView.announce.of(`${e6.state.phrase("current match")}. ${
|
|
1975
|
+
return EditorView.announce.of(`${e6.state.phrase("current match")}. ${D} ${e6.state.phrase("on line")} ${C.number}.`);
|
|
1976
1976
|
}
|
|
1977
1977
|
var baseTheme$2 = /* @__PURE__ */ EditorView.baseTheme({
|
|
1978
1978
|
".cm-panel.cm-search": {
|
|
@@ -2004,129 +2004,129 @@ var baseTheme$2 = /* @__PURE__ */ EditorView.baseTheme({
|
|
|
2004
2004
|
/* @__PURE__ */ Prec.low(searchHighlighter),
|
|
2005
2005
|
baseTheme$2
|
|
2006
2006
|
], SelectedDiagnostic = class {
|
|
2007
|
-
constructor(e6,
|
|
2008
|
-
this.from = e6, this.to =
|
|
2007
|
+
constructor(e6, x, S) {
|
|
2008
|
+
this.from = e6, this.to = x, this.diagnostic = S;
|
|
2009
2009
|
}
|
|
2010
2010
|
}, LintState = class e4 {
|
|
2011
|
-
constructor(e6,
|
|
2012
|
-
this.diagnostics = e6, this.panel =
|
|
2011
|
+
constructor(e6, x, S) {
|
|
2012
|
+
this.diagnostics = e6, this.panel = x, this.selected = S;
|
|
2013
2013
|
}
|
|
2014
|
-
static init(
|
|
2015
|
-
let
|
|
2016
|
-
|
|
2017
|
-
let
|
|
2014
|
+
static init(x, S, C) {
|
|
2015
|
+
let w = C.facet(lintConfig).markerFilter;
|
|
2016
|
+
w && (x = w(x, C));
|
|
2017
|
+
let T = x.slice().sort((e6, x2) => e6.from - x2.from || e6.to - x2.to), E = new RangeSetBuilder(), D = [], O = 0, k = C.doc.iter(), A = 0;
|
|
2018
2018
|
for (let e6 = 0; ; ) {
|
|
2019
|
-
let
|
|
2020
|
-
if (!
|
|
2021
|
-
let
|
|
2022
|
-
for (
|
|
2023
|
-
let
|
|
2024
|
-
if (
|
|
2019
|
+
let x2 = e6 == T.length ? null : T[e6];
|
|
2020
|
+
if (!x2 && !D.length) break;
|
|
2021
|
+
let S2, C2;
|
|
2022
|
+
for (D.length ? (S2 = O, C2 = D.reduce((e7, x3) => Math.min(e7, x3.to), x2 && x2.from > S2 ? x2.from : 1e8)) : (S2 = x2.from, C2 = x2.to, D.push(x2), e6++); e6 < T.length; ) {
|
|
2023
|
+
let x3 = T[e6];
|
|
2024
|
+
if (x3.from == S2 && (x3.to > x3.from || x3.to == S2)) D.push(x3), e6++, C2 = Math.min(x3.to, C2);
|
|
2025
2025
|
else {
|
|
2026
|
-
|
|
2026
|
+
C2 = Math.min(x3.from, C2);
|
|
2027
2027
|
break;
|
|
2028
2028
|
}
|
|
2029
2029
|
}
|
|
2030
|
-
let
|
|
2031
|
-
if (
|
|
2032
|
-
let e7 =
|
|
2033
|
-
e7 > 0 && (
|
|
2034
|
-
for (let e8 =
|
|
2035
|
-
if (e8 >=
|
|
2036
|
-
|
|
2030
|
+
let w2 = false;
|
|
2031
|
+
if (D.some((e7) => e7.from == S2 && e7.to == C2) && (w2 = S2 == C2, !w2 && C2 - S2 < 10)) {
|
|
2032
|
+
let e7 = S2 - (A + k.value.length);
|
|
2033
|
+
e7 > 0 && (k.next(e7), A = S2);
|
|
2034
|
+
for (let e8 = S2; ; ) {
|
|
2035
|
+
if (e8 >= C2) {
|
|
2036
|
+
w2 = true;
|
|
2037
2037
|
break;
|
|
2038
2038
|
}
|
|
2039
|
-
if (!
|
|
2040
|
-
e8 =
|
|
2039
|
+
if (!k.lineBreak && A + k.value.length > e8) break;
|
|
2040
|
+
e8 = A + k.value.length, A += k.value.length, k.next();
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
|
-
let
|
|
2044
|
-
if (
|
|
2045
|
-
widget: new DiagnosticWidget(
|
|
2046
|
-
diagnostics:
|
|
2043
|
+
let j2 = maxSeverity(D);
|
|
2044
|
+
if (w2) E.add(S2, S2, Decoration.widget({
|
|
2045
|
+
widget: new DiagnosticWidget(j2),
|
|
2046
|
+
diagnostics: D.slice()
|
|
2047
2047
|
}));
|
|
2048
2048
|
else {
|
|
2049
|
-
let e7 =
|
|
2050
|
-
|
|
2051
|
-
class: "cm-lintRange cm-lintRange-" +
|
|
2052
|
-
diagnostics:
|
|
2053
|
-
inclusiveEnd:
|
|
2049
|
+
let e7 = D.reduce((e8, x3) => x3.markClass ? e8 + " " + x3.markClass : e8, "");
|
|
2050
|
+
E.add(S2, C2, Decoration.mark({
|
|
2051
|
+
class: "cm-lintRange cm-lintRange-" + j2 + e7,
|
|
2052
|
+
diagnostics: D.slice(),
|
|
2053
|
+
inclusiveEnd: D.some((e8) => e8.to > C2)
|
|
2054
2054
|
}));
|
|
2055
2055
|
}
|
|
2056
|
-
|
|
2057
|
-
for (let e7 = 0; e7 <
|
|
2056
|
+
O = C2;
|
|
2057
|
+
for (let e7 = 0; e7 < D.length; e7++) D[e7].to <= O && D.splice(e7--, 1);
|
|
2058
2058
|
}
|
|
2059
|
-
let
|
|
2060
|
-
return new e4(
|
|
2059
|
+
let j = E.finish();
|
|
2060
|
+
return new e4(j, S, findDiagnostic(j));
|
|
2061
2061
|
}
|
|
2062
2062
|
};
|
|
2063
|
-
function findDiagnostic(e6,
|
|
2064
|
-
let
|
|
2065
|
-
return e6.between(
|
|
2066
|
-
if (!(
|
|
2067
|
-
else if (
|
|
2068
|
-
else
|
|
2069
|
-
}),
|
|
2063
|
+
function findDiagnostic(e6, x = null, S = 0) {
|
|
2064
|
+
let C = null;
|
|
2065
|
+
return e6.between(S, 1e9, (e7, S2, { spec: w }) => {
|
|
2066
|
+
if (!(x && w.diagnostics.indexOf(x) < 0)) if (!C) C = new SelectedDiagnostic(e7, S2, x || w.diagnostics[0]);
|
|
2067
|
+
else if (w.diagnostics.indexOf(C.diagnostic) < 0) return false;
|
|
2068
|
+
else C = new SelectedDiagnostic(C.from, S2, C.diagnostic);
|
|
2069
|
+
}), C;
|
|
2070
2070
|
}
|
|
2071
|
-
function hideTooltip(e6,
|
|
2072
|
-
let
|
|
2073
|
-
if (
|
|
2074
|
-
let
|
|
2075
|
-
return !!(e6.effects.some((e7) => e7.is(setDiagnosticsEffect)) || e6.changes.touchesRange(
|
|
2071
|
+
function hideTooltip(e6, x) {
|
|
2072
|
+
let S = x.pos, C = x.end || S, w = e6.state.facet(lintConfig).hideOn(e6, S, C);
|
|
2073
|
+
if (w != null) return w;
|
|
2074
|
+
let T = e6.startState.doc.lineAt(x.pos);
|
|
2075
|
+
return !!(e6.effects.some((e7) => e7.is(setDiagnosticsEffect)) || e6.changes.touchesRange(T.from, Math.max(T.to, C)));
|
|
2076
2076
|
}
|
|
2077
|
-
function maybeEnableLint(e6,
|
|
2078
|
-
return e6.field(lintState, false) ?
|
|
2077
|
+
function maybeEnableLint(e6, x) {
|
|
2078
|
+
return e6.field(lintState, false) ? x : x.concat(StateEffect.appendConfig.of(lintExtensions));
|
|
2079
2079
|
}
|
|
2080
|
-
function setDiagnostics(e6,
|
|
2081
|
-
return { effects: maybeEnableLint(e6, [setDiagnosticsEffect.of(
|
|
2080
|
+
function setDiagnostics(e6, x) {
|
|
2081
|
+
return { effects: maybeEnableLint(e6, [setDiagnosticsEffect.of(x)]) };
|
|
2082
2082
|
}
|
|
2083
2083
|
var setDiagnosticsEffect = /* @__PURE__ */ StateEffect.define(), togglePanel = /* @__PURE__ */ StateEffect.define(), movePanelSelection = /* @__PURE__ */ StateEffect.define(), lintState = /* @__PURE__ */ StateField.define({
|
|
2084
2084
|
create() {
|
|
2085
2085
|
return new LintState(Decoration.none, null, null);
|
|
2086
2086
|
},
|
|
2087
|
-
update(e6,
|
|
2088
|
-
if (
|
|
2089
|
-
let
|
|
2087
|
+
update(e6, x) {
|
|
2088
|
+
if (x.docChanged && e6.diagnostics.size) {
|
|
2089
|
+
let S = e6.diagnostics.map(x.changes), C = null, w = e6.panel;
|
|
2090
2090
|
if (e6.selected) {
|
|
2091
|
-
let
|
|
2092
|
-
|
|
2091
|
+
let w2 = x.changes.mapPos(e6.selected.from, 1);
|
|
2092
|
+
C = findDiagnostic(S, e6.selected.diagnostic, w2) || findDiagnostic(S, null, w2);
|
|
2093
2093
|
}
|
|
2094
|
-
!
|
|
2094
|
+
!S.size && w && x.state.facet(lintConfig).autoPanel && (w = null), e6 = new LintState(S, w, C);
|
|
2095
2095
|
}
|
|
2096
|
-
for (let
|
|
2097
|
-
let
|
|
2098
|
-
e6 = LintState.init(
|
|
2099
|
-
} else
|
|
2096
|
+
for (let S of x.effects) if (S.is(setDiagnosticsEffect)) {
|
|
2097
|
+
let C = x.state.facet(lintConfig).autoPanel ? S.value.length ? LintPanel.open : null : e6.panel;
|
|
2098
|
+
e6 = LintState.init(S.value, C, x.state);
|
|
2099
|
+
} else S.is(togglePanel) ? e6 = new LintState(e6.diagnostics, S.value ? LintPanel.open : null, e6.selected) : S.is(movePanelSelection) && (e6 = new LintState(e6.diagnostics, e6.panel, S.value));
|
|
2100
2100
|
return e6;
|
|
2101
2101
|
},
|
|
2102
2102
|
provide: (e6) => [showPanel.from(e6, (e7) => e7.panel), EditorView.decorations.from(e6, (e7) => e7.diagnostics)]
|
|
2103
2103
|
}), activeMark = /* @__PURE__ */ Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
|
2104
|
-
function lintTooltip(e6,
|
|
2105
|
-
let { diagnostics:
|
|
2106
|
-
|
|
2107
|
-
if (
|
|
2104
|
+
function lintTooltip(e6, x, S) {
|
|
2105
|
+
let { diagnostics: C } = e6.state.field(lintState), w, T = -1, E = -1;
|
|
2106
|
+
C.between(x - (S < 0 ? 1 : 0), x + (S > 0 ? 1 : 0), (e7, C2, { spec: D2 }) => {
|
|
2107
|
+
if (x >= e7 && x <= C2 && (e7 == C2 || (x > e7 || S > 0) && (x < C2 || S < 0))) return w = D2.diagnostics, T = e7, E = C2, false;
|
|
2108
2108
|
});
|
|
2109
|
-
let
|
|
2110
|
-
return
|
|
2111
|
-
pos:
|
|
2112
|
-
end:
|
|
2113
|
-
above: e6.state.doc.lineAt(
|
|
2109
|
+
let D = e6.state.facet(lintConfig).tooltipFilter;
|
|
2110
|
+
return w && D && (w = D(w, e6.state)), w ? {
|
|
2111
|
+
pos: T,
|
|
2112
|
+
end: E,
|
|
2113
|
+
above: e6.state.doc.lineAt(T).to < E,
|
|
2114
2114
|
create() {
|
|
2115
|
-
return { dom: diagnosticsTooltip(e6,
|
|
2115
|
+
return { dom: diagnosticsTooltip(e6, w) };
|
|
2116
2116
|
}
|
|
2117
2117
|
} : null;
|
|
2118
2118
|
}
|
|
2119
|
-
function diagnosticsTooltip(e6,
|
|
2120
|
-
return crelt("ul", { class: "cm-tooltip-lint" },
|
|
2119
|
+
function diagnosticsTooltip(e6, x) {
|
|
2120
|
+
return crelt("ul", { class: "cm-tooltip-lint" }, x.map((x2) => renderDiagnostic(e6, x2, false)));
|
|
2121
2121
|
}
|
|
2122
2122
|
var openLintPanel = (e6) => {
|
|
2123
|
-
let
|
|
2124
|
-
(!
|
|
2125
|
-
let
|
|
2126
|
-
return
|
|
2123
|
+
let x = e6.state.field(lintState, false);
|
|
2124
|
+
(!x || !x.panel) && e6.dispatch({ effects: maybeEnableLint(e6.state, [togglePanel.of(true)]) });
|
|
2125
|
+
let S = getPanel(e6, LintPanel.open);
|
|
2126
|
+
return S && S.dom.querySelector(".cm-panel-lint ul").focus(), true;
|
|
2127
2127
|
}, closeLintPanel = (e6) => {
|
|
2128
|
-
let
|
|
2129
|
-
return !
|
|
2128
|
+
let x = e6.state.field(lintState, false);
|
|
2129
|
+
return !x || !x.panel ? false : (e6.dispatch({ effects: togglePanel.of(false) }), true);
|
|
2130
2130
|
}, lintKeymap = [{
|
|
2131
2131
|
key: "Mod-Shift-m",
|
|
2132
2132
|
run: openLintPanel,
|
|
@@ -2134,55 +2134,18 @@ var openLintPanel = (e6) => {
|
|
|
2134
2134
|
}, {
|
|
2135
2135
|
key: "F8",
|
|
2136
2136
|
run: (e6) => {
|
|
2137
|
-
let
|
|
2138
|
-
if (!
|
|
2139
|
-
let
|
|
2140
|
-
return !
|
|
2137
|
+
let x = e6.state.field(lintState, false);
|
|
2138
|
+
if (!x) return false;
|
|
2139
|
+
let S = e6.state.selection.main, C = x.diagnostics.iter(S.to + 1);
|
|
2140
|
+
return !C.value && (C = x.diagnostics.iter(0), !C.value || C.from == S.from && C.to == S.to) ? false : (e6.dispatch({
|
|
2141
2141
|
selection: {
|
|
2142
|
-
anchor:
|
|
2143
|
-
head:
|
|
2142
|
+
anchor: C.from,
|
|
2143
|
+
head: C.to
|
|
2144
2144
|
},
|
|
2145
2145
|
scrollIntoView: true
|
|
2146
2146
|
}), true);
|
|
2147
2147
|
}
|
|
2148
|
-
}],
|
|
2149
|
-
constructor(e6) {
|
|
2150
|
-
this.view = e6, this.timeout = -1, this.set = true;
|
|
2151
|
-
let { delay: y } = e6.state.facet(lintConfig);
|
|
2152
|
-
this.lintTime = Date.now() + y, this.run = this.run.bind(this), this.timeout = setTimeout(this.run, y);
|
|
2153
|
-
}
|
|
2154
|
-
run() {
|
|
2155
|
-
clearTimeout(this.timeout);
|
|
2156
|
-
let e6 = Date.now();
|
|
2157
|
-
if (e6 < this.lintTime - 10) this.timeout = setTimeout(this.run, this.lintTime - e6);
|
|
2158
|
-
else {
|
|
2159
|
-
this.set = false;
|
|
2160
|
-
let { state: e7 } = this.view, { sources: y } = e7.facet(lintConfig);
|
|
2161
|
-
y.length && batchResults(y.map((e8) => Promise.resolve(e8(this.view))), (y2) => {
|
|
2162
|
-
this.view.state.doc == e7.doc && this.view.dispatch(setDiagnostics(this.view.state, y2.reduce((e8, y3) => e8.concat(y3))));
|
|
2163
|
-
}, (e8) => {
|
|
2164
|
-
logException(this.view.state, e8);
|
|
2165
|
-
});
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
update(e6) {
|
|
2169
|
-
let y = e6.state.facet(lintConfig);
|
|
2170
|
-
(e6.docChanged || y != e6.startState.facet(lintConfig) || y.needsRefresh && y.needsRefresh(e6)) && (this.lintTime = Date.now() + y.delay, this.set || (this.set = true, this.timeout = setTimeout(this.run, y.delay)));
|
|
2171
|
-
}
|
|
2172
|
-
force() {
|
|
2173
|
-
this.set && (this.lintTime = Date.now(), this.run());
|
|
2174
|
-
}
|
|
2175
|
-
destroy() {
|
|
2176
|
-
clearTimeout(this.timeout);
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
function batchResults(e6, y, b) {
|
|
2180
|
-
let x = [], S = -1;
|
|
2181
|
-
for (let C of e6) C.then((b2) => {
|
|
2182
|
-
x.push(b2), clearTimeout(S), x.length == e6.length ? y(x) : S = setTimeout(() => y(x), 200);
|
|
2183
|
-
}, b);
|
|
2184
|
-
}
|
|
2185
|
-
var lintConfig = /* @__PURE__ */ Facet.define({ combine(e6) {
|
|
2148
|
+
}], lintConfig = /* @__PURE__ */ Facet.define({ combine(e6) {
|
|
2186
2149
|
return {
|
|
2187
2150
|
sources: e6.map((e7) => e7.source).filter((e7) => e7 != null),
|
|
2188
2151
|
...combineConfig(e6.map((e7) => e7.config), {
|
|
@@ -2195,61 +2158,51 @@ var lintConfig = /* @__PURE__ */ Facet.define({ combine(e6) {
|
|
|
2195
2158
|
delay: Math.max,
|
|
2196
2159
|
markerFilter: combineFilter,
|
|
2197
2160
|
tooltipFilter: combineFilter,
|
|
2198
|
-
needsRefresh: (e7,
|
|
2199
|
-
hideOn: (e7,
|
|
2200
|
-
autoPanel: (e7,
|
|
2161
|
+
needsRefresh: (e7, x) => e7 ? x ? (S) => e7(S) || x(S) : e7 : x,
|
|
2162
|
+
hideOn: (e7, x) => e7 ? x ? (S, C, w) => e7(S, C, w) || x(S, C, w) : e7 : x,
|
|
2163
|
+
autoPanel: (e7, x) => e7 || x
|
|
2201
2164
|
})
|
|
2202
2165
|
};
|
|
2203
2166
|
} });
|
|
2204
|
-
function combineFilter(e6,
|
|
2205
|
-
return e6 ?
|
|
2206
|
-
}
|
|
2207
|
-
function linter(e6, y = {}) {
|
|
2208
|
-
return [
|
|
2209
|
-
lintConfig.of({
|
|
2210
|
-
source: e6,
|
|
2211
|
-
config: y
|
|
2212
|
-
}),
|
|
2213
|
-
lintPlugin,
|
|
2214
|
-
lintExtensions
|
|
2215
|
-
];
|
|
2167
|
+
function combineFilter(e6, x) {
|
|
2168
|
+
return e6 ? x ? (S, C) => x(e6(S, C), C) : e6 : x;
|
|
2216
2169
|
}
|
|
2217
2170
|
function assignKeys(e6) {
|
|
2218
|
-
let
|
|
2219
|
-
if (e6) actions: for (let { name:
|
|
2220
|
-
for (let e7 = 0; e7 <
|
|
2221
|
-
let
|
|
2222
|
-
if (/[a-zA-Z]/.test(
|
|
2223
|
-
|
|
2171
|
+
let x = [];
|
|
2172
|
+
if (e6) actions: for (let { name: S } of e6) {
|
|
2173
|
+
for (let e7 = 0; e7 < S.length; e7++) {
|
|
2174
|
+
let C = S[e7];
|
|
2175
|
+
if (/[a-zA-Z]/.test(C) && !x.some((e8) => e8.toLowerCase() == C.toLowerCase())) {
|
|
2176
|
+
x.push(C);
|
|
2224
2177
|
continue actions;
|
|
2225
2178
|
}
|
|
2226
2179
|
}
|
|
2227
|
-
|
|
2180
|
+
x.push("");
|
|
2228
2181
|
}
|
|
2229
|
-
return
|
|
2182
|
+
return x;
|
|
2230
2183
|
}
|
|
2231
|
-
function renderDiagnostic(e6,
|
|
2184
|
+
function renderDiagnostic(e6, x, S) {
|
|
2232
2185
|
var _a;
|
|
2233
|
-
let
|
|
2234
|
-
return crelt("li", { class: "cm-diagnostic cm-diagnostic-" +
|
|
2235
|
-
let
|
|
2236
|
-
if (
|
|
2237
|
-
|
|
2238
|
-
let
|
|
2239
|
-
|
|
2240
|
-
}, { name:
|
|
2241
|
-
|
|
2242
|
-
crelt("u",
|
|
2243
|
-
|
|
2186
|
+
let C = S ? assignKeys(x.actions) : [];
|
|
2187
|
+
return crelt("li", { class: "cm-diagnostic cm-diagnostic-" + x.severity }, crelt("span", { class: "cm-diagnosticText" }, x.renderMessage ? x.renderMessage(e6) : x.message), (_a = x.actions) == null ? void 0 : _a.map((S2, w) => {
|
|
2188
|
+
let T = false, E = (C2) => {
|
|
2189
|
+
if (C2.preventDefault(), T) return;
|
|
2190
|
+
T = true;
|
|
2191
|
+
let w2 = findDiagnostic(e6.state.field(lintState).diagnostics, x);
|
|
2192
|
+
w2 && S2.apply(e6, w2.from, w2.to);
|
|
2193
|
+
}, { name: D } = S2, O = C[w] ? D.indexOf(C[w]) : -1, k = O < 0 ? D : [
|
|
2194
|
+
D.slice(0, O),
|
|
2195
|
+
crelt("u", D.slice(O, O + 1)),
|
|
2196
|
+
D.slice(O + 1)
|
|
2244
2197
|
];
|
|
2245
2198
|
return crelt("button", {
|
|
2246
2199
|
type: "button",
|
|
2247
|
-
class: "cm-diagnosticAction" + (
|
|
2248
|
-
onclick:
|
|
2249
|
-
onmousedown:
|
|
2250
|
-
"aria-label": ` Action: ${
|
|
2251
|
-
},
|
|
2252
|
-
}),
|
|
2200
|
+
class: "cm-diagnosticAction" + (S2.markClass ? " " + S2.markClass : ""),
|
|
2201
|
+
onclick: E,
|
|
2202
|
+
onmousedown: E,
|
|
2203
|
+
"aria-label": ` Action: ${D}${O < 0 ? "" : ` (access key "${C[w]})"`}.`
|
|
2204
|
+
}, k);
|
|
2205
|
+
}), x.source && crelt("div", { class: "cm-diagnosticSource" }, x.source));
|
|
2253
2206
|
}
|
|
2254
2207
|
var DiagnosticWidget = class extends WidgetType {
|
|
2255
2208
|
constructor(e6) {
|
|
@@ -2262,36 +2215,36 @@ var DiagnosticWidget = class extends WidgetType {
|
|
|
2262
2215
|
return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
|
|
2263
2216
|
}
|
|
2264
2217
|
}, PanelItem = class {
|
|
2265
|
-
constructor(e6,
|
|
2266
|
-
this.diagnostic =
|
|
2218
|
+
constructor(e6, x) {
|
|
2219
|
+
this.diagnostic = x, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = renderDiagnostic(e6, x, true), this.dom.id = this.id, this.dom.setAttribute("role", "option");
|
|
2267
2220
|
}
|
|
2268
2221
|
}, LintPanel = class e5 {
|
|
2269
2222
|
constructor(e6) {
|
|
2270
2223
|
this.view = e6, this.items = [];
|
|
2271
|
-
let
|
|
2272
|
-
if (
|
|
2273
|
-
else if (
|
|
2274
|
-
else if (
|
|
2275
|
-
else if (
|
|
2276
|
-
else if (
|
|
2277
|
-
else if (
|
|
2278
|
-
else if (
|
|
2279
|
-
let { diagnostic:
|
|
2280
|
-
for (let
|
|
2281
|
-
let
|
|
2282
|
-
|
|
2224
|
+
let x = (x2) => {
|
|
2225
|
+
if (x2.keyCode == 27) closeLintPanel(this.view), this.view.focus();
|
|
2226
|
+
else if (x2.keyCode == 38 || x2.keyCode == 33) this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
|
2227
|
+
else if (x2.keyCode == 40 || x2.keyCode == 34) this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
|
2228
|
+
else if (x2.keyCode == 36) this.moveSelection(0);
|
|
2229
|
+
else if (x2.keyCode == 35) this.moveSelection(this.items.length - 1);
|
|
2230
|
+
else if (x2.keyCode == 13) this.view.focus();
|
|
2231
|
+
else if (x2.keyCode >= 65 && x2.keyCode <= 90 && this.selectedIndex >= 0) {
|
|
2232
|
+
let { diagnostic: S2 } = this.items[this.selectedIndex], C = assignKeys(S2.actions);
|
|
2233
|
+
for (let w = 0; w < C.length; w++) if (C[w].toUpperCase().charCodeAt(0) == x2.keyCode) {
|
|
2234
|
+
let x3 = findDiagnostic(this.view.state.field(lintState).diagnostics, S2);
|
|
2235
|
+
x3 && S2.actions[w].apply(e6, x3.from, x3.to);
|
|
2283
2236
|
}
|
|
2284
2237
|
} else return;
|
|
2285
|
-
|
|
2286
|
-
},
|
|
2287
|
-
for (let
|
|
2238
|
+
x2.preventDefault();
|
|
2239
|
+
}, S = (e7) => {
|
|
2240
|
+
for (let x2 = 0; x2 < this.items.length; x2++) this.items[x2].dom.contains(e7.target) && this.moveSelection(x2);
|
|
2288
2241
|
};
|
|
2289
2242
|
this.list = crelt("ul", {
|
|
2290
2243
|
tabIndex: 0,
|
|
2291
2244
|
role: "listbox",
|
|
2292
2245
|
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
2293
|
-
onkeydown:
|
|
2294
|
-
onclick:
|
|
2246
|
+
onkeydown: x,
|
|
2247
|
+
onclick: S
|
|
2295
2248
|
}), this.dom = crelt("div", { class: "cm-panel-lint" }, this.list, crelt("button", {
|
|
2296
2249
|
type: "button",
|
|
2297
2250
|
name: "close",
|
|
@@ -2302,70 +2255,70 @@ var DiagnosticWidget = class extends WidgetType {
|
|
|
2302
2255
|
get selectedIndex() {
|
|
2303
2256
|
let e6 = this.view.state.field(lintState).selected;
|
|
2304
2257
|
if (!e6) return -1;
|
|
2305
|
-
for (let
|
|
2258
|
+
for (let x = 0; x < this.items.length; x++) if (this.items[x].diagnostic == e6.diagnostic) return x;
|
|
2306
2259
|
return -1;
|
|
2307
2260
|
}
|
|
2308
2261
|
update() {
|
|
2309
|
-
let { diagnostics: e6, selected:
|
|
2310
|
-
for (e6.between(0, this.view.state.doc.length, (e7,
|
|
2311
|
-
for (let e8 of
|
|
2312
|
-
if (
|
|
2313
|
-
|
|
2314
|
-
let
|
|
2315
|
-
for (let
|
|
2316
|
-
|
|
2262
|
+
let { diagnostics: e6, selected: x } = this.view.state.field(lintState), S = 0, C = false, w = null, T = /* @__PURE__ */ new Set();
|
|
2263
|
+
for (e6.between(0, this.view.state.doc.length, (e7, E, { spec: D }) => {
|
|
2264
|
+
for (let e8 of D.diagnostics) {
|
|
2265
|
+
if (T.has(e8)) continue;
|
|
2266
|
+
T.add(e8);
|
|
2267
|
+
let E2 = -1, D2;
|
|
2268
|
+
for (let x2 = S; x2 < this.items.length; x2++) if (this.items[x2].diagnostic == e8) {
|
|
2269
|
+
E2 = x2;
|
|
2317
2270
|
break;
|
|
2318
2271
|
}
|
|
2319
|
-
|
|
2272
|
+
E2 < 0 ? (D2 = new PanelItem(this.view, e8), this.items.splice(S, 0, D2), C = true) : (D2 = this.items[E2], E2 > S && (this.items.splice(S, E2 - S), C = true)), x && D2.diagnostic == x.diagnostic ? D2.dom.hasAttribute("aria-selected") || (D2.dom.setAttribute("aria-selected", "true"), w = D2) : D2.dom.hasAttribute("aria-selected") && D2.dom.removeAttribute("aria-selected"), S++;
|
|
2320
2273
|
}
|
|
2321
|
-
});
|
|
2274
|
+
}); S < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); ) C = true, this.items.pop();
|
|
2322
2275
|
this.items.length == 0 && (this.items.push(new PanelItem(this.view, {
|
|
2323
2276
|
from: -1,
|
|
2324
2277
|
to: -1,
|
|
2325
2278
|
severity: "info",
|
|
2326
2279
|
message: this.view.state.phrase("No diagnostics")
|
|
2327
|
-
})),
|
|
2280
|
+
})), C = true), w ? (this.list.setAttribute("aria-activedescendant", w.id), this.view.requestMeasure({
|
|
2328
2281
|
key: this,
|
|
2329
2282
|
read: () => ({
|
|
2330
|
-
sel:
|
|
2283
|
+
sel: w.dom.getBoundingClientRect(),
|
|
2331
2284
|
panel: this.list.getBoundingClientRect()
|
|
2332
2285
|
}),
|
|
2333
|
-
write: ({ sel: e7, panel:
|
|
2334
|
-
let
|
|
2335
|
-
e7.top <
|
|
2286
|
+
write: ({ sel: e7, panel: x2 }) => {
|
|
2287
|
+
let S2 = x2.height / this.list.offsetHeight;
|
|
2288
|
+
e7.top < x2.top ? this.list.scrollTop -= (x2.top - e7.top) / S2 : e7.bottom > x2.bottom && (this.list.scrollTop += (e7.bottom - x2.bottom) / S2);
|
|
2336
2289
|
}
|
|
2337
|
-
})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"),
|
|
2290
|
+
})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), C && this.sync();
|
|
2338
2291
|
}
|
|
2339
2292
|
sync() {
|
|
2340
2293
|
let e6 = this.list.firstChild;
|
|
2341
|
-
function
|
|
2342
|
-
let
|
|
2343
|
-
e6 =
|
|
2294
|
+
function x() {
|
|
2295
|
+
let x2 = e6;
|
|
2296
|
+
e6 = x2.nextSibling, x2.remove();
|
|
2344
2297
|
}
|
|
2345
|
-
for (let
|
|
2346
|
-
for (; e6 !=
|
|
2347
|
-
e6 =
|
|
2348
|
-
} else this.list.insertBefore(
|
|
2349
|
-
for (; e6; )
|
|
2298
|
+
for (let S of this.items) if (S.dom.parentNode == this.list) {
|
|
2299
|
+
for (; e6 != S.dom; ) x();
|
|
2300
|
+
e6 = S.dom.nextSibling;
|
|
2301
|
+
} else this.list.insertBefore(S.dom, e6);
|
|
2302
|
+
for (; e6; ) x();
|
|
2350
2303
|
}
|
|
2351
2304
|
moveSelection(e6) {
|
|
2352
2305
|
if (this.selectedIndex < 0) return;
|
|
2353
|
-
let
|
|
2354
|
-
|
|
2306
|
+
let x = findDiagnostic(this.view.state.field(lintState).diagnostics, this.items[e6].diagnostic);
|
|
2307
|
+
x && this.view.dispatch({
|
|
2355
2308
|
selection: {
|
|
2356
|
-
anchor:
|
|
2357
|
-
head:
|
|
2309
|
+
anchor: x.from,
|
|
2310
|
+
head: x.to
|
|
2358
2311
|
},
|
|
2359
2312
|
scrollIntoView: true,
|
|
2360
|
-
effects: movePanelSelection.of(
|
|
2313
|
+
effects: movePanelSelection.of(x)
|
|
2361
2314
|
});
|
|
2362
2315
|
}
|
|
2363
|
-
static open(
|
|
2364
|
-
return new e5(
|
|
2316
|
+
static open(x) {
|
|
2317
|
+
return new e5(x);
|
|
2365
2318
|
}
|
|
2366
2319
|
};
|
|
2367
|
-
function svg(e6,
|
|
2368
|
-
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${
|
|
2320
|
+
function svg(e6, x = 'viewBox="0 0 40 40"') {
|
|
2321
|
+
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${x}>${encodeURIComponent(e6)}</svg>')`;
|
|
2369
2322
|
}
|
|
2370
2323
|
function underline(e6) {
|
|
2371
2324
|
return svg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e6}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
|
|
@@ -2459,81 +2412,81 @@ function severityWeight(e6) {
|
|
|
2459
2412
|
return e6 == "error" ? 4 : e6 == "warning" ? 3 : e6 == "info" ? 2 : 1;
|
|
2460
2413
|
}
|
|
2461
2414
|
function maxSeverity(e6) {
|
|
2462
|
-
let
|
|
2463
|
-
for (let
|
|
2464
|
-
let e7 = severityWeight(
|
|
2465
|
-
e7 >
|
|
2415
|
+
let x = "hint", S = 1;
|
|
2416
|
+
for (let C of e6) {
|
|
2417
|
+
let e7 = severityWeight(C.severity);
|
|
2418
|
+
e7 > S && (S = e7, x = C.severity);
|
|
2466
2419
|
}
|
|
2467
|
-
return
|
|
2420
|
+
return x;
|
|
2468
2421
|
}
|
|
2469
2422
|
var lintExtensions = [
|
|
2470
2423
|
lintState,
|
|
2471
2424
|
/* @__PURE__ */ EditorView.decorations.compute([lintState], (e6) => {
|
|
2472
|
-
let { selected:
|
|
2473
|
-
return !
|
|
2425
|
+
let { selected: x, panel: S } = e6.field(lintState);
|
|
2426
|
+
return !x || !S || x.from == x.to ? Decoration.none : Decoration.set([activeMark.range(x.from, x.to)]);
|
|
2474
2427
|
}),
|
|
2475
2428
|
/* @__PURE__ */ hoverTooltip(lintTooltip, { hideOn: hideTooltip }),
|
|
2476
2429
|
baseTheme
|
|
2477
2430
|
];
|
|
2478
|
-
function forEachDiagnostic(e6,
|
|
2479
|
-
let
|
|
2480
|
-
if (
|
|
2481
|
-
let e7 = [],
|
|
2482
|
-
for (let
|
|
2483
|
-
for (let
|
|
2484
|
-
if (!
|
|
2485
|
-
for (let
|
|
2486
|
-
|
|
2431
|
+
function forEachDiagnostic(e6, x) {
|
|
2432
|
+
let S = e6.field(lintState, false);
|
|
2433
|
+
if (S && S.diagnostics.size) {
|
|
2434
|
+
let e7 = [], C = [], w = -1;
|
|
2435
|
+
for (let T = RangeSet.iter([S.diagnostics]); ; T.next()) {
|
|
2436
|
+
for (let S2 = 0; S2 < e7.length; S2++) (!T.value || T.value.spec.diagnostics.indexOf(e7[S2]) < 0) && (x(e7[S2], C[S2], w), e7.splice(S2, 1), C.splice(S2--, 1));
|
|
2437
|
+
if (!T.value) break;
|
|
2438
|
+
for (let x2 of T.value.spec.diagnostics) e7.indexOf(x2) < 0 && (e7.push(x2), C.push(T.from));
|
|
2439
|
+
w = T.to;
|
|
2487
2440
|
}
|
|
2488
2441
|
}
|
|
2489
2442
|
}
|
|
2490
2443
|
function _extends() {
|
|
2491
2444
|
return _extends = Object.assign ? Object.assign.bind() : function(e6) {
|
|
2492
|
-
for (var
|
|
2493
|
-
var
|
|
2494
|
-
for (var
|
|
2445
|
+
for (var x = 1; x < arguments.length; x++) {
|
|
2446
|
+
var S = arguments[x];
|
|
2447
|
+
for (var C in S) ({}).hasOwnProperty.call(S, C) && (e6[C] = S[C]);
|
|
2495
2448
|
}
|
|
2496
2449
|
return e6;
|
|
2497
2450
|
}, _extends.apply(null, arguments);
|
|
2498
2451
|
}
|
|
2499
|
-
function _objectWithoutPropertiesLoose(e6,
|
|
2452
|
+
function _objectWithoutPropertiesLoose(e6, x) {
|
|
2500
2453
|
if (e6 == null) return {};
|
|
2501
|
-
var
|
|
2502
|
-
for (var
|
|
2503
|
-
if (
|
|
2504
|
-
|
|
2454
|
+
var S = {};
|
|
2455
|
+
for (var C in e6) if ({}.hasOwnProperty.call(e6, C)) {
|
|
2456
|
+
if (x.indexOf(C) !== -1) continue;
|
|
2457
|
+
S[C] = e6[C];
|
|
2505
2458
|
}
|
|
2506
|
-
return
|
|
2459
|
+
return S;
|
|
2507
2460
|
}
|
|
2508
2461
|
var strContent = 63, strDollarBrace = 64, strEnd = 65, escapeSequence = 66, indStrContent = 67, indStrDollarBrace = 68, indStrEnd = 69, indEscapeSequence = 70, quote = 34, backslack = 92, braceL = 123, dollar = 36, apostrophe = 39, scanString = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
2509
|
-
for (let
|
|
2510
|
-
let { next:
|
|
2511
|
-
if (
|
|
2512
|
-
|
|
2462
|
+
for (let x = false, S = 0; ; S++) {
|
|
2463
|
+
let { next: C } = e6;
|
|
2464
|
+
if (C < 0) {
|
|
2465
|
+
S > 0 && e6.acceptToken(strContent);
|
|
2513
2466
|
break;
|
|
2514
|
-
} else if (
|
|
2515
|
-
|
|
2467
|
+
} else if (C === quote) {
|
|
2468
|
+
S > 0 ? e6.acceptToken(strContent) : e6.acceptToken(strEnd, 1);
|
|
2516
2469
|
break;
|
|
2517
|
-
} else if (
|
|
2518
|
-
|
|
2470
|
+
} else if (C === braceL && x) {
|
|
2471
|
+
S == 1 ? e6.acceptToken(strDollarBrace, 1) : e6.acceptToken(strContent, -1);
|
|
2519
2472
|
break;
|
|
2520
|
-
} else
|
|
2521
|
-
|
|
2473
|
+
} else C === backslack && (e6.advance(), e6.acceptToken(escapeSequence, 1));
|
|
2474
|
+
x = C === dollar, e6.advance();
|
|
2522
2475
|
}
|
|
2523
2476
|
}), scanIndString = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
2524
|
-
for (let
|
|
2525
|
-
let { next:
|
|
2526
|
-
if (
|
|
2527
|
-
|
|
2477
|
+
for (let x = false, S = false, C = 0; ; C++) {
|
|
2478
|
+
let { next: w } = e6;
|
|
2479
|
+
if (w < 0) {
|
|
2480
|
+
C > 0 && e6.acceptToken(indStrContent);
|
|
2528
2481
|
break;
|
|
2529
|
-
} else if (
|
|
2530
|
-
|
|
2482
|
+
} else if (w === apostrophe && S) {
|
|
2483
|
+
C > 1 ? e6.acceptToken(indStrContent, -1) : e6.acceptToken(indStrEnd, 1);
|
|
2531
2484
|
break;
|
|
2532
|
-
} else if (
|
|
2533
|
-
|
|
2485
|
+
} else if (w === braceL && x) {
|
|
2486
|
+
C == 1 ? e6.acceptToken(indStrDollarBrace, 1) : e6.acceptToken(indStrContent, -1);
|
|
2534
2487
|
break;
|
|
2535
|
-
} else
|
|
2536
|
-
|
|
2488
|
+
} else w === backslack && (e6.advance(), e6.acceptToken(indEscapeSequence, 1));
|
|
2489
|
+
x = w === dollar, S = w === apostrophe, e6.advance();
|
|
2537
2490
|
}
|
|
2538
2491
|
}), spec_Identifier = {
|
|
2539
2492
|
__proto__: null,
|
|
@@ -2608,10 +2561,10 @@ var strContent = 63, strDollarBrace = 64, strEnd = 65, escapeSequence = 66, indS
|
|
|
2608
2561
|
AttrSet: foldInside,
|
|
2609
2562
|
List: foldInside,
|
|
2610
2563
|
Let(e6) {
|
|
2611
|
-
let
|
|
2612
|
-
return !
|
|
2613
|
-
from:
|
|
2614
|
-
to:
|
|
2564
|
+
let x = e6.getChild("let"), S = e6.getChild("in");
|
|
2565
|
+
return !x || !S ? null : {
|
|
2566
|
+
from: x.to,
|
|
2567
|
+
to: S.from
|
|
2615
2568
|
};
|
|
2616
2569
|
}
|
|
2617
2570
|
}),
|
|
@@ -2779,19 +2732,19 @@ function isSpace(e6) {
|
|
|
2779
2732
|
return e6 == 9 || e6 == 10 || e6 == 13 || e6 == 32;
|
|
2780
2733
|
}
|
|
2781
2734
|
var cachedName = null, cachedInput = null, cachedPos = 0;
|
|
2782
|
-
function tagNameAfter(e6,
|
|
2783
|
-
let
|
|
2784
|
-
if (cachedPos ==
|
|
2785
|
-
let
|
|
2786
|
-
for (; isSpace(
|
|
2787
|
-
let
|
|
2788
|
-
for (; nameChar(
|
|
2789
|
-
return cachedInput = e6, cachedPos =
|
|
2735
|
+
function tagNameAfter(e6, x) {
|
|
2736
|
+
let S = e6.pos + x;
|
|
2737
|
+
if (cachedPos == S && cachedInput == e6) return cachedName;
|
|
2738
|
+
let C = e6.peek(x);
|
|
2739
|
+
for (; isSpace(C); ) C = e6.peek(++x);
|
|
2740
|
+
let w = "";
|
|
2741
|
+
for (; nameChar(C); ) w += String.fromCharCode(C), C = e6.peek(++x);
|
|
2742
|
+
return cachedInput = e6, cachedPos = S, cachedName = w ? w.toLowerCase() : C == question || C == bang ? void 0 : null;
|
|
2790
2743
|
}
|
|
2791
2744
|
var lessThan = 60, greaterThan$1 = 62, slash$1 = 47, question = 63, bang = 33;
|
|
2792
|
-
function ElementContext(e6,
|
|
2793
|
-
this.name = e6, this.parent =
|
|
2794
|
-
for (let
|
|
2745
|
+
function ElementContext(e6, x) {
|
|
2746
|
+
this.name = e6, this.parent = x, this.hash = x ? x.hash : 0;
|
|
2747
|
+
for (let x2 = 0; x2 < e6.length; x2++) this.hash += (this.hash << 4) + e6.charCodeAt(x2) + (e6.charCodeAt(x2) << 8);
|
|
2795
2748
|
}
|
|
2796
2749
|
var startTagTerms = [
|
|
2797
2750
|
StartTag,
|
|
@@ -2801,63 +2754,63 @@ var startTagTerms = [
|
|
|
2801
2754
|
StartTextareaTag
|
|
2802
2755
|
], elementContext = /* @__PURE__ */ new ContextTracker({
|
|
2803
2756
|
start: null,
|
|
2804
|
-
shift(e6,
|
|
2805
|
-
return startTagTerms.indexOf(
|
|
2757
|
+
shift(e6, x, S, C) {
|
|
2758
|
+
return startTagTerms.indexOf(x) > -1 ? new ElementContext(tagNameAfter(C, 1) || "", e6) : e6;
|
|
2806
2759
|
},
|
|
2807
|
-
reduce(e6,
|
|
2808
|
-
return
|
|
2760
|
+
reduce(e6, x) {
|
|
2761
|
+
return x == Element && e6 ? e6.parent : e6;
|
|
2809
2762
|
},
|
|
2810
|
-
reuse(e6,
|
|
2811
|
-
let
|
|
2812
|
-
return
|
|
2763
|
+
reuse(e6, x, S, C) {
|
|
2764
|
+
let w = x.type.id;
|
|
2765
|
+
return w == StartTag || w == OpenTag ? new ElementContext(tagNameAfter(C, 1) || "", e6) : e6;
|
|
2813
2766
|
},
|
|
2814
2767
|
hash(e6) {
|
|
2815
2768
|
return e6 ? e6.hash : 0;
|
|
2816
2769
|
},
|
|
2817
2770
|
strict: false
|
|
2818
|
-
}), tagStart = /* @__PURE__ */ new ExternalTokenizer((e6,
|
|
2771
|
+
}), tagStart = /* @__PURE__ */ new ExternalTokenizer((e6, x) => {
|
|
2819
2772
|
if (e6.next != lessThan) {
|
|
2820
|
-
e6.next < 0 &&
|
|
2773
|
+
e6.next < 0 && x.context && e6.acceptToken(missingCloseTag);
|
|
2821
2774
|
return;
|
|
2822
2775
|
}
|
|
2823
2776
|
e6.advance();
|
|
2824
|
-
let
|
|
2825
|
-
|
|
2826
|
-
let
|
|
2827
|
-
if (
|
|
2828
|
-
if (!
|
|
2829
|
-
let
|
|
2830
|
-
if (
|
|
2831
|
-
if (
|
|
2832
|
-
if (
|
|
2833
|
-
for (let e7 =
|
|
2777
|
+
let S = e6.next == slash$1;
|
|
2778
|
+
S && e6.advance();
|
|
2779
|
+
let C = tagNameAfter(e6, 0);
|
|
2780
|
+
if (C === void 0) return;
|
|
2781
|
+
if (!C) return e6.acceptToken(S ? IncompleteCloseTag : StartTag);
|
|
2782
|
+
let w = x.context ? x.context.name : null;
|
|
2783
|
+
if (S) {
|
|
2784
|
+
if (C == w) return e6.acceptToken(StartCloseTag);
|
|
2785
|
+
if (w && implicitlyClosed[w]) return e6.acceptToken(missingCloseTag, -2);
|
|
2786
|
+
for (let e7 = x.context; e7; e7 = e7.parent) if (e7.name == C) return;
|
|
2834
2787
|
e6.acceptToken(MismatchedStartCloseTag);
|
|
2835
2788
|
} else {
|
|
2836
|
-
if (
|
|
2837
|
-
if (
|
|
2838
|
-
if (
|
|
2839
|
-
if (selfClosers.hasOwnProperty(
|
|
2840
|
-
|
|
2789
|
+
if (C == "script") return e6.acceptToken(StartScriptTag);
|
|
2790
|
+
if (C == "style") return e6.acceptToken(StartStyleTag);
|
|
2791
|
+
if (C == "textarea") return e6.acceptToken(StartTextareaTag);
|
|
2792
|
+
if (selfClosers.hasOwnProperty(C)) return e6.acceptToken(StartSelfClosingTag);
|
|
2793
|
+
w && closeOnOpen[w] && closeOnOpen[w][C] ? e6.acceptToken(missingCloseTag, -1) : e6.acceptToken(StartTag);
|
|
2841
2794
|
}
|
|
2842
2795
|
}, { contextual: true });
|
|
2843
|
-
function contentTokenizer(e6,
|
|
2844
|
-
let
|
|
2845
|
-
return new ExternalTokenizer((
|
|
2846
|
-
for (let
|
|
2847
|
-
if (
|
|
2848
|
-
|
|
2796
|
+
function contentTokenizer(e6, x, S) {
|
|
2797
|
+
let C = 2 + e6.length;
|
|
2798
|
+
return new ExternalTokenizer((w) => {
|
|
2799
|
+
for (let T = 0, E = 0, D = 0; ; D++) {
|
|
2800
|
+
if (w.next < 0) {
|
|
2801
|
+
D && w.acceptToken(x);
|
|
2849
2802
|
break;
|
|
2850
2803
|
}
|
|
2851
|
-
if (
|
|
2852
|
-
else if ((
|
|
2853
|
-
else if (
|
|
2854
|
-
|
|
2804
|
+
if (T == 0 && w.next == lessThan || T == 1 && w.next == slash$1 || T >= 2 && T < C && w.next == e6.charCodeAt(T - 2)) T++, E++;
|
|
2805
|
+
else if ((T == 2 || T == C) && isSpace(w.next)) E++;
|
|
2806
|
+
else if (T == C && w.next == greaterThan$1) {
|
|
2807
|
+
D > E ? w.acceptToken(x, -E) : w.acceptToken(S, -(E - 2));
|
|
2855
2808
|
break;
|
|
2856
|
-
} else if ((
|
|
2857
|
-
|
|
2809
|
+
} else if ((w.next == 10 || w.next == 13) && D) {
|
|
2810
|
+
w.acceptToken(x, 1);
|
|
2858
2811
|
break;
|
|
2859
|
-
} else
|
|
2860
|
-
|
|
2812
|
+
} else T = E = 0;
|
|
2813
|
+
w.advance();
|
|
2861
2814
|
}
|
|
2862
2815
|
});
|
|
2863
2816
|
}
|
|
@@ -2893,108 +2846,108 @@ var scriptTokens = /* @__PURE__ */ contentTokenizer("script", scriptText, StartC
|
|
|
2893
2846
|
at,
|
|
2894
2847
|
slash
|
|
2895
2848
|
], commentContent = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
2896
|
-
for (let
|
|
2849
|
+
for (let x = 0, S = 0; ; S++) {
|
|
2897
2850
|
if (e6.next < 0) {
|
|
2898
|
-
|
|
2851
|
+
S && e6.acceptToken(commentContent$1);
|
|
2899
2852
|
break;
|
|
2900
2853
|
}
|
|
2901
|
-
if (e6.next == dash)
|
|
2902
|
-
else if (e6.next == greaterThan &&
|
|
2903
|
-
|
|
2854
|
+
if (e6.next == dash) x++;
|
|
2855
|
+
else if (e6.next == greaterThan && x >= 2) {
|
|
2856
|
+
S > 3 && e6.acceptToken(commentContent$1, -2);
|
|
2904
2857
|
break;
|
|
2905
|
-
} else
|
|
2858
|
+
} else x = 0;
|
|
2906
2859
|
e6.advance();
|
|
2907
2860
|
}
|
|
2908
2861
|
});
|
|
2909
2862
|
function createStringHandler(e6) {
|
|
2910
|
-
let
|
|
2911
|
-
return () =>
|
|
2863
|
+
let x = false, S = null, C = false;
|
|
2864
|
+
return () => x ? C ? (C = false, true) : e6.next === backslash ? (C = true, true) : S === "double" && e6.next === quoteDouble || S === "single" && e6.next === quoteSingle || S === "template" && e6.next === tick ? (x = false, S = null, true) : true : e6.next === quoteDouble ? (x = true, S = "double", true) : e6.next === quoteSingle ? (x = true, S = "single", true) : e6.next === tick ? (x = true, S = "template", true) : false;
|
|
2912
2865
|
}
|
|
2913
2866
|
function createCommentHandler(e6) {
|
|
2914
|
-
let
|
|
2915
|
-
return () =>
|
|
2867
|
+
let x = false, S = false;
|
|
2868
|
+
return () => x ? (e6.next === newline && (x = false), true) : S ? (e6.next === asterisk && e6.peek(1) === slash && (S = false), true) : e6.next === slash && e6.peek(1) === slash ? (x = true, true) : e6.next === slash && e6.peek(1) === asterisk ? (S = true, true) : false;
|
|
2916
2869
|
}
|
|
2917
2870
|
var longExpression = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
2918
2871
|
if (prefixes.includes(e6.next)) return;
|
|
2919
|
-
let
|
|
2920
|
-
let
|
|
2921
|
-
if (
|
|
2872
|
+
let x = createCommentHandler(e6), S = createStringHandler(e6), C = [], w = (e7) => {
|
|
2873
|
+
let x2 = C.lastIndexOf(e7);
|
|
2874
|
+
if (x2 !== -1) for (; C.length > x2; ) C.pop();
|
|
2922
2875
|
};
|
|
2923
|
-
for (let
|
|
2876
|
+
for (let T = 0; ; T++) {
|
|
2924
2877
|
if (e6.next < 0) {
|
|
2925
|
-
|
|
2878
|
+
T > 0 && e6.acceptToken(LongExpression);
|
|
2926
2879
|
break;
|
|
2927
2880
|
}
|
|
2928
|
-
if (
|
|
2881
|
+
if (x() || S()) {
|
|
2929
2882
|
e6.advance();
|
|
2930
2883
|
continue;
|
|
2931
2884
|
}
|
|
2932
|
-
if (
|
|
2885
|
+
if (C.length === 0 && (e6.next === curlyClose || e6.next === parenClose || e6.next === squareClose)) {
|
|
2933
2886
|
e6.acceptToken(LongExpression);
|
|
2934
2887
|
break;
|
|
2935
2888
|
}
|
|
2936
2889
|
switch (e6.next) {
|
|
2937
2890
|
case parenOpen:
|
|
2938
|
-
|
|
2891
|
+
C.push("(");
|
|
2939
2892
|
break;
|
|
2940
2893
|
case parenClose:
|
|
2941
|
-
|
|
2894
|
+
w("(");
|
|
2942
2895
|
break;
|
|
2943
2896
|
case squareOpen:
|
|
2944
|
-
|
|
2897
|
+
C.push("[");
|
|
2945
2898
|
break;
|
|
2946
2899
|
case squareClose:
|
|
2947
|
-
|
|
2900
|
+
w("[");
|
|
2948
2901
|
break;
|
|
2949
2902
|
case curlyOpen:
|
|
2950
|
-
|
|
2903
|
+
C.push("{");
|
|
2951
2904
|
break;
|
|
2952
2905
|
case curlyClose:
|
|
2953
|
-
|
|
2906
|
+
w("{");
|
|
2954
2907
|
break;
|
|
2955
2908
|
}
|
|
2956
2909
|
e6.advance();
|
|
2957
2910
|
}
|
|
2958
2911
|
}), shortExpression = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
2959
2912
|
if (prefixes.includes(e6.peek(0))) return;
|
|
2960
|
-
let
|
|
2961
|
-
let
|
|
2962
|
-
if (
|
|
2913
|
+
let x = createCommentHandler(e6), S = createStringHandler(e6), C = [], w = (e7) => {
|
|
2914
|
+
let x2 = C.lastIndexOf(e7);
|
|
2915
|
+
if (x2 !== -1) for (; C.length > x2; ) C.pop();
|
|
2963
2916
|
};
|
|
2964
|
-
for (let
|
|
2917
|
+
for (let T = 0; ; T++) {
|
|
2965
2918
|
if (e6.next < 0) {
|
|
2966
|
-
|
|
2919
|
+
T > 0 && e6.acceptToken(ShortExpression);
|
|
2967
2920
|
break;
|
|
2968
2921
|
}
|
|
2969
|
-
if (
|
|
2922
|
+
if (x() || S()) {
|
|
2970
2923
|
e6.advance();
|
|
2971
2924
|
continue;
|
|
2972
2925
|
}
|
|
2973
|
-
if (
|
|
2926
|
+
if (C.length === 0 && (e6.next === curlyClose || e6.next === parenClose || e6.next === squareClose || e6.next === comma)) {
|
|
2974
2927
|
e6.acceptToken(ShortExpression);
|
|
2975
2928
|
break;
|
|
2976
2929
|
}
|
|
2977
2930
|
switch (e6.next) {
|
|
2978
2931
|
case parenOpen:
|
|
2979
|
-
|
|
2932
|
+
C.push("(");
|
|
2980
2933
|
break;
|
|
2981
2934
|
case parenClose:
|
|
2982
|
-
|
|
2935
|
+
w("(");
|
|
2983
2936
|
break;
|
|
2984
2937
|
case squareOpen:
|
|
2985
|
-
|
|
2938
|
+
C.push("[");
|
|
2986
2939
|
break;
|
|
2987
2940
|
case squareClose:
|
|
2988
|
-
|
|
2941
|
+
w("[");
|
|
2989
2942
|
break;
|
|
2990
2943
|
case curlyOpen:
|
|
2991
|
-
|
|
2944
|
+
C.push("{");
|
|
2992
2945
|
break;
|
|
2993
2946
|
case curlyClose:
|
|
2994
|
-
|
|
2947
|
+
w("{");
|
|
2995
2948
|
break;
|
|
2996
2949
|
}
|
|
2997
|
-
if (
|
|
2950
|
+
if (T !== 0 && C.length === 0 && space.includes(e6.next)) {
|
|
2998
2951
|
e6.acceptToken(ShortExpression);
|
|
2999
2952
|
break;
|
|
3000
2953
|
}
|
|
@@ -3270,30 +3223,30 @@ var longExpression = /* @__PURE__ */ new ExternalTokenizer((e6) => {
|
|
|
3270
3223
|
],
|
|
3271
3224
|
tokenPrec: 1571
|
|
3272
3225
|
});
|
|
3273
|
-
function getAttrs(e6,
|
|
3274
|
-
let
|
|
3275
|
-
for (let
|
|
3276
|
-
let e7 =
|
|
3277
|
-
e7 && (
|
|
3226
|
+
function getAttrs(e6, x) {
|
|
3227
|
+
let S = /* @__PURE__ */ Object.create(null);
|
|
3228
|
+
for (let C of e6.firstChild.getChildren("Attribute")) {
|
|
3229
|
+
let e7 = C.getChild("AttributeName"), w = C.getChild("AttributeValue") || C.getChild("UnquotedAttributeValue");
|
|
3230
|
+
e7 && (S[x.read(e7.from, e7.to)] = w ? w.name == "AttributeValue" ? x.read(w.from + 1, w.to - 1) : x.read(w.from, w.to) : "");
|
|
3278
3231
|
}
|
|
3279
|
-
return
|
|
3232
|
+
return S;
|
|
3280
3233
|
}
|
|
3281
|
-
function maybeNest(e6,
|
|
3282
|
-
let
|
|
3283
|
-
for (let
|
|
3234
|
+
function maybeNest(e6, x, S) {
|
|
3235
|
+
let C;
|
|
3236
|
+
for (let w of S) if (!w.attrs || w.attrs(C || (C = getAttrs(e6.node.parent, x)))) return { parser: w.parser };
|
|
3284
3237
|
return null;
|
|
3285
3238
|
}
|
|
3286
3239
|
var expressionParser = /* @__PURE__ */ parser$1.configure({ top: "SingleExpression" });
|
|
3287
3240
|
function configureNesting(e6) {
|
|
3288
|
-
let
|
|
3289
|
-
for (let
|
|
3290
|
-
let e7 =
|
|
3241
|
+
let x = [], S = [], C = [];
|
|
3242
|
+
for (let w of e6) {
|
|
3243
|
+
let e7 = w.tag == "script" ? x : w.tag == "style" ? S : w.tag == "textarea" ? C : null;
|
|
3291
3244
|
if (!e7) throw RangeError("Only script, style, and textarea tags can host nested parsers");
|
|
3292
|
-
e7.push(
|
|
3245
|
+
e7.push(w);
|
|
3293
3246
|
}
|
|
3294
|
-
return parseMixed((e7,
|
|
3295
|
-
let
|
|
3296
|
-
return
|
|
3247
|
+
return parseMixed((e7, w) => {
|
|
3248
|
+
let T = e7.type.id;
|
|
3249
|
+
return T === LongExpression || T === ShortExpression ? { parser: expressionParser } : T === ScriptText ? maybeNest(e7, w, x) : T === StyleText ? maybeNest(e7, w, S) : T === TextareaText ? maybeNest(e7, w, C) : null;
|
|
3297
3250
|
});
|
|
3298
3251
|
}
|
|
3299
3252
|
var defaultNesting = [
|
|
@@ -3321,46 +3274,46 @@ var defaultNesting = [
|
|
|
3321
3274
|
wrap: /* @__PURE__ */ configureNesting(defaultNesting),
|
|
3322
3275
|
props: [/* @__PURE__ */ indentNodeProp.add({
|
|
3323
3276
|
Element: (e6) => {
|
|
3324
|
-
let
|
|
3325
|
-
return e6.node.to <= e6.pos +
|
|
3277
|
+
let x = /^(\s*)(<\/)?/.exec(e6.textAfter);
|
|
3278
|
+
return e6.node.to <= e6.pos + x[0].length ? e6.continue() : e6.lineIndent(e6.node.from) + (x[2] ? 0 : e6.unit);
|
|
3326
3279
|
},
|
|
3327
3280
|
Block: (e6) => {
|
|
3328
|
-
let
|
|
3329
|
-
if (
|
|
3330
|
-
let
|
|
3331
|
-
return
|
|
3281
|
+
let x = e6.node, S = e6.textAfter.trim();
|
|
3282
|
+
if (S.startsWith("{/")) {
|
|
3283
|
+
let C2 = x.name;
|
|
3284
|
+
return C2 === "IfBlock" && S.startsWith("{/if") || C2 === "EachBlock" && S.startsWith("{/each") || C2 === "AwaitBlock" && S.startsWith("{/await") || C2 === "KeyBlock" && S.startsWith("{/key") ? e6.lineIndent(e6.node.from) : null;
|
|
3332
3285
|
}
|
|
3333
|
-
if (
|
|
3334
|
-
if (
|
|
3335
|
-
} else if (
|
|
3336
|
-
let
|
|
3337
|
-
return e6.node.to <= e6.pos +
|
|
3286
|
+
if (x.name === "IfBlock" || x.name === "EachBlock") {
|
|
3287
|
+
if (S.startsWith("{:else")) return e6.lineIndent(x.from);
|
|
3288
|
+
} else if (x.name === "AwaitBlock" && (S.startsWith("{:then") || S.startsWith("{:catch"))) return e6.lineIndent(x.from);
|
|
3289
|
+
let C = /^(\s*)(<\/)?/.exec(e6.textAfter);
|
|
3290
|
+
return e6.node.to <= e6.pos + C[0].length ? e6.continue() : e6.lineIndent(e6.node.from) + (C[2] ? 0 : e6.unit);
|
|
3338
3291
|
},
|
|
3339
3292
|
"BlockOpen BlockClose BlockInline": (e6) => e6.column(e6.node.from) + e6.unit,
|
|
3340
3293
|
"OpenTag CloseTag SelfClosingTag": (e6) => e6.column(e6.node.from) + e6.unit,
|
|
3341
3294
|
Document: (e6) => {
|
|
3342
3295
|
if (e6.pos + /\s*/.exec(e6.textAfter)[0].length < e6.node.to) return e6.continue();
|
|
3343
|
-
let
|
|
3344
|
-
for (let
|
|
3345
|
-
let e7 =
|
|
3346
|
-
if (!e7 || e7.name != "Element" || e7.to !=
|
|
3347
|
-
|
|
3296
|
+
let x = null, S;
|
|
3297
|
+
for (let S2 = e6.node; ; ) {
|
|
3298
|
+
let e7 = S2.lastChild;
|
|
3299
|
+
if (!e7 || e7.name != "Element" || e7.to != S2.to) break;
|
|
3300
|
+
x = S2 = e7;
|
|
3348
3301
|
}
|
|
3349
|
-
return
|
|
3302
|
+
return x && !((S = x.lastChild) && (S.name === "CloseTag" || S.name === "SelfClosingTag")) ? e6.lineIndent(x.from) + e6.unit : null;
|
|
3350
3303
|
}
|
|
3351
3304
|
}), /* @__PURE__ */ foldNodeProp.add({
|
|
3352
3305
|
Block: (e6) => {
|
|
3353
|
-
let
|
|
3354
|
-
return !
|
|
3355
|
-
from:
|
|
3356
|
-
to: (
|
|
3306
|
+
let x = `${e6.name}Open`, S = `${e6.name}Close`, C = e6.firstChild, w = e6.lastChild;
|
|
3307
|
+
return !C || C.name !== x ? null : {
|
|
3308
|
+
from: C.to,
|
|
3309
|
+
to: (w == null ? void 0 : w.name) === S ? w.from : e6.to
|
|
3357
3310
|
};
|
|
3358
3311
|
},
|
|
3359
3312
|
Element: (e6) => {
|
|
3360
|
-
let
|
|
3361
|
-
return !
|
|
3362
|
-
from:
|
|
3363
|
-
to:
|
|
3313
|
+
let x = e6.firstChild, S = e6.lastChild;
|
|
3314
|
+
return !x || x.name != "OpenTag" ? null : {
|
|
3315
|
+
from: x.to,
|
|
3316
|
+
to: S.name === "CloseTag" ? S.from : e6.to
|
|
3364
3317
|
};
|
|
3365
3318
|
}
|
|
3366
3319
|
})]
|
|
@@ -3382,43 +3335,43 @@ function svelte() {
|
|
|
3382
3335
|
autoCloseTags
|
|
3383
3336
|
]);
|
|
3384
3337
|
}
|
|
3385
|
-
function elementName(e6,
|
|
3386
|
-
if (!
|
|
3387
|
-
let
|
|
3388
|
-
return
|
|
3338
|
+
function elementName(e6, x, S = e6.length) {
|
|
3339
|
+
if (!x) return "";
|
|
3340
|
+
let C = x.firstChild, w = C && (C.getChild("TagName") || C.getChild("ComponentName") || C.getChild("SvelteElementName"));
|
|
3341
|
+
return w ? e6.sliceString(w.from, Math.min(w.to, S)) : "";
|
|
3389
3342
|
}
|
|
3390
|
-
var autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((e6,
|
|
3391
|
-
if (e6.composing || e6.state.readOnly ||
|
|
3392
|
-
let { state:
|
|
3343
|
+
var autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((e6, x, S, C) => {
|
|
3344
|
+
if (e6.composing || e6.state.readOnly || x != S || C != ">" && C != "/" || !svelteLanguage.isActiveAt(e6.state, x, -1)) return false;
|
|
3345
|
+
let { state: w } = e6, T = w.changeByRange((x2) => {
|
|
3393
3346
|
var _a, _b, _c;
|
|
3394
|
-
let { head:
|
|
3395
|
-
if ((
|
|
3396
|
-
if (((_b = (_a =
|
|
3397
|
-
let
|
|
3347
|
+
let { head: S2 } = x2, T2 = syntaxTree(w).resolveInner(S2, -1), E;
|
|
3348
|
+
if ((T2.name === "TagName" || T2.name === "ComponentName" || T2.name === "SvelteElementName" || T2.name === "StartTag") && (T2 = T2.parent), C === ">" && T2.name === "OpenTag") {
|
|
3349
|
+
if (((_b = (_a = T2.parent) == null ? void 0 : _a.lastChild) == null ? void 0 : _b.name) != "CloseTag" && (E = elementName(w.doc, T2.parent, S2))) {
|
|
3350
|
+
let x3 = e6.state.doc.sliceString(S2, S2 + 1) === ">", C2 = `${x3 ? "" : ">"}</${E}>`;
|
|
3398
3351
|
return {
|
|
3399
|
-
range: EditorSelection.cursor(
|
|
3352
|
+
range: EditorSelection.cursor(S2 + 1),
|
|
3400
3353
|
changes: {
|
|
3401
|
-
from:
|
|
3402
|
-
insert:
|
|
3354
|
+
from: S2 + (x3 ? 1 : 0),
|
|
3355
|
+
insert: C2
|
|
3403
3356
|
}
|
|
3404
3357
|
};
|
|
3405
3358
|
}
|
|
3406
|
-
} else if (
|
|
3407
|
-
let
|
|
3408
|
-
if (
|
|
3409
|
-
let
|
|
3359
|
+
} else if (C === "/" && T2.name === "OpenTag") {
|
|
3360
|
+
let x3 = T2.parent, C2 = x3 == null ? void 0 : x3.parent;
|
|
3361
|
+
if (x3.from == S2 - 1 && ((_c = C2.lastChild) == null ? void 0 : _c.name) != "CloseTag" && (E = elementName(w.doc, C2, S2))) {
|
|
3362
|
+
let x4 = e6.state.doc.sliceString(S2, S2 + 1) === ">", C3 = `/${E}${x4 ? "" : ">"}`, w2 = S2 + C3.length + (x4 ? 1 : 0);
|
|
3410
3363
|
return {
|
|
3411
|
-
range: EditorSelection.cursor(
|
|
3364
|
+
range: EditorSelection.cursor(w2),
|
|
3412
3365
|
changes: {
|
|
3413
|
-
from:
|
|
3414
|
-
insert:
|
|
3366
|
+
from: S2,
|
|
3367
|
+
insert: C3
|
|
3415
3368
|
}
|
|
3416
3369
|
};
|
|
3417
3370
|
}
|
|
3418
3371
|
}
|
|
3419
|
-
return { range:
|
|
3372
|
+
return { range: x2 };
|
|
3420
3373
|
});
|
|
3421
|
-
return
|
|
3374
|
+
return T.changes.empty ? false : (e6.dispatch(T, {
|
|
3422
3375
|
userEvent: "input.type",
|
|
3423
3376
|
scrollIntoView: true
|
|
3424
3377
|
}), true);
|
|
@@ -3586,123 +3539,123 @@ var autoCloseTags = /* @__PURE__ */ EditorView.inputHandler.of((e6, y, b, x) =>
|
|
|
3586
3539
|
true: true,
|
|
3587
3540
|
false: true
|
|
3588
3541
|
}, isOperatorChar = /[+\-*&^%:=<>!|/~]/, isNegativeChar = /[-]/, curPunc;
|
|
3589
|
-
function tokenBase(e6,
|
|
3590
|
-
let
|
|
3591
|
-
if (
|
|
3592
|
-
if (isVersion(e6,
|
|
3593
|
-
if (
|
|
3594
|
-
return e6.match(`${
|
|
3542
|
+
function tokenBase(e6, x) {
|
|
3543
|
+
let S = e6.next();
|
|
3544
|
+
if (S === '"' || S === "'" || S === "`") return x.tokenize = tokenString(S), x.tokenize(e6, x);
|
|
3545
|
+
if (isVersion(e6, x)) return "version";
|
|
3546
|
+
if (S === "." && keywordsMembersOfAddressType.some(function(x2) {
|
|
3547
|
+
return e6.match(`${x2}`);
|
|
3595
3548
|
})) return "addressFunction";
|
|
3596
|
-
if (typeof
|
|
3597
|
-
if (typeof
|
|
3598
|
-
if (
|
|
3599
|
-
if (e6.eat("*")) return
|
|
3549
|
+
if (typeof S == "string" && isNumber(S, e6)) return "number";
|
|
3550
|
+
if (typeof S == "string" && /[[\]{}(),;:.]/.test(S)) return updateGarmmer(S, x);
|
|
3551
|
+
if (S === "/") {
|
|
3552
|
+
if (e6.eat("*")) return x.tokenize = tokenComment, tokenComment(e6, x);
|
|
3600
3553
|
if (e6.match(/\/{2}/)) {
|
|
3601
|
-
for (
|
|
3602
|
-
if (
|
|
3603
|
-
e6.backUp(1),
|
|
3554
|
+
for (S = e6.next(); S; ) {
|
|
3555
|
+
if (S === "@") {
|
|
3556
|
+
e6.backUp(1), x.grammar = "doc";
|
|
3604
3557
|
break;
|
|
3605
3558
|
}
|
|
3606
|
-
|
|
3559
|
+
S = e6.next();
|
|
3607
3560
|
}
|
|
3608
3561
|
return "doc";
|
|
3609
3562
|
}
|
|
3610
3563
|
if (e6.eat("/")) return e6.skipToEnd(), "comment";
|
|
3611
3564
|
}
|
|
3612
|
-
if (typeof
|
|
3613
|
-
let
|
|
3614
|
-
return typeof
|
|
3565
|
+
if (typeof S == "string" && isNegativeChar.test(S)) {
|
|
3566
|
+
let x2 = e6.peek();
|
|
3567
|
+
return typeof x2 == "string" && isNumber(x2, e6) ? "number" : "operator";
|
|
3615
3568
|
}
|
|
3616
|
-
if (typeof
|
|
3569
|
+
if (typeof S == "string" && isOperatorChar.test(S)) return e6.eatWhile(isOperatorChar), "operator";
|
|
3617
3570
|
e6.eatWhile(/[\w$_\xa1-\uffff]/);
|
|
3618
|
-
let
|
|
3619
|
-
return
|
|
3620
|
-
return
|
|
3621
|
-
}) ? "docReserve" : "doc" : (
|
|
3622
|
-
return e6.match(`.${
|
|
3623
|
-
}) ? "variable-2" :
|
|
3624
|
-
return e6.match(`.${
|
|
3625
|
-
}) ? "abi" : updateHexLiterals(
|
|
3571
|
+
let C = e6.current();
|
|
3572
|
+
return x.grammar === "doc" ? natSpecTags.some(function(e7) {
|
|
3573
|
+
return C === `@${e7}`;
|
|
3574
|
+
}) ? "docReserve" : "doc" : (C === "solidity" && x.lastToken === "pragma" && (x.lastToken = x.lastToken + " " + C), Object.prototype.propertyIsEnumerable.call(keywords, C) ? ((C === "case" || C === "default") && (curPunc = "case"), Object.prototype.propertyIsEnumerable.call(keywordsSpecial, C) && (x.lastToken = C), "keyword") : Object.prototype.propertyIsEnumerable.call(keywordsEtherUnit, C) ? "etherUnit" : Object.prototype.propertyIsEnumerable.call(keywordsContractRelated, C) ? "contractRelated" : Object.prototype.propertyIsEnumerable.call(keywordsControlStructures, C) || Object.prototype.propertyIsEnumerable.call(keywordsTypeInformation, C) || Object.prototype.propertyIsEnumerable.call(keywordsV0505NewReserve, C) ? "keyword" : Object.prototype.propertyIsEnumerable.call(keywordsValueTypes, C) || Object.prototype.propertyIsEnumerable.call(keywordsTimeUnit, C) || isValidInteger(C) || isValidBytes(C) || isValidFixed(C) ? (x.lastToken += "variable", "keyword") : Object.prototype.propertyIsEnumerable.call(atoms, C) ? "atom" : Object.prototype.propertyIsEnumerable.call(keywordsErrorHandling, C) ? "errorHandling" : Object.prototype.propertyIsEnumerable.call(keywordsMathematicalAndCryptographicFuctions, C) ? "mathematicalAndCryptographic" : Object.prototype.propertyIsEnumerable.call(keywordsMoreBlockAndTransactionProperties, C) || Object.prototype.propertyIsEnumerable.call(keywordsBlockAndTransactionProperties, C) && keywordsBlockAndTransactionProperties[C].some(function(x2) {
|
|
3575
|
+
return e6.match(`.${x2}`);
|
|
3576
|
+
}) ? "variable-2" : C === "abi" && keywordsAbiEncodeDecodeFunctions[C].some(function(x2) {
|
|
3577
|
+
return e6.match(`.${x2}`);
|
|
3578
|
+
}) ? "abi" : updateHexLiterals(C, e6) ?? ((x.lastToken === "functionName(" || x.lastToken === "returns(") && Object.prototype.propertyIsEnumerable.call(keywordsContractList, C) ? (x.lastToken += "variable", "variable") : x.lastToken === "function" ? (x.lastToken = "functionName", x.para ?? (x.para = (x.grammar = "function", "")), x.para += "functionName", "functionName") : x.lastToken === "functionName(variable" ? (x.lastToken = "functionName(", "parameterValue") : x.lastToken === "returns(variable" ? (x.lastToken = "returns(", "parameterValue") : (x.lastToken === "address" && C === "payable" && (x.lastToken = "address payable"), (x.lastToken === "contract" || x.lastToken === "struct") && (keywordsContractList[C] = true, x.lastToken = null), x.grammar === "function" ? "parameterValue" : "variable")));
|
|
3626
3579
|
}
|
|
3627
3580
|
function tokenString(e6) {
|
|
3628
|
-
return function(
|
|
3629
|
-
let
|
|
3630
|
-
for (
|
|
3631
|
-
if (
|
|
3632
|
-
|
|
3581
|
+
return function(x, S) {
|
|
3582
|
+
let C = false, w, T = false;
|
|
3583
|
+
for (w = x.next(); w != null; ) {
|
|
3584
|
+
if (w === e6 && !C) {
|
|
3585
|
+
T = true;
|
|
3633
3586
|
break;
|
|
3634
3587
|
}
|
|
3635
|
-
|
|
3588
|
+
C = !C && e6 !== "`" && w === "\\", w = x.next();
|
|
3636
3589
|
}
|
|
3637
|
-
return (
|
|
3590
|
+
return (T || !(C || e6 === "`")) && (S.tokenize = tokenBase), "string";
|
|
3638
3591
|
};
|
|
3639
3592
|
}
|
|
3640
|
-
function tokenComment(e6,
|
|
3641
|
-
let
|
|
3642
|
-
for (;
|
|
3643
|
-
if (
|
|
3644
|
-
|
|
3593
|
+
function tokenComment(e6, x) {
|
|
3594
|
+
let S = false, C = e6.next();
|
|
3595
|
+
for (; C; ) {
|
|
3596
|
+
if (C === "/" && S) {
|
|
3597
|
+
x.tokenize = tokenBase;
|
|
3645
3598
|
break;
|
|
3646
3599
|
}
|
|
3647
|
-
|
|
3600
|
+
S = C === "*", C = e6.next();
|
|
3648
3601
|
}
|
|
3649
3602
|
return "comment";
|
|
3650
3603
|
}
|
|
3651
|
-
function isVersion(e6,
|
|
3652
|
-
if (
|
|
3604
|
+
function isVersion(e6, x) {
|
|
3605
|
+
if (x.lastToken === "pragma solidity") return x.lastToken = null, !x.startOfLine && (e6.match(/[\^{0}][0-9.]+/) || e6.match(/[>=]+?[\s]*[0-9.]+[\s]*[<]?[\s]*[0-9.]+/));
|
|
3653
3606
|
}
|
|
3654
|
-
function isNumber(e6,
|
|
3655
|
-
if (/[\d.]/.test(e6)) return e6 === "." ?
|
|
3607
|
+
function isNumber(e6, x) {
|
|
3608
|
+
if (/[\d.]/.test(e6)) return e6 === "." ? x.match(/^[0-9]+([eE][-+]?[0-9]+)?/) : e6 === "0" ? x.match(/^[xX][0-9a-fA-F]+/) || x.match(/^0[0-7]+/) : x.match(/^[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?/), true;
|
|
3656
3609
|
}
|
|
3657
3610
|
function isValidInteger(e6) {
|
|
3658
3611
|
if (e6.match(/^[u]?int/)) {
|
|
3659
3612
|
if (e6.indexOf("t") + 1 === e6.length) return true;
|
|
3660
|
-
let
|
|
3661
|
-
return
|
|
3613
|
+
let x = Number(e6.substr(e6.indexOf("t") + 1, e6.length));
|
|
3614
|
+
return x % 8 == 0 && x <= 256;
|
|
3662
3615
|
}
|
|
3663
3616
|
}
|
|
3664
3617
|
function isValidBytes(e6) {
|
|
3665
3618
|
if (e6.match(/^bytes/)) {
|
|
3666
3619
|
if (e6.indexOf("s") + 1 === e6.length) return true;
|
|
3667
|
-
let
|
|
3668
|
-
return Number(
|
|
3620
|
+
let x = e6.substr(e6.indexOf("s") + 1, e6.length);
|
|
3621
|
+
return Number(x) <= 32;
|
|
3669
3622
|
}
|
|
3670
3623
|
}
|
|
3671
3624
|
function isValidFixed(e6) {
|
|
3672
3625
|
if (e6.match(/^[u]?fixed([0-9]+x[0-9]+)?/)) {
|
|
3673
3626
|
if (e6.indexOf("d") + 1 === e6.length) return true;
|
|
3674
|
-
let
|
|
3675
|
-
return
|
|
3627
|
+
let x = e6.substr(e6.indexOf("d") + 1, e6.length).split("x").map(Number);
|
|
3628
|
+
return x[0] % 8 == 0 && x[0] <= 256 && x[1] <= 80;
|
|
3676
3629
|
}
|
|
3677
3630
|
}
|
|
3678
|
-
function updateHexLiterals(e6,
|
|
3679
|
-
if (e6.match(/^hex/) &&
|
|
3680
|
-
let e7 = false,
|
|
3681
|
-
for (
|
|
3682
|
-
if (
|
|
3683
|
-
if (
|
|
3684
|
-
|
|
3631
|
+
function updateHexLiterals(e6, x) {
|
|
3632
|
+
if (e6.match(/^hex/) && x.peek() === '"') {
|
|
3633
|
+
let e7 = false, S, C = "", w = "";
|
|
3634
|
+
for (S = x.next(); S; ) {
|
|
3635
|
+
if (w += S, S === '"' && e7) {
|
|
3636
|
+
if (C = w.substring(1, w.length - 1), C.match(/^[0-9a-fA-F]+$/)) return "number";
|
|
3637
|
+
x.backUp(w.length);
|
|
3685
3638
|
break;
|
|
3686
3639
|
}
|
|
3687
|
-
e7 || (e7 =
|
|
3640
|
+
e7 || (e7 = S === '"'), S = x.next();
|
|
3688
3641
|
}
|
|
3689
3642
|
}
|
|
3690
3643
|
}
|
|
3691
|
-
function updateGarmmer(e6,
|
|
3692
|
-
return e6 === "," &&
|
|
3644
|
+
function updateGarmmer(e6, x) {
|
|
3645
|
+
return e6 === "," && x.para === "functionName(variable" && (x.para = "functionName("), x.para != null && x.para.startsWith("functionName") && (e6 === ")" ? x.para.endsWith("(") && (x.para = x.para.substr(0, x.para.length - 1), x.para === "functionName" && (x.grammar = "")) : e6 === "(" && (x.para += e6)), e6 === "(" && x.lastToken === "functionName" ? x.lastToken += e6 : e6 === ")" && x.lastToken === "functionName(" ? x.lastToken = null : e6 === "(" && x.lastToken === "returns" ? x.lastToken += e6 : e6 === ")" && (x.lastToken === "returns(" || x.lastToken === "returns(variable") && (x.lastToken = null), e6 === "(" && x.lastToken === "address" && (x.lastToken += e6), curPunc = e6, null;
|
|
3693
3646
|
}
|
|
3694
3647
|
var Context = class {
|
|
3695
|
-
constructor(e6,
|
|
3696
|
-
this.indented = e6, this.column =
|
|
3648
|
+
constructor(e6, x, S, C, w) {
|
|
3649
|
+
this.indented = e6, this.column = x, this.type = S, this.align = C, this.prev = w;
|
|
3697
3650
|
}
|
|
3698
3651
|
};
|
|
3699
|
-
function pushContext(e6,
|
|
3700
|
-
return e6.context = new Context(e6.indented,
|
|
3652
|
+
function pushContext(e6, x, S) {
|
|
3653
|
+
return e6.context = new Context(e6.indented, x, S, null, e6.context), e6.context;
|
|
3701
3654
|
}
|
|
3702
3655
|
function popContext(e6) {
|
|
3703
3656
|
if (!e6.context.prev) return;
|
|
3704
|
-
let
|
|
3705
|
-
return (
|
|
3657
|
+
let x = e6.context.type;
|
|
3658
|
+
return (x === ")" || x === "]" || x === "}") && (e6.indented = e6.context.indented), e6.context = e6.context.prev;
|
|
3706
3659
|
}
|
|
3707
3660
|
var parser = {
|
|
3708
3661
|
startState(e6) {
|
|
@@ -3716,19 +3669,19 @@ var parser = {
|
|
|
3716
3669
|
para: null
|
|
3717
3670
|
};
|
|
3718
3671
|
},
|
|
3719
|
-
token(e6,
|
|
3720
|
-
let
|
|
3721
|
-
if (e6.sol() && (
|
|
3672
|
+
token(e6, x) {
|
|
3673
|
+
let S = x.context;
|
|
3674
|
+
if (e6.sol() && (S.align ?? (S.align = false), x.indented = e6.indentation(), x.startOfLine = true, S.type === "case" && (S.type = "}"), x.grammar === "doc" && (x.grammar = null)), e6.eatSpace()) return null;
|
|
3722
3675
|
curPunc = null;
|
|
3723
|
-
let
|
|
3724
|
-
return
|
|
3676
|
+
let C = (x.tokenize || tokenBase)(e6, x);
|
|
3677
|
+
return C === "comment" ? C : (S.align ?? (S.align = true), curPunc === "{" ? pushContext(x, e6.column(), "}") : curPunc === "[" ? pushContext(x, e6.column(), "]") : curPunc === "(" ? pushContext(x, e6.column(), ")") : curPunc === "case" ? S.type = "case" : (curPunc === "}" && S.type === "}" || curPunc === S.type) && popContext(x), x.startOfLine = false, C);
|
|
3725
3678
|
},
|
|
3726
|
-
indent(e6,
|
|
3679
|
+
indent(e6, x, S) {
|
|
3727
3680
|
if (e6.tokenize !== tokenBase && e6.tokenize != null) return null;
|
|
3728
|
-
let
|
|
3729
|
-
if (
|
|
3730
|
-
let
|
|
3731
|
-
return
|
|
3681
|
+
let C = e6.context, w = x && x.charAt(0);
|
|
3682
|
+
if (C.type === "case" && /^(?:case|default)\b/.test(x)) return e6.context.type = "}", C.indented;
|
|
3683
|
+
let T = w === C.type;
|
|
3684
|
+
return C.align ? C.column + (T ? 0 : 1) : C.indented + (T ? 0 : S.unit);
|
|
3732
3685
|
},
|
|
3733
3686
|
electricChars: "{}):",
|
|
3734
3687
|
closeBrackets: "()[]{}''\"\"``",
|
|
@@ -3982,16 +3935,16 @@ function loadLanguage(e6) {
|
|
|
3982
3935
|
}
|
|
3983
3936
|
var basicSetup = function(e6) {
|
|
3984
3937
|
e6 === void 0 && (e6 = {});
|
|
3985
|
-
var { crosshairCursor:
|
|
3986
|
-
e6.closeBracketsKeymap !== false && (
|
|
3987
|
-
var
|
|
3988
|
-
return e6.lineNumbers !== false &&
|
|
3938
|
+
var { crosshairCursor: x = false } = e6, S = [];
|
|
3939
|
+
e6.closeBracketsKeymap !== false && (S = S.concat(closeBracketsKeymap)), e6.defaultKeymap !== false && (S = S.concat(defaultKeymap)), e6.searchKeymap !== false && (S = S.concat(searchKeymap)), e6.historyKeymap !== false && (S = S.concat(historyKeymap)), e6.foldKeymap !== false && (S = S.concat(foldKeymap)), e6.completionKeymap !== false && (S = S.concat(completionKeymap)), e6.lintKeymap !== false && (S = S.concat(lintKeymap));
|
|
3940
|
+
var C = [];
|
|
3941
|
+
return e6.lineNumbers !== false && C.push(lineNumbers()), e6.highlightActiveLineGutter !== false && C.push(highlightActiveLineGutter()), e6.highlightSpecialChars !== false && C.push(highlightSpecialChars()), e6.history !== false && C.push(history()), e6.foldGutter !== false && C.push(foldGutter()), e6.drawSelection !== false && C.push(drawSelection()), e6.dropCursor !== false && C.push(dropCursor()), e6.allowMultipleSelections !== false && C.push(EditorState.allowMultipleSelections.of(true)), e6.indentOnInput !== false && C.push(indentOnInput()), e6.syntaxHighlighting !== false && C.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true })), e6.bracketMatching !== false && C.push(bracketMatching()), e6.closeBrackets !== false && C.push(closeBrackets()), e6.autocompletion !== false && C.push(autocompletion()), e6.rectangularSelection !== false && C.push(rectangularSelection()), x !== false && C.push(crosshairCursor()), e6.highlightActiveLine !== false && C.push(highlightActiveLine()), e6.highlightSelectionMatches !== false && C.push(highlightSelectionMatches()), e6.tabSize && typeof e6.tabSize == "number" && C.push(indentUnit.of(" ".repeat(e6.tabSize))), C.concat([keymap.of(S.flat())]).filter(Boolean);
|
|
3989
3942
|
}, minimalSetup = function(e6) {
|
|
3990
3943
|
e6 === void 0 && (e6 = {});
|
|
3991
|
-
var
|
|
3992
|
-
e6.defaultKeymap !== false && (
|
|
3993
|
-
var
|
|
3994
|
-
return e6.highlightSpecialChars !== false &&
|
|
3944
|
+
var x = [];
|
|
3945
|
+
e6.defaultKeymap !== false && (x = x.concat(defaultKeymap)), e6.historyKeymap !== false && (x = x.concat(historyKeymap));
|
|
3946
|
+
var S = [];
|
|
3947
|
+
return e6.highlightSpecialChars !== false && S.push(highlightSpecialChars()), e6.history !== false && S.push(history()), e6.drawSelection !== false && S.push(drawSelection()), e6.syntaxHighlighting !== false && S.push(syntaxHighlighting(defaultHighlightStyle, { fallback: true })), S.concat([keymap.of(x.flat())]).filter(Boolean);
|
|
3995
3948
|
}, chalky = "#e5c07b", coral = "#e06c75", cyan = "#56b6c2", invalid = "#ffffff", ivory = "#abb2bf", stone = "#7d8799", malibu = "#61afef", sage = "#98c379", whiskey = "#d19a66", violet = "#c678dd", darkBackground = "#21252b", highlightBackground = "#2c313a", background = "#282c34", tooltipBackground = "#353a42", selection = "#3E4451", cursor = "#528bff", oneDark = [/* @__PURE__ */ EditorView.theme({
|
|
3996
3949
|
"&": {
|
|
3997
3950
|
color: ivory,
|
|
@@ -4145,21 +4098,21 @@ var basicSetup = function(e6) {
|
|
|
4145
4098
|
}
|
|
4146
4099
|
]))], defaultLightThemeOption = EditorView.theme({ "&": { backgroundColor: "#fff" } }, { dark: false }), getDefaultExtensions = function(e6) {
|
|
4147
4100
|
e6 === void 0 && (e6 = {});
|
|
4148
|
-
var { indentWithTab:
|
|
4149
|
-
switch (
|
|
4101
|
+
var { indentWithTab: x = true, editable: S = true, readOnly: C = false, theme: w = "light", placeholder: T = "", basicSetup: E = true } = e6, D = [];
|
|
4102
|
+
switch (x && D.unshift(keymap.of([indentWithTab])), E && (typeof E == "boolean" ? D.unshift(basicSetup()) : D.unshift(basicSetup(E))), T && D.unshift(placeholder(T)), w) {
|
|
4150
4103
|
case "light":
|
|
4151
|
-
|
|
4104
|
+
D.push(defaultLightThemeOption);
|
|
4152
4105
|
break;
|
|
4153
4106
|
case "dark":
|
|
4154
|
-
|
|
4107
|
+
D.push(oneDark);
|
|
4155
4108
|
break;
|
|
4156
4109
|
case "none":
|
|
4157
4110
|
break;
|
|
4158
4111
|
default:
|
|
4159
|
-
|
|
4112
|
+
D.push(w);
|
|
4160
4113
|
break;
|
|
4161
4114
|
}
|
|
4162
|
-
return
|
|
4115
|
+
return S === false && D.push(EditorView.editable.of(false)), C && D.push(EditorState.readOnly.of(true)), [...D];
|
|
4163
4116
|
}, getStatistics = (e6) => ({
|
|
4164
4117
|
line: e6.state.doc.lineAt(e6.state.selection.main.from),
|
|
4165
4118
|
lineCount: e6.state.doc.lines,
|
|
@@ -4171,11 +4124,11 @@ var basicSetup = function(e6) {
|
|
|
4171
4124
|
selectionAsSingle: e6.state.selection.asSingle().main,
|
|
4172
4125
|
ranges: e6.state.selection.ranges,
|
|
4173
4126
|
selectionCode: e6.state.sliceDoc(e6.state.selection.main.from, e6.state.selection.main.to),
|
|
4174
|
-
selections: e6.state.selection.ranges.map((
|
|
4127
|
+
selections: e6.state.selection.ranges.map((x) => e6.state.sliceDoc(x.from, x.to)),
|
|
4175
4128
|
selectedText: e6.state.selection.ranges.some((e7) => !e7.empty)
|
|
4176
4129
|
}), TimeoutLatch = class {
|
|
4177
|
-
constructor(e6,
|
|
4178
|
-
this.timeLeftMS = void 0, this.timeoutMS = void 0, this.isCancelled = false, this.isTimeExhausted = false, this.callbacks = [], this.timeLeftMS =
|
|
4130
|
+
constructor(e6, x) {
|
|
4131
|
+
this.timeLeftMS = void 0, this.timeoutMS = void 0, this.isCancelled = false, this.isTimeExhausted = false, this.callbacks = [], this.timeLeftMS = x, this.timeoutMS = x, this.callbacks.push(e6);
|
|
4179
4132
|
}
|
|
4180
4133
|
tick() {
|
|
4181
4134
|
if (!this.isCancelled && !this.isTimeExhausted && (this.timeLeftMS--, this.timeLeftMS <= 0)) {
|
|
@@ -4221,68 +4174,66 @@ var basicSetup = function(e6) {
|
|
|
4221
4174
|
}
|
|
4222
4175
|
}, globalScheduler = null, getScheduler = () => typeof window > "u" ? new Scheduler() : (globalScheduler || (globalScheduler = new Scheduler()), globalScheduler), ExternalChange = Annotation.define(), TYPING_TIMOUT = 200, emptyExtensions = [];
|
|
4223
4176
|
function useCodeMirror(e6) {
|
|
4224
|
-
var { value:
|
|
4177
|
+
var { value: x, selection: S, onChange: C, onStatistics: w, onCreateEditor: T, onUpdate: E, extensions: D = emptyExtensions, autoFocus: O, theme: k = "light", height: A = null, minHeight: j = null, maxHeight: M = null, width: N = null, minWidth: P = null, maxWidth: F = null, placeholder: I = "", editable: L = true, readOnly: R = false, indentWithTab: z = true, basicSetup: B = true, root: V, initialState: H } = e6, [U, W] = (0, import_react.useState)(), [G, K] = (0, import_react.useState)(), [J, Y] = (0, import_react.useState)(), X = (0, import_react.useState)(() => ({ current: null }))[0], Z = (0, import_react.useState)(() => ({ current: null }))[0], Q = EditorView.theme({
|
|
4225
4178
|
"&": {
|
|
4226
|
-
height:
|
|
4227
|
-
minHeight:
|
|
4228
|
-
maxHeight:
|
|
4229
|
-
width:
|
|
4230
|
-
minWidth:
|
|
4231
|
-
maxWidth:
|
|
4179
|
+
height: A,
|
|
4180
|
+
minHeight: j,
|
|
4181
|
+
maxHeight: M,
|
|
4182
|
+
width: N,
|
|
4183
|
+
minWidth: P,
|
|
4184
|
+
maxWidth: F
|
|
4232
4185
|
},
|
|
4233
4186
|
"& .cm-scroller": { height: "100% !important" }
|
|
4234
4187
|
}), $ = [
|
|
4235
4188
|
EditorView.updateListener.of((e7) => {
|
|
4236
|
-
e7.docChanged && typeof
|
|
4189
|
+
e7.docChanged && typeof C == "function" && !e7.transactions.some((e8) => e8.annotation(ExternalChange)) && (X.current ? X.current.reset() : (X.current = new TimeoutLatch(() => {
|
|
4237
4190
|
if (Z.current) {
|
|
4238
4191
|
var e8 = Z.current;
|
|
4239
4192
|
Z.current = null, e8();
|
|
4240
4193
|
}
|
|
4241
|
-
|
|
4242
|
-
}, TYPING_TIMOUT), getScheduler().add(
|
|
4194
|
+
X.current = null;
|
|
4195
|
+
}, TYPING_TIMOUT), getScheduler().add(X.current)), C(e7.state.doc.toString(), e7)), w && w(getStatistics(e7));
|
|
4243
4196
|
}),
|
|
4244
4197
|
Q,
|
|
4245
4198
|
...getDefaultExtensions({
|
|
4246
|
-
theme:
|
|
4247
|
-
editable:
|
|
4248
|
-
readOnly:
|
|
4249
|
-
placeholder:
|
|
4250
|
-
indentWithTab:
|
|
4251
|
-
basicSetup:
|
|
4199
|
+
theme: k,
|
|
4200
|
+
editable: L,
|
|
4201
|
+
readOnly: R,
|
|
4202
|
+
placeholder: I,
|
|
4203
|
+
indentWithTab: z,
|
|
4204
|
+
basicSetup: B
|
|
4252
4205
|
})
|
|
4253
4206
|
];
|
|
4254
|
-
return
|
|
4255
|
-
if (
|
|
4207
|
+
return E && typeof E == "function" && $.push(EditorView.updateListener.of(E)), $ = $.concat(D), (0, import_react.useLayoutEffect)(() => {
|
|
4208
|
+
if (U && !J) {
|
|
4256
4209
|
var e7 = {
|
|
4257
|
-
doc:
|
|
4258
|
-
selection:
|
|
4210
|
+
doc: x,
|
|
4211
|
+
selection: S,
|
|
4259
4212
|
extensions: $
|
|
4260
|
-
},
|
|
4261
|
-
if (
|
|
4262
|
-
var
|
|
4263
|
-
state:
|
|
4264
|
-
parent:
|
|
4265
|
-
root:
|
|
4213
|
+
}, C2 = H ? EditorState.fromJSON(H.json, e7, H.fields) : EditorState.create(e7);
|
|
4214
|
+
if (Y(C2), !G) {
|
|
4215
|
+
var w2 = new EditorView({
|
|
4216
|
+
state: C2,
|
|
4217
|
+
parent: U,
|
|
4218
|
+
root: V
|
|
4266
4219
|
});
|
|
4267
|
-
|
|
4220
|
+
K(w2), T && T(w2, C2);
|
|
4268
4221
|
}
|
|
4269
4222
|
}
|
|
4270
4223
|
return () => {
|
|
4271
|
-
|
|
4224
|
+
G && (Y(void 0), K(void 0));
|
|
4272
4225
|
};
|
|
4273
|
-
}, [
|
|
4274
|
-
e6.container &&
|
|
4226
|
+
}, [U, J]), (0, import_react.useEffect)(() => {
|
|
4227
|
+
e6.container && W(e6.container);
|
|
4275
4228
|
}, [e6.container]), (0, import_react.useEffect)(() => () => {
|
|
4276
|
-
|
|
4277
|
-
}, [
|
|
4278
|
-
|
|
4279
|
-
}, [
|
|
4280
|
-
|
|
4229
|
+
G && (G.destroy(), K(void 0)), X.current && (X.current = (X.current.cancel(), null));
|
|
4230
|
+
}, [G]), (0, import_react.useEffect)(() => {
|
|
4231
|
+
O && G && G.focus();
|
|
4232
|
+
}, [O, G]), (0, import_react.useEffect)(() => {
|
|
4233
|
+
G && G.dispatch({ effects: StateEffect.reconfigure.of($) });
|
|
4281
4234
|
}, [
|
|
4282
|
-
D,
|
|
4283
|
-
T,
|
|
4284
|
-
O,
|
|
4285
4235
|
k,
|
|
4236
|
+
D,
|
|
4286
4237
|
A,
|
|
4287
4238
|
j,
|
|
4288
4239
|
M,
|
|
@@ -4292,32 +4243,34 @@ function useCodeMirror(e6) {
|
|
|
4292
4243
|
I,
|
|
4293
4244
|
L,
|
|
4294
4245
|
R,
|
|
4295
|
-
|
|
4296
|
-
|
|
4246
|
+
z,
|
|
4247
|
+
B,
|
|
4248
|
+
C,
|
|
4249
|
+
E
|
|
4297
4250
|
]), (0, import_react.useEffect)(() => {
|
|
4298
|
-
if (
|
|
4299
|
-
var e7 =
|
|
4300
|
-
if (
|
|
4301
|
-
var
|
|
4302
|
-
|
|
4251
|
+
if (x !== void 0) {
|
|
4252
|
+
var e7 = G ? G.state.doc.toString() : "";
|
|
4253
|
+
if (G && x !== e7) {
|
|
4254
|
+
var S2 = X.current && !X.current.isDone, C2 = () => {
|
|
4255
|
+
G && x !== G.state.doc.toString() && G.dispatch({
|
|
4303
4256
|
changes: {
|
|
4304
4257
|
from: 0,
|
|
4305
|
-
to:
|
|
4306
|
-
insert:
|
|
4258
|
+
to: G.state.doc.toString().length,
|
|
4259
|
+
insert: x || ""
|
|
4307
4260
|
},
|
|
4308
4261
|
annotations: [ExternalChange.of(true)]
|
|
4309
4262
|
});
|
|
4310
4263
|
};
|
|
4311
|
-
|
|
4264
|
+
S2 ? Z.current = C2 : C2();
|
|
4312
4265
|
}
|
|
4313
4266
|
}
|
|
4314
|
-
}, [
|
|
4315
|
-
state:
|
|
4316
|
-
setState:
|
|
4317
|
-
view:
|
|
4318
|
-
setView:
|
|
4319
|
-
container:
|
|
4320
|
-
setContainer:
|
|
4267
|
+
}, [x, G]), {
|
|
4268
|
+
state: J,
|
|
4269
|
+
setState: Y,
|
|
4270
|
+
view: G,
|
|
4271
|
+
setView: K,
|
|
4272
|
+
container: U,
|
|
4273
|
+
setContainer: W
|
|
4321
4274
|
};
|
|
4322
4275
|
}
|
|
4323
4276
|
var _excluded = [
|
|
@@ -4344,62 +4297,61 @@ var _excluded = [
|
|
|
4344
4297
|
"readOnly",
|
|
4345
4298
|
"root",
|
|
4346
4299
|
"initialState"
|
|
4347
|
-
], ReactCodeMirror = /* @__PURE__ */ (0, import_react.forwardRef)((e6,
|
|
4348
|
-
var { className:
|
|
4349
|
-
root:
|
|
4350
|
-
value:
|
|
4351
|
-
autoFocus:
|
|
4352
|
-
theme:
|
|
4353
|
-
height:
|
|
4354
|
-
minHeight:
|
|
4355
|
-
maxHeight:
|
|
4356
|
-
width:
|
|
4357
|
-
minWidth:
|
|
4358
|
-
maxWidth:
|
|
4359
|
-
basicSetup:
|
|
4360
|
-
placeholder:
|
|
4361
|
-
indentWithTab:
|
|
4362
|
-
editable:
|
|
4363
|
-
readOnly:
|
|
4364
|
-
selection:
|
|
4365
|
-
onChange:
|
|
4366
|
-
onStatistics:
|
|
4367
|
-
onCreateEditor:
|
|
4368
|
-
onUpdate:
|
|
4369
|
-
extensions:
|
|
4370
|
-
initialState:
|
|
4300
|
+
], ReactCodeMirror = /* @__PURE__ */ (0, import_react.forwardRef)((e6, x) => {
|
|
4301
|
+
var { className: S, value: C = "", selection: w, extensions: T = [], onChange: E, onStatistics: D, onCreateEditor: O, onUpdate: k, autoFocus: A, theme: j = "light", height: M, minHeight: N, maxHeight: P, width: F, minWidth: I, maxWidth: L, basicSetup: R, placeholder: z, indentWithTab: B, editable: V, readOnly: H, root: U, initialState: W } = e6, G = _objectWithoutPropertiesLoose(e6, _excluded), K = (0, import_react.useRef)(null), { state: J, view: Y, container: X, setContainer: Z } = useCodeMirror({
|
|
4302
|
+
root: U,
|
|
4303
|
+
value: C,
|
|
4304
|
+
autoFocus: A,
|
|
4305
|
+
theme: j,
|
|
4306
|
+
height: M,
|
|
4307
|
+
minHeight: N,
|
|
4308
|
+
maxHeight: P,
|
|
4309
|
+
width: F,
|
|
4310
|
+
minWidth: I,
|
|
4311
|
+
maxWidth: L,
|
|
4312
|
+
basicSetup: R,
|
|
4313
|
+
placeholder: z,
|
|
4314
|
+
indentWithTab: B,
|
|
4315
|
+
editable: V,
|
|
4316
|
+
readOnly: H,
|
|
4317
|
+
selection: w,
|
|
4318
|
+
onChange: E,
|
|
4319
|
+
onStatistics: D,
|
|
4320
|
+
onCreateEditor: O,
|
|
4321
|
+
onUpdate: k,
|
|
4322
|
+
extensions: T,
|
|
4323
|
+
initialState: W
|
|
4371
4324
|
});
|
|
4372
|
-
(0, import_react.useImperativeHandle)(
|
|
4373
|
-
editor:
|
|
4374
|
-
state:
|
|
4375
|
-
view:
|
|
4325
|
+
(0, import_react.useImperativeHandle)(x, () => ({
|
|
4326
|
+
editor: K.current,
|
|
4327
|
+
state: J,
|
|
4328
|
+
view: Y
|
|
4376
4329
|
}), [
|
|
4377
|
-
|
|
4330
|
+
K,
|
|
4331
|
+
X,
|
|
4378
4332
|
J,
|
|
4379
|
-
|
|
4380
|
-
K
|
|
4333
|
+
Y
|
|
4381
4334
|
]);
|
|
4382
|
-
var
|
|
4383
|
-
|
|
4384
|
-
}, [
|
|
4385
|
-
if (typeof
|
|
4335
|
+
var Q = (0, import_react.useCallback)((e7) => {
|
|
4336
|
+
K.current = e7, Z(e7);
|
|
4337
|
+
}, [Z]);
|
|
4338
|
+
if (typeof C != "string") throw Error("value must be typeof string but got " + typeof C);
|
|
4386
4339
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", _extends({
|
|
4387
|
-
ref:
|
|
4388
|
-
className: (typeof
|
|
4389
|
-
},
|
|
4340
|
+
ref: Q,
|
|
4341
|
+
className: (typeof j == "string" ? "cm-theme-" + j : "cm-theme") + (S ? " " + S : "")
|
|
4342
|
+
}, G));
|
|
4390
4343
|
});
|
|
4391
4344
|
ReactCodeMirror.displayName = "CodeMirror";
|
|
4392
4345
|
var esm_default = ReactCodeMirror;
|
|
4393
4346
|
export {
|
|
4394
4347
|
_extends as a,
|
|
4395
|
-
|
|
4396
|
-
CopyClipboardIcon as d,
|
|
4348
|
+
historyField as c,
|
|
4397
4349
|
loadLanguage as i,
|
|
4398
|
-
|
|
4350
|
+
insertTab as l,
|
|
4399
4351
|
minimalSetup as n,
|
|
4400
4352
|
forEachDiagnostic as o,
|
|
4401
4353
|
langs as r,
|
|
4402
|
-
|
|
4354
|
+
setDiagnostics as s,
|
|
4403
4355
|
esm_default as t,
|
|
4404
|
-
|
|
4356
|
+
CopyClipboardIcon as u
|
|
4405
4357
|
};
|