Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
leafwriter-x
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LEAF-Writer-X
leafwriter-x
Commits
af80da51
Commit
af80da51
authored
1 year ago
by
Jacob Benz
Browse files
Options
Downloads
Patches
Plain Diff
Handle images >1MB from GitHub
parent
e2651a6b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/cwrc-leafwriter/src/js/layout/panels/imageViewer/index.ts
+39
-8
39 additions, 8 deletions
...cwrc-leafwriter/src/js/layout/panels/imageViewer/index.ts
with
39 additions
and
8 deletions
packages/cwrc-leafwriter/src/js/layout/panels/imageViewer/index.ts
+
39
−
8
View file @
af80da51
...
...
@@ -232,10 +232,25 @@ class ImageViewer {
path
:
GitUrlParse
(
realURL
).
filepath
,
commit
:
GitUrlParse
(
realURL
).
commit
})
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result
.
data
.
content
,
'
base64
'
)]))
// console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
// console.log(tileSources)
if
(
result
.
data
.
content
===
""
)
{
// content empty if file larger then 1MB
//console.log("Get via blob!")
const
result_blob
=
await
octokit
.
request
(
'
GET /repos/{owner}/{repo}/git/blobs/{file_sha}
'
,{
owner
:
GitUrlParse
(
realURL
).
owner
,
repo
:
GitUrlParse
(
realURL
).
name
,
file_sha
:
result
.
data
.
sha
,
})
//console.log(result_blob)
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result_blob
.
data
.
content
,
'
base64
'
)]))
//console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
//console.log(tileSources)
}
else
{
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result
.
data
.
content
,
'
base64
'
)]))
// console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
// console.log(tileSources)
}
}
catch
(
error
)
{
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
"
non-existent
"
};
return
...
...
@@ -274,11 +289,27 @@ class ImageViewer {
path
:
realURL
})
// console.log(result)
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result
.
data
.
content
,
'
base64
'
)]))
//console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
// console.log(tileSources)
if
(
result
.
data
.
content
===
""
)
{
// content empty if file larger then 1MB
//console.log("Get via blob!")
const
result_blob
=
await
octokit
.
request
(
'
GET /repos/{owner}/{repo}/git/blobs/{file_sha}
'
,{
owner
:
this
.
writer
.
overmindState
.
document
.
GitHubOwner
,
repo
:
this
.
writer
.
overmindState
.
document
.
GitHubRepo
,
file_sha
:
result
.
data
.
sha
,
})
//console.log(result_blob)
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result_blob
.
data
.
content
,
'
base64
'
)]))
//console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
//console.log(tileSources)
}
else
{
const
content
=
URL
.
createObjectURL
(
new
Blob
([
Buffer
.
from
(
result
.
data
.
content
,
'
base64
'
)]))
//console.log(realURL + " " + content)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
content
};
// console.log(tileSources)
}
}
catch
(
error
)
{
// console.log(error)
tileSources
[
index
]
=
{
type
:
'
image
'
,
url
:
"
non-existent
"
};
return
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment