-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Julius Härtl <jus@bitgrid.net>
- Loading branch information
1 parent
d29ec59
commit 19cd0ea
Showing
6 changed files
with
337 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @author Julius Härtl <jus@bitgrid.net> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { registerWidget } from '@nextcloud/vue-richtext' | ||
|
||
import FileWidget from './views/ReferenceFileWidget.vue' | ||
|
||
registerWidget('file', (el, { richObjectType, richObject, accessible }) => { | ||
const Widget = Vue.extend(FileWidget) | ||
new Widget({ | ||
propsData: { | ||
richObjectType, | ||
richObject, | ||
accessible, | ||
}, | ||
}).$mount(el) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net> | ||
- | ||
- @author Julius Härtl <jus@bitgrid.net> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
- This program is free software: you can redistribute it and/or modify | ||
- it under the terms of the GNU Affero General Public License as | ||
- published by the Free Software Foundation, either version 3 of the | ||
- License, or (at your option) any later version. | ||
- | ||
- This program is distributed in the hope that it will be useful, | ||
- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
- GNU Affero General Public License for more details. | ||
- | ||
- You should have received a copy of the GNU Affero General Public License | ||
- along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
--> | ||
|
||
<template> | ||
<div v-if="!accessible" class="widget-file widget-file--no-access"> | ||
<div class="widget-file--image widget-file--image--icon icon-folder" /> | ||
<div class="widget-file--details"> | ||
<p class="widget-file--title"> | ||
File can't be accessed | ||
</p> | ||
<p class="widget-file--description"> | ||
You might not have have permissions to view it, ask the sender to share it | ||
</p> | ||
</div> | ||
</div> | ||
<div v-else class="widget-file"> | ||
<div class="widget-file--image" :class="filePreviewClass" :style="filePreview" /> | ||
<div class="widget-file--details"> | ||
<p class="widget-file--title"> | ||
{{ richObject.name }} | ||
</p> | ||
<p class="widget-file--description"> | ||
{{ fileSize }} {{ fileMtime }} | ||
</p> | ||
</div> | ||
<div class="widget-file--actions"> | ||
<button class="icon-more" /> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
name: 'ReferenceFileWidget', | ||
props: { | ||
richObject: { | ||
type: Object, | ||
required: true, | ||
}, | ||
accessible: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
data() { | ||
return {} | ||
}, | ||
computed: { | ||
fileSize() { | ||
return window.OC.Util.humanFileSize(this.richObject.size) | ||
}, | ||
filePreview() { | ||
if (this.richObject.hasPreview) { | ||
/* return { | ||
backgroundImage: 'url(' + this.richObject.preview + ')' | ||
} */ | ||
} | ||
return { | ||
backgroundImage: 'url(' + window.OC.MimeType.getIconUrl(this.richObject.mimetype) + ')' | ||
} | ||
|
||
}, | ||
filePreviewClass() { | ||
if (this.richObject.hasPreview) { | ||
return 'widget-file--image--preview' | ||
} | ||
return 'widget-file--image--icon' | ||
|
||
}, | ||
}, | ||
methods: { | ||
openViewer() { | ||
window.OCA.Viewer.open({ path: this.richObject.path }) | ||
}, | ||
}, | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.widget-file { | ||
display: flex; | ||
|
||
&--image { | ||
width: 40%; | ||
background-position: center; | ||
background-size: cover; | ||
background-repeat: no-repeat; | ||
|
||
&.widget-file--image--icon { | ||
width: 88px; | ||
background-size: 44px; | ||
} | ||
} | ||
|
||
&--title { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
font-weight: bold; | ||
} | ||
|
||
&--details { | ||
padding: 12px; | ||
width: 60%; | ||
|
||
p { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
} | ||
|
||
&--description { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 3; | ||
line-clamp: 3; | ||
-webkit-box-orient: vertical; | ||
} | ||
|
||
&--link a { | ||
color: var(--color-text-maxcontrast); | ||
} | ||
|
||
&.widget-file--no-access { | ||
padding: 12px; | ||
|
||
.widget-file--details { | ||
padding: 0; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters