mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Add clipboard methods to js engine.
This commit is contained in:
@@ -1358,3 +1358,29 @@ let APP = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set clipboard text
|
||||||
|
* @param text {string}
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*
|
||||||
|
* @since 1.3.4
|
||||||
|
*/
|
||||||
|
function setClipboard(text) {
|
||||||
|
return sendMessage({
|
||||||
|
method: 'setClipboard',
|
||||||
|
text: text
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get clipboard text
|
||||||
|
* @returns {Promise<string>}
|
||||||
|
*
|
||||||
|
* @since 1.3.4
|
||||||
|
*/
|
||||||
|
function getClipboard() {
|
||||||
|
return sendMessage({
|
||||||
|
method: 'getClipboard'
|
||||||
|
})
|
||||||
|
}
|
@@ -163,6 +163,13 @@ class JsEngine with _JSEngineApi, JsUiApi, Init {
|
|||||||
return "${App.locale.languageCode}_${App.locale.countryCode}";
|
return "${App.locale.languageCode}_${App.locale.countryCode}";
|
||||||
case "getPlatform":
|
case "getPlatform":
|
||||||
return Platform.operatingSystem;
|
return Platform.operatingSystem;
|
||||||
|
case "setClipboard":
|
||||||
|
return Clipboard.setData(ClipboardData(text: message["text"]));
|
||||||
|
case "getClipboard":
|
||||||
|
return Future.sync(() async {
|
||||||
|
var res = await Clipboard.getData(Clipboard.kTextPlain);
|
||||||
|
return res?.text;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
Reference in New Issue
Block a user