Skip to content

Commit ef01b11

Browse files
chore: add quick keyboard shortcut to open kapa (#5876) (#5909)
* feat: add kapa branch * docs: add kapa widget * docs: update logo * docs: add consent screen * docs: static script * docs: fix script issue * docs: change back to online loading for test * docs: cors anonymous * docs: revert back to lonline loading * Update docusaurus.config.js * Update docusaurus.config.js * Update docusaurus.config.js * docs: change source script location * ci: auto-formatting prettier issues * docs: change logos and theme colors DOC-1587 * docs: further styling * docs: style packs component * docs: style cve table * docs: style getting started cards * docs: change font * docs: adjust size of logo and points of interest * ci: auto-formatting prettier issues * Optimised images with calibre/image-actions * docs: style tooltips * docs: change color of privacy link * docs: update background color * docs: update styles * docs: remove tags from underlines * docs: fix navbar color and add 10% opacity to admonitions * docs: style as support chat * docs: style kapa * docs: adjust color * docs: edit eslint ignore * docs: fix eslint * docs: add disclaimer * docs: remove old logo * docs: add command to bring up chat * docs: add browser shortcut * docs: comment out shortcut script * docs: undo temporary netlify change * docs: add release notes snippets * docs: punctuation * docs: remove netlify changes * docs: keep favicon the same * chore: add shortcut to open * docs: modify dialog location * docs: add keyboard shortcut --------- Co-authored-by: addetz <[email protected]> Co-authored-by: vault-token-factory-spectrocloud[bot] <133815545+vault-token-factory-spectrocloud[bot]@users.noreply.github.com> (cherry picked from commit a4a9a02) Co-authored-by: Lenny Chen <[email protected]>
1 parent 055be9d commit ef01b11

File tree

5 files changed

+46
-47772
lines changed

5 files changed

+46
-47772
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ vale/
77
**/*.yaml
88
**/*.yml
99
.dockerignore
10+
static/scripts/kapa-widget.bundle.js
1011

1112
docs/api-content/**/*.json
1213

docs/docs-content/release-notes/release-notes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ tags: ["release-notes"]
1414
## February 21, 2025 - Documentation & Education Updates
1515

1616
- The Documentation & Education team is enabling a new Q&A bot functionality on the Spectro Cloud official documentation
17-
site. Click the **Ask AI** widget in the bottom right corner to bring up the chat interface.
17+
site. Click the **Ask AI** widget in the bottom right corner or use the **Ctrl + I** (**Cmd + I** on macOS) keyboard
18+
shortcut to bring up the chat interface.
1819

1920
The Q&A bot is only trained on the latest version of the Spectro Cloud documentation. It is unable to answer
2021
version-specific questions. As with all generative AI-powered services, its responses may not be accurate. Always

docusaurus.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const config = {
261261
},
262262
{
263263
src: "/scripts/kapa-shortcut.js",
264-
async: true,
264+
async: false,
265265
},
266266
{
267267
src: "/scripts/kapa-widget.bundle.js",
@@ -287,6 +287,7 @@ const config = {
287287
"data-conversation-button-icons-only": "true",
288288
"data-modal-size": "80%",
289289
"data-modal-lock-scroll": "false",
290+
"data-modal-inner-position-left": "auto",
290291
async: true,
291292
},
292293
{

static/scripts/kapa-shortcut.js

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1-
// (function () {
2-
// let k = window.Kapa;
3-
// if (!k) {
4-
// let i = function () {
5-
// i.c(arguments);
6-
// };
7-
// i.q = [];
8-
// i.c = function (args) {
9-
// i.q.push(args);
10-
// };
11-
// window.Kapa = i;
12-
// }
13-
// })();
1+
(function () {
2+
let k = window.Kapa;
3+
if (!k) {
4+
let i = function () {
5+
i.c(arguments);
6+
};
7+
i.q = [];
8+
i.c = function (args) {
9+
i.q.push(args);
10+
};
11+
window.Kapa = i;
12+
}
13+
})();
1414

15-
// document.addEventListener("keydown", function (event) {
16-
// if ((event.ctrlKey || event.metaKey) && event.key === "i") {
17-
// event.preventDefault();
18-
// console.log("Kapa shortcut triggered");
19-
// window.Kapa("open");
20-
// }
21-
// });
15+
document.addEventListener("keydown", function (event) {
16+
if ((event.ctrlKey || event.metaKey) && event.key === "i") {
17+
event.preventDefault();
18+
19+
// Get the shadow root of the Kapa widget
20+
const kapaContainer = document.querySelector("#kapa-widget-container");
21+
const shadowRoot = kapaContainer?.shadowRoot;
22+
23+
if (!shadowRoot) return; // Exit if the shadow root is not found
24+
25+
// Navigate inside the shadow DOM to find the modal
26+
const kapaPortal = shadowRoot.querySelector("#kapa-widget-portal");
27+
28+
if (!kapaPortal) return; // Exit if the portal is not found
29+
30+
// Now we can access the actual modal element
31+
const modal = kapaPortal.querySelector(".mantine-Modal-root"); // Adjust selector as needed
32+
33+
if (modal && modal.children.length > 0) {
34+
// Modal is open → Close it
35+
window.Kapa("close");
36+
} else {
37+
// Modal is closed or not found → Open it
38+
window.Kapa("open");
39+
}
40+
}
41+
});

0 commit comments

Comments
 (0)