tiptap icon indicating copy to clipboard operation
tiptap copied to clipboard

[Documentation]: `drag-handle-react` and `node-range` pro extensions documentation

Open piszczu4 opened this issue 7 months ago • 4 comments

What’s the URL to the page you’re sending feedback for?

https://tiptap.dev/docs/editor/extensions

What part of the documentation needs improvement?

There is no description of above plugins

What is helpful about that part?

There is no description of above plugins

What is hard to understand, missing or misleading?

There is no description of above plugins

Anything to add? (optional)

No response

piszczu4 avatar Jan 22 '24 11:01 piszczu4

Any updates? It would be awesome to have docs for drag-handle (framework agnostic, I'm Svelte developer)

emil14 avatar Feb 12 '24 08:02 emil14

I also looking for drag handle docs. Any Updates?

carlosvaldesweb avatar Jun 05 '24 16:06 carlosvaldesweb

Sorry we are in the middle of a huge documentation refactor and that is why it is not up yet.

Hopefully in the coming weeks we can release it

nperez0111 avatar Jun 06 '24 07:06 nperez0111

How are we going with this @nperez0111 ?

mrowles avatar Jul 02 '24 07:07 mrowles

Are there any updates on this?

nachodeh avatar Aug 17 '24 08:08 nachodeh

I actually started writing this yesterday. Should be finished on monday

nperez0111 avatar Aug 17 '24 09:08 nperez0111

Here is the preliminary version:


title: Drag Handle extension tags:

  • type: pro meta: category: Editor title: Drag Handle extension | Tiptap Editor Docs description: Enable dragging nodes around your Tiptap Editor with the Drag Handle Extension. Learn how to set it up here in the Docs! extension: name: Drag Handle description: You ever wanted to drag nodes around your editor? Well we too - so here is an extension for that. type: extension icon: GripVertical isPro: true

import { CodeDemo } from '@/components/CodeDemo' import { Callout } from '@/components/ui/Callout'

You ever wanted to drag nodes around your editor? Well we too - so here is an extension for that.

The DragHandle extension allows you to easily handle dragging nodes around in the editor. You can define custom render functions, placement, and more.

Install

Integrate this pro extension by registering for a free [Tiptap account](https://cloud.tiptap.dev/register) and following our [access guide](/guides/pro-extensions) to Tiptap’s private repository.
npm install @tiptap-pro/extension-drag-handle

Settings

render

Renders an element that is positioned with tippy.js. This is the element that will be displayed as the handle when dragging a node around.

DragHandle.configure({
  render: () => {
    const element = document.createElement('div')

    // Use as a hook for CSS to insert an icon
    element.classList.add('custom-drag-handle')

    return element
  },
})

tippyOptions

Options for tippy.js. You can pass any options that are available in the tippy.js documentation.

Default: undefined

DragHandle.configure({
  tippyOptions: {
    placement: 'left',
  },
})

onNodeChange

Returns a node or null when a node is hovered over. This can be used to highlight the node that is currently hovered over.

Default: undefined

DragHandle.configure({
  onNodeChange: ({ node, editor }) => {
    if (!node) {
      selectedNode = null
      return
    }
    // Do something with the node
    selectedNode = node
  },
})

Commands

lockDragHandle()

Locks the draghandle in place and visibility. If the drag handle was visible, it will remain visible until unlocked. If it was hidden, it will remain hidden until unlocked.

This can be useful if you want to have a menu inside of the drag handle and want it to remain visible whether the drag handle is moused over or not.

editor.commands.lockDragHandle()

unlockDragHandle()

Unlocks the draghandle. Resets to default visibility and behavior.

editor.commands.unlockDragHandle()

toggleDragHandle()

Toggle draghandle lock state. If the drag handle is locked, it will be unlocked and vice versa.

editor.commands.toggleDragHandle()

nperez0111 avatar Aug 17 '24 09:08 nperez0111

@nperez0111 thanks! Just set it up in my editor and it's mostly working.

One notable major issue happens with lists. The drag handle plugin applies to the list as a whole instead of allowing me to drag individual items. Is this a known issue? Is there a config I can apply to select list items individually?

nachodeh avatar Aug 20 '24 11:08 nachodeh

@nperez0111 thanks! Just set it up in my editor and it's mostly working.

One notable major issue happens with lists. The drag handle plugin applies to the list as a whole instead of allowing me to drag individual items. Is this a known issue? Is there a config I can apply to select list items individually?

I didn't find any way of changing this behavior, this extension does have the wanted behavior, although as for my use case it also has a few problems.

ori-avraham avatar Aug 20 '24 16:08 ori-avraham