@voicenter-team/voicenter-ui-plus 4.0.0-beta.1 → 4.0.0-beta.3

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.
Files changed (79) hide show
  1. package/MIGRATION_v3.md +196 -0
  2. package/README.md +20 -51
  3. package/library/assets/assets/sass/main.css +1 -1
  4. package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -1
  5. package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
  6. package/library/assets/components/VcMdEditor/VcMdEditorContent.css +1 -1
  7. package/library/assets/components/VcSoundplayer/VcSoundPlayerCompact.css +1 -0
  8. package/library/assets/components/VcSoundplayer/VcSoundVolume.css +1 -1
  9. package/library/components/VcChatComposer/VcChatComposer.vue.mjs +173 -139
  10. package/library/components/VcChatComposer/tiptap.mjs +45 -0
  11. package/library/components/VcCodeBlock/VcCodeBlock.vue.mjs +18 -5
  12. package/library/components/VcCodeBlock/highlight.mjs +8 -0
  13. package/library/components/VcEmojiPicker/VcEmojiPicker.vue.mjs +3 -4
  14. package/library/components/VcEmojiPicker/emojiData.mjs +16 -21
  15. package/library/components/VcHtmlEditor/VcHtmlEditor.vue.mjs +19 -12
  16. package/library/components/VcHtmlEditor/codemirror.mjs +14 -0
  17. package/library/components/VcImageUploader/VcImageUploader.vue.mjs +14 -8
  18. package/library/components/VcImageUploader/cropper.mjs +5 -0
  19. package/library/components/VcJsonSchema/Components/JsonCodeMirror.vue.mjs +16 -7
  20. package/library/components/VcJsonSchema/Components/codemirror.mjs +15 -0
  21. package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
  22. package/library/components/VcMdEditor/ParameterNode.vue2.mjs +2 -2
  23. package/library/components/VcMdEditor/VcMdEditor.vue.mjs +114 -108
  24. package/library/components/VcMdEditor/VcMdEditorContent.vue.mjs +18 -21
  25. package/library/components/VcMdEditor/ltrNumbersPlugin.mjs +42 -39
  26. package/library/components/VcMdEditor/mdEditor.config.mjs +107 -99
  27. package/library/components/VcMdEditor/milkdown.mjs +67 -0
  28. package/library/components/VcMdEditor/rtlCursorPlugin.mjs +3 -3
  29. package/library/components/VcPdfViewer/VcPdfDocument.vue.mjs +4 -8
  30. package/library/components/VcPdfViewer/pdfjslib.mjs +13 -16
  31. package/library/components/VcSoundplayer/VcPlayerPlayStopButton.vue.mjs +2 -1
  32. package/library/components/VcSoundplayer/VcSoundPlayer.vue.mjs +2 -8
  33. package/library/components/VcSoundplayer/VcSoundPlayerCompact.vue.mjs +197 -0
  34. package/library/components/VcSoundplayer/VcSoundPlayerCompact.vue3.mjs +5 -0
  35. package/library/components/VcSoundplayer/VcSoundPlayerProgress.vue.mjs +1 -1
  36. package/library/components/VcSoundplayer/VcSoundPlayerWrapper.vue.mjs +19 -7
  37. package/library/components/VcSoundplayer/player.options.mjs +8 -0
  38. package/library/components/VcSoundplayer/wavesurfer.mjs +14 -0
  39. package/library/index.mjs +59 -56
  40. package/library/index.mjs.br +0 -0
  41. package/library/index.mjs.gz +0 -0
  42. package/library/plugin-components.gen.mjs +91 -88
  43. package/library/plugin.mjs +59 -56
  44. package/library/plugin.mjs.br +0 -0
  45. package/library/plugin.mjs.gz +0 -0
  46. package/library/style.css +7 -5
  47. package/library/style.css.br +0 -0
  48. package/library/style.css.gz +0 -0
  49. package/library/types/components/VcChatComposer/VcChatComposer.vue.d.ts +2 -1
  50. package/library/types/components/VcChatComposer/tiptap.d.ts +61 -0
  51. package/library/types/components/VcCodeBlock/highlight.d.ts +3 -0
  52. package/library/types/components/VcEmojiPicker/VcEmojiPicker.vue.d.ts +1 -1
  53. package/library/types/components/VcEmojiPicker/emojiData.d.ts +3 -3
  54. package/library/types/components/VcHtmlEditor/codemirror.d.ts +8 -0
  55. package/library/types/components/VcImageUploader/VcImageUploader.vue.d.ts +1 -1
  56. package/library/types/components/VcImageUploader/cropper.d.ts +34 -0
  57. package/library/types/components/VcJsonSchema/Components/codemirror.d.ts +9 -0
  58. package/library/types/components/VcMdEditor/ltrNumbersPlugin.d.ts +7 -13
  59. package/library/types/components/VcMdEditor/mdEditor.config.d.ts +12 -16
  60. package/library/types/components/VcMdEditor/milkdown.d.ts +25 -0
  61. package/library/types/components/VcMdEditor/rtlCursorPlugin.d.ts +3 -2
  62. package/library/types/components/VcPdfViewer/VcPdfDocument.vue.d.ts +1 -1
  63. package/library/types/components/VcPdfViewer/VcPdfDocumentPage.vue.d.ts +1 -1
  64. package/library/types/components/VcPdfViewer/pdfjslib.d.ts +1 -1
  65. package/library/types/components/VcSoundplayer/VcPlayerPlayStopButton.vue.d.ts +11 -0
  66. package/library/types/components/VcSoundplayer/VcSoundPlayerCompact.vue.d.ts +75 -0
  67. package/library/types/components/VcSoundplayer/VcSoundPlayerWrapper.vue.d.ts +3 -1
  68. package/library/types/components/VcSoundplayer/player.options.d.ts +2 -0
  69. package/library/types/components/VcSoundplayer/wavesurfer.d.ts +8 -0
  70. package/library/types/components/exports.d.ts +3 -1
  71. package/library/types/components.gen.d.ts +1 -0
  72. package/library/types/types/VcSoundPlayer.types.d.ts +1 -1
  73. package/library/types/utils/optionalPeer.d.ts +33 -0
  74. package/library/utils/excelParser/helper.mjs +2 -7
  75. package/library/utils/optionalPeer.mjs +32 -0
  76. package/package.json +96 -1
  77. package/src/theme/index.ts +101 -101
  78. package/src/theme/theme.types.ts +31 -31
  79. package/tailwind.config.d.ts +5 -5
