From fb569f2328116a2536e4d3e6479fd161d9aa2ef3 Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Thu, 4 Apr 2019 22:51:11 +0200 Subject: [PATCH] Accept a `style` parameter to specify the copied style. If `style` parameter isn't specified, this forces a text/plain copy to make it easier to work with word processors. This also changes the example code to exhibit the bug of issue #46 so that it's easier to test. Fixes #46 --- README.md | 2 +- example/index.html | 28 ++++++++++++++++++++-------- example/index.js | 2 +- index.d.ts | 7 ++++++- index.js | 21 ++++++++++++++++++--- 5 files changed, 46 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3d32fbf..54e4265 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ copy('Text', { |------|--------|-----| |options.debug |false| `Boolean`. Optional. Enable output to console. | |options.message|Copy to clipboard: `#{key}`, Enter| `String`. Optional. Prompt message. `*` | -|options.format|"text/html"| `String`. Optional. Set the MIME type of what you want to copy as. Use `text/html` to copy as HTML, `text/plain` to avoid inherited styles showing when pasted into rich text editor. | +|options.style |false |`boolean \| Object`. Optional. If this is an object, it should have the properties `background` and/or `text` to define respectively background and text colors. Defaults are a white background and black text color. You can also set it to `true` to get these defaults. | `*` all occurrences of `#{key}` are replaced with `⌘+C` for macOS/iOS users, and `Ctrl+C` otherwise. diff --git a/example/index.html b/example/index.html index 978c0f4..06c095f 100644 --- a/example/index.html +++ b/example/index.html @@ -5,14 +5,17 @@ CopyButtonPlayground - + +

copy-to-clipboard Repo

Basic text copy

- + + +

@@ -23,7 +26,7 @@

Multiline text copy

some multiline text for us to copy
- +

@@ -35,26 +38,35 @@

Markup + text copy

- +