Export to Markdown (#20661)

* Give saveAsExcel its own config options

* Wired up correctly

* Merge conflicts

* PR comments 1

Co-authored-by: Ben Russell <russellben@microsoft.com>
This commit is contained in:
Benjamin Russell
2022-10-13 18:08:21 -05:00
committed by GitHub
parent bee1c6be44
commit 38eb0c8429
13 changed files with 216 additions and 14 deletions

View File

@@ -52,6 +52,10 @@ export class SaveResultAction extends Action {
public static SAVEJSON_LABEL = localize('saveAsJson', "Save As JSON");
public static SAVEJSON_ICON = 'saveJson';
public static SAVEMARKDOWN_ID = 'grid.saveAsMarkdown';
public static SAVEMARKDOWN_LABEL = localize('saveAsMarkdown', "Save As Markdown");
public static SAVEMARKDOWN_ICON = 'saveMarkdown';
public static SAVEEXCEL_ID = 'grid.saveAsExcel';
public static SAVEEXCEL_LABEL = localize('saveAsExcel', "Save As Excel");
public static SAVEEXCEL_ICON = 'saveExcel';

View File

@@ -953,6 +953,7 @@ class GridTable<T> extends GridTableBase<T> {
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveResultAction.SAVECSV_ICON, SaveFormat.CSV),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveResultAction.SAVEEXCEL_ICON, SaveFormat.EXCEL),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveResultAction.SAVEJSON_ICON, SaveFormat.JSON),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveResultAction.SAVEMARKDOWN_ICON, SaveFormat.MARKDOWN),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveResultAction.SAVEXML_ICON, SaveFormat.XML),
this.instantiationService.createInstance(ChartDataAction)
);
@@ -969,6 +970,7 @@ class GridTable<T> extends GridTableBase<T> {
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVECSV_ID, SaveResultAction.SAVECSV_LABEL, SaveResultAction.SAVECSV_ICON, SaveFormat.CSV),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEEXCEL_ID, SaveResultAction.SAVEEXCEL_LABEL, SaveResultAction.SAVEEXCEL_ICON, SaveFormat.EXCEL),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEJSON_ID, SaveResultAction.SAVEJSON_LABEL, SaveResultAction.SAVEJSON_ICON, SaveFormat.JSON),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEMARKDOWN_ID, SaveResultAction.SAVEMARKDOWN_LABEL, SaveResultAction.SAVEMARKDOWN_ICON, SaveFormat.MARKDOWN),
this.instantiationService.createInstance(SaveResultAction, SaveResultAction.SAVEXML_ID, SaveResultAction.SAVEXML_LABEL, SaveResultAction.SAVEXML_ICON, SaveFormat.XML),
];
}

View File

@@ -287,6 +287,14 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
handler: gridCommands.saveAsJson
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: gridActions.GRID_SAVEMARKDOWN_ID,
weight: KeybindingWeight.EditorContrib,
when: ResultsGridFocusCondition,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyR, KeyMod.CtrlCmd | KeyCode.KeyM),
handler: gridCommands.saveAsMarkdown
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: gridActions.GRID_SAVEEXCEL_ID,
weight: KeybindingWeight.EditorContrib,
@@ -384,6 +392,21 @@ const queryEditorConfiguration: IConfigurationNode = {
'description': localize('queryEditor.results.saveAsCsv.encoding', "File encoding used when saving results as CSV"),
'default': 'utf-8'
},
'queryEditor.results.saveAsMarkdown.encoding': {
'type': 'string',
'description': localize('queryEditor.results.saveAsMarkdown.encoding', "File encoding used when saving results as Markdown"),
'default': 'utf-8'
},
'queryEditor.results.saveAsMarkdown.includeHeaders': {
'type': 'boolean',
'description': localize('queryEditor.results.saveAsMarkdown.includeHeaders', "When true, column headers are included when saving results as a Markdown file"),
'default': true
},
'queryEditor.results.saveAsMarkdown.lineSeparator': {
'type': 'string',
'description': localize('queryEditor.results.saveAsMarkdown.lineSeparator', "Character(s) to use to separate lines when exporting to Markdown, defaults to system line endings"),
'default': null
},
'queryEditor.results.saveAsXml.formatted': {
'type': 'boolean',
'description': localize('queryEditor.results.saveAsXml.formatted', "When true, XML output will be formatted when saving results as XML"),