@maketribe/ms-app 3.0.35 → 3.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dataview/material/material-group/MaterialGroupTree.js +1 -0
- package/dist/cjs/dataview/material/material-group/MaterialGroupTree.js.map +1 -1
- package/dist/cjs/dataview/member/MemberTable.js +2 -2
- package/dist/cjs/dataview/member/MemberTable.js.map +1 -1
- package/dist/cjs/dataview/menu/MenuTable.js +33 -0
- package/dist/cjs/dataview/menu/MenuTable.js.map +1 -1
- package/dist/cjs/layouts/components/header/tools.js +7 -2
- package/dist/cjs/layouts/components/header/tools.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/{@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e → @codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm}/node_modules/@codemirror/autocomplete/dist/index.js +77 -25
- package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +7 -1433
- package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1484 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1751 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +0 -1030
- package/dist/cjs/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/{@codemirror_lint@6.4.2 → @codemirror_lint@6.5.0}/node_modules/@codemirror/lint/dist/index.js +8 -7
- package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/{@codemirror_search@6.5.5 → @codemirror_search@6.5.6}/node_modules/@codemirror/search/dist/index.js +9 -9
- package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +0 -42
- package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3958 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +3 -2161
- package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10580 -0
- package/dist/cjs/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1668 -0
- package/dist/cjs/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js +7 -7
- package/dist/cjs/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +177 -0
- package/dist/cjs/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/dist/cjs/node_modules/.pnpm/vue-codemirror@6.1.1_codemirror@6.0.1_vue@3.3.4/node_modules/vue-codemirror/dist/vue-codemirror.esm.js +1 -1
- package/dist/esm/dataview/material/material-group/MaterialGroupTree.js +1 -0
- package/dist/esm/dataview/material/material-group/MaterialGroupTree.js.map +1 -1
- package/dist/esm/dataview/member/MemberTable.js +2 -2
- package/dist/esm/dataview/member/MemberTable.js.map +1 -1
- package/dist/esm/dataview/menu/MenuTable.js +34 -1
- package/dist/esm/dataview/menu/MenuTable.js.map +1 -1
- package/dist/esm/layouts/components/header/tools.js +7 -2
- package/dist/esm/layouts/components/header/tools.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/{@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e → @codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm}/node_modules/@codemirror/autocomplete/dist/index.js +77 -25
- package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.15.0_@codemirror_language@6.10.1_@codemirror_state@6.4.1_@codemirr_djjyqdn7bhwopzrz2h2s2bwhzm/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js +4 -1357
- package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.2/node_modules/@codemirror/commands/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js +1408 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_commands@6.3.3/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js +1715 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.10.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js +4 -1011
- package/dist/esm/node_modules/.pnpm/@codemirror_language@6.9.3/node_modules/@codemirror/language/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/{@codemirror_lint@6.4.2 → @codemirror_lint@6.5.0}/node_modules/@codemirror/lint/dist/index.js +8 -7
- package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.5.0/node_modules/@codemirror/lint/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/{@codemirror_search@6.5.5 → @codemirror_search@6.5.6}/node_modules/@codemirror/search/dist/index.js +9 -9
- package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.6/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js +1 -41
- package/dist/esm/node_modules/.pnpm/@codemirror_state@6.3.2/node_modules/@codemirror/state/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js +3930 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_state@6.4.1/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js +5 -2142
- package/dist/esm/node_modules/.pnpm/@codemirror_view@6.22.1/node_modules/@codemirror/view/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js +10548 -0
- package/dist/esm/node_modules/.pnpm/@codemirror_view@6.26.1/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js +1658 -0
- package/dist/esm/node_modules/.pnpm/@lezer_common@1.2.1/node_modules/@lezer/common/dist/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js +8 -8
- package/dist/esm/node_modules/.pnpm/{codemirror@6.0.1_@lezer_common@1.1.1 → codemirror@6.0.1_@lezer_common@1.2.1}/node_modules/codemirror/dist/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js +175 -0
- package/dist/esm/node_modules/.pnpm/style-mod@4.1.2/node_modules/style-mod/src/style-mod.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/vue-codemirror@6.1.1_codemirror@6.0.1_vue@3.3.4/node_modules/vue-codemirror/dist/vue-codemirror.esm.js +1 -1
- package/dist/style/components/classify-search.css +1 -1
- package/dist/style/components/index.css +1 -1
- package/dist/style/index.css +2 -2
- package/dist/style/layouts/default/header.css +1 -1
- package/dist/style/layouts/default/index.css +1 -1
- package/dist/style/layouts/index.css +1 -1
- package/dist/style/src/components/classify-search.scss +5 -2
- package/dist/style/src/layouts/default/header.scss +4 -0
- package/package.json +3 -3
- package/src/dataview/material/material-group/MaterialGroupTree.ts +1 -0
- package/src/dataview/member/MemberTable.tsx +2 -2
- package/src/dataview/menu/MenuTable.ts +34 -1
- package/src/layouts/components/header/tools.tsx +6 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
- package/dist/cjs/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_autocomplete@6.11.1_@codemirror_language@6.9.3_@codemirror_state@6.3.2_@codemirro_dop6xooh6ucho44vivbvrw3b2e/node_modules/@codemirror/autocomplete/dist/index.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_lint@6.4.2/node_modules/@codemirror/lint/dist/index.js.map +0 -1
- package/dist/esm/node_modules/.pnpm/@codemirror_search@6.5.5/node_modules/@codemirror/search/dist/index.js.map +0 -1
|
@@ -8001,14 +8001,6 @@ function getKeymap(state) {
|
|
|
8001
8001
|
Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));
|
|
8002
8002
|
return map;
|
|
8003
8003
|
}
|
|
8004
|
-
/**
|
|
8005
|
-
Run the key handlers registered for a given scope. The event
|
|
8006
|
-
object should be a `"keydown"` event. Returns true if any of the
|
|
8007
|
-
handlers handled it.
|
|
8008
|
-
*/
|
|
8009
|
-
function runScopeHandlers(view, event, scope) {
|
|
8010
|
-
return runHandlers(getKeymap(view.state), event, view, scope);
|
|
8011
|
-
}
|
|
8012
8004
|
let storedPrefix = null;
|
|
8013
8005
|
const PrefixTimeout = 4000;
|
|
8014
8006
|
function buildKeymap(bindings, platform = currentPlatform) {
|
|
@@ -8137,350 +8129,7 @@ function runHandlers(map, event, view, scope) {
|
|
|
8137
8129
|
return handled;
|
|
8138
8130
|
}
|
|
8139
8131
|
|
|
8140
|
-
/**
|
|
8141
|
-
Implementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates
|
|
8142
|
-
a rectangle at a given set of coordinates.
|
|
8143
|
-
*/
|
|
8144
|
-
class RectangleMarker {
|
|
8145
|
-
/**
|
|
8146
|
-
Create a marker with the given class and dimensions. If `width`
|
|
8147
|
-
is null, the DOM element will get no width style.
|
|
8148
|
-
*/
|
|
8149
|
-
constructor(className,
|
|
8150
|
-
/**
|
|
8151
|
-
The left position of the marker (in pixels, document-relative).
|
|
8152
|
-
*/
|
|
8153
|
-
left,
|
|
8154
|
-
/**
|
|
8155
|
-
The top position of the marker.
|
|
8156
|
-
*/
|
|
8157
|
-
top,
|
|
8158
|
-
/**
|
|
8159
|
-
The width of the marker, or null if it shouldn't get a width assigned.
|
|
8160
|
-
*/
|
|
8161
|
-
width,
|
|
8162
|
-
/**
|
|
8163
|
-
The height of the marker.
|
|
8164
|
-
*/
|
|
8165
|
-
height) {
|
|
8166
|
-
this.className = className;
|
|
8167
|
-
this.left = left;
|
|
8168
|
-
this.top = top;
|
|
8169
|
-
this.width = width;
|
|
8170
|
-
this.height = height;
|
|
8171
|
-
}
|
|
8172
|
-
draw() {
|
|
8173
|
-
let elt = document.createElement("div");
|
|
8174
|
-
elt.className = this.className;
|
|
8175
|
-
this.adjust(elt);
|
|
8176
|
-
return elt;
|
|
8177
|
-
}
|
|
8178
|
-
update(elt, prev) {
|
|
8179
|
-
if (prev.className != this.className)
|
|
8180
|
-
return false;
|
|
8181
|
-
this.adjust(elt);
|
|
8182
|
-
return true;
|
|
8183
|
-
}
|
|
8184
|
-
adjust(elt) {
|
|
8185
|
-
elt.style.left = this.left + "px";
|
|
8186
|
-
elt.style.top = this.top + "px";
|
|
8187
|
-
if (this.width != null)
|
|
8188
|
-
elt.style.width = this.width + "px";
|
|
8189
|
-
elt.style.height = this.height + "px";
|
|
8190
|
-
}
|
|
8191
|
-
eq(p) {
|
|
8192
|
-
return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&
|
|
8193
|
-
this.className == p.className;
|
|
8194
|
-
}
|
|
8195
|
-
/**
|
|
8196
|
-
Create a set of rectangles for the given selection range,
|
|
8197
|
-
assigning them theclass`className`. Will create a single
|
|
8198
|
-
rectangle for empty ranges, and a set of selection-style
|
|
8199
|
-
rectangles covering the range's content (in a bidi-aware
|
|
8200
|
-
way) for non-empty ones.
|
|
8201
|
-
*/
|
|
8202
|
-
static forRange(view, className, range) {
|
|
8203
|
-
if (range.empty) {
|
|
8204
|
-
let pos = view.coordsAtPos(range.head, range.assoc || 1);
|
|
8205
|
-
if (!pos)
|
|
8206
|
-
return [];
|
|
8207
|
-
let base = getBase(view);
|
|
8208
|
-
return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];
|
|
8209
|
-
}
|
|
8210
|
-
else {
|
|
8211
|
-
return rectanglesForRange(view, className, range);
|
|
8212
|
-
}
|
|
8213
|
-
}
|
|
8214
|
-
}
|
|
8215
|
-
function getBase(view) {
|
|
8216
|
-
let rect = view.scrollDOM.getBoundingClientRect();
|
|
8217
|
-
let left = view.textDirection == exports.Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;
|
|
8218
|
-
return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };
|
|
8219
|
-
}
|
|
8220
|
-
function wrappedLine(view, pos, inside) {
|
|
8221
|
-
let range = index.EditorSelection.cursor(pos);
|
|
8222
|
-
return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),
|
|
8223
|
-
to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),
|
|
8224
|
-
type: exports.BlockType.Text };
|
|
8225
|
-
}
|
|
8226
|
-
function rectanglesForRange(view, className, range) {
|
|
8227
|
-
if (range.to <= view.viewport.from || range.from >= view.viewport.to)
|
|
8228
|
-
return [];
|
|
8229
|
-
let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);
|
|
8230
|
-
let ltr = view.textDirection == exports.Direction.LTR;
|
|
8231
|
-
let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);
|
|
8232
|
-
let lineElt = content.querySelector(".cm-line"), lineStyle = lineElt && window.getComputedStyle(lineElt);
|
|
8233
|
-
let leftSide = contentRect.left +
|
|
8234
|
-
(lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);
|
|
8235
|
-
let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);
|
|
8236
|
-
let startBlock = blockAt(view, from), endBlock = blockAt(view, to);
|
|
8237
|
-
let visualStart = startBlock.type == exports.BlockType.Text ? startBlock : null;
|
|
8238
|
-
let visualEnd = endBlock.type == exports.BlockType.Text ? endBlock : null;
|
|
8239
|
-
if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))
|
|
8240
|
-
visualStart = wrappedLine(view, from, visualStart);
|
|
8241
|
-
if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))
|
|
8242
|
-
visualEnd = wrappedLine(view, to, visualEnd);
|
|
8243
|
-
if (visualStart && visualEnd && visualStart.from == visualEnd.from) {
|
|
8244
|
-
return pieces(drawForLine(range.from, range.to, visualStart));
|
|
8245
|
-
}
|
|
8246
|
-
else {
|
|
8247
|
-
let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);
|
|
8248
|
-
let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);
|
|
8249
|
-
let between = [];
|
|
8250
|
-
if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||
|
|
8251
|
-
startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)
|
|
8252
|
-
between.push(piece(leftSide, top.bottom, rightSide, bottom.top));
|
|
8253
|
-
else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == exports.BlockType.Text)
|
|
8254
|
-
top.bottom = bottom.top = (top.bottom + bottom.top) / 2;
|
|
8255
|
-
return pieces(top).concat(between).concat(pieces(bottom));
|
|
8256
|
-
}
|
|
8257
|
-
function piece(left, top, right, bottom) {
|
|
8258
|
-
return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);
|
|
8259
|
-
}
|
|
8260
|
-
function pieces({ top, bottom, horizontal }) {
|
|
8261
|
-
let pieces = [];
|
|
8262
|
-
for (let i = 0; i < horizontal.length; i += 2)
|
|
8263
|
-
pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));
|
|
8264
|
-
return pieces;
|
|
8265
|
-
}
|
|
8266
|
-
// Gets passed from/to in line-local positions
|
|
8267
|
-
function drawForLine(from, to, line) {
|
|
8268
|
-
let top = 1e9, bottom = -1e9, horizontal = [];
|
|
8269
|
-
function addSpan(from, fromOpen, to, toOpen, dir) {
|
|
8270
|
-
// Passing 2/-2 is a kludge to force the view to return
|
|
8271
|
-
// coordinates on the proper side of block widgets, since
|
|
8272
|
-
// normalizing the side there, though appropriate for most
|
|
8273
|
-
// coordsAtPos queries, would break selection drawing.
|
|
8274
|
-
let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));
|
|
8275
|
-
let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));
|
|
8276
|
-
if (!fromCoords || !toCoords)
|
|
8277
|
-
return;
|
|
8278
|
-
top = Math.min(fromCoords.top, toCoords.top, top);
|
|
8279
|
-
bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);
|
|
8280
|
-
if (dir == exports.Direction.LTR)
|
|
8281
|
-
horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);
|
|
8282
|
-
else
|
|
8283
|
-
horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);
|
|
8284
|
-
}
|
|
8285
|
-
let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;
|
|
8286
|
-
// Split the range by visible range and document line
|
|
8287
|
-
for (let r of view.visibleRanges)
|
|
8288
|
-
if (r.to > start && r.from < end) {
|
|
8289
|
-
for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {
|
|
8290
|
-
let docLine = view.state.doc.lineAt(pos);
|
|
8291
|
-
for (let span of view.bidiSpans(docLine)) {
|
|
8292
|
-
let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;
|
|
8293
|
-
if (spanFrom >= endPos)
|
|
8294
|
-
break;
|
|
8295
|
-
if (spanTo > pos)
|
|
8296
|
-
addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);
|
|
8297
|
-
}
|
|
8298
|
-
pos = docLine.to + 1;
|
|
8299
|
-
if (pos >= endPos)
|
|
8300
|
-
break;
|
|
8301
|
-
}
|
|
8302
|
-
}
|
|
8303
|
-
if (horizontal.length == 0)
|
|
8304
|
-
addSpan(start, from == null, end, to == null, view.textDirection);
|
|
8305
|
-
return { top, bottom, horizontal };
|
|
8306
|
-
}
|
|
8307
|
-
function drawForWidget(block, top) {
|
|
8308
|
-
let y = contentRect.top + (top ? block.top : block.bottom);
|
|
8309
|
-
return { top: y, bottom: y, horizontal: [] };
|
|
8310
|
-
}
|
|
8311
|
-
}
|
|
8312
|
-
function sameMarker(a, b) {
|
|
8313
|
-
return a.constructor == b.constructor && a.eq(b);
|
|
8314
|
-
}
|
|
8315
|
-
class LayerView {
|
|
8316
|
-
constructor(view, layer) {
|
|
8317
|
-
this.view = view;
|
|
8318
|
-
this.layer = layer;
|
|
8319
|
-
this.drawn = [];
|
|
8320
|
-
this.scaleX = 1;
|
|
8321
|
-
this.scaleY = 1;
|
|
8322
|
-
this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };
|
|
8323
|
-
this.dom = view.scrollDOM.appendChild(document.createElement("div"));
|
|
8324
|
-
this.dom.classList.add("cm-layer");
|
|
8325
|
-
if (layer.above)
|
|
8326
|
-
this.dom.classList.add("cm-layer-above");
|
|
8327
|
-
if (layer.class)
|
|
8328
|
-
this.dom.classList.add(layer.class);
|
|
8329
|
-
this.scale();
|
|
8330
|
-
this.dom.setAttribute("aria-hidden", "true");
|
|
8331
|
-
this.setOrder(view.state);
|
|
8332
|
-
view.requestMeasure(this.measureReq);
|
|
8333
|
-
if (layer.mount)
|
|
8334
|
-
layer.mount(this.dom, view);
|
|
8335
|
-
}
|
|
8336
|
-
update(update) {
|
|
8337
|
-
if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))
|
|
8338
|
-
this.setOrder(update.state);
|
|
8339
|
-
if (this.layer.update(update, this.dom) || update.geometryChanged) {
|
|
8340
|
-
this.scale();
|
|
8341
|
-
update.view.requestMeasure(this.measureReq);
|
|
8342
|
-
}
|
|
8343
|
-
}
|
|
8344
|
-
setOrder(state) {
|
|
8345
|
-
let pos = 0, order = state.facet(layerOrder);
|
|
8346
|
-
while (pos < order.length && order[pos] != this.layer)
|
|
8347
|
-
pos++;
|
|
8348
|
-
this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);
|
|
8349
|
-
}
|
|
8350
|
-
measure() {
|
|
8351
|
-
return this.layer.markers(this.view);
|
|
8352
|
-
}
|
|
8353
|
-
scale() {
|
|
8354
|
-
let { scaleX, scaleY } = this.view;
|
|
8355
|
-
if (scaleX != this.scaleX || scaleY != this.scaleY) {
|
|
8356
|
-
this.scaleX = scaleX;
|
|
8357
|
-
this.scaleY = scaleY;
|
|
8358
|
-
this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;
|
|
8359
|
-
}
|
|
8360
|
-
}
|
|
8361
|
-
draw(markers) {
|
|
8362
|
-
if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {
|
|
8363
|
-
let old = this.dom.firstChild, oldI = 0;
|
|
8364
|
-
for (let marker of markers) {
|
|
8365
|
-
if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&
|
|
8366
|
-
marker.update(old, this.drawn[oldI])) {
|
|
8367
|
-
old = old.nextSibling;
|
|
8368
|
-
oldI++;
|
|
8369
|
-
}
|
|
8370
|
-
else {
|
|
8371
|
-
this.dom.insertBefore(marker.draw(), old);
|
|
8372
|
-
}
|
|
8373
|
-
}
|
|
8374
|
-
while (old) {
|
|
8375
|
-
let next = old.nextSibling;
|
|
8376
|
-
old.remove();
|
|
8377
|
-
old = next;
|
|
8378
|
-
}
|
|
8379
|
-
this.drawn = markers;
|
|
8380
|
-
}
|
|
8381
|
-
}
|
|
8382
|
-
destroy() {
|
|
8383
|
-
if (this.layer.destroy)
|
|
8384
|
-
this.layer.destroy(this.dom, this.view);
|
|
8385
|
-
this.dom.remove();
|
|
8386
|
-
}
|
|
8387
|
-
}
|
|
8388
|
-
const layerOrder = /*@__PURE__*/index.Facet.define();
|
|
8389
|
-
/**
|
|
8390
|
-
Define a layer.
|
|
8391
|
-
*/
|
|
8392
|
-
function layer(config) {
|
|
8393
|
-
return [
|
|
8394
|
-
ViewPlugin.define(v => new LayerView(v, config)),
|
|
8395
|
-
layerOrder.of(config)
|
|
8396
|
-
];
|
|
8397
|
-
}
|
|
8398
|
-
|
|
8399
8132
|
const CanHidePrimary = !browser.ios; // FIXME test IE
|
|
8400
|
-
const selectionConfig = /*@__PURE__*/index.Facet.define({
|
|
8401
|
-
combine(configs) {
|
|
8402
|
-
return index.combineConfig(configs, {
|
|
8403
|
-
cursorBlinkRate: 1200,
|
|
8404
|
-
drawRangeCursor: true
|
|
8405
|
-
}, {
|
|
8406
|
-
cursorBlinkRate: (a, b) => Math.min(a, b),
|
|
8407
|
-
drawRangeCursor: (a, b) => a || b
|
|
8408
|
-
});
|
|
8409
|
-
}
|
|
8410
|
-
});
|
|
8411
|
-
/**
|
|
8412
|
-
Returns an extension that hides the browser's native selection and
|
|
8413
|
-
cursor, replacing the selection with a background behind the text
|
|
8414
|
-
(with the `cm-selectionBackground` class), and the
|
|
8415
|
-
cursors with elements overlaid over the code (using
|
|
8416
|
-
`cm-cursor-primary` and `cm-cursor-secondary`).
|
|
8417
|
-
|
|
8418
|
-
This allows the editor to display secondary selection ranges, and
|
|
8419
|
-
tends to produce a type of selection more in line with that users
|
|
8420
|
-
expect in a text editor (the native selection styling will often
|
|
8421
|
-
leave gaps between lines and won't fill the horizontal space after
|
|
8422
|
-
a line when the selection continues past it).
|
|
8423
|
-
|
|
8424
|
-
It does have a performance cost, in that it requires an extra DOM
|
|
8425
|
-
layout cycle for many updates (the selection is drawn based on DOM
|
|
8426
|
-
layout information that's only available after laying out the
|
|
8427
|
-
content).
|
|
8428
|
-
*/
|
|
8429
|
-
function drawSelection(config = {}) {
|
|
8430
|
-
return [
|
|
8431
|
-
selectionConfig.of(config),
|
|
8432
|
-
cursorLayer,
|
|
8433
|
-
selectionLayer,
|
|
8434
|
-
hideNativeSelection,
|
|
8435
|
-
nativeSelectionHidden.of(true)
|
|
8436
|
-
];
|
|
8437
|
-
}
|
|
8438
|
-
function configChanged(update) {
|
|
8439
|
-
return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
|
|
8440
|
-
}
|
|
8441
|
-
const cursorLayer = /*@__PURE__*/layer({
|
|
8442
|
-
above: true,
|
|
8443
|
-
markers(view) {
|
|
8444
|
-
let { state } = view, conf = state.facet(selectionConfig);
|
|
8445
|
-
let cursors = [];
|
|
8446
|
-
for (let r of state.selection.ranges) {
|
|
8447
|
-
let prim = r == state.selection.main;
|
|
8448
|
-
if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {
|
|
8449
|
-
let className = prim ? "cm-cursor cm-cursor-primary" : "cm-cursor cm-cursor-secondary";
|
|
8450
|
-
let cursor = r.empty ? r : index.EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);
|
|
8451
|
-
for (let piece of RectangleMarker.forRange(view, className, cursor))
|
|
8452
|
-
cursors.push(piece);
|
|
8453
|
-
}
|
|
8454
|
-
}
|
|
8455
|
-
return cursors;
|
|
8456
|
-
},
|
|
8457
|
-
update(update, dom) {
|
|
8458
|
-
if (update.transactions.some(tr => tr.selection))
|
|
8459
|
-
dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
|
|
8460
|
-
let confChange = configChanged(update);
|
|
8461
|
-
if (confChange)
|
|
8462
|
-
setBlinkRate(update.state, dom);
|
|
8463
|
-
return update.docChanged || update.selectionSet || confChange;
|
|
8464
|
-
},
|
|
8465
|
-
mount(dom, view) {
|
|
8466
|
-
setBlinkRate(view.state, dom);
|
|
8467
|
-
},
|
|
8468
|
-
class: "cm-cursorLayer"
|
|
8469
|
-
});
|
|
8470
|
-
function setBlinkRate(state, dom) {
|
|
8471
|
-
dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + "ms";
|
|
8472
|
-
}
|
|
8473
|
-
const selectionLayer = /*@__PURE__*/layer({
|
|
8474
|
-
above: false,
|
|
8475
|
-
markers(view) {
|
|
8476
|
-
return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, "cm-selectionBackground", r))
|
|
8477
|
-
.reduce((a, b) => a.concat(b));
|
|
8478
|
-
},
|
|
8479
|
-
update(update, dom) {
|
|
8480
|
-
return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);
|
|
8481
|
-
},
|
|
8482
|
-
class: "cm-selectionLayer"
|
|
8483
|
-
});
|
|
8484
8133
|
const themeSpec = {
|
|
8485
8134
|
".cm-line": {
|
|
8486
8135
|
"& ::selection": { backgroundColor: "transparent !important" },
|
|
@@ -8491,406 +8140,6 @@ if (CanHidePrimary) {
|
|
|
8491
8140
|
themeSpec[".cm-line"].caretColor = "transparent !important";
|
|
8492
8141
|
themeSpec[".cm-content"] = { caretColor: "transparent !important" };
|
|
8493
8142
|
}
|
|
8494
|
-
const hideNativeSelection = /*@__PURE__*/index.Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));
|
|
8495
|
-
|
|
8496
|
-
const setDropCursorPos = /*@__PURE__*/index.StateEffect.define({
|
|
8497
|
-
map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }
|
|
8498
|
-
});
|
|
8499
|
-
const dropCursorPos = /*@__PURE__*/index.StateField.define({
|
|
8500
|
-
create() { return null; },
|
|
8501
|
-
update(pos, tr) {
|
|
8502
|
-
if (pos != null)
|
|
8503
|
-
pos = tr.changes.mapPos(pos);
|
|
8504
|
-
return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);
|
|
8505
|
-
}
|
|
8506
|
-
});
|
|
8507
|
-
const drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
8508
|
-
constructor(view) {
|
|
8509
|
-
this.view = view;
|
|
8510
|
-
this.cursor = null;
|
|
8511
|
-
this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };
|
|
8512
|
-
}
|
|
8513
|
-
update(update) {
|
|
8514
|
-
var _a;
|
|
8515
|
-
let cursorPos = update.state.field(dropCursorPos);
|
|
8516
|
-
if (cursorPos == null) {
|
|
8517
|
-
if (this.cursor != null) {
|
|
8518
|
-
(_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
8519
|
-
this.cursor = null;
|
|
8520
|
-
}
|
|
8521
|
-
}
|
|
8522
|
-
else {
|
|
8523
|
-
if (!this.cursor) {
|
|
8524
|
-
this.cursor = this.view.scrollDOM.appendChild(document.createElement("div"));
|
|
8525
|
-
this.cursor.className = "cm-dropCursor";
|
|
8526
|
-
}
|
|
8527
|
-
if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)
|
|
8528
|
-
this.view.requestMeasure(this.measureReq);
|
|
8529
|
-
}
|
|
8530
|
-
}
|
|
8531
|
-
readPos() {
|
|
8532
|
-
let { view } = this;
|
|
8533
|
-
let pos = view.state.field(dropCursorPos);
|
|
8534
|
-
let rect = pos != null && view.coordsAtPos(pos);
|
|
8535
|
-
if (!rect)
|
|
8536
|
-
return null;
|
|
8537
|
-
let outer = view.scrollDOM.getBoundingClientRect();
|
|
8538
|
-
return {
|
|
8539
|
-
left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,
|
|
8540
|
-
top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,
|
|
8541
|
-
height: rect.bottom - rect.top
|
|
8542
|
-
};
|
|
8543
|
-
}
|
|
8544
|
-
drawCursor(pos) {
|
|
8545
|
-
if (this.cursor) {
|
|
8546
|
-
let { scaleX, scaleY } = this.view;
|
|
8547
|
-
if (pos) {
|
|
8548
|
-
this.cursor.style.left = pos.left / scaleX + "px";
|
|
8549
|
-
this.cursor.style.top = pos.top / scaleY + "px";
|
|
8550
|
-
this.cursor.style.height = pos.height / scaleY + "px";
|
|
8551
|
-
}
|
|
8552
|
-
else {
|
|
8553
|
-
this.cursor.style.left = "-100000px";
|
|
8554
|
-
}
|
|
8555
|
-
}
|
|
8556
|
-
}
|
|
8557
|
-
destroy() {
|
|
8558
|
-
if (this.cursor)
|
|
8559
|
-
this.cursor.remove();
|
|
8560
|
-
}
|
|
8561
|
-
setDropPos(pos) {
|
|
8562
|
-
if (this.view.state.field(dropCursorPos) != pos)
|
|
8563
|
-
this.view.dispatch({ effects: setDropCursorPos.of(pos) });
|
|
8564
|
-
}
|
|
8565
|
-
}, {
|
|
8566
|
-
eventObservers: {
|
|
8567
|
-
dragover(event) {
|
|
8568
|
-
this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));
|
|
8569
|
-
},
|
|
8570
|
-
dragleave(event) {
|
|
8571
|
-
if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))
|
|
8572
|
-
this.setDropPos(null);
|
|
8573
|
-
},
|
|
8574
|
-
dragend() {
|
|
8575
|
-
this.setDropPos(null);
|
|
8576
|
-
},
|
|
8577
|
-
drop() {
|
|
8578
|
-
this.setDropPos(null);
|
|
8579
|
-
}
|
|
8580
|
-
}
|
|
8581
|
-
});
|
|
8582
|
-
/**
|
|
8583
|
-
Draws a cursor at the current drop position when something is
|
|
8584
|
-
dragged over the editor.
|
|
8585
|
-
*/
|
|
8586
|
-
function dropCursor() {
|
|
8587
|
-
return [dropCursorPos, drawDropCursor];
|
|
8588
|
-
}
|
|
8589
|
-
|
|
8590
|
-
function iterMatches(doc, re, from, to, f) {
|
|
8591
|
-
re.lastIndex = 0;
|
|
8592
|
-
for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {
|
|
8593
|
-
if (!cursor.lineBreak)
|
|
8594
|
-
while (m = re.exec(cursor.value))
|
|
8595
|
-
f(pos + m.index, m);
|
|
8596
|
-
}
|
|
8597
|
-
}
|
|
8598
|
-
function matchRanges(view, maxLength) {
|
|
8599
|
-
let visible = view.visibleRanges;
|
|
8600
|
-
if (visible.length == 1 && visible[0].from == view.viewport.from &&
|
|
8601
|
-
visible[0].to == view.viewport.to)
|
|
8602
|
-
return visible;
|
|
8603
|
-
let result = [];
|
|
8604
|
-
for (let { from, to } of visible) {
|
|
8605
|
-
from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);
|
|
8606
|
-
to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);
|
|
8607
|
-
if (result.length && result[result.length - 1].to >= from)
|
|
8608
|
-
result[result.length - 1].to = to;
|
|
8609
|
-
else
|
|
8610
|
-
result.push({ from, to });
|
|
8611
|
-
}
|
|
8612
|
-
return result;
|
|
8613
|
-
}
|
|
8614
|
-
/**
|
|
8615
|
-
Helper class used to make it easier to maintain decorations on
|
|
8616
|
-
visible code that matches a given regular expression. To be used
|
|
8617
|
-
in a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object
|
|
8618
|
-
represent a matching configuration.
|
|
8619
|
-
*/
|
|
8620
|
-
class MatchDecorator {
|
|
8621
|
-
/**
|
|
8622
|
-
Create a decorator.
|
|
8623
|
-
*/
|
|
8624
|
-
constructor(config) {
|
|
8625
|
-
const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;
|
|
8626
|
-
if (!regexp.global)
|
|
8627
|
-
throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
|
|
8628
|
-
this.regexp = regexp;
|
|
8629
|
-
if (decorate) {
|
|
8630
|
-
this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);
|
|
8631
|
-
}
|
|
8632
|
-
else if (typeof decoration == "function") {
|
|
8633
|
-
this.addMatch = (match, view, from, add) => {
|
|
8634
|
-
let deco = decoration(match, view, from);
|
|
8635
|
-
if (deco)
|
|
8636
|
-
add(from, from + match[0].length, deco);
|
|
8637
|
-
};
|
|
8638
|
-
}
|
|
8639
|
-
else if (decoration) {
|
|
8640
|
-
this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);
|
|
8641
|
-
}
|
|
8642
|
-
else {
|
|
8643
|
-
throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
|
|
8644
|
-
}
|
|
8645
|
-
this.boundary = boundary;
|
|
8646
|
-
this.maxLength = maxLength;
|
|
8647
|
-
}
|
|
8648
|
-
/**
|
|
8649
|
-
Compute the full set of decorations for matches in the given
|
|
8650
|
-
view's viewport. You'll want to call this when initializing your
|
|
8651
|
-
plugin.
|
|
8652
|
-
*/
|
|
8653
|
-
createDeco(view) {
|
|
8654
|
-
let build = new index.RangeSetBuilder(), add = build.add.bind(build);
|
|
8655
|
-
for (let { from, to } of matchRanges(view, this.maxLength))
|
|
8656
|
-
iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));
|
|
8657
|
-
return build.finish();
|
|
8658
|
-
}
|
|
8659
|
-
/**
|
|
8660
|
-
Update a set of decorations for a view update. `deco` _must_ be
|
|
8661
|
-
the set of decorations produced by _this_ `MatchDecorator` for
|
|
8662
|
-
the view state before the update.
|
|
8663
|
-
*/
|
|
8664
|
-
updateDeco(update, deco) {
|
|
8665
|
-
let changeFrom = 1e9, changeTo = -1;
|
|
8666
|
-
if (update.docChanged)
|
|
8667
|
-
update.changes.iterChanges((_f, _t, from, to) => {
|
|
8668
|
-
if (to > update.view.viewport.from && from < update.view.viewport.to) {
|
|
8669
|
-
changeFrom = Math.min(from, changeFrom);
|
|
8670
|
-
changeTo = Math.max(to, changeTo);
|
|
8671
|
-
}
|
|
8672
|
-
});
|
|
8673
|
-
if (update.viewportChanged || changeTo - changeFrom > 1000)
|
|
8674
|
-
return this.createDeco(update.view);
|
|
8675
|
-
if (changeTo > -1)
|
|
8676
|
-
return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);
|
|
8677
|
-
return deco;
|
|
8678
|
-
}
|
|
8679
|
-
updateRange(view, deco, updateFrom, updateTo) {
|
|
8680
|
-
for (let r of view.visibleRanges) {
|
|
8681
|
-
let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);
|
|
8682
|
-
if (to > from) {
|
|
8683
|
-
let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;
|
|
8684
|
-
let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);
|
|
8685
|
-
if (this.boundary) {
|
|
8686
|
-
for (; from > fromLine.from; from--)
|
|
8687
|
-
if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {
|
|
8688
|
-
start = from;
|
|
8689
|
-
break;
|
|
8690
|
-
}
|
|
8691
|
-
for (; to < toLine.to; to++)
|
|
8692
|
-
if (this.boundary.test(toLine.text[to - toLine.from])) {
|
|
8693
|
-
end = to;
|
|
8694
|
-
break;
|
|
8695
|
-
}
|
|
8696
|
-
}
|
|
8697
|
-
let ranges = [], m;
|
|
8698
|
-
let add = (from, to, deco) => ranges.push(deco.range(from, to));
|
|
8699
|
-
if (fromLine == toLine) {
|
|
8700
|
-
this.regexp.lastIndex = start - fromLine.from;
|
|
8701
|
-
while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)
|
|
8702
|
-
this.addMatch(m, view, m.index + fromLine.from, add);
|
|
8703
|
-
}
|
|
8704
|
-
else {
|
|
8705
|
-
iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));
|
|
8706
|
-
}
|
|
8707
|
-
deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });
|
|
8708
|
-
}
|
|
8709
|
-
}
|
|
8710
|
-
return deco;
|
|
8711
|
-
}
|
|
8712
|
-
}
|
|
8713
|
-
|
|
8714
|
-
const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
|
|
8715
|
-
const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
|
|
8716
|
-
const Names = {
|
|
8717
|
-
0: "null",
|
|
8718
|
-
7: "bell",
|
|
8719
|
-
8: "backspace",
|
|
8720
|
-
10: "newline",
|
|
8721
|
-
11: "vertical tab",
|
|
8722
|
-
13: "carriage return",
|
|
8723
|
-
27: "escape",
|
|
8724
|
-
8203: "zero width space",
|
|
8725
|
-
8204: "zero width non-joiner",
|
|
8726
|
-
8205: "zero width joiner",
|
|
8727
|
-
8206: "left-to-right mark",
|
|
8728
|
-
8207: "right-to-left mark",
|
|
8729
|
-
8232: "line separator",
|
|
8730
|
-
8237: "left-to-right override",
|
|
8731
|
-
8238: "right-to-left override",
|
|
8732
|
-
8294: "left-to-right isolate",
|
|
8733
|
-
8295: "right-to-left isolate",
|
|
8734
|
-
8297: "pop directional isolate",
|
|
8735
|
-
8233: "paragraph separator",
|
|
8736
|
-
65279: "zero width no-break space",
|
|
8737
|
-
65532: "object replacement"
|
|
8738
|
-
};
|
|
8739
|
-
let _supportsTabSize = null;
|
|
8740
|
-
function supportsTabSize() {
|
|
8741
|
-
var _a;
|
|
8742
|
-
if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
|
|
8743
|
-
let styles = document.body.style;
|
|
8744
|
-
_supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
|
|
8745
|
-
}
|
|
8746
|
-
return _supportsTabSize || false;
|
|
8747
|
-
}
|
|
8748
|
-
const specialCharConfig = /*@__PURE__*/index.Facet.define({
|
|
8749
|
-
combine(configs) {
|
|
8750
|
-
let config = index.combineConfig(configs, {
|
|
8751
|
-
render: null,
|
|
8752
|
-
specialChars: Specials,
|
|
8753
|
-
addSpecialChars: null
|
|
8754
|
-
});
|
|
8755
|
-
if (config.replaceTabs = !supportsTabSize())
|
|
8756
|
-
config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
|
|
8757
|
-
if (config.addSpecialChars)
|
|
8758
|
-
config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
|
|
8759
|
-
return config;
|
|
8760
|
-
}
|
|
8761
|
-
});
|
|
8762
|
-
/**
|
|
8763
|
-
Returns an extension that installs highlighting of special
|
|
8764
|
-
characters.
|
|
8765
|
-
*/
|
|
8766
|
-
function highlightSpecialChars(
|
|
8767
|
-
/**
|
|
8768
|
-
Configuration options.
|
|
8769
|
-
*/
|
|
8770
|
-
config = {}) {
|
|
8771
|
-
return [specialCharConfig.of(config), specialCharPlugin()];
|
|
8772
|
-
}
|
|
8773
|
-
let _plugin = null;
|
|
8774
|
-
function specialCharPlugin() {
|
|
8775
|
-
return _plugin || (_plugin = ViewPlugin.fromClass(class {
|
|
8776
|
-
constructor(view) {
|
|
8777
|
-
this.view = view;
|
|
8778
|
-
this.decorations = Decoration.none;
|
|
8779
|
-
this.decorationCache = Object.create(null);
|
|
8780
|
-
this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
|
|
8781
|
-
this.decorations = this.decorator.createDeco(view);
|
|
8782
|
-
}
|
|
8783
|
-
makeDecorator(conf) {
|
|
8784
|
-
return new MatchDecorator({
|
|
8785
|
-
regexp: conf.specialChars,
|
|
8786
|
-
decoration: (m, view, pos) => {
|
|
8787
|
-
let { doc } = view.state;
|
|
8788
|
-
let code = index.codePointAt(m[0], 0);
|
|
8789
|
-
if (code == 9) {
|
|
8790
|
-
let line = doc.lineAt(pos);
|
|
8791
|
-
let size = view.state.tabSize, col = index.countColumn(line.text, size, pos - line.from);
|
|
8792
|
-
return Decoration.replace({
|
|
8793
|
-
widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)
|
|
8794
|
-
});
|
|
8795
|
-
}
|
|
8796
|
-
return this.decorationCache[code] ||
|
|
8797
|
-
(this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));
|
|
8798
|
-
},
|
|
8799
|
-
boundary: conf.replaceTabs ? undefined : /[^]/
|
|
8800
|
-
});
|
|
8801
|
-
}
|
|
8802
|
-
update(update) {
|
|
8803
|
-
let conf = update.state.facet(specialCharConfig);
|
|
8804
|
-
if (update.startState.facet(specialCharConfig) != conf) {
|
|
8805
|
-
this.decorator = this.makeDecorator(conf);
|
|
8806
|
-
this.decorations = this.decorator.createDeco(update.view);
|
|
8807
|
-
}
|
|
8808
|
-
else {
|
|
8809
|
-
this.decorations = this.decorator.updateDeco(update, this.decorations);
|
|
8810
|
-
}
|
|
8811
|
-
}
|
|
8812
|
-
}, {
|
|
8813
|
-
decorations: v => v.decorations
|
|
8814
|
-
}));
|
|
8815
|
-
}
|
|
8816
|
-
const DefaultPlaceholder = "\u2022";
|
|
8817
|
-
// Assigns placeholder characters from the Control Pictures block to
|
|
8818
|
-
// ASCII control characters
|
|
8819
|
-
function placeholder$1(code) {
|
|
8820
|
-
if (code >= 32)
|
|
8821
|
-
return DefaultPlaceholder;
|
|
8822
|
-
if (code == 10)
|
|
8823
|
-
return "\u2424";
|
|
8824
|
-
return String.fromCharCode(9216 + code);
|
|
8825
|
-
}
|
|
8826
|
-
class SpecialCharWidget extends WidgetType {
|
|
8827
|
-
constructor(options, code) {
|
|
8828
|
-
super();
|
|
8829
|
-
this.options = options;
|
|
8830
|
-
this.code = code;
|
|
8831
|
-
}
|
|
8832
|
-
eq(other) { return other.code == this.code; }
|
|
8833
|
-
toDOM(view) {
|
|
8834
|
-
let ph = placeholder$1(this.code);
|
|
8835
|
-
let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
|
|
8836
|
-
let custom = this.options.render && this.options.render(this.code, desc, ph);
|
|
8837
|
-
if (custom)
|
|
8838
|
-
return custom;
|
|
8839
|
-
let span = document.createElement("span");
|
|
8840
|
-
span.textContent = ph;
|
|
8841
|
-
span.title = desc;
|
|
8842
|
-
span.setAttribute("aria-label", desc);
|
|
8843
|
-
span.className = "cm-specialChar";
|
|
8844
|
-
return span;
|
|
8845
|
-
}
|
|
8846
|
-
ignoreEvent() { return false; }
|
|
8847
|
-
}
|
|
8848
|
-
class TabWidget extends WidgetType {
|
|
8849
|
-
constructor(width) {
|
|
8850
|
-
super();
|
|
8851
|
-
this.width = width;
|
|
8852
|
-
}
|
|
8853
|
-
eq(other) { return other.width == this.width; }
|
|
8854
|
-
toDOM() {
|
|
8855
|
-
let span = document.createElement("span");
|
|
8856
|
-
span.textContent = "\t";
|
|
8857
|
-
span.className = "cm-tab";
|
|
8858
|
-
span.style.width = this.width + "px";
|
|
8859
|
-
return span;
|
|
8860
|
-
}
|
|
8861
|
-
ignoreEvent() { return false; }
|
|
8862
|
-
}
|
|
8863
|
-
|
|
8864
|
-
/**
|
|
8865
|
-
Mark lines that have a cursor on them with the `"cm-activeLine"`
|
|
8866
|
-
DOM class.
|
|
8867
|
-
*/
|
|
8868
|
-
function highlightActiveLine() {
|
|
8869
|
-
return activeLineHighlighter;
|
|
8870
|
-
}
|
|
8871
|
-
const lineDeco = /*@__PURE__*/Decoration.line({ class: "cm-activeLine" });
|
|
8872
|
-
const activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
8873
|
-
constructor(view) {
|
|
8874
|
-
this.decorations = this.getDeco(view);
|
|
8875
|
-
}
|
|
8876
|
-
update(update) {
|
|
8877
|
-
if (update.docChanged || update.selectionSet)
|
|
8878
|
-
this.decorations = this.getDeco(update.view);
|
|
8879
|
-
}
|
|
8880
|
-
getDeco(view) {
|
|
8881
|
-
let lastLineStart = -1, deco = [];
|
|
8882
|
-
for (let r of view.state.selection.ranges) {
|
|
8883
|
-
let line = view.lineBlockAt(r.head);
|
|
8884
|
-
if (line.from > lastLineStart) {
|
|
8885
|
-
deco.push(lineDeco.range(line.from));
|
|
8886
|
-
lastLineStart = line.from;
|
|
8887
|
-
}
|
|
8888
|
-
}
|
|
8889
|
-
return Decoration.set(deco);
|
|
8890
|
-
}
|
|
8891
|
-
}, {
|
|
8892
|
-
decorations: v => v.decorations
|
|
8893
|
-
});
|
|
8894
8143
|
|
|
8895
8144
|
class Placeholder extends WidgetType {
|
|
8896
8145
|
constructor(content) {
|
|
@@ -8937,955 +8186,10 @@ function placeholder(content) {
|
|
|
8937
8186
|
}, { decorations: v => v.decorations });
|
|
8938
8187
|
}
|
|
8939
8188
|
|
|
8940
|
-
// Don't compute precise column positions for line offsets above this
|
|
8941
|
-
// (since it could get expensive). Assume offset==column for them.
|
|
8942
|
-
const MaxOff = 2000;
|
|
8943
|
-
function rectangleFor(state, a, b) {
|
|
8944
|
-
let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);
|
|
8945
|
-
let ranges = [];
|
|
8946
|
-
if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {
|
|
8947
|
-
let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);
|
|
8948
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
8949
|
-
let line = state.doc.line(i);
|
|
8950
|
-
if (line.length <= endOff)
|
|
8951
|
-
ranges.push(index.EditorSelection.range(line.from + startOff, line.to + endOff));
|
|
8952
|
-
}
|
|
8953
|
-
}
|
|
8954
|
-
else {
|
|
8955
|
-
let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);
|
|
8956
|
-
for (let i = startLine; i <= endLine; i++) {
|
|
8957
|
-
let line = state.doc.line(i);
|
|
8958
|
-
let start = index.findColumn(line.text, startCol, state.tabSize, true);
|
|
8959
|
-
if (start < 0) {
|
|
8960
|
-
ranges.push(index.EditorSelection.cursor(line.to));
|
|
8961
|
-
}
|
|
8962
|
-
else {
|
|
8963
|
-
let end = index.findColumn(line.text, endCol, state.tabSize);
|
|
8964
|
-
ranges.push(index.EditorSelection.range(line.from + start, line.from + end));
|
|
8965
|
-
}
|
|
8966
|
-
}
|
|
8967
|
-
}
|
|
8968
|
-
return ranges;
|
|
8969
|
-
}
|
|
8970
|
-
function absoluteColumn(view, x) {
|
|
8971
|
-
let ref = view.coordsAtPos(view.viewport.from);
|
|
8972
|
-
return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;
|
|
8973
|
-
}
|
|
8974
|
-
function getPos(view, event) {
|
|
8975
|
-
let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);
|
|
8976
|
-
let line = view.state.doc.lineAt(offset), off = offset - line.from;
|
|
8977
|
-
let col = off > MaxOff ? -1
|
|
8978
|
-
: off == line.length ? absoluteColumn(view, event.clientX)
|
|
8979
|
-
: index.countColumn(line.text, view.state.tabSize, offset - line.from);
|
|
8980
|
-
return { line: line.number, col, off };
|
|
8981
|
-
}
|
|
8982
|
-
function rectangleSelectionStyle(view, event) {
|
|
8983
|
-
let start = getPos(view, event), startSel = view.state.selection;
|
|
8984
|
-
if (!start)
|
|
8985
|
-
return null;
|
|
8986
|
-
return {
|
|
8987
|
-
update(update) {
|
|
8988
|
-
if (update.docChanged) {
|
|
8989
|
-
let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);
|
|
8990
|
-
let newLine = update.state.doc.lineAt(newStart);
|
|
8991
|
-
start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };
|
|
8992
|
-
startSel = startSel.map(update.changes);
|
|
8993
|
-
}
|
|
8994
|
-
},
|
|
8995
|
-
get(event, _extend, multiple) {
|
|
8996
|
-
let cur = getPos(view, event);
|
|
8997
|
-
if (!cur)
|
|
8998
|
-
return startSel;
|
|
8999
|
-
let ranges = rectangleFor(view.state, start, cur);
|
|
9000
|
-
if (!ranges.length)
|
|
9001
|
-
return startSel;
|
|
9002
|
-
if (multiple)
|
|
9003
|
-
return index.EditorSelection.create(ranges.concat(startSel.ranges));
|
|
9004
|
-
else
|
|
9005
|
-
return index.EditorSelection.create(ranges);
|
|
9006
|
-
}
|
|
9007
|
-
};
|
|
9008
|
-
}
|
|
9009
|
-
/**
|
|
9010
|
-
Create an extension that enables rectangular selections. By
|
|
9011
|
-
default, it will react to left mouse drag with the Alt key held
|
|
9012
|
-
down. When such a selection occurs, the text within the rectangle
|
|
9013
|
-
that was dragged over will be selected, as one selection
|
|
9014
|
-
[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.
|
|
9015
|
-
*/
|
|
9016
|
-
function rectangularSelection(options) {
|
|
9017
|
-
let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);
|
|
9018
|
-
return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);
|
|
9019
|
-
}
|
|
9020
|
-
const keys = {
|
|
9021
|
-
Alt: [18, e => !!e.altKey],
|
|
9022
|
-
Control: [17, e => !!e.ctrlKey],
|
|
9023
|
-
Shift: [16, e => !!e.shiftKey],
|
|
9024
|
-
Meta: [91, e => !!e.metaKey]
|
|
9025
|
-
};
|
|
9026
|
-
const showCrosshair = { style: "cursor: crosshair" };
|
|
9027
8189
|
/**
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
going to happen when paired with
|
|
9032
|
-
[`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).
|
|
9033
|
-
*/
|
|
9034
|
-
function crosshairCursor(options = {}) {
|
|
9035
|
-
let [code, getter] = keys[options.key || "Alt"];
|
|
9036
|
-
let plugin = ViewPlugin.fromClass(class {
|
|
9037
|
-
constructor(view) {
|
|
9038
|
-
this.view = view;
|
|
9039
|
-
this.isDown = false;
|
|
9040
|
-
}
|
|
9041
|
-
set(isDown) {
|
|
9042
|
-
if (this.isDown != isDown) {
|
|
9043
|
-
this.isDown = isDown;
|
|
9044
|
-
this.view.update([]);
|
|
9045
|
-
}
|
|
9046
|
-
}
|
|
9047
|
-
}, {
|
|
9048
|
-
eventObservers: {
|
|
9049
|
-
keydown(e) {
|
|
9050
|
-
this.set(e.keyCode == code || getter(e));
|
|
9051
|
-
},
|
|
9052
|
-
keyup(e) {
|
|
9053
|
-
if (e.keyCode == code || !getter(e))
|
|
9054
|
-
this.set(false);
|
|
9055
|
-
},
|
|
9056
|
-
mousemove(e) {
|
|
9057
|
-
this.set(getter(e));
|
|
9058
|
-
}
|
|
9059
|
-
}
|
|
9060
|
-
});
|
|
9061
|
-
return [
|
|
9062
|
-
plugin,
|
|
9063
|
-
EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })
|
|
9064
|
-
];
|
|
9065
|
-
}
|
|
9066
|
-
|
|
9067
|
-
const Outside = "-10000px";
|
|
9068
|
-
class TooltipViewManager {
|
|
9069
|
-
constructor(view, facet, createTooltipView) {
|
|
9070
|
-
this.facet = facet;
|
|
9071
|
-
this.createTooltipView = createTooltipView;
|
|
9072
|
-
this.input = view.state.facet(facet);
|
|
9073
|
-
this.tooltips = this.input.filter(t => t);
|
|
9074
|
-
this.tooltipViews = this.tooltips.map(createTooltipView);
|
|
9075
|
-
}
|
|
9076
|
-
update(update, above) {
|
|
9077
|
-
var _a;
|
|
9078
|
-
let input = update.state.facet(this.facet);
|
|
9079
|
-
let tooltips = input.filter(x => x);
|
|
9080
|
-
if (input === this.input) {
|
|
9081
|
-
for (let t of this.tooltipViews)
|
|
9082
|
-
if (t.update)
|
|
9083
|
-
t.update(update);
|
|
9084
|
-
return false;
|
|
9085
|
-
}
|
|
9086
|
-
let tooltipViews = [], newAbove = above ? [] : null;
|
|
9087
|
-
for (let i = 0; i < tooltips.length; i++) {
|
|
9088
|
-
let tip = tooltips[i], known = -1;
|
|
9089
|
-
if (!tip)
|
|
9090
|
-
continue;
|
|
9091
|
-
for (let i = 0; i < this.tooltips.length; i++) {
|
|
9092
|
-
let other = this.tooltips[i];
|
|
9093
|
-
if (other && other.create == tip.create)
|
|
9094
|
-
known = i;
|
|
9095
|
-
}
|
|
9096
|
-
if (known < 0) {
|
|
9097
|
-
tooltipViews[i] = this.createTooltipView(tip);
|
|
9098
|
-
if (newAbove)
|
|
9099
|
-
newAbove[i] = !!tip.above;
|
|
9100
|
-
}
|
|
9101
|
-
else {
|
|
9102
|
-
let tooltipView = tooltipViews[i] = this.tooltipViews[known];
|
|
9103
|
-
if (newAbove)
|
|
9104
|
-
newAbove[i] = above[known];
|
|
9105
|
-
if (tooltipView.update)
|
|
9106
|
-
tooltipView.update(update);
|
|
9107
|
-
}
|
|
9108
|
-
}
|
|
9109
|
-
for (let t of this.tooltipViews)
|
|
9110
|
-
if (tooltipViews.indexOf(t) < 0) {
|
|
9111
|
-
t.dom.remove();
|
|
9112
|
-
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9113
|
-
}
|
|
9114
|
-
if (above) {
|
|
9115
|
-
newAbove.forEach((val, i) => above[i] = val);
|
|
9116
|
-
above.length = newAbove.length;
|
|
9117
|
-
}
|
|
9118
|
-
this.input = input;
|
|
9119
|
-
this.tooltips = tooltips;
|
|
9120
|
-
this.tooltipViews = tooltipViews;
|
|
9121
|
-
return true;
|
|
9122
|
-
}
|
|
9123
|
-
}
|
|
9124
|
-
function windowSpace(view) {
|
|
9125
|
-
let { win } = view;
|
|
9126
|
-
return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };
|
|
9127
|
-
}
|
|
9128
|
-
const tooltipConfig = /*@__PURE__*/index.Facet.define({
|
|
9129
|
-
combine: values => {
|
|
9130
|
-
var _a, _b, _c;
|
|
9131
|
-
return ({
|
|
9132
|
-
position: browser.ios ? "absolute" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || "fixed",
|
|
9133
|
-
parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,
|
|
9134
|
-
tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,
|
|
9135
|
-
});
|
|
9136
|
-
}
|
|
9137
|
-
});
|
|
9138
|
-
const knownHeight = /*@__PURE__*/new WeakMap();
|
|
9139
|
-
const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
9140
|
-
constructor(view) {
|
|
9141
|
-
this.view = view;
|
|
9142
|
-
this.above = [];
|
|
9143
|
-
this.inView = true;
|
|
9144
|
-
this.madeAbsolute = false;
|
|
9145
|
-
this.lastTransaction = 0;
|
|
9146
|
-
this.measureTimeout = -1;
|
|
9147
|
-
let config = view.state.facet(tooltipConfig);
|
|
9148
|
-
this.position = config.position;
|
|
9149
|
-
this.parent = config.parent;
|
|
9150
|
-
this.classes = view.themeClasses;
|
|
9151
|
-
this.createContainer();
|
|
9152
|
-
this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
|
|
9153
|
-
this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));
|
|
9154
|
-
this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
|
|
9155
|
-
if (Date.now() > this.lastTransaction - 50 &&
|
|
9156
|
-
entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
|
|
9157
|
-
this.measureSoon();
|
|
9158
|
-
}, { threshold: [1] }) : null;
|
|
9159
|
-
this.observeIntersection();
|
|
9160
|
-
view.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this));
|
|
9161
|
-
this.maybeMeasure();
|
|
9162
|
-
}
|
|
9163
|
-
createContainer() {
|
|
9164
|
-
if (this.parent) {
|
|
9165
|
-
this.container = document.createElement("div");
|
|
9166
|
-
this.container.style.position = "relative";
|
|
9167
|
-
this.container.className = this.view.themeClasses;
|
|
9168
|
-
this.parent.appendChild(this.container);
|
|
9169
|
-
}
|
|
9170
|
-
else {
|
|
9171
|
-
this.container = this.view.dom;
|
|
9172
|
-
}
|
|
9173
|
-
}
|
|
9174
|
-
observeIntersection() {
|
|
9175
|
-
if (this.intersectionObserver) {
|
|
9176
|
-
this.intersectionObserver.disconnect();
|
|
9177
|
-
for (let tooltip of this.manager.tooltipViews)
|
|
9178
|
-
this.intersectionObserver.observe(tooltip.dom);
|
|
9179
|
-
}
|
|
9180
|
-
}
|
|
9181
|
-
measureSoon() {
|
|
9182
|
-
if (this.measureTimeout < 0)
|
|
9183
|
-
this.measureTimeout = setTimeout(() => {
|
|
9184
|
-
this.measureTimeout = -1;
|
|
9185
|
-
this.maybeMeasure();
|
|
9186
|
-
}, 50);
|
|
9187
|
-
}
|
|
9188
|
-
update(update) {
|
|
9189
|
-
if (update.transactions.length)
|
|
9190
|
-
this.lastTransaction = Date.now();
|
|
9191
|
-
let updated = this.manager.update(update, this.above);
|
|
9192
|
-
if (updated)
|
|
9193
|
-
this.observeIntersection();
|
|
9194
|
-
let shouldMeasure = updated || update.geometryChanged;
|
|
9195
|
-
let newConfig = update.state.facet(tooltipConfig);
|
|
9196
|
-
if (newConfig.position != this.position && !this.madeAbsolute) {
|
|
9197
|
-
this.position = newConfig.position;
|
|
9198
|
-
for (let t of this.manager.tooltipViews)
|
|
9199
|
-
t.dom.style.position = this.position;
|
|
9200
|
-
shouldMeasure = true;
|
|
9201
|
-
}
|
|
9202
|
-
if (newConfig.parent != this.parent) {
|
|
9203
|
-
if (this.parent)
|
|
9204
|
-
this.container.remove();
|
|
9205
|
-
this.parent = newConfig.parent;
|
|
9206
|
-
this.createContainer();
|
|
9207
|
-
for (let t of this.manager.tooltipViews)
|
|
9208
|
-
this.container.appendChild(t.dom);
|
|
9209
|
-
shouldMeasure = true;
|
|
9210
|
-
}
|
|
9211
|
-
else if (this.parent && this.view.themeClasses != this.classes) {
|
|
9212
|
-
this.classes = this.container.className = this.view.themeClasses;
|
|
9213
|
-
}
|
|
9214
|
-
if (shouldMeasure)
|
|
9215
|
-
this.maybeMeasure();
|
|
9216
|
-
}
|
|
9217
|
-
createTooltip(tooltip) {
|
|
9218
|
-
let tooltipView = tooltip.create(this.view);
|
|
9219
|
-
tooltipView.dom.classList.add("cm-tooltip");
|
|
9220
|
-
if (tooltip.arrow && !tooltipView.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
|
|
9221
|
-
let arrow = document.createElement("div");
|
|
9222
|
-
arrow.className = "cm-tooltip-arrow";
|
|
9223
|
-
tooltipView.dom.appendChild(arrow);
|
|
9224
|
-
}
|
|
9225
|
-
tooltipView.dom.style.position = this.position;
|
|
9226
|
-
tooltipView.dom.style.top = Outside;
|
|
9227
|
-
tooltipView.dom.style.left = "0px";
|
|
9228
|
-
this.container.appendChild(tooltipView.dom);
|
|
9229
|
-
if (tooltipView.mount)
|
|
9230
|
-
tooltipView.mount(this.view);
|
|
9231
|
-
return tooltipView;
|
|
9232
|
-
}
|
|
9233
|
-
destroy() {
|
|
9234
|
-
var _a, _b;
|
|
9235
|
-
this.view.win.removeEventListener("resize", this.measureSoon);
|
|
9236
|
-
for (let tooltipView of this.manager.tooltipViews) {
|
|
9237
|
-
tooltipView.dom.remove();
|
|
9238
|
-
(_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);
|
|
9239
|
-
}
|
|
9240
|
-
if (this.parent)
|
|
9241
|
-
this.container.remove();
|
|
9242
|
-
(_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
9243
|
-
clearTimeout(this.measureTimeout);
|
|
9244
|
-
}
|
|
9245
|
-
readMeasure() {
|
|
9246
|
-
let editor = this.view.dom.getBoundingClientRect();
|
|
9247
|
-
let scaleX = 1, scaleY = 1, makeAbsolute = false;
|
|
9248
|
-
if (this.position == "fixed" && this.manager.tooltipViews.length) {
|
|
9249
|
-
let { dom } = this.manager.tooltipViews[0];
|
|
9250
|
-
if (browser.gecko) {
|
|
9251
|
-
// Firefox sets the element's `offsetParent` to the
|
|
9252
|
-
// transformed element when a transform interferes with fixed
|
|
9253
|
-
// positioning.
|
|
9254
|
-
makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
|
|
9255
|
-
}
|
|
9256
|
-
else {
|
|
9257
|
-
// On other browsers, we have to awkwardly try and use other
|
|
9258
|
-
// information to detect a transform.
|
|
9259
|
-
if (this.view.scaleX != 1 || this.view.scaleY != 1) {
|
|
9260
|
-
makeAbsolute = true;
|
|
9261
|
-
}
|
|
9262
|
-
else if (dom.style.top == Outside && dom.style.left == "0px") {
|
|
9263
|
-
let rect = dom.getBoundingClientRect();
|
|
9264
|
-
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
|
|
9265
|
-
}
|
|
9266
|
-
}
|
|
9267
|
-
}
|
|
9268
|
-
if (makeAbsolute || this.position == "absolute") {
|
|
9269
|
-
if (this.parent) {
|
|
9270
|
-
let rect = this.parent.getBoundingClientRect();
|
|
9271
|
-
if (rect.width && rect.height) {
|
|
9272
|
-
scaleX = rect.width / this.parent.offsetWidth;
|
|
9273
|
-
scaleY = rect.height / this.parent.offsetHeight;
|
|
9274
|
-
}
|
|
9275
|
-
}
|
|
9276
|
-
else {
|
|
9277
|
-
({ scaleX, scaleY } = this.view.viewState);
|
|
9278
|
-
}
|
|
9279
|
-
}
|
|
9280
|
-
return {
|
|
9281
|
-
editor,
|
|
9282
|
-
parent: this.parent ? this.container.getBoundingClientRect() : editor,
|
|
9283
|
-
pos: this.manager.tooltips.map((t, i) => {
|
|
9284
|
-
let tv = this.manager.tooltipViews[i];
|
|
9285
|
-
return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);
|
|
9286
|
-
}),
|
|
9287
|
-
size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),
|
|
9288
|
-
space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),
|
|
9289
|
-
scaleX, scaleY, makeAbsolute
|
|
9290
|
-
};
|
|
9291
|
-
}
|
|
9292
|
-
writeMeasure(measured) {
|
|
9293
|
-
var _a;
|
|
9294
|
-
if (measured.makeAbsolute) {
|
|
9295
|
-
this.madeAbsolute = true;
|
|
9296
|
-
this.position = "absolute";
|
|
9297
|
-
for (let t of this.manager.tooltipViews)
|
|
9298
|
-
t.dom.style.position = "absolute";
|
|
9299
|
-
}
|
|
9300
|
-
let { editor, space, scaleX, scaleY } = measured;
|
|
9301
|
-
let others = [];
|
|
9302
|
-
for (let i = 0; i < this.manager.tooltips.length; i++) {
|
|
9303
|
-
let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;
|
|
9304
|
-
let pos = measured.pos[i], size = measured.size[i];
|
|
9305
|
-
// Hide tooltips that are outside of the editor.
|
|
9306
|
-
if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||
|
|
9307
|
-
pos.top >= Math.min(editor.bottom, space.bottom) ||
|
|
9308
|
-
pos.right < Math.max(editor.left, space.left) - .1 ||
|
|
9309
|
-
pos.left > Math.min(editor.right, space.right) + .1) {
|
|
9310
|
-
dom.style.top = Outside;
|
|
9311
|
-
continue;
|
|
9312
|
-
}
|
|
9313
|
-
let arrow = tooltip.arrow ? tView.dom.querySelector(".cm-tooltip-arrow") : null;
|
|
9314
|
-
let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;
|
|
9315
|
-
let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;
|
|
9316
|
-
let offset = tView.offset || noOffset, ltr = this.view.textDirection == exports.Direction.LTR;
|
|
9317
|
-
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
9318
|
-
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
9319
|
-
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
9320
|
-
let above = this.above[i];
|
|
9321
|
-
if (!tooltip.strictSide && (above
|
|
9322
|
-
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
9323
|
-
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
|
|
9324
|
-
above == (space.bottom - pos.bottom > pos.top - space.top))
|
|
9325
|
-
above = this.above[i] = !above;
|
|
9326
|
-
let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
|
|
9327
|
-
if (spaceVert < height && tView.resize !== false) {
|
|
9328
|
-
if (spaceVert < this.view.defaultLineHeight) {
|
|
9329
|
-
dom.style.top = Outside;
|
|
9330
|
-
continue;
|
|
9331
|
-
}
|
|
9332
|
-
knownHeight.set(tView, height);
|
|
9333
|
-
dom.style.height = (height = spaceVert) / scaleY + "px";
|
|
9334
|
-
}
|
|
9335
|
-
else if (dom.style.height) {
|
|
9336
|
-
dom.style.height = "";
|
|
9337
|
-
}
|
|
9338
|
-
let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;
|
|
9339
|
-
let right = left + width;
|
|
9340
|
-
if (tView.overlap !== true)
|
|
9341
|
-
for (let r of others)
|
|
9342
|
-
if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)
|
|
9343
|
-
top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;
|
|
9344
|
-
if (this.position == "absolute") {
|
|
9345
|
-
dom.style.top = (top - measured.parent.top) / scaleY + "px";
|
|
9346
|
-
dom.style.left = (left - measured.parent.left) / scaleX + "px";
|
|
9347
|
-
}
|
|
9348
|
-
else {
|
|
9349
|
-
dom.style.top = top / scaleY + "px";
|
|
9350
|
-
dom.style.left = left / scaleX + "px";
|
|
9351
|
-
}
|
|
9352
|
-
if (arrow) {
|
|
9353
|
-
let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);
|
|
9354
|
-
arrow.style.left = arrowLeft / scaleX + "px";
|
|
9355
|
-
}
|
|
9356
|
-
if (tView.overlap !== true)
|
|
9357
|
-
others.push({ left, top, right, bottom: top + height });
|
|
9358
|
-
dom.classList.toggle("cm-tooltip-above", above);
|
|
9359
|
-
dom.classList.toggle("cm-tooltip-below", !above);
|
|
9360
|
-
if (tView.positioned)
|
|
9361
|
-
tView.positioned(measured.space);
|
|
9362
|
-
}
|
|
9363
|
-
}
|
|
9364
|
-
maybeMeasure() {
|
|
9365
|
-
if (this.manager.tooltips.length) {
|
|
9366
|
-
if (this.view.inView)
|
|
9367
|
-
this.view.requestMeasure(this.measureReq);
|
|
9368
|
-
if (this.inView != this.view.inView) {
|
|
9369
|
-
this.inView = this.view.inView;
|
|
9370
|
-
if (!this.inView)
|
|
9371
|
-
for (let tv of this.manager.tooltipViews)
|
|
9372
|
-
tv.dom.style.top = Outside;
|
|
9373
|
-
}
|
|
9374
|
-
}
|
|
9375
|
-
}
|
|
9376
|
-
}, {
|
|
9377
|
-
eventObservers: {
|
|
9378
|
-
scroll() { this.maybeMeasure(); }
|
|
9379
|
-
}
|
|
9380
|
-
});
|
|
9381
|
-
const baseTheme = /*@__PURE__*/EditorView.baseTheme({
|
|
9382
|
-
".cm-tooltip": {
|
|
9383
|
-
zIndex: 100,
|
|
9384
|
-
boxSizing: "border-box"
|
|
9385
|
-
},
|
|
9386
|
-
"&light .cm-tooltip": {
|
|
9387
|
-
border: "1px solid #bbb",
|
|
9388
|
-
backgroundColor: "#f5f5f5"
|
|
9389
|
-
},
|
|
9390
|
-
"&light .cm-tooltip-section:not(:first-child)": {
|
|
9391
|
-
borderTop: "1px solid #bbb",
|
|
9392
|
-
},
|
|
9393
|
-
"&dark .cm-tooltip": {
|
|
9394
|
-
backgroundColor: "#333338",
|
|
9395
|
-
color: "white"
|
|
9396
|
-
},
|
|
9397
|
-
".cm-tooltip-arrow": {
|
|
9398
|
-
height: `${7 /* Arrow.Size */}px`,
|
|
9399
|
-
width: `${7 /* Arrow.Size */ * 2}px`,
|
|
9400
|
-
position: "absolute",
|
|
9401
|
-
zIndex: -1,
|
|
9402
|
-
overflow: "hidden",
|
|
9403
|
-
"&:before, &:after": {
|
|
9404
|
-
content: "''",
|
|
9405
|
-
position: "absolute",
|
|
9406
|
-
width: 0,
|
|
9407
|
-
height: 0,
|
|
9408
|
-
borderLeft: `${7 /* Arrow.Size */}px solid transparent`,
|
|
9409
|
-
borderRight: `${7 /* Arrow.Size */}px solid transparent`,
|
|
9410
|
-
},
|
|
9411
|
-
".cm-tooltip-above &": {
|
|
9412
|
-
bottom: `-${7 /* Arrow.Size */}px`,
|
|
9413
|
-
"&:before": {
|
|
9414
|
-
borderTop: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
9415
|
-
},
|
|
9416
|
-
"&:after": {
|
|
9417
|
-
borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
9418
|
-
bottom: "1px"
|
|
9419
|
-
}
|
|
9420
|
-
},
|
|
9421
|
-
".cm-tooltip-below &": {
|
|
9422
|
-
top: `-${7 /* Arrow.Size */}px`,
|
|
9423
|
-
"&:before": {
|
|
9424
|
-
borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,
|
|
9425
|
-
},
|
|
9426
|
-
"&:after": {
|
|
9427
|
-
borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,
|
|
9428
|
-
top: "1px"
|
|
9429
|
-
}
|
|
9430
|
-
},
|
|
9431
|
-
},
|
|
9432
|
-
"&dark .cm-tooltip .cm-tooltip-arrow": {
|
|
9433
|
-
"&:before": {
|
|
9434
|
-
borderTopColor: "#333338",
|
|
9435
|
-
borderBottomColor: "#333338"
|
|
9436
|
-
},
|
|
9437
|
-
"&:after": {
|
|
9438
|
-
borderTopColor: "transparent",
|
|
9439
|
-
borderBottomColor: "transparent"
|
|
9440
|
-
}
|
|
9441
|
-
}
|
|
9442
|
-
});
|
|
9443
|
-
const noOffset = { x: 0, y: 0 };
|
|
9444
|
-
/**
|
|
9445
|
-
Facet to which an extension can add a value to show a tooltip.
|
|
9446
|
-
*/
|
|
9447
|
-
const showTooltip = /*@__PURE__*/index.Facet.define({
|
|
9448
|
-
enables: [tooltipPlugin, baseTheme]
|
|
9449
|
-
});
|
|
9450
|
-
const showHoverTooltip = /*@__PURE__*/index.Facet.define();
|
|
9451
|
-
class HoverTooltipHost {
|
|
9452
|
-
// Needs to be static so that host tooltip instances always match
|
|
9453
|
-
static create(view) {
|
|
9454
|
-
return new HoverTooltipHost(view);
|
|
9455
|
-
}
|
|
9456
|
-
constructor(view) {
|
|
9457
|
-
this.view = view;
|
|
9458
|
-
this.mounted = false;
|
|
9459
|
-
this.dom = document.createElement("div");
|
|
9460
|
-
this.dom.classList.add("cm-tooltip-hover");
|
|
9461
|
-
this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));
|
|
9462
|
-
}
|
|
9463
|
-
createHostedView(tooltip) {
|
|
9464
|
-
let hostedView = tooltip.create(this.view);
|
|
9465
|
-
hostedView.dom.classList.add("cm-tooltip-section");
|
|
9466
|
-
this.dom.appendChild(hostedView.dom);
|
|
9467
|
-
if (this.mounted && hostedView.mount)
|
|
9468
|
-
hostedView.mount(this.view);
|
|
9469
|
-
return hostedView;
|
|
9470
|
-
}
|
|
9471
|
-
mount(view) {
|
|
9472
|
-
for (let hostedView of this.manager.tooltipViews) {
|
|
9473
|
-
if (hostedView.mount)
|
|
9474
|
-
hostedView.mount(view);
|
|
9475
|
-
}
|
|
9476
|
-
this.mounted = true;
|
|
9477
|
-
}
|
|
9478
|
-
positioned(space) {
|
|
9479
|
-
for (let hostedView of this.manager.tooltipViews) {
|
|
9480
|
-
if (hostedView.positioned)
|
|
9481
|
-
hostedView.positioned(space);
|
|
9482
|
-
}
|
|
9483
|
-
}
|
|
9484
|
-
update(update) {
|
|
9485
|
-
this.manager.update(update);
|
|
9486
|
-
}
|
|
9487
|
-
destroy() {
|
|
9488
|
-
var _a;
|
|
9489
|
-
for (let t of this.manager.tooltipViews)
|
|
9490
|
-
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9491
|
-
}
|
|
9492
|
-
passProp(name) {
|
|
9493
|
-
let value = undefined;
|
|
9494
|
-
for (let view of this.manager.tooltipViews) {
|
|
9495
|
-
let given = view[name];
|
|
9496
|
-
if (given !== undefined) {
|
|
9497
|
-
if (value === undefined)
|
|
9498
|
-
value = given;
|
|
9499
|
-
else if (value !== given)
|
|
9500
|
-
return undefined;
|
|
9501
|
-
}
|
|
9502
|
-
}
|
|
9503
|
-
return value;
|
|
9504
|
-
}
|
|
9505
|
-
get offset() { return this.passProp("offset"); }
|
|
9506
|
-
get getCoords() { return this.passProp("getCoords"); }
|
|
9507
|
-
get overlap() { return this.passProp("overlap"); }
|
|
9508
|
-
get resize() { return this.passProp("resize"); }
|
|
9509
|
-
}
|
|
9510
|
-
const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
|
|
9511
|
-
let tooltips = state.facet(showHoverTooltip).filter(t => t);
|
|
9512
|
-
if (tooltips.length === 0)
|
|
9513
|
-
return null;
|
|
9514
|
-
return {
|
|
9515
|
-
pos: Math.min(...tooltips.map(t => t.pos)),
|
|
9516
|
-
end: Math.max(...tooltips.map(t => { var _a; return (_a = t.end) !== null && _a !== void 0 ? _a : t.pos; })),
|
|
9517
|
-
create: HoverTooltipHost.create,
|
|
9518
|
-
above: tooltips[0].above,
|
|
9519
|
-
arrow: tooltips.some(t => t.arrow),
|
|
9520
|
-
};
|
|
9521
|
-
});
|
|
9522
|
-
class HoverPlugin {
|
|
9523
|
-
constructor(view, source, field, setHover, hoverTime) {
|
|
9524
|
-
this.view = view;
|
|
9525
|
-
this.source = source;
|
|
9526
|
-
this.field = field;
|
|
9527
|
-
this.setHover = setHover;
|
|
9528
|
-
this.hoverTime = hoverTime;
|
|
9529
|
-
this.hoverTimeout = -1;
|
|
9530
|
-
this.restartTimeout = -1;
|
|
9531
|
-
this.pending = null;
|
|
9532
|
-
this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };
|
|
9533
|
-
this.checkHover = this.checkHover.bind(this);
|
|
9534
|
-
view.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this));
|
|
9535
|
-
view.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
|
|
9536
|
-
}
|
|
9537
|
-
update() {
|
|
9538
|
-
if (this.pending) {
|
|
9539
|
-
this.pending = null;
|
|
9540
|
-
clearTimeout(this.restartTimeout);
|
|
9541
|
-
this.restartTimeout = setTimeout(() => this.startHover(), 20);
|
|
9542
|
-
}
|
|
9543
|
-
}
|
|
9544
|
-
get active() {
|
|
9545
|
-
return this.view.state.field(this.field);
|
|
9546
|
-
}
|
|
9547
|
-
checkHover() {
|
|
9548
|
-
this.hoverTimeout = -1;
|
|
9549
|
-
if (this.active)
|
|
9550
|
-
return;
|
|
9551
|
-
let hovered = Date.now() - this.lastMove.time;
|
|
9552
|
-
if (hovered < this.hoverTime)
|
|
9553
|
-
this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);
|
|
9554
|
-
else
|
|
9555
|
-
this.startHover();
|
|
9556
|
-
}
|
|
9557
|
-
startHover() {
|
|
9558
|
-
clearTimeout(this.restartTimeout);
|
|
9559
|
-
let { view, lastMove } = this;
|
|
9560
|
-
let desc = view.docView.nearest(lastMove.target);
|
|
9561
|
-
if (!desc)
|
|
9562
|
-
return;
|
|
9563
|
-
let pos, side = 1;
|
|
9564
|
-
if (desc instanceof WidgetView) {
|
|
9565
|
-
pos = desc.posAtStart;
|
|
9566
|
-
}
|
|
9567
|
-
else {
|
|
9568
|
-
pos = view.posAtCoords(lastMove);
|
|
9569
|
-
if (pos == null)
|
|
9570
|
-
return;
|
|
9571
|
-
let posCoords = view.coordsAtPos(pos);
|
|
9572
|
-
if (!posCoords ||
|
|
9573
|
-
lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||
|
|
9574
|
-
lastMove.x < posCoords.left - view.defaultCharacterWidth ||
|
|
9575
|
-
lastMove.x > posCoords.right + view.defaultCharacterWidth)
|
|
9576
|
-
return;
|
|
9577
|
-
let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);
|
|
9578
|
-
let rtl = bidi && bidi.dir == exports.Direction.RTL ? -1 : 1;
|
|
9579
|
-
side = (lastMove.x < posCoords.left ? -rtl : rtl);
|
|
9580
|
-
}
|
|
9581
|
-
let open = this.source(view, pos, side);
|
|
9582
|
-
if (open === null || open === void 0 ? void 0 : open.then) {
|
|
9583
|
-
let pending = this.pending = { pos };
|
|
9584
|
-
open.then(result => {
|
|
9585
|
-
if (this.pending == pending) {
|
|
9586
|
-
this.pending = null;
|
|
9587
|
-
if (result)
|
|
9588
|
-
view.dispatch({ effects: this.setHover.of(result) });
|
|
9589
|
-
}
|
|
9590
|
-
}, e => logException(view.state, e, "hover tooltip"));
|
|
9591
|
-
}
|
|
9592
|
-
else if (open) {
|
|
9593
|
-
view.dispatch({ effects: this.setHover.of(open) });
|
|
9594
|
-
}
|
|
9595
|
-
}
|
|
9596
|
-
get tooltip() {
|
|
9597
|
-
let plugin = this.view.plugin(tooltipPlugin);
|
|
9598
|
-
let index = plugin ? plugin.manager.tooltips.findIndex(t => t.create == HoverTooltipHost.create) : -1;
|
|
9599
|
-
return index > -1 ? plugin.manager.tooltipViews[index] : null;
|
|
9600
|
-
}
|
|
9601
|
-
mousemove(event) {
|
|
9602
|
-
var _a;
|
|
9603
|
-
this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };
|
|
9604
|
-
if (this.hoverTimeout < 0)
|
|
9605
|
-
this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);
|
|
9606
|
-
let { active, tooltip } = this;
|
|
9607
|
-
if (active && tooltip && !isInTooltip(tooltip.dom, event) || this.pending) {
|
|
9608
|
-
let { pos } = active || this.pending, end = (_a = active === null || active === void 0 ? void 0 : active.end) !== null && _a !== void 0 ? _a : pos;
|
|
9609
|
-
if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos
|
|
9610
|
-
: !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {
|
|
9611
|
-
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
9612
|
-
this.pending = null;
|
|
9613
|
-
}
|
|
9614
|
-
}
|
|
9615
|
-
}
|
|
9616
|
-
mouseleave(event) {
|
|
9617
|
-
clearTimeout(this.hoverTimeout);
|
|
9618
|
-
this.hoverTimeout = -1;
|
|
9619
|
-
let { active } = this;
|
|
9620
|
-
if (active) {
|
|
9621
|
-
let { tooltip } = this;
|
|
9622
|
-
let inTooltip = tooltip && tooltip.dom.contains(event.relatedTarget);
|
|
9623
|
-
if (!inTooltip)
|
|
9624
|
-
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
9625
|
-
else
|
|
9626
|
-
this.watchTooltipLeave(tooltip.dom);
|
|
9627
|
-
}
|
|
9628
|
-
}
|
|
9629
|
-
watchTooltipLeave(tooltip) {
|
|
9630
|
-
let watch = (event) => {
|
|
9631
|
-
tooltip.removeEventListener("mouseleave", watch);
|
|
9632
|
-
if (this.active && !this.view.dom.contains(event.relatedTarget))
|
|
9633
|
-
this.view.dispatch({ effects: this.setHover.of(null) });
|
|
9634
|
-
};
|
|
9635
|
-
tooltip.addEventListener("mouseleave", watch);
|
|
9636
|
-
}
|
|
9637
|
-
destroy() {
|
|
9638
|
-
clearTimeout(this.hoverTimeout);
|
|
9639
|
-
this.view.dom.removeEventListener("mouseleave", this.mouseleave);
|
|
9640
|
-
this.view.dom.removeEventListener("mousemove", this.mousemove);
|
|
9641
|
-
}
|
|
9642
|
-
}
|
|
9643
|
-
const tooltipMargin = 4;
|
|
9644
|
-
function isInTooltip(tooltip, event) {
|
|
9645
|
-
let rect = tooltip.getBoundingClientRect();
|
|
9646
|
-
return event.clientX >= rect.left - tooltipMargin && event.clientX <= rect.right + tooltipMargin &&
|
|
9647
|
-
event.clientY >= rect.top - tooltipMargin && event.clientY <= rect.bottom + tooltipMargin;
|
|
9648
|
-
}
|
|
9649
|
-
function isOverRange(view, from, to, x, y, margin) {
|
|
9650
|
-
let rect = view.scrollDOM.getBoundingClientRect();
|
|
9651
|
-
let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;
|
|
9652
|
-
if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)
|
|
9653
|
-
return false;
|
|
9654
|
-
let pos = view.posAtCoords({ x, y }, false);
|
|
9655
|
-
return pos >= from && pos <= to;
|
|
9656
|
-
}
|
|
9657
|
-
/**
|
|
9658
|
-
Set up a hover tooltip, which shows up when the pointer hovers
|
|
9659
|
-
over ranges of text. The callback is called when the mouse hovers
|
|
9660
|
-
over the document text. It should, if there is a tooltip
|
|
9661
|
-
associated with position `pos`, return the tooltip description
|
|
9662
|
-
(either directly or in a promise). The `side` argument indicates
|
|
9663
|
-
on which side of the position the pointer is—it will be -1 if the
|
|
9664
|
-
pointer is before the position, 1 if after the position.
|
|
9665
|
-
|
|
9666
|
-
Note that all hover tooltips are hosted within a single tooltip
|
|
9667
|
-
container element. This allows multiple tooltips over the same
|
|
9668
|
-
range to be "merged" together without overlapping.
|
|
9669
|
-
*/
|
|
9670
|
-
function hoverTooltip(source, options = {}) {
|
|
9671
|
-
let setHover = index.StateEffect.define();
|
|
9672
|
-
let hoverState = index.StateField.define({
|
|
9673
|
-
create() { return null; },
|
|
9674
|
-
update(value, tr) {
|
|
9675
|
-
if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
|
|
9676
|
-
options.hideOn && options.hideOn(tr, value)))
|
|
9677
|
-
return null;
|
|
9678
|
-
if (value && tr.docChanged) {
|
|
9679
|
-
let newPos = tr.changes.mapPos(value.pos, -1, index.MapMode.TrackDel);
|
|
9680
|
-
if (newPos == null)
|
|
9681
|
-
return null;
|
|
9682
|
-
let copy = Object.assign(Object.create(null), value);
|
|
9683
|
-
copy.pos = newPos;
|
|
9684
|
-
if (value.end != null)
|
|
9685
|
-
copy.end = tr.changes.mapPos(value.end);
|
|
9686
|
-
value = copy;
|
|
9687
|
-
}
|
|
9688
|
-
for (let effect of tr.effects) {
|
|
9689
|
-
if (effect.is(setHover))
|
|
9690
|
-
value = effect.value;
|
|
9691
|
-
if (effect.is(closeHoverTooltipEffect))
|
|
9692
|
-
value = null;
|
|
9693
|
-
}
|
|
9694
|
-
return value;
|
|
9695
|
-
},
|
|
9696
|
-
provide: f => showHoverTooltip.from(f)
|
|
9697
|
-
});
|
|
9698
|
-
return [
|
|
9699
|
-
hoverState,
|
|
9700
|
-
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),
|
|
9701
|
-
showHoverTooltipHost
|
|
9702
|
-
];
|
|
9703
|
-
}
|
|
9704
|
-
/**
|
|
9705
|
-
Get the active tooltip view for a given tooltip, if available.
|
|
9706
|
-
*/
|
|
9707
|
-
function getTooltip(view, tooltip) {
|
|
9708
|
-
let plugin = view.plugin(tooltipPlugin);
|
|
9709
|
-
if (!plugin)
|
|
9710
|
-
return null;
|
|
9711
|
-
let found = plugin.manager.tooltips.indexOf(tooltip);
|
|
9712
|
-
return found < 0 ? null : plugin.manager.tooltipViews[found];
|
|
9713
|
-
}
|
|
9714
|
-
const closeHoverTooltipEffect = /*@__PURE__*/index.StateEffect.define();
|
|
9715
|
-
|
|
9716
|
-
const panelConfig = /*@__PURE__*/index.Facet.define({
|
|
9717
|
-
combine(configs) {
|
|
9718
|
-
let topContainer, bottomContainer;
|
|
9719
|
-
for (let c of configs) {
|
|
9720
|
-
topContainer = topContainer || c.topContainer;
|
|
9721
|
-
bottomContainer = bottomContainer || c.bottomContainer;
|
|
9722
|
-
}
|
|
9723
|
-
return { topContainer, bottomContainer };
|
|
9724
|
-
}
|
|
9725
|
-
});
|
|
9726
|
-
/**
|
|
9727
|
-
Get the active panel created by the given constructor, if any.
|
|
9728
|
-
This can be useful when you need access to your panels' DOM
|
|
9729
|
-
structure.
|
|
9730
|
-
*/
|
|
9731
|
-
function getPanel(view, panel) {
|
|
9732
|
-
let plugin = view.plugin(panelPlugin);
|
|
9733
|
-
let index = plugin ? plugin.specs.indexOf(panel) : -1;
|
|
9734
|
-
return index > -1 ? plugin.panels[index] : null;
|
|
9735
|
-
}
|
|
9736
|
-
const panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
9737
|
-
constructor(view) {
|
|
9738
|
-
this.input = view.state.facet(showPanel);
|
|
9739
|
-
this.specs = this.input.filter(s => s);
|
|
9740
|
-
this.panels = this.specs.map(spec => spec(view));
|
|
9741
|
-
let conf = view.state.facet(panelConfig);
|
|
9742
|
-
this.top = new PanelGroup(view, true, conf.topContainer);
|
|
9743
|
-
this.bottom = new PanelGroup(view, false, conf.bottomContainer);
|
|
9744
|
-
this.top.sync(this.panels.filter(p => p.top));
|
|
9745
|
-
this.bottom.sync(this.panels.filter(p => !p.top));
|
|
9746
|
-
for (let p of this.panels) {
|
|
9747
|
-
p.dom.classList.add("cm-panel");
|
|
9748
|
-
if (p.mount)
|
|
9749
|
-
p.mount();
|
|
9750
|
-
}
|
|
9751
|
-
}
|
|
9752
|
-
update(update) {
|
|
9753
|
-
let conf = update.state.facet(panelConfig);
|
|
9754
|
-
if (this.top.container != conf.topContainer) {
|
|
9755
|
-
this.top.sync([]);
|
|
9756
|
-
this.top = new PanelGroup(update.view, true, conf.topContainer);
|
|
9757
|
-
}
|
|
9758
|
-
if (this.bottom.container != conf.bottomContainer) {
|
|
9759
|
-
this.bottom.sync([]);
|
|
9760
|
-
this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);
|
|
9761
|
-
}
|
|
9762
|
-
this.top.syncClasses();
|
|
9763
|
-
this.bottom.syncClasses();
|
|
9764
|
-
let input = update.state.facet(showPanel);
|
|
9765
|
-
if (input != this.input) {
|
|
9766
|
-
let specs = input.filter(x => x);
|
|
9767
|
-
let panels = [], top = [], bottom = [], mount = [];
|
|
9768
|
-
for (let spec of specs) {
|
|
9769
|
-
let known = this.specs.indexOf(spec), panel;
|
|
9770
|
-
if (known < 0) {
|
|
9771
|
-
panel = spec(update.view);
|
|
9772
|
-
mount.push(panel);
|
|
9773
|
-
}
|
|
9774
|
-
else {
|
|
9775
|
-
panel = this.panels[known];
|
|
9776
|
-
if (panel.update)
|
|
9777
|
-
panel.update(update);
|
|
9778
|
-
}
|
|
9779
|
-
panels.push(panel);
|
|
9780
|
-
(panel.top ? top : bottom).push(panel);
|
|
9781
|
-
}
|
|
9782
|
-
this.specs = specs;
|
|
9783
|
-
this.panels = panels;
|
|
9784
|
-
this.top.sync(top);
|
|
9785
|
-
this.bottom.sync(bottom);
|
|
9786
|
-
for (let p of mount) {
|
|
9787
|
-
p.dom.classList.add("cm-panel");
|
|
9788
|
-
if (p.mount)
|
|
9789
|
-
p.mount();
|
|
9790
|
-
}
|
|
9791
|
-
}
|
|
9792
|
-
else {
|
|
9793
|
-
for (let p of this.panels)
|
|
9794
|
-
if (p.update)
|
|
9795
|
-
p.update(update);
|
|
9796
|
-
}
|
|
9797
|
-
}
|
|
9798
|
-
destroy() {
|
|
9799
|
-
this.top.sync([]);
|
|
9800
|
-
this.bottom.sync([]);
|
|
9801
|
-
}
|
|
9802
|
-
}, {
|
|
9803
|
-
provide: plugin => EditorView.scrollMargins.of(view => {
|
|
9804
|
-
let value = view.plugin(plugin);
|
|
9805
|
-
return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };
|
|
9806
|
-
})
|
|
9807
|
-
});
|
|
9808
|
-
class PanelGroup {
|
|
9809
|
-
constructor(view, top, container) {
|
|
9810
|
-
this.view = view;
|
|
9811
|
-
this.top = top;
|
|
9812
|
-
this.container = container;
|
|
9813
|
-
this.dom = undefined;
|
|
9814
|
-
this.classes = "";
|
|
9815
|
-
this.panels = [];
|
|
9816
|
-
this.syncClasses();
|
|
9817
|
-
}
|
|
9818
|
-
sync(panels) {
|
|
9819
|
-
for (let p of this.panels)
|
|
9820
|
-
if (p.destroy && panels.indexOf(p) < 0)
|
|
9821
|
-
p.destroy();
|
|
9822
|
-
this.panels = panels;
|
|
9823
|
-
this.syncDOM();
|
|
9824
|
-
}
|
|
9825
|
-
syncDOM() {
|
|
9826
|
-
if (this.panels.length == 0) {
|
|
9827
|
-
if (this.dom) {
|
|
9828
|
-
this.dom.remove();
|
|
9829
|
-
this.dom = undefined;
|
|
9830
|
-
}
|
|
9831
|
-
return;
|
|
9832
|
-
}
|
|
9833
|
-
if (!this.dom) {
|
|
9834
|
-
this.dom = document.createElement("div");
|
|
9835
|
-
this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom";
|
|
9836
|
-
this.dom.style[this.top ? "top" : "bottom"] = "0";
|
|
9837
|
-
let parent = this.container || this.view.dom;
|
|
9838
|
-
parent.insertBefore(this.dom, this.top ? parent.firstChild : null);
|
|
9839
|
-
}
|
|
9840
|
-
let curDOM = this.dom.firstChild;
|
|
9841
|
-
for (let panel of this.panels) {
|
|
9842
|
-
if (panel.dom.parentNode == this.dom) {
|
|
9843
|
-
while (curDOM != panel.dom)
|
|
9844
|
-
curDOM = rm(curDOM);
|
|
9845
|
-
curDOM = curDOM.nextSibling;
|
|
9846
|
-
}
|
|
9847
|
-
else {
|
|
9848
|
-
this.dom.insertBefore(panel.dom, curDOM);
|
|
9849
|
-
}
|
|
9850
|
-
}
|
|
9851
|
-
while (curDOM)
|
|
9852
|
-
curDOM = rm(curDOM);
|
|
9853
|
-
}
|
|
9854
|
-
scrollMargin() {
|
|
9855
|
-
return !this.dom || this.container ? 0
|
|
9856
|
-
: Math.max(0, this.top ?
|
|
9857
|
-
this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :
|
|
9858
|
-
Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
|
|
9859
|
-
}
|
|
9860
|
-
syncClasses() {
|
|
9861
|
-
if (!this.container || this.classes == this.view.themeClasses)
|
|
9862
|
-
return;
|
|
9863
|
-
for (let cls of this.classes.split(" "))
|
|
9864
|
-
if (cls)
|
|
9865
|
-
this.container.classList.remove(cls);
|
|
9866
|
-
for (let cls of (this.classes = this.view.themeClasses).split(" "))
|
|
9867
|
-
if (cls)
|
|
9868
|
-
this.container.classList.add(cls);
|
|
9869
|
-
}
|
|
9870
|
-
}
|
|
9871
|
-
function rm(node) {
|
|
9872
|
-
let next = node.nextSibling;
|
|
9873
|
-
node.remove();
|
|
9874
|
-
return next;
|
|
9875
|
-
}
|
|
9876
|
-
/**
|
|
9877
|
-
Opening a panel is done by providing a constructor function for
|
|
9878
|
-
the panel through this facet. (The panel is closed again when its
|
|
9879
|
-
constructor is no longer provided.) Values of `null` are ignored.
|
|
9880
|
-
*/
|
|
9881
|
-
const showPanel = /*@__PURE__*/index.Facet.define({
|
|
9882
|
-
enables: panelPlugin
|
|
9883
|
-
});
|
|
9884
|
-
|
|
9885
|
-
/**
|
|
9886
|
-
A gutter marker represents a bit of information attached to a line
|
|
9887
|
-
in a specific gutter. Your own custom markers have to extend this
|
|
9888
|
-
class.
|
|
8190
|
+
A gutter marker represents a bit of information attached to a line
|
|
8191
|
+
in a specific gutter. Your own custom markers have to extend this
|
|
8192
|
+
class.
|
|
9889
8193
|
*/
|
|
9890
8194
|
class GutterMarker extends index.RangeValue {
|
|
9891
8195
|
/**
|
|
@@ -9909,478 +8213,16 @@ GutterMarker.prototype.toDOM = undefined;
|
|
|
9909
8213
|
GutterMarker.prototype.mapMode = index.MapMode.TrackBefore;
|
|
9910
8214
|
GutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;
|
|
9911
8215
|
GutterMarker.prototype.point = true;
|
|
9912
|
-
/**
|
|
9913
|
-
Facet used to add a class to all gutter elements for a given line.
|
|
9914
|
-
Markers given to this facet should _only_ define an
|
|
9915
|
-
[`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a
|
|
9916
|
-
[`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear
|
|
9917
|
-
in all gutters for the line).
|
|
9918
|
-
*/
|
|
9919
|
-
const gutterLineClass = /*@__PURE__*/index.Facet.define();
|
|
9920
|
-
const defaults = {
|
|
9921
|
-
class: "",
|
|
9922
|
-
renderEmptyElements: false,
|
|
9923
|
-
elementStyle: "",
|
|
9924
|
-
markers: () => index.RangeSet.empty,
|
|
9925
|
-
lineMarker: () => null,
|
|
9926
|
-
widgetMarker: () => null,
|
|
9927
|
-
lineMarkerChange: null,
|
|
9928
|
-
initialSpacer: null,
|
|
9929
|
-
updateSpacer: null,
|
|
9930
|
-
domEventHandlers: {}
|
|
9931
|
-
};
|
|
9932
|
-
const activeGutters = /*@__PURE__*/index.Facet.define();
|
|
9933
|
-
/**
|
|
9934
|
-
Define an editor gutter. The order in which the gutters appear is
|
|
9935
|
-
determined by their extension priority.
|
|
9936
|
-
*/
|
|
9937
|
-
function gutter(config) {
|
|
9938
|
-
return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];
|
|
9939
|
-
}
|
|
9940
|
-
const unfixGutters = /*@__PURE__*/index.Facet.define({
|
|
9941
|
-
combine: values => values.some(x => x)
|
|
9942
|
-
});
|
|
9943
|
-
/**
|
|
9944
|
-
The gutter-drawing plugin is automatically enabled when you add a
|
|
9945
|
-
gutter, but you can use this function to explicitly configure it.
|
|
9946
|
-
|
|
9947
|
-
Unless `fixed` is explicitly set to `false`, the gutters are
|
|
9948
|
-
fixed, meaning they don't scroll along with the content
|
|
9949
|
-
horizontally (except on Internet Explorer, which doesn't support
|
|
9950
|
-
CSS [`position:
|
|
9951
|
-
sticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).
|
|
9952
|
-
*/
|
|
9953
|
-
function gutters(config) {
|
|
9954
|
-
let result = [
|
|
9955
|
-
gutterView,
|
|
9956
|
-
];
|
|
9957
|
-
if (config && config.fixed === false)
|
|
9958
|
-
result.push(unfixGutters.of(true));
|
|
9959
|
-
return result;
|
|
9960
|
-
}
|
|
9961
|
-
const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
9962
|
-
constructor(view) {
|
|
9963
|
-
this.view = view;
|
|
9964
|
-
this.prevViewport = view.viewport;
|
|
9965
|
-
this.dom = document.createElement("div");
|
|
9966
|
-
this.dom.className = "cm-gutters";
|
|
9967
|
-
this.dom.setAttribute("aria-hidden", "true");
|
|
9968
|
-
this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + "px";
|
|
9969
|
-
this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));
|
|
9970
|
-
for (let gutter of this.gutters)
|
|
9971
|
-
this.dom.appendChild(gutter.dom);
|
|
9972
|
-
this.fixed = !view.state.facet(unfixGutters);
|
|
9973
|
-
if (this.fixed) {
|
|
9974
|
-
// FIXME IE11 fallback, which doesn't support position: sticky,
|
|
9975
|
-
// by using position: relative + event handlers that realign the
|
|
9976
|
-
// gutter (or just force fixed=false on IE11?)
|
|
9977
|
-
this.dom.style.position = "sticky";
|
|
9978
|
-
}
|
|
9979
|
-
this.syncGutters(false);
|
|
9980
|
-
view.scrollDOM.insertBefore(this.dom, view.contentDOM);
|
|
9981
|
-
}
|
|
9982
|
-
update(update) {
|
|
9983
|
-
if (this.updateGutters(update)) {
|
|
9984
|
-
// Detach during sync when the viewport changed significantly
|
|
9985
|
-
// (such as during scrolling), since for large updates that is
|
|
9986
|
-
// faster.
|
|
9987
|
-
let vpA = this.prevViewport, vpB = update.view.viewport;
|
|
9988
|
-
let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);
|
|
9989
|
-
this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);
|
|
9990
|
-
}
|
|
9991
|
-
if (update.geometryChanged)
|
|
9992
|
-
this.dom.style.minHeight = this.view.contentHeight + "px";
|
|
9993
|
-
if (this.view.state.facet(unfixGutters) != !this.fixed) {
|
|
9994
|
-
this.fixed = !this.fixed;
|
|
9995
|
-
this.dom.style.position = this.fixed ? "sticky" : "";
|
|
9996
|
-
}
|
|
9997
|
-
this.prevViewport = update.view.viewport;
|
|
9998
|
-
}
|
|
9999
|
-
syncGutters(detach) {
|
|
10000
|
-
let after = this.dom.nextSibling;
|
|
10001
|
-
if (detach)
|
|
10002
|
-
this.dom.remove();
|
|
10003
|
-
let lineClasses = index.RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);
|
|
10004
|
-
let classSet = [];
|
|
10005
|
-
let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
|
|
10006
|
-
for (let line of this.view.viewportLineBlocks) {
|
|
10007
|
-
if (classSet.length)
|
|
10008
|
-
classSet = [];
|
|
10009
|
-
if (Array.isArray(line.type)) {
|
|
10010
|
-
let first = true;
|
|
10011
|
-
for (let b of line.type) {
|
|
10012
|
-
if (b.type == exports.BlockType.Text && first) {
|
|
10013
|
-
advanceCursor(lineClasses, classSet, b.from);
|
|
10014
|
-
for (let cx of contexts)
|
|
10015
|
-
cx.line(this.view, b, classSet);
|
|
10016
|
-
first = false;
|
|
10017
|
-
}
|
|
10018
|
-
else if (b.widget) {
|
|
10019
|
-
for (let cx of contexts)
|
|
10020
|
-
cx.widget(this.view, b);
|
|
10021
|
-
}
|
|
10022
|
-
}
|
|
10023
|
-
}
|
|
10024
|
-
else if (line.type == exports.BlockType.Text) {
|
|
10025
|
-
advanceCursor(lineClasses, classSet, line.from);
|
|
10026
|
-
for (let cx of contexts)
|
|
10027
|
-
cx.line(this.view, line, classSet);
|
|
10028
|
-
}
|
|
10029
|
-
else if (line.widget) {
|
|
10030
|
-
for (let cx of contexts)
|
|
10031
|
-
cx.widget(this.view, line);
|
|
10032
|
-
}
|
|
10033
|
-
}
|
|
10034
|
-
for (let cx of contexts)
|
|
10035
|
-
cx.finish();
|
|
10036
|
-
if (detach)
|
|
10037
|
-
this.view.scrollDOM.insertBefore(this.dom, after);
|
|
10038
|
-
}
|
|
10039
|
-
updateGutters(update) {
|
|
10040
|
-
let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);
|
|
10041
|
-
let change = update.docChanged || update.heightChanged || update.viewportChanged ||
|
|
10042
|
-
!index.RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);
|
|
10043
|
-
if (prev == cur) {
|
|
10044
|
-
for (let gutter of this.gutters)
|
|
10045
|
-
if (gutter.update(update))
|
|
10046
|
-
change = true;
|
|
10047
|
-
}
|
|
10048
|
-
else {
|
|
10049
|
-
change = true;
|
|
10050
|
-
let gutters = [];
|
|
10051
|
-
for (let conf of cur) {
|
|
10052
|
-
let known = prev.indexOf(conf);
|
|
10053
|
-
if (known < 0) {
|
|
10054
|
-
gutters.push(new SingleGutterView(this.view, conf));
|
|
10055
|
-
}
|
|
10056
|
-
else {
|
|
10057
|
-
this.gutters[known].update(update);
|
|
10058
|
-
gutters.push(this.gutters[known]);
|
|
10059
|
-
}
|
|
10060
|
-
}
|
|
10061
|
-
for (let g of this.gutters) {
|
|
10062
|
-
g.dom.remove();
|
|
10063
|
-
if (gutters.indexOf(g) < 0)
|
|
10064
|
-
g.destroy();
|
|
10065
|
-
}
|
|
10066
|
-
for (let g of gutters)
|
|
10067
|
-
this.dom.appendChild(g.dom);
|
|
10068
|
-
this.gutters = gutters;
|
|
10069
|
-
}
|
|
10070
|
-
return change;
|
|
10071
|
-
}
|
|
10072
|
-
destroy() {
|
|
10073
|
-
for (let view of this.gutters)
|
|
10074
|
-
view.destroy();
|
|
10075
|
-
this.dom.remove();
|
|
10076
|
-
}
|
|
10077
|
-
}, {
|
|
10078
|
-
provide: plugin => EditorView.scrollMargins.of(view => {
|
|
10079
|
-
let value = view.plugin(plugin);
|
|
10080
|
-
if (!value || value.gutters.length == 0 || !value.fixed)
|
|
10081
|
-
return null;
|
|
10082
|
-
return view.textDirection == exports.Direction.LTR
|
|
10083
|
-
? { left: value.dom.offsetWidth * view.scaleX }
|
|
10084
|
-
: { right: value.dom.offsetWidth * view.scaleX };
|
|
10085
|
-
})
|
|
10086
|
-
});
|
|
10087
|
-
function asArray(val) { return (Array.isArray(val) ? val : [val]); }
|
|
10088
|
-
function advanceCursor(cursor, collect, pos) {
|
|
10089
|
-
while (cursor.value && cursor.from <= pos) {
|
|
10090
|
-
if (cursor.from == pos)
|
|
10091
|
-
collect.push(cursor.value);
|
|
10092
|
-
cursor.next();
|
|
10093
|
-
}
|
|
10094
|
-
}
|
|
10095
|
-
class UpdateContext {
|
|
10096
|
-
constructor(gutter, viewport, height) {
|
|
10097
|
-
this.gutter = gutter;
|
|
10098
|
-
this.height = height;
|
|
10099
|
-
this.i = 0;
|
|
10100
|
-
this.cursor = index.RangeSet.iter(gutter.markers, viewport.from);
|
|
10101
|
-
}
|
|
10102
|
-
addElement(view, block, markers) {
|
|
10103
|
-
let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
|
|
10104
|
-
if (this.i == gutter.elements.length) {
|
|
10105
|
-
let newElt = new GutterElement(view, height, above, markers);
|
|
10106
|
-
gutter.elements.push(newElt);
|
|
10107
|
-
gutter.dom.appendChild(newElt.dom);
|
|
10108
|
-
}
|
|
10109
|
-
else {
|
|
10110
|
-
gutter.elements[this.i].update(view, height, above, markers);
|
|
10111
|
-
}
|
|
10112
|
-
this.height = block.bottom;
|
|
10113
|
-
this.i++;
|
|
10114
|
-
}
|
|
10115
|
-
line(view, line, extraMarkers) {
|
|
10116
|
-
let localMarkers = [];
|
|
10117
|
-
advanceCursor(this.cursor, localMarkers, line.from);
|
|
10118
|
-
if (extraMarkers.length)
|
|
10119
|
-
localMarkers = localMarkers.concat(extraMarkers);
|
|
10120
|
-
let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
|
|
10121
|
-
if (forLine)
|
|
10122
|
-
localMarkers.unshift(forLine);
|
|
10123
|
-
let gutter = this.gutter;
|
|
10124
|
-
if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
|
|
10125
|
-
return;
|
|
10126
|
-
this.addElement(view, line, localMarkers);
|
|
10127
|
-
}
|
|
10128
|
-
widget(view, block) {
|
|
10129
|
-
let marker = this.gutter.config.widgetMarker(view, block.widget, block);
|
|
10130
|
-
if (marker)
|
|
10131
|
-
this.addElement(view, block, [marker]);
|
|
10132
|
-
}
|
|
10133
|
-
finish() {
|
|
10134
|
-
let gutter = this.gutter;
|
|
10135
|
-
while (gutter.elements.length > this.i) {
|
|
10136
|
-
let last = gutter.elements.pop();
|
|
10137
|
-
gutter.dom.removeChild(last.dom);
|
|
10138
|
-
last.destroy();
|
|
10139
|
-
}
|
|
10140
|
-
}
|
|
10141
|
-
}
|
|
10142
|
-
class SingleGutterView {
|
|
10143
|
-
constructor(view, config) {
|
|
10144
|
-
this.view = view;
|
|
10145
|
-
this.config = config;
|
|
10146
|
-
this.elements = [];
|
|
10147
|
-
this.spacer = null;
|
|
10148
|
-
this.dom = document.createElement("div");
|
|
10149
|
-
this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
|
|
10150
|
-
for (let prop in config.domEventHandlers) {
|
|
10151
|
-
this.dom.addEventListener(prop, (event) => {
|
|
10152
|
-
let target = event.target, y;
|
|
10153
|
-
if (target != this.dom && this.dom.contains(target)) {
|
|
10154
|
-
while (target.parentNode != this.dom)
|
|
10155
|
-
target = target.parentNode;
|
|
10156
|
-
let rect = target.getBoundingClientRect();
|
|
10157
|
-
y = (rect.top + rect.bottom) / 2;
|
|
10158
|
-
}
|
|
10159
|
-
else {
|
|
10160
|
-
y = event.clientY;
|
|
10161
|
-
}
|
|
10162
|
-
let line = view.lineBlockAtHeight(y - view.documentTop);
|
|
10163
|
-
if (config.domEventHandlers[prop](view, line, event))
|
|
10164
|
-
event.preventDefault();
|
|
10165
|
-
});
|
|
10166
|
-
}
|
|
10167
|
-
this.markers = asArray(config.markers(view));
|
|
10168
|
-
if (config.initialSpacer) {
|
|
10169
|
-
this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);
|
|
10170
|
-
this.dom.appendChild(this.spacer.dom);
|
|
10171
|
-
this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none";
|
|
10172
|
-
}
|
|
10173
|
-
}
|
|
10174
|
-
update(update) {
|
|
10175
|
-
let prevMarkers = this.markers;
|
|
10176
|
-
this.markers = asArray(this.config.markers(update.view));
|
|
10177
|
-
if (this.spacer && this.config.updateSpacer) {
|
|
10178
|
-
let updated = this.config.updateSpacer(this.spacer.markers[0], update);
|
|
10179
|
-
if (updated != this.spacer.markers[0])
|
|
10180
|
-
this.spacer.update(update.view, 0, 0, [updated]);
|
|
10181
|
-
}
|
|
10182
|
-
let vp = update.view.viewport;
|
|
10183
|
-
return !index.RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||
|
|
10184
|
-
(this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);
|
|
10185
|
-
}
|
|
10186
|
-
destroy() {
|
|
10187
|
-
for (let elt of this.elements)
|
|
10188
|
-
elt.destroy();
|
|
10189
|
-
}
|
|
10190
|
-
}
|
|
10191
|
-
class GutterElement {
|
|
10192
|
-
constructor(view, height, above, markers) {
|
|
10193
|
-
this.height = -1;
|
|
10194
|
-
this.above = 0;
|
|
10195
|
-
this.markers = [];
|
|
10196
|
-
this.dom = document.createElement("div");
|
|
10197
|
-
this.dom.className = "cm-gutterElement";
|
|
10198
|
-
this.update(view, height, above, markers);
|
|
10199
|
-
}
|
|
10200
|
-
update(view, height, above, markers) {
|
|
10201
|
-
if (this.height != height) {
|
|
10202
|
-
this.height = height;
|
|
10203
|
-
this.dom.style.height = height + "px";
|
|
10204
|
-
}
|
|
10205
|
-
if (this.above != above)
|
|
10206
|
-
this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
|
|
10207
|
-
if (!sameMarkers(this.markers, markers))
|
|
10208
|
-
this.setMarkers(view, markers);
|
|
10209
|
-
}
|
|
10210
|
-
setMarkers(view, markers) {
|
|
10211
|
-
let cls = "cm-gutterElement", domPos = this.dom.firstChild;
|
|
10212
|
-
for (let iNew = 0, iOld = 0;;) {
|
|
10213
|
-
let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;
|
|
10214
|
-
if (marker) {
|
|
10215
|
-
let c = marker.elementClass;
|
|
10216
|
-
if (c)
|
|
10217
|
-
cls += " " + c;
|
|
10218
|
-
for (let i = iOld; i < this.markers.length; i++)
|
|
10219
|
-
if (this.markers[i].compare(marker)) {
|
|
10220
|
-
skipTo = i;
|
|
10221
|
-
matched = true;
|
|
10222
|
-
break;
|
|
10223
|
-
}
|
|
10224
|
-
}
|
|
10225
|
-
else {
|
|
10226
|
-
skipTo = this.markers.length;
|
|
10227
|
-
}
|
|
10228
|
-
while (iOld < skipTo) {
|
|
10229
|
-
let next = this.markers[iOld++];
|
|
10230
|
-
if (next.toDOM) {
|
|
10231
|
-
next.destroy(domPos);
|
|
10232
|
-
let after = domPos.nextSibling;
|
|
10233
|
-
domPos.remove();
|
|
10234
|
-
domPos = after;
|
|
10235
|
-
}
|
|
10236
|
-
}
|
|
10237
|
-
if (!marker)
|
|
10238
|
-
break;
|
|
10239
|
-
if (marker.toDOM) {
|
|
10240
|
-
if (matched)
|
|
10241
|
-
domPos = domPos.nextSibling;
|
|
10242
|
-
else
|
|
10243
|
-
this.dom.insertBefore(marker.toDOM(view), domPos);
|
|
10244
|
-
}
|
|
10245
|
-
if (matched)
|
|
10246
|
-
iOld++;
|
|
10247
|
-
}
|
|
10248
|
-
this.dom.className = cls;
|
|
10249
|
-
this.markers = markers;
|
|
10250
|
-
}
|
|
10251
|
-
destroy() {
|
|
10252
|
-
this.setMarkers(null, []); // First argument not used unless creating markers
|
|
10253
|
-
}
|
|
10254
|
-
}
|
|
10255
|
-
function sameMarkers(a, b) {
|
|
10256
|
-
if (a.length != b.length)
|
|
10257
|
-
return false;
|
|
10258
|
-
for (let i = 0; i < a.length; i++)
|
|
10259
|
-
if (!a[i].compare(b[i]))
|
|
10260
|
-
return false;
|
|
10261
|
-
return true;
|
|
10262
|
-
}
|
|
10263
|
-
/**
|
|
10264
|
-
Facet used to provide markers to the line number gutter.
|
|
10265
|
-
*/
|
|
10266
|
-
const lineNumberMarkers = /*@__PURE__*/index.Facet.define();
|
|
10267
|
-
const lineNumberConfig = /*@__PURE__*/index.Facet.define({
|
|
10268
|
-
combine(values) {
|
|
10269
|
-
return index.combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {
|
|
10270
|
-
domEventHandlers(a, b) {
|
|
10271
|
-
let result = Object.assign({}, a);
|
|
10272
|
-
for (let event in b) {
|
|
10273
|
-
let exists = result[event], add = b[event];
|
|
10274
|
-
result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;
|
|
10275
|
-
}
|
|
10276
|
-
return result;
|
|
10277
|
-
}
|
|
10278
|
-
});
|
|
10279
|
-
}
|
|
10280
|
-
});
|
|
10281
|
-
class NumberMarker extends GutterMarker {
|
|
10282
|
-
constructor(number) {
|
|
10283
|
-
super();
|
|
10284
|
-
this.number = number;
|
|
10285
|
-
}
|
|
10286
|
-
eq(other) { return this.number == other.number; }
|
|
10287
|
-
toDOM() { return document.createTextNode(this.number); }
|
|
10288
|
-
}
|
|
10289
|
-
function formatNumber(view, number) {
|
|
10290
|
-
return view.state.facet(lineNumberConfig).formatNumber(number, view.state);
|
|
10291
|
-
}
|
|
10292
|
-
const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({
|
|
10293
|
-
class: "cm-lineNumbers",
|
|
10294
|
-
renderEmptyElements: false,
|
|
10295
|
-
markers(view) { return view.state.facet(lineNumberMarkers); },
|
|
10296
|
-
lineMarker(view, line, others) {
|
|
10297
|
-
if (others.some(m => m.toDOM))
|
|
10298
|
-
return null;
|
|
10299
|
-
return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
|
|
10300
|
-
},
|
|
10301
|
-
widgetMarker: () => null,
|
|
10302
|
-
lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
|
|
10303
|
-
initialSpacer(view) {
|
|
10304
|
-
return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
|
|
10305
|
-
},
|
|
10306
|
-
updateSpacer(spacer, update) {
|
|
10307
|
-
let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));
|
|
10308
|
-
return max == spacer.number ? spacer : new NumberMarker(max);
|
|
10309
|
-
},
|
|
10310
|
-
domEventHandlers: state.facet(lineNumberConfig).domEventHandlers
|
|
10311
|
-
}));
|
|
10312
|
-
/**
|
|
10313
|
-
Create a line number gutter extension.
|
|
10314
|
-
*/
|
|
10315
|
-
function lineNumbers(config = {}) {
|
|
10316
|
-
return [
|
|
10317
|
-
lineNumberConfig.of(config),
|
|
10318
|
-
gutters(),
|
|
10319
|
-
lineNumberGutter
|
|
10320
|
-
];
|
|
10321
|
-
}
|
|
10322
|
-
function maxLineNumber(lines) {
|
|
10323
|
-
let last = 9;
|
|
10324
|
-
while (last < lines)
|
|
10325
|
-
last = last * 10 + 9;
|
|
10326
|
-
return last;
|
|
10327
|
-
}
|
|
10328
|
-
const activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {
|
|
10329
|
-
constructor() {
|
|
10330
|
-
super(...arguments);
|
|
10331
|
-
this.elementClass = "cm-activeLineGutter";
|
|
10332
|
-
}
|
|
10333
|
-
};
|
|
10334
|
-
const activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute(["selection"], state => {
|
|
10335
|
-
let marks = [], last = -1;
|
|
10336
|
-
for (let range of state.selection.ranges) {
|
|
10337
|
-
let linePos = state.doc.lineAt(range.head).from;
|
|
10338
|
-
if (linePos > last) {
|
|
10339
|
-
last = linePos;
|
|
10340
|
-
marks.push(activeLineGutterMarker.range(linePos));
|
|
10341
|
-
}
|
|
10342
|
-
}
|
|
10343
|
-
return index.RangeSet.of(marks);
|
|
10344
|
-
});
|
|
10345
|
-
/**
|
|
10346
|
-
Returns an extension that adds a `cm-activeLineGutter` class to
|
|
10347
|
-
all gutter elements on the [active
|
|
10348
|
-
line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
|
|
10349
|
-
*/
|
|
10350
|
-
function highlightActiveLineGutter() {
|
|
10351
|
-
return activeLineGutterHighlighter;
|
|
10352
|
-
}
|
|
10353
8216
|
|
|
10354
8217
|
exports.BidiSpan = BidiSpan;
|
|
10355
8218
|
exports.BlockInfo = BlockInfo;
|
|
10356
8219
|
exports.Decoration = Decoration;
|
|
10357
8220
|
exports.EditorView = EditorView;
|
|
10358
8221
|
exports.GutterMarker = GutterMarker;
|
|
10359
|
-
exports.MatchDecorator = MatchDecorator;
|
|
10360
|
-
exports.RectangleMarker = RectangleMarker;
|
|
10361
8222
|
exports.ViewPlugin = ViewPlugin;
|
|
10362
8223
|
exports.ViewUpdate = ViewUpdate;
|
|
10363
8224
|
exports.WidgetType = WidgetType;
|
|
10364
|
-
exports.crosshairCursor = crosshairCursor;
|
|
10365
|
-
exports.drawSelection = drawSelection;
|
|
10366
|
-
exports.dropCursor = dropCursor;
|
|
10367
|
-
exports.getPanel = getPanel;
|
|
10368
|
-
exports.getTooltip = getTooltip;
|
|
10369
|
-
exports.gutter = gutter;
|
|
10370
|
-
exports.gutterLineClass = gutterLineClass;
|
|
10371
|
-
exports.gutters = gutters;
|
|
10372
|
-
exports.highlightActiveLine = highlightActiveLine;
|
|
10373
|
-
exports.highlightActiveLineGutter = highlightActiveLineGutter;
|
|
10374
|
-
exports.highlightSpecialChars = highlightSpecialChars;
|
|
10375
|
-
exports.hoverTooltip = hoverTooltip;
|
|
10376
8225
|
exports.keymap = keymap;
|
|
10377
|
-
exports.layer = layer;
|
|
10378
|
-
exports.lineNumberMarkers = lineNumberMarkers;
|
|
10379
|
-
exports.lineNumbers = lineNumbers;
|
|
10380
8226
|
exports.logException = logException;
|
|
10381
8227
|
exports.placeholder = placeholder;
|
|
10382
|
-
exports.rectangularSelection = rectangularSelection;
|
|
10383
|
-
exports.runScopeHandlers = runScopeHandlers;
|
|
10384
|
-
exports.showPanel = showPanel;
|
|
10385
|
-
exports.showTooltip = showTooltip;
|
|
10386
8228
|
//# sourceMappingURL=index.js.map
|