Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit dd7c208

Browse files
committed
client: apply grouping to the MIME type list
1 parent 4f5d874 commit dd7c208

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/public/app/widgets/type_widgets/options/code_notes/code_mime_types.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,24 @@ export default class CodeMimeTypesOptions extends OptionsWidget {
1919

2020
async optionsLoaded(options) {
2121
this.$mimeTypes.empty();
22+
let index = -1;
23+
let prevInitial = "";
2224

2325
for (const mimeType of mimeTypesService.getMimeTypes()) {
2426
const id = "code-mime-type-" + (idCtr++);
27+
index++;
28+
29+
// Append a heading to group items by the first letter, excepting for the
30+
// first item ("Plain Text"). Note: this code assumes the items are already
31+
// in alphabetical ordered.
32+
if (index > 0) {
33+
const initial = mimeType.title.charAt(0).toUpperCase();
34+
35+
if (initial !== prevInitial) {
36+
this.$mimeTypes.append($("<h5>").text(initial));
37+
prevInitial = initial;
38+
}
39+
}
2540

2641
this.$mimeTypes.append($("<li>")
2742
.append($('<input type="checkbox" class="form-check-input">')

0 commit comments

Comments
 (0)