@lvce-editor/renderer-process 8.4.0 → 8.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11172,21 +11172,52 @@ const ViewletWebViewEvents = {
11172
11172
  returnValue
11173
11173
  };
11174
11174
 
11175
+ const setIframeCredentialless = ($Iframe, credentialless) => {
11176
+ if (credentialless) {
11177
+ // @ts-ignore
11178
+ $Iframe.credentialless = credentialless;
11179
+ }
11180
+ };
11181
+
11182
+ const setIframeCsp = ($Iframe, csp) => {
11183
+ if (csp) {
11184
+ // @ts-ignore
11185
+ $Iframe.csp = csp;
11186
+ }
11187
+ };
11188
+
11189
+ const setIframeSandBox = ($Iframe, sandbox) => {
11190
+ for (const element of sandbox) {
11191
+ $Iframe.sandbox.add(element);
11192
+ }
11193
+ };
11194
+
11195
+ const setIframeSrc = ($Iframe, src, srcDoc) => {
11196
+ if (src) {
11197
+ $Iframe.src = src;
11198
+ } else if (srcDoc) {
11199
+ $Iframe.srcdoc = srcDoc;
11200
+ }
11201
+ };
11202
+
11175
11203
  // TODO could use browser view when running in electron
11176
- const setIframe = (state, src, sandbox = []) => {
11177
- if (!src) {
11204
+ const setIframe = (state, src, sandbox = [], srcDoc = '', csp = '', credentialless = true) => {
11205
+ if (!src && !srcDoc) {
11178
11206
  return;
11179
11207
  }
11180
11208
  const {
11181
11209
  $Viewlet
11182
11210
  } = state;
11183
11211
  const $Parent = $Viewlet.querySelector('.WebViewWrapper');
11184
- const $Iframe = document.createElement('iframe');
11185
- for (const element of sandbox) {
11186
- $Iframe.sandbox.add(element);
11212
+ if (!$Parent) {
11213
+ throw new Error('webview wrapper not found');
11187
11214
  }
11215
+ const $Iframe = document.createElement('iframe');
11216
+ setIframeCredentialless($Iframe, credentialless);
11217
+ setIframeCsp($Iframe, csp);
11218
+ setIframeSandBox($Iframe, sandbox);
11219
+ setIframeSrc($Iframe, src, srcDoc);
11188
11220
  $Iframe.className = 'E2eTestIframe WebViewIframe';
11189
- $Iframe.src = src;
11190
11221
  $Parent.append($Iframe);
11191
11222
  state.frame = $Iframe;
11192
11223
  set$1(1, $Iframe);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "8.4.0",
3
+ "version": "8.6.0",
4
4
  "description": "",
5
5
  "main": "dist/diffWorkerMain.js",
6
6
  "type": "module",