mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Code style fixed, font detection loop will continue until finding both size and family, and selections within single element are handled.
This commit is contained in:
parent
02ff9fe985
commit
f6b79eb82b
4 changed files with 12 additions and 10 deletions
|
@ -181,7 +181,7 @@ Returns the path through the DOM tree from the `<body>` element to the current c
|
|||
|
||||
### getFontInfo
|
||||
|
||||
Returns an object containing the font-family and font-size information for the element the cursor is in, if any was set. It uses style declarations to detect this, and so will not detect FONT tags. If a selection has been made, it will return an empty object.
|
||||
Returns an object containing the font-family and font-size information for the element the cursor is in, if any was set. It uses style declarations to detect this, and so will not detect FONT tags. If a selection across multiple elements has been made, it will return an empty object.
|
||||
|
||||
### getSelection
|
||||
|
||||
|
|
|
@ -2842,14 +2842,15 @@ proto.getFontInfo = function ( range ) {
|
|||
return {};
|
||||
}
|
||||
|
||||
var element, fontInfo = {};
|
||||
var fontInfo = {},
|
||||
element;
|
||||
|
||||
if ( range.collapsed ) {
|
||||
if ( range.collapsed || range.startContainer === range.endContainer ) {
|
||||
element = range.commonAncestorContainer;
|
||||
if (element.nodeType === TEXT_NODE) {
|
||||
if ( element.nodeType === TEXT_NODE ) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
while ( !fontInfo.family && !fontInfo.size && element && element.nodeName !== 'BODY' ) {
|
||||
while ( !( fontInfo.family && fontInfo.size ) && element && element.nodeName !== 'BODY' ) {
|
||||
if ( element.style.fontFamily ) {
|
||||
fontInfo.family = element.style.fontFamily;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -717,14 +717,15 @@ proto.getFontInfo = function ( range ) {
|
|||
return {};
|
||||
}
|
||||
|
||||
var element, fontInfo = {};
|
||||
var fontInfo = {},
|
||||
element;
|
||||
|
||||
if ( range.collapsed ) {
|
||||
if ( range.collapsed || range.startContainer === range.endContainer ) {
|
||||
element = range.commonAncestorContainer;
|
||||
if (element.nodeType === TEXT_NODE) {
|
||||
if ( element.nodeType === TEXT_NODE ) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
while ( !fontInfo.family && !fontInfo.size && element && element.nodeName !== 'BODY' ) {
|
||||
while ( !( fontInfo.family && fontInfo.size ) && element && element.nodeName !== 'BODY' ) {
|
||||
if ( element.style.fontFamily ) {
|
||||
fontInfo.family = element.style.fontFamily;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue