Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload screenshot from clipboard #6710

Closed
StefanBrand opened this issue Oct 25, 2021 · 7 comments · Fixed by #12181
Closed

Upload screenshot from clipboard #6710

StefanBrand opened this issue Oct 25, 2021 · 7 comments · Fixed by #12181
Assignees
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature. help wanted Extra attention is needed. ux Issues related to user experience.
Milestone

Comments

@StefanBrand
Copy link

StefanBrand commented Oct 25, 2021

Is your feature request related to a problem? If so, please describe.

I often find myself taking screenshots from our web app via the Firefox screenshot tool. By default I always copy to clipboard so that I can paste the screenshot into other tools later. Unfortunately Weblate does not allow this. I must go back to the webapp, take the screenshot again and save it to disk. Then I must upload it to Weblate via the "Browse" button (navigating to the screenshot folder on my disk).

Describe the solution you'd like

Allow pasting screenshots into the "Add new screenshot" dialogue.*

*Might have to be resized automatically to comply with 2000x2000 px limit.

Describe alternatives you've considered

Download & Upload screenshots.

Screenshots

Paste screenshot into this dialogue:
image

@nijel nijel added enhancement Adding or requesting a new feature. help wanted Extra attention is needed. ux Issues related to user experience. backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. labels Oct 26, 2021
@github-actions
Copy link

This issue has been added to the backlog. It is not scheduled on the Weblate roadmap, but it eventually might be implemented.

In case you need this feature soon, please consider helping or push it by funding the development.

@luebbe
Copy link
Contributor

luebbe commented Oct 28, 2021

+1

I was just going to write this feature request myself. It would be a great help indeed.

@ptse888
Copy link

ptse888 commented Nov 16, 2021

@nijel i would like to work on this if possible! could you possibly direct me as to where i should be looking to make this modification?

@nijel
Copy link
Member

nijel commented Nov 17, 2021

The screenshot upload form is here:

class ScreenshotForm(forms.ModelForm):
"""Screenshot upload."""
class Meta:
model = Screenshot
fields = ("name", "image", "translation")
widgets = {
"translation": SortedSelect,
}
field_classes = {
"translation": LanguageChoiceField,
}
def __init__(self, component, data=None, files=None, instance=None, initial=None):
self.component = component
super().__init__(data=data, files=files, instance=instance, initial=initial)
self.fields[
"translation"
].queryset = component.translation_set.prefetch_related("language")
self.fields["translation"].initial = component.source_translation

It is being rendered here:

{% if add_form %}
<form action="{% url 'screenshots' project=object.project.slug component=object.slug %}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Add new screenshot" %}</h4></div>
<div class="panel-body">
{{ add_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" class="btn btn-primary" value="{% trans "Upload" %}" />
</div>
</div>
</form>
{% endif %}

@ParthS007
Copy link
Contributor

ParthS007 commented Jul 1, 2022

@nijel I have some questions:

  1. Where we add javascript code for some actions on html, do we have any rules for that?

  2. What the recommended way to test changes in html files, I am trying to see what data comes in add_form and implement the logic for pasting from clipboard for images ?

  3. Do we want this for all file types or just for images?

  4. Can you please add instructions to access different type of forms in UI?

@nijel
Copy link
Member

nijel commented Jul 4, 2022

No rules so far. Historically, there has been a single JS file, but recently, we've started to split out some logic - we now have also weblate/static/editor/.

We're using django-crispy-forms, it should allow customizing the form rendering, see https://django-crispy-forms.readthedocs.io/en/latest/layouts.html. The screenshot forms are here: https://github.com/WeblateOrg/weblate/blob/main/weblate/screenshots/forms.py, and for now, I'd make this change only to allow pasting screenshots, not anything else.

@nijel nijel assigned meel-hd and unassigned ParthS007 Jul 24, 2024
meel-hd added a commit to meel-hd/weblate that referenced this issue Aug 2, 2024
The user clicks paste. Then the clipboard is read if the permesion is given and the context is secure (as required by the clipboard API). Then the image is pasted into the select file input. Otherwise if no image is available we only inform the  user about that.

NOTE: Implemented only in the add screenshot form in /screenshots page and not in the modal.

Related: WeblateOrg#6710
meel-hd added a commit to meel-hd/weblate that referenced this issue Aug 5, 2024
The previous commit added pase screenshot in screenshot/ pages. This adds it in the modal box that opens when Add Screenshot button clicked while checking individual strings.

Related: WeblateOrg#6710
@nijel nijel linked a pull request Aug 5, 2024 that will close this issue
5 tasks
@nijel nijel added this to the 5.7 milestone Aug 7, 2024
nijel pushed a commit to meel-hd/weblate that referenced this issue Aug 7, 2024
The user clicks paste. Then the clipboard is read if the permesion is given and the context is secure (as required by the clipboard API). Then the image is pasted into the select file input. Otherwise if no image is available we only inform the  user about that.

NOTE: Implemented only in the add screenshot form in /screenshots page and not in the modal.

Related: WeblateOrg#6710
nijel pushed a commit to meel-hd/weblate that referenced this issue Aug 7, 2024
The previous commit added pase screenshot in screenshot/ pages. This adds it in the modal box that opens when Add Screenshot button clicked while checking individual strings.

Related: WeblateOrg#6710
nijel added a commit that referenced this issue Aug 7, 2024
…12181)

* Feat: Add clipboard paste functionality for screenshots

The user clicks paste. Then the clipboard is read if the permesion is given and the context is secure (as required by the clipboard API). Then the image is pasted into the select file input. Otherwise if no image is available we only inform the  user about that.

NOTE: Implemented only in the add screenshot form in /screenshots page and not in the modal.

Related: #6710

* Add screenshot clipboard paste in the modal box.

The previous commit added pase screenshot in screenshot/ pages. This adds it in the modal box that opens when Add Screenshot button clicked while checking individual strings.

Related: #6710

* Move the paste button closer to image input

The paste button now is rendered  by django screenshot form isntead of being in the template.

* Remove the paste button if clipboard API  isn't supported by the browser

* Remove part of the forgotten paste button

* Use custom input instead of using dummy one

* Add paste button to screenshot editing

* Add changelog entry

Co-authored-by: Michal Čihař <michal@cihar.com>
Copy link

github-actions bot commented Aug 7, 2024

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog This is not on the Weblate roadmap for now. Can be prioritized by sponsorship. enhancement Adding or requesting a new feature. help wanted Extra attention is needed. ux Issues related to user experience.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants