@cgboiler/biz-basic 1.0.2 → 1.0.4
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/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/rich-text-editor/RichTextEditor.d.ts +8 -1
- package/es/rich-text-editor/RichTextEditor.js +21 -43
- package/es/rich-text-editor/_atomic.css +0 -2
- package/es/rich-text-editor/index.css +1 -1
- package/es/rich-text-editor/index.less +5 -0
- package/es/rich-text-editor/types.d.ts +10 -1
- package/es/rich-text-editor/types.js +3 -0
- package/es/rich-text-editor/useExtensions.d.ts +1 -0
- package/es/rich-text-editor/useExtensions.js +69 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/rich-text-editor/RichTextEditor.d.ts +8 -1
- package/lib/rich-text-editor/RichTextEditor.js +21 -53
- package/lib/rich-text-editor/_atomic.css +0 -2
- package/lib/rich-text-editor/index.css +1 -1
- package/lib/rich-text-editor/index.less +5 -0
- package/lib/rich-text-editor/types.d.ts +10 -1
- package/lib/rich-text-editor/types.js +3 -0
- package/lib/rich-text-editor/useExtensions.d.ts +1 -0
- package/lib/rich-text-editor/useExtensions.js +98 -0
- package/package.json +2 -1
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -8,7 +8,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
8
8
|
type: StringConstructor;
|
|
9
9
|
default: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
onMentionTriggered: {
|
|
12
|
+
type: FunctionConstructor;
|
|
13
|
+
};
|
|
14
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mention-triggered" | "update:modelValue")[], "mention-triggered" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
15
|
modelValue: {
|
|
13
16
|
type: StringConstructor;
|
|
14
17
|
default: string;
|
|
@@ -17,7 +20,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
17
20
|
type: StringConstructor;
|
|
18
21
|
default: string;
|
|
19
22
|
};
|
|
23
|
+
onMentionTriggered: {
|
|
24
|
+
type: FunctionConstructor;
|
|
25
|
+
};
|
|
20
26
|
}>> & Readonly<{
|
|
27
|
+
"onMention-triggered"?: ((...args: any[]) => any) | undefined;
|
|
21
28
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
22
29
|
}>, {
|
|
23
30
|
modelValue: string;
|
|
@@ -1,60 +1,26 @@
|
|
|
1
1
|
import { createVNode as _createVNode } from "vue";
|
|
2
2
|
import "./_atomic.css";
|
|
3
3
|
import { defineComponent, onMounted, onBeforeUnmount, ref, watch } from "vue";
|
|
4
|
-
import StarterKit from "@tiptap/starter-kit";
|
|
5
4
|
import { Editor, EditorContent } from "@tiptap/vue-3";
|
|
6
|
-
import {
|
|
7
|
-
import { ListKit } from "@tiptap/extension-list";
|
|
8
|
-
import Image from "@tiptap/extension-image";
|
|
9
|
-
import { Placeholder } from "@tiptap/extensions";
|
|
5
|
+
import { useExtensions } from "./useExtensions";
|
|
10
6
|
import { richTextEditorProps } from "./types";
|
|
11
7
|
import "./index.css";
|
|
12
8
|
var stdin_default = defineComponent({
|
|
13
9
|
name: "RichTextEditor",
|
|
14
10
|
props: richTextEditorProps,
|
|
15
|
-
emits: ["update:modelValue"],
|
|
11
|
+
emits: ["update:modelValue", "mention-triggered"],
|
|
16
12
|
setup(props, {
|
|
17
|
-
emit
|
|
13
|
+
emit,
|
|
14
|
+
expose
|
|
18
15
|
}) {
|
|
19
16
|
const editor = ref();
|
|
17
|
+
const extensions = useExtensions({
|
|
18
|
+
props,
|
|
19
|
+
emit
|
|
20
|
+
});
|
|
20
21
|
const initEditor = () => {
|
|
21
22
|
editor.value = new Editor({
|
|
22
|
-
extensions
|
|
23
|
-
addKeyboardShortcuts() {
|
|
24
|
-
return {
|
|
25
|
-
Tab: ({
|
|
26
|
-
editor: editor2
|
|
27
|
-
}) => {
|
|
28
|
-
const {
|
|
29
|
-
$from
|
|
30
|
-
} = editor2.state.selection;
|
|
31
|
-
const currentItem = $from.node(-1);
|
|
32
|
-
if (currentItem.type.name === "listItem") {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
},
|
|
37
|
-
"Shift-Tab": ({
|
|
38
|
-
editor: editor2
|
|
39
|
-
}) => {
|
|
40
|
-
const {
|
|
41
|
-
$from
|
|
42
|
-
} = editor2.state.selection;
|
|
43
|
-
const currentItem = $from.node(-1);
|
|
44
|
-
if (currentItem.type.name === "doc") {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}), Image, TableKit.configure({
|
|
52
|
-
table: {
|
|
53
|
-
resizable: true
|
|
54
|
-
}
|
|
55
|
-
}), Placeholder.configure({
|
|
56
|
-
placeholder: props.placeholder
|
|
57
|
-
})],
|
|
23
|
+
extensions,
|
|
58
24
|
content: props.modelValue,
|
|
59
25
|
onUpdate: ({
|
|
60
26
|
editor: editor2
|
|
@@ -68,6 +34,18 @@ var stdin_default = defineComponent({
|
|
|
68
34
|
}
|
|
69
35
|
});
|
|
70
36
|
};
|
|
37
|
+
const insertMention = (data) => {
|
|
38
|
+
editor.value.commands.insertContent({
|
|
39
|
+
type: "mention",
|
|
40
|
+
attrs: {
|
|
41
|
+
id: data.userId,
|
|
42
|
+
label: data.name
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
expose({
|
|
47
|
+
insertMention
|
|
48
|
+
});
|
|
71
49
|
watch(() => props.modelValue, (newValue) => {
|
|
72
50
|
var _a, _b;
|
|
73
51
|
if (((_a = editor.value) == null ? void 0 : _a.getHTML()) !== newValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
1
|
+
.ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.ProseMirror .mention{color:#c02537;padding:0 .3em}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
export interface MentionData {
|
|
3
|
+
userId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
2
6
|
export declare const richTextEditorProps: {
|
|
3
7
|
modelValue: {
|
|
4
8
|
type: StringConstructor;
|
|
@@ -8,5 +12,10 @@ export declare const richTextEditorProps: {
|
|
|
8
12
|
type: StringConstructor;
|
|
9
13
|
default: string;
|
|
10
14
|
};
|
|
15
|
+
onMentionTriggered: {
|
|
16
|
+
type: FunctionConstructor;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps> & {
|
|
20
|
+
onMentionTriggered?: () => void;
|
|
11
21
|
};
|
|
12
|
-
export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
2
|
+
import { TableKit } from "@tiptap/extension-table";
|
|
3
|
+
import { ListKit } from "@tiptap/extension-list";
|
|
4
|
+
import Image from "@tiptap/extension-image";
|
|
5
|
+
import Mention from "@tiptap/extension-mention";
|
|
6
|
+
import { Placeholder } from "@tiptap/extensions";
|
|
7
|
+
function useExtensions({ props, emit }) {
|
|
8
|
+
const extensions = [
|
|
9
|
+
StarterKit,
|
|
10
|
+
Image,
|
|
11
|
+
TableKit.configure({
|
|
12
|
+
table: { resizable: true }
|
|
13
|
+
}),
|
|
14
|
+
Placeholder.configure({
|
|
15
|
+
placeholder: () => {
|
|
16
|
+
return props.placeholder;
|
|
17
|
+
}
|
|
18
|
+
}),
|
|
19
|
+
ListKit.extend({
|
|
20
|
+
addKeyboardShortcuts() {
|
|
21
|
+
return {
|
|
22
|
+
Tab: ({ editor }) => {
|
|
23
|
+
const { $from } = editor.state.selection;
|
|
24
|
+
const currentItem = $from.node(-1);
|
|
25
|
+
if (currentItem.type.name === "listItem") {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
"Shift-Tab": ({ editor }) => {
|
|
31
|
+
const { $from } = editor.state.selection;
|
|
32
|
+
const currentItem = $from.node(-1);
|
|
33
|
+
if (currentItem.type.name === "doc") {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
Mention.configure({
|
|
42
|
+
HTMLAttributes: {
|
|
43
|
+
class: "mention"
|
|
44
|
+
},
|
|
45
|
+
deleteTriggerWithBackspace: true,
|
|
46
|
+
suggestion: {
|
|
47
|
+
char: "@",
|
|
48
|
+
allowedPrefixes: null,
|
|
49
|
+
// 允许任何前缀
|
|
50
|
+
render() {
|
|
51
|
+
return {
|
|
52
|
+
onStart({ command }) {
|
|
53
|
+
emit("mention-triggered", (data) => {
|
|
54
|
+
command({
|
|
55
|
+
id: data.userId,
|
|
56
|
+
label: data.name
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
];
|
|
65
|
+
return extensions;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
useExtensions
|
|
69
|
+
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(stdin_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(stdin_exports);
|
|
37
37
|
var import_rich_text_editor = __toESM(require("./rich-text-editor"));
|
|
38
38
|
__reExport(stdin_exports, require("./rich-text-editor"), module.exports);
|
|
39
|
-
const version = "1.0.
|
|
39
|
+
const version = "1.0.3";
|
|
40
40
|
function install(app) {
|
|
41
41
|
const components = [
|
|
42
42
|
import_rich_text_editor.default
|
|
@@ -8,7 +8,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
8
8
|
type: StringConstructor;
|
|
9
9
|
default: string;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
onMentionTriggered: {
|
|
12
|
+
type: FunctionConstructor;
|
|
13
|
+
};
|
|
14
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("mention-triggered" | "update:modelValue")[], "mention-triggered" | "update:modelValue", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
12
15
|
modelValue: {
|
|
13
16
|
type: StringConstructor;
|
|
14
17
|
default: string;
|
|
@@ -17,7 +20,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
17
20
|
type: StringConstructor;
|
|
18
21
|
default: string;
|
|
19
22
|
};
|
|
23
|
+
onMentionTriggered: {
|
|
24
|
+
type: FunctionConstructor;
|
|
25
|
+
};
|
|
20
26
|
}>> & Readonly<{
|
|
27
|
+
"onMention-triggered"?: ((...args: any[]) => any) | undefined;
|
|
21
28
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
22
29
|
}>, {
|
|
23
30
|
modelValue: string;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
var stdin_exports = {};
|
|
29
19
|
__export(stdin_exports, {
|
|
@@ -33,60 +23,26 @@ module.exports = __toCommonJS(stdin_exports);
|
|
|
33
23
|
var import_vue = require("vue");
|
|
34
24
|
var import_atomic = require("./_atomic.css");
|
|
35
25
|
var import_vue2 = require("vue");
|
|
36
|
-
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
37
26
|
var import_vue_3 = require("@tiptap/vue-3");
|
|
38
|
-
var
|
|
39
|
-
var import_extension_list = require("@tiptap/extension-list");
|
|
40
|
-
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
41
|
-
var import_extensions = require("@tiptap/extensions");
|
|
27
|
+
var import_useExtensions = require("./useExtensions");
|
|
42
28
|
var import_types = require("./types");
|
|
43
29
|
var import_index = require("./index.css");
|
|
44
30
|
var stdin_default = (0, import_vue2.defineComponent)({
|
|
45
31
|
name: "RichTextEditor",
|
|
46
32
|
props: import_types.richTextEditorProps,
|
|
47
|
-
emits: ["update:modelValue"],
|
|
33
|
+
emits: ["update:modelValue", "mention-triggered"],
|
|
48
34
|
setup(props, {
|
|
49
|
-
emit
|
|
35
|
+
emit,
|
|
36
|
+
expose
|
|
50
37
|
}) {
|
|
51
38
|
const editor = (0, import_vue2.ref)();
|
|
39
|
+
const extensions = (0, import_useExtensions.useExtensions)({
|
|
40
|
+
props,
|
|
41
|
+
emit
|
|
42
|
+
});
|
|
52
43
|
const initEditor = () => {
|
|
53
44
|
editor.value = new import_vue_3.Editor({
|
|
54
|
-
extensions
|
|
55
|
-
addKeyboardShortcuts() {
|
|
56
|
-
return {
|
|
57
|
-
Tab: ({
|
|
58
|
-
editor: editor2
|
|
59
|
-
}) => {
|
|
60
|
-
const {
|
|
61
|
-
$from
|
|
62
|
-
} = editor2.state.selection;
|
|
63
|
-
const currentItem = $from.node(-1);
|
|
64
|
-
if (currentItem.type.name === "listItem") {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
},
|
|
69
|
-
"Shift-Tab": ({
|
|
70
|
-
editor: editor2
|
|
71
|
-
}) => {
|
|
72
|
-
const {
|
|
73
|
-
$from
|
|
74
|
-
} = editor2.state.selection;
|
|
75
|
-
const currentItem = $from.node(-1);
|
|
76
|
-
if (currentItem.type.name === "doc") {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}), import_extension_image.default, import_extension_table.TableKit.configure({
|
|
84
|
-
table: {
|
|
85
|
-
resizable: true
|
|
86
|
-
}
|
|
87
|
-
}), import_extensions.Placeholder.configure({
|
|
88
|
-
placeholder: props.placeholder
|
|
89
|
-
})],
|
|
45
|
+
extensions,
|
|
90
46
|
content: props.modelValue,
|
|
91
47
|
onUpdate: ({
|
|
92
48
|
editor: editor2
|
|
@@ -100,6 +56,18 @@ var stdin_default = (0, import_vue2.defineComponent)({
|
|
|
100
56
|
}
|
|
101
57
|
});
|
|
102
58
|
};
|
|
59
|
+
const insertMention = (data) => {
|
|
60
|
+
editor.value.commands.insertContent({
|
|
61
|
+
type: "mention",
|
|
62
|
+
attrs: {
|
|
63
|
+
id: data.userId,
|
|
64
|
+
label: data.name
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
expose({
|
|
69
|
+
insertMention
|
|
70
|
+
});
|
|
103
71
|
(0, import_vue2.watch)(() => props.modelValue, (newValue) => {
|
|
104
72
|
var _a, _b;
|
|
105
73
|
if (((_a = editor.value) == null ? void 0 : _a.getHTML()) !== newValue) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
1
|
+
.ProseMirror{flex:1;overflow:auto;outline:none;line-height:1.6;font-size:var(--font-base);--white: #fff;--black: #2e2b29;--gray-1: rgba(61, 37, 20, .05);--gray-2: rgba(61, 37, 20, .08);--gray-3: rgba(61, 37, 20, .12);--gray-4: rgba(53, 38, 28, .3);--gray-5: rgba(28, 25, 23, .6);--green: #22c55e;--purple: #6a00f5;--purple-contrast: #5800cc;--purple-light: rgba(88, 5, 255, .05);--yellow-contrast: #facc15;--yellow: rgba(250, 204, 21, .4);--yellow-light: #fffae5;--red: #ff5c33;--red-light: #ffebe5;--shadow: 0px 12px 33px 0px rgba(0, 0, 0, .06), 0px 3.618px 9.949px 0px rgba(0, 0, 0, .04)}.ProseMirror :first-child{margin-top:0}.ProseMirror ol{list-style:auto}.ProseMirror ul{list-style:disc}.ProseMirror ol,.ProseMirror ul{padding-left:1.5em;margin:0 0 12px}.ProseMirror ol li p,.ProseMirror ul li p{margin-top:.25em;margin-bottom:.25em}.ProseMirror li::marker{text-align:start!important}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;margin-top:2.5rem;text-wrap:pretty}.ProseMirror h1,.ProseMirror h2{margin-top:1rem;margin-bottom:1rem}.ProseMirror h1{font-size:1.4rem}.ProseMirror h2{font-size:1.2rem}.ProseMirror h3{font-size:1.1rem}.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{font-size:1rem}.ProseMirror code{background-color:var(--purple-light);border-radius:.4rem;color:var(--black);font-size:.85rem;padding:.25em .3em}.ProseMirror pre{background:var(--black);border-radius:.5rem;color:var(--white);font-family:JetBrainsMono,monospace;margin:1.5rem 0;padding:.75rem 1rem}.ProseMirror pre code{background:none;color:inherit;font-size:.8rem;padding:0}.ProseMirror blockquote{border-left:3px solid var(--gray-3);margin:1.5rem 0;padding-left:1rem}.ProseMirror hr{border:none;border-top:1px solid var(--gray-2);margin:2rem 0}.ProseMirror p.is-editor-empty:first-child:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror .is-empty:before{color:var(--gray-4);content:attr(data-placeholder);float:left;height:0;pointer-events:none}.ProseMirror table{border-collapse:collapse;margin:0;overflow:hidden;table-layout:fixed;width:100%}.ProseMirror table td,.ProseMirror table th{border:1px solid var(--gray-3);box-sizing:border-box;min-width:1em;padding:6px 8px;position:relative;vertical-align:top}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{background-color:var(--gray-1);font-weight:700;text-align:left}.ProseMirror table .selectedCell:after{background:var(--gray-2);content:"";left:0;right:0;top:0;bottom:0;pointer-events:none;position:absolute;z-index:2}.ProseMirror table .column-resize-handle{background-color:var(--purple);bottom:-2px;pointer-events:none;position:absolute;right:-2px;top:0;width:4px}.ProseMirror .tableWrapper{margin:1.5rem 0;overflow-x:auto}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror img{max-width:100%}.ProseMirror .mention{color:#c02537;padding:0 .3em}.animation-indent--right{animation:indent-right .5s cubic-bezier(.68,-.55,.27,1.55) 1 alternate-reverse}@keyframes indent-right{0%{transform:translate(0)}to{transform:translate(12px)}}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
export interface MentionData {
|
|
3
|
+
userId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
2
6
|
export declare const richTextEditorProps: {
|
|
3
7
|
modelValue: {
|
|
4
8
|
type: StringConstructor;
|
|
@@ -8,5 +12,10 @@ export declare const richTextEditorProps: {
|
|
|
8
12
|
type: StringConstructor;
|
|
9
13
|
default: string;
|
|
10
14
|
};
|
|
15
|
+
onMentionTriggered: {
|
|
16
|
+
type: FunctionConstructor;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps> & {
|
|
20
|
+
onMentionTriggered?: () => void;
|
|
11
21
|
};
|
|
12
|
-
export type RichTextEditorProps = ExtractPropTypes<typeof richTextEditorProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useExtensions({ props, emit }: any): (import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-table").TableKitOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-list").ListKitOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>)[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var stdin_exports = {};
|
|
29
|
+
__export(stdin_exports, {
|
|
30
|
+
useExtensions: () => useExtensions
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
33
|
+
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
34
|
+
var import_extension_table = require("@tiptap/extension-table");
|
|
35
|
+
var import_extension_list = require("@tiptap/extension-list");
|
|
36
|
+
var import_extension_image = __toESM(require("@tiptap/extension-image"));
|
|
37
|
+
var import_extension_mention = __toESM(require("@tiptap/extension-mention"));
|
|
38
|
+
var import_extensions = require("@tiptap/extensions");
|
|
39
|
+
function useExtensions({ props, emit }) {
|
|
40
|
+
const extensions = [
|
|
41
|
+
import_starter_kit.default,
|
|
42
|
+
import_extension_image.default,
|
|
43
|
+
import_extension_table.TableKit.configure({
|
|
44
|
+
table: { resizable: true }
|
|
45
|
+
}),
|
|
46
|
+
import_extensions.Placeholder.configure({
|
|
47
|
+
placeholder: () => {
|
|
48
|
+
return props.placeholder;
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
import_extension_list.ListKit.extend({
|
|
52
|
+
addKeyboardShortcuts() {
|
|
53
|
+
return {
|
|
54
|
+
Tab: ({ editor }) => {
|
|
55
|
+
const { $from } = editor.state.selection;
|
|
56
|
+
const currentItem = $from.node(-1);
|
|
57
|
+
if (currentItem.type.name === "listItem") {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
},
|
|
62
|
+
"Shift-Tab": ({ editor }) => {
|
|
63
|
+
const { $from } = editor.state.selection;
|
|
64
|
+
const currentItem = $from.node(-1);
|
|
65
|
+
if (currentItem.type.name === "doc") {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
import_extension_mention.default.configure({
|
|
74
|
+
HTMLAttributes: {
|
|
75
|
+
class: "mention"
|
|
76
|
+
},
|
|
77
|
+
deleteTriggerWithBackspace: true,
|
|
78
|
+
suggestion: {
|
|
79
|
+
char: "@",
|
|
80
|
+
allowedPrefixes: null,
|
|
81
|
+
// 允许任何前缀
|
|
82
|
+
render() {
|
|
83
|
+
return {
|
|
84
|
+
onStart({ command }) {
|
|
85
|
+
emit("mention-triggered", (data) => {
|
|
86
|
+
command({
|
|
87
|
+
id: data.userId,
|
|
88
|
+
label: data.name
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
return extensions;
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cgboiler/biz-basic",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@tiptap/extension-collaboration": "3.0.0-beta.16",
|
|
42
42
|
"@tiptap/extension-image": "^3.0.7",
|
|
43
43
|
"@tiptap/extension-list": "^3.0.7",
|
|
44
|
+
"@tiptap/extension-mention": "^3.0.7",
|
|
44
45
|
"@tiptap/extension-table": "3.0.0-beta.5",
|
|
45
46
|
"@tiptap/extensions": "3.0.0-beta.5",
|
|
46
47
|
"@tiptap/pm": "3.0.0-beta.5",
|