@tiptap/extension-drag-handle 2.22.0

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.
Files changed (41) hide show
  1. package/README.md +14 -0
  2. package/dist/drag-handle-plugin.d.ts +20 -0
  3. package/dist/drag-handle-plugin.d.ts.map +1 -0
  4. package/dist/drag-handle.d.ts +44 -0
  5. package/dist/drag-handle.d.ts.map +1 -0
  6. package/dist/helpers/cloneElement.d.ts +2 -0
  7. package/dist/helpers/cloneElement.d.ts.map +1 -0
  8. package/dist/helpers/dragHandler.d.ts +3 -0
  9. package/dist/helpers/dragHandler.d.ts.map +1 -0
  10. package/dist/helpers/findNextElementFromCursor.d.ts +14 -0
  11. package/dist/helpers/findNextElementFromCursor.d.ts.map +1 -0
  12. package/dist/helpers/getComputedStyle.d.ts +2 -0
  13. package/dist/helpers/getComputedStyle.d.ts.map +1 -0
  14. package/dist/helpers/getInnerCoords.d.ts +6 -0
  15. package/dist/helpers/getInnerCoords.d.ts.map +1 -0
  16. package/dist/helpers/getOuterNode.d.ts +4 -0
  17. package/dist/helpers/getOuterNode.d.ts.map +1 -0
  18. package/dist/helpers/minMax.d.ts +2 -0
  19. package/dist/helpers/minMax.d.ts.map +1 -0
  20. package/dist/helpers/removeNode.d.ts +2 -0
  21. package/dist/helpers/removeNode.d.ts.map +1 -0
  22. package/dist/index.cjs +504 -0
  23. package/dist/index.cjs.map +1 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +493 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/index.umd.js +499 -0
  29. package/dist/index.umd.js.map +1 -0
  30. package/package.json +58 -0
  31. package/src/drag-handle-plugin.ts +370 -0
  32. package/src/drag-handle.ts +92 -0
  33. package/src/helpers/cloneElement.ts +22 -0
  34. package/src/helpers/dragHandler.ts +102 -0
  35. package/src/helpers/findNextElementFromCursor.ts +55 -0
  36. package/src/helpers/getComputedStyle.ts +5 -0
  37. package/src/helpers/getInnerCoords.ts +22 -0
  38. package/src/helpers/getOuterNode.ts +34 -0
  39. package/src/helpers/minMax.ts +3 -0
  40. package/src/helpers/removeNode.ts +3 -0
  41. package/src/index.ts +6 -0
