ghost 5.64.0 → 5.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/{tryghost-adapter-cache-memory-ttl-5.64.0.tgz → tryghost-adapter-cache-memory-ttl-5.65.0.tgz} +0 -0
- package/components/{tryghost-adapter-cache-redis-5.64.0.tgz → tryghost-adapter-cache-redis-5.65.0.tgz} +0 -0
- package/components/{tryghost-adapter-manager-5.64.0.tgz → tryghost-adapter-manager-5.65.0.tgz} +0 -0
- package/components/tryghost-announcement-bar-settings-5.65.0.tgz +0 -0
- package/components/tryghost-api-framework-5.65.0.tgz +0 -0
- package/components/tryghost-api-version-compatibility-service-5.65.0.tgz +0 -0
- package/components/{tryghost-audience-feedback-5.64.0.tgz → tryghost-audience-feedback-5.65.0.tgz} +0 -0
- package/components/{tryghost-bookshelf-repository-5.64.0.tgz → tryghost-bookshelf-repository-5.65.0.tgz} +0 -0
- package/components/tryghost-bootstrap-socket-5.65.0.tgz +0 -0
- package/components/tryghost-collections-5.65.0.tgz +0 -0
- package/components/{tryghost-constants-5.64.0.tgz → tryghost-constants-5.65.0.tgz} +0 -0
- package/components/{tryghost-custom-theme-settings-service-5.64.0.tgz → tryghost-custom-theme-settings-service-5.65.0.tgz} +0 -0
- package/components/{tryghost-data-generator-5.64.0.tgz → tryghost-data-generator-5.65.0.tgz} +0 -0
- package/components/{tryghost-domain-events-5.64.0.tgz → tryghost-domain-events-5.65.0.tgz} +0 -0
- package/components/tryghost-donations-5.65.0.tgz +0 -0
- package/components/{tryghost-dynamic-routing-events-5.64.0.tgz → tryghost-dynamic-routing-events-5.65.0.tgz} +0 -0
- package/components/{tryghost-email-analytics-provider-mailgun-5.64.0.tgz → tryghost-email-analytics-provider-mailgun-5.65.0.tgz} +0 -0
- package/components/tryghost-email-analytics-service-5.65.0.tgz +0 -0
- package/components/{tryghost-email-content-generator-5.64.0.tgz → tryghost-email-content-generator-5.65.0.tgz} +0 -0
- package/components/tryghost-email-events-5.65.0.tgz +0 -0
- package/components/{tryghost-email-service-5.64.0.tgz → tryghost-email-service-5.65.0.tgz} +0 -0
- package/components/tryghost-email-suppression-list-5.65.0.tgz +0 -0
- package/components/tryghost-event-aware-cache-wrapper-5.65.0.tgz +0 -0
- package/components/{tryghost-express-dynamic-redirects-5.64.0.tgz → tryghost-express-dynamic-redirects-5.65.0.tgz} +0 -0
- package/components/{tryghost-external-media-inliner-5.64.0.tgz → tryghost-external-media-inliner-5.65.0.tgz} +0 -0
- package/components/{tryghost-extract-api-key-5.64.0.tgz → tryghost-extract-api-key-5.65.0.tgz} +0 -0
- package/components/{tryghost-html-to-plaintext-5.64.0.tgz → tryghost-html-to-plaintext-5.65.0.tgz} +0 -0
- package/components/tryghost-i18n-5.65.0.tgz +0 -0
- package/components/tryghost-importer-handler-content-files-5.65.0.tgz +0 -0
- package/components/{tryghost-importer-revue-5.64.0.tgz → tryghost-importer-revue-5.65.0.tgz} +0 -0
- package/components/tryghost-in-memory-repository-5.65.0.tgz +0 -0
- package/components/{tryghost-job-manager-5.64.0.tgz → tryghost-job-manager-5.65.0.tgz} +0 -0
- package/components/{tryghost-link-redirects-5.64.0.tgz → tryghost-link-redirects-5.65.0.tgz} +0 -0
- package/components/tryghost-link-replacer-5.65.0.tgz +0 -0
- package/components/{tryghost-link-tracking-5.64.0.tgz → tryghost-link-tracking-5.65.0.tgz} +0 -0
- package/components/{tryghost-magic-link-5.64.0.tgz → tryghost-magic-link-5.65.0.tgz} +0 -0
- package/components/tryghost-mail-events-5.65.0.tgz +0 -0
- package/components/{tryghost-mailgun-client-5.64.0.tgz → tryghost-mailgun-client-5.65.0.tgz} +0 -0
- package/components/{tryghost-member-attribution-5.64.0.tgz → tryghost-member-attribution-5.65.0.tgz} +0 -0
- package/components/{tryghost-member-events-5.64.0.tgz → tryghost-member-events-5.65.0.tgz} +0 -0
- package/components/tryghost-members-api-5.65.0.tgz +0 -0
- package/components/{tryghost-members-csv-5.64.0.tgz → tryghost-members-csv-5.65.0.tgz} +0 -0
- package/components/{tryghost-members-events-service-5.64.0.tgz → tryghost-members-events-service-5.65.0.tgz} +0 -0
- package/components/{tryghost-members-importer-5.64.0.tgz → tryghost-members-importer-5.65.0.tgz} +0 -0
- package/components/{tryghost-members-offers-5.64.0.tgz → tryghost-members-offers-5.65.0.tgz} +0 -0
- package/components/tryghost-members-payments-5.65.0.tgz +0 -0
- package/components/tryghost-members-ssr-5.65.0.tgz +0 -0
- package/components/{tryghost-members-stripe-service-5.64.0.tgz → tryghost-members-stripe-service-5.65.0.tgz} +0 -0
- package/components/tryghost-mentions-email-report-5.65.0.tgz +0 -0
- package/components/{tryghost-milestones-5.64.0.tgz → tryghost-milestones-5.65.0.tgz} +0 -0
- package/components/tryghost-minifier-5.65.0.tgz +0 -0
- package/components/tryghost-model-to-domain-event-interceptor-5.65.0.tgz +0 -0
- package/components/tryghost-mw-api-version-mismatch-5.65.0.tgz +0 -0
- package/components/{tryghost-mw-cache-control-5.64.0.tgz → tryghost-mw-cache-control-5.65.0.tgz} +0 -0
- package/components/{tryghost-mw-error-handler-5.64.0.tgz → tryghost-mw-error-handler-5.65.0.tgz} +0 -0
- package/components/tryghost-mw-session-from-token-5.65.0.tgz +0 -0
- package/components/tryghost-mw-update-user-last-seen-5.65.0.tgz +0 -0
- package/components/{tryghost-mw-version-match-5.64.0.tgz → tryghost-mw-version-match-5.65.0.tgz} +0 -0
- package/components/tryghost-mw-vhost-5.65.0.tgz +0 -0
- package/components/tryghost-nql-filter-expansions-5.65.0.tgz +0 -0
- package/components/tryghost-oembed-service-5.65.0.tgz +0 -0
- package/components/{tryghost-package-json-5.64.0.tgz → tryghost-package-json-5.65.0.tgz} +0 -0
- package/components/{tryghost-post-events-5.64.0.tgz → tryghost-post-events-5.65.0.tgz} +0 -0
- package/components/{tryghost-post-revisions-5.64.0.tgz → tryghost-post-revisions-5.65.0.tgz} +0 -0
- package/components/tryghost-posts-service-5.65.0.tgz +0 -0
- package/components/tryghost-recommendations-5.65.0.tgz +0 -0
- package/components/tryghost-referrers-5.65.0.tgz +0 -0
- package/components/tryghost-security-5.65.0.tgz +0 -0
- package/components/tryghost-session-service-5.65.0.tgz +0 -0
- package/components/{tryghost-settings-path-manager-5.64.0.tgz → tryghost-settings-path-manager-5.65.0.tgz} +0 -0
- package/components/tryghost-slack-notifications-5.65.0.tgz +0 -0
- package/components/{tryghost-staff-service-5.64.0.tgz → tryghost-staff-service-5.65.0.tgz} +0 -0
- package/components/{tryghost-stats-service-5.64.0.tgz → tryghost-stats-service-5.65.0.tgz} +0 -0
- package/components/{tryghost-tiers-5.64.0.tgz → tryghost-tiers-5.65.0.tgz} +0 -0
- package/components/{tryghost-update-check-service-5.64.0.tgz → tryghost-update-check-service-5.65.0.tgz} +0 -0
- package/components/{tryghost-verification-trigger-5.64.0.tgz → tryghost-verification-trigger-5.65.0.tgz} +0 -0
- package/components/{tryghost-version-notifications-data-service-5.64.0.tgz → tryghost-version-notifications-data-service-5.65.0.tgz} +0 -0
- package/components/tryghost-webmentions-5.65.0.tgz +0 -0
- package/core/built/admin/assets/admin-x-settings/CodeEditorView-2b332315.mjs +2347 -0
- package/core/built/admin/assets/admin-x-settings/admin-x-settings.js +6 -0
- package/core/built/admin/assets/admin-x-settings/index-4a560e9e.mjs +19693 -0
- package/core/built/admin/assets/admin-x-settings/index-9cc1df42.mjs +13955 -0
- package/core/built/admin/assets/admin-x-settings/index-b8cc4f2e.mjs +3465 -0
- package/core/built/admin/assets/admin-x-settings/limit-service-7694c0d4.mjs +12902 -0
- package/core/built/admin/assets/admin-x-settings/modals-2073207d.mjs +11518 -0
- package/core/built/admin/assets/{chunk.143.ff0abfe4495f055b0f3d.js → chunk.143.c91dc1d2a8a5a1f318ec.js} +5 -5
- package/core/built/admin/assets/{chunk.178.3e470522312d6d4ed2e4.js → chunk.178.d921de78463d288f3bcd.js} +4 -4
- package/core/built/admin/assets/{chunk.237.9b7032162949850f6c76.js → chunk.518.396deed1a0c759d1f403.js} +1136 -1077
- package/core/built/admin/assets/{ghost-10ff4bcba99e1759098702a12c531352.js → ghost-38746349a72536a92f4d8235a582d716.js} +58 -57
- package/core/built/admin/assets/ghost-761b67711827277b7095ebc7acc5c49f.css +1 -0
- package/core/built/admin/assets/ghost-dark-d3f636c30e80bdd7f21d3fb4770073c9.css +1 -0
- package/core/built/admin/assets/{vendor-f8ce8bd43cf5dad6608f828ab48cee9b.js → vendor-240cd1dbd84a2e07709b867442c41840.js} +4 -4
- package/core/built/admin/index.html +6 -6
- package/core/frontend/src/cards/css/collection.css +42 -12
- package/core/server/api/endpoints/posts-public.js +63 -0
- package/core/server/api/endpoints/recommendations-public.js +1 -1
- package/core/server/api/endpoints/recommendations.js +20 -5
- package/core/server/api/endpoints/utils/serializers/output/config.js +0 -1
- package/core/server/api/endpoints/utils/serializers/output/site.js +1 -1
- package/core/server/data/migrations/versions/5.64/2023-09-19-04-25-40-truncate-stale-built-in-collections-posts.js +6 -8
- package/core/server/data/migrations/versions/5.64/2023-09-19-04-34-10-repopulate-built-in-collection-posts.js +6 -65
- package/core/server/data/migrations/versions/5.65/2023-09-22-06-42-15-truncate-stale-built-in-collections-posts.js +12 -0
- package/core/server/data/migrations/versions/5.65/2023-09-22-06-42-55-repopulate-built-in-featured-collection-posts.js +49 -0
- package/core/server/data/schema/fixtures/fixtures.json +0 -14
- package/core/server/lib/lexical.js +22 -3
- package/core/server/lib/request-external.js +10 -4
- package/core/server/models/post.js +71 -1
- package/core/server/models/relations/authors.js +1 -1
- package/core/server/services/collections/BookshelfCollectionsRepository.js +38 -35
- package/core/server/services/collections/PostsRepository.js +5 -0
- package/core/server/services/collections/service.js +7 -3
- package/core/server/services/members/content-gating.js +11 -7
- package/core/server/services/mentions/WebmentionMetadata.js +14 -2
- package/core/server/services/public-config/site.js +1 -1
- package/core/server/services/recommendations/RecommendationServiceWrapper.js +3 -2
- package/core/server/web/api/endpoints/admin/routes.js +2 -1
- package/core/shared/config/defaults.json +0 -4
- package/core/shared/labs.js +1 -1
- package/package.json +160 -159
- package/yarn.lock +361 -364
- package/components/tryghost-announcement-bar-settings-5.64.0.tgz +0 -0
- package/components/tryghost-api-framework-5.64.0.tgz +0 -0
- package/components/tryghost-api-version-compatibility-service-5.64.0.tgz +0 -0
- package/components/tryghost-bootstrap-socket-5.64.0.tgz +0 -0
- package/components/tryghost-collections-5.64.0.tgz +0 -0
- package/components/tryghost-donations-5.64.0.tgz +0 -0
- package/components/tryghost-email-analytics-service-5.64.0.tgz +0 -0
- package/components/tryghost-email-events-5.64.0.tgz +0 -0
- package/components/tryghost-email-suppression-list-5.64.0.tgz +0 -0
- package/components/tryghost-event-aware-cache-wrapper-5.64.0.tgz +0 -0
- package/components/tryghost-i18n-5.64.0.tgz +0 -0
- package/components/tryghost-importer-handler-content-files-5.64.0.tgz +0 -0
- package/components/tryghost-in-memory-repository-5.64.0.tgz +0 -0
- package/components/tryghost-link-replacer-5.64.0.tgz +0 -0
- package/components/tryghost-mail-events-5.64.0.tgz +0 -0
- package/components/tryghost-members-api-5.64.0.tgz +0 -0
- package/components/tryghost-members-payments-5.64.0.tgz +0 -0
- package/components/tryghost-members-ssr-5.64.0.tgz +0 -0
- package/components/tryghost-mentions-email-report-5.64.0.tgz +0 -0
- package/components/tryghost-minifier-5.64.0.tgz +0 -0
- package/components/tryghost-model-to-domain-event-interceptor-5.64.0.tgz +0 -0
- package/components/tryghost-mw-api-version-mismatch-5.64.0.tgz +0 -0
- package/components/tryghost-mw-session-from-token-5.64.0.tgz +0 -0
- package/components/tryghost-mw-update-user-last-seen-5.64.0.tgz +0 -0
- package/components/tryghost-mw-vhost-5.64.0.tgz +0 -0
- package/components/tryghost-nql-filter-expansions-5.64.0.tgz +0 -0
- package/components/tryghost-oembed-service-5.64.0.tgz +0 -0
- package/components/tryghost-posts-service-5.64.0.tgz +0 -0
- package/components/tryghost-recommendations-5.64.0.tgz +0 -0
- package/components/tryghost-referrers-5.64.0.tgz +0 -0
- package/components/tryghost-security-5.64.0.tgz +0 -0
- package/components/tryghost-session-service-5.64.0.tgz +0 -0
- package/components/tryghost-slack-notifications-5.64.0.tgz +0 -0
- package/components/tryghost-webmentions-5.64.0.tgz +0 -0
- package/core/built/admin/assets/ghost-33664cad4cd6664a8b5fa56e62c5005f.css +0 -1
- package/core/built/admin/assets/ghost-dark-0452daeaee3a9b16dcd954ea60dad518.css +0 -1
- /package/core/built/admin/assets/{chunk.237.9b7032162949850f6c76.js.LICENSE.txt → chunk.518.396deed1a0c759d1f403.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,2347 @@
|
|
|
1
|
+
import { b as xe, d as W, aK as wt, bk as qn, z as Rt, bl as Hn, j as P, bm as Vn, C as zn, J as Un, G as $n, H as Gn, D as Kn } from "./index-4a560e9e.mjs";
|
|
2
|
+
import { E as p, F as ce, v as Be, S as Ee, o as d, w as qe, C as Jn, x as _n, y as Tt, z as Ot, A as be, B as It, G as Pt, H as Wt, J as $e, K as Xe, M as w, O as j, g as et, b as Ge, Q as jn, R as Y, V as Ft, U as y, W as Qn, X as Yn, Y as se, Z as M, _ as Zn, $ as Xn, a0 as tt, a1 as le, a2 as er, a3 as tr, a4 as nr, a5 as rr, a6 as or, a7 as ir, a8 as sr, a9 as lr, aa as ar, ab as cr, ac as hr, ad as ur, ae as fr, af as dr, ag as Nt, ah as mr, ai as gr, aj as pr, ak as yr, al as xr, am as kr, an as qt, ao as br, ap as Sr, t as f, aq as Cr } from "./index-9cc1df42.mjs";
|
|
3
|
+
const vr = (t) => {
|
|
4
|
+
let { state: e } = t, r = e.doc.lineAt(e.selection.main.from), n = rt(t.state, r.from);
|
|
5
|
+
return n.line ? Ar(t) : n.block ? Lr(t) : !1;
|
|
6
|
+
};
|
|
7
|
+
function nt(t, e) {
|
|
8
|
+
return ({ state: r, dispatch: n }) => {
|
|
9
|
+
if (r.readOnly)
|
|
10
|
+
return !1;
|
|
11
|
+
let o = t(e, r);
|
|
12
|
+
return o ? (n(r.update(o)), !0) : !1;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const Ar = /* @__PURE__ */ nt(
|
|
16
|
+
Er,
|
|
17
|
+
0
|
|
18
|
+
/* CommentOption.Toggle */
|
|
19
|
+
), Mr = /* @__PURE__ */ nt(
|
|
20
|
+
Ht,
|
|
21
|
+
0
|
|
22
|
+
/* CommentOption.Toggle */
|
|
23
|
+
), Lr = /* @__PURE__ */ nt(
|
|
24
|
+
(t, e) => Ht(t, e, Br(e)),
|
|
25
|
+
0
|
|
26
|
+
/* CommentOption.Toggle */
|
|
27
|
+
);
|
|
28
|
+
function rt(t, e) {
|
|
29
|
+
let r = t.languageDataAt("commentTokens", e);
|
|
30
|
+
return r.length ? r[0] : {};
|
|
31
|
+
}
|
|
32
|
+
const ie = 50;
|
|
33
|
+
function Dr(t, { open: e, close: r }, n, o) {
|
|
34
|
+
let i = t.sliceDoc(n - ie, n), s = t.sliceDoc(o, o + ie), l = /\s*$/.exec(i)[0].length, a = /^\s*/.exec(s)[0].length, c = i.length - l;
|
|
35
|
+
if (i.slice(c - e.length, c) == e && s.slice(a, a + r.length) == r)
|
|
36
|
+
return {
|
|
37
|
+
open: { pos: n - l, margin: l && 1 },
|
|
38
|
+
close: { pos: o + a, margin: a && 1 }
|
|
39
|
+
};
|
|
40
|
+
let h, u;
|
|
41
|
+
o - n <= 2 * ie ? h = u = t.sliceDoc(n, o) : (h = t.sliceDoc(n, n + ie), u = t.sliceDoc(o - ie, o));
|
|
42
|
+
let m = /^\s*/.exec(h)[0].length, x = /\s*$/.exec(u)[0].length, S = u.length - x - r.length;
|
|
43
|
+
return h.slice(m, m + e.length) == e && u.slice(S, S + r.length) == r ? {
|
|
44
|
+
open: {
|
|
45
|
+
pos: n + m + e.length,
|
|
46
|
+
margin: /\s/.test(h.charAt(m + e.length)) ? 1 : 0
|
|
47
|
+
},
|
|
48
|
+
close: {
|
|
49
|
+
pos: o - x - r.length,
|
|
50
|
+
margin: /\s/.test(u.charAt(S - 1)) ? 1 : 0
|
|
51
|
+
}
|
|
52
|
+
} : null;
|
|
53
|
+
}
|
|
54
|
+
function Br(t) {
|
|
55
|
+
let e = [];
|
|
56
|
+
for (let r of t.selection.ranges) {
|
|
57
|
+
let n = t.doc.lineAt(r.from), o = r.to <= n.to ? n : t.doc.lineAt(r.to), i = e.length - 1;
|
|
58
|
+
i >= 0 && e[i].to > n.from ? e[i].to = o.to : e.push({ from: n.from + /^\s*/.exec(n.text)[0].length, to: o.to });
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
62
|
+
function Ht(t, e, r = e.selection.ranges) {
|
|
63
|
+
let n = r.map((i) => rt(e, i.from).block);
|
|
64
|
+
if (!n.every((i) => i))
|
|
65
|
+
return null;
|
|
66
|
+
let o = r.map((i, s) => Dr(e, n[s], i.from, i.to));
|
|
67
|
+
if (t != 2 && !o.every((i) => i))
|
|
68
|
+
return { changes: e.changes(r.map((i, s) => o[s] ? [] : [{ from: i.from, insert: n[s].open + " " }, { from: i.to, insert: " " + n[s].close }])) };
|
|
69
|
+
if (t != 1 && o.some((i) => i)) {
|
|
70
|
+
let i = [];
|
|
71
|
+
for (let s = 0, l; s < o.length; s++)
|
|
72
|
+
if (l = o[s]) {
|
|
73
|
+
let a = n[s], { open: c, close: h } = l;
|
|
74
|
+
i.push({ from: c.pos - a.open.length, to: c.pos + c.margin }, { from: h.pos - h.margin, to: h.pos + a.close.length });
|
|
75
|
+
}
|
|
76
|
+
return { changes: i };
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
function Er(t, e, r = e.selection.ranges) {
|
|
81
|
+
let n = [], o = -1;
|
|
82
|
+
for (let { from: i, to: s } of r) {
|
|
83
|
+
let l = n.length, a = 1e9, c = rt(e, i).line;
|
|
84
|
+
if (c) {
|
|
85
|
+
for (let h = i; h <= s; ) {
|
|
86
|
+
let u = e.doc.lineAt(h);
|
|
87
|
+
if (u.from > o && (i == s || s > u.from)) {
|
|
88
|
+
o = u.from;
|
|
89
|
+
let m = /^\s*/.exec(u.text)[0].length, x = m == u.length, S = u.text.slice(m, m + c.length) == c ? m : -1;
|
|
90
|
+
m < u.text.length && m < a && (a = m), n.push({ line: u, comment: S, token: c, indent: m, empty: x, single: !1 });
|
|
91
|
+
}
|
|
92
|
+
h = u.to + 1;
|
|
93
|
+
}
|
|
94
|
+
if (a < 1e9)
|
|
95
|
+
for (let h = l; h < n.length; h++)
|
|
96
|
+
n[h].indent < n[h].line.text.length && (n[h].indent = a);
|
|
97
|
+
n.length == l + 1 && (n[l].single = !0);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (t != 2 && n.some((i) => i.comment < 0 && (!i.empty || i.single))) {
|
|
101
|
+
let i = [];
|
|
102
|
+
for (let { line: l, token: a, indent: c, empty: h, single: u } of n)
|
|
103
|
+
(u || !h) && i.push({ from: l.from + c, insert: a + " " });
|
|
104
|
+
let s = e.changes(i);
|
|
105
|
+
return { changes: s, selection: e.selection.map(s, 1) };
|
|
106
|
+
} else if (t != 1 && n.some((i) => i.comment >= 0)) {
|
|
107
|
+
let i = [];
|
|
108
|
+
for (let { line: s, comment: l, token: a } of n)
|
|
109
|
+
if (l >= 0) {
|
|
110
|
+
let c = s.from + l, h = c + a.length;
|
|
111
|
+
s.text[h - s.from] == " " && h++, i.push({ from: c, to: h });
|
|
112
|
+
}
|
|
113
|
+
return { changes: i };
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const Ke = /* @__PURE__ */ Xe.define(), wr = /* @__PURE__ */ Xe.define(), Rr = /* @__PURE__ */ ce.define(), Vt = /* @__PURE__ */ ce.define({
|
|
118
|
+
combine(t) {
|
|
119
|
+
return Be(t, {
|
|
120
|
+
minDepth: 100,
|
|
121
|
+
newGroupDelay: 500,
|
|
122
|
+
joinToEvent: (e, r) => r
|
|
123
|
+
}, {
|
|
124
|
+
minDepth: Math.max,
|
|
125
|
+
newGroupDelay: Math.min,
|
|
126
|
+
joinToEvent: (e, r) => (n, o) => e(n, o) || r(n, o)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
function Tr(t) {
|
|
131
|
+
let e = 0;
|
|
132
|
+
return t.iterChangedRanges((r, n) => e = n), e;
|
|
133
|
+
}
|
|
134
|
+
const zt = /* @__PURE__ */ Ee.define({
|
|
135
|
+
create() {
|
|
136
|
+
return T.empty;
|
|
137
|
+
},
|
|
138
|
+
update(t, e) {
|
|
139
|
+
let r = e.state.facet(Vt), n = e.annotation(Ke);
|
|
140
|
+
if (n) {
|
|
141
|
+
let a = e.docChanged ? d.single(Tr(e.changes)) : void 0, c = C.fromTransaction(e, a), h = n.side, u = h == 0 ? t.undone : t.done;
|
|
142
|
+
return c ? u = Se(u, u.length, r.minDepth, c) : u = Gt(u, e.startState.selection), new T(h == 0 ? n.rest : u, h == 0 ? u : n.rest);
|
|
143
|
+
}
|
|
144
|
+
let o = e.annotation(wr);
|
|
145
|
+
if ((o == "full" || o == "before") && (t = t.isolate()), e.annotation(qe.addToHistory) === !1)
|
|
146
|
+
return e.changes.empty ? t : t.addMapping(e.changes.desc);
|
|
147
|
+
let i = C.fromTransaction(e), s = e.annotation(qe.time), l = e.annotation(qe.userEvent);
|
|
148
|
+
return i ? t = t.addChanges(i, s, l, r, e) : e.selection && (t = t.addSelection(e.startState.selection, s, l, r.newGroupDelay)), (o == "full" || o == "after") && (t = t.isolate()), t;
|
|
149
|
+
},
|
|
150
|
+
toJSON(t) {
|
|
151
|
+
return { done: t.done.map((e) => e.toJSON()), undone: t.undone.map((e) => e.toJSON()) };
|
|
152
|
+
},
|
|
153
|
+
fromJSON(t) {
|
|
154
|
+
return new T(t.done.map(C.fromJSON), t.undone.map(C.fromJSON));
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
function Or(t = {}) {
|
|
158
|
+
return [
|
|
159
|
+
zt,
|
|
160
|
+
Vt.of(t),
|
|
161
|
+
p.domEventHandlers({
|
|
162
|
+
beforeinput(e, r) {
|
|
163
|
+
let n = e.inputType == "historyUndo" ? Ut : e.inputType == "historyRedo" ? Je : null;
|
|
164
|
+
return n ? (e.preventDefault(), n(r)) : !1;
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
];
|
|
168
|
+
}
|
|
169
|
+
function we(t, e) {
|
|
170
|
+
return function({ state: r, dispatch: n }) {
|
|
171
|
+
if (!e && r.readOnly)
|
|
172
|
+
return !1;
|
|
173
|
+
let o = r.field(zt, !1);
|
|
174
|
+
if (!o)
|
|
175
|
+
return !1;
|
|
176
|
+
let i = o.pop(t, r, e);
|
|
177
|
+
return i ? (n(i), !0) : !1;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const Ut = /* @__PURE__ */ we(0, !1), Je = /* @__PURE__ */ we(1, !1), Ir = /* @__PURE__ */ we(0, !0), Pr = /* @__PURE__ */ we(1, !0);
|
|
181
|
+
class C {
|
|
182
|
+
constructor(e, r, n, o, i) {
|
|
183
|
+
this.changes = e, this.effects = r, this.mapped = n, this.startSelection = o, this.selectionsAfter = i;
|
|
184
|
+
}
|
|
185
|
+
setSelAfter(e) {
|
|
186
|
+
return new C(this.changes, this.effects, this.mapped, this.startSelection, e);
|
|
187
|
+
}
|
|
188
|
+
toJSON() {
|
|
189
|
+
var e, r, n;
|
|
190
|
+
return {
|
|
191
|
+
changes: (e = this.changes) === null || e === void 0 ? void 0 : e.toJSON(),
|
|
192
|
+
mapped: (r = this.mapped) === null || r === void 0 ? void 0 : r.toJSON(),
|
|
193
|
+
startSelection: (n = this.startSelection) === null || n === void 0 ? void 0 : n.toJSON(),
|
|
194
|
+
selectionsAfter: this.selectionsAfter.map((o) => o.toJSON())
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
static fromJSON(e) {
|
|
198
|
+
return new C(e.changes && Jn.fromJSON(e.changes), [], e.mapped && _n.fromJSON(e.mapped), e.startSelection && d.fromJSON(e.startSelection), e.selectionsAfter.map(d.fromJSON));
|
|
199
|
+
}
|
|
200
|
+
// This does not check `addToHistory` and such, it assumes the
|
|
201
|
+
// transaction needs to be converted to an item. Returns null when
|
|
202
|
+
// there are no changes or effects in the transaction.
|
|
203
|
+
static fromTransaction(e, r) {
|
|
204
|
+
let n = L;
|
|
205
|
+
for (let o of e.startState.facet(Rr)) {
|
|
206
|
+
let i = o(e);
|
|
207
|
+
i.length && (n = n.concat(i));
|
|
208
|
+
}
|
|
209
|
+
return !n.length && e.changes.empty ? null : new C(e.changes.invert(e.startState.doc), n, void 0, r || e.startState.selection, L);
|
|
210
|
+
}
|
|
211
|
+
static selection(e) {
|
|
212
|
+
return new C(void 0, L, void 0, void 0, e);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function Se(t, e, r, n) {
|
|
216
|
+
let o = e + 1 > r + 20 ? e - r - 1 : 0, i = t.slice(o, e);
|
|
217
|
+
return i.push(n), i;
|
|
218
|
+
}
|
|
219
|
+
function Wr(t, e) {
|
|
220
|
+
let r = [], n = !1;
|
|
221
|
+
return t.iterChangedRanges((o, i) => r.push(o, i)), e.iterChangedRanges((o, i, s, l) => {
|
|
222
|
+
for (let a = 0; a < r.length; ) {
|
|
223
|
+
let c = r[a++], h = r[a++];
|
|
224
|
+
l >= c && s <= h && (n = !0);
|
|
225
|
+
}
|
|
226
|
+
}), n;
|
|
227
|
+
}
|
|
228
|
+
function Fr(t, e) {
|
|
229
|
+
return t.ranges.length == e.ranges.length && t.ranges.filter((r, n) => r.empty != e.ranges[n].empty).length === 0;
|
|
230
|
+
}
|
|
231
|
+
function $t(t, e) {
|
|
232
|
+
return t.length ? e.length ? t.concat(e) : t : e;
|
|
233
|
+
}
|
|
234
|
+
const L = [], Nr = 200;
|
|
235
|
+
function Gt(t, e) {
|
|
236
|
+
if (t.length) {
|
|
237
|
+
let r = t[t.length - 1], n = r.selectionsAfter.slice(Math.max(0, r.selectionsAfter.length - Nr));
|
|
238
|
+
return n.length && n[n.length - 1].eq(e) ? t : (n.push(e), Se(t, t.length - 1, 1e9, r.setSelAfter(n)));
|
|
239
|
+
} else
|
|
240
|
+
return [C.selection([e])];
|
|
241
|
+
}
|
|
242
|
+
function qr(t) {
|
|
243
|
+
let e = t[t.length - 1], r = t.slice();
|
|
244
|
+
return r[t.length - 1] = e.setSelAfter(e.selectionsAfter.slice(0, e.selectionsAfter.length - 1)), r;
|
|
245
|
+
}
|
|
246
|
+
function He(t, e) {
|
|
247
|
+
if (!t.length)
|
|
248
|
+
return t;
|
|
249
|
+
let r = t.length, n = L;
|
|
250
|
+
for (; r; ) {
|
|
251
|
+
let o = Hr(t[r - 1], e, n);
|
|
252
|
+
if (o.changes && !o.changes.empty || o.effects.length) {
|
|
253
|
+
let i = t.slice(0, r);
|
|
254
|
+
return i[r - 1] = o, i;
|
|
255
|
+
} else
|
|
256
|
+
e = o.mapped, r--, n = o.selectionsAfter;
|
|
257
|
+
}
|
|
258
|
+
return n.length ? [C.selection(n)] : L;
|
|
259
|
+
}
|
|
260
|
+
function Hr(t, e, r) {
|
|
261
|
+
let n = $t(t.selectionsAfter.length ? t.selectionsAfter.map((l) => l.map(e)) : L, r);
|
|
262
|
+
if (!t.changes)
|
|
263
|
+
return C.selection(n);
|
|
264
|
+
let o = t.changes.map(e), i = e.mapDesc(t.changes, !0), s = t.mapped ? t.mapped.composeDesc(i) : i;
|
|
265
|
+
return new C(o, w.mapEffects(t.effects, e), s, t.startSelection.map(i), n);
|
|
266
|
+
}
|
|
267
|
+
const Vr = /^(input\.type|delete)($|\.)/;
|
|
268
|
+
class T {
|
|
269
|
+
constructor(e, r, n = 0, o = void 0) {
|
|
270
|
+
this.done = e, this.undone = r, this.prevTime = n, this.prevUserEvent = o;
|
|
271
|
+
}
|
|
272
|
+
isolate() {
|
|
273
|
+
return this.prevTime ? new T(this.done, this.undone) : this;
|
|
274
|
+
}
|
|
275
|
+
addChanges(e, r, n, o, i) {
|
|
276
|
+
let s = this.done, l = s[s.length - 1];
|
|
277
|
+
return l && l.changes && !l.changes.empty && e.changes && (!n || Vr.test(n)) && (!l.selectionsAfter.length && r - this.prevTime < o.newGroupDelay && o.joinToEvent(i, Wr(l.changes, e.changes)) || // For compose (but not compose.start) events, always join with previous event
|
|
278
|
+
n == "input.type.compose") ? s = Se(s, s.length - 1, o.minDepth, new C(e.changes.compose(l.changes), $t(e.effects, l.effects), l.mapped, l.startSelection, L)) : s = Se(s, s.length, o.minDepth, e), new T(s, L, r, n);
|
|
279
|
+
}
|
|
280
|
+
addSelection(e, r, n, o) {
|
|
281
|
+
let i = this.done.length ? this.done[this.done.length - 1].selectionsAfter : L;
|
|
282
|
+
return i.length > 0 && r - this.prevTime < o && n == this.prevUserEvent && n && /^select($|\.)/.test(n) && Fr(i[i.length - 1], e) ? this : new T(Gt(this.done, e), this.undone, r, n);
|
|
283
|
+
}
|
|
284
|
+
addMapping(e) {
|
|
285
|
+
return new T(He(this.done, e), He(this.undone, e), this.prevTime, this.prevUserEvent);
|
|
286
|
+
}
|
|
287
|
+
pop(e, r, n) {
|
|
288
|
+
let o = e == 0 ? this.done : this.undone;
|
|
289
|
+
if (o.length == 0)
|
|
290
|
+
return null;
|
|
291
|
+
let i = o[o.length - 1];
|
|
292
|
+
if (n && i.selectionsAfter.length)
|
|
293
|
+
return r.update({
|
|
294
|
+
selection: i.selectionsAfter[i.selectionsAfter.length - 1],
|
|
295
|
+
annotations: Ke.of({ side: e, rest: qr(o) }),
|
|
296
|
+
userEvent: e == 0 ? "select.undo" : "select.redo",
|
|
297
|
+
scrollIntoView: !0
|
|
298
|
+
});
|
|
299
|
+
if (i.changes) {
|
|
300
|
+
let s = o.length == 1 ? L : o.slice(0, o.length - 1);
|
|
301
|
+
return i.mapped && (s = He(s, i.mapped)), r.update({
|
|
302
|
+
changes: i.changes,
|
|
303
|
+
selection: i.startSelection,
|
|
304
|
+
effects: i.effects,
|
|
305
|
+
annotations: Ke.of({ side: e, rest: s }),
|
|
306
|
+
filter: !1,
|
|
307
|
+
userEvent: e == 0 ? "undo" : "redo",
|
|
308
|
+
scrollIntoView: !0
|
|
309
|
+
});
|
|
310
|
+
} else
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
T.empty = /* @__PURE__ */ new T(L, L);
|
|
315
|
+
const zr = [
|
|
316
|
+
{ key: "Mod-z", run: Ut, preventDefault: !0 },
|
|
317
|
+
{ key: "Mod-y", mac: "Mod-Shift-z", run: Je, preventDefault: !0 },
|
|
318
|
+
{ linux: "Ctrl-Shift-z", run: Je, preventDefault: !0 },
|
|
319
|
+
{ key: "Mod-u", run: Ir, preventDefault: !0 },
|
|
320
|
+
{ key: "Alt-u", mac: "Mod-Shift-u", run: Pr, preventDefault: !0 }
|
|
321
|
+
];
|
|
322
|
+
function ee(t, e) {
|
|
323
|
+
return d.create(t.ranges.map(e), t.mainIndex);
|
|
324
|
+
}
|
|
325
|
+
function O(t, e) {
|
|
326
|
+
return t.update({ selection: e, scrollIntoView: !0, userEvent: "select" });
|
|
327
|
+
}
|
|
328
|
+
function R({ state: t, dispatch: e }, r) {
|
|
329
|
+
let n = ee(t.selection, r);
|
|
330
|
+
return n.eq(t.selection) ? !1 : (e(O(t, n)), !0);
|
|
331
|
+
}
|
|
332
|
+
function Re(t, e) {
|
|
333
|
+
return d.cursor(e ? t.to : t.from);
|
|
334
|
+
}
|
|
335
|
+
function Kt(t, e) {
|
|
336
|
+
return R(t, (r) => r.empty ? t.moveByChar(r, e) : Re(r, e));
|
|
337
|
+
}
|
|
338
|
+
function b(t) {
|
|
339
|
+
return t.textDirectionAt(t.state.selection.main.head) == jn.LTR;
|
|
340
|
+
}
|
|
341
|
+
const Jt = (t) => Kt(t, !b(t)), _t = (t) => Kt(t, b(t));
|
|
342
|
+
function jt(t, e) {
|
|
343
|
+
return R(t, (r) => r.empty ? t.moveByGroup(r, e) : Re(r, e));
|
|
344
|
+
}
|
|
345
|
+
const Ur = (t) => jt(t, !b(t)), $r = (t) => jt(t, b(t));
|
|
346
|
+
function Gr(t, e, r) {
|
|
347
|
+
if (e.type.prop(r))
|
|
348
|
+
return !0;
|
|
349
|
+
let n = e.to - e.from;
|
|
350
|
+
return n && (n > 2 || /[^\s,.;:]/.test(t.sliceDoc(e.from, e.to))) || e.firstChild;
|
|
351
|
+
}
|
|
352
|
+
function Te(t, e, r) {
|
|
353
|
+
let n = et(t).resolveInner(e.head), o = r ? Ge.closedBy : Ge.openedBy;
|
|
354
|
+
for (let a = e.head; ; ) {
|
|
355
|
+
let c = r ? n.childAfter(a) : n.childBefore(a);
|
|
356
|
+
if (!c)
|
|
357
|
+
break;
|
|
358
|
+
Gr(t, c, o) ? n = c : a = r ? c.to : c.from;
|
|
359
|
+
}
|
|
360
|
+
let i = n.type.prop(o), s, l;
|
|
361
|
+
return i && (s = r ? j(t, n.from, 1) : j(t, n.to, -1)) && s.matched ? l = r ? s.end.to : s.end.from : l = r ? n.to : n.from, d.cursor(l, r ? -1 : 1);
|
|
362
|
+
}
|
|
363
|
+
const Kr = (t) => R(t, (e) => Te(t.state, e, !b(t))), Jr = (t) => R(t, (e) => Te(t.state, e, b(t)));
|
|
364
|
+
function Qt(t, e) {
|
|
365
|
+
return R(t, (r) => {
|
|
366
|
+
if (!r.empty)
|
|
367
|
+
return Re(r, e);
|
|
368
|
+
let n = t.moveVertically(r, e);
|
|
369
|
+
return n.head != r.head ? n : t.moveToLineBoundary(r, e);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
const Yt = (t) => Qt(t, !1), Zt = (t) => Qt(t, !0);
|
|
373
|
+
function Xt(t) {
|
|
374
|
+
let e = t.scrollDOM.clientHeight < t.scrollDOM.scrollHeight - 2, r = 0, n = 0, o;
|
|
375
|
+
if (e) {
|
|
376
|
+
for (let i of t.state.facet(p.scrollMargins)) {
|
|
377
|
+
let s = i(t);
|
|
378
|
+
s != null && s.top && (r = Math.max(s == null ? void 0 : s.top, r)), s != null && s.bottom && (n = Math.max(s == null ? void 0 : s.bottom, n));
|
|
379
|
+
}
|
|
380
|
+
o = t.scrollDOM.clientHeight - r - n;
|
|
381
|
+
} else
|
|
382
|
+
o = (t.dom.ownerDocument.defaultView || window).innerHeight;
|
|
383
|
+
return {
|
|
384
|
+
marginTop: r,
|
|
385
|
+
marginBottom: n,
|
|
386
|
+
selfScroll: e,
|
|
387
|
+
height: Math.max(t.defaultLineHeight, o - 5)
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function en(t, e) {
|
|
391
|
+
let r = Xt(t), { state: n } = t, o = ee(n.selection, (s) => s.empty ? t.moveVertically(s, e, r.height) : Re(s, e));
|
|
392
|
+
if (o.eq(n.selection))
|
|
393
|
+
return !1;
|
|
394
|
+
let i;
|
|
395
|
+
if (r.selfScroll) {
|
|
396
|
+
let s = t.coordsAtPos(n.selection.main.head), l = t.scrollDOM.getBoundingClientRect(), a = l.top + r.marginTop, c = l.bottom - r.marginBottom;
|
|
397
|
+
s && s.top > a && s.bottom < c && (i = p.scrollIntoView(o.main.head, { y: "start", yMargin: s.top - a }));
|
|
398
|
+
}
|
|
399
|
+
return t.dispatch(O(n, o), { effects: i }), !0;
|
|
400
|
+
}
|
|
401
|
+
const ht = (t) => en(t, !1), _e = (t) => en(t, !0);
|
|
402
|
+
function N(t, e, r) {
|
|
403
|
+
let n = t.lineBlockAt(e.head), o = t.moveToLineBoundary(e, r);
|
|
404
|
+
if (o.head == e.head && o.head != (r ? n.to : n.from) && (o = t.moveToLineBoundary(e, r, !1)), !r && o.head == n.from && n.length) {
|
|
405
|
+
let i = /^\s*/.exec(t.state.sliceDoc(n.from, Math.min(n.from + 100, n.to)))[0].length;
|
|
406
|
+
i && e.head != n.from + i && (o = d.cursor(n.from + i));
|
|
407
|
+
}
|
|
408
|
+
return o;
|
|
409
|
+
}
|
|
410
|
+
const _r = (t) => R(t, (e) => N(t, e, !0)), jr = (t) => R(t, (e) => N(t, e, !1)), Qr = (t) => R(t, (e) => N(t, e, !b(t))), Yr = (t) => R(t, (e) => N(t, e, b(t))), Zr = (t) => R(t, (e) => d.cursor(t.lineBlockAt(e.head).from, 1)), Xr = (t) => R(t, (e) => d.cursor(t.lineBlockAt(e.head).to, -1));
|
|
411
|
+
function eo(t, e, r) {
|
|
412
|
+
let n = !1, o = ee(t.selection, (i) => {
|
|
413
|
+
let s = j(t, i.head, -1) || j(t, i.head, 1) || i.head > 0 && j(t, i.head - 1, 1) || i.head < t.doc.length && j(t, i.head + 1, -1);
|
|
414
|
+
if (!s || !s.end)
|
|
415
|
+
return i;
|
|
416
|
+
n = !0;
|
|
417
|
+
let l = s.start.from == i.head ? s.end.to : s.end.from;
|
|
418
|
+
return r ? d.range(i.anchor, l) : d.cursor(l);
|
|
419
|
+
});
|
|
420
|
+
return n ? (e(O(t, o)), !0) : !1;
|
|
421
|
+
}
|
|
422
|
+
const to = ({ state: t, dispatch: e }) => eo(t, e, !1);
|
|
423
|
+
function D(t, e) {
|
|
424
|
+
let r = ee(t.state.selection, (n) => {
|
|
425
|
+
let o = e(n);
|
|
426
|
+
return d.range(n.anchor, o.head, o.goalColumn, o.bidiLevel || void 0);
|
|
427
|
+
});
|
|
428
|
+
return r.eq(t.state.selection) ? !1 : (t.dispatch(O(t.state, r)), !0);
|
|
429
|
+
}
|
|
430
|
+
function tn(t, e) {
|
|
431
|
+
return D(t, (r) => t.moveByChar(r, e));
|
|
432
|
+
}
|
|
433
|
+
const nn = (t) => tn(t, !b(t)), rn = (t) => tn(t, b(t));
|
|
434
|
+
function on(t, e) {
|
|
435
|
+
return D(t, (r) => t.moveByGroup(r, e));
|
|
436
|
+
}
|
|
437
|
+
const no = (t) => on(t, !b(t)), ro = (t) => on(t, b(t)), oo = (t) => D(t, (e) => Te(t.state, e, !b(t))), io = (t) => D(t, (e) => Te(t.state, e, b(t)));
|
|
438
|
+
function sn(t, e) {
|
|
439
|
+
return D(t, (r) => t.moveVertically(r, e));
|
|
440
|
+
}
|
|
441
|
+
const ln = (t) => sn(t, !1), an = (t) => sn(t, !0);
|
|
442
|
+
function cn(t, e) {
|
|
443
|
+
return D(t, (r) => t.moveVertically(r, e, Xt(t).height));
|
|
444
|
+
}
|
|
445
|
+
const ut = (t) => cn(t, !1), ft = (t) => cn(t, !0), so = (t) => D(t, (e) => N(t, e, !0)), lo = (t) => D(t, (e) => N(t, e, !1)), ao = (t) => D(t, (e) => N(t, e, !b(t))), co = (t) => D(t, (e) => N(t, e, b(t))), ho = (t) => D(t, (e) => d.cursor(t.lineBlockAt(e.head).from)), uo = (t) => D(t, (e) => d.cursor(t.lineBlockAt(e.head).to)), dt = ({ state: t, dispatch: e }) => (e(O(t, { anchor: 0 })), !0), mt = ({ state: t, dispatch: e }) => (e(O(t, { anchor: t.doc.length })), !0), gt = ({ state: t, dispatch: e }) => (e(O(t, { anchor: t.selection.main.anchor, head: 0 })), !0), pt = ({ state: t, dispatch: e }) => (e(O(t, { anchor: t.selection.main.anchor, head: t.doc.length })), !0), fo = ({ state: t, dispatch: e }) => (e(t.update({ selection: { anchor: 0, head: t.doc.length }, userEvent: "select" })), !0), mo = ({ state: t, dispatch: e }) => {
|
|
446
|
+
let r = Ie(t).map(({ from: n, to: o }) => d.range(n, Math.min(o + 1, t.doc.length)));
|
|
447
|
+
return e(t.update({ selection: d.create(r), userEvent: "select" })), !0;
|
|
448
|
+
}, go = ({ state: t, dispatch: e }) => {
|
|
449
|
+
let r = ee(t.selection, (n) => {
|
|
450
|
+
var o;
|
|
451
|
+
let i = et(t).resolveInner(n.head, 1);
|
|
452
|
+
for (; !(i.from < n.from && i.to >= n.to || i.to > n.to && i.from <= n.from || !(!((o = i.parent) === null || o === void 0) && o.parent)); )
|
|
453
|
+
i = i.parent;
|
|
454
|
+
return d.range(i.to, i.from);
|
|
455
|
+
});
|
|
456
|
+
return e(O(t, r)), !0;
|
|
457
|
+
}, po = ({ state: t, dispatch: e }) => {
|
|
458
|
+
let r = t.selection, n = null;
|
|
459
|
+
return r.ranges.length > 1 ? n = d.create([r.main]) : r.main.empty || (n = d.create([d.cursor(r.main.head)])), n ? (e(O(t, n)), !0) : !1;
|
|
460
|
+
};
|
|
461
|
+
function Oe(t, e) {
|
|
462
|
+
if (t.state.readOnly)
|
|
463
|
+
return !1;
|
|
464
|
+
let r = "delete.selection", { state: n } = t, o = n.changeByRange((i) => {
|
|
465
|
+
let { from: s, to: l } = i;
|
|
466
|
+
if (s == l) {
|
|
467
|
+
let a = e(s);
|
|
468
|
+
a < s ? (r = "delete.backward", a = me(t, a, !1)) : a > s && (r = "delete.forward", a = me(t, a, !0)), s = Math.min(s, a), l = Math.max(l, a);
|
|
469
|
+
} else
|
|
470
|
+
s = me(t, s, !1), l = me(t, l, !0);
|
|
471
|
+
return s == l ? { range: i } : { changes: { from: s, to: l }, range: d.cursor(s) };
|
|
472
|
+
});
|
|
473
|
+
return o.changes.empty ? !1 : (t.dispatch(n.update(o, {
|
|
474
|
+
scrollIntoView: !0,
|
|
475
|
+
userEvent: r,
|
|
476
|
+
effects: r == "delete.selection" ? p.announce.of(n.phrase("Selection deleted")) : void 0
|
|
477
|
+
})), !0);
|
|
478
|
+
}
|
|
479
|
+
function me(t, e, r) {
|
|
480
|
+
if (t instanceof p)
|
|
481
|
+
for (let n of t.state.facet(p.atomicRanges).map((o) => o(t)))
|
|
482
|
+
n.between(e, e, (o, i) => {
|
|
483
|
+
o < e && i > e && (e = r ? i : o);
|
|
484
|
+
});
|
|
485
|
+
return e;
|
|
486
|
+
}
|
|
487
|
+
const hn = (t, e) => Oe(t, (r) => {
|
|
488
|
+
let { state: n } = t, o = n.doc.lineAt(r), i, s;
|
|
489
|
+
if (!e && r > o.from && r < o.from + 200 && !/[^ \t]/.test(i = o.text.slice(0, r - o.from))) {
|
|
490
|
+
if (i[i.length - 1] == " ")
|
|
491
|
+
return r - 1;
|
|
492
|
+
let l = Wt(i, n.tabSize), a = l % $e(n) || $e(n);
|
|
493
|
+
for (let c = 0; c < a && i[i.length - 1 - c] == " "; c++)
|
|
494
|
+
r--;
|
|
495
|
+
s = r;
|
|
496
|
+
} else
|
|
497
|
+
s = Y(o.text, r - o.from, e, e) + o.from, s == r && o.number != (e ? n.doc.lines : 1) && (s += e ? 1 : -1);
|
|
498
|
+
return s;
|
|
499
|
+
}), je = (t) => hn(t, !1), un = (t) => hn(t, !0), fn = (t, e) => Oe(t, (r) => {
|
|
500
|
+
let n = r, { state: o } = t, i = o.doc.lineAt(n), s = o.charCategorizer(n);
|
|
501
|
+
for (let l = null; ; ) {
|
|
502
|
+
if (n == (e ? i.to : i.from)) {
|
|
503
|
+
n == r && i.number != (e ? o.doc.lines : 1) && (n += e ? 1 : -1);
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
let a = Y(i.text, n - i.from, e) + i.from, c = i.text.slice(Math.min(n, a) - i.from, Math.max(n, a) - i.from), h = s(c);
|
|
507
|
+
if (l != null && h != l)
|
|
508
|
+
break;
|
|
509
|
+
(c != " " || n != r) && (l = h), n = a;
|
|
510
|
+
}
|
|
511
|
+
return n;
|
|
512
|
+
}), dn = (t) => fn(t, !1), yo = (t) => fn(t, !0), mn = (t) => Oe(t, (e) => {
|
|
513
|
+
let r = t.lineBlockAt(e).to;
|
|
514
|
+
return e < r ? r : Math.min(t.state.doc.length, e + 1);
|
|
515
|
+
}), xo = (t) => Oe(t, (e) => {
|
|
516
|
+
let r = t.lineBlockAt(e).from;
|
|
517
|
+
return e > r ? r : Math.max(0, e - 1);
|
|
518
|
+
}), ko = ({ state: t, dispatch: e }) => {
|
|
519
|
+
if (t.readOnly)
|
|
520
|
+
return !1;
|
|
521
|
+
let r = t.changeByRange((n) => ({
|
|
522
|
+
changes: { from: n.from, to: n.to, insert: It.of(["", ""]) },
|
|
523
|
+
range: d.cursor(n.from)
|
|
524
|
+
}));
|
|
525
|
+
return e(t.update(r, { scrollIntoView: !0, userEvent: "input" })), !0;
|
|
526
|
+
}, bo = ({ state: t, dispatch: e }) => {
|
|
527
|
+
if (t.readOnly)
|
|
528
|
+
return !1;
|
|
529
|
+
let r = t.changeByRange((n) => {
|
|
530
|
+
if (!n.empty || n.from == 0 || n.from == t.doc.length)
|
|
531
|
+
return { range: n };
|
|
532
|
+
let o = n.from, i = t.doc.lineAt(o), s = o == i.from ? o - 1 : Y(i.text, o - i.from, !1) + i.from, l = o == i.to ? o + 1 : Y(i.text, o - i.from, !0) + i.from;
|
|
533
|
+
return {
|
|
534
|
+
changes: { from: s, to: l, insert: t.doc.slice(o, l).append(t.doc.slice(s, o)) },
|
|
535
|
+
range: d.cursor(l)
|
|
536
|
+
};
|
|
537
|
+
});
|
|
538
|
+
return r.changes.empty ? !1 : (e(t.update(r, { scrollIntoView: !0, userEvent: "move.character" })), !0);
|
|
539
|
+
};
|
|
540
|
+
function Ie(t) {
|
|
541
|
+
let e = [], r = -1;
|
|
542
|
+
for (let n of t.selection.ranges) {
|
|
543
|
+
let o = t.doc.lineAt(n.from), i = t.doc.lineAt(n.to);
|
|
544
|
+
if (!n.empty && n.to == i.from && (i = t.doc.lineAt(n.to - 1)), r >= o.number) {
|
|
545
|
+
let s = e[e.length - 1];
|
|
546
|
+
s.to = i.to, s.ranges.push(n);
|
|
547
|
+
} else
|
|
548
|
+
e.push({ from: o.from, to: i.to, ranges: [n] });
|
|
549
|
+
r = i.number + 1;
|
|
550
|
+
}
|
|
551
|
+
return e;
|
|
552
|
+
}
|
|
553
|
+
function gn(t, e, r) {
|
|
554
|
+
if (t.readOnly)
|
|
555
|
+
return !1;
|
|
556
|
+
let n = [], o = [];
|
|
557
|
+
for (let i of Ie(t)) {
|
|
558
|
+
if (r ? i.to == t.doc.length : i.from == 0)
|
|
559
|
+
continue;
|
|
560
|
+
let s = t.doc.lineAt(r ? i.to + 1 : i.from - 1), l = s.length + 1;
|
|
561
|
+
if (r) {
|
|
562
|
+
n.push({ from: i.to, to: s.to }, { from: i.from, insert: s.text + t.lineBreak });
|
|
563
|
+
for (let a of i.ranges)
|
|
564
|
+
o.push(d.range(Math.min(t.doc.length, a.anchor + l), Math.min(t.doc.length, a.head + l)));
|
|
565
|
+
} else {
|
|
566
|
+
n.push({ from: s.from, to: i.from }, { from: i.to, insert: t.lineBreak + s.text });
|
|
567
|
+
for (let a of i.ranges)
|
|
568
|
+
o.push(d.range(a.anchor - l, a.head - l));
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return n.length ? (e(t.update({
|
|
572
|
+
changes: n,
|
|
573
|
+
scrollIntoView: !0,
|
|
574
|
+
selection: d.create(o, t.selection.mainIndex),
|
|
575
|
+
userEvent: "move.line"
|
|
576
|
+
})), !0) : !1;
|
|
577
|
+
}
|
|
578
|
+
const So = ({ state: t, dispatch: e }) => gn(t, e, !1), Co = ({ state: t, dispatch: e }) => gn(t, e, !0);
|
|
579
|
+
function pn(t, e, r) {
|
|
580
|
+
if (t.readOnly)
|
|
581
|
+
return !1;
|
|
582
|
+
let n = [];
|
|
583
|
+
for (let o of Ie(t))
|
|
584
|
+
r ? n.push({ from: o.from, insert: t.doc.slice(o.from, o.to) + t.lineBreak }) : n.push({ from: o.to, insert: t.lineBreak + t.doc.slice(o.from, o.to) });
|
|
585
|
+
return e(t.update({ changes: n, scrollIntoView: !0, userEvent: "input.copyline" })), !0;
|
|
586
|
+
}
|
|
587
|
+
const vo = ({ state: t, dispatch: e }) => pn(t, e, !1), Ao = ({ state: t, dispatch: e }) => pn(t, e, !0), Mo = (t) => {
|
|
588
|
+
if (t.state.readOnly)
|
|
589
|
+
return !1;
|
|
590
|
+
let { state: e } = t, r = e.changes(Ie(e).map(({ from: o, to: i }) => (o > 0 ? o-- : i < e.doc.length && i++, { from: o, to: i }))), n = ee(e.selection, (o) => t.moveVertically(o, !0)).map(r);
|
|
591
|
+
return t.dispatch({ changes: r, selection: n, scrollIntoView: !0, userEvent: "delete.line" }), !0;
|
|
592
|
+
};
|
|
593
|
+
function Lo(t, e) {
|
|
594
|
+
if (/\(\)|\[\]|\{\}/.test(t.sliceDoc(e - 1, e + 1)))
|
|
595
|
+
return { from: e, to: e };
|
|
596
|
+
let r = et(t).resolveInner(e), n = r.childBefore(e), o = r.childAfter(e), i;
|
|
597
|
+
return n && o && n.to <= e && o.from >= e && (i = n.type.prop(Ge.closedBy)) && i.indexOf(o.name) > -1 && t.doc.lineAt(n.to).from == t.doc.lineAt(o.from).from ? { from: n.to, to: o.from } : null;
|
|
598
|
+
}
|
|
599
|
+
const Do = /* @__PURE__ */ yn(!1), Bo = /* @__PURE__ */ yn(!0);
|
|
600
|
+
function yn(t) {
|
|
601
|
+
return ({ state: e, dispatch: r }) => {
|
|
602
|
+
if (e.readOnly)
|
|
603
|
+
return !1;
|
|
604
|
+
let n = e.changeByRange((o) => {
|
|
605
|
+
let { from: i, to: s } = o, l = e.doc.lineAt(i), a = !t && i == s && Lo(e, i);
|
|
606
|
+
t && (i = s = (s <= l.to ? l : e.doc.lineAt(s)).to);
|
|
607
|
+
let c = new Tt(e, { simulateBreak: i, simulateDoubleBreak: !!a }), h = Ot(c, i);
|
|
608
|
+
for (h == null && (h = /^\s*/.exec(e.doc.lineAt(i).text)[0].length); s < l.to && /\s/.test(l.text[s - l.from]); )
|
|
609
|
+
s++;
|
|
610
|
+
a ? { from: i, to: s } = a : i > l.from && i < l.from + 100 && !/\S/.test(l.text.slice(0, i)) && (i = l.from);
|
|
611
|
+
let u = ["", be(e, h)];
|
|
612
|
+
return a && u.push(be(e, c.lineIndent(l.from, -1))), {
|
|
613
|
+
changes: { from: i, to: s, insert: It.of(u) },
|
|
614
|
+
range: d.cursor(i + 1 + u[1].length)
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
return r(e.update(n, { scrollIntoView: !0, userEvent: "input" })), !0;
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
function ot(t, e) {
|
|
621
|
+
let r = -1;
|
|
622
|
+
return t.changeByRange((n) => {
|
|
623
|
+
let o = [];
|
|
624
|
+
for (let s = n.from; s <= n.to; ) {
|
|
625
|
+
let l = t.doc.lineAt(s);
|
|
626
|
+
l.number > r && (n.empty || n.to > l.from) && (e(l, o, n), r = l.number), s = l.to + 1;
|
|
627
|
+
}
|
|
628
|
+
let i = t.changes(o);
|
|
629
|
+
return {
|
|
630
|
+
changes: o,
|
|
631
|
+
range: d.range(i.mapPos(n.anchor, 1), i.mapPos(n.head, 1))
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
const Eo = ({ state: t, dispatch: e }) => {
|
|
636
|
+
if (t.readOnly)
|
|
637
|
+
return !1;
|
|
638
|
+
let r = /* @__PURE__ */ Object.create(null), n = new Tt(t, { overrideIndentation: (i) => {
|
|
639
|
+
let s = r[i];
|
|
640
|
+
return s ?? -1;
|
|
641
|
+
} }), o = ot(t, (i, s, l) => {
|
|
642
|
+
let a = Ot(n, i.from);
|
|
643
|
+
if (a == null)
|
|
644
|
+
return;
|
|
645
|
+
/\S/.test(i.text) || (a = 0);
|
|
646
|
+
let c = /^\s*/.exec(i.text)[0], h = be(t, a);
|
|
647
|
+
(c != h || l.from < i.from + c.length) && (r[i.from] = a, s.push({ from: i.from, to: i.from + c.length, insert: h }));
|
|
648
|
+
});
|
|
649
|
+
return o.changes.empty || e(t.update(o, { userEvent: "indent" })), !0;
|
|
650
|
+
}, xn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(ot(t, (r, n) => {
|
|
651
|
+
n.push({ from: r.from, insert: t.facet(Pt) });
|
|
652
|
+
}), { userEvent: "input.indent" })), !0), kn = ({ state: t, dispatch: e }) => t.readOnly ? !1 : (e(t.update(ot(t, (r, n) => {
|
|
653
|
+
let o = /^\s*/.exec(r.text)[0];
|
|
654
|
+
if (!o)
|
|
655
|
+
return;
|
|
656
|
+
let i = Wt(o, t.tabSize), s = 0, l = be(t, Math.max(0, i - $e(t)));
|
|
657
|
+
for (; s < o.length && s < l.length && o.charCodeAt(s) == l.charCodeAt(s); )
|
|
658
|
+
s++;
|
|
659
|
+
n.push({ from: r.from + s, to: r.from + o.length, insert: l.slice(s) });
|
|
660
|
+
}), { userEvent: "delete.dedent" })), !0), wo = [
|
|
661
|
+
{ key: "Ctrl-b", run: Jt, shift: nn, preventDefault: !0 },
|
|
662
|
+
{ key: "Ctrl-f", run: _t, shift: rn },
|
|
663
|
+
{ key: "Ctrl-p", run: Yt, shift: ln },
|
|
664
|
+
{ key: "Ctrl-n", run: Zt, shift: an },
|
|
665
|
+
{ key: "Ctrl-a", run: Zr, shift: ho },
|
|
666
|
+
{ key: "Ctrl-e", run: Xr, shift: uo },
|
|
667
|
+
{ key: "Ctrl-d", run: un },
|
|
668
|
+
{ key: "Ctrl-h", run: je },
|
|
669
|
+
{ key: "Ctrl-k", run: mn },
|
|
670
|
+
{ key: "Ctrl-Alt-h", run: dn },
|
|
671
|
+
{ key: "Ctrl-o", run: ko },
|
|
672
|
+
{ key: "Ctrl-t", run: bo },
|
|
673
|
+
{ key: "Ctrl-v", run: _e }
|
|
674
|
+
], Ro = /* @__PURE__ */ [
|
|
675
|
+
{ key: "ArrowLeft", run: Jt, shift: nn, preventDefault: !0 },
|
|
676
|
+
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: Ur, shift: no, preventDefault: !0 },
|
|
677
|
+
{ mac: "Cmd-ArrowLeft", run: Qr, shift: ao, preventDefault: !0 },
|
|
678
|
+
{ key: "ArrowRight", run: _t, shift: rn, preventDefault: !0 },
|
|
679
|
+
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: $r, shift: ro, preventDefault: !0 },
|
|
680
|
+
{ mac: "Cmd-ArrowRight", run: Yr, shift: co, preventDefault: !0 },
|
|
681
|
+
{ key: "ArrowUp", run: Yt, shift: ln, preventDefault: !0 },
|
|
682
|
+
{ mac: "Cmd-ArrowUp", run: dt, shift: gt },
|
|
683
|
+
{ mac: "Ctrl-ArrowUp", run: ht, shift: ut },
|
|
684
|
+
{ key: "ArrowDown", run: Zt, shift: an, preventDefault: !0 },
|
|
685
|
+
{ mac: "Cmd-ArrowDown", run: mt, shift: pt },
|
|
686
|
+
{ mac: "Ctrl-ArrowDown", run: _e, shift: ft },
|
|
687
|
+
{ key: "PageUp", run: ht, shift: ut },
|
|
688
|
+
{ key: "PageDown", run: _e, shift: ft },
|
|
689
|
+
{ key: "Home", run: jr, shift: lo, preventDefault: !0 },
|
|
690
|
+
{ key: "Mod-Home", run: dt, shift: gt },
|
|
691
|
+
{ key: "End", run: _r, shift: so, preventDefault: !0 },
|
|
692
|
+
{ key: "Mod-End", run: mt, shift: pt },
|
|
693
|
+
{ key: "Enter", run: Do },
|
|
694
|
+
{ key: "Mod-a", run: fo },
|
|
695
|
+
{ key: "Backspace", run: je, shift: je },
|
|
696
|
+
{ key: "Delete", run: un },
|
|
697
|
+
{ key: "Mod-Backspace", mac: "Alt-Backspace", run: dn },
|
|
698
|
+
{ key: "Mod-Delete", mac: "Alt-Delete", run: yo },
|
|
699
|
+
{ mac: "Mod-Backspace", run: xo },
|
|
700
|
+
{ mac: "Mod-Delete", run: mn }
|
|
701
|
+
].concat(/* @__PURE__ */ wo.map((t) => ({ mac: t.key, run: t.run, shift: t.shift }))), To = /* @__PURE__ */ [
|
|
702
|
+
{ key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: Kr, shift: oo },
|
|
703
|
+
{ key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: Jr, shift: io },
|
|
704
|
+
{ key: "Alt-ArrowUp", run: So },
|
|
705
|
+
{ key: "Shift-Alt-ArrowUp", run: vo },
|
|
706
|
+
{ key: "Alt-ArrowDown", run: Co },
|
|
707
|
+
{ key: "Shift-Alt-ArrowDown", run: Ao },
|
|
708
|
+
{ key: "Escape", run: po },
|
|
709
|
+
{ key: "Mod-Enter", run: Bo },
|
|
710
|
+
{ key: "Alt-l", mac: "Ctrl-l", run: mo },
|
|
711
|
+
{ key: "Mod-i", run: go, preventDefault: !0 },
|
|
712
|
+
{ key: "Mod-[", run: kn },
|
|
713
|
+
{ key: "Mod-]", run: xn },
|
|
714
|
+
{ key: "Mod-Alt-\\", run: Eo },
|
|
715
|
+
{ key: "Shift-Mod-k", run: Mo },
|
|
716
|
+
{ key: "Shift-Mod-\\", run: to },
|
|
717
|
+
{ key: "Mod-/", run: vr },
|
|
718
|
+
{ key: "Alt-A", run: Mr }
|
|
719
|
+
].concat(Ro), Oo = { key: "Tab", run: xn, shift: kn };
|
|
720
|
+
function g() {
|
|
721
|
+
var t = arguments[0];
|
|
722
|
+
typeof t == "string" && (t = document.createElement(t));
|
|
723
|
+
var e = 1, r = arguments[1];
|
|
724
|
+
if (r && typeof r == "object" && r.nodeType == null && !Array.isArray(r)) {
|
|
725
|
+
for (var n in r)
|
|
726
|
+
if (Object.prototype.hasOwnProperty.call(r, n)) {
|
|
727
|
+
var o = r[n];
|
|
728
|
+
typeof o == "string" ? t.setAttribute(n, o) : o != null && (t[n] = o);
|
|
729
|
+
}
|
|
730
|
+
e++;
|
|
731
|
+
}
|
|
732
|
+
for (; e < arguments.length; e++)
|
|
733
|
+
bn(t, arguments[e]);
|
|
734
|
+
return t;
|
|
735
|
+
}
|
|
736
|
+
function bn(t, e) {
|
|
737
|
+
if (typeof e == "string")
|
|
738
|
+
t.appendChild(document.createTextNode(e));
|
|
739
|
+
else if (e != null)
|
|
740
|
+
if (e.nodeType != null)
|
|
741
|
+
t.appendChild(e);
|
|
742
|
+
else if (Array.isArray(e))
|
|
743
|
+
for (var r = 0; r < e.length; r++)
|
|
744
|
+
bn(t, e[r]);
|
|
745
|
+
else
|
|
746
|
+
throw new RangeError("Unsupported child node: " + e);
|
|
747
|
+
}
|
|
748
|
+
const yt = typeof String.prototype.normalize == "function" ? (t) => t.normalize("NFKD") : (t) => t;
|
|
749
|
+
class Z {
|
|
750
|
+
/**
|
|
751
|
+
Create a text cursor. The query is the search string, `from` to
|
|
752
|
+
`to` provides the region to search.
|
|
753
|
+
|
|
754
|
+
When `normalize` is given, it will be called, on both the query
|
|
755
|
+
string and the content it is matched against, before comparing.
|
|
756
|
+
You can, for example, create a case-insensitive search by
|
|
757
|
+
passing `s => s.toLowerCase()`.
|
|
758
|
+
|
|
759
|
+
Text is always normalized with
|
|
760
|
+
[`.normalize("NFKD")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)
|
|
761
|
+
(when supported).
|
|
762
|
+
*/
|
|
763
|
+
constructor(e, r, n = 0, o = e.length, i, s) {
|
|
764
|
+
this.test = s, this.value = { from: 0, to: 0 }, this.done = !1, this.matches = [], this.buffer = "", this.bufferPos = 0, this.iter = e.iterRange(n, o), this.bufferStart = n, this.normalize = i ? (l) => i(yt(l)) : yt, this.query = this.normalize(r);
|
|
765
|
+
}
|
|
766
|
+
peek() {
|
|
767
|
+
if (this.bufferPos == this.buffer.length) {
|
|
768
|
+
if (this.bufferStart += this.buffer.length, this.iter.next(), this.iter.done)
|
|
769
|
+
return -1;
|
|
770
|
+
this.bufferPos = 0, this.buffer = this.iter.value;
|
|
771
|
+
}
|
|
772
|
+
return Qn(this.buffer, this.bufferPos);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
Look for the next match. Updates the iterator's
|
|
776
|
+
[`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and
|
|
777
|
+
[`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called
|
|
778
|
+
at least once before using the cursor.
|
|
779
|
+
*/
|
|
780
|
+
next() {
|
|
781
|
+
for (; this.matches.length; )
|
|
782
|
+
this.matches.pop();
|
|
783
|
+
return this.nextOverlapping();
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
The `next` method will ignore matches that partially overlap a
|
|
787
|
+
previous match. This method behaves like `next`, but includes
|
|
788
|
+
such matches.
|
|
789
|
+
*/
|
|
790
|
+
nextOverlapping() {
|
|
791
|
+
for (; ; ) {
|
|
792
|
+
let e = this.peek();
|
|
793
|
+
if (e < 0)
|
|
794
|
+
return this.done = !0, this;
|
|
795
|
+
let r = Xn(e), n = this.bufferStart + this.bufferPos;
|
|
796
|
+
this.bufferPos += Yn(e);
|
|
797
|
+
let o = this.normalize(r);
|
|
798
|
+
for (let i = 0, s = n; ; i++) {
|
|
799
|
+
let l = o.charCodeAt(i), a = this.match(l, s);
|
|
800
|
+
if (i == o.length - 1) {
|
|
801
|
+
if (a)
|
|
802
|
+
return this.value = a, this;
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
805
|
+
s == n && i < r.length && r.charCodeAt(i) == l && s++;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
match(e, r) {
|
|
810
|
+
let n = null;
|
|
811
|
+
for (let o = 0; o < this.matches.length; o += 2) {
|
|
812
|
+
let i = this.matches[o], s = !1;
|
|
813
|
+
this.query.charCodeAt(i) == e && (i == this.query.length - 1 ? n = { from: this.matches[o + 1], to: r + 1 } : (this.matches[o]++, s = !0)), s || (this.matches.splice(o, 2), o -= 2);
|
|
814
|
+
}
|
|
815
|
+
return this.query.charCodeAt(0) == e && (this.query.length == 1 ? n = { from: r, to: r + 1 } : this.matches.push(1, r)), n && this.test && !this.test(n.from, n.to, this.buffer, this.bufferPos) && (n = null), n;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
typeof Symbol < "u" && (Z.prototype[Symbol.iterator] = function() {
|
|
819
|
+
return this;
|
|
820
|
+
});
|
|
821
|
+
const Sn = { from: -1, to: -1, match: /* @__PURE__ */ /.*/.exec("") }, it = "gm" + (/x/.unicode == null ? "" : "u");
|
|
822
|
+
class Cn {
|
|
823
|
+
/**
|
|
824
|
+
Create a cursor that will search the given range in the given
|
|
825
|
+
document. `query` should be the raw pattern (as you'd pass it to
|
|
826
|
+
`new RegExp`).
|
|
827
|
+
*/
|
|
828
|
+
constructor(e, r, n, o = 0, i = e.length) {
|
|
829
|
+
if (this.text = e, this.to = i, this.curLine = "", this.done = !1, this.value = Sn, /\\[sWDnr]|\n|\r|\[\^/.test(r))
|
|
830
|
+
return new vn(e, r, n, o, i);
|
|
831
|
+
this.re = new RegExp(r, it + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.iter = e.iter();
|
|
832
|
+
let s = e.lineAt(o);
|
|
833
|
+
this.curLineStart = s.from, this.matchPos = Ce(e, o), this.getLine(this.curLineStart);
|
|
834
|
+
}
|
|
835
|
+
getLine(e) {
|
|
836
|
+
this.iter.next(e), 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());
|
|
837
|
+
}
|
|
838
|
+
nextLine() {
|
|
839
|
+
this.curLineStart = this.curLineStart + this.curLine.length + 1, this.curLineStart > this.to ? this.curLine = "" : this.getLine(0);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
Move to the next match, if there is one.
|
|
843
|
+
*/
|
|
844
|
+
next() {
|
|
845
|
+
for (let e = this.matchPos - this.curLineStart; ; ) {
|
|
846
|
+
this.re.lastIndex = e;
|
|
847
|
+
let r = this.matchPos <= this.to && this.re.exec(this.curLine);
|
|
848
|
+
if (r) {
|
|
849
|
+
let n = this.curLineStart + r.index, o = n + r[0].length;
|
|
850
|
+
if (this.matchPos = Ce(this.text, o + (n == o ? 1 : 0)), n == this.curLineStart + this.curLine.length && this.nextLine(), (n < o || n > this.value.to) && (!this.test || this.test(n, o, r)))
|
|
851
|
+
return this.value = { from: n, to: o, match: r }, this;
|
|
852
|
+
e = this.matchPos - this.curLineStart;
|
|
853
|
+
} else if (this.curLineStart + this.curLine.length < this.to)
|
|
854
|
+
this.nextLine(), e = 0;
|
|
855
|
+
else
|
|
856
|
+
return this.done = !0, this;
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
const Ve = /* @__PURE__ */ new WeakMap();
|
|
861
|
+
class Q {
|
|
862
|
+
constructor(e, r) {
|
|
863
|
+
this.from = e, this.text = r;
|
|
864
|
+
}
|
|
865
|
+
get to() {
|
|
866
|
+
return this.from + this.text.length;
|
|
867
|
+
}
|
|
868
|
+
static get(e, r, n) {
|
|
869
|
+
let o = Ve.get(e);
|
|
870
|
+
if (!o || o.from >= n || o.to <= r) {
|
|
871
|
+
let l = new Q(r, e.sliceString(r, n));
|
|
872
|
+
return Ve.set(e, l), l;
|
|
873
|
+
}
|
|
874
|
+
if (o.from == r && o.to == n)
|
|
875
|
+
return o;
|
|
876
|
+
let { text: i, from: s } = o;
|
|
877
|
+
return s > r && (i = e.sliceString(r, s) + i, s = r), o.to < n && (i += e.sliceString(o.to, n)), Ve.set(e, new Q(s, i)), new Q(r, i.slice(r - s, n - s));
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
class vn {
|
|
881
|
+
constructor(e, r, n, o, i) {
|
|
882
|
+
this.text = e, this.to = i, this.done = !1, this.value = Sn, this.matchPos = Ce(e, o), this.re = new RegExp(r, it + (n != null && n.ignoreCase ? "i" : "")), this.test = n == null ? void 0 : n.test, this.flat = Q.get(e, o, this.chunkEnd(
|
|
883
|
+
o + 5e3
|
|
884
|
+
/* Base */
|
|
885
|
+
));
|
|
886
|
+
}
|
|
887
|
+
chunkEnd(e) {
|
|
888
|
+
return e >= this.to ? this.to : this.text.lineAt(e).to;
|
|
889
|
+
}
|
|
890
|
+
next() {
|
|
891
|
+
for (; ; ) {
|
|
892
|
+
let e = this.re.lastIndex = this.matchPos - this.flat.from, r = this.re.exec(this.flat.text);
|
|
893
|
+
if (r && !r[0] && r.index == e && (this.re.lastIndex = e + 1, r = this.re.exec(this.flat.text)), r) {
|
|
894
|
+
let n = this.flat.from + r.index, o = n + r[0].length;
|
|
895
|
+
if ((this.flat.to >= this.to || r.index + r[0].length <= this.flat.text.length - 10) && (!this.test || this.test(n, o, r)))
|
|
896
|
+
return this.value = { from: n, to: o, match: r }, this.matchPos = Ce(this.text, o + (n == o ? 1 : 0)), this;
|
|
897
|
+
}
|
|
898
|
+
if (this.flat.to == this.to)
|
|
899
|
+
return this.done = !0, this;
|
|
900
|
+
this.flat = Q.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
typeof Symbol < "u" && (Cn.prototype[Symbol.iterator] = vn.prototype[Symbol.iterator] = function() {
|
|
905
|
+
return this;
|
|
906
|
+
});
|
|
907
|
+
function Io(t) {
|
|
908
|
+
try {
|
|
909
|
+
return new RegExp(t, it), !0;
|
|
910
|
+
} catch {
|
|
911
|
+
return !1;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
function Ce(t, e) {
|
|
915
|
+
if (e >= t.length)
|
|
916
|
+
return e;
|
|
917
|
+
let r = t.lineAt(e), n;
|
|
918
|
+
for (; e < r.to && (n = r.text.charCodeAt(e - r.from)) >= 56320 && n < 57344; )
|
|
919
|
+
e++;
|
|
920
|
+
return e;
|
|
921
|
+
}
|
|
922
|
+
function Qe(t) {
|
|
923
|
+
let e = g("input", { class: "cm-textfield", name: "line" }), r = g("form", {
|
|
924
|
+
class: "cm-gotoLine",
|
|
925
|
+
onkeydown: (o) => {
|
|
926
|
+
o.keyCode == 27 ? (o.preventDefault(), t.dispatch({ effects: ve.of(!1) }), t.focus()) : o.keyCode == 13 && (o.preventDefault(), n());
|
|
927
|
+
},
|
|
928
|
+
onsubmit: (o) => {
|
|
929
|
+
o.preventDefault(), n();
|
|
930
|
+
}
|
|
931
|
+
}, g("label", t.state.phrase("Go to line"), ": ", e), " ", g("button", { class: "cm-button", type: "submit" }, t.state.phrase("go")));
|
|
932
|
+
function n() {
|
|
933
|
+
let o = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);
|
|
934
|
+
if (!o)
|
|
935
|
+
return;
|
|
936
|
+
let { state: i } = t, s = i.doc.lineAt(i.selection.main.head), [, l, a, c, h] = o, u = c ? +c.slice(1) : 0, m = a ? +a : s.number;
|
|
937
|
+
if (a && h) {
|
|
938
|
+
let B = m / 100;
|
|
939
|
+
l && (B = B * (l == "-" ? -1 : 1) + s.number / i.doc.lines), m = Math.round(i.doc.lines * B);
|
|
940
|
+
} else
|
|
941
|
+
a && l && (m = m * (l == "-" ? -1 : 1) + s.number);
|
|
942
|
+
let x = i.doc.line(Math.max(1, Math.min(i.doc.lines, m))), S = d.cursor(x.from + Math.max(0, Math.min(u, x.length)));
|
|
943
|
+
t.dispatch({
|
|
944
|
+
effects: [ve.of(!1), p.scrollIntoView(S.from, { y: "center" })],
|
|
945
|
+
selection: S
|
|
946
|
+
}), t.focus();
|
|
947
|
+
}
|
|
948
|
+
return { dom: r };
|
|
949
|
+
}
|
|
950
|
+
const ve = /* @__PURE__ */ w.define(), xt = /* @__PURE__ */ Ee.define({
|
|
951
|
+
create() {
|
|
952
|
+
return !0;
|
|
953
|
+
},
|
|
954
|
+
update(t, e) {
|
|
955
|
+
for (let r of e.effects)
|
|
956
|
+
r.is(ve) && (t = r.value);
|
|
957
|
+
return t;
|
|
958
|
+
},
|
|
959
|
+
provide: (t) => tt.from(t, (e) => e ? Qe : null)
|
|
960
|
+
}), Po = (t) => {
|
|
961
|
+
let e = se(t, Qe);
|
|
962
|
+
if (!e) {
|
|
963
|
+
let r = [ve.of(!0)];
|
|
964
|
+
t.state.field(xt, !1) == null && r.push(w.appendConfig.of([xt, Wo])), t.dispatch({ effects: r }), e = se(t, Qe);
|
|
965
|
+
}
|
|
966
|
+
return e && e.dom.querySelector("input").focus(), !0;
|
|
967
|
+
}, Wo = /* @__PURE__ */ p.baseTheme({
|
|
968
|
+
".cm-panel.cm-gotoLine": {
|
|
969
|
+
padding: "2px 6px 4px",
|
|
970
|
+
"& label": { fontSize: "80%" }
|
|
971
|
+
}
|
|
972
|
+
}), Fo = {
|
|
973
|
+
highlightWordAroundCursor: !1,
|
|
974
|
+
minSelectionLength: 1,
|
|
975
|
+
maxMatches: 100,
|
|
976
|
+
wholeWords: !1
|
|
977
|
+
}, An = /* @__PURE__ */ ce.define({
|
|
978
|
+
combine(t) {
|
|
979
|
+
return Be(t, Fo, {
|
|
980
|
+
highlightWordAroundCursor: (e, r) => e || r,
|
|
981
|
+
minSelectionLength: Math.min,
|
|
982
|
+
maxMatches: Math.min
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
function No(t) {
|
|
987
|
+
let e = [Uo, zo];
|
|
988
|
+
return t && e.push(An.of(t)), e;
|
|
989
|
+
}
|
|
990
|
+
const qo = /* @__PURE__ */ y.mark({ class: "cm-selectionMatch" }), Ho = /* @__PURE__ */ y.mark({ class: "cm-selectionMatch cm-selectionMatch-main" });
|
|
991
|
+
function kt(t, e, r, n) {
|
|
992
|
+
return (r == 0 || t(e.sliceDoc(r - 1, r)) != M.Word) && (n == e.doc.length || t(e.sliceDoc(n, n + 1)) != M.Word);
|
|
993
|
+
}
|
|
994
|
+
function Vo(t, e, r, n) {
|
|
995
|
+
return t(e.sliceDoc(r, r + 1)) == M.Word && t(e.sliceDoc(n - 1, n)) == M.Word;
|
|
996
|
+
}
|
|
997
|
+
const zo = /* @__PURE__ */ Ft.fromClass(class {
|
|
998
|
+
constructor(t) {
|
|
999
|
+
this.decorations = this.getDeco(t);
|
|
1000
|
+
}
|
|
1001
|
+
update(t) {
|
|
1002
|
+
(t.selectionSet || t.docChanged || t.viewportChanged) && (this.decorations = this.getDeco(t.view));
|
|
1003
|
+
}
|
|
1004
|
+
getDeco(t) {
|
|
1005
|
+
let e = t.state.facet(An), { state: r } = t, n = r.selection;
|
|
1006
|
+
if (n.ranges.length > 1)
|
|
1007
|
+
return y.none;
|
|
1008
|
+
let o = n.main, i, s = null;
|
|
1009
|
+
if (o.empty) {
|
|
1010
|
+
if (!e.highlightWordAroundCursor)
|
|
1011
|
+
return y.none;
|
|
1012
|
+
let a = r.wordAt(o.head);
|
|
1013
|
+
if (!a)
|
|
1014
|
+
return y.none;
|
|
1015
|
+
s = r.charCategorizer(o.head), i = r.sliceDoc(a.from, a.to);
|
|
1016
|
+
} else {
|
|
1017
|
+
let a = o.to - o.from;
|
|
1018
|
+
if (a < e.minSelectionLength || a > 200)
|
|
1019
|
+
return y.none;
|
|
1020
|
+
if (e.wholeWords) {
|
|
1021
|
+
if (i = r.sliceDoc(o.from, o.to), s = r.charCategorizer(o.head), !(kt(s, r, o.from, o.to) && Vo(s, r, o.from, o.to)))
|
|
1022
|
+
return y.none;
|
|
1023
|
+
} else if (i = r.sliceDoc(o.from, o.to).trim(), !i)
|
|
1024
|
+
return y.none;
|
|
1025
|
+
}
|
|
1026
|
+
let l = [];
|
|
1027
|
+
for (let a of t.visibleRanges) {
|
|
1028
|
+
let c = new Z(r.doc, i, a.from, a.to);
|
|
1029
|
+
for (; !c.next().done; ) {
|
|
1030
|
+
let { from: h, to: u } = c.value;
|
|
1031
|
+
if ((!s || kt(s, r, h, u)) && (o.empty && h <= o.from && u >= o.to ? l.push(Ho.range(h, u)) : (h >= o.to || u <= o.from) && l.push(qo.range(h, u)), l.length > e.maxMatches))
|
|
1032
|
+
return y.none;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return y.set(l);
|
|
1036
|
+
}
|
|
1037
|
+
}, {
|
|
1038
|
+
decorations: (t) => t.decorations
|
|
1039
|
+
}), Uo = /* @__PURE__ */ p.baseTheme({
|
|
1040
|
+
".cm-selectionMatch": { backgroundColor: "#99ff7780" },
|
|
1041
|
+
".cm-searchMatch .cm-selectionMatch": { backgroundColor: "transparent" }
|
|
1042
|
+
}), $o = ({ state: t, dispatch: e }) => {
|
|
1043
|
+
let { selection: r } = t, n = d.create(r.ranges.map((o) => t.wordAt(o.head) || d.cursor(o.head)), r.mainIndex);
|
|
1044
|
+
return n.eq(r) ? !1 : (e(t.update({ selection: n })), !0);
|
|
1045
|
+
};
|
|
1046
|
+
function Go(t, e) {
|
|
1047
|
+
let { main: r, ranges: n } = t.selection, o = t.wordAt(r.head), i = o && o.from == r.from && o.to == r.to;
|
|
1048
|
+
for (let s = !1, l = new Z(t.doc, e, n[n.length - 1].to); ; )
|
|
1049
|
+
if (l.next(), l.done) {
|
|
1050
|
+
if (s)
|
|
1051
|
+
return null;
|
|
1052
|
+
l = new Z(t.doc, e, 0, Math.max(0, n[n.length - 1].from - 1)), s = !0;
|
|
1053
|
+
} else {
|
|
1054
|
+
if (s && n.some((a) => a.from == l.value.from))
|
|
1055
|
+
continue;
|
|
1056
|
+
if (i) {
|
|
1057
|
+
let a = t.wordAt(l.value.from);
|
|
1058
|
+
if (!a || a.from != l.value.from || a.to != l.value.to)
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
return l.value;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
const Ko = ({ state: t, dispatch: e }) => {
|
|
1065
|
+
let { ranges: r } = t.selection;
|
|
1066
|
+
if (r.some((i) => i.from === i.to))
|
|
1067
|
+
return $o({ state: t, dispatch: e });
|
|
1068
|
+
let n = t.sliceDoc(r[0].from, r[0].to);
|
|
1069
|
+
if (t.selection.ranges.some((i) => t.sliceDoc(i.from, i.to) != n))
|
|
1070
|
+
return !1;
|
|
1071
|
+
let o = Go(t, n);
|
|
1072
|
+
return o ? (e(t.update({
|
|
1073
|
+
selection: t.selection.addRange(d.range(o.from, o.to), !1),
|
|
1074
|
+
effects: p.scrollIntoView(o.to)
|
|
1075
|
+
})), !0) : !1;
|
|
1076
|
+
}, te = /* @__PURE__ */ ce.define({
|
|
1077
|
+
combine(t) {
|
|
1078
|
+
return Be(t, {
|
|
1079
|
+
top: !1,
|
|
1080
|
+
caseSensitive: !1,
|
|
1081
|
+
literal: !1,
|
|
1082
|
+
regexp: !1,
|
|
1083
|
+
wholeWord: !1,
|
|
1084
|
+
createPanel: (e) => new oi(e),
|
|
1085
|
+
scrollToMatch: (e) => p.scrollIntoView(e)
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
class Mn {
|
|
1090
|
+
/**
|
|
1091
|
+
Create a query object.
|
|
1092
|
+
*/
|
|
1093
|
+
constructor(e) {
|
|
1094
|
+
this.search = e.search, this.caseSensitive = !!e.caseSensitive, this.literal = !!e.literal, this.regexp = !!e.regexp, this.replace = e.replace || "", this.valid = !!this.search && (!this.regexp || Io(this.search)), this.unquoted = this.unquote(this.search), this.wholeWord = !!e.wholeWord;
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
@internal
|
|
1098
|
+
*/
|
|
1099
|
+
unquote(e) {
|
|
1100
|
+
return this.literal ? e : e.replace(/\\([nrt\\])/g, (r, n) => n == "n" ? `
|
|
1101
|
+
` : n == "r" ? "\r" : n == "t" ? " " : "\\");
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
Compare this query to another query.
|
|
1105
|
+
*/
|
|
1106
|
+
eq(e) {
|
|
1107
|
+
return this.search == e.search && this.replace == e.replace && this.caseSensitive == e.caseSensitive && this.regexp == e.regexp && this.wholeWord == e.wholeWord;
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
@internal
|
|
1111
|
+
*/
|
|
1112
|
+
create() {
|
|
1113
|
+
return this.regexp ? new Qo(this) : new _o(this);
|
|
1114
|
+
}
|
|
1115
|
+
/**
|
|
1116
|
+
Get a search cursor for this query, searching through the given
|
|
1117
|
+
range in the given state.
|
|
1118
|
+
*/
|
|
1119
|
+
getCursor(e, r = 0, n) {
|
|
1120
|
+
let o = e.doc ? e : le.create({ doc: e });
|
|
1121
|
+
return n == null && (n = o.doc.length), this.regexp ? _(this, o, r, n) : J(this, o, r, n);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
class Ln {
|
|
1125
|
+
constructor(e) {
|
|
1126
|
+
this.spec = e;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function J(t, e, r, n) {
|
|
1130
|
+
return new Z(e.doc, t.unquoted, r, n, t.caseSensitive ? void 0 : (o) => o.toLowerCase(), t.wholeWord ? Jo(e.doc, e.charCategorizer(e.selection.main.head)) : void 0);
|
|
1131
|
+
}
|
|
1132
|
+
function Jo(t, e) {
|
|
1133
|
+
return (r, n, o, i) => ((i > r || i + o.length < n) && (i = Math.max(0, r - 2), o = t.sliceString(i, Math.min(t.length, n + 2))), (e(Ae(o, r - i)) != M.Word || e(Me(o, r - i)) != M.Word) && (e(Me(o, n - i)) != M.Word || e(Ae(o, n - i)) != M.Word));
|
|
1134
|
+
}
|
|
1135
|
+
class _o extends Ln {
|
|
1136
|
+
constructor(e) {
|
|
1137
|
+
super(e);
|
|
1138
|
+
}
|
|
1139
|
+
nextMatch(e, r, n) {
|
|
1140
|
+
let o = J(this.spec, e, n, e.doc.length).nextOverlapping();
|
|
1141
|
+
return o.done && (o = J(this.spec, e, 0, r).nextOverlapping()), o.done ? null : o.value;
|
|
1142
|
+
}
|
|
1143
|
+
// Searching in reverse is, rather than implementing an inverted search
|
|
1144
|
+
// cursor, done by scanning chunk after chunk forward.
|
|
1145
|
+
prevMatchInRange(e, r, n) {
|
|
1146
|
+
for (let o = n; ; ) {
|
|
1147
|
+
let i = Math.max(r, o - 1e4 - this.spec.unquoted.length), s = J(this.spec, e, i, o), l = null;
|
|
1148
|
+
for (; !s.nextOverlapping().done; )
|
|
1149
|
+
l = s.value;
|
|
1150
|
+
if (l)
|
|
1151
|
+
return l;
|
|
1152
|
+
if (i == r)
|
|
1153
|
+
return null;
|
|
1154
|
+
o -= 1e4;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
prevMatch(e, r, n) {
|
|
1158
|
+
return this.prevMatchInRange(e, 0, r) || this.prevMatchInRange(e, n, e.doc.length);
|
|
1159
|
+
}
|
|
1160
|
+
getReplacement(e) {
|
|
1161
|
+
return this.spec.unquote(this.spec.replace);
|
|
1162
|
+
}
|
|
1163
|
+
matchAll(e, r) {
|
|
1164
|
+
let n = J(this.spec, e, 0, e.doc.length), o = [];
|
|
1165
|
+
for (; !n.next().done; ) {
|
|
1166
|
+
if (o.length >= r)
|
|
1167
|
+
return null;
|
|
1168
|
+
o.push(n.value);
|
|
1169
|
+
}
|
|
1170
|
+
return o;
|
|
1171
|
+
}
|
|
1172
|
+
highlight(e, r, n, o) {
|
|
1173
|
+
let i = J(this.spec, e, Math.max(0, r - this.spec.unquoted.length), Math.min(n + this.spec.unquoted.length, e.doc.length));
|
|
1174
|
+
for (; !i.next().done; )
|
|
1175
|
+
o(i.value.from, i.value.to);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function _(t, e, r, n) {
|
|
1179
|
+
return new Cn(e.doc, t.search, {
|
|
1180
|
+
ignoreCase: !t.caseSensitive,
|
|
1181
|
+
test: t.wholeWord ? jo(e.charCategorizer(e.selection.main.head)) : void 0
|
|
1182
|
+
}, r, n);
|
|
1183
|
+
}
|
|
1184
|
+
function Ae(t, e) {
|
|
1185
|
+
return t.slice(Y(t, e, !1), e);
|
|
1186
|
+
}
|
|
1187
|
+
function Me(t, e) {
|
|
1188
|
+
return t.slice(e, Y(t, e));
|
|
1189
|
+
}
|
|
1190
|
+
function jo(t) {
|
|
1191
|
+
return (e, r, n) => !n[0].length || (t(Ae(n.input, n.index)) != M.Word || t(Me(n.input, n.index)) != M.Word) && (t(Me(n.input, n.index + n[0].length)) != M.Word || t(Ae(n.input, n.index + n[0].length)) != M.Word);
|
|
1192
|
+
}
|
|
1193
|
+
class Qo extends Ln {
|
|
1194
|
+
nextMatch(e, r, n) {
|
|
1195
|
+
let o = _(this.spec, e, n, e.doc.length).next();
|
|
1196
|
+
return o.done && (o = _(this.spec, e, 0, r).next()), o.done ? null : o.value;
|
|
1197
|
+
}
|
|
1198
|
+
prevMatchInRange(e, r, n) {
|
|
1199
|
+
for (let o = 1; ; o++) {
|
|
1200
|
+
let i = Math.max(
|
|
1201
|
+
r,
|
|
1202
|
+
n - o * 1e4
|
|
1203
|
+
/* ChunkSize */
|
|
1204
|
+
), s = _(this.spec, e, i, n), l = null;
|
|
1205
|
+
for (; !s.next().done; )
|
|
1206
|
+
l = s.value;
|
|
1207
|
+
if (l && (i == r || l.from > i + 10))
|
|
1208
|
+
return l;
|
|
1209
|
+
if (i == r)
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
prevMatch(e, r, n) {
|
|
1214
|
+
return this.prevMatchInRange(e, 0, r) || this.prevMatchInRange(e, n, e.doc.length);
|
|
1215
|
+
}
|
|
1216
|
+
getReplacement(e) {
|
|
1217
|
+
return this.spec.unquote(this.spec.replace.replace(/\$([$&\d+])/g, (r, n) => n == "$" ? "$" : n == "&" ? e.match[0] : n != "0" && +n < e.match.length ? e.match[n] : r));
|
|
1218
|
+
}
|
|
1219
|
+
matchAll(e, r) {
|
|
1220
|
+
let n = _(this.spec, e, 0, e.doc.length), o = [];
|
|
1221
|
+
for (; !n.next().done; ) {
|
|
1222
|
+
if (o.length >= r)
|
|
1223
|
+
return null;
|
|
1224
|
+
o.push(n.value);
|
|
1225
|
+
}
|
|
1226
|
+
return o;
|
|
1227
|
+
}
|
|
1228
|
+
highlight(e, r, n, o) {
|
|
1229
|
+
let i = _(this.spec, e, Math.max(
|
|
1230
|
+
0,
|
|
1231
|
+
r - 250
|
|
1232
|
+
/* HighlightMargin */
|
|
1233
|
+
), Math.min(n + 250, e.doc.length));
|
|
1234
|
+
for (; !i.next().done; )
|
|
1235
|
+
o(i.value.from, i.value.to);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
const ae = /* @__PURE__ */ w.define(), st = /* @__PURE__ */ w.define(), F = /* @__PURE__ */ Ee.define({
|
|
1239
|
+
create(t) {
|
|
1240
|
+
return new ze(Ye(t).create(), null);
|
|
1241
|
+
},
|
|
1242
|
+
update(t, e) {
|
|
1243
|
+
for (let r of e.effects)
|
|
1244
|
+
r.is(ae) ? t = new ze(r.value.create(), t.panel) : r.is(st) && (t = new ze(t.query, r.value ? lt : null));
|
|
1245
|
+
return t;
|
|
1246
|
+
},
|
|
1247
|
+
provide: (t) => tt.from(t, (e) => e.panel)
|
|
1248
|
+
});
|
|
1249
|
+
class ze {
|
|
1250
|
+
constructor(e, r) {
|
|
1251
|
+
this.query = e, this.panel = r;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
const Yo = /* @__PURE__ */ y.mark({ class: "cm-searchMatch" }), Zo = /* @__PURE__ */ y.mark({ class: "cm-searchMatch cm-searchMatch-selected" }), Xo = /* @__PURE__ */ Ft.fromClass(class {
|
|
1255
|
+
constructor(t) {
|
|
1256
|
+
this.view = t, this.decorations = this.highlight(t.state.field(F));
|
|
1257
|
+
}
|
|
1258
|
+
update(t) {
|
|
1259
|
+
let e = t.state.field(F);
|
|
1260
|
+
(e != t.startState.field(F) || t.docChanged || t.selectionSet || t.viewportChanged) && (this.decorations = this.highlight(e));
|
|
1261
|
+
}
|
|
1262
|
+
highlight({ query: t, panel: e }) {
|
|
1263
|
+
if (!e || !t.spec.valid)
|
|
1264
|
+
return y.none;
|
|
1265
|
+
let { view: r } = this, n = new er();
|
|
1266
|
+
for (let o = 0, i = r.visibleRanges, s = i.length; o < s; o++) {
|
|
1267
|
+
let { from: l, to: a } = i[o];
|
|
1268
|
+
for (; o < s - 1 && a > i[o + 1].from - 2 * 250; )
|
|
1269
|
+
a = i[++o].to;
|
|
1270
|
+
t.highlight(r.state, l, a, (c, h) => {
|
|
1271
|
+
let u = r.state.selection.ranges.some((m) => m.from == c && m.to == h);
|
|
1272
|
+
n.add(c, h, u ? Zo : Yo);
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
return n.finish();
|
|
1276
|
+
}
|
|
1277
|
+
}, {
|
|
1278
|
+
decorations: (t) => t.decorations
|
|
1279
|
+
});
|
|
1280
|
+
function he(t) {
|
|
1281
|
+
return (e) => {
|
|
1282
|
+
let r = e.state.field(F, !1);
|
|
1283
|
+
return r && r.query.spec.valid ? t(e, r) : En(e);
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
const Le = /* @__PURE__ */ he((t, { query: e }) => {
|
|
1287
|
+
let { to: r } = t.state.selection.main, n = e.nextMatch(t.state, r, r);
|
|
1288
|
+
if (!n)
|
|
1289
|
+
return !1;
|
|
1290
|
+
let o = d.single(n.from, n.to), i = t.state.facet(te);
|
|
1291
|
+
return t.dispatch({
|
|
1292
|
+
selection: o,
|
|
1293
|
+
effects: [at(t, n), i.scrollToMatch(o.main, t)],
|
|
1294
|
+
userEvent: "select.search"
|
|
1295
|
+
}), Bn(t), !0;
|
|
1296
|
+
}), De = /* @__PURE__ */ he((t, { query: e }) => {
|
|
1297
|
+
let { state: r } = t, { from: n } = r.selection.main, o = e.prevMatch(r, n, n);
|
|
1298
|
+
if (!o)
|
|
1299
|
+
return !1;
|
|
1300
|
+
let i = d.single(o.from, o.to), s = t.state.facet(te);
|
|
1301
|
+
return t.dispatch({
|
|
1302
|
+
selection: i,
|
|
1303
|
+
effects: [at(t, o), s.scrollToMatch(i.main, t)],
|
|
1304
|
+
userEvent: "select.search"
|
|
1305
|
+
}), Bn(t), !0;
|
|
1306
|
+
}), ei = /* @__PURE__ */ he((t, { query: e }) => {
|
|
1307
|
+
let r = e.matchAll(t.state, 1e3);
|
|
1308
|
+
return !r || !r.length ? !1 : (t.dispatch({
|
|
1309
|
+
selection: d.create(r.map((n) => d.range(n.from, n.to))),
|
|
1310
|
+
userEvent: "select.search.matches"
|
|
1311
|
+
}), !0);
|
|
1312
|
+
}), ti = ({ state: t, dispatch: e }) => {
|
|
1313
|
+
let r = t.selection;
|
|
1314
|
+
if (r.ranges.length > 1 || r.main.empty)
|
|
1315
|
+
return !1;
|
|
1316
|
+
let { from: n, to: o } = r.main, i = [], s = 0;
|
|
1317
|
+
for (let l = new Z(t.doc, t.sliceDoc(n, o)); !l.next().done; ) {
|
|
1318
|
+
if (i.length > 1e3)
|
|
1319
|
+
return !1;
|
|
1320
|
+
l.value.from == n && (s = i.length), i.push(d.range(l.value.from, l.value.to));
|
|
1321
|
+
}
|
|
1322
|
+
return e(t.update({
|
|
1323
|
+
selection: d.create(i, s),
|
|
1324
|
+
userEvent: "select.search.matches"
|
|
1325
|
+
})), !0;
|
|
1326
|
+
}, bt = /* @__PURE__ */ he((t, { query: e }) => {
|
|
1327
|
+
let { state: r } = t, { from: n, to: o } = r.selection.main;
|
|
1328
|
+
if (r.readOnly)
|
|
1329
|
+
return !1;
|
|
1330
|
+
let i = e.nextMatch(r, n, n);
|
|
1331
|
+
if (!i)
|
|
1332
|
+
return !1;
|
|
1333
|
+
let s = [], l, a, c = [];
|
|
1334
|
+
if (i.from == n && i.to == o && (a = r.toText(e.getReplacement(i)), s.push({ from: i.from, to: i.to, insert: a }), i = e.nextMatch(r, i.from, i.to), c.push(p.announce.of(r.phrase("replaced match on line $", r.doc.lineAt(n).number) + "."))), i) {
|
|
1335
|
+
let h = s.length == 0 || s[0].from >= i.to ? 0 : i.to - i.from - a.length;
|
|
1336
|
+
l = d.single(i.from - h, i.to - h), c.push(at(t, i)), c.push(r.facet(te).scrollToMatch(l.main, t));
|
|
1337
|
+
}
|
|
1338
|
+
return t.dispatch({
|
|
1339
|
+
changes: s,
|
|
1340
|
+
selection: l,
|
|
1341
|
+
effects: c,
|
|
1342
|
+
userEvent: "input.replace"
|
|
1343
|
+
}), !0;
|
|
1344
|
+
}), ni = /* @__PURE__ */ he((t, { query: e }) => {
|
|
1345
|
+
if (t.state.readOnly)
|
|
1346
|
+
return !1;
|
|
1347
|
+
let r = e.matchAll(t.state, 1e9).map((o) => {
|
|
1348
|
+
let { from: i, to: s } = o;
|
|
1349
|
+
return { from: i, to: s, insert: e.getReplacement(o) };
|
|
1350
|
+
});
|
|
1351
|
+
if (!r.length)
|
|
1352
|
+
return !1;
|
|
1353
|
+
let n = t.state.phrase("replaced $ matches", r.length) + ".";
|
|
1354
|
+
return t.dispatch({
|
|
1355
|
+
changes: r,
|
|
1356
|
+
effects: p.announce.of(n),
|
|
1357
|
+
userEvent: "input.replace.all"
|
|
1358
|
+
}), !0;
|
|
1359
|
+
});
|
|
1360
|
+
function lt(t) {
|
|
1361
|
+
return t.state.facet(te).createPanel(t);
|
|
1362
|
+
}
|
|
1363
|
+
function Ye(t, e) {
|
|
1364
|
+
var r, n, o, i, s;
|
|
1365
|
+
let l = t.selection.main, a = l.empty || l.to > l.from + 100 ? "" : t.sliceDoc(l.from, l.to);
|
|
1366
|
+
if (e && !a)
|
|
1367
|
+
return e;
|
|
1368
|
+
let c = t.facet(te);
|
|
1369
|
+
return new Mn({
|
|
1370
|
+
search: ((r = e == null ? void 0 : e.literal) !== null && r !== void 0 ? r : c.literal) ? a : a.replace(/\n/g, "\\n"),
|
|
1371
|
+
caseSensitive: (n = e == null ? void 0 : e.caseSensitive) !== null && n !== void 0 ? n : c.caseSensitive,
|
|
1372
|
+
literal: (o = e == null ? void 0 : e.literal) !== null && o !== void 0 ? o : c.literal,
|
|
1373
|
+
regexp: (i = e == null ? void 0 : e.regexp) !== null && i !== void 0 ? i : c.regexp,
|
|
1374
|
+
wholeWord: (s = e == null ? void 0 : e.wholeWord) !== null && s !== void 0 ? s : c.wholeWord
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
function Dn(t) {
|
|
1378
|
+
let e = se(t, lt);
|
|
1379
|
+
return e && e.dom.querySelector("[main-field]");
|
|
1380
|
+
}
|
|
1381
|
+
function Bn(t) {
|
|
1382
|
+
let e = Dn(t);
|
|
1383
|
+
e && e == t.root.activeElement && e.select();
|
|
1384
|
+
}
|
|
1385
|
+
const En = (t) => {
|
|
1386
|
+
let e = t.state.field(F, !1);
|
|
1387
|
+
if (e && e.panel) {
|
|
1388
|
+
let r = Dn(t);
|
|
1389
|
+
if (r && r != t.root.activeElement) {
|
|
1390
|
+
let n = Ye(t.state, e.query.spec);
|
|
1391
|
+
n.valid && t.dispatch({ effects: ae.of(n) }), r.focus(), r.select();
|
|
1392
|
+
}
|
|
1393
|
+
} else
|
|
1394
|
+
t.dispatch({ effects: [
|
|
1395
|
+
st.of(!0),
|
|
1396
|
+
e ? ae.of(Ye(t.state, e.query.spec)) : w.appendConfig.of(si)
|
|
1397
|
+
] });
|
|
1398
|
+
return !0;
|
|
1399
|
+
}, wn = (t) => {
|
|
1400
|
+
let e = t.state.field(F, !1);
|
|
1401
|
+
if (!e || !e.panel)
|
|
1402
|
+
return !1;
|
|
1403
|
+
let r = se(t, lt);
|
|
1404
|
+
return r && r.dom.contains(t.root.activeElement) && t.focus(), t.dispatch({ effects: st.of(!1) }), !0;
|
|
1405
|
+
}, ri = [
|
|
1406
|
+
{ key: "Mod-f", run: En, scope: "editor search-panel" },
|
|
1407
|
+
{ key: "F3", run: Le, shift: De, scope: "editor search-panel", preventDefault: !0 },
|
|
1408
|
+
{ key: "Mod-g", run: Le, shift: De, scope: "editor search-panel", preventDefault: !0 },
|
|
1409
|
+
{ key: "Escape", run: wn, scope: "editor search-panel" },
|
|
1410
|
+
{ key: "Mod-Shift-l", run: ti },
|
|
1411
|
+
{ key: "Alt-g", run: Po },
|
|
1412
|
+
{ key: "Mod-d", run: Ko, preventDefault: !0 }
|
|
1413
|
+
];
|
|
1414
|
+
class oi {
|
|
1415
|
+
constructor(e) {
|
|
1416
|
+
this.view = e;
|
|
1417
|
+
let r = this.query = e.state.field(F).query.spec;
|
|
1418
|
+
this.commit = this.commit.bind(this), this.searchField = g("input", {
|
|
1419
|
+
value: r.search,
|
|
1420
|
+
placeholder: v(e, "Find"),
|
|
1421
|
+
"aria-label": v(e, "Find"),
|
|
1422
|
+
class: "cm-textfield",
|
|
1423
|
+
name: "search",
|
|
1424
|
+
form: "",
|
|
1425
|
+
"main-field": "true",
|
|
1426
|
+
onchange: this.commit,
|
|
1427
|
+
onkeyup: this.commit
|
|
1428
|
+
}), this.replaceField = g("input", {
|
|
1429
|
+
value: r.replace,
|
|
1430
|
+
placeholder: v(e, "Replace"),
|
|
1431
|
+
"aria-label": v(e, "Replace"),
|
|
1432
|
+
class: "cm-textfield",
|
|
1433
|
+
name: "replace",
|
|
1434
|
+
form: "",
|
|
1435
|
+
onchange: this.commit,
|
|
1436
|
+
onkeyup: this.commit
|
|
1437
|
+
}), this.caseField = g("input", {
|
|
1438
|
+
type: "checkbox",
|
|
1439
|
+
name: "case",
|
|
1440
|
+
form: "",
|
|
1441
|
+
checked: r.caseSensitive,
|
|
1442
|
+
onchange: this.commit
|
|
1443
|
+
}), this.reField = g("input", {
|
|
1444
|
+
type: "checkbox",
|
|
1445
|
+
name: "re",
|
|
1446
|
+
form: "",
|
|
1447
|
+
checked: r.regexp,
|
|
1448
|
+
onchange: this.commit
|
|
1449
|
+
}), this.wordField = g("input", {
|
|
1450
|
+
type: "checkbox",
|
|
1451
|
+
name: "word",
|
|
1452
|
+
form: "",
|
|
1453
|
+
checked: r.wholeWord,
|
|
1454
|
+
onchange: this.commit
|
|
1455
|
+
});
|
|
1456
|
+
function n(o, i, s) {
|
|
1457
|
+
return g("button", { class: "cm-button", name: o, onclick: i, type: "button" }, s);
|
|
1458
|
+
}
|
|
1459
|
+
this.dom = g("div", { onkeydown: (o) => this.keydown(o), class: "cm-search" }, [
|
|
1460
|
+
this.searchField,
|
|
1461
|
+
n("next", () => Le(e), [v(e, "next")]),
|
|
1462
|
+
n("prev", () => De(e), [v(e, "previous")]),
|
|
1463
|
+
n("select", () => ei(e), [v(e, "all")]),
|
|
1464
|
+
g("label", null, [this.caseField, v(e, "match case")]),
|
|
1465
|
+
g("label", null, [this.reField, v(e, "regexp")]),
|
|
1466
|
+
g("label", null, [this.wordField, v(e, "by word")]),
|
|
1467
|
+
...e.state.readOnly ? [] : [
|
|
1468
|
+
g("br"),
|
|
1469
|
+
this.replaceField,
|
|
1470
|
+
n("replace", () => bt(e), [v(e, "replace")]),
|
|
1471
|
+
n("replaceAll", () => ni(e), [v(e, "replace all")])
|
|
1472
|
+
],
|
|
1473
|
+
g("button", {
|
|
1474
|
+
name: "close",
|
|
1475
|
+
onclick: () => wn(e),
|
|
1476
|
+
"aria-label": v(e, "close"),
|
|
1477
|
+
type: "button"
|
|
1478
|
+
}, ["×"])
|
|
1479
|
+
]);
|
|
1480
|
+
}
|
|
1481
|
+
commit() {
|
|
1482
|
+
let e = new Mn({
|
|
1483
|
+
search: this.searchField.value,
|
|
1484
|
+
caseSensitive: this.caseField.checked,
|
|
1485
|
+
regexp: this.reField.checked,
|
|
1486
|
+
wholeWord: this.wordField.checked,
|
|
1487
|
+
replace: this.replaceField.value
|
|
1488
|
+
});
|
|
1489
|
+
e.eq(this.query) || (this.query = e, this.view.dispatch({ effects: ae.of(e) }));
|
|
1490
|
+
}
|
|
1491
|
+
keydown(e) {
|
|
1492
|
+
tr(this.view, e, "search-panel") ? e.preventDefault() : e.keyCode == 13 && e.target == this.searchField ? (e.preventDefault(), (e.shiftKey ? De : Le)(this.view)) : e.keyCode == 13 && e.target == this.replaceField && (e.preventDefault(), bt(this.view));
|
|
1493
|
+
}
|
|
1494
|
+
update(e) {
|
|
1495
|
+
for (let r of e.transactions)
|
|
1496
|
+
for (let n of r.effects)
|
|
1497
|
+
n.is(ae) && !n.value.eq(this.query) && this.setQuery(n.value);
|
|
1498
|
+
}
|
|
1499
|
+
setQuery(e) {
|
|
1500
|
+
this.query = e, this.searchField.value = e.search, this.replaceField.value = e.replace, this.caseField.checked = e.caseSensitive, this.reField.checked = e.regexp, this.wordField.checked = e.wholeWord;
|
|
1501
|
+
}
|
|
1502
|
+
mount() {
|
|
1503
|
+
this.searchField.select();
|
|
1504
|
+
}
|
|
1505
|
+
get pos() {
|
|
1506
|
+
return 80;
|
|
1507
|
+
}
|
|
1508
|
+
get top() {
|
|
1509
|
+
return this.view.state.facet(te).top;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
function v(t, e) {
|
|
1513
|
+
return t.state.phrase(e);
|
|
1514
|
+
}
|
|
1515
|
+
const ge = 30, pe = /[\s\.,:;?!]/;
|
|
1516
|
+
function at(t, { from: e, to: r }) {
|
|
1517
|
+
let n = t.state.doc.lineAt(e), o = t.state.doc.lineAt(r).to, i = Math.max(n.from, e - ge), s = Math.min(o, r + ge), l = t.state.sliceDoc(i, s);
|
|
1518
|
+
if (i != n.from) {
|
|
1519
|
+
for (let a = 0; a < ge; a++)
|
|
1520
|
+
if (!pe.test(l[a + 1]) && pe.test(l[a])) {
|
|
1521
|
+
l = l.slice(a);
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
if (s != o) {
|
|
1526
|
+
for (let a = l.length - 1; a > l.length - ge; a--)
|
|
1527
|
+
if (!pe.test(l[a - 1]) && pe.test(l[a])) {
|
|
1528
|
+
l = l.slice(0, a);
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return p.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`);
|
|
1533
|
+
}
|
|
1534
|
+
const ii = /* @__PURE__ */ p.baseTheme({
|
|
1535
|
+
".cm-panel.cm-search": {
|
|
1536
|
+
padding: "2px 6px 4px",
|
|
1537
|
+
position: "relative",
|
|
1538
|
+
"& [name=close]": {
|
|
1539
|
+
position: "absolute",
|
|
1540
|
+
top: "0",
|
|
1541
|
+
right: "4px",
|
|
1542
|
+
backgroundColor: "inherit",
|
|
1543
|
+
border: "none",
|
|
1544
|
+
font: "inherit",
|
|
1545
|
+
padding: 0,
|
|
1546
|
+
margin: 0
|
|
1547
|
+
},
|
|
1548
|
+
"& input, & button, & label": {
|
|
1549
|
+
margin: ".2em .6em .2em 0"
|
|
1550
|
+
},
|
|
1551
|
+
"& input[type=checkbox]": {
|
|
1552
|
+
marginRight: ".2em"
|
|
1553
|
+
},
|
|
1554
|
+
"& label": {
|
|
1555
|
+
fontSize: "80%",
|
|
1556
|
+
whiteSpace: "pre"
|
|
1557
|
+
}
|
|
1558
|
+
},
|
|
1559
|
+
"&light .cm-searchMatch": { backgroundColor: "#ffff0054" },
|
|
1560
|
+
"&dark .cm-searchMatch": { backgroundColor: "#00ffff8a" },
|
|
1561
|
+
"&light .cm-searchMatch-selected": { backgroundColor: "#ff6a0054" },
|
|
1562
|
+
"&dark .cm-searchMatch-selected": { backgroundColor: "#ff00ff8a" }
|
|
1563
|
+
}), si = [
|
|
1564
|
+
F,
|
|
1565
|
+
/* @__PURE__ */ Zn.lowest(Xo),
|
|
1566
|
+
ii
|
|
1567
|
+
];
|
|
1568
|
+
class li {
|
|
1569
|
+
constructor(e, r, n) {
|
|
1570
|
+
this.from = e, this.to = r, this.diagnostic = n;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
class H {
|
|
1574
|
+
constructor(e, r, n) {
|
|
1575
|
+
this.diagnostics = e, this.panel = r, this.selected = n;
|
|
1576
|
+
}
|
|
1577
|
+
static init(e, r, n) {
|
|
1578
|
+
let o = e, i = n.facet(On).markerFilter;
|
|
1579
|
+
i && (o = i(o));
|
|
1580
|
+
let s = y.set(o.map((l) => l.from == l.to || l.from == l.to - 1 && n.doc.lineAt(l.from).to == l.from ? y.widget({
|
|
1581
|
+
widget: new pi(l),
|
|
1582
|
+
diagnostic: l
|
|
1583
|
+
}).range(l.from) : y.mark({
|
|
1584
|
+
attributes: { class: "cm-lintRange cm-lintRange-" + l.severity + (l.markClass ? " " + l.markClass : "") },
|
|
1585
|
+
diagnostic: l
|
|
1586
|
+
}).range(l.from, l.to)), !0);
|
|
1587
|
+
return new H(s, r, X(s));
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
function X(t, e = null, r = 0) {
|
|
1591
|
+
let n = null;
|
|
1592
|
+
return t.between(r, 1e9, (o, i, { spec: s }) => {
|
|
1593
|
+
if (!(e && s.diagnostic != e))
|
|
1594
|
+
return n = new li(o, i, s.diagnostic), !1;
|
|
1595
|
+
}), n;
|
|
1596
|
+
}
|
|
1597
|
+
function ai(t, e) {
|
|
1598
|
+
let r = t.startState.doc.lineAt(e.pos);
|
|
1599
|
+
return !!(t.effects.some((n) => n.is(Rn)) || t.changes.touchesRange(r.from, r.to));
|
|
1600
|
+
}
|
|
1601
|
+
function ci(t, e) {
|
|
1602
|
+
return t.field(A, !1) ? e : e.concat(w.appendConfig.of(ki));
|
|
1603
|
+
}
|
|
1604
|
+
const Rn = /* @__PURE__ */ w.define(), ct = /* @__PURE__ */ w.define(), Tn = /* @__PURE__ */ w.define(), A = /* @__PURE__ */ Ee.define({
|
|
1605
|
+
create() {
|
|
1606
|
+
return new H(y.none, null, null);
|
|
1607
|
+
},
|
|
1608
|
+
update(t, e) {
|
|
1609
|
+
if (e.docChanged) {
|
|
1610
|
+
let r = t.diagnostics.map(e.changes), n = null;
|
|
1611
|
+
if (t.selected) {
|
|
1612
|
+
let o = e.changes.mapPos(t.selected.from, 1);
|
|
1613
|
+
n = X(r, t.selected.diagnostic, o) || X(r, null, o);
|
|
1614
|
+
}
|
|
1615
|
+
t = new H(r, t.panel, n);
|
|
1616
|
+
}
|
|
1617
|
+
for (let r of e.effects)
|
|
1618
|
+
r.is(Rn) ? t = H.init(r.value, t.panel, e.state) : r.is(ct) ? t = new H(t.diagnostics, r.value ? Pe.open : null, t.selected) : r.is(Tn) && (t = new H(t.diagnostics, t.panel, r.value));
|
|
1619
|
+
return t;
|
|
1620
|
+
},
|
|
1621
|
+
provide: (t) => [
|
|
1622
|
+
tt.from(t, (e) => e.panel),
|
|
1623
|
+
p.decorations.from(t, (e) => e.diagnostics)
|
|
1624
|
+
]
|
|
1625
|
+
}), hi = /* @__PURE__ */ y.mark({ class: "cm-lintRange cm-lintRange-active" });
|
|
1626
|
+
function ui(t, e, r) {
|
|
1627
|
+
let { diagnostics: n } = t.state.field(A), o = [], i = 2e8, s = 0;
|
|
1628
|
+
n.between(e - (r < 0 ? 1 : 0), e + (r > 0 ? 1 : 0), (a, c, { spec: h }) => {
|
|
1629
|
+
e >= a && e <= c && (a == c || (e > a || r > 0) && (e < c || r < 0)) && (o.push(h.diagnostic), i = Math.min(a, i), s = Math.max(c, s));
|
|
1630
|
+
});
|
|
1631
|
+
let l = t.state.facet(On).tooltipFilter;
|
|
1632
|
+
return l && (o = l(o)), o.length ? {
|
|
1633
|
+
pos: i,
|
|
1634
|
+
end: s,
|
|
1635
|
+
above: t.state.doc.lineAt(i).to < s,
|
|
1636
|
+
create() {
|
|
1637
|
+
return { dom: fi(t, o) };
|
|
1638
|
+
}
|
|
1639
|
+
} : null;
|
|
1640
|
+
}
|
|
1641
|
+
function fi(t, e) {
|
|
1642
|
+
return g("ul", { class: "cm-tooltip-lint" }, e.map((r) => Pn(t, r, !1)));
|
|
1643
|
+
}
|
|
1644
|
+
const di = (t) => {
|
|
1645
|
+
let e = t.state.field(A, !1);
|
|
1646
|
+
(!e || !e.panel) && t.dispatch({ effects: ci(t.state, [ct.of(!0)]) });
|
|
1647
|
+
let r = se(t, Pe.open);
|
|
1648
|
+
return r && r.dom.querySelector(".cm-panel-lint ul").focus(), !0;
|
|
1649
|
+
}, St = (t) => {
|
|
1650
|
+
let e = t.state.field(A, !1);
|
|
1651
|
+
return !e || !e.panel ? !1 : (t.dispatch({ effects: ct.of(!1) }), !0);
|
|
1652
|
+
}, mi = (t) => {
|
|
1653
|
+
let e = t.state.field(A, !1);
|
|
1654
|
+
if (!e)
|
|
1655
|
+
return !1;
|
|
1656
|
+
let r = t.state.selection.main, n = e.diagnostics.iter(r.to + 1);
|
|
1657
|
+
return !n.value && (n = e.diagnostics.iter(0), !n.value || n.from == r.from && n.to == r.to) ? !1 : (t.dispatch({ selection: { anchor: n.from, head: n.to }, scrollIntoView: !0 }), !0);
|
|
1658
|
+
}, gi = [
|
|
1659
|
+
{ key: "Mod-Shift-m", run: di, preventDefault: !0 },
|
|
1660
|
+
{ key: "F8", run: mi }
|
|
1661
|
+
], On = /* @__PURE__ */ ce.define({
|
|
1662
|
+
combine(t) {
|
|
1663
|
+
return Object.assign({ sources: t.map((e) => e.source) }, Be(t.map((e) => e.config), {
|
|
1664
|
+
delay: 750,
|
|
1665
|
+
markerFilter: null,
|
|
1666
|
+
tooltipFilter: null,
|
|
1667
|
+
needsRefresh: null
|
|
1668
|
+
}, {
|
|
1669
|
+
needsRefresh: (e, r) => e ? r ? (n) => e(n) || r(n) : e : r
|
|
1670
|
+
}));
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
function In(t) {
|
|
1674
|
+
let e = [];
|
|
1675
|
+
if (t)
|
|
1676
|
+
e:
|
|
1677
|
+
for (let { name: r } of t) {
|
|
1678
|
+
for (let n = 0; n < r.length; n++) {
|
|
1679
|
+
let o = r[n];
|
|
1680
|
+
if (/[a-zA-Z]/.test(o) && !e.some((i) => i.toLowerCase() == o.toLowerCase())) {
|
|
1681
|
+
e.push(o);
|
|
1682
|
+
continue e;
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
e.push("");
|
|
1686
|
+
}
|
|
1687
|
+
return e;
|
|
1688
|
+
}
|
|
1689
|
+
function Pn(t, e, r) {
|
|
1690
|
+
var n;
|
|
1691
|
+
let o = r ? In(e.actions) : [];
|
|
1692
|
+
return g("li", { class: "cm-diagnostic cm-diagnostic-" + e.severity }, g("span", { class: "cm-diagnosticText" }, e.renderMessage ? e.renderMessage() : e.message), (n = e.actions) === null || n === void 0 ? void 0 : n.map((i, s) => {
|
|
1693
|
+
let l = !1, a = (m) => {
|
|
1694
|
+
if (m.preventDefault(), l)
|
|
1695
|
+
return;
|
|
1696
|
+
l = !0;
|
|
1697
|
+
let x = X(t.state.field(A).diagnostics, e);
|
|
1698
|
+
x && i.apply(t, x.from, x.to);
|
|
1699
|
+
}, { name: c } = i, h = o[s] ? c.indexOf(o[s]) : -1, u = h < 0 ? c : [
|
|
1700
|
+
c.slice(0, h),
|
|
1701
|
+
g("u", c.slice(h, h + 1)),
|
|
1702
|
+
c.slice(h + 1)
|
|
1703
|
+
];
|
|
1704
|
+
return g("button", {
|
|
1705
|
+
type: "button",
|
|
1706
|
+
class: "cm-diagnosticAction",
|
|
1707
|
+
onclick: a,
|
|
1708
|
+
onmousedown: a,
|
|
1709
|
+
"aria-label": ` Action: ${c}${h < 0 ? "" : ` (access key "${o[s]})"`}.`
|
|
1710
|
+
}, u);
|
|
1711
|
+
}), e.source && g("div", { class: "cm-diagnosticSource" }, e.source));
|
|
1712
|
+
}
|
|
1713
|
+
class pi extends rr {
|
|
1714
|
+
constructor(e) {
|
|
1715
|
+
super(), this.diagnostic = e;
|
|
1716
|
+
}
|
|
1717
|
+
eq(e) {
|
|
1718
|
+
return e.diagnostic == this.diagnostic;
|
|
1719
|
+
}
|
|
1720
|
+
toDOM() {
|
|
1721
|
+
return g("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
class Ct {
|
|
1725
|
+
constructor(e, r) {
|
|
1726
|
+
this.diagnostic = r, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = Pn(e, r, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
class Pe {
|
|
1730
|
+
constructor(e) {
|
|
1731
|
+
this.view = e, this.items = [];
|
|
1732
|
+
let r = (o) => {
|
|
1733
|
+
if (o.keyCode == 27)
|
|
1734
|
+
St(this.view), this.view.focus();
|
|
1735
|
+
else if (o.keyCode == 38 || o.keyCode == 33)
|
|
1736
|
+
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
|
|
1737
|
+
else if (o.keyCode == 40 || o.keyCode == 34)
|
|
1738
|
+
this.moveSelection((this.selectedIndex + 1) % this.items.length);
|
|
1739
|
+
else if (o.keyCode == 36)
|
|
1740
|
+
this.moveSelection(0);
|
|
1741
|
+
else if (o.keyCode == 35)
|
|
1742
|
+
this.moveSelection(this.items.length - 1);
|
|
1743
|
+
else if (o.keyCode == 13)
|
|
1744
|
+
this.view.focus();
|
|
1745
|
+
else if (o.keyCode >= 65 && o.keyCode <= 90 && this.selectedIndex >= 0) {
|
|
1746
|
+
let { diagnostic: i } = this.items[this.selectedIndex], s = In(i.actions);
|
|
1747
|
+
for (let l = 0; l < s.length; l++)
|
|
1748
|
+
if (s[l].toUpperCase().charCodeAt(0) == o.keyCode) {
|
|
1749
|
+
let a = X(this.view.state.field(A).diagnostics, i);
|
|
1750
|
+
a && i.actions[l].apply(e, a.from, a.to);
|
|
1751
|
+
}
|
|
1752
|
+
} else
|
|
1753
|
+
return;
|
|
1754
|
+
o.preventDefault();
|
|
1755
|
+
}, n = (o) => {
|
|
1756
|
+
for (let i = 0; i < this.items.length; i++)
|
|
1757
|
+
this.items[i].dom.contains(o.target) && this.moveSelection(i);
|
|
1758
|
+
};
|
|
1759
|
+
this.list = g("ul", {
|
|
1760
|
+
tabIndex: 0,
|
|
1761
|
+
role: "listbox",
|
|
1762
|
+
"aria-label": this.view.state.phrase("Diagnostics"),
|
|
1763
|
+
onkeydown: r,
|
|
1764
|
+
onclick: n
|
|
1765
|
+
}), this.dom = g("div", { class: "cm-panel-lint" }, this.list, g("button", {
|
|
1766
|
+
type: "button",
|
|
1767
|
+
name: "close",
|
|
1768
|
+
"aria-label": this.view.state.phrase("close"),
|
|
1769
|
+
onclick: () => St(this.view)
|
|
1770
|
+
}, "×")), this.update();
|
|
1771
|
+
}
|
|
1772
|
+
get selectedIndex() {
|
|
1773
|
+
let e = this.view.state.field(A).selected;
|
|
1774
|
+
if (!e)
|
|
1775
|
+
return -1;
|
|
1776
|
+
for (let r = 0; r < this.items.length; r++)
|
|
1777
|
+
if (this.items[r].diagnostic == e.diagnostic)
|
|
1778
|
+
return r;
|
|
1779
|
+
return -1;
|
|
1780
|
+
}
|
|
1781
|
+
update() {
|
|
1782
|
+
let { diagnostics: e, selected: r } = this.view.state.field(A), n = 0, o = !1, i = null;
|
|
1783
|
+
for (e.between(0, this.view.state.doc.length, (s, l, { spec: a }) => {
|
|
1784
|
+
let c = -1, h;
|
|
1785
|
+
for (let u = n; u < this.items.length; u++)
|
|
1786
|
+
if (this.items[u].diagnostic == a.diagnostic) {
|
|
1787
|
+
c = u;
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
c < 0 ? (h = new Ct(this.view, a.diagnostic), this.items.splice(n, 0, h), o = !0) : (h = this.items[c], c > n && (this.items.splice(n, c - n), o = !0)), r && h.diagnostic == r.diagnostic ? h.dom.hasAttribute("aria-selected") || (h.dom.setAttribute("aria-selected", "true"), i = h) : h.dom.hasAttribute("aria-selected") && h.dom.removeAttribute("aria-selected"), n++;
|
|
1791
|
+
}); n < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
|
|
1792
|
+
o = !0, this.items.pop();
|
|
1793
|
+
this.items.length == 0 && (this.items.push(new Ct(this.view, {
|
|
1794
|
+
from: -1,
|
|
1795
|
+
to: -1,
|
|
1796
|
+
severity: "info",
|
|
1797
|
+
message: this.view.state.phrase("No diagnostics")
|
|
1798
|
+
})), o = !0), i ? (this.list.setAttribute("aria-activedescendant", i.id), this.view.requestMeasure({
|
|
1799
|
+
key: this,
|
|
1800
|
+
read: () => ({ sel: i.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
|
|
1801
|
+
write: ({ sel: s, panel: l }) => {
|
|
1802
|
+
s.top < l.top ? this.list.scrollTop -= l.top - s.top : s.bottom > l.bottom && (this.list.scrollTop += s.bottom - l.bottom);
|
|
1803
|
+
}
|
|
1804
|
+
})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), o && this.sync();
|
|
1805
|
+
}
|
|
1806
|
+
sync() {
|
|
1807
|
+
let e = this.list.firstChild;
|
|
1808
|
+
function r() {
|
|
1809
|
+
let n = e;
|
|
1810
|
+
e = n.nextSibling, n.remove();
|
|
1811
|
+
}
|
|
1812
|
+
for (let n of this.items)
|
|
1813
|
+
if (n.dom.parentNode == this.list) {
|
|
1814
|
+
for (; e != n.dom; )
|
|
1815
|
+
r();
|
|
1816
|
+
e = n.dom.nextSibling;
|
|
1817
|
+
} else
|
|
1818
|
+
this.list.insertBefore(n.dom, e);
|
|
1819
|
+
for (; e; )
|
|
1820
|
+
r();
|
|
1821
|
+
}
|
|
1822
|
+
moveSelection(e) {
|
|
1823
|
+
if (this.selectedIndex < 0)
|
|
1824
|
+
return;
|
|
1825
|
+
let r = this.view.state.field(A), n = X(r.diagnostics, this.items[e].diagnostic);
|
|
1826
|
+
n && this.view.dispatch({
|
|
1827
|
+
selection: { anchor: n.from, head: n.to },
|
|
1828
|
+
scrollIntoView: !0,
|
|
1829
|
+
effects: Tn.of(n)
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
static open(e) {
|
|
1833
|
+
return new Pe(e);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function yi(t, e = 'viewBox="0 0 40 40"') {
|
|
1837
|
+
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`;
|
|
1838
|
+
}
|
|
1839
|
+
function ye(t) {
|
|
1840
|
+
return yi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
|
|
1841
|
+
}
|
|
1842
|
+
const xi = /* @__PURE__ */ p.baseTheme({
|
|
1843
|
+
".cm-diagnostic": {
|
|
1844
|
+
padding: "3px 6px 3px 8px",
|
|
1845
|
+
marginLeft: "-1px",
|
|
1846
|
+
display: "block",
|
|
1847
|
+
whiteSpace: "pre-wrap"
|
|
1848
|
+
},
|
|
1849
|
+
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
|
|
1850
|
+
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
|
|
1851
|
+
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
|
|
1852
|
+
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
|
|
1853
|
+
".cm-diagnosticAction": {
|
|
1854
|
+
font: "inherit",
|
|
1855
|
+
border: "none",
|
|
1856
|
+
padding: "2px 4px",
|
|
1857
|
+
backgroundColor: "#444",
|
|
1858
|
+
color: "white",
|
|
1859
|
+
borderRadius: "3px",
|
|
1860
|
+
marginLeft: "8px",
|
|
1861
|
+
cursor: "pointer"
|
|
1862
|
+
},
|
|
1863
|
+
".cm-diagnosticSource": {
|
|
1864
|
+
fontSize: "70%",
|
|
1865
|
+
opacity: 0.7
|
|
1866
|
+
},
|
|
1867
|
+
".cm-lintRange": {
|
|
1868
|
+
backgroundPosition: "left bottom",
|
|
1869
|
+
backgroundRepeat: "repeat-x",
|
|
1870
|
+
paddingBottom: "0.7px"
|
|
1871
|
+
},
|
|
1872
|
+
".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ ye("#d11") },
|
|
1873
|
+
".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ ye("orange") },
|
|
1874
|
+
".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ ye("#999") },
|
|
1875
|
+
".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ ye("#66d") },
|
|
1876
|
+
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
|
|
1877
|
+
".cm-tooltip-lint": {
|
|
1878
|
+
padding: 0,
|
|
1879
|
+
margin: 0
|
|
1880
|
+
},
|
|
1881
|
+
".cm-lintPoint": {
|
|
1882
|
+
position: "relative",
|
|
1883
|
+
"&:after": {
|
|
1884
|
+
content: '""',
|
|
1885
|
+
position: "absolute",
|
|
1886
|
+
bottom: 0,
|
|
1887
|
+
left: "-2px",
|
|
1888
|
+
borderLeft: "3px solid transparent",
|
|
1889
|
+
borderRight: "3px solid transparent",
|
|
1890
|
+
borderBottom: "4px solid #d11"
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
".cm-lintPoint-warning": {
|
|
1894
|
+
"&:after": { borderBottomColor: "orange" }
|
|
1895
|
+
},
|
|
1896
|
+
".cm-lintPoint-info": {
|
|
1897
|
+
"&:after": { borderBottomColor: "#999" }
|
|
1898
|
+
},
|
|
1899
|
+
".cm-lintPoint-hint": {
|
|
1900
|
+
"&:after": { borderBottomColor: "#66d" }
|
|
1901
|
+
},
|
|
1902
|
+
".cm-panel.cm-panel-lint": {
|
|
1903
|
+
position: "relative",
|
|
1904
|
+
"& ul": {
|
|
1905
|
+
maxHeight: "100px",
|
|
1906
|
+
overflowY: "auto",
|
|
1907
|
+
"& [aria-selected]": {
|
|
1908
|
+
backgroundColor: "#ddd",
|
|
1909
|
+
"& u": { textDecoration: "underline" }
|
|
1910
|
+
},
|
|
1911
|
+
"&:focus [aria-selected]": {
|
|
1912
|
+
background_fallback: "#bdf",
|
|
1913
|
+
backgroundColor: "Highlight",
|
|
1914
|
+
color_fallback: "white",
|
|
1915
|
+
color: "HighlightText"
|
|
1916
|
+
},
|
|
1917
|
+
"& u": { textDecoration: "none" },
|
|
1918
|
+
padding: 0,
|
|
1919
|
+
margin: 0
|
|
1920
|
+
},
|
|
1921
|
+
"& [name=close]": {
|
|
1922
|
+
position: "absolute",
|
|
1923
|
+
top: "0",
|
|
1924
|
+
right: "2px",
|
|
1925
|
+
background: "inherit",
|
|
1926
|
+
border: "none",
|
|
1927
|
+
font: "inherit",
|
|
1928
|
+
padding: 0,
|
|
1929
|
+
margin: 0
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}), ki = [
|
|
1933
|
+
A,
|
|
1934
|
+
/* @__PURE__ */ p.decorations.compute([A], (t) => {
|
|
1935
|
+
let { selected: e, panel: r } = t.field(A);
|
|
1936
|
+
return !e || !r || e.from == e.to ? y.none : y.set([
|
|
1937
|
+
hi.range(e.from, e.to)
|
|
1938
|
+
]);
|
|
1939
|
+
}),
|
|
1940
|
+
/* @__PURE__ */ nr(ui, { hideOn: ai }),
|
|
1941
|
+
xi
|
|
1942
|
+
];
|
|
1943
|
+
var vt = function(e) {
|
|
1944
|
+
e === void 0 && (e = {});
|
|
1945
|
+
var {
|
|
1946
|
+
crosshairCursor: r = !1
|
|
1947
|
+
} = e, n = [];
|
|
1948
|
+
e.closeBracketsKeymap !== !1 && (n = n.concat(or)), e.defaultKeymap !== !1 && (n = n.concat(To)), e.searchKeymap !== !1 && (n = n.concat(ri)), e.historyKeymap !== !1 && (n = n.concat(zr)), e.foldKeymap !== !1 && (n = n.concat(ir)), e.completionKeymap !== !1 && (n = n.concat(sr)), e.lintKeymap !== !1 && (n = n.concat(gi));
|
|
1949
|
+
var o = [];
|
|
1950
|
+
return e.lineNumbers !== !1 && o.push(lr()), e.highlightActiveLineGutter !== !1 && o.push(ar()), e.highlightSpecialChars !== !1 && o.push(cr()), e.history !== !1 && o.push(Or()), e.foldGutter !== !1 && o.push(hr()), e.drawSelection !== !1 && o.push(ur()), e.dropCursor !== !1 && o.push(fr()), e.allowMultipleSelections !== !1 && o.push(le.allowMultipleSelections.of(!0)), e.indentOnInput !== !1 && o.push(dr()), e.syntaxHighlighting !== !1 && o.push(Nt(br, {
|
|
1951
|
+
fallback: !0
|
|
1952
|
+
})), e.bracketMatching !== !1 && o.push(mr()), e.closeBrackets !== !1 && o.push(gr()), e.autocompletion !== !1 && o.push(pr()), e.rectangularSelection !== !1 && o.push(yr()), r !== !1 && o.push(xr()), e.highlightActiveLine !== !1 && o.push(kr()), e.highlightSelectionMatches !== !1 && o.push(No()), e.tabSize && typeof e.tabSize == "number" && o.push(Pt.of(" ".repeat(e.tabSize))), o.concat([qt.of(n.flat())]).filter(Boolean);
|
|
1953
|
+
};
|
|
1954
|
+
const bi = "#e5c07b", At = "#e06c75", Si = "#56b6c2", Ci = "#ffffff", ke = "#abb2bf", Ze = "#7d8799", vi = "#61afef", Ai = "#98c379", Mt = "#d19a66", Mi = "#c678dd", Li = "#21252b", Lt = "#2c313a", Dt = "#282c34", Ue = "#353a42", Di = "#3E4451", Bt = "#528bff", Bi = /* @__PURE__ */ p.theme({
|
|
1955
|
+
"&": {
|
|
1956
|
+
color: ke,
|
|
1957
|
+
backgroundColor: Dt
|
|
1958
|
+
},
|
|
1959
|
+
".cm-content": {
|
|
1960
|
+
caretColor: Bt
|
|
1961
|
+
},
|
|
1962
|
+
".cm-cursor, .cm-dropCursor": { borderLeftColor: Bt },
|
|
1963
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: Di },
|
|
1964
|
+
".cm-panels": { backgroundColor: Li, color: ke },
|
|
1965
|
+
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
|
|
1966
|
+
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
|
|
1967
|
+
".cm-searchMatch": {
|
|
1968
|
+
backgroundColor: "#72a1ff59",
|
|
1969
|
+
outline: "1px solid #457dff"
|
|
1970
|
+
},
|
|
1971
|
+
".cm-searchMatch.cm-searchMatch-selected": {
|
|
1972
|
+
backgroundColor: "#6199ff2f"
|
|
1973
|
+
},
|
|
1974
|
+
".cm-activeLine": { backgroundColor: "#6699ff0b" },
|
|
1975
|
+
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
|
|
1976
|
+
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
|
|
1977
|
+
backgroundColor: "#bad0f847"
|
|
1978
|
+
},
|
|
1979
|
+
".cm-gutters": {
|
|
1980
|
+
backgroundColor: Dt,
|
|
1981
|
+
color: Ze,
|
|
1982
|
+
border: "none"
|
|
1983
|
+
},
|
|
1984
|
+
".cm-activeLineGutter": {
|
|
1985
|
+
backgroundColor: Lt
|
|
1986
|
+
},
|
|
1987
|
+
".cm-foldPlaceholder": {
|
|
1988
|
+
backgroundColor: "transparent",
|
|
1989
|
+
border: "none",
|
|
1990
|
+
color: "#ddd"
|
|
1991
|
+
},
|
|
1992
|
+
".cm-tooltip": {
|
|
1993
|
+
border: "none",
|
|
1994
|
+
backgroundColor: Ue
|
|
1995
|
+
},
|
|
1996
|
+
".cm-tooltip .cm-tooltip-arrow:before": {
|
|
1997
|
+
borderTopColor: "transparent",
|
|
1998
|
+
borderBottomColor: "transparent"
|
|
1999
|
+
},
|
|
2000
|
+
".cm-tooltip .cm-tooltip-arrow:after": {
|
|
2001
|
+
borderTopColor: Ue,
|
|
2002
|
+
borderBottomColor: Ue
|
|
2003
|
+
},
|
|
2004
|
+
".cm-tooltip-autocomplete": {
|
|
2005
|
+
"& > ul > li[aria-selected]": {
|
|
2006
|
+
backgroundColor: Lt,
|
|
2007
|
+
color: ke
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}, { dark: !0 }), Ei = /* @__PURE__ */ Sr.define([
|
|
2011
|
+
{
|
|
2012
|
+
tag: f.keyword,
|
|
2013
|
+
color: Mi
|
|
2014
|
+
},
|
|
2015
|
+
{
|
|
2016
|
+
tag: [f.name, f.deleted, f.character, f.propertyName, f.macroName],
|
|
2017
|
+
color: At
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
tag: [/* @__PURE__ */ f.function(f.variableName), f.labelName],
|
|
2021
|
+
color: vi
|
|
2022
|
+
},
|
|
2023
|
+
{
|
|
2024
|
+
tag: [f.color, /* @__PURE__ */ f.constant(f.name), /* @__PURE__ */ f.standard(f.name)],
|
|
2025
|
+
color: Mt
|
|
2026
|
+
},
|
|
2027
|
+
{
|
|
2028
|
+
tag: [/* @__PURE__ */ f.definition(f.name), f.separator],
|
|
2029
|
+
color: ke
|
|
2030
|
+
},
|
|
2031
|
+
{
|
|
2032
|
+
tag: [f.typeName, f.className, f.number, f.changed, f.annotation, f.modifier, f.self, f.namespace],
|
|
2033
|
+
color: bi
|
|
2034
|
+
},
|
|
2035
|
+
{
|
|
2036
|
+
tag: [f.operator, f.operatorKeyword, f.url, f.escape, f.regexp, f.link, /* @__PURE__ */ f.special(f.string)],
|
|
2037
|
+
color: Si
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
tag: [f.meta, f.comment],
|
|
2041
|
+
color: Ze
|
|
2042
|
+
},
|
|
2043
|
+
{
|
|
2044
|
+
tag: f.strong,
|
|
2045
|
+
fontWeight: "bold"
|
|
2046
|
+
},
|
|
2047
|
+
{
|
|
2048
|
+
tag: f.emphasis,
|
|
2049
|
+
fontStyle: "italic"
|
|
2050
|
+
},
|
|
2051
|
+
{
|
|
2052
|
+
tag: f.strikethrough,
|
|
2053
|
+
textDecoration: "line-through"
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
tag: f.link,
|
|
2057
|
+
color: Ze,
|
|
2058
|
+
textDecoration: "underline"
|
|
2059
|
+
},
|
|
2060
|
+
{
|
|
2061
|
+
tag: f.heading,
|
|
2062
|
+
fontWeight: "bold",
|
|
2063
|
+
color: At
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
tag: [f.atom, f.bool, /* @__PURE__ */ f.special(f.variableName)],
|
|
2067
|
+
color: Mt
|
|
2068
|
+
},
|
|
2069
|
+
{
|
|
2070
|
+
tag: [f.processingInstruction, f.string, f.inserted],
|
|
2071
|
+
color: Ai
|
|
2072
|
+
},
|
|
2073
|
+
{
|
|
2074
|
+
tag: f.invalid,
|
|
2075
|
+
color: Ci
|
|
2076
|
+
}
|
|
2077
|
+
]), wi = [Bi, /* @__PURE__ */ Nt(Ei)];
|
|
2078
|
+
var Ri = p.theme({
|
|
2079
|
+
"&": {
|
|
2080
|
+
backgroundColor: "#fff"
|
|
2081
|
+
}
|
|
2082
|
+
}, {
|
|
2083
|
+
dark: !1
|
|
2084
|
+
}), Ti = function(e) {
|
|
2085
|
+
e === void 0 && (e = {});
|
|
2086
|
+
var {
|
|
2087
|
+
indentWithTab: r = !0,
|
|
2088
|
+
editable: n = !0,
|
|
2089
|
+
readOnly: o = !1,
|
|
2090
|
+
theme: i = "light",
|
|
2091
|
+
placeholder: s = "",
|
|
2092
|
+
basicSetup: l = !0
|
|
2093
|
+
} = e, a = [];
|
|
2094
|
+
switch (r && a.unshift(qt.of([Oo])), l && (typeof l == "boolean" ? a.unshift(vt()) : a.unshift(vt(l))), s && a.unshift(Cr(s)), i) {
|
|
2095
|
+
case "light":
|
|
2096
|
+
a.push(Ri);
|
|
2097
|
+
break;
|
|
2098
|
+
case "dark":
|
|
2099
|
+
a.push(wi);
|
|
2100
|
+
break;
|
|
2101
|
+
case "none":
|
|
2102
|
+
break;
|
|
2103
|
+
default:
|
|
2104
|
+
a.push(i);
|
|
2105
|
+
break;
|
|
2106
|
+
}
|
|
2107
|
+
return n === !1 && a.push(p.editable.of(!1)), o && a.push(le.readOnly.of(!0)), [...a];
|
|
2108
|
+
}, Oi = (t) => ({
|
|
2109
|
+
line: t.state.doc.lineAt(t.state.selection.main.from),
|
|
2110
|
+
lineCount: t.state.doc.lines,
|
|
2111
|
+
lineBreak: t.state.lineBreak,
|
|
2112
|
+
length: t.state.doc.length,
|
|
2113
|
+
readOnly: t.state.readOnly,
|
|
2114
|
+
tabSize: t.state.tabSize,
|
|
2115
|
+
selection: t.state.selection,
|
|
2116
|
+
selectionAsSingle: t.state.selection.asSingle().main,
|
|
2117
|
+
ranges: t.state.selection.ranges,
|
|
2118
|
+
selectionCode: t.state.sliceDoc(t.state.selection.main.from, t.state.selection.main.to),
|
|
2119
|
+
selections: t.state.selection.ranges.map((e) => t.state.sliceDoc(e.from, e.to)),
|
|
2120
|
+
selectedText: t.state.selection.ranges.some((e) => !e.empty)
|
|
2121
|
+
}), Et = Xe.define(), Ii = [];
|
|
2122
|
+
function Pi(t) {
|
|
2123
|
+
var {
|
|
2124
|
+
value: e,
|
|
2125
|
+
selection: r,
|
|
2126
|
+
onChange: n,
|
|
2127
|
+
onStatistics: o,
|
|
2128
|
+
onCreateEditor: i,
|
|
2129
|
+
onUpdate: s,
|
|
2130
|
+
extensions: l = Ii,
|
|
2131
|
+
autoFocus: a,
|
|
2132
|
+
theme: c = "light",
|
|
2133
|
+
height: h = null,
|
|
2134
|
+
minHeight: u = null,
|
|
2135
|
+
maxHeight: m = null,
|
|
2136
|
+
width: x = null,
|
|
2137
|
+
minWidth: S = null,
|
|
2138
|
+
maxWidth: B = null,
|
|
2139
|
+
placeholder: V = "",
|
|
2140
|
+
editable: z = !0,
|
|
2141
|
+
readOnly: q = !1,
|
|
2142
|
+
indentWithTab: U = !0,
|
|
2143
|
+
basicSetup: ue = !0,
|
|
2144
|
+
root: We,
|
|
2145
|
+
initialState: ne
|
|
2146
|
+
} = t, [$, fe] = xe(), [k, I] = xe(), [G, K] = xe(), Fe = p.theme({
|
|
2147
|
+
"&": {
|
|
2148
|
+
height: h,
|
|
2149
|
+
minHeight: u,
|
|
2150
|
+
maxHeight: m,
|
|
2151
|
+
width: x,
|
|
2152
|
+
minWidth: S,
|
|
2153
|
+
maxWidth: B
|
|
2154
|
+
},
|
|
2155
|
+
"& .cm-scroller": {
|
|
2156
|
+
height: "100% !important"
|
|
2157
|
+
}
|
|
2158
|
+
}), Ne = p.updateListener.of((E) => {
|
|
2159
|
+
if (E.docChanged && typeof n == "function" && // Fix echoing of the remote changes:
|
|
2160
|
+
// If transaction is market as remote we don't have to call `onChange` handler again
|
|
2161
|
+
!E.transactions.some((Nn) => Nn.annotation(Et))) {
|
|
2162
|
+
var oe = E.state.doc, de = oe.toString();
|
|
2163
|
+
n(de, E);
|
|
2164
|
+
}
|
|
2165
|
+
o && o(Oi(E));
|
|
2166
|
+
}), Fn = Ti({
|
|
2167
|
+
theme: c,
|
|
2168
|
+
editable: z,
|
|
2169
|
+
readOnly: q,
|
|
2170
|
+
placeholder: V,
|
|
2171
|
+
indentWithTab: U,
|
|
2172
|
+
basicSetup: ue
|
|
2173
|
+
}), re = [Ne, Fe, ...Fn];
|
|
2174
|
+
return s && typeof s == "function" && re.push(p.updateListener.of(s)), re = re.concat(l), W(() => {
|
|
2175
|
+
if ($ && !G) {
|
|
2176
|
+
var E = {
|
|
2177
|
+
doc: e,
|
|
2178
|
+
selection: r,
|
|
2179
|
+
extensions: re
|
|
2180
|
+
}, oe = ne ? le.fromJSON(ne.json, E, ne.fields) : le.create(E);
|
|
2181
|
+
if (K(oe), !k) {
|
|
2182
|
+
var de = new p({
|
|
2183
|
+
state: oe,
|
|
2184
|
+
parent: $,
|
|
2185
|
+
root: We
|
|
2186
|
+
});
|
|
2187
|
+
I(de), i && i(de, oe);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
return () => {
|
|
2191
|
+
k && (K(void 0), I(void 0));
|
|
2192
|
+
};
|
|
2193
|
+
}, [$, G]), W(() => fe(t.container), [t.container]), W(() => () => {
|
|
2194
|
+
k && (k.destroy(), I(void 0));
|
|
2195
|
+
}, [k]), W(() => {
|
|
2196
|
+
a && k && k.focus();
|
|
2197
|
+
}, [a, k]), W(() => {
|
|
2198
|
+
k && k.dispatch({
|
|
2199
|
+
effects: w.reconfigure.of(re)
|
|
2200
|
+
});
|
|
2201
|
+
}, [c, l, h, u, m, x, S, B, V, z, q, U, ue, n, s]), W(() => {
|
|
2202
|
+
if (e !== void 0) {
|
|
2203
|
+
var E = k ? k.state.doc.toString() : "";
|
|
2204
|
+
k && e !== E && k.dispatch({
|
|
2205
|
+
changes: {
|
|
2206
|
+
from: 0,
|
|
2207
|
+
to: E.length,
|
|
2208
|
+
insert: e || ""
|
|
2209
|
+
},
|
|
2210
|
+
annotations: [Et.of(!0)]
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
}, [e, k]), {
|
|
2214
|
+
state: G,
|
|
2215
|
+
setState: K,
|
|
2216
|
+
view: k,
|
|
2217
|
+
setView: I,
|
|
2218
|
+
container: $,
|
|
2219
|
+
setContainer: fe
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
var Wi = ["className", "value", "selection", "extensions", "onChange", "onStatistics", "onCreateEditor", "onUpdate", "autoFocus", "theme", "height", "minHeight", "maxHeight", "width", "minWidth", "maxWidth", "basicSetup", "placeholder", "indentWithTab", "editable", "readOnly", "root", "initialState"], Wn = /* @__PURE__ */ wt((t, e) => {
|
|
2223
|
+
var {
|
|
2224
|
+
className: r,
|
|
2225
|
+
value: n = "",
|
|
2226
|
+
selection: o,
|
|
2227
|
+
extensions: i = [],
|
|
2228
|
+
onChange: s,
|
|
2229
|
+
onStatistics: l,
|
|
2230
|
+
onCreateEditor: a,
|
|
2231
|
+
onUpdate: c,
|
|
2232
|
+
autoFocus: h,
|
|
2233
|
+
theme: u = "light",
|
|
2234
|
+
height: m,
|
|
2235
|
+
minHeight: x,
|
|
2236
|
+
maxHeight: S,
|
|
2237
|
+
width: B,
|
|
2238
|
+
minWidth: V,
|
|
2239
|
+
maxWidth: z,
|
|
2240
|
+
basicSetup: q,
|
|
2241
|
+
placeholder: U,
|
|
2242
|
+
indentWithTab: ue,
|
|
2243
|
+
editable: We,
|
|
2244
|
+
readOnly: ne,
|
|
2245
|
+
root: $,
|
|
2246
|
+
initialState: fe
|
|
2247
|
+
} = t, k = qn(t, Wi), I = Rt(null), {
|
|
2248
|
+
state: G,
|
|
2249
|
+
view: K,
|
|
2250
|
+
container: Fe
|
|
2251
|
+
} = Pi({
|
|
2252
|
+
container: I.current,
|
|
2253
|
+
root: $,
|
|
2254
|
+
value: n,
|
|
2255
|
+
autoFocus: h,
|
|
2256
|
+
theme: u,
|
|
2257
|
+
height: m,
|
|
2258
|
+
minHeight: x,
|
|
2259
|
+
maxHeight: S,
|
|
2260
|
+
width: B,
|
|
2261
|
+
minWidth: V,
|
|
2262
|
+
maxWidth: z,
|
|
2263
|
+
basicSetup: q,
|
|
2264
|
+
placeholder: U,
|
|
2265
|
+
indentWithTab: ue,
|
|
2266
|
+
editable: We,
|
|
2267
|
+
readOnly: ne,
|
|
2268
|
+
selection: o,
|
|
2269
|
+
onChange: s,
|
|
2270
|
+
onStatistics: l,
|
|
2271
|
+
onCreateEditor: a,
|
|
2272
|
+
onUpdate: c,
|
|
2273
|
+
extensions: i,
|
|
2274
|
+
initialState: fe
|
|
2275
|
+
});
|
|
2276
|
+
if (Hn(e, () => ({
|
|
2277
|
+
editor: I.current,
|
|
2278
|
+
state: G,
|
|
2279
|
+
view: K
|
|
2280
|
+
}), [I, Fe, G, K]), typeof n != "string")
|
|
2281
|
+
throw new Error("value must be typeof string but got " + typeof n);
|
|
2282
|
+
var Ne = typeof u == "string" ? "cm-theme-" + u : "cm-theme";
|
|
2283
|
+
return /* @__PURE__ */ P.jsx("div", Vn({
|
|
2284
|
+
ref: I,
|
|
2285
|
+
className: "" + Ne + (r ? " " + r : "")
|
|
2286
|
+
}, k));
|
|
2287
|
+
});
|
|
2288
|
+
Wn.displayName = "CodeMirror";
|
|
2289
|
+
const Fi = p.theme({
|
|
2290
|
+
"& .cm-scroller": {
|
|
2291
|
+
fontFamily: "Consolas, Liberation Mono, Menlo, Courier, monospace"
|
|
2292
|
+
},
|
|
2293
|
+
"& .cm-activeLine, & .cm-activeLineGutter": {
|
|
2294
|
+
backgroundColor: "transparent"
|
|
2295
|
+
}
|
|
2296
|
+
}), Hi = wt(function({
|
|
2297
|
+
title: e,
|
|
2298
|
+
value: r,
|
|
2299
|
+
height: n = "200px",
|
|
2300
|
+
error: o,
|
|
2301
|
+
hint: i,
|
|
2302
|
+
clearBg: s = !0,
|
|
2303
|
+
extensions: l,
|
|
2304
|
+
onChange: a,
|
|
2305
|
+
...c
|
|
2306
|
+
}, h) {
|
|
2307
|
+
const u = zn(), m = Rt(null), [x, S] = xe(100), [B, V] = Un.useState(null);
|
|
2308
|
+
W(() => {
|
|
2309
|
+
Promise.all(l).then(V);
|
|
2310
|
+
}, [l]), W(() => {
|
|
2311
|
+
const q = new ResizeObserver(([U]) => {
|
|
2312
|
+
S(U.contentRect.width);
|
|
2313
|
+
});
|
|
2314
|
+
return q.observe(m.current), () => q.disconnect();
|
|
2315
|
+
}, []);
|
|
2316
|
+
let z = $n(
|
|
2317
|
+
"peer order-2 w-full max-w-full overflow-hidden rounded-sm border",
|
|
2318
|
+
s ? "bg-transparent" : "bg-grey-75",
|
|
2319
|
+
o ? "border-red" : "border-grey-500 hover:border-grey-700 focus:border-grey-800",
|
|
2320
|
+
e && "mt-2",
|
|
2321
|
+
n === "full" && "h-full"
|
|
2322
|
+
);
|
|
2323
|
+
return /* @__PURE__ */ P.jsxs(P.Fragment, { children: [
|
|
2324
|
+
/* @__PURE__ */ P.jsx("div", { ref: m }),
|
|
2325
|
+
B && /* @__PURE__ */ P.jsxs("div", { className: n === "full" ? "h-full" : "", style: { width: x }, children: [
|
|
2326
|
+
/* @__PURE__ */ P.jsx(
|
|
2327
|
+
Wn,
|
|
2328
|
+
{
|
|
2329
|
+
ref: h,
|
|
2330
|
+
className: z,
|
|
2331
|
+
extensions: B,
|
|
2332
|
+
height: n === "full" ? "100%" : n,
|
|
2333
|
+
theme: Fi,
|
|
2334
|
+
value: r,
|
|
2335
|
+
onChange: a,
|
|
2336
|
+
...c
|
|
2337
|
+
}
|
|
2338
|
+
),
|
|
2339
|
+
e && /* @__PURE__ */ P.jsx(Gn, { className: "order-1 !text-grey-700 peer-focus:!text-black", htmlFor: u, useLabelTag: !0, children: e }),
|
|
2340
|
+
i && /* @__PURE__ */ P.jsx(Kn, { className: "order-3", color: o ? "red" : "", children: i })
|
|
2341
|
+
] })
|
|
2342
|
+
] });
|
|
2343
|
+
});
|
|
2344
|
+
export {
|
|
2345
|
+
Hi as default
|
|
2346
|
+
};
|
|
2347
|
+
//# sourceMappingURL=CodeEditorView-2b332315.mjs.map
|