@blockslides/extension-drag-handle-vue-3 0.1.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.
package/LICENSE.md ADDED
@@ -0,0 +1,36 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 BlockSlides
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.
22
+
23
+ ---
24
+
25
+ ## Acknowledgments
26
+
27
+ This project includes code and patterns adapted from [Tiptap](https://tiptap.dev),
28
+ an open-source headless editor framework for web artisans.
29
+
30
+ **Tiptap License:**
31
+
32
+ - Copyright (c) 2025, Tiptap GmbH
33
+ - Licensed under MIT License
34
+ - Original source: https://github.com/ueberdosis/tiptap
35
+
36
+ See `_tiptap/LICENSE.md` for the full Tiptap license.
package/dist/index.cjs ADDED
@@ -0,0 +1,94 @@
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);
19
+
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);
27
+
28
+ // src/DragHandle.ts
29
+ var import_extension_drag_handle = require("@blockslides/extension-drag-handle");
30
+ var import_vue = require("vue");
31
+ var DragHandle = (0, import_vue.defineComponent)({
32
+ name: "DragHandleVue",
33
+ props: {
34
+ pluginKey: {
35
+ type: [String, Object],
36
+ default: import_extension_drag_handle.dragHandlePluginDefaultKey
37
+ },
38
+ editor: {
39
+ type: Object,
40
+ required: true
41
+ },
42
+ computePositionConfig: {
43
+ type: Object,
44
+ default: () => ({})
45
+ },
46
+ onNodeChange: {
47
+ type: Function,
48
+ default: null
49
+ },
50
+ class: {
51
+ type: String,
52
+ default: "drag-handle"
53
+ }
54
+ },
55
+ setup(props, { slots }) {
56
+ const root = (0, import_vue.ref)(null);
57
+ (0, import_vue.onMounted)(() => {
58
+ const { editor, pluginKey, onNodeChange, computePositionConfig } = props;
59
+ editor.registerPlugin(
60
+ (0, import_extension_drag_handle.DragHandlePlugin)({
61
+ editor,
62
+ element: root.value,
63
+ pluginKey,
64
+ computePositionConfig: { ...import_extension_drag_handle.defaultComputePositionConfig, ...computePositionConfig },
65
+ onNodeChange
66
+ }).plugin
67
+ );
68
+ });
69
+ (0, import_vue.onBeforeUnmount)(() => {
70
+ const { pluginKey, editor } = props;
71
+ editor.unregisterPlugin(pluginKey);
72
+ });
73
+ return () => {
74
+ var _a;
75
+ return (0, import_vue.h)(
76
+ "div",
77
+ {
78
+ ref: root,
79
+ class: props.class,
80
+ style: { visibility: "hidden", position: "absolute" }
81
+ },
82
+ (_a = slots.default) == null ? void 0 : _a.call(slots)
83
+ );
84
+ };
85
+ }
86
+ });
87
+
88
+ // src/index.ts
89
+ var index_default = DragHandle;
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ DragHandle
93
+ });
94
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/DragHandle.ts"],"sourcesContent":["import { DragHandle } from './DragHandle.js'\n\nexport * from './DragHandle.js'\n\nexport default DragHandle\n","import type { DragHandlePluginProps } from '@blockslides/extension-drag-handle'\nimport {\n defaultComputePositionConfig,\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n} from '@blockslides/extension-drag-handle'\nimport type { Editor } from '@blockslides/core'\nimport type { PropType } from 'vue'\nimport { defineComponent, h, onBeforeUnmount, onMounted, ref } from 'vue'\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 class?: string\n onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void\n}\n\nexport const DragHandle = defineComponent({\n name: 'DragHandleVue',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<DragHandleProps['pluginKey']>,\n default: dragHandlePluginDefaultKey,\n },\n\n editor: {\n type: Object as PropType<DragHandleProps['editor']>,\n required: true,\n },\n\n computePositionConfig: {\n type: Object as PropType<DragHandleProps['computePositionConfig']>,\n default: () => ({}),\n },\n\n onNodeChange: {\n type: Function as PropType<DragHandleProps['onNodeChange']>,\n default: null,\n },\n\n class: {\n type: String as PropType<DragHandleProps['class']>,\n default: 'drag-handle',\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { editor, pluginKey, onNodeChange, computePositionConfig } = props\n\n editor.registerPlugin(\n DragHandlePlugin({\n editor,\n element: root.value as HTMLElement,\n pluginKey,\n computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },\n onNodeChange,\n }).plugin,\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey as string)\n })\n\n return () =>\n h(\n 'div',\n {\n ref: root,\n class: props.class,\n style: { visibility: 'hidden', position: 'absolute' },\n },\n slots.default?.(),\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mCAIO;AAGP,iBAAoE;AAS7D,IAAM,iBAAa,4BAAgB;AAAA,EACxC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,uBAAuB;AAAA,MACrB,MAAM;AAAA,MACN,SAAS,OAAO,CAAC;AAAA,IACnB;AAAA,IAEA,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,OAAO;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,EAAE,MAAM,GAAG;AACtB,UAAM,WAAO,gBAAwB,IAAI;AAEzC,8BAAU,MAAM;AACd,YAAM,EAAE,QAAQ,WAAW,cAAc,sBAAsB,IAAI;AAEnE,aAAO;AAAA,YACL,+CAAiB;AAAA,UACf;AAAA,UACA,SAAS,KAAK;AAAA,UACd;AAAA,UACA,uBAAuB,EAAE,GAAG,2DAA8B,GAAG,sBAAsB;AAAA,UACnF;AAAA,QACF,CAAC,EAAE;AAAA,MACL;AAAA,IACF,CAAC;AAED,oCAAgB,MAAM;AACpB,YAAM,EAAE,WAAW,OAAO,IAAI;AAE9B,aAAO,iBAAiB,SAAmB;AAAA,IAC7C,CAAC;AAED,WAAO,MAAG;AAtEd;AAuEM;AAAA,QACE;AAAA,QACA;AAAA,UACE,KAAK;AAAA,UACL,OAAO,MAAM;AAAA,UACb,OAAO,EAAE,YAAY,UAAU,UAAU,WAAW;AAAA,QACtD;AAAA,SACA,WAAM,YAAN;AAAA,MACF;AAAA;AAAA,EACJ;AACF,CAAC;;;AD7ED,IAAO,gBAAQ;","names":[]}