@uzum-tech/ui 2.4.5 → 2.4.7

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 (64) hide show
  1. package/dist/index.js +112 -21
  2. package/dist/index.mjs +112 -21
  3. package/dist/index.prod.js +3 -3
  4. package/dist/index.prod.mjs +3 -3
  5. package/es/button/src/Button.d.ts +4 -0
  6. package/es/button/src/Button.mjs +4 -2
  7. package/es/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.d.ts +1 -1
  8. package/es/chat/src/ChatParts/ChatHeader/ChatHeader.d.ts +1 -1
  9. package/es/chat/src/styles/index.cssr.mjs +1 -1
  10. package/es/components.d.ts +70 -1
  11. package/es/dialog/src/DialogProvider.d.ts +1 -1579
  12. package/es/editor/index.d.ts +1 -1
  13. package/es/editor/src/Editor.d.ts +21 -0
  14. package/es/editor/src/Editor.mjs +5 -2
  15. package/es/editor/src/EditorParts/EditorContent/EditorContent.d.ts +27 -0
  16. package/es/editor/src/EditorParts/EditorContent/EditorContent.mjs +37 -3
  17. package/es/editor/src/EditorParts/EditorContent/interface.d.ts +11 -0
  18. package/es/editor/src/EditorParts/EditorContent/interface.mjs +2 -0
  19. package/es/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +18 -0
  20. package/es/editor/src/EditorParts/EditorToolbar/interface.d.ts +9 -0
  21. package/es/editor/src/composables/use-editor-css-vars.mjs +8 -2
  22. package/es/editor/src/extensions.d.ts +2 -1
  23. package/es/editor/src/extensions.mjs +34 -4
  24. package/es/editor/src/interface.d.ts +22 -2
  25. package/es/editor/src/interface.mjs +1 -0
  26. package/es/editor/src/styles/index.cssr.mjs +21 -4
  27. package/es/editor/styles/dark.d.ts +3 -0
  28. package/es/editor/styles/light.d.ts +6 -0
  29. package/es/editor/styles/light.mjs +6 -1
  30. package/es/message-bubble/src/styles/index.cssr.mjs +1 -1
  31. package/es/typography/src/text.d.ts +1 -1
  32. package/es/version.d.ts +1 -1
  33. package/es/version.mjs +1 -1
  34. package/lib/button/src/Button.d.ts +4 -0
  35. package/lib/button/src/Button.js +8 -3
  36. package/lib/chat/src/ChatParts/ChatAttachmentButton/ChatAttachmentButton.d.ts +1 -1
  37. package/lib/chat/src/ChatParts/ChatHeader/ChatHeader.d.ts +1 -1
  38. package/lib/chat/src/styles/index.cssr.js +1 -1
  39. package/lib/components.d.ts +70 -1
  40. package/lib/dialog/src/DialogProvider.d.ts +1 -1579
  41. package/lib/editor/index.d.ts +1 -1
  42. package/lib/editor/src/Editor.d.ts +21 -0
  43. package/lib/editor/src/Editor.js +4 -2
  44. package/lib/editor/src/EditorParts/EditorContent/EditorContent.d.ts +27 -0
  45. package/lib/editor/src/EditorParts/EditorContent/EditorContent.js +30 -3
  46. package/lib/editor/src/EditorParts/EditorContent/interface.d.ts +11 -0
  47. package/lib/editor/src/EditorParts/EditorContent/interface.js +1 -1
  48. package/lib/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +18 -0
  49. package/lib/editor/src/EditorParts/EditorToolbar/interface.d.ts +9 -0
  50. package/lib/editor/src/composables/use-editor-css-vars.js +5 -2
  51. package/lib/editor/src/extensions.d.ts +2 -1
  52. package/lib/editor/src/extensions.js +41 -5
  53. package/lib/editor/src/interface.d.ts +22 -2
  54. package/lib/editor/src/interface.js +1 -1
  55. package/lib/editor/src/styles/index.cssr.js +21 -4
  56. package/lib/editor/styles/dark.d.ts +3 -0
  57. package/lib/editor/styles/light.d.ts +6 -0
  58. package/lib/editor/styles/light.js +5 -2
  59. package/lib/message-bubble/src/styles/index.cssr.js +1 -1
  60. package/lib/typography/src/text.d.ts +1 -1
  61. package/lib/version.d.ts +1 -1
  62. package/lib/version.js +1 -1
  63. package/package.json +1 -1
  64. package/web-types.json +32 -3
package/dist/index.js CHANGED
@@ -22507,6 +22507,7 @@
22507
22507
  },
22508
22508
  dashed: Boolean,
22509
22509
  renderIcon: Function,
