Skip to content

Commit 7996eea

Browse files
save file
1 parent cebde36 commit 7996eea

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

utils/editors/html-editor/html/output-html/output-html.html

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{display:flex}
1414

1515
.radio
16-
{border:1px solid lightgray;padding:2px 10px;border-radius:5px}
16+
{border:1px solid lightgray;padding:2px 10px;border-radius:5px;cursor:pointer}
1717

1818
#hldr
1919
{flex:1;box-sizing:border-box;position:relative}
@@ -26,15 +26,24 @@
2626

2727
<div id=hdr>
2828
<span id=allow-scripts class=radio>
29-
<input type=checkbox>
29+
<input type=checkbox checked>
3030
allow-scripts
3131
</span>
32+
<span id=allow-modals class=radio>
33+
<input type=checkbox checked>
34+
allow-modals
35+
</span>
36+
<span id=allow-popups class=radio>
37+
<input type=checkbox checked>
38+
allow-popups
39+
</span>
40+
3241
<div style='flex:1'></div>
3342
<button id=kill style='margin-right:20px'>kill</button>
3443
</div>
3544

3645
<div id=hldr>
37-
<iframe sandbox='allow-scripts allow-forms allow-popups allow-modals allow-downloads allow-pointer-lock allow-same-origin'></iframe>
46+
<iframe sandbox='allow-forms allow-downloads allow-pointer-lock allow-popups-to-escape-sandbox allow-same-origin'></iframe>
3847
<div id=glass></div>
3948
</div>
4049

@@ -69,6 +78,7 @@
6978

7079
var hldr;
7180
var iframe;
81+
var def_sandbox;
7282
var glass;
7383

7484

@@ -95,12 +105,15 @@
95105

96106
var hdr = $(shadow,'#hdr');
97107
chk['allow-scripts'] = $.chkbox(hdr,'#allow-scripts');
98-
console.log(chk);
108+
chk['allow-modals'] = $.chkbox(hdr,'#allow-modals');
109+
chk['allow-popups'] = $.chkbox(hdr,'#allow-popups');
110+
99111
$(hdr,'#kill').onclick = btn.kill;
100112

101113

102114
hldr = $(shadow,'#hldr');
103115
iframe = $(shadow,'iframe');
116+
def_sandbox = iframe.getAttribute('sandbox');
104117
glass = $(shadow,'#glass');
105118

106119

@@ -147,13 +160,22 @@
147160

148161
obj.srcdoc = function(html){
149162

150-
var attr = iframe.getAttribute('sandbox');
163+
var attr = def_sandbox;
164+
console.log(attr);
151165
var tokens = new Set(attr.split(/\s+/).filter(Boolean));
166+
152167
if(chk['allow-scripts'].checked){
153168
tokens.add('allow-scripts');
154169
}
170+
if(chk['allow-modals'].checked){
171+
tokens.add('allow-modals');
172+
}
173+
if(chk['allow-popups'].checked){
174+
tokens.add('allow-popups');
175+
}
176+
155177
var attr = [...tokens].join(' ');
156-
console.log(attr);
178+
console.log(attr);
157179
iframe.setAttribute('sandbox',attr);
158180

159181
iframe.srcdoc = html;

0 commit comments

Comments
 (0)