Skip to content

Commit

Permalink
Comply to new addScript API
Browse files Browse the repository at this point in the history
Required by nextcloud/server#30015

Signed-off-by: Jonas Meurer <jonas@freesources.org>
  • Loading branch information
mejo- committed Dec 14, 2021
1 parent 074db6b commit 2a8d67f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/Listeners/LoadViewerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function handle(Event $event): void {
if (!$event instanceof LoadViewer) {
return;
}
\OCP\Util::addScript('text', 'text-viewer');
\OCP\Util::addScript('text', 'text-viewer', 'viewer');
\OCP\Util::addStyle('text', 'icons');
}
}
11 changes: 4 additions & 7 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,14 @@ import { openMimetypesMarkdown, openMimetypesPlainText } from './helpers/mime'
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
__webpack_public_path__ = OC.linkTo('text', 'js/') // eslint-disable-line

document.addEventListener('DOMContentLoaded', () => {
if (typeof OCA.Viewer === 'undefined') {
console.error('Viewer app is not installed')
return
}

if (typeof OCA.Viewer === 'undefined') {
console.error('Viewer app is not installed')
} else {
OCA.Viewer.registerHandler({
id: 'text',
mimes: [...openMimetypesMarkdown, ...openMimetypesPlainText],
component: ViewerComponent,
group: null,
theme: 'default',
})
})
}

0 comments on commit 2a8d67f

Please sign in to comment.