diff --git a/src/index.ts b/src/index.ts index e6b9d68..a0a8153 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,6 +26,11 @@ export interface GlobalDragHandleOptions { * If handle element is found, that element will be used as drag handle. If not, a default handle will be created */ dragHandleSelector?: string; + + /** + * except tag for drag handle + */ + exceptTag: string[]; } function absoluteRect(node: Element) { const data = node.getBoundingClientRect(); @@ -143,7 +148,10 @@ export function DragHandlePlugin( // if inline node is selected, e.g mention -> go to the parent node to select the whole node // if table row is selected, go to the parent node to select the whole node - if ((selection as NodeSelection).node.type.isInline || (selection as NodeSelection).node.type.name === 'tableRow') { + if ( + (selection as NodeSelection).node.type.isInline || + (selection as NodeSelection).node.type.name === 'tableRow' + ) { let $pos = view.state.doc.resolve(selection.from); selection = NodeSelection.create(view.state.doc, $pos.before()); } @@ -265,10 +273,11 @@ export function DragHandlePlugin( }); const notDragging = node?.closest('.not-draggable'); + const exceptTags = options.exceptTag.concat(['ol', 'ul']).join(', '); if ( !(node instanceof Element) || - node.matches('ul, ol') || + node.matches(exceptTags) || notDragging ) { hideDragHandle(); @@ -359,6 +368,7 @@ const GlobalDragHandle = Extension.create({ return { dragHandleWidth: 20, scrollTreshold: 100, + exceptTag: ['ul', 'ol'], }; }, @@ -369,6 +379,7 @@ const GlobalDragHandle = Extension.create({ dragHandleWidth: this.options.dragHandleWidth, scrollTreshold: this.options.scrollTreshold, dragHandleSelector: this.options.dragHandleSelector, + exceptTag: this.options.exceptTag, }), ]; },