@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/dist/index.js ADDED
@@ -0,0 +1,71 @@
1
+ // src/DragHandle.ts
2
+ import {
3
+ defaultComputePositionConfig,
4
+ DragHandlePlugin,
5
+ dragHandlePluginDefaultKey
6
+ } from "@blockslides/extension-drag-handle";
7
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref } from "vue";
8
+ var DragHandle = defineComponent({
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
+ setup(props, { slots }) {
33
+ const root = ref(null);
34
+ onMounted(() => {
35
+ const { editor, pluginKey, onNodeChange, computePositionConfig } = props;
36
+ editor.registerPlugin(
37
+ DragHandlePlugin({
38
+ editor,
39
+ element: root.value,
40
+ pluginKey,
41
+ computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
42
+ onNodeChange
43
+ }).plugin
44
+ );
45
+ });
46
+ onBeforeUnmount(() => {
47
+ const { pluginKey, editor } = props;
48
+ editor.unregisterPlugin(pluginKey);
49
+ });
50
+ return () => {
51
+ var _a;
52
+ return h(
53
+ "div",
54
+ {
55
+ ref: root,
56
+ class: props.class,
57
+ style: { visibility: "hidden", position: "absolute" }
58
+ },
59
+ (_a = slots.default) == null ? void 0 : _a.call(slots)
60
+ );
61
+ };
62
+ }
63
+ });
64
+
65
+ // src/index.ts
66
+ var index_default = DragHandle;
67
+ export {
68
+ DragHandle,
69
+ index_default as default
70
+ };
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/DragHandle.ts","../src/index.ts"],"sourcesContent":["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","import { DragHandle } from './DragHandle.js'\n\nexport * from './DragHandle.js'\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}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@blockslides/extension-drag-handle-vue-3",
3
+ "description": "drag handle extension for blockslides with vue 3",
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-3"
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": "^3.0.0",
36
+ "@blockslides/extension-drag-handle": "^0.1.0",
37
+ "@blockslides/pm": "^0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "vue": "^3.0.0",
41
+ "@blockslides/extension-drag-handle": "^0.1.0",
42
+ "@blockslides/pm": "^0.1.0"
43
+ },
44
+ "scripts": {
45
+ "build": "tsup",
46
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
47
+ }
48
+ }
@@ -0,0 +1,82 @@
1
+ import type { DragHandlePluginProps } from '@blockslides/extension-drag-handle'
2
+ import {
3
+ defaultComputePositionConfig,
4
+ DragHandlePlugin,
5
+ dragHandlePluginDefaultKey,
6
+ } from '@blockslides/extension-drag-handle'
7
+ import type { Editor } from '@blockslides/core'
8
+ import type { PropType } from 'vue'
9
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref } from 'vue'
10
+
11
+ type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>
12
+
13
+ export type DragHandleProps = Omit<Optional<DragHandlePluginProps, 'pluginKey'>, 'element'> & {
14
+ class?: string
15
+ onNodeChange?: (data: { node: Node | null; editor: Editor; pos: number }) => void
16
+ }
17
+
18
+ export const DragHandle = defineComponent({
19
+ name: 'DragHandleVue',
20
+
21
+ props: {
22
+ pluginKey: {
23
+ type: [String, Object] as PropType<DragHandleProps['pluginKey']>,
24
+ default: dragHandlePluginDefaultKey,
25
+ },
26
+
27
+ editor: {
28
+ type: Object as PropType<DragHandleProps['editor']>,
29
+ required: true,
30
+ },
31
+
32
+ computePositionConfig: {
33
+ type: Object as PropType<DragHandleProps['computePositionConfig']>,
34
+ default: () => ({}),
35
+ },
36
+
37
+ onNodeChange: {
38
+ type: Function as PropType<DragHandleProps['onNodeChange']>,
39
+ default: null,
40
+ },
41
+
42
+ class: {
43
+ type: String as PropType<DragHandleProps['class']>,
44
+ default: 'drag-handle',
45
+ },
46
+ },
47
+
48
+ setup(props, { slots }) {
49
+ const root = ref<HTMLElement | null>(null)
50
+
51
+ onMounted(() => {
52
+ const { editor, pluginKey, onNodeChange, computePositionConfig } = props
53
+
54
+ editor.registerPlugin(
55
+ DragHandlePlugin({
56
+ editor,
57
+ element: root.value as HTMLElement,
58
+ pluginKey,
59
+ computePositionConfig: { ...defaultComputePositionConfig, ...computePositionConfig },
60
+ onNodeChange,
61
+ }).plugin,
62
+ )
63
+ })
64
+
65
+ onBeforeUnmount(() => {
66
+ const { pluginKey, editor } = props
67
+
68
+ editor.unregisterPlugin(pluginKey as string)
69
+ })
70
+
71
+ return () =>
72
+ h(
73
+ 'div',
74
+ {
75
+ ref: root,
76
+ class: props.class,
77
+ style: { visibility: 'hidden', position: 'absolute' },
78
+ },
79
+ slots.default?.(),
80
+ )
81
+ },
82
+ })
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