Skip to content

Commit

Permalink
feat: support excalidraw file
Browse files Browse the repository at this point in the history
Signed-off-by: Hoang Pham <hoangmaths96@gmail.com>
  • Loading branch information
hweihwang committed May 16, 2024
1 parent a5fc9b1 commit 8b84fe9
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/img/filetypes/whiteboard.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions core/js/mimetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ OC.MimeType = {
while (mimeType in OC.MimeTypeList.aliases) {
mimeType = OC.MimeTypeList.aliases[mimeType];
}

if (mimeType in OC.MimeType._mimeTypeIcons) {
return OC.MimeType._mimeTypeIcons[mimeType];
}
Expand All @@ -94,6 +95,7 @@ OC.MimeType = {
}
}
if(OCA.Theming && gotIcon === null) {
console.log(mimeType);
path = OC.generateUrl('/apps/theming/img/core/filetypes/');
path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files);
gotIcon = true;
Expand Down
2 changes: 2 additions & 0 deletions core/js/mimetypelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OC.MimeTypeList={
"application/postscript": "image",
"application/rss+xml": "application/xml",
"application/vnd.android.package-archive": "package/x-generic",
"application/vnd.excalidraw+json": "whiteboard",
"application/vnd.lotus-wordpro": "x-office/document",
"application/vnd.garmin.tcx+xml": "location",
"application/vnd.google-earth.kml+xml": "location",
Expand Down Expand Up @@ -141,6 +142,7 @@ OC.MimeTypeList={
"text-code",
"text-vcard",
"video",
"whiteboard",
"x-office-document",
"x-office-drawing",
"x-office-form",
Expand Down
12 changes: 12 additions & 0 deletions lib/private/Repair/RepairMimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ private function updateMimetypes($updatedMimetypes) {
return $count;
}

private function introduceExcalidrawType() {
$updatedMimetypes = [
'excalidraw' => 'application/vnd.excalidraw+json',
];

return $this->updateMimetypes($updatedMimetypes);
}

private function introduceAsciidocType() {
$updatedMimetypes = [
'adoc' => 'text/asciidoc',
Expand Down Expand Up @@ -334,5 +342,9 @@ public function run(IOutput $out) {
if (version_compare($ocVersionFromBeforeUpdate, '29.0.0.10', '<') && $this->introduceReStructuredTextFormatType()) {
$out->info('Fixed ReStructured Text mime type');
}

if (version_compare($ocVersionFromBeforeUpdate, '29.0.0.10', '<') && $this->introduceExcalidrawType()) {
$out->info('Fixed Excalidraw mime type');
}
}
}
1 change: 1 addition & 0 deletions resources/config/mimetypealiases.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"application/postscript": "image",
"application/rss+xml": "application/xml",
"application/vnd.android.package-archive": "package/x-generic",
"application/vnd.excalidraw+json": "whiteboard",
"application/vnd.lotus-wordpro": "x-office/document",
"application/vnd.garmin.tcx+xml": "location",
"application/vnd.google-earth.kml+xml": "location",
Expand Down
1 change: 1 addition & 0 deletions resources/config/mimetypemapping.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"eps": ["application/postscript"],
"epub": ["application/epub+zip"],
"erf": ["image/x-dcraw"],
"excalidraw": ["application/vnd.excalidraw+json"],
"exe": ["application/x-ms-dos-executable"],
"fb2": ["application/x-fictionbook+xml", "text/plain"],
"flac": ["audio/flac"],
Expand Down

0 comments on commit 8b84fe9

Please sign in to comment.