fix: Fixed super note "Table of contents" not working on mobile

This commit is contained in:
Aman Harwara
2024-04-01 17:34:03 +05:30
parent 4b19076f9b
commit 73eba38c14
2 changed files with 17 additions and 6 deletions

View File

@@ -736,7 +736,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"
SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
boost: 57d2868c099736d80fcd648bf211b4431e51a558
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 71803c074f6325f10b5ec891c443b6bbabef0ca7
@@ -756,7 +756,7 @@ SPEC CHECKSUMS:
MMKV: 9c6c3fa4ddd849f28c7b9a5c9d23aab84f14ee35
MMKVCore: 9bb7440b170181ac5b81f542ac258103542e693d
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 0080d0a6ebf2577475bda044aa59e2ca1f909cda
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: df81ab637d35fac9e6eb94611cfd20f0feb05455
RCTTypeSafety: 4636e4a36c7c2df332bda6d59b19b41c443d4287
React: e0cc5197a804031a6c53fb38483c3485fcb9d6f3

View File

@@ -22,6 +22,7 @@ import {
COMMAND_PRIORITY_LOW,
$createParagraphNode,
$isTextNode,
$getNodeByKey,
} from 'lexical'
import {
mergeRegister,
@@ -816,6 +817,7 @@ const ToolbarPlugin = () => {
className="py-1"
disableMobileFullscreenTakeover
disableFlip
disableApplyingMobileWidth
portal={false}
documentElement={popoverDocumentElement}
>
@@ -837,14 +839,23 @@ const ToolbarPlugin = () => {
<MenuItem
key={key}
className="overflow-hidden md:py-2"
onClick={() => {
editor.getEditorState().read(() => {
onMouseDown={(event) => {
event.preventDefault()
setIsTOCOpen(false)
editor.update(() => {
const node = $getNodeByKey(key)
if (!node) {
return
}
node.selectEnd()
editor.focus()
const domElement = editor.getElementByKey(key)
if (!domElement) {
return
}
domElement.scrollIntoView({ block: 'start' })
setIsTOCOpen(false)
setTimeout(() => {
domElement.scrollIntoView({ behavior: 'smooth', block: 'start' })
}, 1)
})
}}
style={{