mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +01:00
editor: fix search popup removed on link hover
This commit is contained in:
@@ -26,15 +26,17 @@ import {
|
|||||||
import {
|
import {
|
||||||
getPopupContainer,
|
getPopupContainer,
|
||||||
getPopupRoot,
|
getPopupRoot,
|
||||||
getToolbarElement,
|
getToolbarElement
|
||||||
unmountPopupRoot
|
|
||||||
} from "../../toolbar/utils/dom.js";
|
} from "../../toolbar/utils/dom.js";
|
||||||
import {
|
import {
|
||||||
useIsMobile,
|
useIsMobile,
|
||||||
useToolbarStore
|
useToolbarStore
|
||||||
} from "../../toolbar/stores/toolbar-store.js";
|
} from "../../toolbar/stores/toolbar-store.js";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ResponsivePresenter, ResponsivePresenterProps } from "../responsive/index.js";
|
import {
|
||||||
|
ResponsivePresenter,
|
||||||
|
ResponsivePresenterProps
|
||||||
|
} from "../responsive/index.js";
|
||||||
|
|
||||||
export type PopupWrapperProps = UsePopupHandlerOptions & {
|
export type PopupWrapperProps = UsePopupHandlerOptions & {
|
||||||
autoCloseOnUnmount?: boolean;
|
autoCloseOnUnmount?: boolean;
|
||||||
@@ -106,11 +108,12 @@ type ShowPopupOptions = {
|
|||||||
export function showPopup(options: ShowPopupOptions) {
|
export function showPopup(options: ShowPopupOptions) {
|
||||||
const { popup, ...props } = options;
|
const { popup, ...props } = options;
|
||||||
|
|
||||||
|
const root = getPopupRoot();
|
||||||
function hide() {
|
function hide() {
|
||||||
unmountPopupRoot();
|
root.unmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPopupRoot().render(
|
root.render(
|
||||||
<ResponsivePresenter
|
<ResponsivePresenter
|
||||||
isOpen
|
isOpen
|
||||||
position={{
|
position={{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createRoot, Root } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
|
||||||
export function getToolbarElement() {
|
export function getToolbarElement() {
|
||||||
return (
|
return (
|
||||||
@@ -48,13 +48,9 @@ export function getEditorDOM() {
|
|||||||
getEditorContainer()) as HTMLElement; // ProseMirror
|
getEditorContainer()) as HTMLElement; // ProseMirror
|
||||||
}
|
}
|
||||||
|
|
||||||
let popupRoot: Root | undefined = undefined;
|
|
||||||
export function getPopupRoot() {
|
export function getPopupRoot() {
|
||||||
if (!popupRoot) popupRoot = createRoot(getPopupContainer());
|
const container = getPopupContainer();
|
||||||
return popupRoot;
|
const div = document.createElement("div");
|
||||||
}
|
container.appendChild(div);
|
||||||
|
return createRoot(div);
|
||||||
export function unmountPopupRoot() {
|
|
||||||
if (popupRoot) popupRoot.unmount();
|
|
||||||
popupRoot = undefined;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user