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

[IMP] Clipboard: support images in the clipboard #5098

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rrahir
Copy link
Collaborator

@rrahir rrahir commented Oct 15, 2024

Description:

This commit adds the support of images in the clipboard. Namely,

  • Pasting an image from the OS clipboard will automatically upload it to
    the filestore and dispatch a CREATE_IMAGE accordingly.
  • Copying a chart or an image from the spreadsheet will add it to the
    oOS clipboard. It can then be pasted somewhere else, like a discuss
    app, a text editor maybe?.

TODO

  • support multi type of images (not just png) It technically works
    because we never check agains the actual type of the file we upload
    but it's wrong. Maybe use a generic image/* mimetype instead of using
    png. We still need to purge out dangerous mimetypes like image/svg(+xml)
  • Currently uploads the image from the clipboard THEN only checks if the
    we are copy pasting from the same spreadsheet clipboard (potential
    useless upload)
  • Not supported by some apps like Office 365 online (word & powerpoint tested). Supposedly because our
    clipboard has some text/* types along the image/* so it ignores the
    later. for a fully integrated feature, we should probably decorrelate it
    from the standard copy paste and make a menu "copy image to os
    clipboard" ? tbd
  • works on discord at least
  • No test whatsoever
    Task: 4241877

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

The current implementation of the cross-browser clipboard relies heavily
on an API that is currently only available on Chromium based browsers
(see [table](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#api.clipboarditem)).

There is currently no definitive announce that the feature will be
adopted by other browsers (namely FF and Safari) and since the feature
is still marked as experimental, it'd be better to rely ona more generic
approach.

This revision changes the flow to rely entirely on the `text/html`
mimetype as it is supported by all modern browsers.

Task: 4241877
This commit adds the support of images in the clipboard. Namely,
- Pasting an image from the OS clipboard will automatically upload it to
  the filestore and dispatch a CREATE_IMAGE accordingly.
- Copying a chart or an image from the spreadsheet will add it to the
  oOS clipboard. It can then be pasted somewhere else, like a discuss
app, a text editor maybe?.

TODO
- support multi type of images (not just png) It technically works
  because we never check agains the actual type of the file we upload
but it's wrong. Maybe use a generic `image/*` mimetype instead of using
png. We still need to purge out dangerous mimetypes like image/svg(+xml)
- Currently uploads the image from the clipboard THEN only checks if the
  we are copy pasting from the same spreadsheet clipboard (potential
useless upload)
- Not supported by some apps like Office 365 online (word & powerpoint tested). Supposedly because our
  clipboard has some text/* types along the image/* so it ignores the
later. for a fully integrated feature, we should probably decorrelate it
from the standard copy paste and make a  menu "copy image to os
clipboard" ? tbd
-works on discord at least
- No test whatsoever
@robodoo
Copy link
Collaborator

robodoo commented Oct 15, 2024

Pull request status dashboard

@rrahir rrahir changed the title Master handle images in clipboard rar [FIX] clipboard: Fix clipboard cross-browser coverage Oct 15, 2024
@rrahir rrahir changed the title [FIX] clipboard: Fix clipboard cross-browser coverage [IMP] Clipboard: support images in the clipboard Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants