@tiptap/extension-drag-handle 2.25.1 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/drag-handle-plugin.d.ts +3 -3
- package/dist/drag-handle-plugin.d.ts.map +1 -1
- package/dist/index.cjs +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +8 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/drag-handle-plugin.ts +50 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core';
|
|
2
|
-
import { Node } from '@tiptap/pm/model';
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { Node } from '@tiptap/pm/model';
|
|
3
3
|
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
4
|
-
import { Props as TippyProps } from 'tippy.js';
|
|
4
|
+
import type { Props as TippyProps } from 'tippy.js';
|
|
5
5
|
export interface DragHandlePluginProps {
|
|
6
6
|
pluginKey?: PluginKey | string;
|
|
7
7
|
editor: Editor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-handle-plugin.d.ts","sourceRoot":"","sources":["../src/drag-handle-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"drag-handle-plugin.d.ts","sourceRoot":"","sources":["../src/drag-handle-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,KAAK,EAAY,KAAK,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AA+D7D,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,WAAW,CAAA;IACpB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;QACjB,GAAG,EAAE,MAAM,CAAA;KACZ,KAAK,IAAI,CAAA;IACV,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;CACnC;AAED,eAAO,MAAM,0BAA0B,gBAA8B,CAAA;AAErE,eAAO,MAAM,gBAAgB,gEAM1B,qBAAqB;;EAwTvB,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -197,7 +197,7 @@ const getAbsolutePos = (state, relativePos) => {
|
|
|
197
197
|
if (!ystate) {
|
|
198
198
|
return -1;
|
|
199
199
|
}
|
|
200
|
-
return yProsemirror.relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
|
|
200
|
+
return (yProsemirror.relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0);
|
|
201
201
|
};
|
|
202
202
|
const getOuterDomNode = (view, domNode) => {
|
|
203
203
|
let tmpDomNode = domNode;
|
|
@@ -386,6 +386,13 @@ const DragHandlePlugin = ({ pluginKey = dragHandlePluginDefaultKey, element, edi
|
|
|
386
386
|
},
|
|
387
387
|
props: {
|
|
388
388
|
handleDOMEvents: {
|
|
389
|
+
keydown(view) {
|
|
390
|
+
if (popup && popup.state.isVisible && view.hasFocus()) {
|
|
391
|
+
popup.hide();
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
},
|
|
389
396
|
mouseleave(_view, e) {
|
|
390
397
|
// Do not hide open popup on mouseleave.
|
|
391
398
|
if (locked) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport { Node } from '@tiptap/pm/model'\nimport {\n EditorState, Plugin, PluginKey,\n Transaction,\n} from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\nimport tippy, { Instance, Props as TippyProps } from 'tippy.js'\nimport { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean;\n};\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping)\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string;\n editor: Editor;\n element: HTMLElement;\n onNodeChange?: (data: { editor: Editor; node: Node | null; pos: number }) => void;\n tippyOptions?: Partial<TippyProps>;\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(tr: Transaction, value: PluginState, oldState: EditorState, state: EditorState) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle","getSelectionRanges","NodeRangeSelection","ySyncPluginKey","absolutePositionToRelativePosition","relativePositionToAbsolutePosition","PluginKey","Plugin","isChangeOrigin","tippy","Extension"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;IAClC,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;AAG7D,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,YAAY,CAAC,IAAiB,EAAA;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgB;AACtD,IAAA,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAkB;AAC7F,IAAA,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAkB;IAEzG,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,KAAK,KAAI;AAC9C,QAAA,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC;AACjE,KAAC,CAAC;AAEF,IAAA,OAAO,UAAU;AACnB;;ACXO,M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Q,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAI;AACrC,gBAAA,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK;AAC3B,gBAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAI;gBACrC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;AAC1C,gBAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;SACF;KACF;IAED,qBAAqB,GAAA;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAErC,OAAO;AACL,YAAA,gBAAgB,CAAC;AACf,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;gBACvC,OAAO;gBACP,MAAM,EAAE,IAAI,CAAC,MAAM;AACnB,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;aACxC,CAAC;SACH;KACF;AACF,CAAA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import type { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport type { Node } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\nimport type { Instance, Props as TippyProps } from 'tippy.js'\nimport tippy from 'tippy.js'\nimport {\n absolutePositionToRelativePosition,\n relativePositionToAbsolutePosition,\n ySyncPluginKey,\n} from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean\n}\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(\n absolutePos,\n ystate.type,\n ystate.binding.mapping,\n )\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return (\n relativePositionToAbsolutePosition(\n ystate.doc,\n ystate.type,\n relativePos,\n ystate.binding.mapping,\n ) || 0\n )\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string\n editor: Editor\n element: HTMLElement\n onNodeChange?: (data: {\n editor: Editor\n node: Node | null\n pos: number\n }) => void\n tippyOptions?: Partial<TippyProps>\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(\n tr: Transaction,\n value: PluginState,\n oldState: EditorState,\n state: EditorState,\n ) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n keydown(view) {\n if (popup && popup.state.isVisible && view.hasFocus()) {\n popup.hide()\n return false\n }\n\n return false\n },\n\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle","getSelectionRanges","NodeRangeSelection","ySyncPluginKey","absolutePositionToR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AAC1B,gBAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAI;AACrC,gBAAA,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,KAAK;AAC3B,gBAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAI;gBACrC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;AAC1C,gBAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;aACtE;SACF;KACF;IAED,qBAAqB,GAAA;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QAErC,OAAO;AACL,YAAA,gBAAgB,CAAC;AACf,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;gBACvC,OAAO;gBACP,MAAM,EAAE,IAAI,CAAC,MAAM;AACnB,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;aACxC,CAAC;SACH;KACF;AACF,CAAA;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ const getAbsolutePos = (state, relativePos) => {
|
|
|
189
189
|
if (!ystate) {
|
|
190
190
|
return -1;
|
|
191
191
|
}
|
|
192
|
-
return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
|
|
192
|
+
return (relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0);
|
|
193
193
|
};
|
|
194
194
|
const getOuterDomNode = (view, domNode) => {
|
|
195
195
|
let tmpDomNode = domNode;
|
|
@@ -378,6 +378,13 @@ const DragHandlePlugin = ({ pluginKey = dragHandlePluginDefaultKey, element, edi
|
|
|
378
378
|
},
|
|
379
379
|
props: {
|
|
380
380
|
handleDOMEvents: {
|
|
381
|
+
keydown(view) {
|
|
382
|
+
if (popup && popup.state.isVisible && view.hasFocus()) {
|
|
383
|
+
popup.hide();
|
|
384
|
+
return false;
|
|
385
|
+
}
|
|
386
|
+
return false;
|
|
387
|
+
},
|
|
381
388
|
mouseleave(_view, e) {
|
|
382
389
|
// Do not hide open popup on mouseleave.
|
|
383
390
|
if (locked) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport { Node } from '@tiptap/pm/model'\nimport {\n EditorState, Plugin, PluginKey,\n Transaction,\n} from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\nimport tippy, { Instance, Props as TippyProps } from 'tippy.js'\nimport { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean;\n};\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping)\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string;\n editor: Editor;\n element: HTMLElement;\n onNodeChange?: (data: { editor: Editor; node: Node | null; pos: number }) => void;\n tippyOptions?: Partial<TippyProps>;\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(tr: Transaction, value: PluginState, oldState: EditorState, state: EditorState) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle"],"mappings":";;;;;;;AAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;IAClC,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;AAG7D,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,YAAY,CAAC,IAAiB,EAAA;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgB;AACtD,IAAA,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAkB;AAC7F,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/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import type { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport type { Node } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\nimport type { Instance, Props as TippyProps } from 'tippy.js'\nimport tippy from 'tippy.js'\nimport {\n absolutePositionToRelativePosition,\n relativePositionToAbsolutePosition,\n ySyncPluginKey,\n} from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean\n}\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(\n absolutePos,\n ystate.type,\n ystate.binding.mapping,\n )\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return (\n relativePositionToAbsolutePosition(\n ystate.doc,\n ystate.type,\n relativePos,\n ystate.binding.mapping,\n ) || 0\n )\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string\n editor: Editor\n element: HTMLElement\n onNodeChange?: (data: {\n editor: Editor\n node: Node | null\n pos: number\n }) => void\n tippyOptions?: Partial<TippyProps>\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(\n tr: Transaction,\n value: PluginState,\n oldState: EditorState,\n state: EditorState,\n ) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n keydown(view) {\n if (popup && popup.state.isVisible && view.hasFocus()) {\n popup.hide()\n return false\n }\n\n return false\n },\n\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle"],"mappings":";;;;;;;AAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;IAClC,IAAI,KAAK,GAAG,EAAE;AACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;AAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;AACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;AAG7D,IAAA,OAAO,KAAK;AACd;AAEM,SAAU,YAAY,CAAC,IAAiB,EAAA;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgB;AACtD,IAAA,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAkB;AAC7F,IAAA,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAkB;IAEzG,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,KAAK,KAAI;AAC9C,QAAA,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC;AACjE,KAAC,CAAC;AAEF,IAAA,OAAO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ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0;
|
|
191
|
+
return (yProsemirror.relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0);
|
|
192
192
|
};
|
|
193
193
|
const getOuterDomNode = (view, domNode) => {
|
|
194
194
|
let tmpDomNode = domNode;
|
|
@@ -377,6 +377,13 @@
|
|
|
377
377
|
},
|
|
378
378
|
props: {
|
|
379
379
|
handleDOMEvents: {
|
|
380
|
+
keydown(view) {
|
|
381
|
+
if (popup && popup.state.isVisible && view.hasFocus()) {
|
|
382
|
+
popup.hide();
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
return false;
|
|
386
|
+
},
|
|
380
387
|
mouseleave(_view, e) {
|
|
381
388
|
// Do not hide open popup on mouseleave.
|
|
382
389
|
if (locked) {
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport { Node } from '@tiptap/pm/model'\nimport {\n EditorState, Plugin, PluginKey,\n Transaction,\n} from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\nimport tippy, { Instance, Props as TippyProps } from 'tippy.js'\nimport { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean;\n};\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(absolutePos, ystate.type, ystate.binding.mapping)\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return relativePositionToAbsolutePosition(ystate.doc, ystate.type, relativePos, ystate.binding.mapping) || 0\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string;\n editor: Editor;\n element: HTMLElement;\n onNodeChange?: (data: { editor: Editor; node: Node | null; pos: number }) => void;\n tippyOptions?: Partial<TippyProps>;\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(tr: Transaction, value: PluginState, oldState: EditorState, state: EditorState) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle","getSelectionRanges","NodeRangeSelection","ySyncPluginKey","absolutePositionToRelativePosition","relativePositionToAbsolutePosition","PluginKey","Plugin","isChangeOrigin","Extension"],"mappings":";;;;;;EAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;MAClC,IAAI,KAAK,GAAG,EAAE;EACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;EAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;EACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;EAG7D,IAAA,OAAO,KAAK;EACd;EAEM,SAAU,Y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;EACf,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;kBACvC,OAAO;kBACP,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;eACxC,CAAC;WACH;OACF;EACF,CAAA;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/helpers/cloneElement.ts","../src/helpers/findNextElementFromCursor.ts","../src/helpers/getComputedStyle.ts","../src/helpers/minMax.ts","../src/helpers/getInnerCoords.ts","../src/helpers/removeNode.ts","../src/helpers/dragHandler.ts","../src/helpers/getOuterNode.ts","../src/drag-handle-plugin.ts","../src/drag-handle.ts"],"sourcesContent":["function getCSSText(element: Element) {\n let value = ''\n const style = getComputedStyle(element)\n\n for (let i = 0; i < style.length; i += 1) {\n value += `${style[i]}:${style.getPropertyValue(style[i])};`\n }\n\n return value\n}\n\nexport function cloneElement(node: HTMLElement) {\n const clonedNode = node.cloneNode(true) as HTMLElement\n const sourceElements = [node, ...Array.from(node.getElementsByTagName('*'))] as HTMLElement[]\n const targetElements = [clonedNode, ...Array.from(clonedNode.getElementsByTagName('*'))] as HTMLElement[]\n\n sourceElements.forEach((sourceElement, index) => {\n targetElements[index].style.cssText = getCSSText(sourceElement)\n })\n\n return clonedNode\n}\n","import { Editor } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\n\nexport type FindElementNextToCoords = {\n x: number\n y: number\n direction?: 'left' | 'right'\n editor: Editor\n}\n\nexport const findElementNextToCoords = (options: FindElementNextToCoords) => {\n const {\n x, y, direction, editor,\n } = options\n let resultElement: HTMLElement | null = null\n let resultNode: Node | null = null\n let pos: number | null = null\n\n let currentX = x\n\n while (resultNode === null && currentX < window.innerWidth && currentX > 0) {\n const allElements = document.elementsFromPoint(currentX, y)\n const prosemirrorIndex = allElements.findIndex(element => element.classList.contains('ProseMirror'))\n const filteredElements = allElements.slice(0, prosemirrorIndex)\n\n if (filteredElements.length > 0) {\n const target = filteredElements[0]\n\n resultElement = target as HTMLElement\n pos = editor.view.posAtDOM(target, 0)\n\n if (pos >= 0) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n\n if (resultNode?.isText) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos - 1, 0))\n }\n\n if (!resultNode) {\n resultNode = editor.state.doc.nodeAt(Math.max(pos, 0))\n }\n\n break\n }\n }\n\n if (direction === 'left') {\n currentX -= 1\n } else {\n currentX += 1\n }\n }\n\n return { resultElement, resultNode, pos: pos ?? null }\n}\n","export function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any {\n const style = window.getComputedStyle(node)\n\n return style[property]\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","import { EditorView } from '@tiptap/pm/view'\n\nimport { getComputedStyle } from './getComputedStyle.js'\nimport { minMax } from './minMax.js'\n\nexport function getInnerCoords(view: EditorView, x: number, y: number): { left: number, top: number } {\n const paddingLeft = parseInt(getComputedStyle(view.dom, 'paddingLeft'), 10)\n const paddingRight = parseInt(getComputedStyle(view.dom, 'paddingRight'), 10)\n const borderLeft = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const borderRight = parseInt(getComputedStyle(view.dom, 'borderLeftWidth'), 10)\n const bounds = view.dom.getBoundingClientRect()\n const coords = {\n left: minMax(\n x,\n bounds.left + paddingLeft + borderLeft,\n bounds.right - paddingRight - borderRight,\n ),\n top: y,\n }\n\n return coords\n}\n","export function removeNode(node: HTMLElement) {\n node.parentNode?.removeChild(node)\n}\n","import { Editor } from '@tiptap/core'\nimport { getSelectionRanges, NodeRangeSelection } from '@tiptap/extension-node-range'\nimport { SelectionRange } from '@tiptap/pm/state'\n\nimport { cloneElement } from './cloneElement.js'\nimport { findElementNextToCoords } from './findNextElementFromCursor.js'\nimport { getInnerCoords } from './getInnerCoords.js'\nimport { removeNode } from './removeNode.js'\n\nfunction getDragHandleRanges(event: DragEvent, editor: Editor): SelectionRange[] {\n const { doc } = editor.view.state\n\n const result = findElementNextToCoords({\n editor, x: event.clientX, y: event.clientY, direction: 'right',\n })\n\n if (!result.resultNode || result.pos === null) {\n return []\n }\n\n const x = event.clientX\n\n // @ts-ignore\n const coords = getInnerCoords(editor.view, x, event.clientY)\n const posAtCoords = editor.view.posAtCoords(coords)\n\n if (!posAtCoords) {\n return []\n }\n\n const { pos } = posAtCoords\n const nodeAt = doc.resolve(pos).parent\n\n if (!nodeAt) {\n return []\n }\n\n const $from = doc.resolve(result.pos)\n const $to = doc.resolve(result.pos + 1)\n\n return getSelectionRanges($from, $to, 0)\n}\n\nexport function dragHandler(event: DragEvent, editor: Editor) {\n const { view } = editor\n\n if (!event.dataTransfer) {\n return\n }\n\n const { empty, $from, $to } = view.state.selection\n\n const dragHandleRanges = getDragHandleRanges(event, editor)\n\n const selectionRanges = getSelectionRanges($from, $to, 0)\n const isDragHandleWithinSelection = selectionRanges.some(range => {\n return dragHandleRanges.find(dragHandleRange => {\n return dragHandleRange.$from === range.$from\n && dragHandleRange.$to === range.$to\n })\n })\n\n const ranges = empty || !isDragHandleWithinSelection\n ? dragHandleRanges\n : selectionRanges\n\n if (!ranges.length) {\n return\n }\n\n const { tr } = view.state\n const wrapper = document.createElement('div')\n const from = ranges[0].$from.pos\n const to = ranges[ranges.length - 1].$to.pos\n\n const selection = NodeRangeSelection.create(view.state.doc, from, to)\n const slice = selection.content()\n\n ranges.forEach(range => {\n const element = view.nodeDOM(range.$from.pos) as HTMLElement\n const clonedElement = cloneElement(element)\n\n wrapper.append(clonedElement)\n })\n\n wrapper.style.position = 'absolute'\n wrapper.style.top = '-10000px'\n document.body.append(wrapper)\n\n event.dataTransfer.clearData()\n event.dataTransfer.setDragImage(wrapper, 0, 0)\n\n // tell ProseMirror the dragged content\n view.dragging = { slice, move: true }\n\n tr.setSelection(selection)\n\n view.dispatch(tr)\n\n // clean up\n document.addEventListener('drop', () => removeNode(wrapper), { once: true })\n}\n","import { Node } from '@tiptap/pm/model'\n\nexport const getOuterNodePos = (doc: Node, pos: number): number => {\n const resolvedPos = doc.resolve(pos)\n const { depth } = resolvedPos\n\n if (depth === 0) {\n return pos\n }\n\n const a = resolvedPos.pos - resolvedPos.parentOffset\n\n return a - 1\n}\n\nexport const getOuterNode = (doc: Node, pos: number): Node | null => {\n const node = doc.nodeAt(pos)\n const resolvedPos = doc.resolve(pos)\n\n let { depth } = resolvedPos\n let parent = node\n\n while (depth > 0) {\n const currentNode = resolvedPos.node(depth)\n\n depth -= 1\n\n if (depth === 0) {\n parent = currentNode\n }\n }\n\n return parent\n}\n","import type { Editor } from '@tiptap/core'\nimport { isChangeOrigin } from '@tiptap/extension-collaboration'\nimport type { Node } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\nimport type { Instance, Props as TippyProps } from 'tippy.js'\nimport tippy from 'tippy.js'\nimport {\n absolutePositionToRelativePosition,\n relativePositionToAbsolutePosition,\n ySyncPluginKey,\n} from 'y-prosemirror'\n\nimport { dragHandler } from './helpers/dragHandler.js'\nimport { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'\nimport { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'\nimport { removeNode } from './helpers/removeNode.js'\n\ntype PluginState = {\n locked: boolean\n}\n\nconst getRelativePos = (state: EditorState, absolutePos: number) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return null\n }\n\n return absolutePositionToRelativePosition(\n absolutePos,\n ystate.type,\n ystate.binding.mapping,\n )\n}\n\nconst getAbsolutePos = (state: EditorState, relativePos: any) => {\n const ystate = ySyncPluginKey.getState(state)\n\n if (!ystate) {\n return -1\n }\n\n return (\n relativePositionToAbsolutePosition(\n ystate.doc,\n ystate.type,\n relativePos,\n ystate.binding.mapping,\n ) || 0\n )\n}\n\nconst getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {\n let tmpDomNode = domNode\n\n // Traverse to top level node.\n while (tmpDomNode && tmpDomNode.parentNode) {\n if (tmpDomNode.parentNode === view.dom) {\n break\n }\n\n tmpDomNode = tmpDomNode.parentNode as HTMLElement\n }\n\n return tmpDomNode\n}\n\nexport interface DragHandlePluginProps {\n pluginKey?: PluginKey | string\n editor: Editor\n element: HTMLElement\n onNodeChange?: (data: {\n editor: Editor\n node: Node | null\n pos: number\n }) => void\n tippyOptions?: Partial<TippyProps>\n}\n\nexport const dragHandlePluginDefaultKey = new PluginKey('dragHandle')\n\nexport const DragHandlePlugin = ({\n pluginKey = dragHandlePluginDefaultKey,\n element,\n editor,\n tippyOptions,\n onNodeChange,\n}: DragHandlePluginProps) => {\n const wrapper = document.createElement('div')\n let popup: Instance | null = null\n let locked = false\n let currentNode: Node | null = null\n let currentNodePos = -1\n let currentNodeRelPos: any\n\n element.addEventListener('dragstart', e => {\n // Push this to the end of the event cue\n // Fixes bug where incorrect drag pos is returned if drag handle has position: absolute\n // @ts-ignore\n dragHandler(e, editor)\n\n setTimeout(() => {\n if (element) {\n element.style.pointerEvents = 'none'\n }\n }, 0)\n })\n\n element.addEventListener('dragend', () => {\n if (element) {\n element.style.pointerEvents = 'auto'\n }\n })\n\n return new Plugin({\n key: typeof pluginKey === 'string' ? new PluginKey(pluginKey) : pluginKey,\n\n state: {\n init() {\n return { locked: false }\n },\n apply(\n tr: Transaction,\n value: PluginState,\n oldState: EditorState,\n state: EditorState,\n ) {\n const isLocked = tr.getMeta('lockDragHandle')\n const hideDragHandle = tr.getMeta('hideDragHandle')\n\n if (isLocked !== undefined) {\n locked = isLocked\n }\n\n if (hideDragHandle && popup) {\n popup.hide()\n\n locked = false\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n\n return value\n }\n\n // Something has changed and drag handler is visible…\n if (tr.docChanged && currentNodePos !== -1 && element && popup) {\n // Yjs replaces the entire document on every incoming change and needs a special handling.\n // If change comes from another user …\n if (isChangeOrigin(tr)) {\n // https://discuss.yjs.dev/t/y-prosemirror-mapping-a-single-relative-position-when-doc-changes/851/3\n const newPos = getAbsolutePos(state, currentNodeRelPos)\n\n if (newPos !== currentNodePos) {\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // We will get the outer node with data and position in views update method.\n }\n } else {\n // … otherwise use ProseMirror mapping to update the position.\n const newPos = tr.mapping.map(currentNodePos)\n\n if (newPos !== currentNodePos) {\n // TODO: Remove\n // console.log('Position has changed …', { old: currentNodePos, new: newPos }, tr);\n\n // Set the new position for our current node.\n currentNodePos = newPos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(state, currentNodePos)\n\n // We will get the outer node with data and position in views update method.\n }\n }\n }\n\n return value\n },\n },\n\n view: view => {\n element.draggable = true\n element.style.pointerEvents = 'auto'\n\n editor.view.dom.parentElement?.appendChild(wrapper)\n\n wrapper.appendChild(element)\n wrapper.style.pointerEvents = 'none'\n wrapper.style.position = 'absolute'\n wrapper.style.top = '0'\n wrapper.style.left = '0'\n\n return {\n update(_, oldState) {\n if (!element) {\n return\n }\n\n if (!editor.isEditable) {\n popup?.destroy()\n popup = null\n return\n }\n\n if (!popup) {\n popup = tippy(view.dom, {\n getReferenceClientRect: null,\n interactive: true,\n trigger: 'manual',\n placement: 'left-start',\n hideOnClick: false,\n duration: 100,\n popperOptions: {\n modifiers: [\n { name: 'flip', enabled: false },\n {\n name: 'preventOverflow',\n options: {\n rootBoundary: 'document',\n mainAxis: false,\n },\n },\n ],\n },\n ...tippyOptions,\n appendTo: wrapper,\n content: element,\n })\n }\n\n // Prevent element being draggend while being open.\n if (locked) {\n element.draggable = false\n } else {\n element.draggable = true\n }\n\n // Do not close on updates (e.g. changing padding of a section or collaboration events)\n // popup?.hide();\n\n // Recalculate popup position if doc has changend and drag handler is visible.\n if (view.state.doc.eq(oldState.doc) || currentNodePos === -1) {\n return\n }\n\n // Get domNode from (new) position.\n let domNode = view.nodeDOM(currentNodePos) as HTMLElement\n\n // Since old element could have been wrapped, we need to find\n // the outer node and take its position and node data.\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos) // TODO: needed?\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('View has updated: callback with new data and repositioning of popup …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Update Tippys getReferenceClientRect since domNode might have changed.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n },\n\n // TODO: Kills even on hot reload\n destroy() {\n popup?.destroy()\n\n if (element) {\n removeNode(wrapper)\n }\n },\n }\n },\n\n props: {\n handleDOMEvents: {\n keydown(view) {\n if (popup && popup.state.isVisible && view.hasFocus()) {\n popup.hide()\n return false\n }\n\n return false\n },\n\n mouseleave(_view, e) {\n // Do not hide open popup on mouseleave.\n if (locked) {\n return false\n }\n\n // If e.target is not inside the wrapper, hide.\n if (e.target && !wrapper.contains(e.relatedTarget as HTMLElement)) {\n popup?.hide()\n\n currentNode = null\n currentNodePos = -1\n\n onNodeChange?.({ editor, node: null, pos: -1 })\n }\n\n return false\n },\n\n mousemove(view, e) {\n // Do not continue if popup is not initialized or open.\n if (!element || !popup || locked) {\n return false\n }\n\n const nodeData = findElementNextToCoords({\n x: e.clientX,\n y: e.clientY,\n direction: 'right',\n editor,\n })\n\n // Skip if there is no node next to coords\n if (!nodeData.resultElement) {\n return false\n }\n\n let domNode = nodeData.resultElement as HTMLElement\n\n domNode = getOuterDomNode(view, domNode)\n\n // Skip if domNode is editor dom.\n if (domNode === view.dom) {\n return false\n }\n\n // We only want `Element`.\n if (domNode?.nodeType !== 1) {\n return false\n }\n\n const domNodePos = view.posAtDOM(domNode, 0)\n const outerNode = getOuterNode(editor.state.doc, domNodePos)\n\n if (outerNode !== currentNode) {\n const outerNodePos = getOuterNodePos(editor.state.doc, domNodePos)\n\n currentNode = outerNode\n currentNodePos = outerNodePos\n\n // Memorize relative position to retrieve absolute position in case of collaboration\n currentNodeRelPos = getRelativePos(view.state, currentNodePos)\n\n // TODO: Remove\n // console.log('Mousemove with changed node / node data …', {\n // domNode,\n // currentNodePos,\n // currentNode,\n // rect: (domNode as Element).getBoundingClientRect(),\n // });\n\n onNodeChange?.({ editor, node: currentNode, pos: currentNodePos })\n\n // Set nodes clientRect.\n popup.setProps({\n getReferenceClientRect: () => (domNode as Element).getBoundingClientRect(),\n })\n\n popup.show()\n }\n\n return false\n },\n },\n },\n })\n}\n","import { Editor, Extension } from '@tiptap/core'\nimport { Node } from '@tiptap/pm/model'\nimport { Props } from 'tippy.js'\n\nimport { DragHandlePlugin } from './drag-handle-plugin.js'\n\nexport interface DragHandleOptions {\n /**\n * Renders an element that is positioned with tippy.js\n */\n render (): HTMLElement,\n /**\n * Options for tippy.js\n */\n tippyOptions?: Partial<Props>,\n /**\n * Locks the draghandle in place and visibility\n */\n locked?: boolean,\n /**\n * Returns a node or null when a node is hovered over\n */\n onNodeChange?: (options: { node: Node | null, editor: Editor }) => void,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n dragHandle: {\n /**\n * Locks the draghandle in place and visibility\n */\n lockDragHandle: () => ReturnType,\n /**\n * Unlocks the draghandle\n */\n unlockDragHandle: () => ReturnType,\n /**\n * Toggle draghandle lock state\n */\n toggleDragHandle: () => ReturnType,\n }\n }\n}\n\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: 'dragHandle',\n\n addOptions() {\n return {\n render() {\n const element = document.createElement('div')\n\n element.classList.add('drag-handle')\n\n return element\n },\n tippyOptions: {},\n locked: false,\n onNodeChange: () => { return null },\n }\n },\n\n addCommands() {\n return {\n lockDragHandle: () => ({ editor }) => {\n this.options.locked = true\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n unlockDragHandle: () => ({ editor }) => {\n this.options.locked = false\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n toggleDragHandle: () => ({ editor }) => {\n this.options.locked = !this.options.locked\n return editor.commands.setMeta('lockDragHandle', this.options.locked)\n },\n }\n },\n\n addProseMirrorPlugins() {\n const element = this.options.render()\n\n return [\n DragHandlePlugin({\n tippyOptions: this.options.tippyOptions,\n element,\n editor: this.editor,\n onNodeChange: this.options.onNodeChange,\n }),\n ]\n },\n})\n"],"names":["getComputedStyle","getSelectionRanges","NodeRangeSelection","ySyncPluginKey","absolutePositionToRelativePosition","relativePositionToAbsolutePosition","PluginKey","Plugin","isChangeOrigin","Extension"],"mappings":";;;;;;EAAA,SAAS,UAAU,CAAC,OAAgB,EAAA;MAClC,IAAI,KAAK,GAAG,EAAE;EACd,IAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC;EAEvC,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;EACxC,QAAA,KAAK,IAAI,CAAG,EAAA,KAAK,CAAC,CAAC,CAAC,CAAI,CAAA,EAAA,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG;;EAG7D,IAAA,OAAO,KAAK;EACd;EAEM,SAAU,YAAY,CAAC,IAAiB,EAAA;MAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAgB;EACtD,IAAA,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAo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O;EACL,YAAA,gBAAgB,CAAC;EACf,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;kBACvC,OAAO;kBACP,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,gBAAA,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;eACxC,CAAC;WACH;OACF;EACF,CAAA;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-drag-handle",
|
|
3
3
|
"description": "drag handle extension for tiptap",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.26.1",
|
|
5
5
|
"homepage": "https://tiptap.dev/docs/editor/extensions/functionality/drag-handle",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"tippy.js": "^6.3.7"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tiptap/extension-node-range": "^2.
|
|
48
|
-
"@tiptap/core": "^2.
|
|
49
|
-
"@tiptap/extension-collaboration": "^2.
|
|
50
|
-
"@tiptap/pm": "^2.
|
|
47
|
+
"@tiptap/extension-node-range": "^2.26.1",
|
|
48
|
+
"@tiptap/core": "^2.26.1",
|
|
49
|
+
"@tiptap/extension-collaboration": "^2.26.1",
|
|
50
|
+
"@tiptap/pm": "^2.26.1",
|
|
51
51
|
"tippy.js": "^6.3.7",
|
|
52
52
|
"y-prosemirror": "^1.2.12"
|
|
53
53
|
},
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Editor } from '@tiptap/core'
|
|
1
|
+
import type { Editor } from '@tiptap/core'
|
|
2
2
|
import { isChangeOrigin } from '@tiptap/extension-collaboration'
|
|
3
|
-
import { Node } from '@tiptap/pm/model'
|
|
3
|
+
import type { Node } from '@tiptap/pm/model'
|
|
4
|
+
import type { EditorState, Transaction } from '@tiptap/pm/state'
|
|
5
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state'
|
|
6
|
+
import type { EditorView } from '@tiptap/pm/view'
|
|
7
|
+
import type { Instance, Props as TippyProps } from 'tippy.js'
|
|
8
|
+
import tippy from 'tippy.js'
|
|
4
9
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import tippy, { Instance, Props as TippyProps } from 'tippy.js'
|
|
10
|
-
import { absolutePositionToRelativePosition, relativePositionToAbsolutePosition, ySyncPluginKey } from 'y-prosemirror'
|
|
10
|
+
absolutePositionToRelativePosition,
|
|
11
|
+
relativePositionToAbsolutePosition,
|
|
12
|
+
ySyncPluginKey,
|
|
13
|
+
} from 'y-prosemirror'
|
|
11
14
|
|
|
12
15
|
import { dragHandler } from './helpers/dragHandler.js'
|
|
13
16
|
import { findElementNextToCoords } from './helpers/findNextElementFromCursor.js'
|
|
@@ -15,8 +18,8 @@ import { getOuterNode, getOuterNodePos } from './helpers/getOuterNode.js'
|
|
|
15
18
|
import { removeNode } from './helpers/removeNode.js'
|
|
16
19
|
|
|
17
20
|
type PluginState = {
|
|
18
|
-
locked: boolean
|
|
19
|
-
}
|
|
21
|
+
locked: boolean
|
|
22
|
+
}
|
|
20
23
|
|
|
21
24
|
const getRelativePos = (state: EditorState, absolutePos: number) => {
|
|
22
25
|
const ystate = ySyncPluginKey.getState(state)
|
|
@@ -25,7 +28,11 @@ const getRelativePos = (state: EditorState, absolutePos: number) => {
|
|
|
25
28
|
return null
|
|
26
29
|
}
|
|
27
30
|
|
|
28
|
-
return absolutePositionToRelativePosition(
|
|
31
|
+
return absolutePositionToRelativePosition(
|
|
32
|
+
absolutePos,
|
|
33
|
+
ystate.type,
|
|
34
|
+
ystate.binding.mapping,
|
|
35
|
+
)
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
const getAbsolutePos = (state: EditorState, relativePos: any) => {
|
|
@@ -35,7 +42,14 @@ const getAbsolutePos = (state: EditorState, relativePos: any) => {
|
|
|
35
42
|
return -1
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
return
|
|
45
|
+
return (
|
|
46
|
+
relativePositionToAbsolutePosition(
|
|
47
|
+
ystate.doc,
|
|
48
|
+
ystate.type,
|
|
49
|
+
relativePos,
|
|
50
|
+
ystate.binding.mapping,
|
|
51
|
+
) || 0
|
|
52
|
+
)
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
const getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {
|
|
@@ -54,11 +68,15 @@ const getOuterDomNode = (view: EditorView, domNode: HTMLElement) => {
|
|
|
54
68
|
}
|
|
55
69
|
|
|
56
70
|
export interface DragHandlePluginProps {
|
|
57
|
-
pluginKey?: PluginKey | string
|
|
58
|
-
editor: Editor
|
|
59
|
-
element: HTMLElement
|
|
60
|
-
onNodeChange?: (data: {
|
|
61
|
-
|
|
71
|
+
pluginKey?: PluginKey | string
|
|
72
|
+
editor: Editor
|
|
73
|
+
element: HTMLElement
|
|
74
|
+
onNodeChange?: (data: {
|
|
75
|
+
editor: Editor
|
|
76
|
+
node: Node | null
|
|
77
|
+
pos: number
|
|
78
|
+
}) => void
|
|
79
|
+
tippyOptions?: Partial<TippyProps>
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
export const dragHandlePluginDefaultKey = new PluginKey('dragHandle')
|
|
@@ -103,7 +121,12 @@ export const DragHandlePlugin = ({
|
|
|
103
121
|
init() {
|
|
104
122
|
return { locked: false }
|
|
105
123
|
},
|
|
106
|
-
apply(
|
|
124
|
+
apply(
|
|
125
|
+
tr: Transaction,
|
|
126
|
+
value: PluginState,
|
|
127
|
+
oldState: EditorState,
|
|
128
|
+
state: EditorState,
|
|
129
|
+
) {
|
|
107
130
|
const isLocked = tr.getMeta('lockDragHandle')
|
|
108
131
|
const hideDragHandle = tr.getMeta('hideDragHandle')
|
|
109
132
|
|
|
@@ -281,6 +304,15 @@ export const DragHandlePlugin = ({
|
|
|
281
304
|
|
|
282
305
|
props: {
|
|
283
306
|
handleDOMEvents: {
|
|
307
|
+
keydown(view) {
|
|
308
|
+
if (popup && popup.state.isVisible && view.hasFocus()) {
|
|
309
|
+
popup.hide()
|
|
310
|
+
return false
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return false
|
|
314
|
+
},
|
|
315
|
+
|
|
284
316
|
mouseleave(_view, e) {
|
|
285
317
|
// Do not hide open popup on mouseleave.
|
|
286
318
|
if (locked) {
|