Comments (2)
We won't add this feature because I think this is out of the scope of electron-tabs, which is intended to be generic and "KISS" lib.
Why not accessing title element with tab.spans.title
, as we do in :
Line 415 in 49525b8
By the way, be aware that contenteditable
does not filter out HTML elements, so pasting a h1 or several paragraphs in the tab would lead to a broken display. I guess you do want raw text, so you probably need to use window.prompt
instead. Untested example:
function tab_init(tab) {
const tabTitle = tab.spans.title;
tab.setTitle("Page " + tabGroup.newTabId);
tabTitle.addEventListener("click", function() {
const newTitle = window.prompt("Please type the new title");
tab.setTitle(newTitle);
});
}
from electron-tabs.
Thank you for the quick reply. tab.spans.title
is exactly what I was looking for.
I have a few comments if anybody else is looking for this functionality.
window.prompt
is not supported by electron, so you would have to write your own prompt function (electron/electron#472).
What I ended up using is the following:
function tab_init(tab) {
tab.setTitle("Page " + tabGroup.newTabId);
let tab_title = tab.spans.title;
tab.element.addEventListener("click", function() {
tab_title.setAttribute("contenteditable", true);
});
tab_title.addEventListener("blur", function() {
tab_title.setAttribute("contenteditable", false);
if (tab_title.textContent == "") tab_title.textContent = "No title";
tab_title.textContent = tab_title.textContent;
});
}
contenteditable
does not filter out pasted html elements, so I am filtering it out myself (tab_title.textContent = tab_title.textContent;
).
I am not calling tab.setTitle()
because it modifies the innerHTML
of the title span so html code would be rendered.
from electron-tabs.
Related Issues (20)
- height of tab-group never be changed. HOT 1
- how do Drag up and down to create a new window?like google Browser HOT 1
- Easier way to set the view height
- Chrome Style Tabs HOT 1
- How to remove the system default title bar, and the effect is similar to Chrome? HOT 2
- [feature]Could drag tab into another open window? HOT 2
- electron-tabs will not load local (file://) URL no matter what content it is HOT 13
- How can I use it in vue3? HOT 1
- locate elements in webview HOT 1
- setWindowOpenHandler not firing on the main process HOT 1
- How to refresh current tab content on click of menu HOT 3
- about addTab title HOT 1
- How to open link inside the tab content? HOT 2
- Using BrowserView instead of webView HOT 1
- Not loading js file HOT 3
- getNextTab / getPreviousTab HOT 1
- How to open the target blank hyperlinks inside the tab content in a new tab HOT 2
- Is it possible to disable background throttling on tabs? HOT 1
- How to set the css style of the background of the tab bar? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-tabs.