Skip to content

Commit 04fcbad

Browse files
committed
fix: register viewer by uniq name instead of "component"
- Anonymous function in object property has a name of the property - component - This name is used for global viewer component registration - `component` is not a valid name, because it is a built-in name for Vue and it registers a global component - Using named function to have an explicit name Signed-off-by: Grigorii K. Shartsev <[email protected]>
1 parent 7b8b3de commit 04fcbad

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/viewer.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,23 @@ import { openMimetypesMarkdown, openMimetypesPlainText } from './helpers/mime.js
2626
__webpack_nonce__ = btoa(OC.requestToken) // eslint-disable-line
2727
__webpack_public_path__ = OC.linkTo('text', 'js/') // eslint-disable-line
2828

29+
/**
30+
* Wrapper for async registration of ViewerComponent.
31+
* Note: it should be named function - the name is used for component registration.
32+
*
33+
* @return {Promise<import('./components/ViewerComponent.vue')>} ViewerComponent
34+
*/
35+
function AsyncTextViewerComponent() {
36+
return import('./components/ViewerComponent.vue')
37+
}
38+
2939
if (typeof OCA.Viewer === 'undefined') {
3040
logger.error('Viewer app is not installed')
3141
} else {
3242
OCA.Viewer.registerHandler({
3343
id: 'text',
3444
mimes: [...openMimetypesMarkdown, ...openMimetypesPlainText],
35-
component: () => import('./components/ViewerComponent.vue'),
45+
component: AsyncTextViewerComponent,
3646
group: null,
3747
theme: 'default',
3848
canCompare: true,

0 commit comments

Comments
 (0)