arthuro555

Clipboard Extension ++

Nov 18th, 2020
741
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 4.57 KB | None | 0 0
  1. {
  2.   "author": "@Bouh, @arthuro555",
  3.   "description": "Expression returning the content of the clipboard.",
  4.   "extensionNamespace": "",
  5.   "fullName": "Clipboard",
  6.   "name": "Clipboard",
  7.   "shortDescription": "Expression returning the content of the clipboard.",
  8.   "tags": "clipboard, pasteboard, paste, write",
  9.   "version": "0.0.2",
  10.   "eventsFunctions": [
  11.     {
  12.       "description": "Read the text from the clipboard asynchronously (works on all platforms)",
  13.       "fullName": "Get text from the clipboard",
  14.       "functionType": "Action",
  15.       "name": "readTextCrossPlaform",
  16.       "sentence": "Read clipboard and store text in _PARAM1_",
  17.       "events": [
  18.         {
  19.           "disabled": false,
  20.           "folded": false,
  21.           "type": "BuiltinCommonInstructions::JsCode",
  22.           "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst callback =\n    runtimeScene\n        .getVariables()\n        .get(eventsFunctionContext.getArgument(\"callback\"));\n\nif (navigator.clipboard) {\n    navigator.clipboard.readText()\n        .then(text => {\n            callback.setString(text);\n        }).catch(err => {\n            console.error(\"Error occured while getting clipboard content: \", err.message);\n        });\n} else if (!electron || !electron.clipboard)\n    eventsFunctionContext.returnValue = electron.clipboard.readText();\n",
  23.           "parameterObjects": "",
  24.           "useStrict": true
  25.         }
  26.       ],
  27.       "parameters": [
  28.         {
  29.           "codeOnly": false,
  30.           "defaultValue": "",
  31.           "description": "Callback variable where to store the result",
  32.           "longDescription": "",
  33.           "name": "callback",
  34.           "optional": false,
  35.           "supplementaryInformation": "",
  36.           "type": "string"
  37.         }
  38.       ],
  39.       "objectGroups": []
  40.     },
  41.     {
  42.       "description": "Read the text from the clipboard (Windows, macOS, Linux only)",
  43.       "fullName": "Get text from the clipboard (Windows, macOS, Linux)",
  44.       "functionType": "StringExpression",
  45.       "name": "ReadText",
  46.       "sentence": "",
  47.       "events": [
  48.         {
  49.           "disabled": false,
  50.           "folded": false,
  51.           "type": "BuiltinCommonInstructions::Comment",
  52.           "color": {
  53.             "b": 109,
  54.             "g": 230,
  55.             "r": 255,
  56.             "textB": 0,
  57.             "textG": 0,
  58.             "textR": 0
  59.           },
  60.           "comment": "This is here for retrocompatibility. Try to use the asynchronous readTextCrossPlatform action instead.",
  61.           "comment2": ""
  62.         },
  63.         {
  64.           "disabled": false,
  65.           "folded": false,
  66.           "type": "BuiltinCommonInstructions::JsCode",
  67.           "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nif (electron && electron.clipboard) eventsFunctionContext.returnValue = electron.clipboard.readText();\n",
  68.           "parameterObjects": "",
  69.           "useStrict": true
  70.         }
  71.       ],
  72.       "parameters": [],
  73.       "objectGroups": []
  74.     },
  75.     {
  76.       "description": "Write the text in the clipboard (Windows, macOS, Linux only)",
  77.       "fullName": "Write text to the clipboard (Windows, macOS, Linux)",
  78.       "functionType": "Action",
  79.       "name": "WriteText",
  80.       "sentence": "Write _PARAM1_ to clipboard",
  81.       "events": [
  82.         {
  83.           "disabled": false,
  84.           "folded": false,
  85.           "type": "BuiltinCommonInstructions::JsCode",
  86.           "inlineCode": "const electron = runtimeScene.getGame().getRenderer().getElectron();\nconst text = eventsFunctionContext.getArgument(\"text\");\n\nif (!electron || !electron.clipboard) {\n  //TODO cache this element to not create elements on each call\n  const inputElement = document.createElement(\"input\");\n  inputElement.id = \"Clipboard_copy_temp\";\n  inputElement.value = text;\n  document.body.appendChild(inputElement);\n  inputElement.select();\n  inputElement.setSelectionRange(0, text.length);\n  inputElement.execCommand(\"copy\");\n  inputElement.remove();\n} else electron.clipboard.writeText(eventsFunctionContext.getArgument(\"text\"));\n",
  87.           "parameterObjects": "",
  88.           "useStrict": true
  89.         }
  90.       ],
  91.       "parameters": [
  92.         {
  93.           "codeOnly": false,
  94.           "defaultValue": "",
  95.           "description": "Text to write to clipboard",
  96.           "longDescription": "",
  97.           "name": "text",
  98.           "optional": false,
  99.           "supplementaryInformation": "",
  100.           "type": "string"
  101.         }
  102.       ],
  103.       "objectGroups": []
  104.     }
  105.   ],
  106.   "eventsBasedBehaviors": []
  107. }
Advertisement
Add Comment
Please, Sign In to add comment