package/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # @tiptap/extension-drag-handle
2
+ [![Version](https://img.shields.io/npm/v/@tiptap/extension-drag-handle.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-drag-handle)
3
+ [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-drag-handle.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
+ [![License](https://img.shields.io/npm/l/@tiptap/extension-drag-handle.svg)](https://www.npmjs.com/package/@tiptap/extension-drag-handle)
5
+ [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
+
7
+ ## Introduction
8
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ ## Official Documentation
11
+ Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
+
13
+ ## License
14
+ Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
@@ -0,0 +1,20 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { Node } from '@tiptap/pm/model';
3
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
4
+ import { Props as TippyProps } from 'tippy.js';
5
+ export interface DragHandlePluginProps {
6
+ pluginKey?: PluginKey | string;
7
+ editor: Editor;
8
+ element: HTMLElement;
9
+ onNodeChange?: (data: {
10
+ editor: Editor;
11
+ node: Node | null;
12
+ pos: number;
13
+ }) => void;
14
+ tippyOptions?: Partial<TippyProps>;
15
+ }
16
+ export declare const dragHandlePluginDefaultKey: PluginKey<any>;
17
+ export declare const DragHandlePlugin: ({ pluginKey, element, editor, tippyOptions, onNodeChange, }: DragHandlePluginProps) => Plugin<{
18
+ locked: boolean;
19
+ }>;
20
+ //# sourceMappingURL=drag-handle-plugin.d.ts.map
@@ -0,0 +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;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EACQ,MAAM,EAAE,SAAS,EAE/B,MAAM,kBAAkB,CAAA;AAEzB,OAAc,EAAY,KAAK,IAAI,UAAU,EAAE,MAAM,UAAU,CAAA;AA+C/D,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,0BAA0B,gBAA8B,CAAA;AAErE,eAAO,MAAM,gBAAgB,gEAM1B,qBAAqB;;EA0SvB,CAAA"}
@@ -0,0 +1,44 @@
1
+ import { Editor, Extension } from '@tiptap/core';
2
+ import { Node } from '@tiptap/pm/model';
3
+ import { Props } from 'tippy.js';
4
+ export interface DragHandleOptions {
5
+ /**
6
+ * Renders an element that is positioned with tippy.js
7
+ */
8
+ render(): HTMLElement;
9
+ /**
10
+ * Options for tippy.js
11
+ */
12
+ tippyOptions?: Partial<Props>;
13
+ /**
14
+ * Locks the draghandle in place and visibility
15
+ */
16
+ locked?: boolean;
17
+ /**
18
+ * Returns a node or null when a node is hovered over
19
+ */
20
+ onNodeChange?: (options: {
21
+ node: Node | null;
22
+ editor: Editor;
23
+ }) => void;
24
+ }
25
+ declare module '@tiptap/core' {
26
+ interface Commands<ReturnType> {
27
+ dragHandle: {
28
+ /**
29
+ * Locks the draghandle in place and visibility
30
+ */
31
+ lockDragHandle: () => ReturnType;
32
+ /**
33
+ * Unlocks the draghandle
34
+ */
35
+ unlockDragHandle: () => ReturnType;
36
+ /**
37
+ * Toggle draghandle lock state
38
+ */
39
+ toggleDragHandle: () => ReturnType;
40
+ };
41
+ }
42
+ }
43
+ export declare const DragHandle: Extension<DragHandleOptions, any>;
44
+ //# sourceMappingURL=drag-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-handle.d.ts","sourceRoot":"","sources":["../src/drag-handle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAIhC,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,IAAK,WAAW,CAAC;IACvB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACzE;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV;;eAEG;YACH,cAAc,EAAE,MAAM,UAAU,CAAC;YACjC;;eAEG;YACH,gBAAgB,EAAE,MAAM,UAAU,CAAC;YACnC;;eAEG;YACH,gBAAgB,EAAE,MAAM,UAAU,CAAC;SACpC,CAAA;KACF;CACF;AAED,eAAO,MAAM,UAAU,mCA+CrB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function cloneElement(node: HTMLElement): HTMLElement;
2
+ //# sourceMappingURL=cloneElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloneElement.d.ts","sourceRoot":"","sources":["../../src/helpers/cloneElement.ts"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,eAU7C"}
@@ -0,0 +1,3 @@
1
+ import { Editor } from '@tiptap/core';
2
+ export declare function dragHandler(event: DragEvent, editor: Editor): void;
3
+ //# sourceMappingURL=dragHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dragHandler.d.ts","sourceRoot":"","sources":["../../src/helpers/dragHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AA2CrC,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QA0D3D"}
@@ -0,0 +1,14 @@
1
+ import { Editor } from '@tiptap/core';
2
+ import { Node } from '@tiptap/pm/model';
3
+ export type FindElementNextToCoords = {
4
+ x: number;
5
+ y: number;
6
+ direction?: 'left' | 'right';
7
+ editor: Editor;
8
+ };
9
+ export declare const findElementNextToCoords: (options: FindElementNextToCoords) => {
10
+ resultElement: HTMLElement | null;
11
+ resultNode: Node | null;
12
+ pos: number | null;
13
+ };
14
+ //# sourceMappingURL=findNextElementFromCursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"findNextElementFromCursor.d.ts","sourceRoot":"","sources":["../../src/helpers/findNextElementFromCursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,uBAAuB,YAAa,uBAAuB;;;;CA4CvE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function getComputedStyle(node: Element, property: keyof CSSStyleDeclaration): any;
2
+ //# sourceMappingURL=getComputedStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getComputedStyle.d.ts","sourceRoot":"","sources":["../../src/helpers/getComputedStyle.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,GAAG,GAAG,CAIxF"}
@@ -0,0 +1,6 @@
1
+ import { EditorView } from '@tiptap/pm/view';
2
+ export declare function getInnerCoords(view: EditorView, x: number, y: number): {
3
+ left: number;
4
+ top: number;
5
+ };
6
+ //# sourceMappingURL=getInnerCoords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInnerCoords.d.ts","sourceRoot":"","sources":["../../src/helpers/getInnerCoords.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAK5C,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAgBpG"}
@@ -0,0 +1,4 @@
1
+ import { Node } from '@tiptap/pm/model';
2
+ export declare const getOuterNodePos: (doc: Node, pos: number) => number;
3
+ export declare const getOuterNode: (doc: Node, pos: number) => Node | null;
4
+ //# sourceMappingURL=getOuterNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getOuterNode.d.ts","sourceRoot":"","sources":["../../src/helpers/getOuterNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,eAAO,MAAM,eAAe,QAAS,IAAI,OAAO,MAAM,KAAG,MAWxD,CAAA;AAED,eAAO,MAAM,YAAY,QAAS,IAAI,OAAO,MAAM,KAAG,IAAI,GAAG,IAkB5D,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function minMax(value?: number, min?: number, max?: number): number;
2
+ //# sourceMappingURL=minMax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"minMax.d.ts","sourceRoot":"","sources":["../../src/helpers/minMax.ts"],"names":[],"mappings":"AAAA,wBAAgB,MAAM,CAAC,KAAK,SAAI,EAAE,GAAG,SAAI,EAAE,GAAG,SAAI,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,2 @@
1
+ export declare function removeNode(node: HTMLElement): void;
2
+ //# sourceMappingURL=removeNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"removeNode.d.ts","sourceRoot":"","sources":["../../src/helpers/removeNode.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,QAE3C"}