* 检查选区是否选中在内容一行的开始或者结尾 * @param editor * @param options * @returns
(editor: Editor, options: { point?: Point; edge?: SelectionEdge } = {})
| 229 | * @returns |
| 230 | */ |
| 231 | isSelectLineEdge(editor: Editor, options: { point?: Point; edge?: SelectionEdge } = {}): boolean { |
| 232 | const { point = editor.selection?.focus, edge = 'start' } = options |
| 233 | if (!point) return false |
| 234 | const entry = Editor.above(editor, { at: point, match: n => Editor.isBlock(editor, n) }) |
| 235 | if (!entry) return false |
| 236 | const [block] = entry |
| 237 | const rangeLines = getLineRectsByRange(editor, { anchor: point, focus: point }) |
| 238 | if (rangeLines.length === 0) return false |
| 239 | const rangeLine = rangeLines[0] |
| 240 | const lines = getLineRectsByNode(editor, block) |
| 241 | for (const line of lines) { |
| 242 | if ( |
| 243 | ~['start', 'anchor'].indexOf(edge) && |
| 244 | line.left === rangeLine.left && |
| 245 | line.top === rangeLine.top |
| 246 | ) { |
| 247 | return true |
| 248 | } else if ( |
| 249 | ~['end', 'focus'].indexOf(edge) && |
| 250 | line.right === rangeLine.right && |
| 251 | line.top === rangeLine.top |
| 252 | ) { |
| 253 | return true |
| 254 | } |
| 255 | } |
| 256 | return false |
| 257 | }, |
| 258 | |
| 259 | /** |
| 260 | * Return the host window of the current editor. |
nothing calls this directly
no test coverage detected
searching dependent graphs…