mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-26 16:14:08 +00:00
Show preview for PDF image (#11793)
GitOrigin-RevId: 5c7dde42cdfcf9952e47487358f7e2b52658cc59
This commit is contained in:
parent
1807f18b7d
commit
6175df9f95
3 changed files with 12 additions and 6 deletions
|
@ -292,19 +292,25 @@ export default FileTreeManager = class FileTreeManager {
|
|||
return this._findEntityByPathInFolder(this.$scope.rootFolder, path)
|
||||
}
|
||||
|
||||
getPreviewUrlByPath(path) {
|
||||
for (const extension of [
|
||||
getPreviewByPath(path) {
|
||||
for (const suffix of [
|
||||
'',
|
||||
'.png',
|
||||
'.jpg',
|
||||
'.jpeg',
|
||||
'.pdf',
|
||||
'.PNG',
|
||||
'.JPG',
|
||||
'.JPEG',
|
||||
'.PDF',
|
||||
]) {
|
||||
const entity = this.findEntityByPath(path + extension)
|
||||
const entity = this.findEntityByPath(path + suffix)
|
||||
|
||||
if (entity) {
|
||||
return `/project/${this.$scope.project._id}/file/${entity.id}`
|
||||
return {
|
||||
url: `/project/${this.$scope.project._id}/file/${entity.id}`,
|
||||
extension: entity.name.split('.').pop(),
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
|
|
@ -98,7 +98,7 @@ const initialize = () => {
|
|||
findEntityByPath: () => null,
|
||||
getEntityPath: () => null,
|
||||
getRootDocDirname: () => undefined,
|
||||
getPreviewUrlByPath: () => undefined,
|
||||
getPreviewByPath: () => null,
|
||||
},
|
||||
editorManager: {
|
||||
getCurrentDocId: () => 'foo',
|
||||
|
|
|
@ -52,7 +52,7 @@ export function EditorProviders({
|
|||
findEntityByPath: () => null,
|
||||
getEntityPath: () => '',
|
||||
getRootDocDirname: () => '',
|
||||
getPreviewUrlByPath: path => path,
|
||||
getPreviewByPath: path => ({ url: path, extension: 'png' }),
|
||||
},
|
||||
editorManager = {
|
||||
getCurrentDocId: () => 'foo',
|
||||
|
|
Loading…
Reference in a new issue