chore: fix super editor menus overflowing
This commit is contained in:
@@ -989,7 +989,7 @@ class NoteView extends AbstractComponent<NoteViewProps, State> {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{editorMode === 'super' && (
|
{editorMode === 'super' && (
|
||||||
<div className={classNames('blocks-editor w-full flex-grow overflow-hidden overflow-y-auto')}>
|
<div className={classNames('blocks-editor w-full flex-grow overflow-hidden')}>
|
||||||
<SuperEditor
|
<SuperEditor
|
||||||
key={this.note.uuid}
|
key={this.note.uuid}
|
||||||
application={this.application}
|
application={this.application}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { isMobileScreen } from '@/Utils'
|
|||||||
import { CSSProperties } from 'react'
|
import { CSSProperties } from 'react'
|
||||||
import { PopoverAlignment, PopoverSide } from './Types'
|
import { PopoverAlignment, PopoverSide } from './Types'
|
||||||
import { OppositeSide, checkCollisions, getNonCollidingAlignment } from './Utils/Collisions'
|
import { OppositeSide, checkCollisions, getNonCollidingAlignment } from './Utils/Collisions'
|
||||||
import { getAppRect, getPopoverMaxHeight, getPositionedPopoverRect } from './Utils/Rect'
|
import { getPopoverMaxHeight, getPositionedPopoverRect } from './Utils/Rect'
|
||||||
|
|
||||||
const percentOf = (percent: number, value: number) => (percent / 100) * value
|
const percentOf = (percent: number, value: number) => (percent / 100) * value
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ export const getPositionedPopoverStyles = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
let maxHeight = getPopoverMaxHeight(
|
let maxHeight = getPopoverMaxHeight(
|
||||||
getAppRect(),
|
documentRect,
|
||||||
anchorRect,
|
anchorRect,
|
||||||
disableFlip ? side : sideWithLessOverflows,
|
disableFlip ? side : sideWithLessOverflows,
|
||||||
finalAlignment,
|
finalAlignment,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const getPopoverMaxHeight = (
|
|||||||
if (buttonRect) {
|
if (buttonRect) {
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case 'top':
|
case 'top':
|
||||||
constraint = appRect.height - buttonRect.top
|
constraint = Math.abs(appRect.height - buttonRect.top)
|
||||||
if (topSafeAreaInset > 0) {
|
if (topSafeAreaInset > 0) {
|
||||||
constraint += topSafeAreaInset
|
constraint += topSafeAreaInset
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ import { useStateRef } from '@/Hooks/useStateRef'
|
|||||||
import { getDOMRangeRect } from '../../Lexical/Utils/getDOMRangeRect'
|
import { getDOMRangeRect } from '../../Lexical/Utils/getDOMRangeRect'
|
||||||
import { getPositionedPopoverStyles } from '@/Components/Popover/GetPositionedPopoverStyles'
|
import { getPositionedPopoverStyles } from '@/Components/Popover/GetPositionedPopoverStyles'
|
||||||
import usePreference from '@/Hooks/usePreference'
|
import usePreference from '@/Hooks/usePreference'
|
||||||
|
import { ElementIds } from '@/Constants/ElementIDs'
|
||||||
|
|
||||||
const TOGGLE_LINK_AND_EDIT_COMMAND = createCommand<string | null>('TOGGLE_LINK_AND_EDIT_COMMAND')
|
const TOGGLE_LINK_AND_EDIT_COMMAND = createCommand<string | null>('TOGGLE_LINK_AND_EDIT_COMMAND')
|
||||||
|
|
||||||
@@ -503,7 +504,7 @@ const ToolbarPlugin = () => {
|
|||||||
|
|
||||||
const [isFocusInEditor, setIsFocusInEditor] = useState(false)
|
const [isFocusInEditor, setIsFocusInEditor] = useState(false)
|
||||||
const [isFocusInToolbar, setIsFocusInToolbar] = useState(false)
|
const [isFocusInToolbar, setIsFocusInToolbar] = useState(false)
|
||||||
const canShowToolbarOnMobile = isFocusInEditor || isFocusInToolbar
|
const canShowToolbarOnMobile = true
|
||||||
const canShowAllItems = isMobile || isToolbarFixedToTop
|
const canShowAllItems = isMobile || isToolbarFixedToTop
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -583,7 +584,8 @@ const ToolbarPlugin = () => {
|
|||||||
toolbarStore,
|
toolbarStore,
|
||||||
])
|
])
|
||||||
|
|
||||||
const popoverDocumentElement = editor.getRootElement()?.parentElement ?? document.body
|
const popoverDocumentElement =
|
||||||
|
document.getElementById(ElementIds.SuperEditor) ?? editor.getRootElement()?.parentElement ?? document.body
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -760,7 +762,7 @@ const ToolbarPlugin = () => {
|
|||||||
disableMobileFullscreenTakeover
|
disableMobileFullscreenTakeover
|
||||||
disableFlip
|
disableFlip
|
||||||
portal={false}
|
portal={false}
|
||||||
documentElement={isMobile ? popoverDocumentElement : undefined}
|
documentElement={popoverDocumentElement}
|
||||||
>
|
>
|
||||||
<div className="mb-1.5 mt-1 px-3 text-sm font-semibold uppercase text-text">Table of Contents</div>
|
<div className="mb-1.5 mt-1 px-3 text-sm font-semibold uppercase text-text">Table of Contents</div>
|
||||||
<LexicalTableOfContents>
|
<LexicalTableOfContents>
|
||||||
@@ -816,7 +818,7 @@ const ToolbarPlugin = () => {
|
|||||||
disableFlip
|
disableFlip
|
||||||
containerClassName="md:!min-w-60 md:!w-auto"
|
containerClassName="md:!min-w-60 md:!w-auto"
|
||||||
portal={false}
|
portal={false}
|
||||||
documentElement={isMobile ? popoverDocumentElement : undefined}
|
documentElement={popoverDocumentElement}
|
||||||
>
|
>
|
||||||
<Menu a11yLabel="Text formatting options" className="!px-0" onClick={() => setIsTextFormatMenuOpen(false)}>
|
<Menu a11yLabel="Text formatting options" className="!px-0" onClick={() => setIsTextFormatMenuOpen(false)}>
|
||||||
<ToolbarMenuItem
|
<ToolbarMenuItem
|
||||||
@@ -857,7 +859,7 @@ const ToolbarPlugin = () => {
|
|||||||
disableFlip
|
disableFlip
|
||||||
containerClassName="md:!min-w-60 md:!w-auto"
|
containerClassName="md:!min-w-60 md:!w-auto"
|
||||||
portal={false}
|
portal={false}
|
||||||
documentElement={isMobile ? popoverDocumentElement : undefined}
|
documentElement={popoverDocumentElement}
|
||||||
>
|
>
|
||||||
<Menu a11yLabel="Text style" className="!px-0" onClick={() => setIsTextStyleMenuOpen(false)}>
|
<Menu a11yLabel="Text style" className="!px-0" onClick={() => setIsTextStyleMenuOpen(false)}>
|
||||||
<ToolbarMenuItem
|
<ToolbarMenuItem
|
||||||
@@ -930,7 +932,7 @@ const ToolbarPlugin = () => {
|
|||||||
disableFlip
|
disableFlip
|
||||||
containerClassName="md:!min-w-60 md:!w-auto"
|
containerClassName="md:!min-w-60 md:!w-auto"
|
||||||
portal={false}
|
portal={false}
|
||||||
documentElement={isMobile ? popoverDocumentElement : undefined}
|
documentElement={popoverDocumentElement}
|
||||||
>
|
>
|
||||||
<Menu a11yLabel="Alignment" className="!px-0" onClick={() => setIsAlignmentMenuOpen(false)}>
|
<Menu a11yLabel="Alignment" className="!px-0" onClick={() => setIsAlignmentMenuOpen(false)}>
|
||||||
<ToolbarMenuItem
|
<ToolbarMenuItem
|
||||||
@@ -971,7 +973,7 @@ const ToolbarPlugin = () => {
|
|||||||
disableFlip
|
disableFlip
|
||||||
containerClassName="md:!min-w-60 md:!w-auto"
|
containerClassName="md:!min-w-60 md:!w-auto"
|
||||||
portal={false}
|
portal={false}
|
||||||
documentElement={isMobile ? popoverDocumentElement : undefined}
|
documentElement={popoverDocumentElement}
|
||||||
>
|
>
|
||||||
<Menu a11yLabel="Insert" className="!px-0" onClick={() => setIsInsertMenuOpen(false)}>
|
<Menu a11yLabel="Insert" className="!px-0" onClick={() => setIsInsertMenuOpen(false)}>
|
||||||
<ToolbarMenuItem
|
<ToolbarMenuItem
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import AutoFocusPlugin from './Plugins/AutoFocusPlugin'
|
|||||||
import usePreference from '@/Hooks/usePreference'
|
import usePreference from '@/Hooks/usePreference'
|
||||||
import BlockPickerMenuPlugin from './Plugins/BlockPickerPlugin/BlockPickerPlugin'
|
import BlockPickerMenuPlugin from './Plugins/BlockPickerPlugin/BlockPickerPlugin'
|
||||||
import { EditorEventSource } from '@/Types/EditorEventSource'
|
import { EditorEventSource } from '@/Types/EditorEventSource'
|
||||||
|
import { ElementIds } from '@/Constants/ElementIDs'
|
||||||
|
|
||||||
export const SuperNotePreviewCharLimit = 160
|
export const SuperNotePreviewCharLimit = 160
|
||||||
|
|
||||||
@@ -187,6 +188,7 @@ export const SuperEditor: FunctionComponent<Props> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
id={ElementIds.SuperEditor}
|
||||||
className="font-editor relative flex h-full w-full flex-col"
|
className="font-editor relative flex h-full w-full flex-col"
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ export const ElementIds = {
|
|||||||
ItemLinkAutocompleteInput: 'item-link-autocomplete-input',
|
ItemLinkAutocompleteInput: 'item-link-autocomplete-input',
|
||||||
SearchBar: 'search-bar',
|
SearchBar: 'search-bar',
|
||||||
ConflictResolutionButton: 'conflict-resolution-button',
|
ConflictResolutionButton: 'conflict-resolution-button',
|
||||||
|
SuperEditor: 'super-editor',
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
Reference in New Issue
Block a user