mirror of
https://github.com/fastmail/Squire.git
synced 2025-02-21 22:35:57 -05:00
Fix getFontInfo iteration up tree
This commit is contained in:
parent
3afa14bf40
commit
e133f26db1
3 changed files with 41 additions and 37 deletions
|
@ -2974,29 +2974,31 @@ proto.getFontInfo = function ( range ) {
|
|||
if ( element.nodeType === TEXT_NODE ) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
while ( seenAttributes < 4 && element && ( style = element.style ) ) {
|
||||
if ( !fontInfo.color && ( attr = style.color ) ) {
|
||||
fontInfo.color = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.backgroundColor &&
|
||||
( attr = style.backgroundColor ) ) {
|
||||
fontInfo.backgroundColor = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
|
||||
fontInfo.family = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
|
||||
fontInfo.size = attr;
|
||||
seenAttributes += 1;
|
||||
while ( seenAttributes < 4 && element ) {
|
||||
if ( style = element.style ) {
|
||||
if ( !fontInfo.color && ( attr = style.color ) ) {
|
||||
fontInfo.color = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.backgroundColor &&
|
||||
( attr = style.backgroundColor ) ) {
|
||||
fontInfo.backgroundColor = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
|
||||
fontInfo.family = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
|
||||
fontInfo.size = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
}
|
||||
element = element.parentNode;
|
||||
}
|
||||
}
|
||||
return fontInfo;
|
||||
};
|
||||
};
|
||||
|
||||
proto._addFormat = function ( tag, attributes, range ) {
|
||||
// If the range is collapsed we simply insert the node by wrapping
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -794,29 +794,31 @@ proto.getFontInfo = function ( range ) {
|
|||
if ( element.nodeType === TEXT_NODE ) {
|
||||
element = element.parentNode;
|
||||
}
|
||||
while ( seenAttributes < 4 && element && ( style = element.style ) ) {
|
||||
if ( !fontInfo.color && ( attr = style.color ) ) {
|
||||
fontInfo.color = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.backgroundColor &&
|
||||
( attr = style.backgroundColor ) ) {
|
||||
fontInfo.backgroundColor = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
|
||||
fontInfo.family = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
|
||||
fontInfo.size = attr;
|
||||
seenAttributes += 1;
|
||||
while ( seenAttributes < 4 && element ) {
|
||||
if ( style = element.style ) {
|
||||
if ( !fontInfo.color && ( attr = style.color ) ) {
|
||||
fontInfo.color = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.backgroundColor &&
|
||||
( attr = style.backgroundColor ) ) {
|
||||
fontInfo.backgroundColor = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.family && ( attr = style.fontFamily ) ) {
|
||||
fontInfo.family = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
if ( !fontInfo.size && ( attr = style.fontSize ) ) {
|
||||
fontInfo.size = attr;
|
||||
seenAttributes += 1;
|
||||
}
|
||||
}
|
||||
element = element.parentNode;
|
||||
}
|
||||
}
|
||||
return fontInfo;
|
||||
};
|
||||
};
|
||||
|
||||
proto._addFormat = function ( tag, attributes, range ) {
|
||||
// If the range is collapsed we simply insert the node by wrapping
|
||||
|
|
Loading…
Add table
Reference in a new issue