Giter Club home page Giter Club logo

Comments (4)

dwzkit avatar dwzkit commented on June 10, 2024 1

I've found the solution to the issue I was encountering. As it turns out, the solution was available in the official documentation all along. The fix is to add contenteditable="false" to the elements outside of the node-view-content.

This attribute tells the browser that the content of the node-view-content should not be editable by the user. By adding this attribute, the issue with the cursor not moving up and down as expected has been resolved.

from vue-tippy.

KABBOUCHI avatar KABBOUCHI commented on June 10, 2024

instead of using interactive, u can use manual trigger https://vue-tippy.netlify.app/props#trigger or set hideOnClick to false

from vue-tippy.

dwzkit avatar dwzkit commented on June 10, 2024

Here's the part of my Vue component code where the issue is:

<template>
  <node-view-wrapper>
    <tippy
        ref="tippyInstance"
        arrow
        :hide-on-click="false"
        interactive
        placement = 'left'
        theme="sidebar-bubble-toolbar"
        :inertia="true"
    >
      <!-- ... -->

      <template #content>
        <tippy
            arrow
            interactive
            :hide-on-click="false"
            :inertia="true"
            placement = "left"
            theme="sidebar-bubble-toolbar"
            animation="shift-away"
            :duration="[450, 250]"
            :onMount = "handleHoverStart"
            :onUntrigger = "handleHoverEnd"
        >
          <!-- ... -->

          <template #content>
            <side-tool-bar
                v-show = "isHovered"
                :hide-button-list="['history','bold','italic','underline','strike']"
                 style="border: 0px solid blue;padding: 0;"
                 :editor="editor"
                 :posFrom="posFrom"
                 :nodeViewProps="props"
                 :categoryOrder="['heading','text-align','mark']"/>
          </template>
        </tippy>
      </template>
    </tippy>
  </node-view-wrapper>
</template>

This is a screenshot showing the behavior before modification:
image

I tried removing the interactive attribute from the first tippy component, and changed the trigger to 'mouseenter focus'. This is how it looks after the modification:

  <node-view-wrapper>
    <tippy
        ref="tippyInstance"
        arrow
        :hide-on-click="false"
        trigger="mouseenter focus"
        placement='left'
        theme="sidebar-bubble-toolbar"
        :inertia="true"
    >
    <!-- ... -->

However, after this change, the second Tippy tooltip doesn't show up when the cursor is moved to anymore.
This is a screenshot showing the behavior after modification:
image

I'm unsure of how to modify my code to achieve the desired behavior. Can you help?

The desired effect I am aiming for is that when the first tippy instance is visible, if the cursor in the corresponding line presses the down arrow key, it should ideally move to the nearest position on the next line, not to the end of the current line. Currently, it moves to the end of the current line, which is inconsistent with the expected behavior. However, when I remove the "interactive" property, the cursor in the corresponding line can move to the nearest position on the next line upon pressing the down arrow key, as expected.However, when I make this modification, the second tippy instance can no longer be displayed and interacted with, which is also not my expected outcome.

image

from vue-tippy.

dwzkit avatar dwzkit commented on June 10, 2024

Upon investigation, it seems the issue arises from the selectVertically function in prosemirror-view. This function seems to handle vertical cursor movement, but it doesn't consider tiptap's NodeView components that contain elements beyond node-view-content.

function selectVertically(view: EditorView, dir: number, mods: string) {
  let sel = view.state.selection
  if (sel instanceof TextSelection && !sel.empty || mods.indexOf("s") > -1) return false
  if (browser.mac && mods.indexOf("m") > -1) return false
  let {$from, $to} = sel

  if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? "up" : "down")) {
    let next = moveSelectionBlock(view.state, dir)
    if (next && (next instanceof NodeSelection))
      return apply(view, next)
  }
  if (!$from.parent.inlineContent) {
    let side = dir < 0 ? $from : $to
    let beyond = sel instanceof AllSelection ? Selection.near(side, dir) : Selection.findFrom(side, dir)
    return beyond ? apply(view, beyond) : false
  }
  return false
}

I believe this function is causing the issue because it does not accommodate for the structure of a NodeView that contains more than just the node-view-content.

from vue-tippy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.