(currctJupyterModel)
| 177 | |
| 178 | */ |
| 179 | const getActiveContext = (currctJupyterModel) => { |
| 180 | // Obtain the current input box (cell) from the Textarea of the current input box |
| 181 | const activeCell = document.activeElement.parentElement.parentElement; |
| 182 | |
| 183 | const cellElements = Array.from(document.querySelectorAll(`.${currctJupyterModel.requiredClassName.cell}`)); |
| 184 | const activeCellIndex = cellElements.findIndex(cell => cell.contains(activeCell)); |
| 185 | let context = [] |
| 186 | |
| 187 | for (let i = 0; i < cellElements.length; i++) { |
| 188 | if (i == activeCellIndex) { |
| 189 | const [activeCellContent, cursorAtEndInLine] = getActiveCellPointerCode(activeCell, i, currctJupyterModel) |
| 190 | if (!cursorAtEndInLine) return [] |
| 191 | |
| 192 | context = [...context, ...activeCellContent] |
| 193 | } else if (i < activeCellIndex) { |
| 194 | const cellContent = getCellCode(cellElements[i], i, currctJupyterModel) |
| 195 | context = [...context, ...cellContent] |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | return context |
| 200 | } |
| 201 | |
| 202 | |
| 203 |
no test coverage detected