This repository has been archived by the owner on Jan 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jadefish/cross-browser-support
Cross browser support
- Loading branch information
Showing
31 changed files
with
10,494 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,80 @@ | ||
# clipboard_presenter_plugin | ||
|
||
A plugin for [voom/presenters](https://github.com/rx/presenters) which | ||
provides clipboard interaction via the | ||
[clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API). | ||
The clipboard_presenter_plugin is a plugin for | ||
[rx/presenters](https://github.com/rx/presenters) which provides clipboard | ||
interaction. | ||
|
||
## Actions | ||
|
||
The clipboard_presenter_plugin provides the following actions: | ||
|
||
* Copy from an element: `clipboard copy: :some_field` | ||
* Cut from an element: `clipboard cut: :some_field` | ||
|
||
## Usage | ||
|
||
Include the clipboard_presenter_plugin either globally via the `plugins` | ||
configuration setting | ||
|
||
```ruby | ||
# config/initializers/presenters.rb | ||
Voom::Presenters::Settings.configure do |config| | ||
config.presenters.plugins << :clipboard | ||
# Now `clipboard` is available in every POM! | ||
end | ||
``` | ||
|
||
or on a per-POM basis via the `plugin` method. | ||
|
||
```ruby | ||
# presenters/foos/view.pom | ||
Voom::Presenters.define(:view, namespace: :foos) do | ||
plugin :clipboard | ||
|
||
# ... | ||
end | ||
``` | ||
|
||
Then, use one of the clipboard actions in an event handler. | ||
|
||
```ruby | ||
text_field id: :my_secret_token do | ||
value current_user.super_secret_token | ||
end | ||
|
||
button icon: :file_copy do | ||
tooltip 'Copy token' | ||
|
||
event :click do | ||
clipboard copy: :my_secret_token | ||
snackbar 'Copied token to clipboard!' | ||
end | ||
end | ||
``` | ||
|
||
## Browser support | ||
|
||
The following browsers are considered officially supported: | ||
|
||
* Chrome 42+ | ||
* Edge 12+ | ||
* Firefox 41+ | ||
* Safari 10+ | ||
|
||
## Building | ||
|
||
0. `nvm use && npm i` | ||
1. `npm run type-check` | ||
2. Compile TS to JS: `npm run build` (output: `views/clipboard/build`) | ||
3. Transpile and bundle via Babel and Webpack: `npm run bundle:dev` (output: | ||
`dist/bundle.js`) | ||
|
||
Or, `npm run watch` to watch `views/clipboard/src` for changes and run steps 1-3 above. | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Branch it | ||
4. Fix it | ||
4. PR it | ||
5. Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<script> | ||
<%= File.read(File.expand_path('clipboard.js', __dir__) ) %> | ||
<%= File.read(File.expand_path('../../../../../public/bundle.js', __dir__) ) %> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"presets": [ | ||
["@babel/env", { | ||
"targets": { | ||
"chrome": "42", | ||
"edge": "12", | ||
"firefox": "41", | ||
"ie": "9", | ||
"opera": "29", | ||
"safari": "10" | ||
} | ||
}], | ||
"@babel/typescript" | ||
], | ||
"plugins": [ | ||
"@babel/proposal-class-properties" | ||
], | ||
"sourceType": "unambiguous", | ||
|
||
"env": { | ||
"test": { | ||
"plugins": [ | ||
["@babel/plugin-transform-runtime", { | ||
"regenerator": true | ||
}] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
/build | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v12.16 |
Oops, something went wrong.