@tiptap/extension-drag-handle-vue-2 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.
- package/README.md +14 -0
- package/dist/DragHandle.d.ts +29 -0
- package/dist/DragHandle.d.ts.map +1 -0
- package/dist/index.cjs +60 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +59 -0
- package/dist/index.umd.js.map +1 -0
- package/package.json +53 -0
- package/src/DragHandle.ts +75 -0
- package/src/index.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @tiptap/extension-drag-handle-vue-2
|
|
2
|
+
[](https://www.npmjs.com/package/@tiptap/extension-drag-handle-vue-2)
|
|
3
|
+
[](https://npmcharts.com/compare/tiptap?minimal=true)
|
|
4
|
+
[](https://www.npmjs.com/package/@tiptap/extension-drag-handle-vue-2)
|
|
5
|
+
[](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,29 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { DragHandlePluginProps } from '@tiptap/extension-drag-handle';
|
|
3
|
+
import Vue from 'vue';
|
|
4
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
5
|
+
export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
6
|
+
class?: string;
|
|
7
|
+
onNodeChange?: (data: {
|
|
8
|
+
node: Node | null;
|
|
9
|
+
editor: Editor;
|
|
10
|
+
pos: number;
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const DragHandle: import("vue/types/vue").ExtendedVue<Vue<Record<string, any>, Record<string, any>, never, never, (event: string, ...args: any[]) => Vue>, unknown, unknown, unknown, {
|
|
14
|
+
pluginKey: string | import("prosemirror-state").PluginKey<any> | undefined;
|
|
15
|
+
editor: Editor;
|
|
16
|
+
tippyOptions: {} | undefined;
|
|
17
|
+
onNodeChange: (((data: {
|
|
18
|
+
editor: Editor;
|
|
19
|
+
node: import("prosemirror-model").Node | null;
|
|
20
|
+
pos: number;
|
|
21
|
+
}) => void) & ((data: {
|
|
22
|
+
node: Node | null;
|
|
23
|
+
editor: Editor;
|
|
24
|
+
pos: number;
|
|
25
|
+
}) => void)) | undefined;
|
|
26
|
+
class: string | undefined;
|
|
27
|
+
}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=DragHandle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragHandle.d.ts","sourceRoot":"","sources":["../src/DragHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAGL,qBAAqB,EACtB,MAAM,+BAA+B,CAAA;AACtC,OAAO,GAAiB,MAAM,KAAK,CAAA;AAEnC,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,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;CACnF,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;0BAHC;QAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;;gFA8DjF,CAAA"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var extensionDragHandle = require('@tiptap/extension-drag-handle');
|
|
6
|
+
var Vue = require('vue');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
|
+
|
|
10
|
+
var Vue__default = /*#__PURE__*/_interopDefaultCompat(Vue);
|
|
11
|
+
|
|
12
|
+
const DragHandle = Vue__default.default.extend({
|
|
13
|
+
name: 'DragHandleVue',
|
|
14
|
+
props: {
|
|
15
|
+
pluginKey: {
|
|
16
|
+
type: [String, Object],
|
|
17
|
+
default: extensionDragHandle.dragHandlePluginDefaultKey,
|
|
18
|
+
},
|
|
19
|
+
editor: {
|
|
20
|
+
type: Object,
|
|
21
|
+
required: true,
|
|
22
|
+
},
|
|
23
|
+
tippyOptions: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: () => ({}),
|
|
26
|
+
},
|
|
27
|
+
onNodeChange: {
|
|
28
|
+
type: Function,
|
|
29
|
+
default: null,
|
|
30
|
+
},
|
|
31
|
+
class: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'drag-handle',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
mounted() {
|
|
37
|
+
const { editor, pluginKey, onNodeChange, tippyOptions, } = this.$props;
|
|
38
|
+
editor.registerPlugin(extensionDragHandle.DragHandlePlugin({
|
|
39
|
+
editor,
|
|
40
|
+
element: this.$el,
|
|
41
|
+
pluginKey,
|
|
42
|
+
tippyOptions,
|
|
43
|
+
onNodeChange,
|
|
44
|
+
}));
|
|
45
|
+
},
|
|
46
|
+
// eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
|
|
47
|
+
beforeDestroy() {
|
|
48
|
+
const { pluginKey, editor } = this.$props;
|
|
49
|
+
editor.unregisterPlugin(pluginKey);
|
|
50
|
+
},
|
|
51
|
+
render(h) {
|
|
52
|
+
return h('div', {
|
|
53
|
+
class: this.class,
|
|
54
|
+
}, this.$slots.default);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
exports.DragHandle = DragHandle;
|
|
59
|
+
exports.default = DragHandle;
|
|
60
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/DragHandle.ts"],"sourcesContent":["import { Editor } from '@tiptap/core'\nimport {\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n DragHandlePluginProps,\n} from '@tiptap/extension-drag-handle'\nimport Vue, { PropType } 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 = Vue.extend({\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 tippyOptions: {\n type: Object as PropType<DragHandleProps['tippyOptions']>,\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 mounted() {\n const {\n editor,\n pluginKey,\n onNodeChange,\n tippyOptions,\n } = this.$props\n\n editor.registerPlugin(DragHandlePlugin({\n editor,\n element: this.$el as HTMLElement,\n pluginKey,\n tippyOptions,\n onNodeChange,\n }))\n },\n\n // eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle\n beforeDestroy() {\n const { pluginKey, editor } = this.$props\n\n editor.unregisterPlugin(pluginKey as string)\n },\n\n render(h) {\n return h('div', {\n class: this.class,\n }, this.$slots.default)\n },\n})\n"],"names":["Vue","dragHandlePluginDefaultKey","DragHandlePlugin"],"mappings":";;;;;;;;;;;AAea,MAAA,UAAU,GAAGA,oBAAG,CAAC,MAAM,CAAC;AACnC,IAAA,IAAI,EAAE,eAAe;AAErB,IAAA,KAAK,EAAE;AACL,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA2C;AAChE,YAAA,OAAO,EAAEC,8CAA0B;AACpC,SAAA;AAED,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA6C;AACnD,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAmD;AACzD,YAAA,OAAO,EAAE,OAAO,EAAE,CAAC;AACpB,SAAA;AAED,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,QAAqD;AAC3D,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AAED,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAA4C;AAClD,YAAA,OAAO,EAAE,aAAa;AACvB,SAAA;AACF,KAAA;IAED,OAAO,GAAA;AACL,QAAA,MAAM,EACJ,MAAM,EACN,SAAS,EACT,YAAY,EACZ,YAAY,GACb,GAAG,IAAI,CAAC,MAAM;AAEf,QAAA,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;YACrC,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,GAAkB;YAChC,SAAS;YACT,YAAY;YACZ,YAAY;AACb,SAAA,CAAC,CAAC;KACJ;;IAGD,aAAa,GAAA;QACX,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM;AAEzC,QAAA,MAAM,CAAC,gBAAgB,CAAC,SAAmB,CAAC;KAC7C;AAED,IAAA,MAAM,CAAC,CAAC,EAAA;QACN,OAAO,CAAC,CAAC,KAAK,EAAE;YACd,KAAK,EAAE,IAAI,CAAC,KAAK;AAClB,SAAA,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;KACxB;AACF,CAAA;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
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.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { dragHandlePluginDefaultKey, DragHandlePlugin } from '@tiptap/extension-drag-handle';
|
|
2
|
+
import Vue from 'vue';
|
|
3
|
+
|
|
4
|
+
const DragHandle = Vue.extend({
|
|
5
|
+
name: 'DragHandleVue',
|
|
6
|
+
props: {
|
|
7
|
+
pluginKey: {
|
|
8
|
+
type: [String, Object],
|
|
9
|
+
default: dragHandlePluginDefaultKey,
|
|
10
|
+
},
|
|
11
|
+
editor: {
|
|
12
|
+
type: Object,
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
tippyOptions: {
|
|
16
|
+
type: Object,
|
|
17
|
+
default: () => ({}),
|
|
18
|
+
},
|
|
19
|
+
onNodeChange: {
|
|
20
|
+
type: Function,
|
|
21
|
+
default: null,
|
|
22
|
+
},
|
|
23
|
+
class: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'drag-handle',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
mounted() {
|
|
29
|
+
const { editor, pluginKey, onNodeChange, tippyOptions, } = this.$props;
|
|
30
|
+
editor.registerPlugin(DragHandlePlugin({
|
|
31
|
+
editor,
|
|
32
|
+
element: this.$el,
|
|
33
|
+
pluginKey,
|
|
34
|
+
tippyOptions,
|
|
35
|
+
onNodeChange,
|
|
36
|
+
}));
|
|
37
|
+
},
|
|
38
|
+
// eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
|
|
39
|
+
beforeDestroy() {
|
|
40
|
+
const { pluginKey, editor } = this.$props;
|
|
41
|
+
editor.unregisterPlugin(pluginKey);
|
|
42
|
+
},
|
|
43
|
+
render(h) {
|
|
44
|
+
return h('div', {
|
|
45
|
+
class: this.class,
|
|
46
|
+
}, this.$slots.default);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { DragHandle, DragHandle as default };
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/DragHandle.ts"],"sourcesContent":["import { Editor } from '@tiptap/core'\nimport {\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n DragHandlePluginProps,\n} from '@tiptap/extension-drag-handle'\nimport Vue, { PropType } 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 = Vue.extend({\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 tippyOptions: {\n type: Object as PropType<DragHandleProps['tippyOptions']>,\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 mounted() {\n const {\n editor,\n pluginKey,\n onNodeChange,\n tippyOptions,\n } = this.$props\n\n editor.registerPlugin(DragHandlePlugin({\n editor,\n element: this.$el as HTMLElement,\n pluginKey,\n tippyOptions,\n onNodeChange,\n }))\n },\n\n // eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle\n beforeDestroy() {\n const { pluginKey, editor } = this.$props\n\n editor.unregisterPlugin(pluginKey as string)\n },\n\n render(h) {\n return h('div', {\n class: this.class,\n }, this.$slots.default)\n },\n})\n"],"names":[],"mappings":";;;AAea,MAAA,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC;AACnC,IAAA,IAAI,EAAE,eAAe;AAErB,IAAA,KAAK,EAAE;AACL,QAAA,SAAS,EAAE;AACT,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA2C;AAChE,YAAA,OAAO,EAAE,0BAA0B;AACpC,SAAA;AAED,QAAA,MAAM,EAAE;AACN,YAAA,IAAI,EAAE,MAA6C;AACnD,YAAA,QAAQ,EAAE,IAAI;AACf,SAAA;AAED,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,MAAmD;AACzD,YAAA,OAAO,EAAE,OAAO,EAAE,CAAC;AACpB,SAAA;AAED,QAAA,YAAY,EAAE;AACZ,YAAA,IAAI,EAAE,QAAqD;AAC3D,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;AAED,QAAA,KAAK,EAAE;AACL,YAAA,IAAI,EAAE,MAA4C;AAClD,YAAA,OAAO,EAAE,aAAa;AACvB,SAAA;AACF,KAAA;IAED,OAAO,GAAA;AACL,QAAA,MAAM,EACJ,MAAM,EACN,SAAS,EACT,YAAY,EACZ,YAAY,GACb,GAAG,IAAI,CAAC,MAAM;AAEf,QAAA,MAAM,CAAC,cAAc,CAAC,gBAAgB,CAAC;YACrC,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,GAAkB;YAChC,SAAS;YACT,YAAY;YACZ,YAAY;AACb,SAAA,CAAC,CAAC;KACJ;;IAGD,aAAa,GAAA;QACX,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM;AAEzC,QAAA,MAAM,CAAC,gBAAgB,CAAC,SAAmB,CAAC;KAC7C;AAED,IAAA,MAAM,CAAC,CAAC,EAAA;QACN,OAAO,CAAC,CAAC,KAAK,EAAE;YACd,KAAK,EAAE,IAAI,CAAC,KAAK;AAClB,SAAA,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;KACxB;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/extension-drag-handle'), require('vue')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/extension-drag-handle', 'vue'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-drag-handle-vue-2"] = {}, global.extensionDragHandle, global.Vue));
|
|
5
|
+
})(this, (function (exports, extensionDragHandle, Vue) { 'use strict';
|
|
6
|
+
|
|
7
|
+
const DragHandle = Vue.extend({
|
|
8
|
+
name: 'DragHandleVue',
|
|
9
|
+
props: {
|
|
10
|
+
pluginKey: {
|
|
11
|
+
type: [String, Object],
|
|
12
|
+
default: extensionDragHandle.dragHandlePluginDefaultKey,
|
|
13
|
+
},
|
|
14
|
+
editor: {
|
|
15
|
+
type: Object,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
tippyOptions: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default: () => ({}),
|
|
21
|
+
},
|
|
22
|
+
onNodeChange: {
|
|
23
|
+
type: Function,
|
|
24
|
+
default: null,
|
|
25
|
+
},
|
|
26
|
+
class: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'drag-handle',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
mounted() {
|
|
32
|
+
const { editor, pluginKey, onNodeChange, tippyOptions, } = this.$props;
|
|
33
|
+
editor.registerPlugin(extensionDragHandle.DragHandlePlugin({
|
|
34
|
+
editor,
|
|
35
|
+
element: this.$el,
|
|
36
|
+
pluginKey,
|
|
37
|
+
tippyOptions,
|
|
38
|
+
onNodeChange,
|
|
39
|
+
}));
|
|
40
|
+
},
|
|
41
|
+
// eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
|
|
42
|
+
beforeDestroy() {
|
|
43
|
+
const { pluginKey, editor } = this.$props;
|
|
44
|
+
editor.unregisterPlugin(pluginKey);
|
|
45
|
+
},
|
|
46
|
+
render(h) {
|
|
47
|
+
return h('div', {
|
|
48
|
+
class: this.class,
|
|
49
|
+
}, this.$slots.default);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
exports.DragHandle = DragHandle;
|
|
54
|
+
exports.default = DragHandle;
|
|
55
|
+
|
|
56
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
57
|
+
|
|
58
|
+
}));
|
|
59
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/DragHandle.ts"],"sourcesContent":["import { Editor } from '@tiptap/core'\nimport {\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n DragHandlePluginProps,\n} from '@tiptap/extension-drag-handle'\nimport Vue, { PropType } 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 = Vue.extend({\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 tippyOptions: {\n type: Object as PropType<DragHandleProps['tippyOptions']>,\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 mounted() {\n const {\n editor,\n pluginKey,\n onNodeChange,\n tippyOptions,\n } = this.$props\n\n editor.registerPlugin(DragHandlePlugin({\n editor,\n element: this.$el as HTMLElement,\n pluginKey,\n tippyOptions,\n onNodeChange,\n }))\n },\n\n // eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle\n beforeDestroy() {\n const { pluginKey, editor } = this.$props\n\n editor.unregisterPlugin(pluginKey as string)\n },\n\n render(h) {\n return h('div', {\n class: this.class,\n }, this.$slots.default)\n },\n})\n"],"names":["dragHandlePluginDefaultKey","DragHandlePlugin"],"mappings":";;;;;;AAea,QAAA,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC;EACnC,IAAA,IAAI,EAAE,eAAe;EAErB,IAAA,KAAK,EAAE;EACL,QAAA,SAAS,EAAE;EACT,YAAA,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAA2C;EAChE,YAAA,OAAO,EAAEA,8CAA0B;EACpC,SAAA;EAED,QAAA,MAAM,EAAE;EACN,YAAA,IAAI,EAAE,MAA6C;EACnD,YAAA,QAAQ,EAAE,IAAI;EACf,SAAA;EAED,QAAA,YAAY,EAAE;EACZ,YAAA,IAAI,EAAE,MAAmD;EACzD,YAAA,OAAO,EAAE,OAAO,EAAE,CAAC;EACpB,SAAA;EAED,QAAA,YAAY,EAAE;EACZ,YAAA,IAAI,EAAE,QAAqD;EAC3D,YAAA,OAAO,EAAE,IAAI;EACd,SAAA;EAED,QAAA,KAAK,EAAE;EACL,YAAA,IAAI,EAAE,MAA4C;EAClD,YAAA,OAAO,EAAE,aAAa;EACvB,SAAA;EACF,KAAA;MAED,OAAO,GAAA;EACL,QAAA,MAAM,EACJ,MAAM,EACN,SAAS,EACT,YAAY,EACZ,YAAY,GACb,GAAG,IAAI,CAAC,MAAM;EAEf,QAAA,MAAM,CAAC,cAAc,CAACC,oCAAgB,CAAC;cACrC,MAAM;cACN,OAAO,EAAE,IAAI,CAAC,GAAkB;cAChC,SAAS;cACT,YAAY;cACZ,YAAY;EACb,SAAA,CAAC,CAAC;OACJ;;MAGD,aAAa,GAAA;UACX,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM;EAEzC,QAAA,MAAM,CAAC,gBAAgB,CAAC,SAAmB,CAAC;OAC7C;EAED,IAAA,MAAM,CAAC,CAAC,EAAA;UACN,OAAO,CAAC,CAAC,KAAK,EAAE;cACd,KAAK,EAAE,IAAI,CAAC,KAAK;EAClB,SAAA,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;OACxB;EACF,CAAA;;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiptap/extension-drag-handle-vue-2",
|
|
3
|
+
"description": "drag handle extension for tiptap with vue 2",
|
|
4
|
+
"version": "2.22.0",
|
|
5
|
+
"homepage": "https://tiptap.dev",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tiptap",
|
|
8
|
+
"tiptap extension"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"funding": {
|
|
12
|
+
"type": "github",
|
|
13
|
+
"url": "https://github.com/sponsors/ueberdosis"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/ueberdosis/tiptap",
|
|
18
|
+
"directory": "packages/extension-drag-handle-vue-2"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.cjs",
|
|
29
|
+
"module": "dist/index.js",
|
|
30
|
+
"umd": "dist/index.umd.js",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"src",
|
|
34
|
+
"dist"
|
|
35
|
+
],
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@tiptap/extension-drag-handle": "^2.14.0",
|
|
38
|
+
"@tiptap/pm": "^2.7.0",
|
|
39
|
+
"@tiptap/vue-2": "^2.7.0",
|
|
40
|
+
"vue": "^2.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@tiptap/extension-drag-handle": "^2.22.0",
|
|
44
|
+
"@tiptap/pm": "^2.22.0",
|
|
45
|
+
"@tiptap/vue-2": "^2.22.0",
|
|
46
|
+
"vue": "^2.0.0",
|
|
47
|
+
"vue-ts-types": "1.6.2"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"clean": "rm -rf dist",
|
|
51
|
+
"build": "npm run clean && rollup -c"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core'
|
|
2
|
+
import {
|
|
3
|
+
DragHandlePlugin,
|
|
4
|
+
dragHandlePluginDefaultKey,
|
|
5
|
+
DragHandlePluginProps,
|
|
6
|
+
} from '@tiptap/extension-drag-handle'
|
|
7
|
+
import Vue, { PropType } from 'vue'
|
|
8
|
+
|
|
9
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
10
|
+
|
|
11
|
+
export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
|
|
12
|
+
class?: string;
|
|
13
|
+
onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const DragHandle = Vue.extend({
|
|
17
|
+
name: 'DragHandleVue',
|
|
18
|
+
|
|
19
|
+
props: {
|
|
20
|
+
pluginKey: {
|
|
21
|
+
type: [String, Object] as PropType<DragHandleProps['pluginKey']>,
|
|
22
|
+
default: dragHandlePluginDefaultKey,
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
editor: {
|
|
26
|
+
type: Object as PropType<DragHandleProps['editor']>,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
tippyOptions: {
|
|
31
|
+
type: Object as PropType<DragHandleProps['tippyOptions']>,
|
|
32
|
+
default: () => ({}),
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
onNodeChange: {
|
|
36
|
+
type: Function as PropType<DragHandleProps['onNodeChange']>,
|
|
37
|
+
default: null,
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
class: {
|
|
41
|
+
type: String as PropType<DragHandleProps['class']>,
|
|
42
|
+
default: 'drag-handle',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
mounted() {
|
|
47
|
+
const {
|
|
48
|
+
editor,
|
|
49
|
+
pluginKey,
|
|
50
|
+
onNodeChange,
|
|
51
|
+
tippyOptions,
|
|
52
|
+
} = this.$props
|
|
53
|
+
|
|
54
|
+
editor.registerPlugin(DragHandlePlugin({
|
|
55
|
+
editor,
|
|
56
|
+
element: this.$el as HTMLElement,
|
|
57
|
+
pluginKey,
|
|
58
|
+
tippyOptions,
|
|
59
|
+
onNodeChange,
|
|
60
|
+
}))
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
|
|
64
|
+
beforeDestroy() {
|
|
65
|
+
const { pluginKey, editor } = this.$props
|
|
66
|
+
|
|
67
|
+
editor.unregisterPlugin(pluginKey as string)
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
render(h) {
|
|
71
|
+
return h('div', {
|
|
72
|
+
class: this.class,
|
|
73
|
+
}, this.$slots.default)
|
|
74
|
+
},
|
|
75
|
+
})
|