Improved Webkit and Gecko :empty selector.

But the real block level unfocusable bug is still not solved.
This commit is contained in:
djmaze 2020-09-24 16:11:46 +02:00
parent fca5a0e290
commit a8ddeecb49
2 changed files with 8 additions and 7 deletions

View file

@ -60,12 +60,14 @@
.squire-wysiwyg div:-moz-only-whitespace { .squire-wysiwyg div:-moz-only-whitespace {
min-height: 1em; min-height: 1em;
} }
.squire-wysiwyg div:empty:before, /*
.squire-wysiwyg div:-moz-only-whitespace:before { .squire-wysiwyg div:empty::before,
.squire-wysiwyg div:-moz-only-whitespace::before {
content: "Start writing here…"; content: "Start writing here…";
opacity: 0.5; opacity: 0.5;
position: absolute -moz-user-select: text;
} }
*/
.squire-wysiwyg, .squire-plain { .squire-wysiwyg, .squire-plain {
min-height: 200px; min-height: 200px;

View file

@ -241,7 +241,7 @@ const
fixCursor = ( node, root ) => { fixCursor = ( node, root ) => {
// In Webkit and Gecko, block level elements are collapsed and // In Webkit and Gecko, block level elements are collapsed and
// unfocusable if they have no content. To remedy this, a <BR> must be // unfocusable if they have no content (:empty). To remedy this, a <BR> must be
// inserted. In Opera and IE, we just need a textnode in order for the // inserted. In Opera and IE, we just need a textnode in order for the
// cursor to appear. // cursor to appear.
let self = root.__squire__; let self = root.__squire__;
@ -281,10 +281,9 @@ const
fixer = doc.createTextNode( '' ); fixer = doc.createTextNode( '' );
} }
} }
} else if ( !node.querySelector( 'BR' ) ) { // } else if ( !node.querySelector( 'BR' ) ) {
} else if ( node.matches( ':empty' ) ) {
fixer = createElement( doc, 'BR' ); fixer = createElement( doc, 'BR' );
// fixer = doc.createTextNode( ZWS );
// fixer = doc.createTextNode( NBSP );
while ( ( child = node.lastElementChild ) && !isInline( child ) ) { while ( ( child = node.lastElementChild ) && !isInline( child ) ) {
node = child; node = child;
} }