diff --git a/src/templates.ts b/src/templates.ts index fa322c386b..1cb57f016d 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -29,6 +29,7 @@ export const SHOW_ME_TEMPLATES: Templates = { Tray: 'Tray', utilityProcess: 'utilityProcess', WebContents: 'WebContents', + WebContentsView: 'WebContentsView', WebFrame: 'WebFrame', }, }; diff --git a/static/show-me/webcontentsview/main.js b/static/show-me/webcontentsview/main.js new file mode 100644 index 0000000000..d7baaf5d25 --- /dev/null +++ b/static/show-me/webcontentsview/main.js @@ -0,0 +1,21 @@ +// A View that displays a WebContents. +// +// For more info, see: +// https://electronjs.org/docs/api/web-contents-view + +// In the main process. +const { app, BaseWindow, WebContentsView } = require('electron') + +app.whenReady().then(() => { + const win = new BaseWindow({ width: 800, height: 400 }) + + const view1 = new WebContentsView() + win.contentView.addChildView(view1) + view1.setBounds({ x: 0, y: 0, width: 400, height: 400 }) + view1.webContents.loadURL('https://www.electronjs.org') + + const view2 = new WebContentsView() + win.contentView.addChildView(view2) + view2.setBounds({ x: 400, y: 0, width: 400, height: 400 }) + view2.webContents.loadURL('https://www.electronjs.org/fiddle') +})