Skip to content

Commit 5713c63

Browse files
authored
Merge pull request #209 from kpinnipa/newBranchTest
Update CodeMirror to stable version via jupyterlab update.
2 parents b00d759 + f356aff commit 5713c63

7 files changed

+1066
-1000
lines changed

src/CodeSnippetDisplay.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,8 @@ export class CodeSnippetDisplay extends React.Component<
525525
if (target.innerHTML !== new_element.value) {
526526
const newName = new_element.value;
527527

528-
const isDuplicateName = this.props.codeSnippetManager.duplicateNameExists(
529-
newName
530-
);
528+
const isDuplicateName =
529+
this.props.codeSnippetManager.duplicateNameExists(newName);
531530

532531
if (isDuplicateName) {
533532
await showDialog({
@@ -605,8 +604,8 @@ export class CodeSnippetDisplay extends React.Component<
605604
'--jp-content-font-color3'
606605
);
607606

608-
(this._dragData.dragImage
609-
.children[0] as HTMLElement).style.color = dragImageTextColor;
607+
(this._dragData.dragImage.children[0] as HTMLElement).style.color =
608+
dragImageTextColor;
610609

611610
// add CSS style
612611
this._dragData.dragImage.classList.add(SNIPPET_DRAG_IMAGE);
@@ -1498,7 +1497,8 @@ export class CodeSnippetDisplay extends React.Component<
14981497
if (value.button.accept) {
14991498
const dirs = value.value.split('/');
15001499

1501-
const codeSnippetContentsManager = CodeSnippetContentsService.getInstance();
1500+
const codeSnippetContentsManager =
1501+
CodeSnippetContentsService.getInstance();
15021502

15031503
let path = '';
15041504
for (let i = 0; i < dirs.length; i++) {

src/CodeSnippetEditor.tsx

+50-33
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ export class CodeSnippetEditor extends ReactWidget {
177177
document.getElementById('code-' + this._codeSnippetEditorMetaData.id)
178178
) {
179179
const editorFactory = this.editorServices.factoryService.newInlineEditor;
180-
const getMimeTypeByLanguage = this.editorServices.mimeTypeService
181-
.getMimeTypeByLanguage;
180+
const getMimeTypeByLanguage =
181+
this.editorServices.mimeTypeService.getMimeTypeByLanguage;
182182

183183
this.editor = editorFactory({
184184
host: document.getElementById(
@@ -257,15 +257,21 @@ export class CodeSnippetEditor extends ReactWidget {
257257
this.dispose();
258258
super.onCloseRequest(msg);
259259
} else if (response.button.label === 'Save') {
260-
const name = (document.querySelector(
261-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
262-
) as HTMLInputElement).value;
263-
const description = (document.querySelector(
264-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
265-
) as HTMLInputElement).value;
266-
const language = (document.querySelector(
267-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
268-
) as HTMLSelectElement).value;
260+
const name = (
261+
document.querySelector(
262+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
263+
) as HTMLInputElement
264+
).value;
265+
const description = (
266+
document.querySelector(
267+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
268+
) as HTMLInputElement
269+
).value;
270+
const language = (
271+
document.querySelector(
272+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
273+
) as HTMLSelectElement
274+
).value;
269275

270276
const validity = validateInputs(name, description, language);
271277
if (validity) {
@@ -333,15 +339,21 @@ export class CodeSnippetEditor extends ReactWidget {
333339
}
334340

335341
saveChange(event: React.MouseEvent<HTMLElement, MouseEvent>): void {
336-
const name = (document.querySelector(
337-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
338-
) as HTMLInputElement).value;
339-
const description = (document.querySelector(
340-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
341-
) as HTMLInputElement).value;
342-
const language = (document.querySelector(
343-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
344-
) as HTMLSelectElement).value;
342+
const name = (
343+
document.querySelector(
344+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
345+
) as HTMLInputElement
346+
).value;
347+
const description = (
348+
document.querySelector(
349+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
350+
) as HTMLInputElement
351+
).value;
352+
const language = (
353+
document.querySelector(
354+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
355+
) as HTMLSelectElement
356+
).value;
345357

346358
const validity = validateInputs(name, description, language);
347359
if (validity) {
@@ -350,15 +362,21 @@ export class CodeSnippetEditor extends ReactWidget {
350362
}
351363

352364
async updateSnippet(): Promise<boolean> {
353-
const name = (document.querySelector(
354-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
355-
) as HTMLInputElement).value;
356-
const description = (document.querySelector(
357-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
358-
) as HTMLInputElement).value;
359-
const language = (document.querySelector(
360-
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
361-
) as HTMLSelectElement).value;
365+
const name = (
366+
document.querySelector(
367+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_NAME_INPUT}`
368+
) as HTMLInputElement
369+
).value;
370+
const description = (
371+
document.querySelector(
372+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_DESC_INPUT}`
373+
) as HTMLInputElement
374+
).value;
375+
const language = (
376+
document.querySelector(
377+
`.${CODE_SNIPPET_EDITOR}-${this._codeSnippetEditorMetaData.id} .${CODE_SNIPPET_EDITOR_LANG_INPUT}`
378+
) as HTMLSelectElement
379+
).value;
362380

363381
this._codeSnippetEditorMetaData.name = name;
364382
this._codeSnippetEditorMetaData.description = description;
@@ -409,11 +427,10 @@ export class CodeSnippetEditor extends ReactWidget {
409427
).then((res: boolean) => {
410428
if (res) {
411429
// get the id of snippet you are editting
412-
const removedSnippet = this.contentsService.getSnippet(
413-
oldName
414-
)[0];
430+
const removedSnippet =
431+
this.contentsService.getSnippet(oldName)[0];
415432

416-
// delete the one you are editting
433+
// delete the one you are editing
417434
this.contentsService.deleteSnippet(removedSnippet.id);
418435
} else {
419436
return false;

src/CodeSnippetInputDialog.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const FILE_DIALOG_CLASS = 'jp-codeSnippet-fileDialog';
2323
/**
2424
* CSS STYLING
2525
*/
26-
// const CODE_SNIPPET_DIALOG_INPUT = 'jp-codeSnippet-dialog-input';
2726
const CODE_SNIPPET_DIALOG_NAME_INPUT = 'jp-codeSnippet-dialog-name-input';
2827
const CODE_SNIPPET_DIALOG_DESC_INPUT = 'jp-codeSnippet-dialog-desc-input';
2928
const CODE_SNIPPET_DIALOG_LANG_INPUT = 'jp-codeSnippet-dialog-lang-input';
@@ -242,15 +241,21 @@ class InputHandler extends Widget {
242241
getValue(): string[] {
243242
const inputs = [];
244243
inputs.push(
245-
(this.node.querySelector(
246-
`.${CODE_SNIPPET_DIALOG_NAME_INPUT}`
247-
) as HTMLInputElement).value,
248-
(this.node.querySelector(
249-
`.${CODE_SNIPPET_DIALOG_DESC_INPUT}`
250-
) as HTMLInputElement).value,
251-
(this.node.querySelector(
252-
`.${CODE_SNIPPET_DIALOG_LANG_INPUT}`
253-
) as HTMLInputElement).value
244+
(
245+
this.node.querySelector(
246+
`.${CODE_SNIPPET_DIALOG_NAME_INPUT}`
247+
) as HTMLInputElement
248+
).value,
249+
(
250+
this.node.querySelector(
251+
`.${CODE_SNIPPET_DIALOG_DESC_INPUT}`
252+
) as HTMLInputElement
253+
).value,
254+
(
255+
this.node.querySelector(
256+
`.${CODE_SNIPPET_DIALOG_LANG_INPUT}`
257+
) as HTMLInputElement
258+
).value
254259
);
255260

256261
inputs.push(...Private.selectedTags);

src/CodeSnippetPreview.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { ArrayExt } from '@lumino/algorithm';
1212
import { ICodeSnippet, CodeSnippetService } from './CodeSnippetService';
1313

1414
/**
15-
* The class name for preview box
15+
* The class name for preview box.
1616
*/
1717
const PREVIEW_CLASS = 'jp-codeSnippet-preview';
1818
const PREVIEW_CONTENT = 'jp-codeSnippet-preview-content';
@@ -156,8 +156,8 @@ export class Preview<T> extends Widget {
156156

157157
if (!this.editor && document.getElementById(PREVIEW_CONTENT + this._id)) {
158158
const editorFactory = this.editorServices.factoryService.newInlineEditor;
159-
const getMimeTypeByLanguage = this.editorServices.mimeTypeService
160-
.getMimeTypeByLanguage;
159+
const getMimeTypeByLanguage =
160+
this.editorServices.mimeTypeService.getMimeTypeByLanguage;
161161

162162
let previewFontSize = this.codeSnippetService.settings.get(
163163
'snippetPreviewFontSize'

src/CodeSnippetService.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface ICodeSnippet {
88
name: string;
99
description: string;
1010
language: string;
11-
// code separated by new line
11+
// code separated by a new line
1212
code: string[];
1313
id: number;
1414
tags?: string[];
@@ -29,7 +29,7 @@ export class CodeSnippetService {
2929
if (
3030
!JSONExt.deepEqual(
3131
newCodeSnippetList,
32-
(this.codeSnippetList as unknown) as PartialJSONValue
32+
this.codeSnippetList as unknown as PartialJSONValue
3333
)
3434
) {
3535
this.codeSnippetList = this.convertToICodeSnippetList(
@@ -55,7 +55,7 @@ export class CodeSnippetService {
5555
if (this.settingManager.get('snippets').user === undefined) {
5656
// set the user setting + default in the beginning
5757
this.settingManager
58-
.set('snippets', (defaultSnippets as unknown) as PartialJSONValue)
58+
.set('snippets', defaultSnippets as unknown as PartialJSONValue)
5959
.then(() => {
6060
const userSnippets = this.convertToICodeSnippetList(
6161
this.settingManager.get('snippets').user as JSONArray
@@ -82,7 +82,7 @@ export class CodeSnippetService {
8282
const snippetList: ICodeSnippet[] = [];
8383

8484
snippets.forEach((snippet) => {
85-
snippetList.push((snippet as unknown) as ICodeSnippet);
85+
snippetList.push(snippet as unknown as ICodeSnippet);
8686
});
8787
return snippetList;
8888
}
@@ -124,7 +124,7 @@ export class CodeSnippetService {
124124
}
125125

126126
await this.settingManager
127-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
127+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
128128
.catch((_) => {
129129
return false;
130130
});
@@ -152,7 +152,7 @@ export class CodeSnippetService {
152152
}
153153

154154
await this.settingManager
155-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
155+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
156156
.catch((_) => {
157157
return false;
158158
});
@@ -168,7 +168,7 @@ export class CodeSnippetService {
168168
}
169169
}
170170
await this.settingManager
171-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
171+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
172172
.catch((_) => {
173173
return false;
174174
});
@@ -196,7 +196,7 @@ export class CodeSnippetService {
196196
}
197197

198198
await this.settingManager
199-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
199+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
200200
.catch((_) => {
201201
return false;
202202
});
@@ -228,7 +228,7 @@ export class CodeSnippetService {
228228
});
229229

230230
await this.settingManager
231-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
231+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
232232
.catch((_) => {
233233
return false;
234234
});
@@ -245,7 +245,7 @@ export class CodeSnippetService {
245245
this.codeSnippetList.forEach((snippet, i) => (snippet.id = i));
246246

247247
await this.settingManager
248-
.set('snippets', (this.codeSnippetList as unknown) as PartialJSONValue)
248+
.set('snippets', this.codeSnippetList as unknown as PartialJSONValue)
249249
.catch((_) => {
250250
return false;
251251
});

src/CodeSnippetWidget.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ export class CodeSnippetWidget extends ReactWidget {
290290
this.moveCodeSnippet(srcIdx, idx);
291291
}
292292
} else {
293-
const notebook: Notebook = event.mimeData.getData('internal:cells')[0]
294-
.parent;
293+
const notebook: Notebook =
294+
event.mimeData.getData('internal:cells')[0].parent;
295295

296296
const language = notebook.model.defaultKernelLanguage;
297297
// Handle the case where we are copying cells

0 commit comments

Comments
 (0)