Skip to content

Commit

Permalink
docs(api): tweak Ti.UI.Clipboard docs
Browse files Browse the repository at this point in the history
- add note about clipbaord expiration option on mac vs ios
  • Loading branch information
sgtcoolguy committed Dec 11, 2020
1 parent 820be76 commit b749629
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
44 changes: 25 additions & 19 deletions apidoc/Titanium/UI/Clipboard/Clipboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ description: |
The Clipboard is a temporary data store, used to save a single item of data that may then
be accessed by the user using UI copy and paste interactions within an app or between apps.
On iOS, the module's `*Data()` methods enable multiple representations of the
On iOS, the module's `setData()` and `getData()` methods enable multiple representations of the
same data item to be stored together with their respective
[MIME type](http://en.wikipedia.org/wiki/Internet_media_type) to describe their format. For
example, `'text'` and `'text/plain'` for text, and `'image/jpg'` and `'image/png'` for an image.
iOS Will report back the type of data representation in `getItems()` as
[Universal Type Identifiers](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html).
When working with text, either the `*Data()` methods may be used with a `'text/plain'` type, or
the `*Text()` methods without the need to specify the type.
When working with text, either of the `getData()`/`setData()` methods may be used with a `'text/plain'` type, or
the `getText()`/`hasText()`/`setText()` methods without the need to specify the type.
Android currently only supports text type of data to be stored.
Android currently only supports text data to be stored.
#### Clipboard Data Types
The `*Text()` methods are equivalent to calling `*Data()` with a `'text'` or `'text/plain'`
The `getText()`/`hasText()`/`setText()` methods are equivalent to calling `getData()`/`setData()` with a `'text'` or `'text/plain'`
type. These work with plain Unicode strings.
An image is stored using the `'image'` type, or an explicit image MIME type, and is returned as
Expand All @@ -35,7 +37,7 @@ methods:
summary: |
Deletes data of the specified MIME type stored in the clipboard. If MIME type omitted, all
data is deleted.
description: On Android, identical to `clearText` method.
description: On Android, identical to the `clearText()` method.
parameters:
- name: type
summary: MIME type. Ignored on Android.
Expand All @@ -51,7 +53,7 @@ methods:
- name: getData
summary: Gets data of the specified MIME type stored in the clipboard. Returns null if non-text mimetype on Android.
returns:
type: [String,Titanium.Blob]
type: [String, Titanium.Blob]
parameters:
- name: type
summary: MIME type. Must be 'text' or 'text/plain' on Android, or else null is returned.
Expand Down Expand Up @@ -112,7 +114,8 @@ methods:
- name: type
summary: |
MIME type. Must be 'text' or 'text/plain' on Android.
Possible types include: `'text', 'text/plain', 'color', 'image', 'url', 'text/uri-list'`
Possible types include: `'text', 'text/plain', 'color', 'image', 'url', 'text/uri-list'`.
iOS also supports [Universal Type Identifiers](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html)
type: String

- name: data
Expand Down Expand Up @@ -147,6 +150,10 @@ methods:

- name: getItems
summary: Gets the items that have been specified earlier using <Titanium.UI.Clipboard.setItems>.
description: |
The returned Array contains simple Objects whose keys are the reported
[Universal Type Identifiers](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html)
reported by iOS; and values are the underlying object/data.
returns:
- type: Array<Dictionary>
osver: {ios: {min: "10.0"}}
Expand Down Expand Up @@ -215,37 +222,35 @@ examples:
``` js
var win = Ti.UI.createWindow({
backgroundColor : "#fff"
backgroundColor: "#fff"
});
var btn1 = Ti.UI.createButton({
title : "Set clipboard items",
title: "Set clipboard items",
top: 40
});
var btn2 = Ti.UI.createButton({
title : "Get clipboard items",
title: "Get clipboard items",
top: 80
});
btn1.addEventListener("click", function() {
var localOnly = Ti.UI.CLIPBOARD_OPTION_LOCAL_ONLY;
var expirationDate = Ti.UI.CLIPBOARD_OPTION_EXPIRATION_DATE;
btn1.addEventListener("click", function () {
const options = {};
options[Ti.UI.CLIPBOARD_OPTION_LOCAL_ONLY] = true;
options[Ti.UI.CLIPBOARD_OPTION_EXPIRATION_DATE] = new Date(2030, 4, 20);
Ti.UI.Clipboard.setItems({
items: [{
"text/plain": "John",
},{
"text/plain": "Doe"
}],
options: {
localOnly: true,
expirationDate: new Date(2020, 04, 20)
}
options
});
});
btn2.addEventListener("click", function() {
btn2.addEventListener("click", function () {
alert(Ti.UI.Clipboard.getItems());
});
Expand Down Expand Up @@ -293,6 +298,7 @@ properties:
summary: |
An array of key-value items to add to the clipboard. The key must a valid mime-type
matching the mime-type of the value.
Alterntaively, iOS supports using [Universal Type Identifiers](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html)
type: Array<Dictionary>

- name: options
Expand Down
5 changes: 4 additions & 1 deletion apidoc/Titanium/UI/UI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,10 @@ properties:
since: "5.5.0"

- name: CLIPBOARD_OPTION_EXPIRATION_DATE
summary: Specifies the time and date that you want the system to remove the clipboard items from the clipboard.
summary: |
Specifies the time and date that you want the system to remove the clipboard items from the clipboard.
Note that on macOS, setting a date in the past does not appear to invalidate items immediately, while on iOS it does.
type: String
permission: read-only
platforms: [iphone, ipad, macos]
Expand Down

0 comments on commit b749629

Please sign in to comment.