# Clipboard
Clipboard management.
# Manifest Declaration
You need to declare the use of this API in the manifest's features
member:
{"name": "system.clipboard"}
# Module Import
Before using this service in a component, you need to import the module in the script section of the UX document.
import clipboard from '@system.clipboard'
Or
let clipboard = require("@system.clipboard")
# Methods
This service has the following methods:
# set({text,success,fail,complete})
Modifies content on the clipboard.
# Arguments
This method requires an object
with the following attributes:
text
(string
). Mandatory attribute with the content that will be stored in the clipboard. The empty string (``) clears the clipboard value.success
(function(res)
). Optional callback function for success.fail
(function(code)
). Optional callback function for failure.complete
(function()
). Optional callback function for completion.
Example:
clipboard.set({
text: 'Text to paste!'
})
# get({success,fail,complete})
Retrieves the content on the clipboard.
# Arguments
This method requires an object
with the following attributes:
text
(string
). Mandatory attribute with the content that will be stored in the clipboard. The empty string (``) clears the clipboard value.success
(function(res)
). Optional callback function for success with the following argument:res.text
(string
) with the content of the clipboard.
fail
(function(code)
). Optional callback function for failure.complete
(function()
). Optional callback function for completion.
Example:
clipboard.get({
success:function(data){
console.log("handling success: " + data.text);
},
fail: function(data, code) {
console.log("handling fail, code=" + code);
}
})