rwb-codemirror-helix 0.2.1 → 0.2.3
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/index.cjs +141 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +139 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -4
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
searchStateField: () => searchStateField
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(index_exports);
|
|
33
|
-
var
|
|
33
|
+
var import_state19 = require("@codemirror/state");
|
|
34
34
|
var import_commands2 = require("@codemirror/commands");
|
|
35
35
|
|
|
36
36
|
// src/state.ts
|
|
@@ -219,7 +219,48 @@ var helixBaseTheme = import_view.EditorView.baseTheme({
|
|
|
219
219
|
fontStyle: "italic",
|
|
220
220
|
opacity: "0.7"
|
|
221
221
|
},
|
|
222
|
-
"& .helix-status-register": { color: "var(--helix-register-color, #7000c0)" }
|
|
222
|
+
"& .helix-status-register": { color: "var(--helix-register-color, #7000c0)" },
|
|
223
|
+
// Which-key panel
|
|
224
|
+
"& .helix-whichkey-panel": {
|
|
225
|
+
display: "flex",
|
|
226
|
+
flexWrap: "wrap",
|
|
227
|
+
alignItems: "center",
|
|
228
|
+
gap: "2px 14px",
|
|
229
|
+
padding: "4px 8px",
|
|
230
|
+
fontSize: "0.82em",
|
|
231
|
+
fontFamily: "monospace",
|
|
232
|
+
background: "var(--helix-status-bg, inherit)",
|
|
233
|
+
color: "var(--helix-status-fg, inherit)",
|
|
234
|
+
borderTop: "1px solid var(--helix-status-border, #999)",
|
|
235
|
+
userSelect: "none"
|
|
236
|
+
},
|
|
237
|
+
"& .helix-whichkey-title": {
|
|
238
|
+
fontWeight: "bold",
|
|
239
|
+
opacity: "0.45",
|
|
240
|
+
marginRight: "6px",
|
|
241
|
+
textTransform: "uppercase",
|
|
242
|
+
letterSpacing: "0.06em",
|
|
243
|
+
fontSize: "0.9em"
|
|
244
|
+
},
|
|
245
|
+
"& .helix-whichkey-item": {
|
|
246
|
+
display: "inline-flex",
|
|
247
|
+
alignItems: "center",
|
|
248
|
+
gap: "5px"
|
|
249
|
+
},
|
|
250
|
+
"& .helix-whichkey-key": {
|
|
251
|
+
fontWeight: "bold",
|
|
252
|
+
color: "var(--helix-normal-color, #0080e0)",
|
|
253
|
+
background: "rgba(128, 128, 128, 0.12)",
|
|
254
|
+
padding: "0 5px",
|
|
255
|
+
borderRadius: "3px",
|
|
256
|
+
border: "1px solid rgba(128, 128, 128, 0.25)",
|
|
257
|
+
minWidth: "1.5em",
|
|
258
|
+
textAlign: "center",
|
|
259
|
+
lineHeight: "1.5"
|
|
260
|
+
},
|
|
261
|
+
"& .helix-whichkey-desc": {
|
|
262
|
+
opacity: "0.7"
|
|
263
|
+
}
|
|
223
264
|
});
|
|
224
265
|
|
|
225
266
|
// src/keymap.ts
|
|
@@ -2454,11 +2495,12 @@ var searchTheme = import_view2.EditorView.baseTheme({
|
|
|
2454
2495
|
display: "flex",
|
|
2455
2496
|
alignItems: "center",
|
|
2456
2497
|
gap: "4px",
|
|
2457
|
-
background: "var(--helix-
|
|
2458
|
-
borderTop: "1px solid #
|
|
2498
|
+
background: "var(--helix-status-bg, inherit)",
|
|
2499
|
+
borderTop: "1px solid var(--helix-status-border, #999)"
|
|
2459
2500
|
},
|
|
2460
2501
|
"& .helix-search-prefix": {
|
|
2461
|
-
color: "
|
|
2502
|
+
color: "var(--helix-pending-color, inherit)",
|
|
2503
|
+
opacity: "0.7",
|
|
2462
2504
|
fontFamily: "monospace",
|
|
2463
2505
|
minWidth: "12px"
|
|
2464
2506
|
},
|
|
@@ -2472,7 +2514,8 @@ var searchTheme = import_view2.EditorView.baseTheme({
|
|
|
2472
2514
|
fontSize: "inherit"
|
|
2473
2515
|
},
|
|
2474
2516
|
"& .helix-search-count": {
|
|
2475
|
-
color: "
|
|
2517
|
+
color: "inherit",
|
|
2518
|
+
opacity: "0.5",
|
|
2476
2519
|
fontSize: "0.8em",
|
|
2477
2520
|
minWidth: "60px",
|
|
2478
2521
|
textAlign: "right"
|
|
@@ -2681,13 +2724,13 @@ var multiSelectTheme = import_view3.EditorView.baseTheme({
|
|
|
2681
2724
|
alignItems: "center",
|
|
2682
2725
|
padding: "4px 8px",
|
|
2683
2726
|
gap: "6px",
|
|
2684
|
-
borderTop: "1px solid var(--helix-border, #
|
|
2685
|
-
background: "var(--helix-
|
|
2727
|
+
borderTop: "1px solid var(--helix-status-border, #999)",
|
|
2728
|
+
background: "var(--helix-status-bg, inherit)",
|
|
2686
2729
|
fontFamily: "monospace",
|
|
2687
2730
|
fontSize: "14px"
|
|
2688
2731
|
},
|
|
2689
2732
|
".helix-multiselect-prefix": {
|
|
2690
|
-
color: "var(--helix-
|
|
2733
|
+
color: "var(--helix-normal-color, #0080e0)",
|
|
2691
2734
|
fontWeight: "bold",
|
|
2692
2735
|
whiteSpace: "nowrap"
|
|
2693
2736
|
},
|
|
@@ -3800,12 +3843,99 @@ function buildHelixKeymap() {
|
|
|
3800
3843
|
];
|
|
3801
3844
|
}
|
|
3802
3845
|
|
|
3846
|
+
// src/whichkey.ts
|
|
3847
|
+
var import_view7 = require("@codemirror/view");
|
|
3848
|
+
var MENUS = {
|
|
3849
|
+
goto: [
|
|
3850
|
+
["g", "file start"],
|
|
3851
|
+
["e", "file end"],
|
|
3852
|
+
["h", "line start"],
|
|
3853
|
+
["l", "line end"],
|
|
3854
|
+
["s", "first non-ws"],
|
|
3855
|
+
["t", "screen top"],
|
|
3856
|
+
["c", "screen middle"],
|
|
3857
|
+
["b", "screen bottom"],
|
|
3858
|
+
["j", "move down"],
|
|
3859
|
+
["k", "move up"],
|
|
3860
|
+
[".", "last change"],
|
|
3861
|
+
["w", "word jump"],
|
|
3862
|
+
["|", "column"]
|
|
3863
|
+
],
|
|
3864
|
+
view: [
|
|
3865
|
+
["z / c", "center"],
|
|
3866
|
+
["t", "scroll top"],
|
|
3867
|
+
["b", "scroll bottom"],
|
|
3868
|
+
["j / \u2193", "scroll down"],
|
|
3869
|
+
["k / \u2191", "scroll up"]
|
|
3870
|
+
],
|
|
3871
|
+
match: [
|
|
3872
|
+
["m", "matching bracket"],
|
|
3873
|
+
["s", "surround add"],
|
|
3874
|
+
["d", "surround delete"],
|
|
3875
|
+
["r", "surround replace"],
|
|
3876
|
+
["i", "select inside"],
|
|
3877
|
+
["a", "select around"]
|
|
3878
|
+
],
|
|
3879
|
+
bracket_next: [
|
|
3880
|
+
["p", "next paragraph"],
|
|
3881
|
+
["Space", "newline below"]
|
|
3882
|
+
],
|
|
3883
|
+
bracket_prev: [
|
|
3884
|
+
["p", "prev paragraph"],
|
|
3885
|
+
["Space", "newline above"]
|
|
3886
|
+
]
|
|
3887
|
+
};
|
|
3888
|
+
var TITLE = {
|
|
3889
|
+
goto: "goto",
|
|
3890
|
+
view: "view",
|
|
3891
|
+
match: "match",
|
|
3892
|
+
bracket_next: "]",
|
|
3893
|
+
bracket_prev: "["
|
|
3894
|
+
};
|
|
3895
|
+
function render(dom, view) {
|
|
3896
|
+
const hs = getHelixState(view.state);
|
|
3897
|
+
const entries = hs.pendingOp ? MENUS[hs.pendingOp.type] ?? null : null;
|
|
3898
|
+
if (!entries) {
|
|
3899
|
+
dom.style.display = "none";
|
|
3900
|
+
return;
|
|
3901
|
+
}
|
|
3902
|
+
dom.style.display = "";
|
|
3903
|
+
dom.innerHTML = "";
|
|
3904
|
+
const title = dom.appendChild(document.createElement("span"));
|
|
3905
|
+
title.className = "helix-whichkey-title";
|
|
3906
|
+
title.textContent = TITLE[hs.pendingOp.type] ?? "";
|
|
3907
|
+
for (const [key, desc] of entries) {
|
|
3908
|
+
const item = dom.appendChild(document.createElement("span"));
|
|
3909
|
+
item.className = "helix-whichkey-item";
|
|
3910
|
+
const keyEl = item.appendChild(document.createElement("span"));
|
|
3911
|
+
keyEl.className = "helix-whichkey-key";
|
|
3912
|
+
keyEl.textContent = key;
|
|
3913
|
+
const descEl = item.appendChild(document.createElement("span"));
|
|
3914
|
+
descEl.className = "helix-whichkey-desc";
|
|
3915
|
+
descEl.textContent = desc;
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
var whichKeyExtension = import_view7.showPanel.of((view) => {
|
|
3919
|
+
const dom = document.createElement("div");
|
|
3920
|
+
dom.className = "helix-whichkey-panel";
|
|
3921
|
+
render(dom, view);
|
|
3922
|
+
return {
|
|
3923
|
+
dom,
|
|
3924
|
+
top: false,
|
|
3925
|
+
update(u) {
|
|
3926
|
+
const prev = getHelixState(u.startState).pendingOp;
|
|
3927
|
+
const next = getHelixState(u.state).pendingOp;
|
|
3928
|
+
if (prev !== next) render(dom, u.view);
|
|
3929
|
+
}
|
|
3930
|
+
};
|
|
3931
|
+
});
|
|
3932
|
+
|
|
3803
3933
|
// src/index.ts
|
|
3804
3934
|
function helixKeymap(options = {}) {
|
|
3805
3935
|
const { defaultMode = "normal", statusBar = true } = options;
|
|
3806
3936
|
const extensions = [
|
|
3807
3937
|
// Core state
|
|
3808
|
-
|
|
3938
|
+
import_state19.EditorState.allowMultipleSelections.of(true),
|
|
3809
3939
|
helixStateField,
|
|
3810
3940
|
searchStateField,
|
|
3811
3941
|
multiSelectStateField,
|
|
@@ -3824,6 +3954,7 @@ function helixKeymap(options = {}) {
|
|
|
3824
3954
|
// Panels
|
|
3825
3955
|
searchPanelExtension,
|
|
3826
3956
|
multiSelectPanelExtension,
|
|
3957
|
+
whichKeyExtension,
|
|
3827
3958
|
// Keybindings + input blocking
|
|
3828
3959
|
...buildHelixKeymap()
|
|
3829
3960
|
];
|