@lvce-editor/renderer-process 8.4.0 → 8.5.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,36 @@ const ViewletWebViewEvents = {
11172
11172
  returnValue
11173
11173
  };
11174
11174
 
11175
+ const setIframeSandBox = ($Iframe, sandbox) => {
11176
+ for (const element of sandbox) {
11177
+ $Iframe.sandbox.add(element);
11178
+ }
11179
+ };
11180
+
11175
11181
  // TODO could use browser view when running in electron
11176
- const setIframe = (state, src, sandbox = []) => {
11177
- if (!src) {
11182
+ const setIframe = (state, src, sandbox = [], srcDoc = '', csp = '') => {
11183
+ if (!src && !srcDoc) {
11178
11184
  return;
11179
11185
  }
11180
11186
  const {
11181
11187
  $Viewlet
11182
11188
  } = state;
11183
11189
  const $Parent = $Viewlet.querySelector('.WebViewWrapper');
11190
+ if (!$Parent) {
11191
+ throw new Error('webview wrapper not found');
11192
+ }
11184
11193
  const $Iframe = document.createElement('iframe');
11185
- for (const element of sandbox) {
11186
- $Iframe.sandbox.add(element);
11194
+ if (csp) {
11195
+ // @ts-ignore
11196
+ $Iframe.csp = csp;
11187
11197
  }
11198
+ setIframeSandBox($Iframe, sandbox);
11188
11199
  $Iframe.className = 'E2eTestIframe WebViewIframe';
11189
- $Iframe.src = src;
11200
+ if (src) {
11201
+ $Iframe.src = src;
11202
+ } else if (srcDoc) {
11203
+ $Iframe.srcdoc = srcDoc;
11204
+ }
11190
11205
  $Parent.append($Iframe);
11191
11206
  state.frame = $Iframe;
11192
11207
  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.5.0",
4
4
  "description": "",
5
5
  "main": "dist/diffWorkerMain.js",
6
6
  "type": "module",