@blockslides/extension-drag-handle-vue-2 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/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ // src/DragHandle.ts
2
+ import {
3
+ defaultComputePositionConfig,
4
+ DragHandlePlugin,
5
+ dragHandlePluginDefaultKey
6
+ } from "@blockslides/extension-drag-handle";
7
+ import Vue from "vue";
8
+ var DragHandle = Vue.extend({
9
+ name: "DragHandleVue",
10
+ props: {
11
+ pluginKey: {
12
+ type: [String, Object],
13
+ default: () => dragHandlePluginDefaultKey
14
+ },
15
+ editor: {
16
+ type: Object,
17
+ required: true
18
+ },
19
+ computePositionConfig: {
20
+ type: Object,
21
+ default: () => ({})
22
+ },
23
+ onNodeChange: {
24
+ type: Function,
25
+ default: null
26
+ },
27
+ class: {
28
+ type: String,
29
+ default: "drag-handle"
30
+ }
31
+ },
32
+ mounted() {
33
+ const { editor, pluginKey, onNodeChange } = this.$props;
34
+ editor.registerPlugin(
35
+ DragHandlePlugin({
36
+ editor,
37
+ element: this.$el,
38
+ pluginKey,
39
+ computePositionConfig: { ...defaultComputePositionConfig, ...this.computePositionConfig },
40
+ onNodeChange
41
+ }).plugin
42
+ );
43
+ },
44
+ // eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
45
+ beforeDestroy() {
46
+ const { pluginKey, editor } = this.$props;
47
+ editor.unregisterPlugin(pluginKey);
48
+ },
49
+ render(h) {
50
+ return h(
51
+ "div",
52
+ {
53
+ class: this.class
54
+ },
55
+ this.$slots.default
56
+ );
57
+ }
58
+ });
59
+
60
+ // src/index.ts
61
+ var index_default = DragHandle;
62
+ export {
63
+ DragHandle,
64
+ index_default as default
65
+ };
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/DragHandle.ts","../src/index.ts"],"sourcesContent":["import type { Editor } from '@blockslides/core'\nimport {\n type DragHandlePluginProps,\n defaultComputePositionConfig,\n DragHandlePlugin,\n dragHandlePluginDefaultKey,\n} from '@blockslides/extension-drag-handle'\nimport Vue, { type 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 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 mounted() {\n const { editor, pluginKey, onNodeChange } = this.$props\n\n editor.registerPlugin(\n DragHandlePlugin({\n editor,\n element: this.$el as HTMLElement,\n pluginKey,\n computePositionConfig: { ...defaultComputePositionConfig, ...this.computePositionConfig },\n onNodeChange,\n }).plugin,\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(\n 'div',\n {\n class: this.class,\n },\n this.$slots.default,\n )\n },\n})\n","import { DragHandle } from './DragHandle.js'\n\nexport * from './DragHandle.js'\n\nexport default DragHandle\n"],"mappings":";AACA;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,SAA4B;AAS5B,IAAM,aAAa,IAAI,OAAO;AAAA,EACnC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS,MAAM;AAAA,IACjB;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,UAAU;AACR,UAAM,EAAE,QAAQ,WAAW,aAAa,IAAI,KAAK;AAEjD,WAAO;AAAA,MACL,iBAAiB;AAAA,QACf;AAAA,QACA,SAAS,KAAK;AAAA,QACd;AAAA,QACA,uBAAuB,EAAE,GAAG,8BAA8B,GAAG,KAAK,sBAAsB;AAAA,QACxF;AAAA,MACF,CAAC,EAAE;AAAA,IACL;AAAA,EACF;AAAA;AAAA,EAGA,gBAAgB;AACd,UAAM,EAAE,WAAW,OAAO,IAAI,KAAK;AAEnC,WAAO,iBAAiB,SAAmB;AAAA,EAC7C;AAAA,EAEA,OAAO,GAAG;AACR,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,OAAO,KAAK;AAAA,MACd;AAAA,MACA,KAAK,OAAO;AAAA,IACd;AAAA,EACF;AACF,CAAC;;;ACxED,IAAO,gBAAQ;","names":[]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@blockslides/extension-drag-handle-vue-2",
3
+ "description": "drag handle extension for blockslides with vue 2",
4
+ "version": "0.1.0",
5
+ "keywords": [
6
+ "blockslides",
7
+ "blockslides extension"
8
+ ],
9
+ "author": "keivanmojmali",
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/keivanmojmali/blockslides",
14
+ "directory": "packages/extension-drag-handle-vue-2"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ ".": {
19
+ "types": {
20
+ "import": "./dist/index.d.ts",
21
+ "require": "./dist/index.d.cts"
22
+ },
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "main": "dist/index.cjs",
28
+ "module": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "files": [
31
+ "src",
32
+ "dist"
33
+ ],
34
+ "peerDependencies": {
35
+ "vue": "^2.0.0",
36
+ "@blockslides/extension-drag-handle": "^0.1.0",
37
+ "@blockslides/pm": "^0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "vue": "^2.0.0",
41
+ "vue-ts-types": "1.6.2",
42
+ "@blockslides/extension-drag-handle": "^0.1.0",
43
+ "@blockslides/pm": "^0.1.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup",
47
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
48
+ }
49
+ }
@@ -0,0 +1,77 @@
1
+ import type { Editor } from '@blockslides/core'
2
+ import {
3
+ type DragHandlePluginProps,
4
+ defaultComputePositionConfig,
5
+ DragHandlePlugin,
6
+ dragHandlePluginDefaultKey,
7
+ } from '@blockslides/extension-drag-handle'
8
+ import Vue, { type PropType } from 'vue'
9
+
10
+ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
11
+
12
+ export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
13
+ class?: string
14
+ onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void
15
+ }
16
+
17
+ export const DragHandle = Vue.extend({
18
+ name: 'DragHandleVue',
19
+
20
+ props: {
21
+ pluginKey: {
22
+ type: [String, Object] as PropType<DragHandleProps['pluginKey']>,
23
+ default: () => dragHandlePluginDefaultKey,
24
+ },
25
+
26
+ editor: {
27
+ type: Object as PropType<DragHandleProps['editor']>,
28
+ required: true,
29
+ },
30
+
31
+ computePositionConfig: {
32
+ type: Object as PropType<DragHandleProps['computePositionConfig']>,
33
+ default: () => ({}),
34
+ },
35
+
36
+ onNodeChange: {
37
+ type: Function as PropType<DragHandleProps['onNodeChange']>,
38
+ default: null,
39
+ },
40
+
41
+ class: {
42
+ type: String as PropType<DragHandleProps['class']>,
43
+ default: 'drag-handle',
44
+ },
45
+ },
46
+
47
+ mounted() {
48
+ const { editor, pluginKey, onNodeChange } = this.$props
49
+
50
+ editor.registerPlugin(
51
+ DragHandlePlugin({
52
+ editor,
53
+ element: this.$el as HTMLElement,
54
+ pluginKey,
55
+ computePositionConfig: { ...defaultComputePositionConfig, ...this.computePositionConfig },
56
+ onNodeChange,
57
+ }).plugin,
58
+ )
59
+ },
60
+
61
+ // eslint-disable-next-line vue/no-deprecated-destroyed-lifecycle
62
+ beforeDestroy() {
63
+ const { pluginKey, editor } = this.$props
64
+
65
+ editor.unregisterPlugin(pluginKey as string)
66
+ },
67
+
68
+ render(h) {
69
+ return h(
70
+ 'div',
71
+ {
72
+ class: this.class,
73
+ },
74
+ this.$slots.default,
75
+ )
76
+ },
77
+ })
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { DragHandle } from './DragHandle.js'
2
+
3
+ export * from './DragHandle.js'
4
+
5
+ export default DragHandle