@@ -1,16 +1,6 @@
1
1
  import '../../assets/components/VcChatComposer/VcChatComposer.css';
2
- import { defineComponent, reactive, ref, computed, watch, onBeforeUnmount, openBlock, createElementBlock, withModifiers, normalizeClass, createVNode, unref, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, createBlock, withDirectives, Teleport, vShow, createTextVNode, withCtx } from "vue";
2
+ import { defineComponent, reactive, ref, shallowRef, computed, watch, onMounted, onBeforeUnmount, openBlock, createElementBlock, withModifiers, normalizeClass, createVNode, unref, createElementVNode, toDisplayString, createCommentVNode, renderSlot, Fragment, renderList, createBlock, withDirectives, Teleport, resolveDynamicComponent, vShow, createTextVNode, withCtx } from "vue";
3
3
  import { useFileDialog } from "@vueuse/core";
4
- import { Extension, useEditor, EditorContent } from "@tiptap/vue-3";
5
- import Document from "@tiptap/extension-document";
6
- import Paragraph from "@tiptap/extension-paragraph";
7
- import Text from "@tiptap/extension-text";
8
- import Bold from "@tiptap/extension-bold";
9
- import Italic from "@tiptap/extension-italic";
10
- import Strike from "@tiptap/extension-strike";
11
- import Code from "@tiptap/extension-code";
12
- import Mention from "@tiptap/extension-mention";
13
- import { UndoRedo, Placeholder } from "@tiptap/extensions";
14
4
  import { Upload, Trash2, Square, Paperclip, Mic, SendHorizontal } from "@lucide/vue";
15
5
  import _sfc_main$5 from "../VcAvatar/VcAvatar.vue.mjs";
16
6
  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 */
@@ -33,6 +23,7 @@ import { partitionByAccept } from "../../utils/fileAccept.mjs";
33
23
  import { getFileSize } from "../../utils/helpers.mjs";
34
24
  import { literalParam } from "../../utils/i18nParams.mjs";
35
25
  import { resolveFormat, richTextToDoc, docToRichText } from "./richText.mjs";
26
+ import { loadTiptap } from "./tiptap.mjs";
36
27
  const _hoisted_1 = {
37
28
  key: 0,
38
29
  class: "vc-chat-composer__drop"
@@ -61,14 +52,18 @@ const _hoisted_8 = {
61
52
  };
62
53
  const _hoisted_9 = { class: "vc-chat-composer__editor-wrapper" };
63
54
  const _hoisted_10 = ["aria-selected", "onMousedown"];
64
- const _hoisted_11 = { class: "vc-chat-composer__toolbar" };
65
- const _hoisted_12 = { class: "vc-chat-composer__actions" };
66
- const _hoisted_13 = {
55
+ const _hoisted_11 = {
56
+ key: 1,
57
+ class: "vc-chat-composer__editor is--loading"
58
+ };
59
+ const _hoisted_12 = { class: "vc-chat-composer__toolbar" };
60
+ const _hoisted_13 = { class: "vc-chat-composer__actions" };
61
+ const _hoisted_14 = {
67
62
  key: 0,
68
63
  class: "vc-chat-composer__hint",
69
64
  "data-test": "chat-composer-hint"
70
65
  };
71
- const _hoisted_14 = {
66
+ const _hoisted_15 = {
72
67
  key: 5,
73
68
  class: "vc-chat-composer__error",
74
69
  role: "alert",
@@ -100,12 +95,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
100
95
  },
101
96
  emits: ["update:modelValue", "update:attachments", "send", "retry", "emoji-select", "stop", "attachment-click", "focus", "blur"],
102
97
  setup(__props, { expose: __expose, emit: __emit }) {
103
- const FORMAT_EXTENSIONS = {
104
- bold: Bold,
105
- italic: Italic,
106
- strike: Strike,
107
- code: Code
108
- };
109
98
  const props = __props;
110
99
  const emit = __emit;
111
100
  const mention = reactive({
@@ -117,7 +106,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
117
106
  const mentionListRef = ref();
118
107
  let mountMentionList;
119
108
  let unmountMentionList;
120
- const hasText = ref(!!resolveFormat(props.format).parse(props.modelValue).text.trim());
109
+ const tiptap = shallowRef();
110
+ const editor = shallowRef();
111
+ let isUnmounted = false;
112
+ let textBeforeLoad = resolveFormat(props.format).parse(props.modelValue);
113
+ let focusOnLoad = false;
114
+ const hasText = ref(!!textBeforeLoad.text.trim());
121
115
  let lastEmittedValue = "";
122
116
  const isDragOver = ref(false);
123
117
  let dragDepth = 0;
@@ -194,8 +188,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
194
188
  }
195
189
  }
196
190
  function getRichText() {
197
- var _a;
198
- const richText = docToRichText(((_a = editor.value) == null ? void 0 : _a.getJSON()) ?? {});
191
+ const richText = editor.value ? docToRichText(editor.value.getJSON()) : textBeforeLoad;
199
192
  return {
200
193
  ...richText,
201
194
  entities: richText.entities.map((entity) => {
@@ -210,10 +203,28 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
210
203
  })
211
204
  };
212
205
  }
213
- function insertEmoji(emoji) {
206
+ function emitValue(richText) {
207
+ hasText.value = !!richText.text.trim();
208
+ const value = valueFormat.value.serialize(richText);
209
+ lastEmittedValue = JSON.stringify(value);
210
+ emit("update:modelValue", value);
211
+ }
212
+ function focus() {
214
213
  var _a;
214
+ focusOnLoad = !editor.value;
215
+ return (_a = editor.value) == null ? void 0 : _a.commands.focus();
216
+ }
217
+ function insertEmoji(emoji) {
215
218
  emit("emoji-select", emoji);
216
- (_a = editor.value) == null ? void 0 : _a.chain().focus().insertContent(emoji).run();
219
+ if (editor.value) {
220
+ editor.value.chain().focus().insertContent(emoji).run();
221
+ return;
222
+ }
223
+ textBeforeLoad = {
224
+ ...textBeforeLoad,
225
+ text: textBeforeLoad.text + emoji
226
+ };
227
+ emitValue(textBeforeLoad);
217
228
  }
218
229
  const fileDialog = useFileDialog();
219
230
  fileDialog.onChange((files) => {
@@ -331,8 +342,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
331
342
  recorder.reset();
332
343
  }
333
344
  function clear() {
334
- var _a;
335
- (_a = editor.value) == null ? void 0 : _a.chain().clearContent(true).unsetAllMarks().run();
345
+ if (editor.value) {
346
+ editor.value.chain().clearContent(true).unsetAllMarks().run();
347
+ } else {
348
+ textBeforeLoad = {
349
+ text: "",
350
+ entities: []
351
+ };
352
+ emitValue(textBeforeLoad);
353
+ }
336
354
  rejectedText.value = "";
337
355
  if (props.attachments.length) {
338
356
  emit("update:attachments", []);
@@ -340,7 +358,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
340
358
  deleteRecording();
341
359
  }
342
360
  function send() {
343
- if (!canSend.value || !editor.value) {
361
+ if (!canSend.value) {
344
362
  return;
345
363
  }
346
364
  const richText = getRichText();
@@ -354,105 +372,107 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
354
372
  clear();
355
373
  }
356
374
  }
357
- const SendOnEnter = Extension.create({
358
- name: "vcSendOnEnter",
359
- // Before the default Enter (new paragraph); the mention list handles Enter while it is open.
360
- priority: 1e3,
361
- addKeyboardShortcuts() {
362
- return {
363
- Enter: () => {
364
- if (mention.isOpen || this.editor.view.composing) {
365
- return false;
366
- }
367
- if (!props.streaming) {
368
- send();
369
- }
370
- return true;
371
- },
372
- "Shift-Enter": () => this.editor.commands.splitBlock()
373
- };
374
- }
375
- });
376
- const editor = useEditor({
377
- editable: !props.disabled,
378
- editorProps: {
379
- handlePaste: (_view, event) => onPaste(event)
380
- },
381
- content: richTextToDoc(valueFormat.value.parse(props.modelValue)),
382
- extensions: [
383
- Document,
384
- Paragraph,
385
- Text,
386
- UndoRedo,
387
- Placeholder.configure({ placeholder: () => placeholderText.value }),
388
- // Plain text cannot keep formatting: no format extensions, so typed markers stay text.
389
- ...(props.format === "text" ? [] : props.formats).map((format) => FORMAT_EXTENSIONS[format]),
390
- Mention.configure({
391
- HTMLAttributes: { class: "vc-chat-composer__mention" },
392
- suggestion: {
393
- char: "@",
394
- placement: "top-start",
395
- floatingUi: { strategy: "fixed" },
396
- allow: () => props.mentions.length > 0,
397
- items: ({ query }) => props.mentions.filter((user) => user.name.toLowerCase().includes(query.toLowerCase())).slice(0, MAX_MENTION_SUGGESTIONS),
398
- render: () => ({
399
- onStart: (suggestion) => {
400
- mountMentionList = suggestion.mount;
401
- mention.isOpen = true;
402
- mention.items = suggestion.items;
403
- mention.index = 0;
404
- mention.command = suggestion.command;
405
- },
406
- onUpdate: (suggestion) => {
407
- mountMentionList = suggestion.mount;
408
- mention.items = suggestion.items;
409
- mention.index = 0;
410
- mention.command = suggestion.command;
411
- },
412
- onExit: () => {
413
- detachMentionList();
414
- mountMentionList = void 0;
415
- mention.isOpen = false;
416
- mention.items = [];
417
- },
418
- onKeyDown: ({ event }) => {
419
- if (!mention.isOpen || !mention.items.length) {
420
- return false;
421
- }
422
- const count = mention.items.length;
423
- if (event.key === "ArrowDown") {
424
- mention.index = (mention.index + 1) % count;
425
- return true;
426
- }
427
- if (event.key === "ArrowUp") {
428
- mention.index = (mention.index - 1 + count) % count;
429
- return true;
430
- }
431
- if (event.key === "Enter" || event.key === "Tab") {
432
- selectMention(mention.index);
433
- return true;
434
- }
435
- if (event.key === "Escape") {
436
- mention.isOpen = false;
437
- return true;
438
- }
375
+ function createEditor({ Editor, Extension, Document, Paragraph, Text, Bold, Italic, Strike, Code, Mention, Placeholder, UndoRedo }) {
376
+ const formatExtensions = {
377
+ bold: Bold,
378
+ italic: Italic,
379
+ strike: Strike,
380
+ code: Code
381
+ };
382
+ const SendOnEnter = Extension.create({
383
+ name: "vcSendOnEnter",
384
+ // Before the default Enter (new paragraph); the mention list handles Enter while it is open.
385
+ priority: 1e3,
386
+ addKeyboardShortcuts() {
387
+ return {
388
+ Enter: () => {
389
+ if (mention.isOpen || this.editor.view.composing) {
439
390
  return false;
440
391
  }
441
- })
442
- }
443
- }),
444
- SendOnEnter
445
- ],
446
- onFocus: () => emit("focus"),
447
- onBlur: () => emit("blur"),
448
- onUpdate: () => {
449
- const richText = getRichText();
450
- hasText.value = !!richText.text.trim();
451
- const value = valueFormat.value.serialize(richText);
452
- lastEmittedValue = JSON.stringify(value);
453
- emit("update:modelValue", value);
454
- }
455
- });
392
+ if (!props.streaming) {
393
+ send();
394
+ }
395
+ return true;
396
+ },
397
+ "Shift-Enter": () => this.editor.commands.splitBlock()
398
+ };
399
+ }
400
+ });
401
+ return new Editor({
402
+ editable: !props.disabled,
403
+ editorProps: {
404
+ handlePaste: (_view, event) => onPaste(event)
405
+ },
406
+ content: richTextToDoc(textBeforeLoad),
407
+ extensions: [
408
+ Document,
409
+ Paragraph,
410
+ Text,
411
+ UndoRedo,
412
+ Placeholder.configure({ placeholder: () => placeholderText.value }),
413
+ // Plain text cannot keep formatting: no format extensions, so typed markers stay text.
414
+ ...(props.format === "text" ? [] : props.formats).map((format) => formatExtensions[format]),
415
+ Mention.configure({
416
+ HTMLAttributes: { class: "vc-chat-composer__mention" },
417
+ suggestion: {
418
+ char: "@",
419
+ placement: "top-start",
420
+ floatingUi: { strategy: "fixed" },
421
+ allow: () => props.mentions.length > 0,
422
+ items: ({ query }) => props.mentions.filter((user) => user.name.toLowerCase().includes(query.toLowerCase())).slice(0, MAX_MENTION_SUGGESTIONS),
423
+ render: () => ({
424
+ onStart: (suggestion) => {
425
+ mountMentionList = suggestion.mount;
426
+ mention.isOpen = true;
427
+ mention.items = suggestion.items;
428
+ mention.index = 0;
429
+ mention.command = suggestion.command;
430
+ },
431
+ onUpdate: (suggestion) => {
432
+ mountMentionList = suggestion.mount;
433
+ mention.items = suggestion.items;
434
+ mention.index = 0;
435
+ mention.command = suggestion.command;
436
+ },
437
+ onExit: () => {
438
+ detachMentionList();
439
+ mountMentionList = void 0;
440
+ mention.isOpen = false;
441
+ mention.items = [];
442
+ },
443
+ onKeyDown: ({ event }) => {
444
+ if (!mention.isOpen || !mention.items.length) {
445
+ return false;
446
+ }
447
+ const count = mention.items.length;
448
+ if (event.key === "ArrowDown") {
449
+ mention.index = (mention.index + 1) % count;
450
+ return true;
451
+ }
452
+ if (event.key === "ArrowUp") {
453
+ mention.index = (mention.index - 1 + count) % count;
454
+ return true;
455
+ }
456
+ if (event.key === "Enter" || event.key === "Tab") {
457
+ selectMention(mention.index);
458
+ return true;
459
+ }
460
+ if (event.key === "Escape") {
461
+ mention.isOpen = false;
462
+ return true;
463
+ }
464
+ return false;
465
+ }
466
+ })
467
+ }
468
+ }),
469
+ SendOnEnter
470
+ ],
471
+ onFocus: () => emit("focus"),
472
+ onBlur: () => emit("blur"),
473
+ onUpdate: () => emitValue(getRichText())
474
+ });
475
+ }
456
476
  watch(mentionListRef, (element) => {
457
477
  detachMentionList();
458
478
  if (element && mountMentionList) {
@@ -460,28 +480,41 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
460
480
  }
461
481
  });
462
482
  watch(() => props.modelValue, (value) => {
463
- if (!editor.value || JSON.stringify(value) === lastEmittedValue) {
483
+ if (JSON.stringify(value) === lastEmittedValue) {
464
484
  return;
465
485
  }
466
486
  const richText = valueFormat.value.parse(value);
467
487
  hasText.value = !!richText.text.trim();
468
- editor.value.commands.setContent(richTextToDoc(richText), { emitUpdate: false });
488
+ if (editor.value) {
489
+ editor.value.commands.setContent(richTextToDoc(richText), { emitUpdate: false });
490
+ } else {
491
+ textBeforeLoad = richText;
492
+ }
469
493
  });
470
494
  watch(() => props.disabled, (disabled) => {
471
495
  var _a;
472
496
  (_a = editor.value) == null ? void 0 : _a.setEditable(!disabled);
473
497
  });
498
+ onMounted(async () => {
499
+ const loaded = await loadTiptap();
500
+ if (isUnmounted) {
501
+ return;
502
+ }
503
+ editor.value = createEditor(loaded);
504
+ tiptap.value = loaded;
505
+ if (focusOnLoad) {
506
+ editor.value.commands.focus();
507
+ }
508
+ });
474
509
  onBeforeUnmount(() => {
475
510
  var _a;
511
+ isUnmounted = true;
476
512
  detachMentionList();
477
513
  (_a = editor.value) == null ? void 0 : _a.destroy();
478
514
  });
479
515
  __expose({
480
516
  send,
481
- focus: () => {
482
- var _a;
483
- return (_a = editor.value) == null ? void 0 : _a.commands.focus();
484
- },
517
+ focus,
485
518
  addFiles,
486
519
  clear
487
520
  });
@@ -580,15 +613,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
580
613
  }), 128))
581
614
  ], 512)) : createCommentVNode("", true)
582
615
  ])),
