@voicenter-team/voicenter-ui-plus 3.4.4 → 3.4.5
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 +502 -502
- package/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcAvatar/VcAvatar.css +1 -0
- package/library/assets/components/VcBadgeTag/VcBadgeTag.css +1 -0
- package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -0
- package/library/assets/components/VcEmojiPicker/VcEmojiPicker.css +1 -0
- package/library/assets/components/VcFileUploader/VcFileItem.css +1 -0
- package/library/assets/components/VcFileUploader/VcFileUploaderArea.css +1 -1
- package/library/assets/components/VcFileUploader/VcFileUploaderSimple.css +1 -1
- package/library/assets/components/VcJsonSchema/Components/JsonSchemaEditor.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Circles.css +1 -1
- package/library/assets/components/VcLoading/Loaders/DotSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LdsSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LoadIcon.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Stretch.css +1 -1
- package/library/assets/components/VcLoading/VcLoading.css +1 -1
- package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
- package/library/assets/components/VcMessage/VcMessage.css +1 -0
- package/library/assets/components/VcMessage/content/VcMessageAudioBlock.css +1 -0
- package/library/assets/components/VcMessage/content/VcMessageFileBlock.css +1 -0
- package/library/assets/components/VcMessage/content/VcMessageImageBlock.css +1 -0
- package/library/assets/components/VcMessage/content/VcMessageTextBlock.css +1 -0
- package/library/assets/components/VcMessage/reactions/VcMessageEmojiPicker.css +1 -0
- package/library/assets/components/VcMessage/reactions/VcMessageReactionBar.css +1 -0
- package/library/assets/components/VcMessagesWrapper/VcMessagesWrapper.css +1 -0
- package/library/assets/components/VcSkeletonLoader/Loaders/Card.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Circle.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Row.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Square.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Text.css +1 -1
- package/library/components/VcAvatar/VcAvatar.vue.mjs +62 -0
- package/library/components/VcAvatar/VcAvatar.vue3.mjs +5 -0
- package/library/components/VcBadgeTag/VcBadgeTag.vue.mjs +31 -0
- package/library/components/VcBadgeTag/VcBadgeTag.vue3.mjs +5 -0
- package/library/components/VcChatComposer/VcChatComposer.vue.mjs +554 -0
- package/library/components/VcChatComposer/VcChatComposer.vue3.mjs +5 -0
- package/library/components/VcChatComposer/richText.mjs +320 -0
- package/library/components/VcEmojiPicker/VcEmojiPicker.vue.mjs +387 -0
- package/library/components/VcEmojiPicker/VcEmojiPicker.vue3.mjs +5 -0
- package/library/components/VcEmojiPicker/emojiData.mjs +26 -0
- package/library/components/VcFileUploader/VcFileItem.vue.mjs +146 -0
- package/library/components/VcFileUploader/VcFileItem.vue3.mjs +5 -0
- package/library/components/VcFileUploader/VcFileUploaderArea.vue.mjs +24 -147
- package/library/components/VcFileUploader/VcFileUploaderSimple.vue.mjs +1 -1
- package/library/components/VcJsonSchema/Components/JsonSchemaEditor.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Circles.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue2.mjs +2 -2
- package/library/components/VcLoading/Loaders/LdsSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/LoadIcon.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue2.mjs +1 -1
- package/library/components/VcLoading/VcLoading.vue.mjs +1 -1
- package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
- package/library/components/VcMessage/VcMessage.vue.mjs +212 -0
- package/library/components/VcMessage/VcMessage.vue3.mjs +5 -0
- package/library/components/VcMessage/content/VcMessageAudioBlock.vue.mjs +53 -0
- package/library/components/VcMessage/content/VcMessageAudioBlock.vue3.mjs +5 -0
- package/library/components/VcMessage/content/VcMessageFileBlock.vue.mjs +80 -0
- package/library/components/VcMessage/content/VcMessageFileBlock.vue3.mjs +5 -0
- package/library/components/VcMessage/content/VcMessageImageBlock.vue.mjs +57 -0
- package/library/components/VcMessage/content/VcMessageImageBlock.vue3.mjs +5 -0
- package/library/components/VcMessage/content/VcMessageTextBlock.vue.mjs +19 -0
- package/library/components/VcMessage/content/VcMessageTextBlock.vue3.mjs +5 -0
- package/library/components/VcMessage/content/messageContentComponents.mjs +17 -0
- package/library/components/VcMessage/reactions/VcMessageEmojiPicker.vue.mjs +167 -0
- package/library/components/VcMessage/reactions/VcMessageEmojiPicker.vue3.mjs +5 -0
- package/library/components/VcMessage/reactions/VcMessageReactionBar.vue.mjs +82 -0
- package/library/components/VcMessage/reactions/VcMessageReactionBar.vue3.mjs +5 -0
- package/library/components/VcMessage/reactions/emojis.mjs +4 -0
- package/library/components/VcMessagesWrapper/VcMessagesWrapper.vue.mjs +243 -0
- package/library/components/VcMessagesWrapper/VcMessagesWrapper.vue3.mjs +5 -0
- package/library/components/VcSkeletonLoader/Loaders/Card.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Circle.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Row.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Square.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Text.vue.mjs +1 -1
- package/library/components/VcSoundplayer/useSoundPlayerProvideInject.mjs +1 -1
- package/library/composables/useAudioRecorder.mjs +120 -0
- package/library/enum/fileTypes.mjs +51 -0
- package/library/index.mjs +237 -216
- package/library/index.mjs.br +0 -0
- package/library/index.mjs.gz +0 -0
- package/library/localization/index.mjs.gz +0 -0
- package/library/localization/locales/en.json.mjs +24 -1
- package/library/plugin-components.gen.mjs +171 -150
- package/library/plugin.mjs +235 -214
- package/library/plugin.mjs.br +0 -0
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +42 -16
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/theme/index.mjs.gz +0 -0
- package/library/types/components/VcAvatar/VcAvatar.vue.d.ts +47 -0
- package/library/types/components/VcBadgeTag/VcBadgeTag.vue.d.ts +42 -0
- package/library/types/components/VcChatComposer/VcChatComposer.vue.d.ts +81 -0
- package/library/types/components/VcChatComposer/richText.d.ts +12 -0
- package/library/types/components/VcCollapse/VcCollapseItem.vue.d.ts +1 -1
- package/library/types/components/VcEmojiPicker/VcEmojiPicker.vue.d.ts +63 -0
- package/library/types/components/VcEmojiPicker/emojiData.d.ts +16 -0
- package/library/types/components/VcExcelUploader/VcExcelFileUploadBlock.vue.d.ts +1 -1
- package/library/types/components/VcExtendedDatetimeRangePicker/VcExtendedDatetimeRangePicker.vue.d.ts +2 -2
- package/library/types/components/VcFileUploader/VcFileItem.vue.d.ts +85 -0
- package/library/types/components/VcFileUploader/VcFileUploader.vue.d.ts +3 -3
- package/library/types/components/VcFileUploader/VcFileUploaderArea.vue.d.ts +17 -18
- package/library/types/components/VcFileUploader/VcFileUploaderSimple.vue.d.ts +3 -3
- package/library/types/components/VcForm/VcForm.vue.d.ts +1 -1
- package/library/types/components/VcMessage/VcMessage.vue.d.ts +66 -0
- package/library/types/components/VcMessage/content/VcMessageAudioBlock.vue.d.ts +24 -0
- package/library/types/components/VcMessage/content/VcMessageFileBlock.vue.d.ts +24 -0
- package/library/types/components/VcMessage/content/VcMessageImageBlock.vue.d.ts +28 -0
- package/library/types/components/VcMessage/content/VcMessageTextBlock.vue.d.ts +24 -0
- package/library/types/components/VcMessage/content/messageContentComponents.d.ts +3 -0
- package/library/types/components/VcMessage/reactions/VcMessageEmojiPicker.vue.d.ts +68 -0
- package/library/types/components/VcMessage/reactions/VcMessageReactionBar.vue.d.ts +28 -0
- package/library/types/components/VcMessage/reactions/emojis.d.ts +1 -0
- package/library/types/components/VcMessagesWrapper/VcMessagesWrapper.vue.d.ts +71 -0
- package/library/types/components/VcProgress/VcProgress.vue.d.ts +1 -1
- package/library/types/components/VcRadioGroup/VcRadioGroup.vue.d.ts +3 -3
- package/library/types/components/VcSelect/VcInfiniteScrollSelect.vue.d.ts +6 -6
- package/library/types/components/VcSelect/VcSelect.vue.d.ts +6 -6
- package/library/types/components/VcSelect/VcSelectGrouped.vue.d.ts +6 -6
- package/library/types/components/VcSelect/VcSelectOption.vue.d.ts +3 -3
- package/library/types/components/VcTree/VcTree.vue.d.ts +6 -6
- package/library/types/components/VcTree/VcTreeSelect.vue.d.ts +3 -3
- package/library/types/components/VcWizard/VcSummaryStep.vue.d.ts +1 -1
- package/library/types/components/VcWizard/VcWizardSummary.vue.d.ts +1 -1
- package/library/types/components/exports.d.ts +15 -1
- package/library/types/components.gen.d.ts +7 -0
- package/library/types/composables/useAudioRecorder.d.ts +18 -0
- package/library/types/entity/components/Button/VcEntityDeleteIconButton.vue.d.ts +3 -3
- package/library/types/enum/fileTypes.d.ts +3 -0
- package/library/types/localization/locales/en.json.d.ts +187 -164
- package/library/types/theme/themes.json.d.ts +227 -227
- package/library/types/types/VcAvatar.types.d.ts +35 -0
- package/library/types/types/VcBadgeTag.types.d.ts +19 -0
- package/library/types/types/VcChatComposer.types.d.ts +112 -0
- package/library/types/types/VcEmojiPicker.types.d.ts +20 -0
- package/library/types/types/VcFileUploader.types.d.ts +4 -0
- package/library/types/types/VcMessage.types.d.ts +131 -0
- package/library/types/types/VcMessagesWrapper.types.d.ts +61 -0
- package/library/types/types/index.d.ts +6 -0
- package/library/utils/jsonSchema/index.mjs.gz +0 -0
- package/package.json +215 -185
- package/src/theme/index.ts +101 -101
- package/src/theme/tailwindScheme.js +37 -37
- package/src/theme/theme.types.ts +31 -31
- package/src/theme/themeMerge.ts +40 -40
- package/src/theme/themes.json +227 -227
- package/tailwind.config.d.ts +5 -5
- package/tailwind.config.js +192 -192
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import '../../assets/components/VcBadgeTag/VcBadgeTag.css';
|
|
2
|
+
import { defineComponent, computed, openBlock, createElementBlock, normalizeStyle, normalizeClass, renderSlot, createTextVNode, toDisplayString } from "vue";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
__name: "VcBadgeTag",
|
|
5
|
+
props: {
|
|
6
|
+
value: { default: void 0 },
|
|
7
|
+
size: { default: "md" },
|
|
8
|
+
color: { default: "var(--primary-actions)" },
|
|
9
|
+
textColor: { default: "var(--btn-filled-text)" }
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const styleVariables = computed(() => ({
|
|
14
|
+
"--vc-badge-tag-bg": props.color,
|
|
15
|
+
"--vc-badge-tag-text": props.textColor
|
|
16
|
+
}));
|
|
17
|
+
return (_ctx, _cache) => {
|
|
18
|
+
return openBlock(), createElementBlock("span", {
|
|
19
|
+
class: normalizeClass([`vc-badge-tag--${__props.size}`, "vc-badge-tag"]),
|
|
20
|
+
style: normalizeStyle(styleVariables.value)
|
|
21
|
+
}, [
|
|
22
|
+
renderSlot(_ctx.$slots, "default", {}, () => [
|
|
23
|
+
createTextVNode(toDisplayString(__props.value), 1)
|
|
24
|
+
])
|
|
25
|
+
], 6);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
_sfc_main as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import '../../assets/components/VcChatComposer/VcChatComposer.css';
|
|
2
|
+
import { defineComponent, reactive, ref, computed, watch, onBeforeUnmount, openBlock, createElementBlock, withModifiers, normalizeClass, createVNode, unref, createElementVNode, toDisplayString, createCommentVNode, Fragment, renderList, createBlock, withDirectives, Teleport, vShow, createTextVNode, withCtx } from "vue";
|
|
3
|
+
import { Extension, useEditor, EditorContent } from "@tiptap/vue-3";
|
|
4
|
+
import Document from "@tiptap/extension-document";
|
|
5
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
6
|
+
import Text from "@tiptap/extension-text";
|
|
7
|
+
import Bold from "@tiptap/extension-bold";
|
|
8
|
+
import Italic from "@tiptap/extension-italic";
|
|
9
|
+
import Strike from "@tiptap/extension-strike";
|
|
10
|
+
import Code from "@tiptap/extension-code";
|
|
11
|
+
import Mention from "@tiptap/extension-mention";
|
|
12
|
+
import { UndoRedo, Placeholder } from "@tiptap/extensions";
|
|
13
|
+
import { Upload, Trash2, Square, Paperclip, Mic, SendHorizontal } from "@lucide/vue";
|
|
14
|
+
import _sfc_main$5 from "../VcAvatar/VcAvatar.vue.mjs";
|
|
15
|
+
import '../../assets/components/VcSoundplayer/VcSoundPlayer.css';import '../../assets/components/VcIcon/VcIcon.css';import '../../assets/components/VcFileUploader/VcFileItem.css';import '../../assets/components/VcEmojiPicker/VcEmojiPicker.css';import '../../assets/components/VcButton/VcButtonIcon.css';import '../../assets/components/VcButton/VcButton.css';import '../../assets/components/VcAvatar/VcAvatar.css';/* empty css */
|
|
16
|
+
import _sfc_main$7 from "../VcButton/VcButton.vue.mjs";
|
|
17
|
+
/* empty css */
|
|
18
|
+
import _sfc_main$3 from "../VcButton/VcButtonIcon.vue.mjs";
|
|
19
|
+
/* empty css */
|
|
20
|
+
import _sfc_main$6 from "../VcEmojiPicker/VcEmojiPicker.vue.mjs";
|
|
21
|
+
/* empty css */
|
|
22
|
+
import _sfc_main$2 from "../VcFileUploader/VcFileItem.vue.mjs";
|
|
23
|
+
/* empty css */
|
|
24
|
+
import _sfc_main$1 from "../VcIcon/VcIcon.vue.mjs";
|
|
25
|
+
/* empty css */
|
|
26
|
+
import _sfc_main$4 from "../VcSoundplayer/VcSoundPlayer.vue.mjs";
|
|
27
|
+
/* empty css */
|
|
28
|
+
import useFileUploader from "../../composables/input/useFileUploader.mjs";
|
|
29
|
+
import useAudioRecorder from "../../composables/useAudioRecorder.mjs";
|
|
30
|
+
import { tVU } from "../../localization/index.mjs";
|
|
31
|
+
import { resolveFormat, richTextToDoc, docToRichText } from "./richText.mjs";
|
|
32
|
+
const _hoisted_1 = {
|
|
33
|
+
key: 0,
|
|
34
|
+
class: "vc-chat-composer__drop"
|
|
35
|
+
};
|
|
36
|
+
const _hoisted_2 = { class: "vc-chat-composer__drop-title" };
|
|
37
|
+
const _hoisted_3 = {
|
|
38
|
+
key: 0,
|
|
39
|
+
class: "vc-chat-composer__drop-hint"
|
|
40
|
+
};
|
|
41
|
+
const _hoisted_4 = {
|
|
42
|
+
key: 1,
|
|
43
|
+
class: "vc-chat-composer__attachments"
|
|
44
|
+
};
|
|
45
|
+
const _hoisted_5 = {
|
|
46
|
+
key: 2,
|
|
47
|
+
class: "vc-chat-composer__recording"
|
|
48
|
+
};
|
|
49
|
+
const _hoisted_6 = { class: "vc-chat-composer__recording-time" };
|
|
50
|
+
const _hoisted_7 = {
|
|
51
|
+
key: 3,
|
|
52
|
+
class: "vc-chat-composer__voice"
|
|
53
|
+
};
|
|
54
|
+
const _hoisted_8 = { class: "vc-chat-composer__editor-wrapper" };
|
|
55
|
+
const _hoisted_9 = ["aria-selected", "onMousedown"];
|
|
56
|
+
const _hoisted_10 = { class: "vc-chat-composer__toolbar" };
|
|
57
|
+
const _hoisted_11 = { class: "vc-chat-composer__actions" };
|
|
58
|
+
const _hoisted_12 = ["accept"];
|
|
59
|
+
const _hoisted_13 = { class: "vc-chat-composer__hint" };
|
|
60
|
+
const _hoisted_14 = {
|
|
61
|
+
key: 4,
|
|
62
|
+
class: "vc-chat-composer__error"
|
|
63
|
+
};
|
|
64
|
+
const MAX_MENTION_SUGGESTIONS = 8;
|
|
65
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
66
|
+
__name: "VcChatComposer",
|
|
67
|
+
props: {
|
|
68
|
+
modelValue: {},
|
|
69
|
+
format: { default: "entities" },
|
|
70
|
+
formats: { default: () => ["bold", "italic", "strike", "code"] },
|
|
71
|
+
mentions: { default: () => [] },
|
|
72
|
+
attachments: { default: () => [] },
|
|
73
|
+
placeholder: { default: void 0 },
|
|
74
|
+
disabled: { type: Boolean, default: false },
|
|
75
|
+
accept: { default: void 0 },
|
|
76
|
+
maxFiles: { default: 10 },
|
|
77
|
+
fileSizeLimit: { default: void 0 },
|
|
78
|
+
fileListSizeLimit: { default: void 0 },
|
|
79
|
+
dropHintText: { default: void 0 },
|
|
80
|
+
recentEmojis: { default: () => [] },
|
|
81
|
+
enableVoice: { type: Boolean, default: true },
|
|
82
|
+
clearOnSend: { type: Boolean, default: true }
|
|
83
|
+
},
|
|
84
|
+
emits: ["update:modelValue", "update:attachments", "send", "retry", "emoji-select"],
|
|
85
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
86
|
+
const FORMAT_EXTENSIONS = {
|
|
87
|
+
bold: Bold,
|
|
88
|
+
italic: Italic,
|
|
89
|
+
strike: Strike,
|
|
90
|
+
code: Code
|
|
91
|
+
};
|
|
92
|
+
const props = __props;
|
|
93
|
+
const emit = __emit;
|
|
94
|
+
const mention = reactive({
|
|
95
|
+
isOpen: false,
|
|
96
|
+
items: [],
|
|
97
|
+
index: 0,
|
|
98
|
+
command: void 0
|
|
99
|
+
});
|
|
100
|
+
const mentionListRef = ref();
|
|
101
|
+
let mountMentionList;
|
|
102
|
+
let unmountMentionList;
|
|
103
|
+
const hasText = ref(!!resolveFormat(props.format).parse(props.modelValue).text.trim());
|
|
104
|
+
let lastEmittedValue = "";
|
|
105
|
+
const fileInputRef = ref();
|
|
106
|
+
const isDragOver = ref(false);
|
|
107
|
+
let dragDepth = 0;
|
|
108
|
+
const recorder = useAudioRecorder();
|
|
109
|
+
const uploaderProps = {
|
|
110
|
+
get files() {
|
|
111
|
+
return props.attachments;
|
|
112
|
+
},
|
|
113
|
+
get modelValue() {
|
|
114
|
+
return props.attachments;
|
|
115
|
+
},
|
|
116
|
+
get maxLength() {
|
|
117
|
+
return props.maxFiles;
|
|
118
|
+
},
|
|
119
|
+
get fileSizeLimit() {
|
|
120
|
+
return props.fileSizeLimit;
|
|
121
|
+
},
|
|
122
|
+
get fileListSizeLimit() {
|
|
123
|
+
return props.fileListSizeLimit;
|
|
124
|
+
},
|
|
125
|
+
multiple: true,
|
|
126
|
+
fileType: "file"
|
|
127
|
+
};
|
|
128
|
+
const { errorText, onTagClose, processFiles } = useFileUploader(uploaderProps, (event, files) => {
|
|
129
|
+
if (event === "update:modelValue") {
|
|
130
|
+
emit("update:attachments", files);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const placeholderText = computed(() => props.placeholder ?? tVU.t("voicenterUi.chatComposer.placeholder"));
|
|
134
|
+
const pressText = computed(() => tVU.t("voicenterUi.chatComposer.press"));
|
|
135
|
+
const toSendText = computed(() => tVU.t("voicenterUi.chatComposer.toSend"));
|
|
136
|
+
const sendText = computed(() => tVU.t("voicenterUi.chatComposer.send"));
|
|
137
|
+
const attachText = computed(() => tVU.t("voicenterUi.chatComposer.attach"));
|
|
138
|
+
const recordText = computed(() => tVU.t("voicenterUi.chatComposer.record"));
|
|
139
|
+
const stopText = computed(() => tVU.t("voicenterUi.chatComposer.stopRecording"));
|
|
140
|
+
const dropText = computed(() => tVU.t("voicenterUi.chatComposer.dropFiles"));
|
|
141
|
+
const cancelText = computed(() => tVU.t("voicenterUi.general.cancel"));
|
|
142
|
+
const deleteText = computed(() => tVU.t("voicenterUi.general.delete"));
|
|
143
|
+
const valueFormat = computed(() => resolveFormat(props.format));
|
|
144
|
+
const recordingTime = computed(() => {
|
|
145
|
+
const seconds = recorder.duration.value;
|
|
146
|
+
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
|
147
|
+
});
|
|
148
|
+
const errorMessage = computed(() => {
|
|
149
|
+
if (recorder.error.value) {
|
|
150
|
+
return tVU.t("voicenterUi.chatComposer.microphoneError");
|
|
151
|
+
}
|
|
152
|
+
return errorText.value;
|
|
153
|
+
});
|
|
154
|
+
const isUploading = computed(() => props.attachments.some((item) => item.status));
|
|
155
|
+
const canSend = computed(() => {
|
|
156
|
+
if (props.disabled || isUploading.value || recorder.state.value === "recording") {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return hasText.value || props.attachments.length > 0 || recorder.state.value === "recorded";
|
|
160
|
+
});
|
|
161
|
+
function getInitials(name) {
|
|
162
|
+
return name.split(/\s+/).map((part) => part[0] ?? "").join("").slice(0, 2);
|
|
163
|
+
}
|
|
164
|
+
function detachMentionList() {
|
|
165
|
+
unmountMentionList == null ? void 0 : unmountMentionList();
|
|
166
|
+
unmountMentionList = void 0;
|
|
167
|
+
}
|
|
168
|
+
function selectMention(index) {
|
|
169
|
+
const user = mention.items[index];
|
|
170
|
+
if (user && mention.command) {
|
|
171
|
+
mention.command({
|
|
172
|
+
id: String(user.id),
|
|
173
|
+
label: user.name
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function getRichText() {
|
|
178
|
+
var _a;
|
|
179
|
+
const richText = docToRichText(((_a = editor.value) == null ? void 0 : _a.getJSON()) ?? {});
|
|
180
|
+
return {
|
|
181
|
+
...richText,
|
|
182
|
+
entities: richText.entities.map((entity) => {
|
|
183
|
+
if (entity.type !== "mention") {
|
|
184
|
+
return entity;
|
|
185
|
+
}
|
|
186
|
+
const user = props.mentions.find((item) => String(item.id) === String(entity.userId));
|
|
187
|
+
return {
|
|
188
|
+
...entity,
|
|
189
|
+
userId: (user == null ? void 0 : user.id) ?? entity.userId
|
|
190
|
+
};
|
|
191
|
+
})
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function insertEmoji(emoji) {
|
|
195
|
+
var _a;
|
|
196
|
+
emit("emoji-select", emoji);
|
|
197
|
+
(_a = editor.value) == null ? void 0 : _a.chain().focus().insertContent(emoji).run();
|
|
198
|
+
}
|
|
199
|
+
function openFileDialog() {
|
|
200
|
+
if (!fileInputRef.value || props.disabled) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
fileInputRef.value.click();
|
|
204
|
+
}
|
|
205
|
+
function addFiles(files) {
|
|
206
|
+
if (props.disabled || !files.length) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
processFiles([...props.attachments, ...files]);
|
|
210
|
+
}
|
|
211
|
+
function onFileInputChange() {
|
|
212
|
+
var _a;
|
|
213
|
+
addFiles(Array.from(((_a = fileInputRef.value) == null ? void 0 : _a.files) ?? []));
|
|
214
|
+
if (fileInputRef.value) {
|
|
215
|
+
fileInputRef.value.value = "";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function onDragEnter(event) {
|
|
219
|
+
var _a;
|
|
220
|
+
if (props.disabled || !((_a = event.dataTransfer) == null ? void 0 : _a.types.includes("Files"))) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
dragDepth++;
|
|
224
|
+
isDragOver.value = true;
|
|
225
|
+
}
|
|
226
|
+
function onDragLeave() {
|
|
227
|
+
dragDepth = Math.max(dragDepth - 1, 0);
|
|
228
|
+
if (!dragDepth) {
|
|
229
|
+
isDragOver.value = false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function onDrop(event) {
|
|
233
|
+
var _a;
|
|
234
|
+
dragDepth = 0;
|
|
235
|
+
isDragOver.value = false;
|
|
236
|
+
addFiles(Array.from(((_a = event.dataTransfer) == null ? void 0 : _a.files) ?? []));
|
|
237
|
+
}
|
|
238
|
+
function startRecording() {
|
|
239
|
+
if (!recorder || props.disabled) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
recorder.start();
|
|
243
|
+
}
|
|
244
|
+
function stopRecording() {
|
|
245
|
+
if (!recorder) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
recorder.stop();
|
|
249
|
+
}
|
|
250
|
+
function cancelRecording() {
|
|
251
|
+
if (!recorder) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
recorder.cancel();
|
|
255
|
+
}
|
|
256
|
+
function deleteRecording() {
|
|
257
|
+
if (!recorder) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
recorder.reset();
|
|
261
|
+
}
|
|
262
|
+
function send() {
|
|
263
|
+
if (!canSend.value || !editor.value) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const richText = getRichText();
|
|
267
|
+
emit("send", {
|
|
268
|
+
value: valueFormat.value.serialize(richText),
|
|
269
|
+
richText,
|
|
270
|
+
attachments: props.attachments,
|
|
271
|
+
voice: recorder.blob.value
|
|
272
|
+
});
|
|
273
|
+
if (props.clearOnSend) {
|
|
274
|
+
editor.value.chain().clearContent(true).unsetAllMarks().run();
|
|
275
|
+
emit("update:attachments", []);
|
|
276
|
+
deleteRecording();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const SendOnEnter = Extension.create({
|
|
280
|
+
name: "vcSendOnEnter",
|
|
281
|
+
// Before the default Enter (new paragraph); the mention list handles Enter while it is open.
|
|
282
|
+
priority: 1e3,
|
|
283
|
+
addKeyboardShortcuts() {
|
|
284
|
+
return {
|
|
285
|
+
Enter: () => {
|
|
286
|
+
if (mention.isOpen || this.editor.view.composing) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
send();
|
|
290
|
+
return true;
|
|
291
|
+
},
|
|
292
|
+
"Shift-Enter": () => this.editor.commands.splitBlock()
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
const editor = useEditor({
|
|
297
|
+
editable: !props.disabled,
|
|
298
|
+
content: richTextToDoc(valueFormat.value.parse(props.modelValue)),
|
|
299
|
+
extensions: [
|
|
300
|
+
Document,
|
|
301
|
+
Paragraph,
|
|
302
|
+
Text,
|
|
303
|
+
UndoRedo,
|
|
304
|
+
Placeholder.configure({ placeholder: () => placeholderText.value }),
|
|
305
|
+
...props.formats.map((format) => FORMAT_EXTENSIONS[format]),
|
|
306
|
+
Mention.configure({
|
|
307
|
+
HTMLAttributes: { class: "vc-chat-composer__mention" },
|
|
308
|
+
suggestion: {
|
|
309
|
+
char: "@",
|
|
310
|
+
placement: "top-start",
|
|
311
|
+
floatingUi: { strategy: "fixed" },
|
|
312
|
+
allow: () => props.mentions.length > 0,
|
|
313
|
+
items: ({ query }) => props.mentions.filter((user) => user.name.toLowerCase().includes(query.toLowerCase())).slice(0, MAX_MENTION_SUGGESTIONS),
|
|
314
|
+
render: () => ({
|
|
315
|
+
onStart: (suggestion) => {
|
|
316
|
+
mountMentionList = suggestion.mount;
|
|
317
|
+
mention.isOpen = true;
|
|
318
|
+
mention.items = suggestion.items;
|
|
319
|
+
mention.index = 0;
|
|
320
|
+
mention.command = suggestion.command;
|
|
321
|
+
},
|
|
322
|
+
onUpdate: (suggestion) => {
|
|
323
|
+
mountMentionList = suggestion.mount;
|
|
324
|
+
mention.items = suggestion.items;
|
|
325
|
+
mention.index = 0;
|
|
326
|
+
mention.command = suggestion.command;
|
|
327
|
+
},
|
|
328
|
+
onExit: () => {
|
|
329
|
+
detachMentionList();
|
|
330
|
+
mountMentionList = void 0;
|
|
331
|
+
mention.isOpen = false;
|
|
332
|
+
mention.items = [];
|
|
333
|
+
},
|
|
334
|
+
onKeyDown: ({ event }) => {
|
|
335
|
+
if (!mention.isOpen || !mention.items.length) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const count = mention.items.length;
|
|
339
|
+
if (event.key === "ArrowDown") {
|
|
340
|
+
mention.index = (mention.index + 1) % count;
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (event.key === "ArrowUp") {
|
|
344
|
+
mention.index = (mention.index - 1 + count) % count;
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
if (event.key === "Enter" || event.key === "Tab") {
|
|
348
|
+
selectMention(mention.index);
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
if (event.key === "Escape") {
|
|
352
|
+
mention.isOpen = false;
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
}),
|
|
360
|
+
SendOnEnter
|
|
361
|
+
],
|
|
362
|
+
onUpdate: () => {
|
|
363
|
+
const richText = getRichText();
|
|
364
|
+
hasText.value = !!richText.text.trim();
|
|
365
|
+
const value = valueFormat.value.serialize(richText);
|
|
366
|
+
lastEmittedValue = JSON.stringify(value);
|
|
367
|
+
emit("update:modelValue", value);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
watch(mentionListRef, (element) => {
|
|
371
|
+
detachMentionList();
|
|
372
|
+
if (element && mountMentionList) {
|
|
373
|
+
unmountMentionList = mountMentionList(element);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
watch(() => props.modelValue, (value) => {
|
|
377
|
+
if (!editor.value || JSON.stringify(value) === lastEmittedValue) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
const richText = valueFormat.value.parse(value);
|
|
381
|
+
hasText.value = !!richText.text.trim();
|
|
382
|
+
editor.value.commands.setContent(richTextToDoc(richText), { emitUpdate: false });
|
|
383
|
+
});
|
|
384
|
+
watch(() => props.disabled, (disabled) => {
|
|
385
|
+
var _a;
|
|
386
|
+
(_a = editor.value) == null ? void 0 : _a.setEditable(!disabled);
|
|
387
|
+
});
|
|
388
|
+
onBeforeUnmount(() => {
|
|
389
|
+
var _a;
|
|
390
|
+
detachMentionList();
|
|
391
|
+
(_a = editor.value) == null ? void 0 : _a.destroy();
|
|
392
|
+
});
|
|
393
|
+
__expose({
|
|
394
|
+
send,
|
|
395
|
+
focus: () => {
|
|
396
|
+
var _a;
|
|
397
|
+
return (_a = editor.value) == null ? void 0 : _a.commands.focus();
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
return (_ctx, _cache) => {
|
|
401
|
+
return openBlock(), createElementBlock("div", {
|
|
402
|
+
class: normalizeClass([{ "is--disabled": __props.disabled, "is--drag": isDragOver.value }, "vc-chat-composer"]),
|
|
403
|
+
onDragenter: withModifiers(onDragEnter, ["prevent"]),
|
|
404
|
+
onDragover: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
405
|
+
}, ["prevent"])),
|
|
406
|
+
onDragleave: onDragLeave,
|
|
407
|
+
onDrop: withModifiers(onDrop, ["prevent"])
|
|
408
|
+
}, [
|
|
409
|
+
isDragOver.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
410
|
+
createVNode(_sfc_main$1, {
|
|
411
|
+
icon: unref(Upload),
|
|
412
|
+
class: "vc-chat-composer__drop-icon"
|
|
413
|
+
}, null, 8, ["icon"]),
|
|
414
|
+
createElementVNode("span", _hoisted_2, toDisplayString(dropText.value), 1),
|
|
415
|
+
__props.dropHintText ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.dropHintText), 1)) : createCommentVNode("", true)
|
|
416
|
+
])) : createCommentVNode("", true),
|
|
417
|
+
__props.attachments.length ? (openBlock(), createElementBlock("div", _hoisted_4, [
|
|
418
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(__props.attachments, (item) => {
|
|
419
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
420
|
+
key: item.id ?? item.name,
|
|
421
|
+
file: item,
|
|
422
|
+
status: item.status,
|
|
423
|
+
progress: item.progress,
|
|
424
|
+
disabled: __props.disabled,
|
|
425
|
+
onRemove: ($event) => unref(onTagClose)(item.id),
|
|
426
|
+
onRetry: ($event) => emit("retry", item)
|
|
427
|
+
}, null, 8, ["file", "status", "progress", "disabled", "onRemove", "onRetry"]);
|
|
428
|
+
}), 128))
|
|
429
|
+
])) : createCommentVNode("", true),
|
|
430
|
+
unref(recorder).state.value === "recording" ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
431
|
+
_cache[1] || (_cache[1] = createElementVNode("span", { class: "vc-chat-composer__recording-dot" }, null, -1)),
|
|
432
|
+
createElementVNode("span", _hoisted_6, toDisplayString(recordingTime.value), 1),
|
|
433
|
+
createVNode(_sfc_main$3, {
|
|
434
|
+
icon: unref(Trash2),
|
|
435
|
+
title: cancelText.value,
|
|
436
|
+
"aria-label": cancelText.value,
|
|
437
|
+
color: "destructive",
|
|
438
|
+
onClick: cancelRecording
|
|
439
|
+
}, null, 8, ["icon", "title", "aria-label"]),
|
|
440
|
+
createVNode(_sfc_main$3, {
|
|
441
|
+
icon: unref(Square),
|
|
442
|
+
title: stopText.value,
|
|
443
|
+
"aria-label": stopText.value,
|
|
444
|
+
color: "primary",
|
|
445
|
+
onClick: stopRecording
|
|
446
|
+
}, null, 8, ["icon", "title", "aria-label"])
|
|
447
|
+
])) : unref(recorder).state.value === "recorded" && unref(recorder).url.value ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
|
448
|
+
createVNode(_sfc_main$4, {
|
|
449
|
+
src: unref(recorder).url.value,
|
|
450
|
+
size: "sm",
|
|
451
|
+
class: "vc-chat-composer__voice-player"
|
|
452
|
+
}, null, 8, ["src"]),
|
|
453
|
+
createVNode(_sfc_main$3, {
|
|
454
|
+
icon: unref(Trash2),
|
|
455
|
+
title: deleteText.value,
|
|
456
|
+
"aria-label": deleteText.value,
|
|
457
|
+
color: "destructive",
|
|
458
|
+
onClick: deleteRecording
|
|
459
|
+
}, null, 8, ["icon", "title", "aria-label"])
|
|
460
|
+
])) : createCommentVNode("", true),
|
|
461
|
+
withDirectives(createElementVNode("div", _hoisted_8, [
|
|
462
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
463
|
+
mention.isOpen && mention.items.length ? (openBlock(), createElementBlock("ul", {
|
|
464
|
+
key: 0,
|
|
465
|
+
ref_key: "mentionListRef",
|
|
466
|
+
ref: mentionListRef,
|
|
467
|
+
role: "listbox",
|
|
468
|
+
class: "vc-chat-composer__mentions"
|
|
469
|
+
}, [
|
|
470
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(mention.items, (user, index) => {
|
|
471
|
+
return openBlock(), createElementBlock("li", {
|
|
472
|
+
key: user.id,
|
|
473
|
+
"aria-selected": index === mention.index,
|
|
474
|
+
class: normalizeClass([{ "is--active": index === mention.index }, "vc-chat-composer__mention-option"]),
|
|
475
|
+
role: "option",
|
|
476
|
+
onMousedown: withModifiers(($event) => selectMention(index), ["prevent"])
|
|
477
|
+
}, [
|
|
478
|
+
createVNode(_sfc_main$5, {
|
|
479
|
+
src: user.avatar,
|
|
480
|
+
initials: getInitials(user.name),
|
|
481
|
+
alt: user.name,
|
|
482
|
+
size: "sm"
|
|
483
|
+
}, null, 8, ["src", "initials", "alt"]),
|
|
484
|
+
createElementVNode("span", null, toDisplayString(user.name), 1)
|
|
485
|
+
], 42, _hoisted_9);
|
|
486
|
+
}), 128))
|
|
487
|
+
], 512)) : createCommentVNode("", true)
|
|
488
|
+
])),
|
|
489
|
+
createVNode(unref(EditorContent), {
|
|
490
|
+
editor: unref(editor),
|
|
491
|
+
class: "vc-chat-composer__editor"
|
|
492
|
+
}, null, 8, ["editor"])
|
|
493
|
+
], 512), [
|
|
494
|
+
[vShow, unref(recorder).state.value === "idle"]
|
|
495
|
+
]),
|
|
496
|
+
createElementVNode("div", _hoisted_10, [
|
|
497
|
+
createElementVNode("div", _hoisted_11, [
|
|
498
|
+
createVNode(_sfc_main$3, {
|
|
499
|
+
icon: unref(Paperclip),
|
|
500
|
+
disabled: __props.disabled,
|
|
501
|
+
title: attachText.value,
|
|
502
|
+
"aria-label": attachText.value,
|
|
503
|
+
color: "secondary",
|
|
504
|
+
onClick: openFileDialog
|
|
505
|
+
}, null, 8, ["icon", "disabled", "title", "aria-label"]),
|
|
506
|
+
createElementVNode("input", {
|
|
507
|
+
ref_key: "fileInputRef",
|
|
508
|
+
ref: fileInputRef,
|
|
509
|
+
accept: __props.accept,
|
|
510
|
+
type: "file",
|
|
511
|
+
multiple: "",
|
|
512
|
+
class: "vc-chat-composer__file-input",
|
|
513
|
+
onChange: onFileInputChange
|
|
514
|
+
}, null, 40, _hoisted_12),
|
|
515
|
+
createVNode(_sfc_main$6, {
|
|
516
|
+
"recent-emojis": __props.recentEmojis,
|
|
517
|
+
disabled: __props.disabled,
|
|
518
|
+
onSelect: insertEmoji
|
|
519
|
+
}, null, 8, ["recent-emojis", "disabled"]),
|
|
520
|
+
__props.enableVoice && unref(recorder).isSupported.value ? (openBlock(), createBlock(_sfc_main$3, {
|
|
521
|
+
key: 0,
|
|
522
|
+
icon: unref(Mic),
|
|
523
|
+
disabled: __props.disabled || unref(recorder).state.value !== "idle",
|
|
524
|
+
title: recordText.value,
|
|
525
|
+
"aria-label": recordText.value,
|
|
526
|
+
color: "secondary",
|
|
527
|
+
onClick: startRecording
|
|
528
|
+
}, null, 8, ["icon", "disabled", "title", "aria-label"])) : createCommentVNode("", true)
|
|
529
|
+
]),
|
|
530
|
+
createElementVNode("span", _hoisted_13, [
|
|
531
|
+
createTextVNode(toDisplayString(pressText.value) + " ", 1),
|
|
532
|
+
_cache[2] || (_cache[2] = createElementVNode("kbd", { class: "vc-chat-composer__kbd" }, "Enter", -1)),
|
|
533
|
+
createTextVNode(" " + toDisplayString(toSendText.value), 1)
|
|
534
|
+
]),
|
|
535
|
+
createVNode(_sfc_main$7, {
|
|
536
|
+
icon: unref(SendHorizontal),
|
|
537
|
+
disabled: !canSend.value,
|
|
538
|
+
color: "primary",
|
|
539
|
+
onClick: send
|
|
540
|
+
}, {
|
|
541
|
+
default: withCtx(() => [
|
|
542
|
+
createTextVNode(toDisplayString(sendText.value), 1)
|
|
543
|
+
]),
|
|
544
|
+
_: 1
|
|
545
|
+
}, 8, ["icon", "disabled"])
|
|
546
|
+
]),
|
|
547
|
+
errorMessage.value ? (openBlock(), createElementBlock("div", _hoisted_14, toDisplayString(errorMessage.value), 1)) : createCommentVNode("", true)
|
|
548
|
+
], 34);
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
export {
|
|
553
|
+
_sfc_main as default
|
|
554
|
+
};
|