#439·VvvebJs

Text selection detection and media queries for wysiwyg editor leading to unwanted/confusing results

Author: hayden-tCreated Jan 17, 2026Updated Jan 17, 2026

https://github.com/givanz/VvvebJs/blob/078fe4f14ae3febb3c7387a605ccddc9803c4a7c/libs/builder/builder.js#L629

im using firefox and if you double click a text section, to show the little style editor that appears above your content, and change any setting there it just wraps the text in a span, even if you select the whole text, and if you change it again, it just inject another span inside the first span, on and on.

for me selection.baseNode just always is undefined, when i think it uses the common alias selection.anchorNode instead but as well as this the calculation of a selection length doesnt work

Also using the wysiwyg styler doesnt take into account if you are in mobile/tablet view or desktop.

You can force it to always apply the inline style editor changes to the parent element by setting this line to 0 https://github.com/givanz/VvvebJs/blob/078fe4f14ae3febb3c7387a605ccddc9803c4a7c/libs/builder/builder.js#L627 it just means any style applied will apply to the whole element regardless of selection

Also any edits via this toolbar are not counted in mediaqueries (tablet/mobile) view, leading to confusion as this is not mentioned, you could disable the toolbar completely and do everythign via the left panel by commenting out this line https://github.com/givanz/VvvebJs/blob/078fe4f14ae3febb3c7387a605ccddc9803c4a7c/libs/builder/builder.js#L799

Image i guess though there are different needs for different things, and really you might need to create links, bold words or colors within a text element this way, otherwise you would need a way to insert spans within existing elements another way , which you could do

So you sort of need it, and i think i might instead actually just remove font size from the toolbar so that theres no confusions, that way anything in the toolbar is not really mobile/desktop specific.

Here is my minimal toolbar for just working on inline text (ps you have to style hide the buttons, not html comment them out otherwise you get js errors expecting them https://github.com/givanz/VvvebJs/blob/078fe4f14ae3febb3c7387a605ccddc9803c4a7c/editor.html#L511

Image