docs: remove duplicate fiddles
This commit is contained in:
		
					parent
					
						
							
								d166182865
							
						
					
				
			
			
				commit
				
					
						d5f31c2208
					
				
			
		
					 6 changed files with 0 additions and 159 deletions
				
			
		| 
						 | 
				
			
			@ -1,68 +0,0 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="UTF-8" />
 | 
			
		||||
    <title>Open external links</title>
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <div class="demo">
 | 
			
		||||
      <div class="demo-wrapper">
 | 
			
		||||
        <div class="demo-box">
 | 
			
		||||
          <div class="demo-controls">
 | 
			
		||||
            <button class="demo-button" id="open-ex-links">View Demo</button>
 | 
			
		||||
          </div>
 | 
			
		||||
          <p>
 | 
			
		||||
            If you do not want your app to open website links
 | 
			
		||||
            <em>within</em> the app, you can use the <code>shell</code> module
 | 
			
		||||
            to open them externally. When clicked, the links will open outside
 | 
			
		||||
            of your app and in the user's default web browser.
 | 
			
		||||
          </p>
 | 
			
		||||
          <p>
 | 
			
		||||
            When the demo button is clicked, the electron website will open in
 | 
			
		||||
            your browser.
 | 
			
		||||
          </p>
 | 
			
		||||
          <p></p>
 | 
			
		||||
          <h5>Renderer Process</h5>
 | 
			
		||||
          <pre><code>
 | 
			
		||||
                const { shell } = require('electron')
 | 
			
		||||
                const exLinksBtn = document.getElementById('open-ex-links')
 | 
			
		||||
                exLinksBtn.addEventListener('click', (event) => {
 | 
			
		||||
                shell.openExternal('https://electronjs.org')
 | 
			
		||||
                })
 | 
			
		||||
            </code></pre>
 | 
			
		||||
 | 
			
		||||
          <div class="demo-protip">
 | 
			
		||||
            <h2>ProTip</h2>
 | 
			
		||||
            <strong>Open all outbound links externally.</strong>
 | 
			
		||||
            <p>
 | 
			
		||||
              You may want to open all <code>http</code> and
 | 
			
		||||
              <code>https</code> links outside of your app. To do this, query
 | 
			
		||||
              the document and loop through each link and add a listener. This
 | 
			
		||||
              app uses the code below which is located in
 | 
			
		||||
              <code>assets/ex-links.js</code>.
 | 
			
		||||
            </p>
 | 
			
		||||
            <h5>Renderer Process</h5>
 | 
			
		||||
            <pre><code>
 | 
			
		||||
                const { shell } = require('electron')
 | 
			
		||||
                const links = document.querySelectorAll('a[href]')
 | 
			
		||||
                for (const link of links) {
 | 
			
		||||
                    const url = link.getAttribute('href')
 | 
			
		||||
                    if (url.indexOf('http') === 0) {
 | 
			
		||||
                        link.addEventListener('click', (e) => {
 | 
			
		||||
                            e.preventDefault()
 | 
			
		||||
                            shell.openExternal(url)
 | 
			
		||||
                        })
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            </code></pre>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <script>
 | 
			
		||||
      // You can also require other files to run in this process
 | 
			
		||||
      require("./renderer.js");
 | 
			
		||||
    </script>
 | 
			
		||||
  </body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,26 +0,0 @@
 | 
			
		|||
const { app, BrowserWindow } = require('electron')
 | 
			
		||||
 | 
			
		||||
let mainWindow = null
 | 
			
		||||
 | 
			
		||||
function createWindow () {
 | 
			
		||||
  const windowOptions = {
 | 
			
		||||
    width: 600,
 | 
			
		||||
    height: 400,
 | 
			
		||||
    title: 'Open External Links',
 | 
			
		||||
    webPreferences: {
 | 
			
		||||
      contextIsolation: false,
 | 
			
		||||
      nodeIntegration: true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  mainWindow = new BrowserWindow(windowOptions)
 | 
			
		||||
  mainWindow.loadFile('index.html')
 | 
			
		||||
 | 
			
		||||
  mainWindow.on('closed', () => {
 | 
			
		||||
    mainWindow = null
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
app.whenReady().then(() => {
 | 
			
		||||
  createWindow()
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			@ -1,7 +0,0 @@
 | 
			
		|||
const { shell } = require('electron')
 | 
			
		||||
 | 
			
		||||
const exLinksBtn = document.getElementById('open-ex-links')
 | 
			
		||||
 | 
			
		||||
exLinksBtn.addEventListener('click', (event) => {
 | 
			
		||||
  shell.openExternal('https://electronjs.org')
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			@ -1,24 +0,0 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
  <head>
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
  </head>
 | 
			
		||||
  <body>
 | 
			
		||||
    <div>
 | 
			
		||||
      <div>
 | 
			
		||||
        <h1>Open Path in File Manager</h1>
 | 
			
		||||
        <i>Supports: Win, macOS, Linux <span>|</span> Process: Both</i>
 | 
			
		||||
        <div>
 | 
			
		||||
          <p>This demonstrates using the <code>shell</code> module to open the system file manager at a particular location.</p>
 | 
			
		||||
          <p>Clicking the demo button will open your file manager at the root.</p>
 | 
			
		||||
          <div>
 | 
			
		||||
            <button id="open-file-manager">View Demo</button>
 | 
			
		||||
          </div>
 | 
			
		||||
        </div>
 | 
			
		||||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
  </body>
 | 
			
		||||
  <script>
 | 
			
		||||
    require('./renderer.js')
 | 
			
		||||
  </script>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,26 +0,0 @@
 | 
			
		|||
const { app, BrowserWindow } = require('electron')
 | 
			
		||||
 | 
			
		||||
let mainWindow = null
 | 
			
		||||
 | 
			
		||||
function createWindow () {
 | 
			
		||||
  const windowOptions = {
 | 
			
		||||
    width: 600,
 | 
			
		||||
    height: 400,
 | 
			
		||||
    title: 'Open Path in File Manager',
 | 
			
		||||
    webPreferences: {
 | 
			
		||||
      contextIsolation: false,
 | 
			
		||||
      nodeIntegration: true
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  mainWindow = new BrowserWindow(windowOptions)
 | 
			
		||||
  mainWindow.loadFile('index.html')
 | 
			
		||||
 | 
			
		||||
  mainWindow.on('closed', () => {
 | 
			
		||||
    mainWindow = null
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
app.whenReady().then(() => {
 | 
			
		||||
  createWindow()
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +0,0 @@
 | 
			
		|||
const { shell } = require('electron')
 | 
			
		||||
const os = require('node:os')
 | 
			
		||||
 | 
			
		||||
const fileManagerBtn = document.getElementById('open-file-manager')
 | 
			
		||||
 | 
			
		||||
fileManagerBtn.addEventListener('click', (event) => {
 | 
			
		||||
  shell.showItemInFolder(os.homedir())
 | 
			
		||||
})
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue