Skip to content

Commit

Permalink
fix: tooltip plugin offset (#1419)
Browse files Browse the repository at this point in the history
* fix: tooltip plugin offset

* chore: fix offset
  • Loading branch information
Saul-Mirone authored Jul 11, 2024
1 parent 4511a04 commit 615b697
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
5 changes: 0 additions & 5 deletions packages/crepe/src/feature/block-edit/menu/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ export const menuComponent: Component<MenuProps> = ({
return

scrollRoot.scrollTop = target.offsetTop - scrollRoot.offsetTop

// target?.scrollIntoView({
// behavior: 'smooth',
// block: 'end',
// })
}, [])

const runByIndex = useCallback((index: number) => {
Expand Down
1 change: 1 addition & 0 deletions packages/crepe/src/feature/block-edit/menu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class MenuView implements PluginView {

return true
},
offset: 10,
})

this.#slashProvider.onShow = () => {
Expand Down
1 change: 1 addition & 0 deletions packages/crepe/src/feature/toolbar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ToolbarView implements PluginView {
this.#tooltipProvider = new TooltipProvider({
content: this.#content,
debounce: 20,
offset: 10,
shouldShow(view: EditorView) {
const { doc, selection } = view.state
const { empty, from, to } = selection
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/plugin-tooltip/src/tooltip-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class TooltipProvider {
}
computePosition(virtualEl, this.element, {
placement: 'top',
middleware: [flip()],
middleware: [flip(), offset(this.#offset)],
platform: {
...platform,
getOffsetParent: element =>
Expand Down

0 comments on commit 615b697

Please sign in to comment.