@jupyterlab/fileeditor-extension 4.5.0-alpha.1 → 4.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/commands.ts CHANGED
@@ -289,6 +289,26 @@ export namespace Commands {
289
289
  ? trans.__('Decrease Text Editor Font Size')
290
290
  : trans.__('Decrease Font Size');
291
291
  }
292
+ },
293
+ describedBy: {
294
+ args: {
295
+ type: 'object',
296
+ properties: {
297
+ delta: {
298
+ type: 'number',
299
+ description: trans.__(
300
+ 'The font size change delta (positive to increase, negative to decrease)'
301
+ )
302
+ },
303
+ isMenu: {
304
+ type: 'boolean',
305
+ description: trans.__(
306
+ 'Whether the command is called from a menu context'
307
+ )
308
+ }
309
+ },
310
+ required: ['delta']
311
+ }
292
312
  }
293
313
  });
294
314
 
@@ -309,7 +329,13 @@ export namespace Commands {
309
329
  isEnabled,
310
330
  isToggled: () =>
311
331
  config.lineNumbers ?? extensions.baseConfiguration.lineNumbers,
312
- label: trans.__('Show Line Numbers')
332
+ label: trans.__('Show Line Numbers'),
333
+ describedBy: {
334
+ args: {
335
+ type: 'object',
336
+ properties: {}
337
+ }
338
+ }
313
339
  });
314
340
 
315
341
  commands.addCommand(CommandIDs.currentLineNumbers, {
@@ -331,6 +357,12 @@ export namespace Commands {
331
357
  | boolean
332
358
  | undefined) ?? false
333
359
  );
360
+ },
361
+ describedBy: {
362
+ args: {
363
+ type: 'object',
364
+ properties: {}
365
+ }
334
366
  }
335
367
  });
336
368
 
@@ -354,7 +386,18 @@ export namespace Commands {
354
386
  (config.lineWrap ?? extensions.baseConfiguration.lineWrap)
355
387
  );
356
388
  },
357
- label: trans.__('Word Wrap')
389
+ label: trans.__('Word Wrap'),
390
+ describedBy: {
391
+ args: {
392
+ type: 'object',
393
+ properties: {
394
+ mode: {
395
+ type: 'boolean',
396
+ description: trans.__('Whether to enable word wrap')
397
+ }
398
+ }
399
+ }
400
+ }
358
401
  });
359
402
 
360
403
  commands.addCommand(CommandIDs.currentLineWrap, {
@@ -374,6 +417,12 @@ export namespace Commands {
374
417
  return (
375
418
  (widget?.content.editor.getOption('lineWrap') as boolean) ?? false
376
419
  );
420
+ },
421
+ describedBy: {
422
+ args: {
423
+ type: 'object',
424
+ properties: {}
425
+ }
377
426
  }
378
427
  });
379
428
 
@@ -407,6 +456,19 @@ export namespace Commands {
407
456
  return args['size']
408
457
  ? args['size'] === currentIndentUnit
409
458
  : 'Tab' == currentIndentUnit;
459
+ },
460
+ describedBy: {
461
+ args: {
462
+ type: 'object',
463
+ properties: {
464
+ size: {
465
+ type: 'string',
466
+ description: trans.__(
467
+ 'The number of spaces for indentation (or Tab for tab indentation)'
468
+ )
469
+ }
470
+ }
471
+ }
410
472
  }
411
473
  });
412
474
 
@@ -427,7 +489,13 @@ export namespace Commands {
427
489
  label: trans.__('Match Brackets'),
428
490
  isEnabled,
429
491
  isToggled: () =>
430
- config.matchBrackets ?? extensions.baseConfiguration.matchBrackets
492
+ config.matchBrackets ?? extensions.baseConfiguration.matchBrackets,
493
+ describedBy: {
494
+ args: {
495
+ type: 'object',
496
+ properties: {}
497
+ }
498
+ }
431
499
  });
432
500
 
433
501
  commands.addCommand(CommandIDs.currentMatchBrackets, {
@@ -449,6 +517,12 @@ export namespace Commands {
449
517
  | boolean
450
518
  | undefined) ?? false
451
519
  );
520
+ },
521
+ describedBy: {
522
+ args: {
523
+ type: 'object',
524
+ properties: {}
525
+ }
452
526
  }
453
527
  });
454
528
 
@@ -473,7 +547,20 @@ export namespace Commands {
473
547
  label: trans.__('Auto Close Brackets in Text Editor'),
474
548
  isToggled: () =>
475
549
  config.autoClosingBrackets ??
476
- extensions.baseConfiguration.autoClosingBrackets
550
+ extensions.baseConfiguration.autoClosingBrackets,
551
+ describedBy: {
552
+ args: {
553
+ type: 'object',
554
+ properties: {
555
+ force: {
556
+ type: 'boolean',
557
+ description: trans.__(
558
+ 'Force enable/disable auto closing brackets'
559
+ )
560
+ }
561
+ }
562
+ }
563
+ }
477
564
  });
478
565
 
479
566
  commands.addCommand(CommandIDs.autoClosingBracketsUniversal, {
@@ -502,7 +589,13 @@ export namespace Commands {
502
589
  isToggled: () =>
503
590
  commands.isToggled(CommandIDs.autoClosingBrackets) ||
504
591
  commands.isToggled(autoClosingBracketsNotebook) ||
505
- commands.isToggled(autoClosingBracketsConsole)
592
+ commands.isToggled(autoClosingBracketsConsole),
593
+ describedBy: {
594
+ args: {
595
+ type: 'object',
596
+ properties: {}
597
+ }
598
+ }
506
599
  });
507
600
 
508
601
  /**
@@ -524,7 +617,22 @@ export namespace Commands {
524
617
  }
525
618
  },
526
619
  isToggled: args =>
527
- args['theme'] === (config.theme ?? extensions.baseConfiguration.theme)
620
+ args['theme'] === (config.theme ?? extensions.baseConfiguration.theme),
621
+ describedBy: {
622
+ args: {
623
+ type: 'object',
624
+ properties: {
625
+ theme: {
626
+ type: 'string',
627
+ description: trans.__('The theme name to change to')
628
+ },
629
+ displayName: {
630
+ type: 'string',
631
+ description: trans.__('The display name of the theme')
632
+ }
633
+ }
634
+ }
635
+ }
528
636
  });
529
637
 
530
638
  commands.addCommand(CommandIDs.find, {
@@ -537,7 +645,13 @@ export namespace Commands {
537
645
  const editor = widget.content.editor as CodeMirrorEditor;
538
646
  editor.execCommand(findNext);
539
647
  },
540
- isEnabled
648
+ isEnabled,
649
+ describedBy: {
650
+ args: {
651
+ type: 'object',
652
+ properties: {}
653
+ }
654
+ }
541
655
  });
542
656
 
543
657
  commands.addCommand(CommandIDs.goToLine, {
@@ -560,7 +674,22 @@ export namespace Commands {
560
674
  editor.execCommand(gotoLine);
561
675
  }
562
676
  },
563
- isEnabled
677
+ isEnabled,
678
+ describedBy: {
679
+ args: {
680
+ type: 'object',
681
+ properties: {
682
+ line: {
683
+ type: 'number',
684
+ description: trans.__('The line number to go to (1-indexed)')
685
+ },
686
+ column: {
687
+ type: 'number',
688
+ description: trans.__('The column number to go to (1-indexed)')
689
+ }
690
+ }
691
+ }
692
+ }
564
693
  });
565
694
 
566
695
  commands.addCommand(CommandIDs.changeLanguage, {
@@ -593,6 +722,21 @@ export namespace Commands {
593
722
  const spec = languages.findByMIME(mime);
594
723
  const name = spec && spec.name;
595
724
  return args['name'] === name;
725
+ },
726
+ describedBy: {
727
+ args: {
728
+ type: 'object',
729
+ properties: {
730
+ name: {
731
+ type: 'string',
732
+ description: trans.__('The language name to change to')
733
+ },
734
+ displayName: {
735
+ type: 'string',
736
+ description: trans.__('The display name of the language')
737
+ }
738
+ }
739
+ }
596
740
  }
597
741
  });
598
742
 
@@ -610,7 +754,20 @@ export namespace Commands {
610
754
  widget.content.editor.replaceSelection?.(text);
611
755
  },
612
756
  isEnabled,
613
- label: trans.__('Replace Selection in Editor')
757
+ label: trans.__('Replace Selection in Editor'),
758
+ describedBy: {
759
+ args: {
760
+ type: 'object',
761
+ properties: {
762
+ text: {
763
+ type: 'string',
764
+ description: trans.__(
765
+ 'The text to replace the current selection with'
766
+ )
767
+ }
768
+ }
769
+ }
770
+ }
614
771
  });
615
772
 
616
773
  /**
@@ -628,7 +785,13 @@ export namespace Commands {
628
785
  },
629
786
  isEnabled,
630
787
  icon: consoleIcon,
631
- label: trans.__('Create Console for Editor')
788
+ label: trans.__('Create Console for Editor'),
789
+ describedBy: {
790
+ args: {
791
+ type: 'object',
792
+ properties: {}
793
+ }
794
+ }
632
795
  });
633
796
 
634
797
  /**
@@ -650,7 +813,13 @@ export namespace Commands {
650
813
  }
651
814
  },
652
815
  label: trans.__('Restart Kernel'),
653
- isEnabled: () => consoleTracker !== null && isEnabled()
816
+ isEnabled: () => consoleTracker !== null && isEnabled(),
817
+ describedBy: {
818
+ args: {
819
+ type: 'object',
820
+ properties: {}
821
+ }
822
+ }
654
823
  });
655
824
 
656
825
  /**
@@ -714,7 +883,13 @@ export namespace Commands {
714
883
  }
715
884
  },
716
885
  isEnabled,
717
- label: trans.__('Run Selected Code')
886
+ label: trans.__('Run Selected Code'),
887
+ describedBy: {
888
+ args: {
889
+ type: 'object',
890
+ properties: {}
891
+ }
892
+ }
718
893
  });
719
894
 
720
895
  /**
@@ -752,7 +927,13 @@ export namespace Commands {
752
927
  }
753
928
  },
754
929
  isEnabled,
755
- label: trans.__('Run All Code')
930
+ label: trans.__('Run All Code'),
931
+ describedBy: {
932
+ args: {
933
+ type: 'object',
934
+ properties: {}
935
+ }
936
+ }
756
937
  });
757
938
 
758
939
  /**
@@ -779,7 +960,13 @@ export namespace Commands {
779
960
  );
780
961
  },
781
962
  icon: markdownIcon,
782
- label: trans.__('Show Markdown Preview')
963
+ label: trans.__('Show Markdown Preview'),
964
+ describedBy: {
965
+ args: {
966
+ type: 'object',
967
+ properties: {}
968
+ }
969
+ }
783
970
  });
784
971
 
785
972
  /**
@@ -809,6 +996,42 @@ export namespace Commands {
809
996
  cwd as string,
810
997
  (args.fileExt as string) ?? 'txt'
811
998
  );
999
+ },
1000
+ describedBy: {
1001
+ args: {
1002
+ type: 'object',
1003
+ properties: {
1004
+ cwd: {
1005
+ type: 'string',
1006
+ description: trans.__('The current working directory path')
1007
+ },
1008
+ fileExt: {
1009
+ type: 'string',
1010
+ description: trans.__('The file extension for the new file')
1011
+ },
1012
+ isPalette: {
1013
+ type: 'boolean',
1014
+ description:
1015
+ 'Whether the command is being called from the command palette'
1016
+ },
1017
+ paletteLabel: {
1018
+ type: 'string',
1019
+ description: trans.__('The label to show in the command palette')
1020
+ },
1021
+ launcherLabel: {
1022
+ type: 'string',
1023
+ description: trans.__('The label to show in the launcher')
1024
+ },
1025
+ caption: {
1026
+ type: 'string',
1027
+ description: trans.__('The caption for the command')
1028
+ },
1029
+ iconName: {
1030
+ type: 'string',
1031
+ description: trans.__('The name of the icon to use')
1032
+ }
1033
+ }
1034
+ }
812
1035
  }
813
1036
  });
814
1037
 
@@ -825,6 +1048,22 @@ export namespace Commands {
825
1048
  execute: args => {
826
1049
  const cwd = args['cwd'] || defaultBrowser.model.path;
827
1050
  return createNew(commands, cwd as string, 'md');
1051
+ },
1052
+ describedBy: {
1053
+ args: {
1054
+ type: 'object',
1055
+ properties: {
1056
+ cwd: {
1057
+ type: 'string',
1058
+ description: trans.__('The current working directory path')
1059
+ },
1060
+ isPalette: {
1061
+ type: 'boolean',
1062
+ description:
1063
+ 'Whether the command is being called from the command palette'
1064
+ }
1065
+ }
1066
+ }
828
1067
  }
829
1068
  });
830
1069
 
@@ -855,7 +1094,13 @@ export namespace Commands {
855
1094
  return widget.editor.model.sharedModel.canUndo();
856
1095
  },
857
1096
  icon: undoIcon.bindprops({ stylesheet: 'menuItem' }),
858
- label: trans.__('Undo')
1097
+ label: trans.__('Undo'),
1098
+ describedBy: {
1099
+ args: {
1100
+ type: 'object',
1101
+ properties: {}
1102
+ }
1103
+ }
859
1104
  });
860
1105
 
861
1106
  /**
@@ -885,7 +1130,13 @@ export namespace Commands {
885
1130
  return widget.editor.model.sharedModel.canRedo();
886
1131
  },
887
1132
  icon: redoIcon.bindprops({ stylesheet: 'menuItem' }),
888
- label: trans.__('Redo')
1133
+ label: trans.__('Redo'),
1134
+ describedBy: {
1135
+ args: {
1136
+ type: 'object',
1137
+ properties: {}
1138
+ }
1139
+ }
889
1140
  });
890
1141
 
891
1142
  /**
@@ -920,7 +1171,13 @@ export namespace Commands {
920
1171
  return isSelected(widget.editor as CodeMirrorEditor);
921
1172
  },
922
1173
  icon: cutIcon.bindprops({ stylesheet: 'menuItem' }),
923
- label: trans.__('Cut')
1174
+ label: trans.__('Cut'),
1175
+ describedBy: {
1176
+ args: {
1177
+ type: 'object',
1178
+ properties: {}
1179
+ }
1180
+ }
924
1181
  });
925
1182
 
926
1183
  /**
@@ -954,7 +1211,13 @@ export namespace Commands {
954
1211
  return isSelected(widget.editor as CodeMirrorEditor);
955
1212
  },
956
1213
  icon: copyIcon.bindprops({ stylesheet: 'menuItem' }),
957
- label: trans.__('Copy')
1214
+ label: trans.__('Copy'),
1215
+ describedBy: {
1216
+ args: {
1217
+ type: 'object',
1218
+ properties: {}
1219
+ }
1220
+ }
958
1221
  });
959
1222
 
960
1223
  /**
@@ -981,7 +1244,13 @@ export namespace Commands {
981
1244
  },
982
1245
  isEnabled: () => Boolean(isEnabled() && tracker.currentWidget?.content),
983
1246
  icon: pasteIcon.bindprops({ stylesheet: 'menuItem' }),
984
- label: trans.__('Paste')
1247
+ label: trans.__('Paste'),
1248
+ describedBy: {
1249
+ args: {
1250
+ type: 'object',
1251
+ properties: {}
1252
+ }
1253
+ }
985
1254
  });
986
1255
 
987
1256
  /**
@@ -999,7 +1268,13 @@ export namespace Commands {
999
1268
  editor.execCommand(selectAll);
1000
1269
  },
1001
1270
  isEnabled: () => Boolean(isEnabled() && tracker.currentWidget?.content),
1002
- label: trans.__('Select All')
1271
+ label: trans.__('Select All'),
1272
+ describedBy: {
1273
+ args: {
1274
+ type: 'object',
1275
+ properties: {}
1276
+ }
1277
+ }
1003
1278
  });
1004
1279
 
1005
1280
  // All commands with isEnabled defined directly or in a semantic commands
@@ -1049,6 +1324,12 @@ export namespace Commands {
1049
1324
  if (id) {
1050
1325
  return manager.invoke(id);
1051
1326
  }
1327
+ },
1328
+ describedBy: {
1329
+ args: {
1330
+ type: 'object',
1331
+ properties: {}
1332
+ }
1052
1333
  }
1053
1334
  });
1054
1335
 
@@ -1060,6 +1341,12 @@ export namespace Commands {
1060
1341
  if (id) {
1061
1342
  return manager.select(id);
1062
1343
  }
1344
+ },
1345
+ describedBy: {
1346
+ args: {
1347
+ type: 'object',
1348
+ properties: {}
1349
+ }
1063
1350
  }
1064
1351
  });
1065
1352
 
@@ -1440,6 +1727,36 @@ export namespace Commands {
1440
1727
  label: trans.__('Open Code Viewer'),
1441
1728
  execute: (args: any) => {
1442
1729
  return openCodeViewer(args);
1730
+ },
1731
+ describedBy: {
1732
+ args: {
1733
+ type: 'object',
1734
+ properties: {
1735
+ content: {
1736
+ type: 'string',
1737
+ description: trans.__('The content to display in the code viewer')
1738
+ },
1739
+ label: {
1740
+ type: 'string',
1741
+ description: trans.__('The label for the code viewer')
1742
+ },
1743
+ mimeType: {
1744
+ type: 'string',
1745
+ description: trans.__('The MIME type of the content')
1746
+ },
1747
+ extension: {
1748
+ type: 'string',
1749
+ description: trans.__(
1750
+ 'The file extension to derive MIME type from'
1751
+ )
1752
+ },
1753
+ widgetId: {
1754
+ type: 'string',
1755
+ description: trans.__('The ID to assign to the widget')
1756
+ }
1757
+ },
1758
+ required: ['content']
1759
+ }
1443
1760
  }
1444
1761
  });
1445
1762
  }
package/src/index.ts CHANGED
@@ -58,6 +58,7 @@ import {
58
58
  } from '@jupyterlab/lsp';
59
59
  import { IMainMenu } from '@jupyterlab/mainmenu';
60
60
  import { IObservableList } from '@jupyterlab/observables';
61
+ import { IMarkdownParser } from '@jupyterlab/rendermime';
61
62
  import { IRenderMime } from '@jupyterlab/rendermime-interfaces';
62
63
  import { Session } from '@jupyterlab/services';
63
64
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
@@ -100,7 +101,8 @@ const plugin: JupyterFrontEndPlugin<IEditorTracker> = {
100
101
  ISessionContextDialogs,
101
102
  ITableOfContentsRegistry,
102
103
  ITranslator,
103
- IFormRendererRegistry
104
+ IFormRendererRegistry,
105
+ IMarkdownParser
104
106
  ],
105
107
  provides: IEditorTracker,
106
108
  autoStart: true
@@ -334,7 +336,8 @@ function activate(
334
336
  sessionDialogs_: ISessionContextDialogs | null,
335
337
  tocRegistry: ITableOfContentsRegistry | null,
336
338
  translator_: ITranslator | null,
337
- formRegistry: IFormRendererRegistry | null
339
+ formRegistry: IFormRendererRegistry | null,
340
+ parser: IMarkdownParser | null
338
341
  ): IEditorTracker {
339
342
  const id = plugin.id;
340
343
  const translator = translator_ ?? nullTranslator;
@@ -627,7 +630,7 @@ function activate(
627
630
 
628
631
  if (tocRegistry) {
629
632
  tocRegistry.add(new LaTeXTableOfContentsFactory(tracker));
630
- tocRegistry.add(new MarkdownTableOfContentsFactory(tracker));
633
+ tocRegistry.add(new MarkdownTableOfContentsFactory(tracker, parser));
631
634
  tocRegistry.add(new PythonTableOfContentsFactory(tracker));
632
635
  }
633
636
 
package/style/index.css CHANGED
@@ -9,6 +9,7 @@
9
9
  @import url('~@jupyterlab/statusbar/style/index.css');
10
10
  @import url('~@jupyterlab/apputils/style/index.css');
11
11
  @import url('~@jupyterlab/codeeditor/style/index.css');
12
+ @import url('~@jupyterlab/rendermime/style/index.css');
12
13
  @import url('~@jupyterlab/docregistry/style/index.css');
13
14
  @import url('~@jupyterlab/application/style/index.css');
14
15
  @import url('~@jupyterlab/documentsearch/style/index.css');
package/style/index.js CHANGED
@@ -9,6 +9,7 @@ import '@jupyterlab/ui-components/style/index.js';
9
9
  import '@jupyterlab/statusbar/style/index.js';
10
10
  import '@jupyterlab/apputils/style/index.js';
11
11
  import '@jupyterlab/codeeditor/style/index.js';
12
+ import '@jupyterlab/rendermime/style/index.js';
12
13
  import '@jupyterlab/docregistry/style/index.js';
13
14
  import '@jupyterlab/application/style/index.js';
14
15
  import '@jupyterlab/documentsearch/style/index.js';