A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: Ctrl-A in console output selects all the output (#5360)
Myles Scolnick06a98eecf19e
diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjsindex a5c7c10af3..febc3618da 100644--- a/frontend/.eslintrc.cjs+++ b/frontend/.eslintrc.cjs@@ -13,8 +13,6 @@ module.exports = {"plugin:@typescript-eslint/recommended-type-checked","plugin:@typescript-eslint/stylistic-type-checked","plugin:@typescript-eslint/strict-type-checked",- // Accessibility- "plugin:jsx-a11y/strict",// React"plugin:react-hooks/recommended-legacy","plugin:react/recommended",@@ -84,10 +82,6 @@ module.exports = {"@typescript-eslint/consistent-indexed-object-style": "off","@typescript-eslint/require-await": "off","@typescript-eslint/restrict-template-expressions": "off",- "jsx-a11y/no-autofocus": "off",- "jsx-a11y/no-static-element-interactions": "off",- "jsx-a11y/no-noninteractive-element-interactions": "off",- "jsx-a11y/click-events-have-key-events": "off","storybook/no-redundant-story-name": "off",// Turn of unicorn rules that don't have autofixes or that we don't want"unicorn/prefer-string-raw": "off",diff --git a/frontend/package.json b/frontend/package.jsonindex 378eabe687..f2b10c6e71 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -217,7 +217,6 @@"cross-env": "^7.0.3","eslint": "^8.57.0","eslint-config-prettier": "^9.1.0",- "eslint-plugin-jsx-a11y": "^6.9.0","eslint-plugin-react": "^7.34.3","eslint-plugin-react-hooks": "^6.0.0-rc.1","eslint-plugin-ssr-friendly": "^1.3.0",diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yamlindex 2fa0d3f8ed..5df3d5ae52 100644--- a/frontend/pnpm-lock.yaml+++ b/frontend/pnpm-lock.yaml@@ -547,9 +547,6 @@ importers:eslint-config-prettier:specifier: ^9.1.0version: 9.1.0([email protected])- eslint-plugin-jsx-a11y:- specifier: ^6.9.0- version: 6.9.0([email protected])eslint-plugin-react:specifier: ^7.34.3version: 7.34.3([email protected])@@ -4206,9 +4203,6 @@ packages:resolution: {integrity: sha512-y+CcFFwelSXpLZk/7fMB2mUbGtX9lKycf1MWJ7CaTIERyitVlyQx6C+sxcROU2BAJ24OiZyK+8wj2i8AlBoS3A==}engines: {node: '>=10'}- resolution: {integrity: sha512-R5iJ5lkuHybztUfuOAznmboyjWq8O6sqNqtK7CLOqdydi54VNbORp49mb14KbWgG1QD3JFO9hJdZ+y4KutfdOQ==}-resolution: {integrity: sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==}@@ -4281,9 +4275,6 @@ packages:resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}engines: {node: '>=12'}- resolution: {integrity: sha512-OH/2E5Fg20h2aPrbe+QL8JZQFko0YZaF+j4mnQ7BGhfavO7OpSLa8a0y9sBwomHdSbkhTS8TQNayBfnW5DwbvQ==}-resolution: {integrity: sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==}engines: {node: '>=4'}@@ -4316,13 +4307,6 @@ packages:resolution: {integrity: sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg==}- resolution: {integrity: sha512-QbUdXJVTpvUTHU7871ppZkdOLBeGUKBQWHkHrvN2V9IQWGMt61zf3B45BtzjxEJzYuj0JBjBZP/hmYS/R9pmAw==}- engines: {node: '>=4'}-- resolution: {integrity: sha512-goKlv8DZrK9hUh975fnHzhNIO4jUnFCfv/dszV5VwUGDFjI6vQ2VwoyjYjYNEbBE8AH87TduWP5uyDR1D+Iteg==}-resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}engines: {node: '>=10', npm: '>=6'}@@ -5028,9 +5012,6 @@ packages:resolution: {integrity: sha512-tvlJLyQf834SylNKax8Wkzco/1ias1OPw8DcUMDE7oUIoSEW25riQVuiu/0OWEFqT0cxHT3Pa9/D82Jr47IONw==}- resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==}-resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==}engines: {node: '>=0.10'}@@ -5099,10 +5080,6 @@ packages:resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}engines: {node: '>=6'}- resolution: {integrity: sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==}- engines: {node: '>= 0.4'}-resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}@@ -5280,9 +5257,6 @@ packages:resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==}engines: {node: '>= 0.4'}- resolution: {integrity: sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==}-resolution: {integrity: sha512-zoMwbCcH5hwUkKJkT8kDIBZSz9I6mVG//+lDCinLCGov4+r7NIy0ld8o03M0cJxl2spVf6ESYVS6/gpIfq1FFw==}engines: {node: '>= 0.4'}@@ -5361,12 +5335,6 @@ packages:peerDependencies:eslint: '>=7.7.0'- resolution: {integrity: sha512-nOFOCaJG2pYqORjK19lqPqxMO/JpvdCZdPtNdxY3kvom3jTvkAbOvQvD8wuD0G8BYR0IGAGYDlzqWJOh/ybn2g==}- engines: {node: '>=4.0'}- peerDependencies:- eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8-resolution: {integrity: sha512-NyC3yIC9fazLitYiN8eHykV5wLp/SMuUZMh+sdPSHIeN4ReXIc7if40jtGjDplAgVL/4OkN1d9gneWe9lFZgag==}engines: {node: '>=18'}@@ -6420,13 +6388,6 @@ packages:resolution: {integrity: sha512-QJv/h939gDpvT+9SiLVlY7tZC3xB2qK57v0J04Sh9wpMb6MP1q8gB21L3WIo8T5P1MSMg3Ep14L7KkDCFG3y4w==}engines: {node: '>=16.0.0'}- resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==}-- resolution: {integrity: sha512-MbjN408fEndfiQXbFQ1vnd+1NoLDsnQW41410oQBXiyXDMYH5z505juWa4KUE1LqxRC7DgOgZDbKLxHIwm27hA==}- engines: {node: '>=0.10'}-resolution: {integrity: sha512-8h2oVEZNktL4BH2JCOI90iD1yXwL6iNW7KcCKT2QZgQJR2vbqDsldCTPRU9NifTCqHZci57XvQQ15YTu+sTYPg==}@@ -6889,10 +6850,6 @@ packages:resolution: {integrity: sha512-wqdhLpfCUbEsoEwl3FXwGyv8ief1k/1aUdIPCqVnupM6e8l63BEJdiF/0swtn04/8p05tG/T0FrpTlfwvljOdw==}- resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==}- engines: {node: '>= 0.4'}-resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}engines: {node: '>= 0.4'}@@ -8058,10 +8015,6 @@ packages:resolution: {integrity: sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==}- resolution: {integrity: sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==}- engines: {node: '>= 0.4'}-resolution: {integrity: sha512-sVKbCj/OTx67jhmauhxc2dcr1P+yOgz/x3h0krwjyMgdc5Oubvxyg4NYDZmzAw+ym36g/lzH8N0Ccp4dwtdfxw==}hasBin: true@@ -8106,9 +8059,6 @@ packages:resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}engines: {node: '>=12'}- resolution: {integrity: sha512-E34CkBgyeqNDcrbU76cDjL5JLcVrtSdYq0MEh/B10r17pRP4ciHLwTgnuLV8Ay6cgEMLkcBkFCKyFZ43YldYzg==}-resolution: {integrity: sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==}engines: {node: '>= 0.4'}@@ -13795,10 +13745,6 @@ snapshots:dependencies:tslib: 2.8.1- dependencies:- deep-equal: 2.2.3-dependencies:dequal: 2.0.3@@ -13892,8 +13838,6 @@ snapshots:- [email protected]: {}-dependencies:tslib: 2.8.1@@ -13922,12 +13866,6 @@ snapshots:- [email protected]: {}-- dependencies:- deep-equal: 2.2.3-dependencies:'@babel/runtime': 7.27.6@@ -14715,8 +14653,6 @@ snapshots:d3: 7.9.0lodash-es: 4.17.21- [email protected]: {}-dependencies:assert-plus: 1.0.0@@ -14780,27 +14716,6 @@ snapshots:- dependencies:- array-buffer-byte-length: 1.0.1- call-bind: 1.0.7- es-get-iterator: 1.1.3- get-intrinsic: 1.2.4- is-arguments: 1.1.1- is-array-buffer: 3.0.4- is-date-object: 1.0.5- is-regex: 1.1.4- is-shared-array-buffer: 1.0.3- isarray: 2.0.5- object-is: 1.1.5- object-keys: 1.1.1- object.assign: 4.1.5- regexp.prototype.flags: 1.5.2- side-channel: 1.0.6- which-boxed-primitive: 1.0.2- which-collection: 1.0.1- which-typed-array: 1.1.15-@@ -15018,18 +14933,6 @@ snapshots:- dependencies:- call-bind: 1.0.7- get-intrinsic: 1.2.4- has-symbols: 1.0.3- is-arguments: 1.1.1- is-map: 2.0.2- is-set: 2.0.2- is-string: 1.0.7- isarray: 2.0.5- stop-iteration-iterator: 1.0.0-dependencies:call-bind: 1.0.7@@ -15160,26 +15063,6 @@ snapshots:dependencies:eslint: 8.57.0- dependencies:- aria-query: 5.1.3- array-includes: 3.1.8- array.prototype.flatmap: 1.3.2- ast-types-flow: 0.0.8- axe-core: 4.9.1- axobject-query: 3.1.1- damerau-levenshtein: 1.0.8- emoji-regex: 9.2.2- es-iterator-helpers: 1.0.19- eslint: 8.57.0- hasown: 2.0.2- jsx-ast-utils: 3.3.5- language-tags: 1.0.9- minimatch: 3.1.2- object.fromentries: 2.0.8- safe-regex-test: 1.0.3- string.prototype.includes: 2.0.0-dependencies:'@babel/core': 7.27.4@@ -16327,12 +16210,6 @@ snapshots:vscode-languageserver-textdocument: 1.0.12vscode-uri: 3.0.8- [email protected]: {}-- dependencies:- language-subtag-registry: 0.3.22-@@ -16982,11 +16859,6 @@ snapshots:- dependencies:- call-bind: 1.0.7- define-properties: 1.2.1-@@ -18441,10 +18313,6 @@ snapshots:- dependencies:- internal-slot: 1.0.7-dependencies:'@storybook/core': 8.6.14([email protected])@@ -18495,11 +18363,6 @@ snapshots:emoji-regex: 9.2.2strip-ansi: 7.1.0- dependencies:- define-properties: 1.2.1- es-abstract: 1.23.3-dependencies:call-bind: 1.0.7diff --git a/frontend/src/components/editor/file-tree/renderers.tsx b/frontend/src/components/editor/file-tree/renderers.tsxindex dffa9c7499..5b3dc2ce51 100644--- a/frontend/src/components/editor/file-tree/renderers.tsx+++ b/frontend/src/components/editor/file-tree/renderers.tsx@@ -59,7 +59,6 @@ export const AudioViewer: React.FC<{ base64: Base64String; mime: string }> = ({mime,base64,}) => {- // eslint-disable-next-line jsx-a11y/media-has-captionreturn <audio controls={true} src={base64ToDataURL(base64, mime)} />;};@@ -67,7 +66,6 @@ export const VideoViewer: React.FC<{ base64: Base64String; mime: string }> = ({mime,base64,}) => {- // eslint-disable-next-line jsx-a11y/media-has-captionreturn <video controls={true} src={base64ToDataURL(base64, mime)} />;};diff --git a/frontend/src/components/editor/output/ConsoleOutput.tsx b/frontend/src/components/editor/output/ConsoleOutput.tsxindex 45f44d662d..3922501ea5 100644--- a/frontend/src/components/editor/output/ConsoleOutput.tsx+++ b/frontend/src/components/editor/output/ConsoleOutput.tsx@@ -9,6 +9,7 @@ import type { CellId } from "@/core/cells/ids";import { isInternalCellName } from "@/core/cells/names";import type { WithResponse } from "@/core/cells/types";import type { OutputMessage } from "@/core/kernel/messages";+import { useSelectAllContent } from "@/hooks/useSelectAllContent";import { cn } from "@/utils/cn";import { invariant } from "@/utils/invariant";import { NameCellContentEditable } from "../actions/name-cell-input";@@ -63,6 +64,9 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {const hasOutputs = consoleOutputs.length > 0;+ // Enable Ctrl/Cmd-A to select all content within the console output+ useSelectAllContent(ref, hasOutputs);+// Keep scroll at the bottom if it is within 120px of the bottom,// so when we add new content, it will lock to the bottom//@@ -106,8 +110,10 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {title={stale ? "This console output is stale" : undefined}data-testid="console-output-area"ref={ref}+ // biome-ignore lint/a11y/noNoninteractiveTabindex: Needed to capture keypress events+ tabIndex={0}className={cn(- "console-output-area overflow-hidden rounded-b-lg flex flex-col-reverse w-full gap-1",+ "console-output-area overflow-hidden rounded-b-lg flex flex-col-reverse w-full gap-1 focus:outline-none",stale && "marimo-output-stale",hasOutputs ? "p-5" : "p-3",className,diff --git a/frontend/src/components/editor/output/VideoOutput.tsx b/frontend/src/components/editor/output/VideoOutput.tsxindex 36b2e81e43..67f2280ebf 100644--- a/frontend/src/components/editor/output/VideoOutput.tsx+++ b/frontend/src/components/editor/output/VideoOutput.tsx@@ -7,8 +7,5 @@ interface Props {}export const VideoOutput = ({ src, className }: Props): JSX.Element => {- return (- // eslint-disable-next-line jsx-a11y/iframe-has-title- <iframe className={className} src={src} />- );+ return <iframe className={className} src={src} />;};diff --git a/frontend/src/components/ui/typography.tsx b/frontend/src/components/ui/typography.tsxindex 64e428a84c..2800f60a8b 100644--- a/frontend/src/components/ui/typography.tsx+++ b/frontend/src/components/ui/typography.tsx@@ -1,5 +1,4 @@/* Copyright 2024 Marimo. All rights reserved. */-/* eslint-disable jsx-a11y/heading-has-content */import * as React from "react";import { cn } from "@/utils/cn";diff --git a/frontend/src/hooks/useSelectAllContent.ts b/frontend/src/hooks/useSelectAllContent.tsnew file mode 100644index 0000000000..5dd01c05a5--- /dev/null+++ b/frontend/src/hooks/useSelectAllContent.ts@@ -0,0 +1,50 @@+/* Copyright 2024 Marimo. All rights reserved. */+import type { RefObject } from "react";+import { useEventListener } from "./useEventListener";++/**+ * Hook that enables Ctrl/Cmd-A to select all text content within a specific element+ * @param ref - React ref to the element whose content should be selectable+ * @param enabled - Whether the hook should be active (defaults to true)+ */+export function useSelectAllContent<T extends HTMLElement>(+ ref: RefObject<T | null>,+ enabled = true,+) {+ const handleKeyDown = (event: KeyboardEvent) => {+ if (!enabled) {+ return;+ }++ const element = ref.current;+ if (!element) {+ return;+ }++ // Check for Ctrl-A (Windows/Linux) or Cmd-A (Mac)+ const isSelectAll =+ event.key.toLowerCase() === "a" && (event.ctrlKey || event.metaKey);++ if (!isSelectAll) {+ return;+ }++ // Prevent default browser select-all behavior+ event.preventDefault();+ event.stopPropagation();++ // Create selection of all content within the element+ const selection = window.getSelection();+ if (!selection) {+ return;+ }++ const range = document.createRange();+ range.selectNodeContents(element);++ selection.removeAllRanges();+ selection.addRange(range);+ };++ useEventListener(ref, "keydown", handleKeyDown);+}