22510
+ iconProps: Object,
22510
22511
  iconPlacement: {
22511
22512
  type: String,
22512
22513
  default: "left"
@@ -22985,7 +22986,7 @@
22985
22986
  /* @__PURE__ */ vue.h(FadeInExpandTransition, { width: true }, {
22986
22987
  default: () => resolveWrappedSlot(
22987
22988
  this.$slots.icon,
22988
- (children2) => (this.loading || this.renderIcon || children2) && /* @__PURE__ */ vue.h(
22989
+ (children2) => (this.loading || children2 || this.renderIcon || this.iconProps) && /* @__PURE__ */ vue.h(
22989
22990
  "span",
22990
22991
  {
22991
22992
  class: `${mergedClsPrefix}-button__icon`,
@@ -23009,7 +23010,7 @@
23009
23010
  class: `${mergedClsPrefix}-icon-slot`,
23010
23011
  role: "none"
23011
23012
  },
23012
- this.renderIcon ? this.renderIcon() : children2
23013
+ children2 || (this.renderIcon ? this.renderIcon() : this.iconProps ? /* @__PURE__ */ vue.h(UIcon$1, { ...this.iconProps }) : null)
23013
23014
  )
23014
23015
  })
23015
23016
  )
@@ -54541,6 +54542,8 @@
54541
54542
  lineHeightTitleSmall,
54542
54543
  lineHeightBodyLarge,
54543
54544
  lineHeightBodyMedium,
54545
+ fontBodySmall,
54546
+ lineHeightBodySmall,
54544
54547
  surfacePrimary,
54545
54548
  elementsQuaternary,
54546
54549
  elementsQuinary,
@@ -54597,7 +54600,10 @@
54597
54600
  markdownH1LineHeight: lineHeightTitleMedium,
54598
54601
  markdownH2LineHeight: lineHeightTitleSmall,
54599
54602
  markdownH3LineHeight: lineHeightBodyLarge,
54600
- markdownTextLineHeight: lineHeightBodyMedium
54603
+ markdownTextLineHeight: lineHeightBodyMedium,
54604
+ countTextColor: textTertiary,
54605
+ countFontSize: fontBodySmall,
54606
+ countLineHeight: lineHeightBodySmall
54601
54607
  };
54602
54608
  }
54603
54609
  const editorLight = createTheme$1({
@@ -60868,7 +60874,7 @@
60868
60874
  border-radius: var(--u-message-bubble-border-radius);
60869
60875
  font-size: 14px;
60870
60876
  line-height: 20px;
60871
- word-wrap: break-word;
60877
+ overflow-wrap: anywhere;
60872
60878
  background-color: var(--u-message-bubble-background-color-other);
60873
60879
  color: var(--u-message-bubble-text-color-other);
60874
60880
  border-bottom-left-radius: 6px;
@@ -61953,7 +61959,7 @@
61953
61959
  border-radius: 18px;
61954
61960
  font-size: 14px;
61955
61961
  line-height: 20px;
61956
- word-wrap: break-word;
61962
+ overflow-wrap: anywhere;
61957
61963
  background-color: var(--u-message-bubble-background-color-other);
61958
61964
  color: var(--u-message-bubble-text-color-other);
61959
61965
  border-bottom-left-radius: 6px;
@@ -82947,7 +82953,10 @@ img.ProseMirror-separator {
82947
82953
  markdownH1LineHeight,
82948
82954
  markdownH2LineHeight,
82949
82955
  markdownH3LineHeight,
82950
- markdownTextLineHeight
82956
+ markdownTextLineHeight,
82957
+ countTextColor,
82958
+ countFontSize,
82959
+ countLineHeight
82951
82960
  } = themeVarsRef.value;
82952
82961
  return {
82953
82962
  "--u-bezier": cubicBezierEaseInOut,
@@ -82987,7 +82996,10 @@ img.ProseMirror-separator {
82987
82996
  "--u-editor-markdown-h1-line-height": markdownH1LineHeight,
82988
82997
  "--u-editor-markdown-h2-line-height": markdownH2LineHeight,
82989
82998
  "--u-editor-markdown-h3-line-height": markdownH3LineHeight,
82990
- "--u-editor-markdown-text-line-height": markdownTextLineHeight
82999
+ "--u-editor-markdown-text-line-height": markdownTextLineHeight,
83000
+ "--u-editor-count-text-color": countTextColor,
83001
+ "--u-editor-count-font-size": countFontSize,
83002
+ "--u-editor-count-line-height": countLineHeight
82991
83003
  };
82992
83004
  });
82993
83005
  }
@@ -83027,6 +83039,7 @@ img.ProseMirror-separator {
83027
83039
  autofocus: Boolean,
83028
83040
  maxLength: Number,
83029
83041
  maxRows: Number,
83042
+ showCount: Boolean,
83030
83043
  toolbarButtonProps: Object,
83031
83044
  toolbarIconProps: Object,
83032
83045
  toolbarDropdownProps: Object,
@@ -83062,7 +83075,11 @@ img.ProseMirror-separator {
83062
83075
  margin: 0;
83063
83076
  `), cE("toolbar-block-type", `
83064
83077
  width: 71px;
83065
- `)]), cE("content-wrapper", `
83078
+ `)]), cE("body", `
83079
+ display: flex;
83080
+ flex-direction: column;
83081
+ gap: 4px;
83082
+ `), cE("content-wrapper", `
83066
83083
  position: relative;
83067
83084
  box-sizing: border-box;
83068
83085
  display: flex;
@@ -83084,7 +83101,14 @@ img.ProseMirror-separator {
83084
83101
  right: 6px;
83085
83102
  top: 6px;
83086
83103
  flex-shrink: 0;
83087
- `)]), cE("content", `
83104
+ `)]), cE("count", `
83105
+ align-self: flex-end;
83106
+ font-size: var(--u-editor-count-font-size);
83107
+ line-height: var(--u-editor-count-line-height);
83108
+ color: var(--u-editor-count-text-color);
83109
+ white-space: nowrap;
83110
+ padding-right: 10px;
83111
+ `), cE("content", `
83088
83112
  white-space: normal;
83089
83113
  width: 100%;
83090
83114
  min-width: 0;
@@ -83092,7 +83116,7 @@ img.ProseMirror-separator {
83092
83116
  color: var(--u-editor-content-text-color);
83093
83117
  font-size: var(--u-editor-markdown-text-font-size);
83094
83118
  line-height: var(--u-editor-markdown-text-line-height);
83095
- word-wrap: break-word;
83119
+ overflow-wrap: anywhere;
83096
83120
  `, [cM("scrollable", `
83097
83121
  overflow-y: auto;
83098
83122
  scrollbar-width: none;
@@ -83100,7 +83124,10 @@ img.ProseMirror-separator {
83100
83124
  width: 0;
83101
83125
  height: 0;
83102
83126
  display: none;
83103
- `)]), cE("editable", "outline: none;", [c$1(".is-editor-empty:first-child::before", `
83127
+ `)]), cE("editable", `
83128
+ outline: none;
83129
+ overflow-wrap: anywhere;
83130
+ `, [c$1(".is-editor-empty:first-child::before", `
83104
83131
  content: attr(data-placeholder);
83105
83132
  float: left;
83106
83133
  height: 0;
@@ -83191,6 +83218,8 @@ img.ProseMirror-separator {
83191
83218
  },
83192
83219
  sendDisabled: Boolean,
83193
83220
  maxRows: Number,
83221
+ showCount: Boolean,
83222
+ maxLength: Number,
83194
83223
  sendTooltip: String,
83195
83224
  disabled: Boolean,
83196
83225
  sendButtonProps: Object,
@@ -83226,6 +83255,7 @@ img.ProseMirror-separator {
83226
83255
  const sendButtonThemeOverridesRef = vue.computed(() => createSendButtonThemeOverrides(themeVarsRef.value));
83227
83256
  const scrollbarInstRef = vue.ref(null);
83228
83257
  const contentInstRef = vue.ref(null);
83258
+ const characterCountRef = vue.ref(0);
83229
83259
  const mergedMaxRowsRef = vue.computed(
83230
83260
  () => UEditor?.maxRowsRef.value ?? props.maxRows
83231
83261
  );
@@ -83244,18 +83274,27 @@ img.ProseMirror-separator {
83244
83274
  function syncScrollbar() {
83245
83275
  scrollbarInstRef.value?.syncUnifiedContainer();
83246
83276
  }
83277
+ function syncCharacterCount() {
83278
+ characterCountRef.value = editorInstanceRef.value?.storage.characterCount?.characters() ?? 0;
83279
+ }
83280
+ function handleTransaction({ transaction }) {
83281
+ syncScrollbar();
83282
+ if (transaction.docChanged)
83283
+ syncCharacterCount();
83284
+ }
83247
83285
  function unsubscribe() {
83248
- subscribed?.off("transaction", syncScrollbar);
83286
+ subscribed?.off("transaction", handleTransaction);
83249
83287
  subscribed = void 0;
83250
83288
  }
83251
83289
  vue.watch(
83252
83290
  editorInstanceRef,
83253
83291
  (editor) => {
83254
83292
  unsubscribe();
83293
+ syncCharacterCount();
83255
83294
  if (!editor)
83256
83295
  return;
83257
83296
  subscribed = editor;
83258
- editor.on("transaction", syncScrollbar);
83297
+ editor.on("transaction", handleTransaction);
83259
83298
  },
83260
83299
  { immediate: true }
83261
83300
  );
@@ -83294,6 +83333,16 @@ img.ProseMirror-separator {
83294
83333
  mergedContentProps: vue.computed(
83295
83334
  () => UEditor?.contentPropsRef.value ?? props.contentProps
83296
83335
  ),
83336
+ mergedShowCount: vue.computed(
83337
+ () => UEditor?.showCountRef.value ?? props.showCount
83338
+ ),
83339
+ mergedMaxLength: vue.computed(
83340
+ () => UEditor?.maxLengthRef.value ?? props.maxLength
83341
+ ),
83342
+ countAvailable: vue.computed(
83343
+ () => !!editorInstanceRef.value?.storage.characterCount
83344
+ ),
83345
+ characterCount: characterCountRef,
83297
83346
  scrollbarInstRef,
83298
83347
  contentInstRef,
83299
83348
  mergedMaxRows: mergedMaxRowsRef,
@@ -83305,7 +83354,7 @@ img.ProseMirror-separator {
83305
83354
  },
83306
83355
  render() {
83307
83356
  this.onRender?.();
83308
- const content = /* @__PURE__ */ vue.h(
83357
+ const contentWrapper = /* @__PURE__ */ vue.h(
83309
83358
  "div",
83310
83359
  {
83311
83360
  class: [
@@ -83351,6 +83400,16 @@ img.ProseMirror-separator {
83351
83400
  { icon: this.$slots.sendIcon }
83352
83401
  )
83353
83402
  );
83403
+ const content = this.mergedShowCount ? /* @__PURE__ */ vue.h("div", { class: `${this.mergedClsPrefix}-editor__body` }, contentWrapper, this.countAvailable && /* @__PURE__ */ vue.h("span", { class: `${this.mergedClsPrefix}-editor__count` }, resolveSlotWithProps(
83404
+ this.$slots.count,
83405
+ {
83406
+ count: this.characterCount,
83407
+ maxLength: this.mergedMaxLength
83408
+ },
83409
+ () => [
83410
+ this.mergedMaxLength === void 0 ? this.characterCount : `${this.characterCount} / ${this.mergedMaxLength}`
83411
+ ]
83412
+ ))) : contentWrapper;
83354
83413
  if (!this.isStandalone)
83355
83414
  return content;
83356
83415
  return /* @__PURE__ */ vue.h(
@@ -93299,6 +93358,36 @@ img.ProseMirror-separator {
93299
93358
  }];
93300
93359
  }
93301
93360
  });
93361
+ const CharacterLimit = Extension.create({
93362
+ name: "characterLimit",
93363
+ addOptions: () => ({
93364
+ getLimit: () => void 0
93365
+ }),
93366
+ addProseMirrorPlugins() {
93367
+ const {
93368
+ getLimit
93369
+ } = this.options;
93370
+ const count = node => this.editor.storage.characterCount.characters({
93371
+ node
93372
+ });
93373
+ return [new Plugin({
93374
+ filterTransaction: (transaction, state) => {
93375
+ const limit = getLimit();
93376
+ if (!transaction.docChanged || transaction.getMeta("preventUpdate") || !limit) {
93377
+ return true;
93378
+ }
93379
+ const oldSize = count(state.doc);
93380
+ const newSize = count(transaction.doc);
93381
+ if (newSize <= limit) return true;
93382
+ if (oldSize > limit) return newSize <= oldSize;
93383
+ if (!transaction.getMeta("paste")) return false;
93384
+ const pos = transaction.selection.$head.pos;
93385
+ transaction.deleteRange(pos - (newSize - limit), pos);
93386
+ return count(transaction.doc) <= limit;
93387
+ }
93388
+ })];
93389
+ }
93390
+ });
93302
93391
  const SendShortcut = Extension.create({
93303
93392
  name: "sendShortcut",
93304
93393
  priority: 1e3,
@@ -93354,7 +93443,7 @@ img.ProseMirror-separator {
93354
93443
  }
93355
93444
  const single = document.childCount === 1 && document.firstChild?.type.name === "paragraph";
93356
93445
  const slice = single ? new Slice(document.content, 1, 1) : new Slice(document.content, 0, 0);
93357
- view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
93446
+ view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
93358
93447
  return true;
93359
93448
  }
93360
93449
  }
@@ -93401,9 +93490,9 @@ img.ProseMirror-separator {
93401
93490
  }
93402
93491
  }), Placeholder.configure({
93403
93492
  placeholder
93404
- }), ...(maxLength === void 0 ? [] : [CharacterCount.configure({
93405
- limit: maxLength
93406
- })]), MarkdownSource, MarkdownPaste.configure({
93493
+ }), CharacterCount, CharacterLimit.configure({
93494
+ getLimit: typeof maxLength === "function" ? maxLength : () => maxLength
93495
+ }), MarkdownSource, MarkdownPaste.configure({
93407
93496
  markdownOptions
93408
93497
  }), ...(onSendShortcut ? [SendShortcut.configure({
93409
93498
  onSend: onSendShortcut
@@ -93509,7 +93598,7 @@ img.ProseMirror-separator {
93509
93598
  markdownOptions: props.markdownOptions,
93510
93599
  extensions: props.extensions,
93511
93600
  nodeProps: props.nodeProps,
93512
- maxLength: props.maxLength,
93601
+ maxLength: () => props.maxLength,
93513
93602
  onSendShortcut: props.sendOnEnter ? handleSend : void 0
93514
93603
  }),
93515
93604
  editable: editableRef.value,
@@ -93657,6 +93746,8 @@ img.ProseMirror-separator {
93657
93746
  contentPropsRef: vue.toRef(props, "contentProps"),
93658
93747
  maxRowsRef: vue.toRef(props, "maxRows"),
93659
93748
  showSendButtonRef: vue.toRef(props, "showSendButton"),
93749
+ showCountRef: vue.toRef(props, "showCount"),
93750
+ maxLengthRef: vue.toRef(props, "maxLength"),
93660
93751
  sendDisabledRef,
93661
93752
  sendTooltipRef: mergedSendTooltipRef,
93662
93753
  disabledRef: vue.toRef(props, "disabled"),
@@ -93692,7 +93783,7 @@ img.ProseMirror-separator {
93692
93783
  style: this.inlineThemeDisabled ? void 0 : this.cssVars
93693
93784
  },
93694
93785
  this.$slots.toolbar?.() ?? /* @__PURE__ */ vue.h(_UEditorToolbar, null),
93695
- this.$slots.content?.() ?? /* @__PURE__ */ vue.h(_UEditorContent, null, { sendIcon: this.$slots.sendIcon })
93786
+ this.$slots.content?.() ?? /* @__PURE__ */ vue.h(_UEditorContent, null, { sendIcon: this.$slots.sendIcon, count: this.$slots.count })
93696
93787
  );
93697
93788
  }
93698
93789
  });
@@ -155097,7 +155188,7 @@ ${icon.label}`.toLowerCase()
155097
155188
  });
155098
155189
  }
155099
155190
 
155100
- var version = "2.4.5";
155191
+ var version = "2.4.7";
155101
155192
 
155102
155193
  function create({
155103
155194
  componentPrefix = "U",
package/dist/index.mjs CHANGED
@@ -22503,6 +22503,7 @@ const buttonProps = {
22503
22503
  },
22504
22504
  dashed: Boolean,
22505
22505
  renderIcon: Function,
22506
+ iconProps: Object,
22506
22507
  iconPlacement: {
22507
22508
  type: String,
22508
22509
  default: "left"
@@ -22981,7 +22982,7 @@ const Button = defineComponent({
22981
22982
  /* @__PURE__ */ h$1(FadeInExpandTransition, { width: true }, {
22982
22983
  default: () => resolveWrappedSlot(
22983
22984
  this.$slots.icon,
22984
- (children2) => (this.loading || this.renderIcon || children2) && /* @__PURE__ */ h$1(
22985
+ (children2) => (this.loading || children2 || this.renderIcon || this.iconProps) && /* @__PURE__ */ h$1(
22985
22986
  "span",
22986
22987
  {
22987
22988
  class: `${mergedClsPrefix}-button__icon`,
@@ -23005,7 +23006,7 @@ const Button = defineComponent({
23005
23006
  class: `${mergedClsPrefix}-icon-slot`,
23006
23007
  role: "none"
23007
23008
  },
23008
- this.renderIcon ? this.renderIcon() : children2
23009
+ children2 || (this.renderIcon ? this.renderIcon() : this.iconProps ? /* @__PURE__ */ h$1(UIcon$1, { ...this.iconProps }) : null)
23009
23010
  )
23010
23011
  })
23011
23012
  )
@@ -54537,6 +54538,8 @@ function self$M(vars) {
54537
54538
  lineHeightTitleSmall,
54538
54539
  lineHeightBodyLarge,
54539
54540
  lineHeightBodyMedium,
54541
+ fontBodySmall,
54542
+ lineHeightBodySmall,
54540
54543
  surfacePrimary,
54541
54544
  elementsQuaternary,
54542
54545
  elementsQuinary,
@@ -54593,7 +54596,10 @@ function self$M(vars) {
54593
54596
  markdownH1LineHeight: lineHeightTitleMedium,
54594
54597
  markdownH2LineHeight: lineHeightTitleSmall,
54595
54598
  markdownH3LineHeight: lineHeightBodyLarge,
54596
- markdownTextLineHeight: lineHeightBodyMedium
54599
+ markdownTextLineHeight: lineHeightBodyMedium,
54600
+ countTextColor: textTertiary,
54601
+ countFontSize: fontBodySmall,
54602
+ countLineHeight: lineHeightBodySmall
54597
54603
  };
54598
54604
  }
54599
54605
  const editorLight = createTheme$1({
@@ -60864,7 +60870,7 @@ var style$1a = cB("message-bubble", `
60864
60870
  border-radius: var(--u-message-bubble-border-radius);
60865
60871
  font-size: 14px;
60866
60872
  line-height: 20px;
60867
- word-wrap: break-word;
60873
+ overflow-wrap: anywhere;
60868
60874
  background-color: var(--u-message-bubble-background-color-other);
60869
60875
  color: var(--u-message-bubble-text-color-other);
60870
60876
  border-bottom-left-radius: 6px;
@@ -61949,7 +61955,7 @@ var style$19 = cB("chat", `
61949
61955
  border-radius: 18px;
61950
61956
  font-size: 14px;
61951
61957
  line-height: 20px;
61952
- word-wrap: break-word;
61958
+ overflow-wrap: anywhere;
61953
61959
  background-color: var(--u-message-bubble-background-color-other);
61954
61960
  color: var(--u-message-bubble-text-color-other);
61955
61961
  border-bottom-left-radius: 6px;
@@ -82943,7 +82949,10 @@ function useEditorCssVars(themeRef, themeVarsRef) {
82943
82949
  markdownH1LineHeight,
82944
82950
  markdownH2LineHeight,
82945
82951
  markdownH3LineHeight,
82946
- markdownTextLineHeight
82952
+ markdownTextLineHeight,
82953
+ countTextColor,
82954
+ countFontSize,
82955
+ countLineHeight
82947
82956
  } = themeVarsRef.value;
82948
82957
  return {
82949
82958
  "--u-bezier": cubicBezierEaseInOut,
@@ -82983,7 +82992,10 @@ function useEditorCssVars(themeRef, themeVarsRef) {
82983
82992
  "--u-editor-markdown-h1-line-height": markdownH1LineHeight,
82984
82993
  "--u-editor-markdown-h2-line-height": markdownH2LineHeight,
82985
82994
  "--u-editor-markdown-h3-line-height": markdownH3LineHeight,
82986
- "--u-editor-markdown-text-line-height": markdownTextLineHeight
82995
+ "--u-editor-markdown-text-line-height": markdownTextLineHeight,
82996
+ "--u-editor-count-text-color": countTextColor,
82997
+ "--u-editor-count-font-size": countFontSize,
82998
+ "--u-editor-count-line-height": countLineHeight
82987
82999
  };
82988
83000
  });
82989
83001
  }
@@ -83023,6 +83035,7 @@ const editorProps = {
83023
83035
  autofocus: Boolean,
83024
83036
  maxLength: Number,
83025
83037
  maxRows: Number,
83038
+ showCount: Boolean,
83026
83039
  toolbarButtonProps: Object,
83027
83040
  toolbarIconProps: Object,
83028
83041
  toolbarDropdownProps: Object,
@@ -83058,7 +83071,11 @@ var style$16 = c$1([cB("editor", `
83058
83071
  margin: 0;
83059
83072
  `), cE("toolbar-block-type", `
83060
83073
  width: 71px;
83061
- `)]), cE("content-wrapper", `
83074
+ `)]), cE("body", `
83075
+ display: flex;
83076
+ flex-direction: column;
83077
+ gap: 4px;
83078
+ `), cE("content-wrapper", `
83062
83079
  position: relative;
83063
83080
  box-sizing: border-box;
83064
83081
  display: flex;
@@ -83080,7 +83097,14 @@ var style$16 = c$1([cB("editor", `
83080
83097
  right: 6px;
83081
83098
  top: 6px;
83082
83099
  flex-shrink: 0;
83083
- `)]), cE("content", `
83100
+ `)]), cE("count", `
83101
+ align-self: flex-end;
83102
+ font-size: var(--u-editor-count-font-size);
83103
+ line-height: var(--u-editor-count-line-height);
83104
+ color: var(--u-editor-count-text-color);
83105
+ white-space: nowrap;
83106
+ padding-right: 10px;
83107
+ `), cE("content", `
83084
83108
  white-space: normal;
83085
83109
  width: 100%;
83086
83110
  min-width: 0;
@@ -83088,7 +83112,7 @@ var style$16 = c$1([cB("editor", `
83088
83112
  color: var(--u-editor-content-text-color);
83089
83113
  font-size: var(--u-editor-markdown-text-font-size);
83090
83114
  line-height: var(--u-editor-markdown-text-line-height);
83091
- word-wrap: break-word;
83115
+ overflow-wrap: anywhere;
83092
83116
  `, [cM("scrollable", `
83093
83117
  overflow-y: auto;
83094
83118
  scrollbar-width: none;
@@ -83096,7 +83120,10 @@ var style$16 = c$1([cB("editor", `
83096
83120
  width: 0;
83097
83121
  height: 0;
83098
83122
  display: none;
83099
- `)]), cE("editable", "outline: none;", [c$1(".is-editor-empty:first-child::before", `
83123
+ `)]), cE("editable", `
83124
+ outline: none;
83125
+ overflow-wrap: anywhere;
83126
+ `, [c$1(".is-editor-empty:first-child::before", `
83100
83127
  content: attr(data-placeholder);
83101
83128
  float: left;
83102
83129
  height: 0;
@@ -83187,6 +83214,8 @@ const editorContentProps = {
83187
83214
  },
83188
83215
  sendDisabled: Boolean,
83189
83216
  maxRows: Number,
83217
+ showCount: Boolean,
83218
+ maxLength: Number,
83190
83219
  sendTooltip: String,
83191
83220
  disabled: Boolean,
83192
83221
  sendButtonProps: Object,
@@ -83222,6 +83251,7 @@ var _UEditorContent = defineComponent({
83222
83251
  const sendButtonThemeOverridesRef = computed(() => createSendButtonThemeOverrides(themeVarsRef.value));
83223
83252
  const scrollbarInstRef = ref(null);
83224
83253
  const contentInstRef = ref(null);
83254
+ const characterCountRef = ref(0);
83225
83255
  const mergedMaxRowsRef = computed(
83226
83256
  () => UEditor?.maxRowsRef.value ?? props.maxRows
83227
83257
  );
@@ -83240,18 +83270,27 @@ var _UEditorContent = defineComponent({
83240
83270
  function syncScrollbar() {
83241
83271
  scrollbarInstRef.value?.syncUnifiedContainer();
83242
83272
  }
83273
+ function syncCharacterCount() {
83274
+ characterCountRef.value = editorInstanceRef.value?.storage.characterCount?.characters() ?? 0;
83275
+ }
83276
+ function handleTransaction({ transaction }) {
83277
+ syncScrollbar();
83278
+ if (transaction.docChanged)
83279
+ syncCharacterCount();
83280
+ }
83243
83281
  function unsubscribe() {
83244
- subscribed?.off("transaction", syncScrollbar);
83282
+ subscribed?.off("transaction", handleTransaction);
83245
83283
  subscribed = void 0;
83246
83284
  }
83247
83285
  watch(
83248
83286
  editorInstanceRef,
83249
83287
  (editor) => {
83250
83288
  unsubscribe();
83289
+ syncCharacterCount();
83251
83290
  if (!editor)
83252
83291
  return;
83253
83292
  subscribed = editor;
83254
- editor.on("transaction", syncScrollbar);
83293
+ editor.on("transaction", handleTransaction);
83255
83294
  },
83256
83295
  { immediate: true }
83257
83296
  );
@@ -83290,6 +83329,16 @@ var _UEditorContent = defineComponent({
83290
83329
  mergedContentProps: computed(
83291
83330
  () => UEditor?.contentPropsRef.value ?? props.contentProps
83292
83331
  ),
83332
+ mergedShowCount: computed(
83333
+ () => UEditor?.showCountRef.value ?? props.showCount
83334
+ ),
83335
+ mergedMaxLength: computed(
83336
+ () => UEditor?.maxLengthRef.value ?? props.maxLength
83337
+ ),
83338
+ countAvailable: computed(
83339
+ () => !!editorInstanceRef.value?.storage.characterCount
83340
+ ),
83341
+ characterCount: characterCountRef,
83293
83342
  scrollbarInstRef,
83294
83343
  contentInstRef,
83295
83344
  mergedMaxRows: mergedMaxRowsRef,
@@ -83301,7 +83350,7 @@ var _UEditorContent = defineComponent({
83301
83350
  },
83302
83351
  render() {
83303
83352
  this.onRender?.();
83304
- const content = /* @__PURE__ */ h$1(
83353
+ const contentWrapper = /* @__PURE__ */ h$1(
83305
83354
  "div",
83306
83355
  {
83307
83356
  class: [
@@ -83347,6 +83396,16 @@ var _UEditorContent = defineComponent({
83347
83396
  { icon: this.$slots.sendIcon }
83348
83397
  )
83349
83398
  );
83399
+ const content = this.mergedShowCount ? /* @__PURE__ */ h$1("div", { class: `${this.mergedClsPrefix}-editor__body` }, contentWrapper, this.countAvailable && /* @__PURE__ */ h$1("span", { class: `${this.mergedClsPrefix}-editor__count` }, resolveSlotWithProps(
83400
+ this.$slots.count,
83401
+ {
83402
+ count: this.characterCount,
83403
+ maxLength: this.mergedMaxLength
83404
+ },
83405
+ () => [
83406
+ this.mergedMaxLength === void 0 ? this.characterCount : `${this.characterCount} / ${this.mergedMaxLength}`
83407
+ ]
83408
+ ))) : contentWrapper;
83350
83409
  if (!this.isStandalone)
83351
83410
  return content;
83352
83411
  return /* @__PURE__ */ h$1(
@@ -93295,6 +93354,36 @@ const MarkdownSource = Extension.create({
93295
93354
  }];
93296
93355
  }
93297
93356
  });
93357
+ const CharacterLimit = Extension.create({
93358
+ name: "characterLimit",
93359
+ addOptions: () => ({
93360
+ getLimit: () => void 0
93361
+ }),
93362
+ addProseMirrorPlugins() {
93363
+ const {
93364
+ getLimit
93365
+ } = this.options;
93366
+ const count = node => this.editor.storage.characterCount.characters({
93367
+ node
93368
+ });
93369
+ return [new Plugin({
93370
+ filterTransaction: (transaction, state) => {
93371
+ const limit = getLimit();
93372
+ if (!transaction.docChanged || transaction.getMeta("preventUpdate") || !limit) {
93373
+ return true;
93374
+ }
93375
+ const oldSize = count(state.doc);
93376
+ const newSize = count(transaction.doc);
93377
+ if (newSize <= limit) return true;
93378
+ if (oldSize > limit) return newSize <= oldSize;
93379
+ if (!transaction.getMeta("paste")) return false;
93380
+ const pos = transaction.selection.$head.pos;
93381
+ transaction.deleteRange(pos - (newSize - limit), pos);
93382
+ return count(transaction.doc) <= limit;
93383
+ }
93384
+ })];
93385
+ }
93386
+ });
93298
93387
  const SendShortcut = Extension.create({
93299
93388
  name: "sendShortcut",
93300
93389
  priority: 1e3,
@@ -93350,7 +93439,7 @@ const MarkdownPaste = Extension.create({
93350
93439
  }
93351
93440
  const single = document.childCount === 1 && document.firstChild?.type.name === "paragraph";
93352
93441
  const slice = single ? new Slice(document.content, 1, 1) : new Slice(document.content, 0, 0);
93353
- view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
93442
+ view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
93354
93443
  return true;
93355
93444
  }
93356
93445
  }
@@ -93397,9 +93486,9 @@ function createEditorExtensions({
93397
93486
  }
93398
93487
  }), Placeholder.configure({
93399
93488
  placeholder
93400
- }), ...(maxLength === void 0 ? [] : [CharacterCount.configure({
93401
- limit: maxLength
93402
- })]), MarkdownSource, MarkdownPaste.configure({
93489
+ }), CharacterCount, CharacterLimit.configure({
93490
+ getLimit: typeof maxLength === "function" ? maxLength : () => maxLength
93491
+ }), MarkdownSource, MarkdownPaste.configure({
93403
93492
  markdownOptions
93404
93493
  }), ...(onSendShortcut ? [SendShortcut.configure({
93405
93494
  onSend: onSendShortcut
@@ -93505,7 +93594,7 @@ var _UEditor = defineComponent({
93505
93594
  markdownOptions: props.markdownOptions,
93506
93595
  extensions: props.extensions,
93507
93596
  nodeProps: props.nodeProps,
93508
- maxLength: props.maxLength,
93597
+ maxLength: () => props.maxLength,
93509
93598
  onSendShortcut: props.sendOnEnter ? handleSend : void 0
93510
93599
  }),
93511
93600
  editable: editableRef.value,
@@ -93653,6 +93742,8 @@ var _UEditor = defineComponent({
93653
93742
  contentPropsRef: toRef(props, "contentProps"),
93654
93743
  maxRowsRef: toRef(props, "maxRows"),
93655
93744
  showSendButtonRef: toRef(props, "showSendButton"),
93745
+ showCountRef: toRef(props, "showCount"),
93746
+ maxLengthRef: toRef(props, "maxLength"),
93656
93747
  sendDisabledRef,
93657
93748
  sendTooltipRef: mergedSendTooltipRef,
93658
93749
  disabledRef: toRef(props, "disabled"),
@@ -93688,7 +93779,7 @@ var _UEditor = defineComponent({
93688
93779
  style: this.inlineThemeDisabled ? void 0 : this.cssVars
93689
93780
  },
93690
93781
  this.$slots.toolbar?.() ?? /* @__PURE__ */ h$1(_UEditorToolbar, null),
93691
- this.$slots.content?.() ?? /* @__PURE__ */ h$1(_UEditorContent, null, { sendIcon: this.$slots.sendIcon })
93782
+ this.$slots.content?.() ?? /* @__PURE__ */ h$1(_UEditorContent, null, { sendIcon: this.$slots.sendIcon, count: this.$slots.count })
93692
93783
  );
93693
93784
  }
93694
93785
  });
@@ -155093,7 +155184,7 @@ function useThemeVars() {
155093
155184
  });
155094
155185
  }
155095
155186
 
155096
- var version = "2.4.5";
155187
+ var version = "2.4.7";
155097
155188
 
155098
155189
  function create({
155099
155190
  componentPrefix = "U",