Merge pull request #93 from brrd/develop

Version 0.12.0
This commit is contained in:
Thomas Brouard 2020-02-04 13:39:04 +01:00 committed by GitHub
commit b20f757c5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 503 additions and 480 deletions

11
.editorconfig Normal file
View 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

View file

@ -18,7 +18,18 @@ $ npm run demo
## 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
<div class="etabs-tabgroup">
@ -34,7 +45,7 @@ And call the module in the renderer process:
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
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
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

View file

@ -3,9 +3,7 @@ const app = electron.app;
app.setName('electron-tabs-demo');
app.on('ready', function () {
const mainWindow = new electron.BrowserWindow({
webPreferences: {
nodeIntegration: true,
@ -17,5 +15,4 @@ app.on('ready', function () {
mainWindow.show();
mainWindow.focus();
});
});

View file

@ -124,6 +124,7 @@
}
.etabs-views {
position: relative;
border-top: 1px solid #aaa;
height: calc(100vh - 33px);
}

View file

@ -8,16 +8,12 @@ if (!document) {
(function () {
const styles = `
webview {
width: 100%;
height: 100%;
top: 0;
right: 0;
bottom: 0;
left: 0;
position: absolute;
visibility: hidden;
}
webview.visible {
width: 100%;
height: 100%;
visibility: visible;
}
`;
@ -35,7 +31,7 @@ class TabGroup extends EventEmitter {
viewContainerSelector: args.viewContainerSelector || ".etabs-views",
tabClass: args.tabClass || "etabs-tab",
viewClass: args.viewClass || "etabs-view",
closeButtonText: args.closeButtonText || "&#10006;",
closeButtonText: args.closeButtonText || "&#215;",
newTab: args.newTab,
newTabButtonText: args.newTabButtonText || "&#65291;",
ready: args.ready
@ -407,6 +403,12 @@ const TabPrivate = {
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);
if (this.webviewAttributes) {
let attrs = this.webviewAttributes;

View file

@ -1,6 +1,6 @@
{
"name": "electron-tabs",
"version": "0.11.0",
"version": "0.12.0",
"description": "Simple tabs for Electron applications",
"main": "index.js",
"repository": {
@ -20,6 +20,6 @@
"author": "brrd",
"license": "MIT",
"devDependencies": {
"electron": "^1.6.11"
"electron": "^8.0.0"
}
}