diff --git a/app/editor/components/FloatingToolbar.tsx b/app/editor/components/FloatingToolbar.tsx index df7bc2177e..af198da950 100644 --- a/app/editor/components/FloatingToolbar.tsx +++ b/app/editor/components/FloatingToolbar.tsx @@ -89,7 +89,7 @@ function usePosition({ ? noticeBlock.pos : null; - if (position) { + if (position !== null) { const element = view.nodeDOM(position); const bounds = (element as HTMLElement).getBoundingClientRect(); selectionBounds.top = bounds.top; diff --git a/app/editor/menus/notice.tsx b/app/editor/menus/notice.tsx index 3ef1c8b71a..a1125c6b80 100644 --- a/app/editor/menus/notice.tsx +++ b/app/editor/menus/notice.tsx @@ -16,10 +16,8 @@ export default function noticeMenuItems( readOnly: boolean | undefined, dictionary: Dictionary ): MenuItem[] { - const { selection } = state; - const { $from } = selection; - const node = $from.node(-1); - const currentStyle = node.attrs.style as NoticeTypes; + const node = state.selection.$from.node(-1); + const currentStyle = node?.attrs.style as NoticeTypes; const mapping = { [NoticeTypes.Info]: dictionary.infoNotice,