@tiptap/extension-drag-handle-react 2.24.1 → 3.0.0-beta.10
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/LICENSE.md +21 -0
- package/dist/index.cjs +80 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -4
- package/dist/index.js +59 -36
- package/dist/index.js.map +1 -1
- package/package.json +16 -14
- package/src/DragHandle.tsx +26 -25
- package/dist/DragHandle.d.ts +0 -24
- package/dist/DragHandle.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -46
- package/dist/index.umd.js.map +0 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Tiptap GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
CHANGED
|
@@ -1,47 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
DragHandle: () => DragHandle,
|
|
24
|
+
default: () => index_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
11
27
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
// src/DragHandle.tsx
|
|
29
|
+
var import_extension_drag_handle = require("@tiptap/extension-drag-handle");
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
var DragHandle = (props) => {
|
|
33
|
+
const {
|
|
34
|
+
className = "drag-handle",
|
|
35
|
+
children,
|
|
36
|
+
editor,
|
|
37
|
+
pluginKey = import_extension_drag_handle.dragHandlePluginDefaultKey,
|
|
38
|
+
onNodeChange,
|
|
39
|
+
computePositionConfig = import_extension_drag_handle.defaultComputePositionConfig
|
|
40
|
+
} = props;
|
|
41
|
+
const [element, setElement] = (0, import_react.useState)(null);
|
|
42
|
+
const plugin = (0, import_react.useRef)(null);
|
|
43
|
+
(0, import_react.useEffect)(() => {
|
|
44
|
+
let initPlugin = null;
|
|
45
|
+
if (!element) {
|
|
46
|
+
return () => {
|
|
47
|
+
plugin.current = null;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (editor.isDestroyed) {
|
|
51
|
+
return () => {
|
|
52
|
+
plugin.current = null;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (!plugin.current) {
|
|
56
|
+
initPlugin = (0, import_extension_drag_handle.DragHandlePlugin)({
|
|
57
|
+
editor,
|
|
58
|
+
element,
|
|
59
|
+
pluginKey,
|
|
60
|
+
computePositionConfig: { ...import_extension_drag_handle.defaultComputePositionConfig, ...computePositionConfig },
|
|
61
|
+
onNodeChange
|
|
62
|
+
});
|
|
63
|
+
plugin.current = initPlugin.plugin;
|
|
64
|
+
editor.registerPlugin(plugin.current);
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
editor.unregisterPlugin(pluginKey);
|
|
68
|
+
plugin.current = null;
|
|
69
|
+
if (initPlugin) {
|
|
70
|
+
initPlugin.unbind();
|
|
71
|
+
initPlugin = null;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}, [element, editor, onNodeChange, pluginKey, computePositionConfig]);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style: { visibility: "hidden", position: "absolute" }, ref: setElement, children });
|
|
43
76
|
};
|
|
44
77
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
78
|
+
// src/index.ts
|
|
79
|
+
var index_default = DragHandle;
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
DragHandle
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/DragHandle.tsx"],"sourcesContent":["import { DragHandle } from './DragHandle.js'\n\nexport * from './DragHandle.js'\n\nexport default DragHandle\n","import {\n type DragHandlePluginProps,\n defaultComputePositionConfig,\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n} from '@tiptap/extension-drag-handle'\nimport type { Node } from '@tiptap/pm/model'\nimport type { Plugin } from '@tiptap/pm/state'\nimport type { Editor } from '@tiptap/react'\nimport { type ReactNode, useEffect, useRef, useState } from 'react'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {\n className?: string\n onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void\n children: ReactNode\n}\n\nexport const DragHandle = (props: DragHandleProps) => {\n const {\n className = 'drag-handle',\n children,\n editor,\n pluginKey = dragHandlePluginDefaultKey,\n onNodeChange,\n computePositionConfig = defaultComputePositionConfig,\n } = props\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const plugin = useRef<Plugin | null>(null)\n\n useEffect(() => {\n let initPlugin: {\n plugin: Plugin\n unbind: () => void\n } | null = null\n\n if (!element) {\n return () => {\n plugin.current = null\n }\n }\n\n if (editor.isDestroyed) {\n return () => {\n plugin.current = null\n }\n }\n\n if (!plugin.current) {\n initPlugin = DragHandlePlugin({\n editor,\n element,\n pluginKey,\n computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },\n onNodeChange,\n })\n plugin.current = initPlugin.plugin\n\n editor.registerPlugin(plugin.current)\n }\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n plugin.current = null\n if (initPlugin) {\n initPlugin.unbind()\n initPlugin = null\n }\n }\n }, [element, editor, onNodeChange, pluginKey, computePositionConfig])\n\n return (\n <div className={className} style={{ visibility: 'hidden', position: 'absolute' }} ref={setElement}>\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mCAKO;AAIP,mBAA4D;AAgExD;AAtDG,IAAM,aAAa,CAAC,UAA2B;AACpD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,wBAAwB;AAAA,EAC1B,IAAI;AACJ,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAgC,IAAI;AAClE,QAAM,aAAS,qBAAsB,IAAI;AAEzC,8BAAU,MAAM;AACd,QAAI,aAGO;AAEX,QAAI,CAAC,SAAS;AACZ,aAAO,MAAM;AACX,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,aAAa;AACtB,aAAO,MAAM;AACX,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,CAAC,OAAO,SAAS;AACnB,uBAAa,+CAAiB;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA,uBAAuB,EAAE,GAAG,2DAA8B,GAAG,sBAAsB;AAAA,QACnF;AAAA,MACF,CAAC;AACD,aAAO,UAAU,WAAW;AAE5B,aAAO,eAAe,OAAO,OAAO;AAAA,IACtC;AAEA,WAAO,MAAM;AACX,aAAO,iBAAiB,SAAS;AACjC,aAAO,UAAU;AACjB,UAAI,YAAY;AACd,mBAAW,OAAO;AAClB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,QAAQ,cAAc,WAAW,qBAAqB,CAAC;AAEpE,SACE,4CAAC,SAAI,WAAsB,OAAO,EAAE,YAAY,UAAU,UAAU,WAAW,GAAG,KAAK,YACpF,UACH;AAEJ;;;ADzEA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DragHandlePluginProps } from '@tiptap/extension-drag-handle';
|
|
3
|
+
import { Node } from '@tiptap/pm/model';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
8
|
+
type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
9
|
+
className?: string;
|
|
10
|
+
onNodeChange?: (data: {
|
|
11
|
+
node: Node | null;
|
|
12
|
+
editor: Editor;
|
|
13
|
+
pos: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
declare const DragHandle: (props: DragHandleProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { DragHandle, type DragHandleProps, DragHandle as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { DragHandlePluginProps } from '@tiptap/extension-drag-handle';
|
|
3
|
+
import { Node } from '@tiptap/pm/model';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
8
|
+
type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
9
|
+
className?: string;
|
|
10
|
+
onNodeChange?: (data: {
|
|
11
|
+
node: Node | null;
|
|
12
|
+
editor: Editor;
|
|
13
|
+
pos: number;
|
|
14
|
+
}) => void;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
declare const DragHandle: (props: DragHandleProps) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { DragHandle, type DragHandleProps, DragHandle as default };
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
// src/DragHandle.tsx
|
|
2
|
+
import {
|
|
3
|
+
defaultComputePositionConfig,
|
|
4
|
+
DragHandlePlugin,
|
|
5
|
+
dragHandlePluginDefaultKey
|
|
6
|
+
} from "@tiptap/extension-drag-handle";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var DragHandle = (props) => {
|
|
10
|
+
const {
|
|
11
|
+
className = "drag-handle",
|
|
12
|
+
children,
|
|
13
|
+
editor,
|
|
14
|
+
pluginKey = dragHandlePluginDefaultKey,
|
|
15
|
+
onNodeChange,
|
|
16
|
+
computePositionConfig = defaultComputePositionConfig
|
|
17
|
+
} = props;
|
|
18
|
+
const [element, setElement] = useState(null);
|
|
19
|
+
const plugin = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let initPlugin = null;
|
|
22
|
+
if (!element) {
|
|
23
|
+
return () => {
|
|
24
|
+
plugin.current = null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (editor.isDestroyed) {
|
|
28
|
+
return () => {
|
|
29
|
+
plugin.current = null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (!plugin.current) {
|
|
33
|
+
initPlugin = DragHandlePlugin({
|
|
34
|
+
editor,
|
|
35
|
+
element,
|
|
36
|
+
pluginKey,
|
|
37
|
+
computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
|
|
38
|
+
onNodeChange
|
|
39
|
+
});
|
|
40
|
+
plugin.current = initPlugin.plugin;
|
|
41
|
+
editor.registerPlugin(plugin.current);
|
|
42
|
+
}
|
|
43
|
+
return () => {
|
|
44
|
+
editor.unregisterPlugin(pluginKey);
|
|
45
|
+
plugin.current = null;
|
|
46
|
+
if (initPlugin) {
|
|
47
|
+
initPlugin.unbind();
|
|
48
|
+
initPlugin = null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, [element, editor, onNodeChange, pluginKey, computePositionConfig]);
|
|
52
|
+
return /* @__PURE__ */ jsx("div", { className, style: { visibility: "hidden", position: "absolute" }, ref: setElement, children });
|
|
35
53
|
};
|
|
36
54
|
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
// src/index.ts
|
|
56
|
+
var index_default = DragHandle;
|
|
57
|
+
export {
|
|
58
|
+
DragHandle,
|
|
59
|
+
index_default as default
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/DragHandle.tsx","../src/index.ts"],"sourcesContent":["import {\n type DragHandlePluginProps,\n defaultComputePositionConfig,\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n} from '@tiptap/extension-drag-handle'\nimport type { Node } from '@tiptap/pm/model'\nimport type { Plugin } from '@tiptap/pm/state'\nimport type { Editor } from '@tiptap/react'\nimport { type ReactNode, useEffect, useRef, useState } from 'react'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {\n className?: string\n onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void\n children: ReactNode\n}\n\nexport const DragHandle = (props: DragHandleProps) => {\n const {\n className = 'drag-handle',\n children,\n editor,\n pluginKey = dragHandlePluginDefaultKey,\n onNodeChange,\n computePositionConfig = defaultComputePositionConfig,\n } = props\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const plugin = useRef<Plugin | null>(null)\n\n useEffect(() => {\n let initPlugin: {\n plugin: Plugin\n unbind: () => void\n } | null = null\n\n if (!element) {\n return () => {\n plugin.current = null\n }\n }\n\n if (editor.isDestroyed) {\n return () => {\n plugin.current = null\n }\n }\n\n if (!plugin.current) {\n initPlugin = DragHandlePlugin({\n editor,\n element,\n pluginKey,\n computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },\n onNodeChange,\n })\n plugin.current = initPlugin.plugin\n\n editor.registerPlugin(plugin.current)\n }\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n plugin.current = null\n if (initPlugin) {\n initPlugin.unbind()\n initPlugin = null\n }\n }\n }, [element, editor, onNodeChange, pluginKey, computePositionConfig])\n\n return (\n <div className={className} style={{ visibility: 'hidden', position: 'absolute' }} ref={setElement}>\n {children}\n </div>\n )\n}\n","import { DragHandle } from './DragHandle.js'\n\nexport * from './DragHandle.js'\n\nexport default DragHandle\n"],"mappings":";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAyB,WAAW,QAAQ,gBAAgB;AAgExD;AAtDG,IAAM,aAAa,CAAC,UAA2B;AACpD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ;AAAA,IACA,wBAAwB;AAAA,EAC1B,IAAI;AACJ,QAAM,CAAC,SAAS,UAAU,IAAI,SAAgC,IAAI;AAClE,QAAM,SAAS,OAAsB,IAAI;AAEzC,YAAU,MAAM;AACd,QAAI,aAGO;AAEX,QAAI,CAAC,SAAS;AACZ,aAAO,MAAM;AACX,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,aAAa;AACtB,aAAO,MAAM;AACX,eAAO,UAAU;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,CAAC,OAAO,SAAS;AACnB,mBAAa,iBAAiB;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA,uBAAuB,EAAE,GAAG,8BAA8B,GAAG,sBAAsB;AAAA,QACnF;AAAA,MACF,CAAC;AACD,aAAO,UAAU,WAAW;AAE5B,aAAO,eAAe,OAAO,OAAO;AAAA,IACtC;AAEA,WAAO,MAAM;AACX,aAAO,iBAAiB,SAAS;AACjC,aAAO,UAAU;AACjB,UAAI,YAAY;AACd,mBAAW,OAAO;AAClB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF,GAAG,CAAC,SAAS,QAAQ,cAAc,WAAW,qBAAqB,CAAC;AAEpE,SACE,oBAAC,SAAI,WAAsB,OAAO,EAAE,YAAY,UAAU,UAAU,WAAW,GAAG,KAAK,YACpF,UACH;AAEJ;;;ACzEA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-drag-handle-react",
|
|
3
3
|
"description": "drag handle extension for tiptap with react",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-beta.10",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -20,37 +20,39 @@
|
|
|
20
20
|
"type": "module",
|
|
21
21
|
"exports": {
|
|
22
22
|
".": {
|
|
23
|
-
"types":
|
|
23
|
+
"types": {
|
|
24
|
+
"import": "./dist/index.d.ts",
|
|
25
|
+
"require": "./dist/index.d.cts"
|
|
26
|
+
},
|
|
24
27
|
"import": "./dist/index.js",
|
|
25
28
|
"require": "./dist/index.cjs"
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
"main": "dist/index.cjs",
|
|
29
32
|
"module": "dist/index.js",
|
|
30
|
-
"umd": "dist/index.umd.js",
|
|
31
33
|
"types": "dist/index.d.ts",
|
|
32
34
|
"files": [
|
|
33
35
|
"src",
|
|
34
36
|
"dist"
|
|
35
37
|
],
|
|
36
38
|
"peerDependencies": {
|
|
37
|
-
"@tiptap/extension-drag-handle": "^2.14.0",
|
|
38
|
-
"@tiptap/pm": "^2.7.0",
|
|
39
|
-
"@tiptap/react": "^2.7.0",
|
|
40
39
|
"react": "^16.8 || ^17 || ^18 || ^19",
|
|
41
|
-
"react-dom": "^16.8 || ^17 || ^18 || ^19"
|
|
40
|
+
"react-dom": "^16.8 || ^17 || ^18 || ^19",
|
|
41
|
+
"@tiptap/extension-drag-handle": "3.0.0-beta.10",
|
|
42
|
+
"@tiptap/pm": "3.0.0-beta.10",
|
|
43
|
+
"@tiptap/react": "3.0.0-beta.10"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
|
-
"@tiptap/extension-drag-handle": "^2.24.1",
|
|
45
|
-
"@tiptap/pm": "^2.24.1",
|
|
46
|
-
"@tiptap/react": "^2.24.1",
|
|
47
46
|
"@types/react": "^18.0.0",
|
|
48
47
|
"@types/react-dom": "^18.0.0",
|
|
49
48
|
"react": "^18.0.0",
|
|
50
|
-
"react-dom": "^18.0.0"
|
|
49
|
+
"react-dom": "^18.0.0",
|
|
50
|
+
"@tiptap/extension-drag-handle": "3.0.0-beta.10",
|
|
51
|
+
"@tiptap/pm": "3.0.0-beta.10",
|
|
52
|
+
"@tiptap/react": "3.0.0-beta.10"
|
|
51
53
|
},
|
|
52
54
|
"scripts": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
|
|
55
57
|
}
|
|
56
|
-
}
|
|
58
|
+
}
|
package/src/DragHandle.tsx
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type DragHandlePluginProps,
|
|
3
|
+
defaultComputePositionConfig,
|
|
2
4
|
DragHandlePlugin,
|
|
3
5
|
dragHandlePluginDefaultKey,
|
|
4
|
-
DragHandlePluginProps,
|
|
5
6
|
} from '@tiptap/extension-drag-handle'
|
|
6
|
-
import { Node } from '@tiptap/pm/model'
|
|
7
|
-
import { Plugin } from '@tiptap/pm/state'
|
|
8
|
-
import { Editor } from '@tiptap/react'
|
|
9
|
-
import
|
|
10
|
-
ReactNode, useEffect, useRef, useState,
|
|
11
|
-
} from 'react'
|
|
7
|
+
import type { Node } from '@tiptap/pm/model'
|
|
8
|
+
import type { Plugin } from '@tiptap/pm/state'
|
|
9
|
+
import type { Editor } from '@tiptap/react'
|
|
10
|
+
import { type ReactNode, useEffect, useRef, useState } from 'react'
|
|
12
11
|
|
|
13
|
-
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K
|
|
12
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
|
|
14
13
|
|
|
15
14
|
export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
16
|
-
className?: string
|
|
17
|
-
onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void
|
|
18
|
-
children: ReactNode
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Tippy.js options for the drag handle tooltip.
|
|
22
|
-
*
|
|
23
|
-
* **IMPORTANT**: Make sure to memoize this object - otherwise the object
|
|
24
|
-
* will cause the drag handle to be re-initialized on every render breaking it.
|
|
25
|
-
*/
|
|
26
|
-
tippyOptions?: DragHandlePluginProps['tippyOptions'];
|
|
27
|
-
};
|
|
15
|
+
className?: string
|
|
16
|
+
onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void
|
|
17
|
+
children: ReactNode
|
|
18
|
+
}
|
|
28
19
|
|
|
29
20
|
export const DragHandle = (props: DragHandleProps) => {
|
|
30
21
|
const {
|
|
@@ -33,12 +24,17 @@ export const DragHandle = (props: DragHandleProps) => {
|
|
|
33
24
|
editor,
|
|
34
25
|
pluginKey = dragHandlePluginDefaultKey,
|
|
35
26
|
onNodeChange,
|
|
36
|
-
|
|
27
|
+
computePositionConfig = defaultComputePositionConfig,
|
|
37
28
|
} = props
|
|
38
29
|
const [element, setElement] = useState<HTMLDivElement | null>(null)
|
|
39
30
|
const plugin = useRef<Plugin | null>(null)
|
|
40
31
|
|
|
41
32
|
useEffect(() => {
|
|
33
|
+
let initPlugin: {
|
|
34
|
+
plugin: Plugin
|
|
35
|
+
unbind: () => void
|
|
36
|
+
} | null = null
|
|
37
|
+
|
|
42
38
|
if (!element) {
|
|
43
39
|
return () => {
|
|
44
40
|
plugin.current = null
|
|
@@ -52,13 +48,14 @@ export const DragHandle = (props: DragHandleProps) => {
|
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
if (!plugin.current) {
|
|
55
|
-
|
|
51
|
+
initPlugin = DragHandlePlugin({
|
|
56
52
|
editor,
|
|
57
53
|
element,
|
|
58
54
|
pluginKey,
|
|
59
|
-
|
|
55
|
+
computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
|
|
60
56
|
onNodeChange,
|
|
61
57
|
})
|
|
58
|
+
plugin.current = initPlugin.plugin
|
|
62
59
|
|
|
63
60
|
editor.registerPlugin(plugin.current)
|
|
64
61
|
}
|
|
@@ -66,11 +63,15 @@ export const DragHandle = (props: DragHandleProps) => {
|
|
|
66
63
|
return () => {
|
|
67
64
|
editor.unregisterPlugin(pluginKey)
|
|
68
65
|
plugin.current = null
|
|
66
|
+
if (initPlugin) {
|
|
67
|
+
initPlugin.unbind()
|
|
68
|
+
initPlugin = null
|
|
69
|
+
}
|
|
69
70
|
}
|
|
70
|
-
}, [element, editor, onNodeChange, pluginKey,
|
|
71
|
+
}, [element, editor, onNodeChange, pluginKey, computePositionConfig])
|
|
71
72
|
|
|
72
73
|
return (
|
|
73
|
-
<div className={className} ref={setElement}>
|
|
74
|
+
<div className={className} style={{ visibility: 'hidden', position: 'absolute' }} ref={setElement}>
|
|
74
75
|
{children}
|
|
75
76
|
</div>
|
|
76
77
|
)
|
package/dist/DragHandle.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { DragHandlePluginProps } from '@tiptap/extension-drag-handle';
|
|
2
|
-
import { Node } from '@tiptap/pm/model';
|
|
3
|
-
import { Editor } from '@tiptap/react';
|
|
4
|
-
import React, { ReactNode } from 'react';
|
|
5
|
-
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
6
|
-
export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
7
|
-
className?: string;
|
|
8
|
-
onNodeChange?: (data: {
|
|
9
|
-
node: Node | null;
|
|
10
|
-
editor: Editor;
|
|
11
|
-
pos: number;
|
|
12
|
-
}) => void;
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
/**
|
|
15
|
-
* Tippy.js options for the drag handle tooltip.
|
|
16
|
-
*
|
|
17
|
-
* **IMPORTANT**: Make sure to memoize this object - otherwise the object
|
|
18
|
-
* will cause the drag handle to be re-initialized on every render breaking it.
|
|
19
|
-
*/
|
|
20
|
-
tippyOptions?: DragHandlePluginProps['tippyOptions'];
|
|
21
|
-
};
|
|
22
|
-
export declare const DragHandle: (props: DragHandleProps) => React.JSX.Element;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=DragHandle.d.ts.map
|
package/dist/DragHandle.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DragHandle.d.ts","sourceRoot":"","sources":["../src/DragHandle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,qBAAqB,EACtB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,EAAE,EACZ,SAAS,EACV,MAAM,OAAO,CAAA;AAEd,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,qBAAqB,EAAE,WAAW,CAAC,EAAE,SAAS,CAAC,GAAG;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAClF,QAAQ,EAAE,SAAS,CAAC;IAEpB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,qBAAqB,CAAC,cAAc,CAAC,CAAC;CACtD,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,eAAe,sBAgDhD,CAAA"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,cAAc,iBAAiB,CAAA;AAE/B,eAAe,UAAU,CAAA"}
|
package/dist/index.umd.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/extension-drag-handle'), require('react')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/extension-drag-handle', 'react'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-drag-handle-react"] = {}, global.extensionDragHandle, global.React));
|
|
5
|
-
})(this, (function (exports, extensionDragHandle, React) { 'use strict';
|
|
6
|
-
|
|
7
|
-
const DragHandle = (props) => {
|
|
8
|
-
const { className = 'drag-handle', children, editor, pluginKey = extensionDragHandle.dragHandlePluginDefaultKey, onNodeChange, tippyOptions, } = props;
|
|
9
|
-
const [element, setElement] = React.useState(null);
|
|
10
|
-
const plugin = React.useRef(null);
|
|
11
|
-
React.useEffect(() => {
|
|
12
|
-
if (!element) {
|
|
13
|
-
return () => {
|
|
14
|
-
plugin.current = null;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (editor.isDestroyed) {
|
|
18
|
-
return () => {
|
|
19
|
-
plugin.current = null;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (!plugin.current) {
|
|
23
|
-
plugin.current = extensionDragHandle.DragHandlePlugin({
|
|
24
|
-
editor,
|
|
25
|
-
element,
|
|
26
|
-
pluginKey,
|
|
27
|
-
tippyOptions,
|
|
28
|
-
onNodeChange,
|
|
29
|
-
});
|
|
30
|
-
editor.registerPlugin(plugin.current);
|
|
31
|
-
}
|
|
32
|
-
return () => {
|
|
33
|
-
editor.unregisterPlugin(pluginKey);
|
|
34
|
-
plugin.current = null;
|
|
35
|
-
};
|
|
36
|
-
}, [element, editor, onNodeChange, pluginKey, tippyOptions]);
|
|
37
|
-
return (React.createElement("div", { className: className, ref: setElement }, children));
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
exports.DragHandle = DragHandle;
|
|
41
|
-
exports.default = DragHandle;
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
44
|
-
|
|
45
|
-
}));
|
|
46
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/DragHandle.tsx"],"sourcesContent":["import {\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n DragHandlePluginProps,\n} from '@tiptap/extension-drag-handle'\nimport { Node } from '@tiptap/pm/model'\nimport { Plugin } from '@tiptap/pm/state'\nimport { Editor } from '@tiptap/react'\nimport React, {\n ReactNode, useEffect, useRef, useState,\n} from 'react'\n\ntype Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;\n\nexport type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {\n className?: string;\n onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void;\n children: ReactNode;\n\n /**\n * Tippy.js options for the drag handle tooltip.\n *\n * **IMPORTANT**: Make sure to memoize this object - otherwise the object\n * will cause the drag handle to be re-initialized on every render breaking it.\n */\n tippyOptions?: DragHandlePluginProps['tippyOptions'];\n};\n\nexport const DragHandle = (props: DragHandleProps) => {\n const {\n className = 'drag-handle',\n children,\n editor,\n pluginKey = dragHandlePluginDefaultKey,\n onNodeChange,\n tippyOptions,\n } = props\n const [element, setElement] = useState<HTMLDivElement | null>(null)\n const plugin = useRef<Plugin | null>(null)\n\n useEffect(() => {\n if (!element) {\n return () => {\n plugin.current = null\n }\n }\n\n if (editor.isDestroyed) {\n return () => {\n plugin.current = null\n }\n }\n\n if (!plugin.current) {\n plugin.current = DragHandlePlugin({\n editor,\n element,\n pluginKey,\n tippyOptions,\n onNodeChange,\n })\n\n editor.registerPlugin(plugin.current)\n }\n\n return () => {\n editor.unregisterPlugin(pluginKey)\n plugin.current = null\n }\n }, [element, editor, onNodeChange, pluginKey, tippyOptions])\n\n return (\n <div className={className} ref={setElement}>\n {children}\n </div>\n )\n}\n"],"names":["dragHandlePluginDefaultKey","useState","useRef","useEffect","DragHandlePlugin"],"mappings":";;;;;;AA4Ba,QAAA,UAAU,GAAG,CAAC,KAAsB,KAAI;EACnD,IAAA,MAAM,EACJ,SAAS,GAAG,aAAa,EACzB,QAAQ,EACR,MAAM,EACN,SAAS,GAAGA,8CAA0B,EACtC,YAAY,EACZ,YAAY,GACb,GAAG,KAAK;MACT,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGC,cAAQ,CAAwB,IAAI,CAAC;EACnE,IAAA,MAAM,MAAM,GAAGC,YAAM,CAAgB,IAAI,CAAC;MAE1CC,eAAS,CAAC,MAAK;UACb,IAAI,CAAC,OAAO,EAAE;EACZ,YAAA,OAAO,MAAK;EACV,gBAAA,MAAM,CAAC,OAAO,GAAG,IAAI;EACvB,aAAC;;EAGH,QAAA,IAAI,MAAM,CAAC,WAAW,EAAE;EACtB,YAAA,OAAO,MAAK;EACV,gBAAA,MAAM,CAAC,OAAO,GAAG,IAAI;EACvB,aAAC;;EAGH,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;EACnB,YAAA,MAAM,CAAC,OAAO,GAAGC,oCAAgB,CAAC;kBAChC,MAAM;kBACN,OAAO;kBACP,SAAS;kBACT,YAAY;kBACZ,YAAY;EACb,aAAA,CAAC;EAEF,YAAA,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC;;EAGvC,QAAA,OAAO,MAAK;EACV,YAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC;EAClC,YAAA,MAAM,CAAC,OAAO,GAAG,IAAI;EACvB,SAAC;EACH,KAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;EAE5D,IAAA,QACE,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAA,EACvC,QAAQ,CACL;EAEV;;;;;;;;;;;"}
|