rwb-codemirror-helix 0.2.2 → 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 +132 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +130 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
|
@@ -3802,12 +3843,99 @@ function buildHelixKeymap() {
|
|
|
3802
3843
|
];
|
|
3803
3844
|
}
|
|
3804
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
|
+
|
|
3805
3933
|
// src/index.ts
|
|
3806
3934
|
function helixKeymap(options = {}) {
|
|
3807
3935
|
const { defaultMode = "normal", statusBar = true } = options;
|
|
3808
3936
|
const extensions = [
|
|
3809
3937
|
// Core state
|
|
3810
|
-
|
|
3938
|
+
import_state19.EditorState.allowMultipleSelections.of(true),
|
|
3811
3939
|
helixStateField,
|
|
3812
3940
|
searchStateField,
|
|
3813
3941
|
multiSelectStateField,
|
|
@@ -3826,6 +3954,7 @@ function helixKeymap(options = {}) {
|
|
|
3826
3954
|
// Panels
|
|
3827
3955
|
searchPanelExtension,
|
|
3828
3956
|
multiSelectPanelExtension,
|
|
3957
|
+
whichKeyExtension,
|
|
3829
3958
|
// Keybindings + input blocking
|
|
3830
3959
|
...buildHelixKeymap()
|
|
3831
3960
|
];
|