@prosekit/vue 0.0.0-next-20230627094841
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 +21 -0
- package/README.md +0 -0
- package/dist/prosekit-vue-components-menu-item.js +14 -0
- package/dist/prosekit-vue-components-menu.js +14 -0
- package/dist/prosekit-vue-components-popover-slash.js +42 -0
- package/dist/prosekit-vue-components-popover-suggestion-consumer.js +14 -0
- package/dist/prosekit-vue-components-popover-suggestion.js +42 -0
- package/dist/prosekit-vue-components-popover.js +14 -0
- package/dist/prosekit-vue-components-popover2.js +14 -0
- package/dist/prosekit-vue-components-slash-popover.js +14 -0
- package/dist/prosekit-vue.js +88 -0
- package/package.json +81 -0
- package/src/index.ts +7 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 ocavue
|
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/README.md
ADDED
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/menu-item.gen.ts
|
2
|
+
import "@prosekit/lit/elements/menu-item";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var MenuItem = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-menu-item", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
MenuItem
|
14
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/menu.gen.ts
|
2
|
+
import "@prosekit/lit/elements/menu";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var Menu = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-menu", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
Menu
|
14
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// src/components/popover-slash.ts
|
2
|
+
import { defineComponent as defineComponent2, h as h2, ref } from "vue";
|
3
|
+
|
4
|
+
// src/components/popover-slash.gen.ts
|
5
|
+
import "@prosekit/lit/elements/popover-slash";
|
6
|
+
import { defineComponent, h } from "vue";
|
7
|
+
var PopoverSlash = defineComponent(
|
8
|
+
(props, { slots }) => {
|
9
|
+
return () => {
|
10
|
+
var _a;
|
11
|
+
return h("prosekit-popover-slash", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
12
|
+
};
|
13
|
+
}
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/popover-slash.ts
|
17
|
+
var PopoverSlash2 = defineComponent2(
|
18
|
+
({ editor }, { slots }) => {
|
19
|
+
const contextRef = ref(null);
|
20
|
+
const onContext = (context) => {
|
21
|
+
contextRef.value = context;
|
22
|
+
};
|
23
|
+
return () => {
|
24
|
+
const context = contextRef.value;
|
25
|
+
const query = context == null ? void 0 : context.query;
|
26
|
+
return h2(
|
27
|
+
PopoverSlash,
|
28
|
+
{
|
29
|
+
".editor": editor,
|
30
|
+
".onContext": onContext
|
31
|
+
},
|
32
|
+
() => {
|
33
|
+
var _a;
|
34
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots, { query });
|
35
|
+
}
|
36
|
+
);
|
37
|
+
};
|
38
|
+
}
|
39
|
+
);
|
40
|
+
export {
|
41
|
+
PopoverSlash2 as PopoverSlash
|
42
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/popover-suggestion-consumer.gen.ts
|
2
|
+
import "@prosekit/lit/elements/popover-suggestion-consumer";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var PopoverSuggestionConsumer = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-popover-suggestion-consumer", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
PopoverSuggestionConsumer
|
14
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
// src/components/popover-suggestion.ts
|
2
|
+
import { defineComponent as defineComponent2, h as h2, ref } from "vue";
|
3
|
+
|
4
|
+
// src/components/popover-suggestion.gen.ts
|
5
|
+
import "@prosekit/lit/elements/popover-suggestion";
|
6
|
+
import { defineComponent, h } from "vue";
|
7
|
+
var PopoverSuggestion = defineComponent(
|
8
|
+
(props, { slots }) => {
|
9
|
+
return () => {
|
10
|
+
var _a;
|
11
|
+
return h("prosekit-popover-suggestion", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
12
|
+
};
|
13
|
+
}
|
14
|
+
);
|
15
|
+
|
16
|
+
// src/components/popover-suggestion.ts
|
17
|
+
var PopoverSuggestion2 = defineComponent2(
|
18
|
+
({ editor, rules }, { slots }) => {
|
19
|
+
const contextRef = ref(null);
|
20
|
+
const onContext = (context) => {
|
21
|
+
contextRef.value = context;
|
22
|
+
};
|
23
|
+
return () => {
|
24
|
+
const context = contextRef.value;
|
25
|
+
return h2(
|
26
|
+
PopoverSuggestion,
|
27
|
+
{
|
28
|
+
".editor": editor,
|
29
|
+
".rules": rules,
|
30
|
+
".onContext": onContext
|
31
|
+
},
|
32
|
+
() => {
|
33
|
+
var _a;
|
34
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots, context);
|
35
|
+
}
|
36
|
+
);
|
37
|
+
};
|
38
|
+
}
|
39
|
+
);
|
40
|
+
export {
|
41
|
+
PopoverSuggestion2 as PopoverSuggestion
|
42
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/popover.gen.ts
|
2
|
+
import "@prosekit/lit/elements/popover";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var Popover = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-popover", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
Popover
|
14
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/popover2.gen.ts
|
2
|
+
import "@prosekit/lit/elements/popover2";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var Popover2 = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-popover2", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
Popover2
|
14
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// src/components/slash-popover.gen.ts
|
2
|
+
import "@prosekit/lit/elements/slash-popover";
|
3
|
+
import { defineComponent, h } from "vue";
|
4
|
+
var SlashPopover = defineComponent(
|
5
|
+
(props, { slots }) => {
|
6
|
+
return () => {
|
7
|
+
var _a;
|
8
|
+
return h("prosekit-slash-popover", props, (_a = slots.default) == null ? void 0 : _a.call(slots));
|
9
|
+
};
|
10
|
+
}
|
11
|
+
);
|
12
|
+
export {
|
13
|
+
SlashPopover
|
14
|
+
};
|
@@ -0,0 +1,88 @@
|
|
1
|
+
// src/components/prosekit.ts
|
2
|
+
import { ProseKitError as ProseKitError2, createEditor } from "@prosekit/core";
|
3
|
+
import { computed, defineComponent, effect } from "vue";
|
4
|
+
|
5
|
+
// src/injection/editor-injection.ts
|
6
|
+
import { ProseKitError } from "@prosekit/core";
|
7
|
+
import { inject, provide } from "vue";
|
8
|
+
var symbol = Symbol("ProseKitContext");
|
9
|
+
function provideEditor(editor) {
|
10
|
+
provide(symbol, editor);
|
11
|
+
}
|
12
|
+
function injectEditor() {
|
13
|
+
const editor = inject(symbol);
|
14
|
+
if (!editor) {
|
15
|
+
throw new ProseKitError("Can't inject editor");
|
16
|
+
}
|
17
|
+
return editor;
|
18
|
+
}
|
19
|
+
|
20
|
+
// src/components/prosekit.ts
|
21
|
+
var ProseKit = defineComponent(
|
22
|
+
(props, { slots }) => {
|
23
|
+
const editorRef = useComputedEditor(props);
|
24
|
+
provideEditor(editorRef.value);
|
25
|
+
effect(() => {
|
26
|
+
const editor = editorRef.value;
|
27
|
+
if (props.place) {
|
28
|
+
editor.mount(props.place);
|
29
|
+
} else if (editor.mounted) {
|
30
|
+
editor.unmount();
|
31
|
+
}
|
32
|
+
});
|
33
|
+
return () => {
|
34
|
+
var _a;
|
35
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots);
|
36
|
+
};
|
37
|
+
},
|
38
|
+
{ props: ["editor", "extension", "place"] }
|
39
|
+
);
|
40
|
+
function useComputedEditor(props) {
|
41
|
+
return computed(() => {
|
42
|
+
if (props.editor) {
|
43
|
+
if (props.extension) {
|
44
|
+
throw new ProseKitError2(
|
45
|
+
"You can't pass both an editor and an extension to ProseKit"
|
46
|
+
);
|
47
|
+
}
|
48
|
+
return props.editor;
|
49
|
+
} else {
|
50
|
+
if (props.extension) {
|
51
|
+
return createEditor({ extension: props.extension });
|
52
|
+
} else {
|
53
|
+
throw new ProseKitError2(
|
54
|
+
"You must pass either an editor or an extension to ProseKit"
|
55
|
+
);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
// src/hooks/use-keymap.ts
|
62
|
+
import { addKeymap } from "@prosekit/core";
|
63
|
+
import { computed as computed2 } from "vue";
|
64
|
+
|
65
|
+
// src/hooks/use-extension.ts
|
66
|
+
import { effect as effect2 } from "vue";
|
67
|
+
|
68
|
+
// src/hooks/use-editor.ts
|
69
|
+
function useEditor() {
|
70
|
+
return injectEditor();
|
71
|
+
}
|
72
|
+
|
73
|
+
// src/hooks/use-extension.ts
|
74
|
+
function useExtension({ extension }) {
|
75
|
+
const editor = useEditor();
|
76
|
+
effect2(() => editor.use(extension));
|
77
|
+
}
|
78
|
+
|
79
|
+
// src/hooks/use-keymap.ts
|
80
|
+
function useKeymap({ keymap }) {
|
81
|
+
const extension = computed2(() => addKeymap(keymap));
|
82
|
+
useExtension({ extension: extension.value });
|
83
|
+
}
|
84
|
+
export {
|
85
|
+
ProseKit,
|
86
|
+
useEditor,
|
87
|
+
useKeymap
|
88
|
+
};
|
package/package.json
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
{
|
2
|
+
"name": "@prosekit/vue",
|
3
|
+
"type": "module",
|
4
|
+
"version": "0.0.0-next-20230627094841",
|
5
|
+
"private": false,
|
6
|
+
"author": {
|
7
|
+
"name": "ocavue",
|
8
|
+
"email": "ocavue@gmail.com"
|
9
|
+
},
|
10
|
+
"license": "MIT",
|
11
|
+
"funding": "https://github.com/sponsors/ocavue",
|
12
|
+
"homepage": "https://github.com/ocavue/prosekit#readme",
|
13
|
+
"repository": {
|
14
|
+
"type": "git",
|
15
|
+
"url": "git+https://github.com/ocavue/prosekit.git",
|
16
|
+
"directory": "packages/vue"
|
17
|
+
},
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/ocavue/prosekit/issues"
|
20
|
+
},
|
21
|
+
"keywords": [
|
22
|
+
"ProseMirror"
|
23
|
+
],
|
24
|
+
"sideEffects": false,
|
25
|
+
"main": "./dist/prosekit-vue.js",
|
26
|
+
"module": "./dist/prosekit-vue.js",
|
27
|
+
"exports": {
|
28
|
+
".": {
|
29
|
+
"types": "./dist/prosekit-vue.d.ts",
|
30
|
+
"import": "./dist/prosekit-vue.js",
|
31
|
+
"default": "./dist/prosekit-vue.js"
|
32
|
+
},
|
33
|
+
"./components/menu": {
|
34
|
+
"types": "./dist/prosekit-vue-components-menu.d.ts",
|
35
|
+
"import": "./dist/prosekit-vue-components-menu.js",
|
36
|
+
"default": "./dist/prosekit-vue-components-menu.js"
|
37
|
+
},
|
38
|
+
"./components/menu-item": {
|
39
|
+
"types": "./dist/prosekit-vue-components-menu-item.d.ts",
|
40
|
+
"import": "./dist/prosekit-vue-components-menu-item.js",
|
41
|
+
"default": "./dist/prosekit-vue-components-menu-item.js"
|
42
|
+
},
|
43
|
+
"./components/popover": {
|
44
|
+
"types": "./dist/prosekit-vue-components-popover.d.ts",
|
45
|
+
"import": "./dist/prosekit-vue-components-popover.js",
|
46
|
+
"default": "./dist/prosekit-vue-components-popover.js"
|
47
|
+
},
|
48
|
+
"./components/popover-suggestion": {
|
49
|
+
"types": "./dist/prosekit-vue-components-popover-suggestion.d.ts",
|
50
|
+
"import": "./dist/prosekit-vue-components-popover-suggestion.js",
|
51
|
+
"default": "./dist/prosekit-vue-components-popover-suggestion.js"
|
52
|
+
}
|
53
|
+
},
|
54
|
+
"files": [
|
55
|
+
"dist"
|
56
|
+
],
|
57
|
+
"dependencies": {
|
58
|
+
"@prosekit/core": "0.0.0-next-20230627094841",
|
59
|
+
"@prosekit/lit": "0.0.0-next-20230627094841"
|
60
|
+
},
|
61
|
+
"peerDependencies": {
|
62
|
+
"vue": ">= 3.0.0"
|
63
|
+
},
|
64
|
+
"peerDependenciesMeta": {
|
65
|
+
"vue": {
|
66
|
+
"optional": true
|
67
|
+
}
|
68
|
+
},
|
69
|
+
"devDependencies": {
|
70
|
+
"tsup": "^7.1.0",
|
71
|
+
"typescript": "^5.1.3",
|
72
|
+
"vitest": "^0.32.2",
|
73
|
+
"vue": "^3.3.4",
|
74
|
+
"@prosekit/dev": "0.0.0"
|
75
|
+
},
|
76
|
+
"scripts": {
|
77
|
+
"build:tsup": "tsup",
|
78
|
+
"build:tsc": "tsc -b tsconfig.json"
|
79
|
+
},
|
80
|
+
"types": "./dist/prosekit-vue.d.ts"
|
81
|
+
}
|