diff --git a/code_editor/__init__.py b/code_editor/__init__.py index 088457f3a..94d91d03c 100644 --- a/code_editor/__init__.py +++ b/code_editor/__init__.py @@ -172,7 +172,7 @@ def code_editor(code, lang='python', theme="default", shortcuts="vscode", height ace_props = {"style": {"borderRadius": "0px 0px 8px 8px"}} input = st.text_area("Input:", demo_sample_python_code, height=200) - response_dict = code_editor(input, height = height, lang=language, theme=theme, shortcuts=shortcuts, focus=focus, buttons=btns, info=info_bar, props=ace_props, options={"wrap": wrap}) + response_dict = code_editor(input, height = height, lang=language, theme=theme, shortcuts=shortcuts, focus=focus, buttons=btns, info=info_bar, props=ace_props, options={"wrap": wrap}, allow_reset=True, key="code_editor_demo") if response_dict['type'] == "submit" and len(response_dict['text']) != 0: st.write("Response type: ", response_dict['type']) diff --git a/code_editor/frontend/node_modules/.cache/babel-loader/0c07d4e0763cd385884143ff9e0a4ac1.json b/code_editor/frontend/node_modules/.cache/babel-loader/0c07d4e0763cd385884143ff9e0a4ac1.json new file mode 100644 index 000000000..0ee40e2a5 --- /dev/null +++ b/code_editor/frontend/node_modules/.cache/babel-loader/0c07d4e0763cd385884143ff9e0a4ac1.json @@ -0,0 +1 @@ +{"ast":null,"code":"import _styled2 from \"styled-components\";\nimport { createGlobalStyle as _createGlobalStyle } from \"styled-components\";\nimport _styled from \"styled-components\";\nvar _jsxFileName = \"/home/anasbouzid/streamlit-code-editor/code_editor/frontend/src/CodeEditor.tsx\",\n _s = $RefreshSig$();\nimport { Streamlit, withStreamlitConnection } from \"streamlit-component-lib\";\nimport { useState, useRef, useEffect, useMemo } from \"react\";\nimport ace from \"ace-builds\";\nimport { Editor } from './editor';\nimport { Menu as ButtonMenu, Set as ButtonSet, Info as InfoBar } from \"./button-menu\";\nimport \"ace-builds/webpack-resolver\";\nimport \"ace-builds/src-noconflict/mode-python\";\nimport \"ace-builds/src-noconflict/mode-javascript\";\nimport \"ace-builds/src-noconflict/ext-language_tools\";\nimport \"ace-builds/src-noconflict/ext-searchbox\";\nimport \"ace-builds/src-noconflict/ext-prompt\";\nimport \"ace-builds/src-noconflict/ext-modelist\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst defaultOptions = {\n fontFamily: '\"Source Code Pro\", monospace',\n cursorStyle: \"smooth\",\n displayIndentGuides: false,\n wrap: false,\n highlightActiveLine: true,\n showPrintMargin: false,\n showLineNumbers: false,\n foldStyle: \"markbegin\",\n autoScrollEditorIntoView: false,\n animatedScroll: true,\n fadeFoldWidgets: true\n};\nconst defaultEditorProps = {\n editorProps: {\n $blockScrolling: true\n }\n};\nconst defaultProps = {\n cursorStart: 1,\n enableBasicAutocompletion: false,\n enableLiveAutocompletion: true,\n enableSnippets: true,\n focus: false,\n fontSize: 14,\n highlightActiveLine: true,\n navigateToFileEnd: true,\n placeholder: null,\n readOnly: false,\n scrollMargin: [15, 15, 0, 0],\n setOptions: defaultOptions,\n showGutter: true,\n showPrintMargin: false,\n style: {},\n tabSize: 4,\n width: \"auto\",\n debounceChangePeriod: 250\n};\nconst GlobalCSS = _createGlobalStyle`\n html {\n opacity: ${props => props.isDisabled ? \"0.5\" : \"1\"};\n cursor: ${props => props.isDisabled ? \"not-allowed\" : \"auto\"};\n pointer-events: ${props => props.isDisabled ? \"none\" : \"auto\"};\n }\n body {\n margin: 0;\n padding: 0;\n }\n ${props => props.inject}\n`;\n_c = GlobalCSS;\nconst StyledCodeEditor = _styled.div.withConfig({\n displayName: \"CodeEditor__StyledCodeEditor\",\n componentId: \"sc-wmif04-0\"\n})([\"width:100%;border-radius:8px;overflow:hidden;display:flex;flex-direction:column;:hover button{opacity:1;transform:scale(1);}button.always-on{opacity:1;transform:scale(1);transition:none;}:hover button svg{opacity:1;transform:scale(1);}:hover button.with-icon span{opacity:1;transform:scale(1);}button.always-on > span{opacity:1;transform:scale(1);transition:none;}button.always-on > svg{opacity:1;transform:scale(1);transition:none;}\"]);\nvar _StyledStyledCodeEditor = _styled(StyledCodeEditor).withConfig({\n displayName: \"CodeEditor___StyledStyledCodeEditor\",\n componentId: \"sc-wmif04-1\"\n})([\"\", \"\"], p => p.$_css);\nconst CodeEditor = _ref => {\n _s();\n var _ref3;\n let {\n args,\n width,\n disabled,\n theme\n } = _ref;\n //sets code to the initial value every time the component is rendered\n //to set the initial value once, use a function instead of a value.\n const [code, setCode] = useState(args['code']);\n // const [keybindingAddRemove, setKeybindingAddRemove] = useState([\"\",\"\"]);\n\n const aceEditor = useRef(null);\n const infoTextRef = useRef(null);\n const baseSession = useRef(null);\n const keepFocus = useRef(false);\n const reset = useRef(false);\n var timeoutId;\n\n /**\n * This function takes as input either a snippetText string that is expected\n * to be already formatted like the text in a SnippetFile or a dictionary or \n * and array of dictionaries. For the first case, it just returns the input.\n * For the second and third case, a (SnippetFile format) string is constructed\n * from the dict(s) and returned. Learn more about snippets {@link here}\n * @param snippetRaw snippets to be converted to a single snippetText string\n * @returns {string} snippetText\n */\n const createSnippets = snippetRaw => {\n return typeof snippetRaw === \"string\" ? snippetRaw : (Array.isArray(snippetRaw) ? snippetRaw : [snippetRaw]).map(_ref2 => {\n let {\n name,\n code\n } = _ref2;\n return ['snippet ' + name, code.split('\\n').map(c => '\\t' + c).join('\\n')].join('\\n');\n }).join('\\n');\n };\n const [snippetAddRemove, setSnippetAddRemove] = useState({\n [args['lang']]: [createSnippets(args[\"snippets\"][0]), createSnippets(args[\"snippets\"][1])]\n });\n const [keybindingAddRemove, setKeybindingAddRemove] = useState(args['keybindings']);\n useEffect(() => {\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n }, []);\n useEffect(() => {\n if (aceEditor.current && keepFocus.current) {\n aceEditor.current.editor.focus();\n keepFocus.current = false;\n }\n }, [keepFocus.current]);\n\n // To reasons for the useEffect here: \n // 1. to set the focus on the editor only when the focus argument has changed to true.\n // 2. to set the focus on the editor after rendering the component at which point, the \n // editor should be ready.\n useEffect(() => {\n if (aceEditor.current && args.focus) {\n aceEditor.current.editor.focus();\n }\n }, [args.focus]);\n const onChangeHandler = newCode => {\n setCode(newCode);\n };\n\n // commands is an array of objects containing functions\n // that the editor can be triggered to call.\n const commands = {\n commands: [{\n name: 'submit',\n //name for the key binding.\n description: \"Send 'submit' response\",\n //description of the command\n bindKey: {\n win: 'Ctrl-Enter',\n mac: 'Command-Enter'\n },\n //key combination used for the command.\n exec: editor => {\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n Streamlit.setComponentValue({\n text: editor.getValue(),\n type: \"submit\",\n lang: outgoingMode\n });\n }\n }, {\n name: 'saveState',\n description: \"Save state\",\n bindKey: {\n win: 'Ctrl-Alt-S',\n mac: 'Command-Alt-S'\n },\n exec: editor => {\n setCode(editor.getValue());\n }\n }, {\n name: 'copyAll',\n description: \"Copy all text to clipboard\",\n exec: editor => {\n unsecureCopyTextToClipboard(editor.getValue());\n }\n }, {\n name: 'reset',\n exec: () => {\n resetEditor();\n }\n }, {\n name: 'keepFocus',\n description: \"Return cursor to editor\",\n exec: () => {\n keepFocus.current = true;\n }\n }, {\n name: \"setMode\",\n description: \"Set language mode\",\n exec: (editor, lang) => {\n if (lang && typeof lang === \"string\") editor.getSession().setMode(\"ace/mode/\" + lang);\n },\n readOnly: true\n }, {\n name: \"changeShortcuts\",\n description: \"Switch shortcuts\",\n exec: (editor, shortcuts) => {\n if (shortcuts && typeof shortcuts === \"string\") editor.setKeyboardHandler(\"ace/keyboard/\" + shortcuts);else {\n //rotate through the available keyboard handlers\n const handlers = [\"ace/keyboard/vim\", \"ace/keyboard/emacs\", \"ace/keyboard/sublime\", \"ace/keyboard/vscode\"];\n const currentHandler = handlers[(handlers.indexOf(editor.$keybindingId) + 1) % 4];\n editor.setKeyboardHandler(currentHandler);\n }\n },\n readOnly: true\n }, {\n name: 'toggleKeyboardShortcuts',\n exec: editor => {\n if (!document.getElementById('kbshortcutmenu')) editor.execCommand('showKeyboardShortcuts');else editor.execCommand('simulateKeyPress', {\n type: \"keydown\",\n keyCode: 27\n });\n }\n }, {\n name: 'simulateKeyPress',\n exec: (editor, args) => {\n if (args.key) document.dispatchEvent(new KeyboardEvent(args.type, {\n 'key': args.key\n }));else if (args.keyCode) document.dispatchEvent(new KeyboardEvent(args.type, {\n 'keyCode': args.keyCode\n }));\n }\n }, {\n name: 'infoMessage',\n description: \"Display message in info bar\",\n exec: (editor, args) => {\n if (args.targetQueryString) {\n const target = document.querySelector(args.targetQueryString);\n if (target) {\n target.innerText = args.text;\n target.classList.add(args.classToggle || \"\");\n if (args.timeout) {\n timeoutId = setTimeout(() => {\n target.classList.remove(args.classToggle || \"\");\n }, args.timeout);\n }\n }\n } else if (infoTextRef.current) {\n infoTextRef.current.innerText = args.text;\n infoTextRef.current.classList.add(args.classToggle || \"\");\n if (args.timeout) {\n timeoutId = setTimeout(() => {\n var _infoTextRef$current;\n (_infoTextRef$current = infoTextRef.current) === null || _infoTextRef$current === void 0 ? void 0 : _infoTextRef$current.classList.remove(args.classToggle || \"\");\n }, args.timeout);\n }\n }\n }\n }, {\n name: 'response',\n //name for the key binding.\n description: \"Send custom response\",\n //description of the command\n exec: function (editor) {\n let responseType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"\";\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n Streamlit.setComponentValue({\n text: code,\n type: responseType,\n lang: outgoingMode\n });\n }\n }, {\n name: 'editSnippets',\n description: \"Edit snippets\",\n bindKey: {\n win: 'Ctrl-Alt-M',\n mac: 'Command-Alt-M'\n },\n exec: editor => {\n const snippetManager = ace.require('ace/snippets').snippetManager;\n if (baseSession.current) {\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n if (outgoingMode === \"snippets\") {\n const snippetText = editor.getSession().getValue();\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n if (outgoingMode === \"snippets\") {}\n try {\n const snippetsPlusMinus = snippetText.split(\"###~~~\")[1];\n const [snippetsPlus, snippetsMinus] = snippetsPlusMinus.split(\"###---\");\n const snippetsToAdd = snippetsPlus.split(\"###+++\")[1];\n const snippetsToRemove = snippetsMinus;\n const langMode = editor.getSession().$modeId.split(\"/\").pop();\n setSnippetAddRemove({\n [langMode]: [snippetAddRemove[langMode][0] + snippetsToAdd, snippetAddRemove[langMode][1] + snippetsToRemove]\n });\n } catch (error) {\n editor.execCommand(\"infoMessage\", {\n text: \"error parsing file, restoring original file\",\n timeout: 2000,\n classToggle: \"show\"\n });\n }\n }\n } else {\n const langMode = editor.getSession().$modeId.split(\"/\").pop();\n const snippetConcatText = `\\n###~~~#(DO NOT EDIT THIS LINE)\n# Commented out above are all the snippets that are currently\n# registered for ${args['lang']} mode.\n\\n\\n###+++#(DO NOT EDIT THIS LINE) \\n# Put the snippets you want to add below this line.\\n\\n\\n\\n\n\\n\\n\\n###---#(DO NOT EDIT THIS LINE) \\n# Put the snippets you want to remove below this line.\\n\\n\\n\\n\\n\\n\\n`;\n const snippetText = \"#\" + createSnippets(snippetManager.snippetMap[langMode].map(snip => ({\n name: snip.name,\n code: snip.content\n }))).replace(/\\n/g, \"\\n#\") + snippetConcatText;\n // snippetManager.files[editor.getSession().$modeId].snippetText\n const lineCount = (snippetText.match(/\\n/g) || []).length;\n baseSession.current = editor.getSession();\n const snippetsSession = ace.createEditSession(snippetText, \"ace/mode/snippets\");\n editor.setSession(snippetsSession);\n const cursorPos = {\n row: lineCount - 15 > 0 ? lineCount - 15 : 0,\n column: 0\n };\n editor.moveCursorTo(cursorPos.row, cursorPos.column);\n editor.renderer.scrollCursorIntoView(cursorPos, 0.5);\n }\n }\n }, {\n name: 'editKeyBindings',\n description: \"Edit keybindings\",\n bindKey: {\n win: 'Ctrl-Alt-B',\n mac: 'Command-Alt-B'\n },\n exec: editor => {\n ace.require('ace/autocomplete').Autocomplete.for(editor);\n if (baseSession.current) {\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n if (outgoingMode === \"json\") {\n const keybindingsJSON = editor.getSession().getValue();\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n try {\n setKeybindingAddRemove(JSON.parse(keybindingsJSON));\n } catch (error) {\n editor.execCommand(\"infoMessage\", {\n text: \"error parsing file, restoring original file\",\n timeout: 2000,\n classToggle: \"show\"\n });\n }\n }\n } else {\n const keybindings = {\n commands: {},\n completer: {}\n };\n if (editor.completer && editor.completer.keyboardHandler.commands) {\n keybindings.completer = Object.keys(editor.completer.keyboardHandler.commands).map(key => {\n var _editor$completer$key;\n return {\n bindkey: (_editor$completer$key = editor.completer.keyboardHandler.commands[key].bindKey) !== null && _editor$completer$key !== void 0 ? _editor$completer$key : \"\",\n name: editor.completer.keyboardHandler.commands[key].name\n };\n });\n }\n if (editor.commands.commands) {\n keybindings.commands = Object.keys(editor.commands.commands).map(key => {\n var _editor$commands$comm;\n return {\n bindkey: (_editor$commands$comm = editor.commands.commands[key].bindKey) !== null && _editor$commands$comm !== void 0 ? _editor$commands$comm : \"\",\n name: editor.commands.commands[key].name\n };\n });\n }\n const keybindingsJSON = JSON.stringify(keybindings, undefined, 2);\n baseSession.current = editor.getSession();\n const keybindingsSession = ace.createEditSession(keybindingsJSON, \"ace/mode/json\");\n editor.setSession(keybindingsSession);\n }\n }\n }, {\n name: 'exitSession',\n //name for the key binding.\n bindKey: {\n win: 'Esc',\n mac: 'Esc'\n },\n description: \"Return to main session (keep changes)\",\n //description of the command\n exec: editor => {\n if (baseSession.current) {\n const mode = editor.getSession().$modeId.split(\"/\").pop();\n if (mode === \"snippets\") editor.execCommand(\"editSnippets\");else if (mode === \"json\") editor.execCommand(\"editKeyBindings\");\n }\n }\n }, {\n name: 'abandonSession',\n //name for the key binding.\n bindKey: {\n win: 'Ctrl-Alt-Esc',\n mac: 'Command-Alt-Esc'\n },\n description: \"Return to main session (discard changes)\",\n //description of the command\n exec: editor => {\n if (baseSession.current) {\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n }\n }\n }, {\n name: 'classART',\n //name for the key binding.\n description: \"Add/Remove/Toggle class for element\",\n //description of the command\n exec: (editor, args) => {\n var _document$querySelect, _document$querySelect2, _document$querySelect3;\n if (args.targetQueryString && args.type && args.class) {\n switch (args.type) {\n case \"add\":\n (_document$querySelect = document.querySelectorAll(args.targetQueryString)) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.forEach(el => el.classList.add(args.class));\n break;\n case \"remove\":\n (_document$querySelect2 = document.querySelectorAll(args.targetQueryString)) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.forEach(el => el.classList.remove(args.class));\n break;\n case \"toggle\":\n (_document$querySelect3 = document.querySelectorAll(args.targetQueryString)) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.forEach(el => el.classList.toggle(args.class));\n break;\n default:\n break;\n }\n }\n }\n }, {\n name: 'conditionalExecute',\n //name for the key binding.\n description: \"Execute command if element exists\",\n //description of the command\n exec: (editor, args) => {\n if (args.targetQueryString && args.command && Array.isArray(args.command)) {\n var _args$condition;\n if (!((_args$condition = args.condition) !== null && _args$condition !== void 0 ? _args$condition : true) === !document.querySelector(args.targetQueryString)) {\n typeof args.command[0] === \"string\" ? execute(args.command[0], args.command[1]) : console.warn(\"Editor command - conditionalExecute: improper command format! Command array must contain name of command as first element and arguments as second element.\");\n }\n }\n }\n }]\n };\n const execute = function (command) {\n var _aceEditor$current;\n let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"\";\n const editor = (_aceEditor$current = aceEditor.current) === null || _aceEditor$current === void 0 ? void 0 : _aceEditor$current.editor;\n if (editor) {\n if (!args) {\n editor.execCommand(command);\n } else if (typeof args === \"number\" || typeof args === \"string\") {\n editor.execCommand(command, args);\n } else if (typeof args === \"object\" && !Array.isArray(args)) {\n var containsNumsStr = true;\n Object.keys(args).forEach(key => {\n containsNumsStr = typeof args[key] === \"string\" || typeof args[key] === \"number\" || Array.isArray(args[key]);\n });\n if (Object.keys(args).length < 4 && containsNumsStr) {\n editor.execCommand(command, args);\n }\n } else {\n console.warn(`Function - execute: failed to parse/execute \"${command}\" command!`);\n }\n }\n };\n const executeAll = commands => {\n commands.forEach(singleCommand => {\n if (Array.isArray(singleCommand)) {\n typeof singleCommand[0] === \"string\" ? execute(singleCommand[0], singleCommand[1]) : console.warn(\"Function - executeAll: improper command format! Singular commands must contain name of command as first element and arguments as second element.\");\n } else if (typeof singleCommand === \"string\") {\n execute(singleCommand);\n } else {\n console.warn(\"Function - executeAll: failed to parse/execute command(s)!\");\n }\n });\n };\n const resetEditor = () => {\n setCode(args['code']);\n };\n const unsecureCopyTextToClipboard = text => {\n const textField = document.createElement('textarea');\n textField.value = text;\n document.body.appendChild(textField);\n textField.select();\n document.execCommand('copy');\n textField.remove();\n };\n\n /**\n * resizeObserver observes changes in elements its given to observe and is used here\n * to communicate to streamlit the height of the component that has changed\n * so that streamlit can adjust the iframe containing the component accordingly.\n */\n const resizeObserver = new ResizeObserver(entries => {\n var _entries$0$contentBox;\n // If we know that the body will always fully contain our component (without cutting it off)\n // then we can use docuemnt.body height instead\n Streamlit.setFrameHeight((_entries$0$contentBox = entries[0].contentBoxSize.blockSize) !== null && _entries$0$contentBox !== void 0 ? _entries$0$contentBox : entries[0].contentRect.height);\n });\n const observe = divElem => {\n divElem ? resizeObserver.observe(divElem) : resizeObserver.disconnect();\n };\n\n // This useEffect is used to reset the editor when the code argument changes and\n // the allow_reset argument is true. The allow_reset argument only impacts the\n // behavior of the component when the component has a fixed key argument because\n // changing the key argument results in the creation of a new component instance.\n // Everything would be reset anyways.\n useEffect(() => {\n if (args['allow_reset'] === true && args['code'] !== code) {\n reset.current = !reset.current;\n resetEditor();\n }\n }, [args['code']]);\n\n /**\n * This could also be memoized but I don't think it would be necessary because its not expensive.\n */\n const themeChoice = () => {\n const isDarkTheme = theme ? theme.base === \"dark\" : true;\n switch (args['theme']) {\n case \"contrast\":\n return isDarkTheme ? \"streamlit_light\" : \"streamlit_dark\";\n case \"light\":\n return \"streamlit_light\";\n case \"dark\":\n return \"streamlit_dark\";\n case \"default\":\n return isDarkTheme ? \"streamlit_dark\" : \"streamlit_light\";\n default:\n return isDarkTheme ? \"streamlit_dark\" : \"streamlit_light\";\n }\n };\n const themeProp = themeChoice();\n const componentContainerProps = args[\"component_props\"];\n const {\n info: infoArg,\n menu: menuArg,\n focus: focusArg,\n code: codeArg,\n ...rest\n } = args;\n const editorArgsString = JSON.stringify(rest);\n const menuArgsString = JSON.stringify(menuArg);\n const infoArgsString = JSON.stringify(infoArg);\n const buttonArgsString = JSON.stringify(args['buttons']);\n const themeString = JSON.stringify(theme);\n const snippets = JSON.stringify(snippetAddRemove);\n\n /**\n * This section contains the main sub-components (child components). These components are wrapped in useMemos\n * in order to prevent unnecessary re-rendering of the components. This is listed as one of its use cases in the\n * React docs ({@link https://beta.reactjs.org/reference/react/useMemo#skipping-re-rendering-of-components Skipping re-rendering of components})\n *\n * This component is the editor component that is rendered. It is only re-rendered when\n * certain properties change. This is important because we should account for the possibility that the editor \n * is being used at any given moment. Unnecessary and frequent re-rendering of the editor (for outside reasons\n * especially) can impact user experience and responsiveness.\n */\n const editor = useMemo(() => {\n const keybindings = JSON.stringify(keybindingAddRemove);\n const revertedArgs = JSON.parse(editorArgsString);\n\n // Create commands for each button\n if (revertedArgs['buttons'].length > 0) {\n revertedArgs['buttons'].forEach(button => {\n commands.commands = [...commands.commands, {\n name: button.name.trim().replace(/\\s+/g, '_') + '_button',\n description: \"Execute '\" + button.name + \"' button command(s)\",\n exec: () => {\n executeAll(button.commands);\n }\n }];\n });\n }\n let heightProps = {};\n if (typeof revertedArgs['height'] === \"number\") heightProps = {\n minLines: 1,\n maxLines: revertedArgs['height']\n };else if (typeof revertedArgs['height'] === \"string\") heightProps = {\n height: revertedArgs['height']\n };else if (Array.isArray(revertedArgs['height']) && revertedArgs['height'].length === 2) heightProps = {\n minLines: revertedArgs['height'][0],\n maxLines: revertedArgs['height'][1]\n };\n const aceEditorProps = {\n ...defaultEditorProps,\n ...revertedArgs['editorProps']\n };\n const aceOptions = {\n ...defaultOptions,\n ...revertedArgs['options']\n };\n const partProps = {\n setOptions: aceOptions,\n editorProps: aceEditorProps\n };\n const aceProps = {\n ...defaultProps,\n ...partProps,\n ...heightProps,\n ...revertedArgs['props']\n };\n\n /**\n * TODO: Remove props from aceProps that we don't want to allow user access to.\n */\n return /*#__PURE__*/_jsxDEV(Editor, {\n editorRef: aceEditor,\n code: code,\n lang: revertedArgs['lang'],\n theme: themeProp,\n shortcuts: revertedArgs['shortcuts'],\n snippetString: snippets,\n commands: commands.commands,\n keybindingString: keybindings,\n props: aceProps,\n onChange: value => onChangeHandler(value)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 588,\n columnNumber: 9\n }, this);\n }, [editorArgsString, themeProp, snippets, keybindingAddRemove, reset.current]);\n const buttons = useMemo(() => {\n const revertedButtons = JSON.parse(buttonArgsString);\n const revertedTheme = JSON.parse(themeString);\n const customButtonTheme = revertedTheme !== null && revertedTheme !== void 0 ? revertedTheme : {};\n const customButtons = {\n buttons: revertedButtons !== null && revertedButtons !== void 0 ? revertedButtons : [],\n name: \"customButtons\"\n };\n return /*#__PURE__*/_jsxDEV(ButtonSet, {\n buttonGroup: customButtons,\n theme: customButtonTheme,\n themeProp: themeProp,\n executeAll: commands => executeAll(commands)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 608,\n columnNumber: 7\n }, this);\n }, [buttonArgsString, themeString, themeProp]);\n const menu = useMemo(() => {\n const revertedMenu = JSON.parse(menuArgsString);\n const revertedTheme = JSON.parse(themeString);\n const menuTheme = revertedTheme !== null && revertedTheme !== void 0 ? revertedTheme : {};\n return /*#__PURE__*/_jsxDEV(ButtonMenu, {\n menu: revertedMenu,\n theme: menuTheme,\n themeProp: themeProp,\n executeAll: commands => executeAll(commands)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 621,\n columnNumber: 7\n }, this);\n }, [menuArgsString, themeString, themeProp]);\n const info = useMemo(() => {\n const revertedInfo = JSON.parse(infoArgsString);\n const revertedTheme = JSON.parse(themeString);\n const infoTheme = revertedTheme !== null && revertedTheme !== void 0 ? revertedTheme : {};\n return /*#__PURE__*/_jsxDEV(InfoBar, {\n infoRef: infoTextRef,\n info: revertedInfo,\n theme: infoTheme\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 634,\n columnNumber: 7\n }, this);\n }, [infoArgsString, themeString]);\n const globalCSS = useMemo(() => {\n return /*#__PURE__*/_jsxDEV(GlobalCSS, {\n isDisabled: disabled,\n inject: componentContainerProps.globalCSS\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 643,\n columnNumber: 7\n }, this);\n }, [componentContainerProps.globalCSS, disabled]);\n return /*#__PURE__*/_jsxDEV(_StyledStyledCodeEditor, {\n ref: observe,\n style: componentContainerProps.style,\n className: (_ref3 = \"streamlit_code-editor \" + (theme === null || theme === void 0 ? void 0 : theme.base)) !== null && _ref3 !== void 0 ? _ref3 : \"\",\n $_css: componentContainerProps.css,\n children: [globalCSS, editor, buttons, menu, info]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 648,\n columnNumber: 5\n }, this);\n};\n_s(CodeEditor, \"508paNGWcrdruPD7XQ0HUEI0Jhc=\");\n_c2 = CodeEditor;\nexport default _c3 = withStreamlitConnection(CodeEditor);\nvar _c, _c2, _c3;\n$RefreshReg$(_c, \"GlobalCSS\");\n$RefreshReg$(_c2, \"CodeEditor\");\n$RefreshReg$(_c3, \"%default%\");","map":{"version":3,"names":["Streamlit","withStreamlitConnection","useState","useRef","useEffect","useMemo","ace","Editor","Menu","ButtonMenu","Set","ButtonSet","Info","InfoBar","defaultOptions","fontFamily","cursorStyle","displayIndentGuides","wrap","highlightActiveLine","showPrintMargin","showLineNumbers","foldStyle","autoScrollEditorIntoView","animatedScroll","fadeFoldWidgets","defaultEditorProps","editorProps","$blockScrolling","defaultProps","cursorStart","enableBasicAutocompletion","enableLiveAutocompletion","enableSnippets","focus","fontSize","navigateToFileEnd","placeholder","readOnly","scrollMargin","setOptions","showGutter","style","tabSize","width","debounceChangePeriod","GlobalCSS","createGlobalStyle","props","isDisabled","inject","StyledCodeEditor","styled","div","CodeEditor","args","disabled","theme","code","setCode","aceEditor","infoTextRef","baseSession","keepFocus","reset","timeoutId","createSnippets","snippetRaw","Array","isArray","map","name","split","c","join","snippetAddRemove","setSnippetAddRemove","keybindingAddRemove","setKeybindingAddRemove","clearTimeout","current","editor","onChangeHandler","newCode","commands","description","bindKey","win","mac","exec","outgoingMode","getSession","$modeId","pop","setComponentValue","text","getValue","type","lang","unsecureCopyTextToClipboard","resetEditor","setMode","shortcuts","setKeyboardHandler","handlers","currentHandler","indexOf","$keybindingId","document","getElementById","execCommand","keyCode","key","dispatchEvent","KeyboardEvent","targetQueryString","target","querySelector","innerText","classList","add","classToggle","timeout","setTimeout","remove","responseType","snippetManager","require","snippetText","setSession","snippetsPlusMinus","snippetsPlus","snippetsMinus","snippetsToAdd","snippetsToRemove","langMode","error","snippetConcatText","snippetMap","snip","content","replace","lineCount","match","length","snippetsSession","createEditSession","cursorPos","row","column","moveCursorTo","renderer","scrollCursorIntoView","Autocomplete","for","keybindingsJSON","JSON","parse","keybindings","completer","keyboardHandler","Object","keys","bindkey","stringify","undefined","keybindingsSession","mode","class","querySelectorAll","forEach","el","toggle","command","condition","execute","console","warn","containsNumsStr","executeAll","singleCommand","textField","createElement","value","body","appendChild","select","resizeObserver","ResizeObserver","entries","setFrameHeight","contentBoxSize","blockSize","contentRect","height","observe","divElem","disconnect","themeChoice","isDarkTheme","base","themeProp","componentContainerProps","info","infoArg","menu","menuArg","focusArg","codeArg","rest","editorArgsString","menuArgsString","infoArgsString","buttonArgsString","themeString","snippets","revertedArgs","button","trim","heightProps","minLines","maxLines","aceEditorProps","aceOptions","partProps","aceProps","buttons","revertedButtons","revertedTheme","customButtonTheme","customButtons","revertedMenu","menuTheme","revertedInfo","infoTheme","globalCSS","css"],"sources":["/home/anasbouzid/streamlit-code-editor/code_editor/frontend/src/CodeEditor.tsx"],"sourcesContent":["import {\n Streamlit,\n withStreamlitConnection,\n ComponentProps,\n Theme,\n} from \"streamlit-component-lib\"\nimport styled, { createGlobalStyle } from \"styled-components/macro\"\nimport { useState, useRef, useEffect, useMemo } from \"react\"\nimport AceEditor from \"react-ace\";\nimport ace from \"ace-builds\";\nimport { Editor } from './editor';\nimport { Menu as ButtonMenu, Set as ButtonSet, customButton, buttonGroup, Info as InfoBar } from \"./button-menu\"\n\nimport \"ace-builds/webpack-resolver\";\nimport \"ace-builds/src-noconflict/mode-python\";\nimport \"ace-builds/src-noconflict/mode-javascript\";\nimport \"ace-builds/src-noconflict/ext-language_tools\";\nimport \"ace-builds/src-noconflict/ext-searchbox\";\nimport \"ace-builds/src-noconflict/ext-prompt\";\nimport \"ace-builds/src-noconflict/ext-modelist\";\n\ninterface CodeEditorProps extends ComponentProps {\n args: any\n width: number\n disabled: boolean\n theme?: Theme\n}\n\nconst defaultOptions = {\n fontFamily: '\"Source Code Pro\", monospace',\n cursorStyle: \"smooth\",\n displayIndentGuides: false,\n wrap: false,\n highlightActiveLine: true,\n showPrintMargin: false,\n showLineNumbers: false,\n foldStyle: \"markbegin\",\n autoScrollEditorIntoView: false,\n animatedScroll: true,\n fadeFoldWidgets: true,\n}\n\nconst defaultEditorProps = {\n editorProps: {\n $blockScrolling: true\n }\n}\n\nconst defaultProps = {\n cursorStart: 1,\n enableBasicAutocompletion: false,\n enableLiveAutocompletion: true,\n enableSnippets: true,\n focus: false,\n fontSize: 14,\n highlightActiveLine: true,\n navigateToFileEnd: true,\n placeholder: null,\n readOnly: false,\n scrollMargin: [15, 15, 0, 0],\n setOptions: defaultOptions,\n showGutter: true,\n showPrintMargin: false,\n style: {},\n tabSize: 4,\n width: \"auto\",\n debounceChangePeriod: 250,\n}\n\nconst GlobalCSS = createGlobalStyle<{isDisabled?: boolean, inject: string}>`\n html {\n opacity: ${props => props.isDisabled? \"0.5\": \"1\"};\n cursor: ${props => props.isDisabled? \"not-allowed\": \"auto\"};\n pointer-events: ${props => props.isDisabled? \"none\": \"auto\"};\n }\n body {\n margin: 0;\n padding: 0;\n }\n ${props => props.inject}\n`\nconst StyledCodeEditor = styled.div`\n width: 100%;\n border-radius: 8px;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n :hover button {\n opacity: 1;\n transform: scale(1);\n }\n button.always-on {\n opacity: 1;\n transform: scale(1);\n transition: none;\n }\n :hover button svg {\n opacity: 1;\n transform: scale(1);\n }\n :hover button.with-icon span {\n opacity: 1;\n transform: scale(1);\n }\n button.always-on > span {\n opacity: 1;\n transform: scale(1);\n transition: none;\n }\n button.always-on > svg {\n opacity: 1;\n transform: scale(1);\n transition: none;\n }\n `;\n\nconst CodeEditor = ({ args, width, disabled, theme }: CodeEditorProps) => {\n\n //sets code to the initial value every time the component is rendered\n //to set the initial value once, use a function instead of a value.\n const [code, setCode] = useState(args['code']);\n // const [keybindingAddRemove, setKeybindingAddRemove] = useState([\"\",\"\"]);\n\n const aceEditor = useRef(null);\n const infoTextRef = useRef(null);\n const baseSession = useRef(null);\n const keepFocus = useRef(false);\n const reset = useRef(false);\n\n var timeoutId: NodeJS.Timeout;\n\n /**\n * This function takes as input either a snippetText string that is expected\n * to be already formatted like the text in a SnippetFile or a dictionary or \n * and array of dictionaries. For the first case, it just returns the input.\n * For the second and third case, a (SnippetFile format) string is constructed\n * from the dict(s) and returned. Learn more about snippets {@link here}\n * @param snippetRaw snippets to be converted to a single snippetText string\n * @returns {string} snippetText\n */\n const createSnippets = (snippetRaw: string | object | [object]): string => {\n return (typeof snippetRaw === \"string\" ? snippetRaw : (Array.isArray(snippetRaw) ? snippetRaw : [snippetRaw]).map(({ name, code }) =>\n ([\n 'snippet ' + name,\n code.split('\\n')\n .map((c: string) => '\\t' + c)\n .join('\\n'),\n ].join('\\n'))\n ).join('\\n'))\n }\n const [snippetAddRemove, setSnippetAddRemove] = useState({[args['lang']] : [createSnippets(args[\"snippets\"][0]), createSnippets(args[\"snippets\"][1])]});\n const [keybindingAddRemove, setKeybindingAddRemove] = useState(args['keybindings']);\n\n\n useEffect(() => {\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n }, []);\n\n useEffect(() => {\n if(aceEditor.current && keepFocus.current){\n aceEditor.current.editor.focus();\n keepFocus.current = false;\n }\n }, [keepFocus.current]);\n\n // To reasons for the useEffect here: \n // 1. to set the focus on the editor only when the focus argument has changed to true.\n // 2. to set the focus on the editor after rendering the component at which point, the \n // editor should be ready.\n useEffect(() => {\n if(aceEditor.current && args.focus){\n aceEditor.current.editor.focus();\n }\n }, [args.focus]);\n\n const onChangeHandler = (newCode: string) => {\n setCode(newCode);\n }\n\n // commands is an array of objects containing functions\n // that the editor can be triggered to call.\n const commands = { commands: [\n {\n name: 'submit', //name for the key binding.\n description: \"Send 'submit' response\", //description of the command\n bindKey: { win: 'Ctrl-Enter', mac: 'Command-Enter' }, //key combination used for the command.\n exec: (editor: any) => {\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n Streamlit.setComponentValue({text: editor.getValue(), type: \"submit\", lang: outgoingMode });\n }\n },\n {\n name: 'saveState',\n description: \"Save state\",\n bindKey: { win: 'Ctrl-Alt-S', mac: 'Command-Alt-S' },\n exec: (editor: ace.Ace.Editor) => {\n setCode(editor.getValue());\n }\n },\n {\n name: 'copyAll',\n description: \"Copy all text to clipboard\",\n exec: (editor: ace.Ace.Editor) => {\n unsecureCopyTextToClipboard(editor.getValue());\n }\n },\n {\n name: 'reset',\n exec: () => {\n resetEditor();\n }\n },\n {\n name: 'keepFocus',\n description: \"Return cursor to editor\",\n exec: () => {\n keepFocus.current = true;\n }\n },\n {\n name: \"setMode\",\n description: \"Set language mode\",\n exec: (editor: ace.Ace.Editor, lang: string) => {\n if(lang && typeof lang === \"string\")\n editor.getSession().setMode(\"ace/mode/\" + lang);\n },\n readOnly: true\n },\n {\n name: \"changeShortcuts\",\n description: \"Switch shortcuts\",\n exec: (editor: any, shortcuts?: string) => {\n if(shortcuts && typeof shortcuts === \"string\")\n editor.setKeyboardHandler(\"ace/keyboard/\" + shortcuts);\n else {\n //rotate through the available keyboard handlers\n const handlers = [\"ace/keyboard/vim\", \"ace/keyboard/emacs\", \"ace/keyboard/sublime\", \"ace/keyboard/vscode\"];\n const currentHandler = handlers[(handlers.indexOf(editor.$keybindingId) + 1) % 4];\n editor.setKeyboardHandler(currentHandler);\n }\n },\n readOnly: true\n },\n {\n name: 'toggleKeyboardShortcuts',\n exec: (editor: ace.Ace.Editor) => {\n if(!document.getElementById('kbshortcutmenu'))\n editor.execCommand('showKeyboardShortcuts');\n else \n editor.execCommand('simulateKeyPress', {type:\"keydown\", keyCode: 27});\n }\n },\n {\n name: 'simulateKeyPress',\n exec: (editor: ace.Ace.Editor, args: {type: string, key?: string, keyCode?: number}) => {\n if(args.key)\n document.dispatchEvent(new KeyboardEvent(args.type,{'key': args.key})); \n else if(args.keyCode)\n document.dispatchEvent(new KeyboardEvent(args.type,{'keyCode': args.keyCode})); \n }\n },\n {\n name: 'infoMessage',\n description: \"Display message in info bar\",\n exec: (editor: ace.Ace.Editor, args: {text: string, timeout?: number, classToggle?: string, targetQueryString?: string} ) => {\n if(args.targetQueryString){\n const target = document.querySelector(args.targetQueryString) as HTMLElement;\n if(target){\n target.innerText = args.text;\n target.classList.add(args.classToggle || \"\")\n if(args.timeout){\n timeoutId = setTimeout(() => {\n target.classList.remove(args.classToggle || \"\");\n }, args.timeout);\n }\n }\n }\n else if(infoTextRef.current){\n infoTextRef.current.innerText = args.text;\n infoTextRef.current.classList.add(args.classToggle || \"\");\n if(args.timeout){\n timeoutId = setTimeout(() => {\n infoTextRef.current?.classList.remove(args.classToggle || \"\");\n }, args.timeout);\n }\n }\n }\n },\n {\n name: 'response', //name for the key binding.\n description: \"Send custom response\", //description of the command\n exec: (editor: any, responseType = \"\") => {\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n Streamlit.setComponentValue({ text: code, type: responseType, lang: outgoingMode });\n }\n },\n {\n name: 'editSnippets',\n description: \"Edit snippets\",\n bindKey: { win: 'Ctrl-Alt-M', mac: 'Command-Alt-M' },\n exec: (editor: any) => {\n const snippetManager = ace.require('ace/snippets').snippetManager;\n if(baseSession.current){\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n if(outgoingMode === \"snippets\"){\n const snippetText = editor.getSession().getValue();\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n if(outgoingMode === \"snippets\"){}\n try{\n const snippetsPlusMinus = snippetText.split(\"###~~~\")[1];\n const [snippetsPlus, snippetsMinus] = snippetsPlusMinus.split(\"###---\");\n const snippetsToAdd = snippetsPlus.split(\"###+++\")[1];\n const snippetsToRemove = snippetsMinus;\n const langMode = editor.getSession().$modeId.split(\"/\").pop();\n setSnippetAddRemove({[langMode] : [snippetAddRemove[langMode][0] + snippetsToAdd, snippetAddRemove[langMode][1] + snippetsToRemove]});\n } catch (error) {\n editor.execCommand(\"infoMessage\",{text: \"error parsing file, restoring original file\", timeout: 2000, classToggle: \"show\"});\n }\n }\n } else {\n const langMode = editor.getSession().$modeId.split(\"/\").pop()\n const snippetConcatText = `\\n###~~~#(DO NOT EDIT THIS LINE)\n# Commented out above are all the snippets that are currently\n# registered for ${args['lang']} mode.\n\\n\\n###+++#(DO NOT EDIT THIS LINE) \\n# Put the snippets you want to add below this line.\\n\\n\\n\\n\n\\n\\n\\n###---#(DO NOT EDIT THIS LINE) \\n# Put the snippets you want to remove below this line.\\n\\n\\n\\n\\n\\n\\n`;\n const snippetText = \"#\" + createSnippets(snippetManager.snippetMap[langMode].map((snip: any) => ({name: snip.name, code: snip.content}))).replace(/\\n/g, \"\\n#\") + snippetConcatText;\n // snippetManager.files[editor.getSession().$modeId].snippetText\n const lineCount = (snippetText.match(/\\n/g) || []).length;\n baseSession.current = editor.getSession();\n const snippetsSession = ace.createEditSession(snippetText, \"ace/mode/snippets\");\n editor.setSession(snippetsSession);\n const cursorPos = {row: (lineCount - 15)>0? lineCount - 15 : 0, column: 0};\n editor.moveCursorTo(cursorPos.row, cursorPos.column);\n editor.renderer.scrollCursorIntoView(cursorPos, 0.5);\n }\n }\n },\n {\n name: 'editKeyBindings',\n description: \"Edit keybindings\",\n bindKey: { win: 'Ctrl-Alt-B', mac: 'Command-Alt-B' },\n exec: (editor: any) => {\n ace.require('ace/autocomplete').Autocomplete.for(editor);\n if(baseSession.current){\n const outgoingMode = editor.getSession().$modeId.split(\"/\").pop();\n if(outgoingMode === \"json\"){\n const keybindingsJSON = editor.getSession().getValue();\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n try{\n setKeybindingAddRemove(JSON.parse(keybindingsJSON));\n } catch (error) {\n editor.execCommand(\"infoMessage\",{text: \"error parsing file, restoring original file\", timeout: 2000, classToggle: \"show\"});\n }\n }\n } else {\n const keybindings = {commands: {}, completer: {}};\n if(editor.completer && editor.completer.keyboardHandler.commands){\n keybindings.completer = Object.keys(editor.completer.keyboardHandler.commands).map((key: any) => ({bindkey: editor.completer.keyboardHandler.commands[key].bindKey ?? \"\", name: editor.completer.keyboardHandler.commands[key].name}));\n }\n if(editor.commands.commands){\n keybindings.commands = Object.keys(editor.commands.commands).map((key: any) => ({bindkey: editor.commands.commands[key].bindKey ?? \"\", name: editor.commands.commands[key].name}));\n }\n const keybindingsJSON = JSON.stringify(keybindings, undefined, 2);\n baseSession.current = editor.getSession();\n const keybindingsSession = ace.createEditSession(keybindingsJSON, \"ace/mode/json\");\n editor.setSession(keybindingsSession);\n }\n }\n },\n {\n name: 'exitSession', //name for the key binding.\n bindKey: { win: 'Esc', mac: 'Esc' },\n description: \"Return to main session (keep changes)\", //description of the command\n exec: (editor: any) => {\n if(baseSession.current){\n const mode = editor.getSession().$modeId.split(\"/\").pop();\n if (mode === \"snippets\")\n editor.execCommand(\"editSnippets\");\n else if (mode === \"json\")\n editor.execCommand(\"editKeyBindings\");\n }\n }\n },\n {\n name: 'abandonSession', //name for the key binding.\n bindKey: { win: 'Ctrl-Alt-Esc', mac: 'Command-Alt-Esc' },\n description: \"Return to main session (discard changes)\", //description of the command\n exec: (editor: any) => {\n if(baseSession.current){\n editor.setSession(baseSession.current);\n baseSession.current = null;\n setCode(editor.getSession().getValue());\n }\n }\n },\n {\n name: 'classART', //name for the key binding.\n description: \"Add/Remove/Toggle class for element\", //description of the command\n exec: (editor: any, args: {targetQueryString: string, type: string, class: string}) => {\n if(args.targetQueryString && args.type && args.class){\n switch(args.type){\n case \"add\":\n document.querySelectorAll(args.targetQueryString)?.forEach((el: any) => el.classList.add(args.class));\n break;\n case \"remove\":\n document.querySelectorAll(args.targetQueryString)?.forEach((el: any) => el.classList.remove(args.class));\n break;\n case \"toggle\":\n document.querySelectorAll(args.targetQueryString)?.forEach((el: any) => el.classList.toggle(args.class));\n break;\n default:\n break;\n }\n }\n }\n },\n {\n name: 'conditionalExecute', //name for the key binding.\n description: \"Execute command if element exists\", //description of the command\n exec: (editor: any, args: {targetQueryString: string, command: any[], condition?: boolean}) => {\n if(args.targetQueryString && args.command && Array.isArray(args.command)){\n if(!(args.condition ?? true) === !document.querySelector(args.targetQueryString)){\n typeof args.command[0] === \"string\" ? execute(args.command[0], args.command[1]) : console.warn(\"Editor command - conditionalExecute: improper command format! Command array must contain name of command as first element and arguments as second element.\");\n }\n }\n }\n }\n ]};\n\n const execute = (command: string, args: any = \"\") => {\n const editor = aceEditor.current?.editor;\n if (editor) {\n if (!args) {\n editor.execCommand(command)\n }\n else if (typeof args === \"number\" || typeof args === \"string\") {\n editor.execCommand(command, args);\n }\n else if (typeof args === \"object\" && !Array.isArray(args)) {\n var containsNumsStr = true;\n Object.keys(args).forEach((key: any) => {\n containsNumsStr = typeof args[key] === \"string\" || typeof args[key] === \"number\" || Array.isArray(args[key]);\n });\n if (Object.keys(args).length < 4 && containsNumsStr) {\n editor.execCommand(command, args);\n }\n }\n else {\n console.warn(`Function - execute: failed to parse/execute \"${command}\" command!`);\n }\n }\n }\n\n const executeAll = (commands: any[]) => {\n commands.forEach(singleCommand => {\n if (Array.isArray(singleCommand)) {\n typeof singleCommand[0] === \"string\" ? execute(singleCommand[0], singleCommand[1]) : console.warn(\"Function - executeAll: improper command format! Singular commands must contain name of command as first element and arguments as second element.\");\n } else if (typeof singleCommand === \"string\") {\n execute(singleCommand);\n } else {\n console.warn(\"Function - executeAll: failed to parse/execute command(s)!\");\n }\n });\n }\n\n const resetEditor = () => {\n setCode(args['code']);\n }\n\n const unsecureCopyTextToClipboard = (text: string) => {\n const textField = document.createElement('textarea');\n textField.value = text;\n document.body.appendChild(textField);\n textField.select();\n document.execCommand('copy');\n textField.remove();\n }\n\n /**\n * resizeObserver observes changes in elements its given to observe and is used here\n * to communicate to streamlit the height of the component that has changed\n * so that streamlit can adjust the iframe containing the component accordingly.\n */\n const resizeObserver = new ResizeObserver((entries: any) => {\n // If we know that the body will always fully contain our component (without cutting it off)\n // then we can use docuemnt.body height instead\n Streamlit.setFrameHeight((entries[0].contentBoxSize.blockSize ?? entries[0].contentRect.height)); \n })\n\n const observe = (divElem: any) => {\n divElem ? resizeObserver.observe(divElem as HTMLDivElement) : resizeObserver.disconnect();\n }\n\n // This useEffect is used to reset the editor when the code argument changes and\n // the allow_reset argument is true. The allow_reset argument only impacts the\n // behavior of the component when the component has a fixed key argument because\n // changing the key argument results in the creation of a new component instance.\n // Everything would be reset anyways.\n useEffect(() => {\n if (args['allow_reset'] === true && args['code'] !== code) {\n reset.current = !reset.current;\n resetEditor();\n }\n }, [args['code']]);\n\n /**\n * This could also be memoized but I don't think it would be necessary because its not expensive.\n */\n const themeChoice = () => {\n const isDarkTheme = theme? theme.base === \"dark\" : true;\n switch (args['theme']) {\n case \"contrast\":\n return isDarkTheme? \"streamlit_light\" : \"streamlit_dark\";\n case \"light\":\n return \"streamlit_light\";\n case \"dark\":\n return \"streamlit_dark\";\n case \"default\":\n return isDarkTheme? \"streamlit_dark\" : \"streamlit_light\";\n default:\n return isDarkTheme? \"streamlit_dark\" : \"streamlit_light\";\n }\n }\n\n const themeProp = themeChoice();\n const componentContainerProps = args[\"component_props\"];\n\n const {info: infoArg, menu: menuArg, focus: focusArg, code: codeArg, ...rest} = args;\n const editorArgsString = JSON.stringify(rest);\n const menuArgsString = JSON.stringify(menuArg);\n const infoArgsString = JSON.stringify(infoArg);\n const buttonArgsString = JSON.stringify(args['buttons']);\n const themeString = JSON.stringify(theme);\n const snippets = JSON.stringify(snippetAddRemove);\n\n /**\n * This section contains the main sub-components (child components). These components are wrapped in useMemos\n * in order to prevent unnecessary re-rendering of the components. This is listed as one of its use cases in the\n * React docs ({@link https://beta.reactjs.org/reference/react/useMemo#skipping-re-rendering-of-components Skipping re-rendering of components})\n *\n * This component is the editor component that is rendered. It is only re-rendered when\n * certain properties change. This is important because we should account for the possibility that the editor \n * is being used at any given moment. Unnecessary and frequent re-rendering of the editor (for outside reasons\n * especially) can impact user experience and responsiveness.\n */\n const editor = useMemo(() => {\n const keybindings = JSON.stringify(keybindingAddRemove);\n const revertedArgs = JSON.parse(editorArgsString);\n\n // Create commands for each button\n if(revertedArgs['buttons'].length > 0) {\n revertedArgs['buttons'].forEach((button: any) => {\n commands.commands = [...commands.commands, {\n name: (button.name as string).trim().replace(/\\s+/g, '_') + '_button',\n description: \"Execute '\" + button.name + \"' button command(s)\",\n exec: () => {\n executeAll(button.commands);\n }}];\n });\n }\n\n let heightProps = {};\n if(typeof revertedArgs['height'] === \"number\") \n heightProps = {minLines: 1, maxLines: revertedArgs['height']};\n else if(typeof revertedArgs['height'] === \"string\") \n heightProps = {height: revertedArgs['height']};\n else if(Array.isArray(revertedArgs['height']) && revertedArgs['height'].length === 2) \n heightProps = {minLines: revertedArgs['height'][0], maxLines: revertedArgs['height'][1]};\n\n const aceEditorProps = { ...defaultEditorProps, ...revertedArgs['editorProps'] };\n const aceOptions = { ...defaultOptions, ...revertedArgs['options'] };\n const partProps = { setOptions: aceOptions, editorProps: aceEditorProps };\n const aceProps = { ...defaultProps, ...partProps,...heightProps, ...revertedArgs['props'] };\n\n /**\n * TODO: Remove props from aceProps that we don't want to allow user access to.\n */\n return (\n onChangeHandler(value)} />\n );\n }, [editorArgsString, themeProp, snippets, keybindingAddRemove, reset.current]);\n\n const buttons = useMemo(() => {\n const revertedButtons = JSON.parse(buttonArgsString);\n const revertedTheme = JSON.parse(themeString);\n const customButtonTheme = revertedTheme ?? {};\n const customButtons = {buttons: (revertedButtons ?? []) as customButton[], name: \"customButtons\"} as buttonGroup;\n return (\n < ButtonSet\n buttonGroup={customButtons} \n theme={customButtonTheme} \n themeProp={themeProp} \n executeAll={(commands) => executeAll(commands)} />\n );\n }, [buttonArgsString, themeString, themeProp]);\n\n const menu = useMemo(() => {\n const revertedMenu = JSON.parse(menuArgsString);\n const revertedTheme = JSON.parse(themeString);\n const menuTheme = revertedTheme ?? {};\n return (\n executeAll(commands)} />\n );\n }, [menuArgsString, themeString, themeProp]);\n\n const info = useMemo(() => {\n const revertedInfo = JSON.parse(infoArgsString);\n const revertedTheme = JSON.parse(themeString);\n const infoTheme = revertedTheme ?? {};\n return (\n \n );\n }, [infoArgsString, themeString]);\n\n const globalCSS = useMemo(() => {\n return (\n \n );\n }, [componentContainerProps.globalCSS, disabled]);\n\n return (\n \n {globalCSS}\n {editor}\n {buttons}\n {menu}\n {info}\n \n )\n}\n\nexport default withStreamlitConnection(CodeEditor)"],"mappings":";;;;;AAAA,SACEA,SAAS,EACTC,uBAAuB,QAGlB,yBAAyB;AAEhC,SAASC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE5D,OAAOC,GAAG,MAAM,YAAY;AAC5B,SAASC,MAAM,QAAQ,UAAU;AACjC,SAASC,IAAI,IAAIC,UAAU,EAAEC,GAAG,IAAIC,SAAS,EAA6BC,IAAI,IAAIC,OAAO,QAAQ,eAAe;AAEhH,OAAO,6BAA6B;AACpC,OAAO,uCAAuC;AAC9C,OAAO,2CAA2C;AAClD,OAAO,8CAA8C;AACrD,OAAO,yCAAyC;AAChD,OAAO,sCAAsC;AAC7C,OAAO,wCAAwC;AA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A;MAAA;IAAA,QAAG;EAElF,CAAC,EAAE,CAACjC,uBAAuB,CAACiC,SAAS,EAAEnL,QAAQ,CAAC,CAAC;EAEjD,oBACE;IAAkB,GAAG,EAAE2I,OAAQ;IAAC,KAAK,EAAEO,uBAAuB,CAAChK,KAAM;IAAmC,SAAS,WAAE,wBAAwB,IAAGe,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAE+I,IAAI,0CAAI,EAAI;IAAA,OAAtFE,uBAAuB,CAACkC,GAAG;IAAA,WACnGD,SAAS,EACT1J,MAAM,EACNiJ,OAAO,EACPrB,IAAI,EACJF,IAAI;EAAA;IAAA;IAAA;IAAA;EAAA,QACY;AAEvB,CAAC;AAAA,GA3hBKrJ,UAAU;AAAA,MAAVA,UAAU;AA6hBhB,qBAAerD,uBAAuB,CAACqD,UAAU,CAAC;AAAA;AAAA;AAAA;AAAA"},"metadata":{},"sourceType":"module"} \ No newline at end of file diff --git a/code_editor/frontend/node_modules/.cache/babel-loader/22922bf87b4a6e072b2ebbd7ed80a593.json b/code_editor/frontend/node_modules/.cache/babel-loader/22922bf87b4a6e072b2ebbd7ed80a593.json new file mode 100644 index 000000000..c9d411045 --- /dev/null +++ b/code_editor/frontend/node_modules/.cache/babel-loader/22922bf87b4a6e072b2ebbd7ed80a593.json @@ -0,0 +1 @@ +{"ast":null,"code":"import _styled3 from \"styled-components\";\nimport _styled2 from \"styled-components\";\nimport { ThemeProvider as _ThemeProvider } from \"styled-components\";\nimport _styled from \"styled-components\";\nvar _jsxFileName = \"/home/anasbouzid/streamlit-code-editor/code_editor/frontend/src/button-menu.tsx\",\n _this = this,\n _s = $RefreshSig$();\n// import styled, { ThemeProvider, css } from \"styled-components\"\nimport { useRef, useState } from \"react\";\nimport * as Icons from \"react-feather\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nexport const StyledDiv = _styled.div.withConfig({\n displayName: \"button-menu__StyledDiv\",\n componentId: \"sc-rz5v7a-0\"\n})([\"\"]);\nvar _StyledStyledDiv2 = _styled(StyledDiv).withConfig({\n displayName: \"button-menu___StyledStyledDiv2\",\n componentId: \"sc-rz5v7a-1\"\n})([\"\", \"\"], p => p.$_css2);\nvar _StyledStyledDiv = _styled(StyledDiv).withConfig({\n displayName: \"button-menu___StyledStyledDiv\",\n componentId: \"sc-rz5v7a-2\"\n})([\"\", \"\"], p => p.$_css);\nexport const StyledRegSpan = _styled.span.withConfig({\n displayName: \"button-menu__StyledRegSpan\",\n componentId: \"sc-rz5v7a-3\"\n})([\"\"]);\nexport const StyledSpan = _styled.span.withConfig({\n displayName: \"button-menu__StyledSpan\",\n componentId: \"sc-rz5v7a-4\"\n})([\"height:2.5rem;line-height:2.5rem;margin:0px 0.4rem 0.15rem 0.4rem;opacity:0;transform:scale(0);transition:opacity 300ms 150ms,transform 300ms 150ms;\"]);\nexport const StyledButton = _styled.button.withConfig({\n displayName: \"button-menu__StyledButton\",\n componentId: \"sc-rz5v7a-5\"\n})([\"border:none;border-radius:5px;background:none;height:2.5rem;line-height:0;display:flex;align-items:center;justify-content:center;opacity:0;position:absolute;transform:scale(0);transition:opacity 20ms 300ms,transform 20ms 300ms;z-index:9994;:focus{outline:none;}span{color:\", \";transform:scale(0);transform-origin:right;transition:opacity 300ms 150ms,transform 300ms 150ms;}:hover span{color:\", \";opacity:1;transform:scale(1);}svg{stroke:\", \";transform:scale(0);transition:opacity 300ms 150ms,transform 300ms 150ms;}:hover svg{stroke:\", \";}\"], props => props.themeProp === \"streamlit_dark\" ? \"rgba(250,250,250,0.6)\" : \"rgba(0,0,0,0.5)\", props => props.primary ? props.theme.primaryColor : props.themeProp === \"streamlit_dark\" ? \"rgb(250,250,250)\" : \"rgb(49, 51, 63)\", props => props.themeProp === \"streamlit_dark\" ? \"rgba(250,250,250,0.6)\" : \"rgba(0,0,0,0.5)\", props => props.primary ? props.theme.primaryColor : props.themeProp === \"streamlit_dark\" ? \"rgb(250,250,250)\" : \"rgb(49, 51, 63)\");\nexport const creatIcon = function (name) {\n let size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;\n const CustomIcon = Icons[name];\n return /*#__PURE__*/_jsxDEV(CustomIcon, {\n size: `${size}`\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 10\n }, _this);\n};\nexport const Info = _ref => {\n let {\n info,\n theme,\n infoRef\n } = _ref;\n return /*#__PURE__*/_jsxDEV(_ThemeProvider, {\n theme: theme,\n children: Object.keys(info).length === 0 ? `` : /*#__PURE__*/_jsxDEV(_StyledStyledDiv, {\n className: \"custom_info_bar \" + (info.name ? info.name : \"\"),\n style: info.style,\n $_css: info.css,\n children: [/*#__PURE__*/_jsxDEV(StyledRegSpan, {\n ref: infoRef,\n className: \"code_editor-info message\"\n }, \"code_editor_info_message\", false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 10\n }, this), (info.info || []).map(info => /*#__PURE__*/_jsxDEV(StyledRegSpan, {\n className: info.class,\n style: info.style,\n children: info.name\n }, \"info_\" + info.name, false, {\n fileName: _jsxFileName,\n lineNumber: 121,\n columnNumber: 11\n }, this))]\n }, \"info_bar\", true, {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 48\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 116,\n columnNumber: 5\n }, this);\n};\n_c = Info;\nexport const Button = _ref2 => {\n _s();\n let {\n button,\n theme,\n themeProp,\n executeAll\n } = _ref2;\n const [toggle, setToggle] = useState(false); //this toggle is currently not being used\n const ref = useRef(null);\n const execute = (commands, toggledCommands) => {\n if (button.classToggle) {\n setToggle(!toggle);\n if (ref.current) {\n ref.current.classList.toggle(button.classToggle);\n if (ref.current.classList.contains(button.classToggle)) executeAll(ref, commands);else executeAll(ref, toggledCommands !== null && toggledCommands !== void 0 ? toggledCommands : commands);\n } else executeAll(ref, toggle ? toggledCommands !== null && toggledCommands !== void 0 ? toggledCommands : commands : commands);\n } else executeAll(ref, commands);\n };\n return /*#__PURE__*/_jsxDEV(StyledButton, {\n ref: ref,\n primary: button.primary ? button.primary : false,\n className: (button.class ? button.class : \"\") + (button.alwaysOn ? \" always-on\" : \"\") + (button.showWithIcon ? \" with-icon\" : \"\"),\n themeProp: themeProp,\n style: button.style,\n theme: theme,\n onClick: () => {\n var _button$commands;\n return execute((_button$commands = button.commands) !== null && _button$commands !== void 0 ? _button$commands : [], button.toggledCommands);\n },\n children: [button.hasText && button.name ? /*#__PURE__*/_jsxDEV(StyledSpan, {\n children: button.name\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 165,\n columnNumber: 43\n }, this) : ``, button.feather ? creatIcon(button.feather || \"X\", button.iconSize) : \"\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 157,\n columnNumber: 5\n }, this);\n};\n_s(Button, \"McrgaD3jAIsIrmY/a7aU1vofoRo=\");\n_c2 = Button;\nexport const Set = _ref3 => {\n let {\n buttonGroup,\n executeAll,\n theme,\n themeProp\n } = _ref3;\n const execute = (buttonRef, commands) => {\n // Do things here that depend on which button is clicked using buttonRef.current\n if (commands) executeAll(commands);\n };\n return /*#__PURE__*/_jsxDEV(_ThemeProvider, {\n theme: theme,\n children: buttonGroup.buttons.map(button => /*#__PURE__*/_jsxDEV(Button, {\n button: button,\n themeProp: themeProp,\n theme: theme,\n executeAll: (ref, commands) => execute(ref, commands)\n }, buttonGroup.name + \"_\" + button.name, false, {\n fileName: _jsxFileName,\n lineNumber: 190,\n columnNumber: 9\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 188,\n columnNumber: 7\n }, this);\n};\n_c3 = Set;\nexport const Menu = _ref4 => {\n let {\n menu,\n executeAll,\n theme,\n themeProp\n } = _ref4;\n const execute = (buttonRef, commands) => {\n // Do things here that depend on which button is clicked using buttonRef.current\n if (commands) executeAll(commands);\n };\n return /*#__PURE__*/_jsxDEV(_ThemeProvider, {\n theme: theme,\n children: Object.keys(menu).length === 0 ? \"\" : /*#__PURE__*/_jsxDEV(_StyledStyledDiv2, {\n className: \"custom_menu\",\n style: menu.style,\n $_css2: menu.css,\n children: !menu.groups ? `` : menu.groups.map((group, index) => /*#__PURE__*/_jsxDEV(StyledDiv, {\n className: \"menu_group \" + group.name,\n style: group.style,\n \"data-one-toggle-only\": group.toggleOnlyOne,\n children: group.buttons.map(button => /*#__PURE__*/_jsxDEV(Button, {\n button: button,\n themeProp: themeProp,\n theme: theme,\n executeAll: (ref, commands) => execute(ref, commands)\n }, group.name + \"_\" + button.name, false, {\n fileName: _jsxFileName,\n lineNumber: 223,\n columnNumber: 17\n }, this))\n }, \"group_\" + group.name + index, false, {\n fileName: _jsxFileName,\n lineNumber: 221,\n columnNumber: 11\n }, this))\n }, \"menu_bar\", false, {\n fileName: _jsxFileName,\n lineNumber: 219,\n columnNumber: 48\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 218,\n columnNumber: 5\n }, this);\n};\n_c4 = Menu;\nvar _c, _c2, _c3, _c4;\n$RefreshReg$(_c, \"Info\");\n$RefreshReg$(_c2, \"Button\");\n$RefreshReg$(_c3, \"Set\");\n$RefreshReg$(_c4, \"Menu\");","map":{"version":3,"names":["useRef","useState","Icons","StyledDiv","styled","div","StyledRegSpan","span","StyledSpan","StyledButton","button","props","themeProp","primary","theme","primaryColor","creatIcon","name","size","CustomIcon","Info","info","infoRef","Object","keys","length","style","css","map","class","Button","executeAll","toggle","setToggle","ref","execute","commands","toggledCommands","classToggle","current","classList","contains","alwaysOn","showWithIcon","hasText","feather","iconSize","Set","buttonGroup","buttonRef","buttons","Menu","menu","groups","group","index","toggleOnlyOne"],"sources":["/home/anasbouzid/streamlit-code-editor/code_editor/frontend/src/button-menu.tsx"],"sourcesContent":["// import styled, { ThemeProvider, css } from \"styled-components\"\nimport { useRef, useState } from \"react\"\nimport styled, { ThemeProvider } from 'styled-components/macro'\nimport * as Icons from \"react-feather\"\n\n\nexport interface customInfoText {\n name: string,\n class?: string,\n style?: object,\n theme?: object\n}\n\nexport interface infoBar {\n name?: string,\n css?: string,\n style?: object,\n info?: customInfoText[]\n}\n\nexport interface customButton {\n name: string,\n feather?: string,\n iconSize?: number,\n primary?: boolean,\n hasText?: boolean,\n showWithIcon?: boolean,\n alwaysOn?: boolean,\n commands?: any[],\n toggledCommands?: any[],\n class?: string,\n style?: object,\n theme?: object, \n classToggle?: string,\n}\n\nexport interface buttonGroup {\n name: string,\n buttons: customButton[],\n style?: object,\n toggleOnlyOne?: boolean,\n}\n\nexport interface menu {\n style?: object,\n css?: string,\n groups?: buttonGroup[]\n}\n\nexport const StyledDiv = styled.div``;\nexport const StyledRegSpan = styled.span``;\n\nexport const StyledSpan = styled.span`\n height: 2.5rem;\n line-height: 2.5rem;\n margin: 0px 0.4rem 0.15rem 0.4rem;\n opacity: 0;\n transform: scale(0);\n transition: opacity 300ms 150ms, transform 300ms 150ms;\n`;\n\nexport const StyledButton = styled.button<{primary?: boolean, themeProp: string, theme: object}>`\n border: none;\n border-radius: 5px;\n background: none;\n height: 2.5rem;\n line-height: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n opacity: 0;\n position: absolute;\n transform: scale(0);\n transition: opacity 20ms 300ms, transform 20ms 300ms;\n z-index: 9994;\n :focus {\n outline: none;\n }\n span{\n color: ${props => props.themeProp === \"streamlit_dark\"? \"rgba(250,250,250,0.6)\": \"rgba(0,0,0,0.5)\"};\n transform: scale(0);\n transform-origin: right;\n transition: opacity 300ms 150ms, transform 300ms 150ms;\n }\n :hover span {\n color: ${props => props.primary? props.theme.primaryColor : props.themeProp === \"streamlit_dark\"? \"rgb(250,250,250)\" : \"rgb(49, 51, 63)\"};\n opacity: 1;\n transform: scale(1);\n }\n svg {\n stroke: ${props => props.themeProp === \"streamlit_dark\"? \"rgba(250,250,250,0.6)\": \"rgba(0,0,0,0.5)\"};\n transform: scale(0);\n transition: opacity 300ms 150ms, transform 300ms 150ms;\n }\n :hover svg {\n stroke: ${props => props.primary? props.theme.primaryColor : props.themeProp === \"streamlit_dark\"? \"rgb(250,250,250)\" : \"rgb(49, 51, 63)\"};\n }\n`;\n\nexport type iconKey = keyof typeof Icons;\n\nexport const creatIcon = (name: iconKey, size = 16) => {\n const CustomIcon = Icons[name];\n return ;\n}\n\nexport type CustomInfoBar = {\n theme: object,\n info: infoBar,\n infoRef: any,\n}\n\nexport const Info = ({info, theme, infoRef}: CustomInfoBar) => {\n\n return (\n \n {(Object.keys(info).length === 0) ? `` : \n {\n }\n {(info.info || []).map((info: customInfoText)=>(\n \n {info.name}\n \n ))}\n }\n );\n}\n \nexport type CustomButtonType = {\n button: customButton, \n theme: object, \n themeProp: string, \n executeAll: (ref: React.RefObject, commands: any[]) => void\n}\nexport const Button = ({button, theme, themeProp, executeAll}: CustomButtonType) => {\n const [toggle, setToggle] = useState(false); //this toggle is currently not being used\n const ref = useRef(null);\n\n const execute = (commands: any[], toggledCommands?: any[]) => {\n if(button.classToggle){\n setToggle(!toggle);\n if (ref.current){\n ref.current.classList.toggle(button.classToggle);\n if(ref.current.classList.contains(button.classToggle))\n executeAll(ref, commands);\n else\n executeAll(ref, toggledCommands ?? commands);\n }\n else \n executeAll(ref, toggle? toggledCommands?? commands : commands);\n } \n else \n executeAll(ref, commands);\n }\n\n return (\n execute(button.commands ?? [], button.toggledCommands)}>\n {(button.hasText && button.name)? {button.name} : ``}\n {button.feather? creatIcon(button.feather as iconKey || \"X\", button.iconSize) : \"\"}\n \n )\n}\n\nexport type CustomButtonSet = \n{\n theme: object,\n themeProp: string,\n buttonGroup: buttonGroup,\n executeAll: (commands: any[]) => void \n}\n \nexport const Set = ({buttonGroup, executeAll, theme, themeProp}: CustomButtonSet) => {\n\n const execute = (buttonRef: React.RefObject, commands: any[]) => {\n // Do things here that depend on which button is clicked using buttonRef.current\n if(commands)\n executeAll(commands);\n }\n\n return (\n \n {buttonGroup.buttons.map( (button) => (\n