(rect: DOMRect, line: Record<'top' | 'bottom' | 'height', number>)
| 153 | * @return {Boolean} - True if the rect intersects with the line, false otherwise |
| 154 | */ |
| 155 | const isRectInLine = (rect: DOMRect, line: Record<'top' | 'bottom' | 'height', number>) => { |
| 156 | const deltaEdge = rect.height / 3 |
| 157 | return ( |
| 158 | // Check if the rect is fully contained within the line |
| 159 | (rect.top >= line.top && |
| 160 | (rect.bottom <= line.bottom || |
| 161 | // Check if the top of the rect is in the line and the overflow of the bottom is within 2/3 |
| 162 | rect.top + deltaEdge < line.bottom || |
| 163 | // Check if the bottom of the rect is within 2/3 from the top of the line and the top of the rect is above the bottom of the line |
| 164 | (rect.top <= line.top + line.height / 3 && rect.bottom > line.top))) || |
| 165 | // Check if the rect covers the height of the line and the line is within the top and bottom of the rect |
| 166 | (rect.top <= line.top && |
| 167 | (rect.bottom >= line.bottom || |
| 168 | // Check if the top of the rect is above or equal to the top of the line and the bottom of the rect is within 2/3 of the line |
| 169 | rect.bottom - deltaEdge > line.top)) || |
| 170 | // Check if the bottom of the rect is within 2/3 from the bottom of the line and the top of the rect is above the bottom of the line |
| 171 | (rect.bottom <= line.bottom && |
| 172 | rect.bottom >= line.bottom - line.height / 3 && |
| 173 | rect.top < line.bottom) |
| 174 | ) |
| 175 | } |
| 176 | /** |
| 177 | * Find the maximum position in the line of the top position in the el node |
| 178 | * @param editor - The Editor instance |
no outgoing calls
no test coverage detected
searching dependent graphs…