583
- createVNode(unref(EditorContent), {
584
- editor: unref(editor),
616
+ tiptap.value ? (openBlock(), createBlock(resolveDynamicComponent(tiptap.value.EditorContent), {
617
+ key: 0,
618
+ editor: editor.value,
585
619
  class: "vc-chat-composer__editor"
586
- }, null, 8, ["editor"])
620
+ }, null, 8, ["editor"])) : (openBlock(), createElementBlock("div", _hoisted_11))
587
621
  ], 512), [
588
622
  [vShow, unref(recorder).state.value === "idle"]
589
623
  ]),
590
- createElementVNode("div", _hoisted_11, [
591
- createElementVNode("div", _hoisted_12, [
624
+ createElementVNode("div", _hoisted_12, [
625
+ createElementVNode("div", _hoisted_13, [
592
626
  __props.enableAttachments ? (openBlock(), createBlock(_sfc_main$3, {
593
627
  key: 0,
594
628
  icon: unref(Paperclip),
@@ -619,7 +653,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
619
653
  streaming: __props.streaming
620
654
  })
621
655
  ]),
622
- __props.showSendHint ? (openBlock(), createElementBlock("span", _hoisted_13, [
656
+ __props.showSendHint ? (openBlock(), createElementBlock("span", _hoisted_14, [
623
657
  createTextVNode(toDisplayString(pressText.value) + " ", 1),
624
658
  _cache[3] || (_cache[3] = createElementVNode("kbd", { class: "vc-chat-composer__kbd" }, "Enter", -1)),
625
659
  createTextVNode(" " + toDisplayString(toSendText.value), 1)
@@ -658,7 +692,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
658
692
  _: 1
659
693
  }, 8, ["icon", "disabled"]))
660
694
  ]),
661
- errorMessage.value ? (openBlock(), createElementBlock("div", _hoisted_14, toDisplayString(errorMessage.value), 1)) : createCommentVNode("", true)
695
+ errorMessage.value ? (openBlock(), createElementBlock("div", _hoisted_15, toDisplayString(errorMessage.value), 1)) : createCommentVNode("", true)
662
696
  ], 34);
663
697
  };
664
698
  }
@@ -0,0 +1,45 @@
1
+ import { cachedLoad, loadOptionalPeer } from "../../utils/optionalPeer.mjs";
2
+ async function importTiptap() {
3
+ const [
4
+ { Editor, EditorContent, Extension },
5
+ { Placeholder, UndoRedo },
6
+ { Document },
7
+ { Paragraph },
8
+ { Text },
9
+ { Bold },
10
+ { Italic },
11
+ { Strike },
12
+ { Code },
13
+ { Mention }
14
+ ] = await Promise.all([
15
+ loadOptionalPeer("@tiptap/vue-3", import("@tiptap/vue-3")),
16
+ loadOptionalPeer("@tiptap/extensions", import("@tiptap/extensions")),
17
+ loadOptionalPeer("@tiptap/extension-document", import("@tiptap/extension-document")),
18
+ loadOptionalPeer("@tiptap/extension-paragraph", import("@tiptap/extension-paragraph")),
19
+ loadOptionalPeer("@tiptap/extension-text", import("@tiptap/extension-text")),
20
+ loadOptionalPeer("@tiptap/extension-bold", import("@tiptap/extension-bold")),
21
+ loadOptionalPeer("@tiptap/extension-italic", import("@tiptap/extension-italic")),
22
+ loadOptionalPeer("@tiptap/extension-strike", import("@tiptap/extension-strike")),
23
+ loadOptionalPeer("@tiptap/extension-code", import("@tiptap/extension-code")),
24
+ loadOptionalPeer("@tiptap/extension-mention", import("@tiptap/extension-mention"))
25
+ ]);
26
+ return {
27
+ Editor,
28
+ EditorContent,
29
+ Extension,
30
+ Placeholder,
31
+ UndoRedo,
32
+ Document,
33
+ Paragraph,
34
+ Text,
35
+ Bold,
36
+ Italic,
37
+ Strike,
38
+ Code,
39
+ Mention
40
+ };
41
+ }
42
+ const loadTiptap = cachedLoad(importTiptap);
43
+ export {
44
+ loadTiptap
45
+ };
@@ -1,10 +1,11 @@
1
1
  import '../../assets/components/VcCodeBlock/VcCodeBlock.css';
2
- import { defineComponent, ref, useTemplateRef, onMounted, computed, onUnmounted, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createBlock, unref, createElementVNode, normalizeStyle, Fragment, renderList } from "vue";
2
+ import { defineComponent, ref, useTemplateRef, shallowRef, onBeforeMount, onMounted, computed, onUnmounted, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createBlock, unref, createElementVNode, normalizeStyle, Fragment, renderList } from "vue";
3
3
  import { Check, Copy } from "@lucide/vue";
4
- import hljs from "highlight.js/lib/common";
4
+ import { escape } from "lodash-es";
5
5
  import { convertToUnit } from "../../utils/helpers.mjs";
6
6
  import _sfc_main$1 from "../VcButton/VcButtonIcon.vue.mjs";
7
7
  import '../../assets/components/VcButton/VcButtonIcon.css';/* empty css */
8
+ import { loadHljs } from "./highlight.mjs";
8
9
  const _hoisted_1 = {
9
10
  key: 0,
10
11
  class: "vc-code-block__header"
@@ -56,6 +57,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
56
57
  const copied = ref(false);
57
58
  let copiedTimeout;
58
59
  const blockRef = useTemplateRef("blockRef");
60
+ const hljs = shallowRef();
61
+ onBeforeMount(async () => {
62
+ hljs.value = await loadHljs();
63
+ });
59
64
  const surfaceIsDark = ref(false);
60
65
  let themeObserver;
61
66
  function parseRgb(color) {
@@ -97,14 +102,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
97
102
  return props.code.replace(/^\n+/, "").trimEnd();
98
103
  });
99
104
  const resolvedLanguage = computed(() => {
100
- if (props.language && hljs.getLanguage(props.language)) {
105
+ var _a;
106
+ if (props.language && ((_a = hljs.value) == null ? void 0 : _a.getLanguage(props.language))) {
101
107
  return props.language;
102
108
  }
103
109
  return "";
104
110
  });
105
111
  const highlighted = computed(() => {
112
+ const highlighter = hljs.value;
113
+ if (!highlighter) {
114
+ return {
115
+ value: escape(normalizedCode.value),
116
+ language: ""
117
+ };
118
+ }
106
119
  if (resolvedLanguage.value) {
107
- const result2 = hljs.highlight(normalizedCode.value, {
120
+ const result2 = highlighter.highlight(normalizedCode.value, {
108
121
  language: resolvedLanguage.value,
109
122
  ignoreIllegals: true
110
123
  });
@@ -113,7 +126,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
113
126
  language: result2.language ?? resolvedLanguage.value
114
127
  };
115
128
  }
116
- const result = hljs.highlightAuto(normalizedCode.value);
129
+ const result = highlighter.highlightAuto(normalizedCode.value);
117
130
  return {
118
131
  value: result.value,
119
132
  language: result.language ?? ""
@@ -0,0 +1,8 @@
1
+ import { cachedLoad, loadOptionalPeer } from "../../utils/optionalPeer.mjs";
2
+ const loadHljs = cachedLoad(async () => {
3
+ const { default: hljs } = await loadOptionalPeer("highlight.js", import("highlight.js/lib/common"));
4
+ return hljs;
5
+ });
6
+ export {
7
+ loadHljs
8
+ };
@@ -178,8 +178,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
178
178
  var _a2;
179
179
  return (_a2 = searchRef.value) == null ? void 0 : _a2.focus();
180
180
  });
181
- loadGroups().catch(() => {
182
- });
181
+ return loadGroups();
183
182
  }
184
183
  function close(returnFocus = false) {
185
184
  var _a, _b;
@@ -195,9 +194,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
195
194
  function toggle() {
196
195
  if (isOpen.value) {
197
196
  close();
198
- } else {
199
- open();
197
+ return;
200
198
  }
199
+ return open();
201
200
  }
202
201
  function select(emoji) {
203
202
  emit("select", emoji);
@@ -1,26 +1,21 @@
1
+ import { cachedLoad, loadOptionalPeer } from "../../utils/optionalPeer.mjs";
1
2
  const EXCLUDED_GROUP_KEYS = ["component"];
2
- let groupsPromise;
3
- function loadEmojiGroups() {
4
- groupsPromise ?? (groupsPromise = Promise.all([
5
- import("emojibase-data/en/data.json"),
6
- import("emojibase-data/en/messages.json")
7
- ]).then(([{ default: data }, { default: messages }]) => {
8
- return [...messages.groups].sort((a, b) => a.order - b.order).filter((group) => !EXCLUDED_GROUP_KEYS.includes(group.key)).map((group) => ({
9
- key: group.key,
10
- label: group.message,
11
- emojis: data.filter((emoji) => emoji.group === group.order).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).map((emoji) => ({
12
- emoji: emoji.emoji,
13
- label: emoji.label,
14
- tags: emoji.tags ?? [],
15
- version: emoji.version
16
- }))
17
- }));
18
- }).catch((error) => {
19
- groupsPromise = void 0;
20
- throw error;
3
+ const loadEmojiGroups = cachedLoad(async () => {
4
+ const [{ default: data }, { default: messages }] = await Promise.all([
5
+ loadOptionalPeer("emojibase-data", import("emojibase-data/en/data.json")),
6
+ loadOptionalPeer("emojibase-data", import("emojibase-data/en/messages.json"))
7
+ ]);
8
+ return [...messages.groups].sort((a, b) => a.order - b.order).filter((group) => !EXCLUDED_GROUP_KEYS.includes(group.key)).map((group) => ({
9
+ key: group.key,
10
+ label: group.message,
11
+ emojis: data.filter((emoji) => emoji.group === group.order).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).map((emoji) => ({
12
+ emoji: emoji.emoji,
13
+ label: emoji.label,
14
+ tags: emoji.tags ?? [],
15
+ version: emoji.version
16
+ }))
21
17
  }));
22
- return groupsPromise;
23
- }
18
+ });
24
19
  export {
25
20
  loadEmojiGroups
26
21
  };