All Projects → Jarred-Sumner → react-native-media-clipboard

Jarred-Sumner / react-native-media-clipboard

Licence: other
Image support for the clipboard in React Native

Programming Languages

Objective-C++
1391 projects
swift
15916 projects
objective c
16641 projects - #2 most used programming language
typescript
32286 projects
javascript
184084 projects - #8 most used programming language
ruby
36898 projects - #4 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to react-native-media-clipboard

secure-pbcopy
pbcopy(1) replacement that marks data as confidential
Stars: ✭ 18 (-60.87%)
Mutual labels:  clipboard
clipboard-manager-electron
A clipboard manager built with Electron
Stars: ✭ 92 (+100%)
Mutual labels:  clipboard
midgard
⛰️ Universal clipboard sharing service (supports macOS/Linux/Windows/iOS)
Stars: ✭ 81 (+76.09%)
Mutual labels:  clipboard
vim-cutlass
Plugin that adds a 'cut' operation separate from 'delete'
Stars: ✭ 134 (+191.3%)
Mutual labels:  clipboard
cb
Command line interface to manage clipboard
Stars: ✭ 69 (+50%)
Mutual labels:  clipboard
v-copy
Vue directive to copy to clipboard. (1kB)
Stars: ✭ 88 (+91.3%)
Mutual labels:  clipboard
townshell
For Townscaper, an application providing additional keyboard shortcuts, tools to manipulate .scape files, screen recording
Stars: ✭ 40 (-13.04%)
Mutual labels:  clipboard
macos-receiver
A MacOS TabBar (StatusBar) application that securely receives one-time passwords (OTPs) that you tapped in Raivo for iOS.
Stars: ✭ 44 (-4.35%)
Mutual labels:  clipboard
kakboard
Clipboard integration for Kakoune
Stars: ✭ 49 (+6.52%)
Mutual labels:  clipboard
netflix-list-exporter
💫‎‎‎‏‏‎ An Extension to export your lists from Netflix to Clipboard area and share it with your friends.
Stars: ✭ 60 (+30.43%)
Mutual labels:  clipboard
rofi-fontawesome
fontawesome icon list for rofi dmenu
Stars: ✭ 58 (+26.09%)
Mutual labels:  clipboard
XamarinClipboardPlugin
Cross Platform Clipboard access for Xamarin
Stars: ✭ 24 (-47.83%)
Mutual labels:  clipboard
cotp
Trustworthy, encrypted, command-line TOTP/HOTP authenticator app with import functionality.
Stars: ✭ 45 (-2.17%)
Mutual labels:  clipboard
alfred-string-operations
Perform string operations to clipboard content
Stars: ✭ 70 (+52.17%)
Mutual labels:  clipboard
ZetaHtmlEditControl
A small wrapper class around the Windows Forms 2.0 WebBrowser control.
Stars: ✭ 72 (+56.52%)
Mutual labels:  clipboard
cookie-extraction
登录后提取在线cookie,更新至服务器或拷贝至剪切板,为爬虫抓取跳过复杂验证码识别程序
Stars: ✭ 46 (+0%)
Mutual labels:  clipboard
clipetty
Manipulate the system (clip)board with (e)macs from a (tty)
Stars: ✭ 91 (+97.83%)
Mutual labels:  clipboard
CLIp
CLIp is a clipboard manager for a command line interface written in 100% standard C only. Pipe to it to copy, pipe from it to paste.
Stars: ✭ 12 (-73.91%)
Mutual labels:  clipboard
clipboard-win
Rust win clipboard utilities
Stars: ✭ 25 (-45.65%)
Mutual labels:  clipboard
ClipboardXX
Header only, lightweight and cross platform C++ library for copy and paste text from clipboard.
Stars: ✭ 36 (-21.74%)
Mutual labels:  clipboard

react-native-media-clipboard

React Native has several libraries that let you get the contents of the clipboard, but none of them support images.

react-native-media-clipboard suports:

  • images
  • strings
  • URLs

Getting started

$ npm install react-native-media-clipboard --save

Installation (iOS only)

  1. cd ios && pod install
  2. Add the following line near the top of AppDelegate.h:
#import <react-native-media-clipboard/MediaClipboard.h>
  1. [Optional] Inside the AppDelegate @implementation add this:
- (void)applicationDidBecomeActive:(UIApplication *)application {
  [MediaClipboard onApplicationBecomeActive];
}

This makes sure that the clipboard is in sync if the application went into the background.

Swift bridging header

If your project does not contain any Swift code, then you need to create a bridging header – or you'll get a bunch of strange build errors.

  1. Xcode -> File -> New -> Create an empty .swift file. It will prompt you asking if you want to create a bridging header. Say yes.

If your project already has Swift code (or a bridging header), just ignore this step.

  1. Re-build your app: react-native run-ios

Usage

import {
  ClipboardContext,
  ClipboardProvider
} from "react-native-media-clipboard";
  1. At the root of your application, add <ClipboardProvider> in the render method, like this:
<ClipboardProvider>
  <MyVeryRealApp>{children}</MyVeryRealApp>
</ClipboardProvider>
  1. ClipboardContext contains a clipboard and a mediaSource object. It automatically updates whenever the user copies something to their clipboard or removes something from their clipboard.
const { clipboard, mediaSource } = React.useContext(ClipboardContext);

// Example mediaSource:
{
  "mimeType": "image/png",
  "scale": 1,
  "width": 828,
  "uri": "file:///tmp/C4A65610-E644-44C2-AC54-25A8AD56A4C6.png",
  "height": 1792
}

// Example clipboard:
{
  urls: [],
  strings: [],
  hasImages: false,
  hasURLs: false,
  hasStrings: false
};

// You can just pass in the `mediaSource` object to the built-in Image component. As long as the mediaSource object is not null, it should just work.
<Image source={mediaSource} />

There are type definitions for these, so you shouldn't need to refer back to this much.


This library is iOS only. There is no Android support.

Images are saved in the temporary directory for the app in a background thread. It does not send data URIs across the bridge.

There is a JSI implementation of this as well, however I haven't finished porting it to this library. A contributor is welcome to submit a PR for that :)

Example repo

Example repo: react-native-media-clipboard-example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].