sound.",
+ example: "sound('bd').out()",
+ },
+ bpm: {
+ name: "bpm",
+ category: "time",
+ description: "Get or set the current beats per minute.",
+ example: "bpm(135) // set the bpm to 135",
+ },
+ out: {
+ name: "out",
+ category: "audio",
+ description: "Connect the sound() chain to the output",
+ example: "sound('clap').out()",
+ },
+};
+
+export const inlineHoveringTips = hoverTooltip(
+ (view: any, pos: any, side: any) => {
+ let { from, to, text } = view.state.doc.lineAt(pos);
+ let start = pos,
+ end = pos;
+ while (start > from && /\w/.test(text[start - from - 1])) start--;
+ while (end < to && /\w/.test(text[end - from])) end++;
+ if ((start == pos && side < 0) || (end == pos && side > 0)) return null;
+ return {
+ pos: start,
+ end,
+ above: true,
+ create(view: EditorView) {
+ if (
+ text.slice(start - from, end - from) in completionDatabase ===
+ false
+ ) {
+ return { dom: document.createElement("div") };
+ }
+ let completion =
+ completionDatabase[text.slice(start - from, end - from)] || {};
+ let divContent = `
+ ${completion.name} [${completion.category}]
+ ${completion.description}
+ ${completion.example}
+ `;
+ let dom = document.createElement("div");
+ dom.classList.add("px-4", "py-2", "bg-neutral-700", "rounded-lg");
+ dom.innerHTML = divContent;
+ return { dom };
+ },
+ };
+ }
+);