A programming framework for agentic AI
Keyboard copy event and search bar cancellation (#5820)
peterychang92d857f6b467
diff --git a/python/packages/autogen-core/docs/src/_static/custom.css b/python/packages/autogen-core/docs/src/_static/custom.cssindex 243fb7d43..ed7edce8d 100644--- a/python/packages/autogen-core/docs/src/_static/custom.css+++ b/python/packages/autogen-core/docs/src/_static/custom.css@@ -112,7 +112,11 @@ html[data-theme="light"] .bd-header {margin-right: 5px;}+/* This is gross, but necessary to meet accessibility requirements */+.headerlink {+ visibility: visible !important;+}/* jupyter notebook output cells */.bd-article .docutils .cell_output .output .highlight > pre:focus-visible{border: 2px outset var(--pst-color-secondary);-}\ No newline at end of file+}diff --git a/python/packages/autogen-core/docs/src/_static/custom.js b/python/packages/autogen-core/docs/src/_static/custom.jsnew file mode 100644index 000000000..e469c45ca--- /dev/null+++ b/python/packages/autogen-core/docs/src/_static/custom.js@@ -0,0 +1,43 @@+document.addEventListener('DOMContentLoaded', function() {+ document.querySelectorAll('.copybtn').forEach(button => {+ button.addEventListener('click', async function(event) {+ // Save the current focus+ const focusedElement = document.activeElement;++ // Perform the copy action+ await copyToClipboard(this);++ // Restore the focus+ focusedElement.focus();+ });+ });++ document.querySelectorAll('.search-button-field').forEach(button => {+ button.addEventListener('click', () => {+ // Save the element that had focus before opening the search+ const previousFocus = document.activeElement;++ // Logic to open the search goes here++ // Add an event listener to handle closing the search+ document.addEventListener('keydown', (event) => {+ if (event.key === 'Escape') {+ // Logic to close the search goes here++ // Restore focus to the previous element+ previousFocus.focus();+ }+ });+ });+ });+});++async function copyToClipboard(button) {+ const targetSelector = button.getAttribute('data-clipboard-target');+ const codeBlock = document.querySelector(targetSelector);+ try {+ await navigator.clipboard.writeText(codeBlock.textContent);+ } catch (err) {+ console.error('Failed to copy text: ', err);+ }+}\ No newline at end of filediff --git a/python/packages/autogen-core/docs/src/conf.py b/python/packages/autogen-core/docs/src/conf.pyindex 98d8dc67f..7f7cf2513 100644--- a/python/packages/autogen-core/docs/src/conf.py+++ b/python/packages/autogen-core/docs/src/conf.py@@ -136,7 +136,7 @@ html_theme_options = {]}-html_js_files = ["custom-icon.js", "banner-override.js"]+html_js_files = ["custom-icon.js", "banner-override.js", "custom.js"]html_sidebars = {"packages/index": [],"user-guide/core-user-guide/**": ["sidebar-nav-bs-core"],