From 7892c6e7eede249ab6db26f020cf2f49e498e3e7 Mon Sep 17 00:00:00 2001 From: quank123wip Date: Fri, 8 Nov 2024 15:01:26 +0800 Subject: [PATCH] fix(tooltop): shift tooltip when overflow on x-axis. --- packages/plugins/plugin-tooltip/src/tooltip-provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/plugins/plugin-tooltip/src/tooltip-provider.ts b/packages/plugins/plugin-tooltip/src/tooltip-provider.ts index 5b850a042755..f67965df194b 100644 --- a/packages/plugins/plugin-tooltip/src/tooltip-provider.ts +++ b/packages/plugins/plugin-tooltip/src/tooltip-provider.ts @@ -3,7 +3,7 @@ import { TextSelection } from '@milkdown/prose/state' import type { EditorView } from '@milkdown/prose/view' import debounce from 'lodash.debounce' import type { VirtualElement } from '@floating-ui/dom' -import { computePosition, flip, offset } from '@floating-ui/dom' +import { computePosition, flip, offset, shift } from '@floating-ui/dom' import { posToDOMRect } from '@milkdown/prose' /// Options for tooltip provider. @@ -84,7 +84,7 @@ export class TooltipProvider { } computePosition(virtualEl, this.element, { placement: 'top', - middleware: [flip(), offset(this.#offset)], + middleware: [flip(), offset(this.#offset), shift()], }) .then(({ x, y }) => { Object.assign(this.element.style, {