mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-23 03:53:53 +00:00
commit
b20f757c5d
11
.editorconfig
Normal file
11
.editorconfig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
16
README.md
16
README.md
|
@ -18,7 +18,18 @@ $ npm run demo
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Add the following elements to the app page:
|
Electron-tabs uses webviews, so you first need to use the following `webPreferences` options in the main process:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const mainWindow = new electron.BrowserWindow({
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
webviewTag: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Then add the following elements to the app page:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div class="etabs-tabgroup">
|
<div class="etabs-tabgroup">
|
||||||
|
@ -34,7 +45,7 @@ And call the module in the renderer process:
|
||||||
const TabGroup = require("electron-tabs");
|
const TabGroup = require("electron-tabs");
|
||||||
```
|
```
|
||||||
|
|
||||||
Then you can initialize a tab group and add tabs to it:
|
Now you can initialize a tab group and add tabs to it:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
let tabGroup = new TabGroup();
|
let tabGroup = new TabGroup();
|
||||||
|
@ -52,6 +63,7 @@ If you don't want to write your own styles, you can also insert the sample elect
|
||||||
```
|
```
|
||||||
|
|
||||||
### Note
|
### Note
|
||||||
|
|
||||||
Please note, there is a known issue in some versions of Electron that prevents the process to completely shut down and it remains hanging in Background Processes (Windows 10). If you encounter that issue please use the workaround provided at https://github.com/electron/electron/issues/13939
|
Please note, there is a known issue in some versions of Electron that prevents the process to completely shut down and it remains hanging in Background Processes (Windows 10). If you encounter that issue please use the workaround provided at https://github.com/electron/electron/issues/13939
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
|
@ -3,9 +3,7 @@ const app = electron.app;
|
||||||
|
|
||||||
app.setName('electron-tabs-demo');
|
app.setName('electron-tabs-demo');
|
||||||
|
|
||||||
|
|
||||||
app.on('ready', function () {
|
app.on('ready', function () {
|
||||||
|
|
||||||
const mainWindow = new electron.BrowserWindow({
|
const mainWindow = new electron.BrowserWindow({
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
@ -17,5 +15,4 @@ app.on('ready', function () {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.etabs-views {
|
.etabs-views {
|
||||||
|
position: relative;
|
||||||
border-top: 1px solid #aaa;
|
border-top: 1px solid #aaa;
|
||||||
height: calc(100vh - 33px);
|
height: calc(100vh - 33px);
|
||||||
}
|
}
|
||||||
|
|
16
index.js
16
index.js
|
@ -8,16 +8,12 @@ if (!document) {
|
||||||
(function () {
|
(function () {
|
||||||
const styles = `
|
const styles = `
|
||||||
webview {
|
webview {
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
webview.visible {
|
webview.visible {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -35,7 +31,7 @@ class TabGroup extends EventEmitter {
|
||||||
viewContainerSelector: args.viewContainerSelector || ".etabs-views",
|
viewContainerSelector: args.viewContainerSelector || ".etabs-views",
|
||||||
tabClass: args.tabClass || "etabs-tab",
|
tabClass: args.tabClass || "etabs-tab",
|
||||||
viewClass: args.viewClass || "etabs-view",
|
viewClass: args.viewClass || "etabs-view",
|
||||||
closeButtonText: args.closeButtonText || "✖",
|
closeButtonText: args.closeButtonText || "×",
|
||||||
newTab: args.newTab,
|
newTab: args.newTab,
|
||||||
newTabButtonText: args.newTabButtonText || "+",
|
newTabButtonText: args.newTabButtonText || "+",
|
||||||
ready: args.ready
|
ready: args.ready
|
||||||
|
@ -407,6 +403,12 @@ const TabPrivate = {
|
||||||
|
|
||||||
this.webview.addEventListener("did-finish-load", tabWebviewDidFinishLoadHandler.bind(this), false);
|
this.webview.addEventListener("did-finish-load", tabWebviewDidFinishLoadHandler.bind(this), false);
|
||||||
|
|
||||||
|
this.webview.addEventListener("dom-ready", function () {
|
||||||
|
// Remove this once https://github.com/electron/electron/issues/14474 is fixed
|
||||||
|
tab.webview.blur();
|
||||||
|
tab.webview.focus();
|
||||||
|
});
|
||||||
|
|
||||||
this.webview.classList.add(this.tabGroup.options.viewClass);
|
this.webview.classList.add(this.tabGroup.options.viewClass);
|
||||||
if (this.webviewAttributes) {
|
if (this.webviewAttributes) {
|
||||||
let attrs = this.webviewAttributes;
|
let attrs = this.webviewAttributes;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "electron-tabs",
|
"name": "electron-tabs",
|
||||||
"version": "0.11.0",
|
"version": "0.12.0",
|
||||||
"description": "Simple tabs for Electron applications",
|
"description": "Simple tabs for Electron applications",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -20,6 +20,6 @@
|
||||||
"author": "brrd",
|
"author": "brrd",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "^1.6.11"
|
"electron": "^8.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue