File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -164,24 +164,24 @@ function activateCodeSnippet(
164
164
execute : ( ) => {
165
165
const highlightedCode = getSelectedText ( ) ;
166
166
if ( highlightedCode === '' ) {
167
- //if user just right-clicks the whole cell to save
167
+ //if user just right-clicks cell(s) to save
168
168
const curr = document . getElementsByClassName ( 'jp-Cell jp-mod-selected' ) ;
169
169
const resultArray = [ ] ;
170
170
for ( let i = 1 ; i < curr . length ; i ++ ) {
171
+ //loop through each cell
171
172
const text = curr [ i ] as HTMLElement ;
172
173
const textContent = text . innerText ;
173
174
const arrayInput = textContent . split ( '\n' ) ;
174
175
const indexedInput = arrayInput . slice ( 1 ) ;
175
176
for ( let i = 0 ; i < indexedInput . length ; i ++ ) {
176
- for ( let j = 0 ; j < indexedInput [ i ] . length ; j ++ ) {
177
- if ( indexedInput [ i ] . charCodeAt ( j ) === 8203 ) {
178
- indexedInput [ i ] = '' ;
179
- }
177
+ // looping through each line in cell
178
+ if ( indexedInput [ i ] . charCodeAt ( 0 ) === 8203 ) {
179
+ //check if first char in line is invalid
180
+ indexedInput [ i ] = '' ; //replace invalid line with empty string
180
181
}
181
- resultArray . push ( indexedInput [ i ] ) ;
182
+ resultArray . push ( indexedInput [ i ] ) ; //push cell code lines into result
182
183
}
183
184
}
184
- console . log ( resultArray ) ;
185
185
CodeSnippetInputDialog ( codeSnippetWidget , resultArray , - 1 ) ;
186
186
} else {
187
187
CodeSnippetInputDialog (
You can’t perform that action at this time.
0 commit comments