Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
cae4eb8b
Commit
cae4eb8b
authored
Apr 21, 2021
by
dsehnal
Browse files
Options
Downloads
Patches
Plain Diff
await screenshot clipboard write & fallback to <img> on fail
parent
5514b24f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mol-plugin-ui/viewport/screenshot.tsx
+11
-8
11 additions, 8 deletions
src/mol-plugin-ui/viewport/screenshot.tsx
src/mol-plugin/util/viewport-screenshot.ts
+1
-1
1 addition, 1 deletion
src/mol-plugin/util/viewport-screenshot.ts
with
12 additions
and
9 deletions
src/mol-plugin-ui/viewport/screenshot.tsx
+
11
−
8
View file @
cae4eb8b
...
...
@@ -34,12 +34,16 @@ export class DownloadScreenshotControls extends PluginUIComponent<{ close: () =>
}
private
copy
=
async
()
=>
{
try
{
await
this
.
plugin
.
helpers
.
viewportScreenshot
?.
copyToClipboard
();
PluginCommands
.
Toast
.
Show
(
this
.
plugin
,
{
message
:
'
Copied to clipboard.
'
,
title
:
'
Screenshot
'
,
timeoutMs
:
1500
});
}
catch
{
return
this
.
copyImg
();
}
}
private
copyImg
=
async
()
=>
{
...
...
@@ -71,8 +75,7 @@ export class DownloadScreenshotControls extends PluginUIComponent<{ close: () =>
<
CropControls
plugin
=
{
this
.
plugin
}
/>
</
div
>
}
<
div
className
=
'msp-flex-row'
>
{
hasClipboardApi
&&
<
Button
icon
=
{
CopySvg
}
onClick
=
{
this
.
copy
}
disabled
=
{
this
.
state
.
isDisabled
}
>
Copy
</
Button
>
}
{
!
hasClipboardApi
&&
!
this
.
state
.
imageData
&&
<
Button
icon
=
{
CopySvg
}
onClick
=
{
this
.
copyImg
}
disabled
=
{
this
.
state
.
isDisabled
}
>
Copy
</
Button
>
}
{
!
this
.
state
.
imageData
&&
<
Button
icon
=
{
CopySvg
}
onClick
=
{
hasClipboardApi
?
this
.
copy
:
this
.
copyImg
}
disabled
=
{
this
.
state
.
isDisabled
}
>
Copy
</
Button
>
}
{
this
.
state
.
imageData
&&
<
Button
onClick
=
{
()
=>
this
.
setState
({
imageData
:
void
0
})
}
disabled
=
{
this
.
state
.
isDisabled
}
>
Clear
</
Button
>
}
<
Button
icon
=
{
GetAppSvg
}
onClick
=
{
this
.
download
}
disabled
=
{
this
.
state
.
isDisabled
}
>
Download
</
Button
>
</
div
>
...
...
This diff is collapsed.
Click to expand it.
src/mol-plugin/util/viewport-screenshot.ts
+
1
−
1
View file @
cae4eb8b
...
...
@@ -324,7 +324,7 @@ class ViewportScreenshotHelper extends PluginComponent {
await
ctx
.
update
(
'
Converting image...
'
);
const
blob
=
await
canvasToBlob
(
this
.
canvas
,
'
png
'
);
const
item
=
new
ClipboardItem
({
'
image/png
'
:
blob
});
cb
.
write
([
item
]);
await
cb
.
write
([
item
]);
this
.
plugin
.
log
.
message
(
'
Image copied to clipboard.
'
);
});
}
...
...
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