![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
[Feature request] - Ctrl+Click on classes
Hi, Kovid.
Is it possible to add the following feature? - Ctrl+Click on a CSS class name on Code window leading to the corresponding CSS seletor on the Stylesheet file Right now, I have to use the Live CSS panel. |
![]() |
![]() |
![]() |
#2 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 445
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
|
This might sound like a short-cut, but what if the code you ctrl-click on is part of a complex cascade of styling? In a complex book, I have enough trouble figuring some of it out WITH live css! Sometimes when looking at code view, what you think is a controlling class isn't really doing what you think it is. Not against the idea, just pointing this out...
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,221
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The problem with this, as retiredbiker points out is that it is misleading. There is no single place to jump to. Any class could be used as part of the selector for many different rules.
|
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Sorry, maybe I wasn't specific enough. The Ctrl+Click would be on the actual class name, not in any part of the element.
This is what I had in mind (just like Sigil): 1) Code example: Spoiler:
2) CSS stylesheet: Spoiler:
3) Now, if I Ctrl+Click on any of the class names, it would take me to the corresponding rule on the CSS Stylesheet. 4) If there are more than one rule applied, like the second example on the code (class="class3 class8"), this wouldn't be a problem, since I have to click on one or the other. If I click on on 'class3', it would take me to '.class3 {...}' on the CSS stylesheet. If I click on 'class8', then it would take me to '.class8 {...}'. Like I said, this is how it works on Sigil. it's very useful and time saving. On calibre Editor, this already work opening files through their links on the code. Last edited by thiago.eec; 01-27-2021 at 07:15 AM. |
![]() |
![]() |
![]() |
#5 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,221
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
There is no corresponding selector. There can be multiple selectors that have a given class name.
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
I mean, maybe you can have the same class name on multiple CSS Stylesheet files, but not on the same, right? And the CSS file is referenced using the <link> element on each HTML file. |
|
![]() |
![]() |
![]() |
#7 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,221
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Code:
p span.moo { color: red } li span.moo { color: green } You can even have multiple rules with the exact same selectors Code:
.moo { font-size: 11pt } .moo { color: purple } |
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
Thanks for explanation. P.S.: Sigil does recognize the diference between 'p.moo' vs 'li.moo', but choked on 'p span.moo' vs 'li span.moo' |
|
![]() |
![]() |
![]() |
#9 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,506
Karma: 5703586
Join Date: Nov 2009
Device: many
|
FWIW, Yes that feature in Sigil was designed to just handle element.class and .class selectors and not combinators and to take you to the first definition of the class if found in a linked stylesheet. The user would have to search the stylesheet for other places that class is defined or used. But that is typically easy to do once the Stylesheet tab is opened especially when only a single stylesheet is linked.
It is not a full query done by selector. It was designed to help in the majority of user cases that involve simple selectors and not meant for use with more advanced combinator or pseudoclass selectors. The Preview Inspector can be used to determine the exact selectors used. IMHO, the designers of CSS have completely forgotten the KISS engineering principle (and I could say the same for the epub3 spec, the html5 spec, etc!). Simple combinations of elements and classees can handle almost all cases especially when class attributes can be easily added to the epub xhtml source by the epub developer unlike when iframes and injected ad blocks are used where classes can not be easily added and therefore combinators must be used to handle things. FWIW, Sigil has just added its own version of gumbo query and fixed a number of bugs to help it determine if even complex css selectors apply to a specific node. So improvements for this feature in Sigil are coming but as Kovid said, there is no way to handle all cases. |
![]() |
![]() |
![]() |
#10 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Thanks for the input, Kevin.
I think that handling most of the cases is a great goal. It helps a lot when editing the book. |
![]() |
![]() |
![]() |
#11 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
You're able to double-click and jump to the class's location in the CSS. (Plus jumping to the very first instance would work for the vast majority of cases, like KevinH said.) I find the Right-Click > "Go to Link or Style" in Sigil to be absolutely fantastic, and it's one of my most-used features to easily hop around/parse books on opening. (Especially when dealing with calibre### classes.) Quote:
![]() Last edited by Tex2002ans; 01-29-2021 at 07:41 PM. |
||
![]() |
![]() |
![]() |
#12 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,252
Karma: 145488788
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
I find live CSS works really well. I can see the CSS class and see if I want to edit it. I know there is the preview, but it doesn't always show if the class needs editing.
|
![]() |
![]() |
![]() |
#13 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,252
Karma: 145488788
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
If this is added, can it be made as a right click menu item instead? I would find that much easier as I already have my hand on the mouse.
|
![]() |
![]() |
![]() |
#14 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,221
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@Tex2002 The calibre editor has live css which is a much more comprehensive solution to this problem. And no the reports allows you to see how many places a class is used not just jump to one, which may be quite misleading.
|
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,194
Karma: 1355861
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
|
Quote:
That would make it a lot less useful. You would have to click and then navigate to the menu item. That's a two step process. Ctrl+Click is a single step, and a lot faster. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Feature Request... | Syllius | Calibre | 2 | 08-26-2019 08:48 PM |
Pseudo classes to be deleted as unused classes | Leonatus | Sigil | 2 | 09-23-2018 09:12 AM |
feature request: ctrl+A in in the "file preview" | valida | Editor | 5 | 09-13-2017 07:18 AM |
[Android App] Calibre Companion - long-click request | Perkin | Devices | 3 | 09-06-2012 01:18 PM |
Feature Request | Beak | Devices | 2 | 02-20-2011 10:18 AM |