scripting: expose Image()

canvas: typo
This commit is contained in:
jean-emmanuel 2022-05-22 12:58:49 +02:00
parent c84067c456
commit 23dadaaf7d
4 changed files with 7 additions and 2 deletions

View file

@ -10,6 +10,7 @@
- widgets
- canvas: add `onResize` script property
- scripting: expose javascript's `Image` constructor
## 1.16.2

View file

@ -114,6 +114,8 @@ The following variables and functions are accessible in this context.
- `platform`: operating system as seen by the client
- `session`: session file path
- `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)
- `Image`: javavscript's [Image](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) constructor
!!! note "this"
Unlike in most javascript contexts, the special keyword `this` doesn't point to an object but instead returns the string `"this"`.

View file

@ -180,7 +180,7 @@ class CanvasWidget extends Canvas {
if (!this.getProp('onResize')) return
this.scripts.onDraw.run({
this.scripts.onResize.run({
value: this.value,
width: this.width,
height: this.height,

View file

@ -506,9 +506,11 @@ class ScriptVm extends Vm {
}
this.sandbox.contentWindow.Image = Image
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'setFocus', 'unfocus', 'setScroll', 'getScroll', 'toolbar',
'openUrl', 'getVar', 'setVar', 'runAs']) {
'openUrl', 'getVar', 'setVar', 'runAs', 'Image']) {
this.sanitize(this.sandbox.contentWindow[imports])
}