mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* fix: use TipTap Markdown for rich text fields * fix: escape markdown at line starts only and skip saves without edits * perf: skip the preview markdown round-trip when no empty paragraphs are possible * fix: address feedback; add docs * fix: copilot feedback * fix: copy one cell, paste in edit mode in another one
23 lines
660 B
JavaScript
23 lines
660 B
JavaScript
import { posToDOMRect } from '@tiptap/core'
|
|
|
|
export const isRichTextSelectionVisible = (editor, scrollTargets) => {
|
|
if (!editor || !scrollTargets) {
|
|
return true
|
|
}
|
|
|
|
const { from, to } = editor.state.selection
|
|
const selectionRect = posToDOMRect(editor.view, from, to)
|
|
const targets = Array.isArray(scrollTargets) ? scrollTargets : [scrollTargets]
|
|
|
|
return targets.every((target) => {
|
|
const containerRect =
|
|
target === window
|
|
? { top: 0, bottom: window.innerHeight }
|
|
: target.getBoundingClientRect()
|
|
return (
|
|
selectionRect.bottom > containerRect.top &&
|
|
selectionRect.top < containerRect.bottom
|
|
)
|
|
})
|
|
}
|