1 |
|
2 |
|
3 | import { Widget } from '@lumino/widgets';
|
4 |
|
5 |
|
6 |
|
7 | export class IFrame extends Widget {
|
8 | |
9 |
|
10 |
|
11 | constructor(options = {}) {
|
12 | super({ node: Private.createNode() });
|
13 | this._sandbox = [];
|
14 | this.addClass('jp-IFrame');
|
15 | this.sandbox = options.sandbox || [];
|
16 | this.referrerPolicy = options.referrerPolicy || 'no-referrer';
|
17 | }
|
18 | |
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | get referrerPolicy() {
|
28 | return this._referrerPolicy;
|
29 | }
|
30 | set referrerPolicy(value) {
|
31 | if (this._referrerPolicy === value) {
|
32 | return;
|
33 | }
|
34 | this._referrerPolicy = value;
|
35 | const iframe = this.node.querySelector('iframe');
|
36 | iframe.setAttribute('referrerpolicy', value);
|
37 | }
|
38 | |
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | get sandbox() {
|
52 | return this._sandbox.slice();
|
53 | }
|
54 | set sandbox(values) {
|
55 | this._sandbox = values.slice();
|
56 | const iframe = this.node.querySelector('iframe');
|
57 | const exceptions = values.length ? values.join(' ') : '';
|
58 | iframe.setAttribute('sandbox', exceptions);
|
59 | }
|
60 | |
61 |
|
62 |
|
63 | get url() {
|
64 | return this.node.querySelector('iframe').getAttribute('src') || '';
|
65 | }
|
66 | set url(url) {
|
67 | this.node.querySelector('iframe').setAttribute('src', url);
|
68 | }
|
69 | }
|
70 |
|
71 |
|
72 |
|
73 | var Private;
|
74 | (function (Private) {
|
75 | |
76 |
|
77 |
|
78 | function createNode() {
|
79 | const node = document.createElement('div');
|
80 | const iframe = document.createElement('iframe');
|
81 | iframe.setAttribute('sandbox', '');
|
82 | iframe.style.height = '100%';
|
83 | iframe.style.width = '100%';
|
84 | node.appendChild(iframe);
|
85 | return node;
|
86 | }
|
87 | Private.createNode = createNode;
|
88 | })(Private || (Private = {}));
|
89 |
|
\ | No newline at end of file |