chore: fix issue with link editor position on iOS
This commit is contained in:
@@ -12,7 +12,6 @@ import { classNames } from '@standardnotes/snjs'
|
||||
import Icon from '@/Components/Icon/Icon'
|
||||
import StyledTooltip from '@/Components/StyledTooltip/StyledTooltip'
|
||||
import { TOGGLE_LINK_COMMAND } from '@lexical/link'
|
||||
import Portal from '@/Components/Portal/Portal'
|
||||
import { mergeRegister } from '@lexical/utils'
|
||||
import { KeyboardKey } from '@standardnotes/ui-services'
|
||||
import Button from '@/Components/Button/Button'
|
||||
@@ -20,6 +19,9 @@ import { sanitizeUrl } from '../../Lexical/Utils/sanitizeUrl'
|
||||
import { getSelectedNode } from '../../Lexical/Utils/getSelectedNode'
|
||||
import { $isLinkTextNode } from './ToolbarLinkTextEditor'
|
||||
import { useElementResize } from '@/Hooks/useElementRect'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { ElementIds } from '@/Constants/ElementIDs'
|
||||
import { getAdjustedStylesForNonPortalPopover } from '@/Components/Popover/Utils/getAdjustedStylesForNonPortal'
|
||||
|
||||
const FloatingLinkEditor = ({
|
||||
linkUrl,
|
||||
@@ -90,7 +92,8 @@ const FloatingLinkEditor = ({
|
||||
maxHeightFunction: () => 'none',
|
||||
})
|
||||
if (calculatedStyles) {
|
||||
Object.entries(calculatedStyles).forEach(([key, value]) => {
|
||||
const adjustedStyles = getAdjustedStylesForNonPortalPopover(linkEditorElement, calculatedStyles)
|
||||
Object.entries(adjustedStyles).forEach(([key, value]) => {
|
||||
linkEditorElement.style.setProperty(key, value)
|
||||
})
|
||||
linkEditorElement.style.opacity = '1'
|
||||
@@ -145,8 +148,7 @@ const FloatingLinkEditor = ({
|
||||
setTimeout(updateLinkEditorPosition)
|
||||
}, [isEditMode, updateLinkEditorPosition])
|
||||
|
||||
return (
|
||||
<Portal>
|
||||
return createPortal(
|
||||
<div
|
||||
id="super-link-editor"
|
||||
className="absolute bottom-12 left-1/2 z-modal w-[calc(100%_-_1rem)] -translate-x-1/2 rounded-lg border border-border bg-contrast px-2 py-1 shadow-sm shadow-contrast translucent-ui:border-[--popover-border-color] translucent-ui:bg-[--popover-background-color] translucent-ui:[backdrop-filter:var(--popover-backdrop-filter)] md:bottom-[unset] md:left-0 md:top-0 md:w-auto md:translate-x-0 md:opacity-0"
|
||||
@@ -275,8 +277,8 @@ const FloatingLinkEditor = ({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Portal>
|
||||
</div>,
|
||||
document.getElementById(ElementIds.SuperEditor) ?? document.body,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user