@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
@@ -6,5 +6,5 @@ export type { SendButtonProps } from './src/EditorParts/SendButton/interface';
6
6
  export type { ToolbarButtonProps } from './src/EditorParts/ToolbarButton/interface';
7
7
  export { createEditorExtensions } from './src/extensions';
8
8
  export { editorInjectionKey, editorProps } from './src/interface';
9
- export type { EditorInst, EditorNodeProps, EditorProps, EditorSlots, EditorToolbar, EditorToolbarItemKey } from './src/interface';
9
+ export type { EditorCountSlotProps, EditorInst, EditorNodeProps, EditorProps, EditorSlots, EditorToolbar, EditorToolbarItemKey } from './src/interface';
10
10
  export type { Editor } from '@tiptap/vue-3';
@@ -34,6 +34,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
34
34
  readonly autofocus: BooleanConstructor;
35
35
  readonly maxLength: NumberConstructor;
36
36
  readonly maxRows: NumberConstructor;
37
+ readonly showCount: BooleanConstructor;
37
38
  readonly toolbarButtonProps: import("vue").PropType<Partial<import("../..").ButtonProps>>;
38
39
  readonly toolbarIconProps: import("vue").PropType<Partial<import("../..").IconProps>>;
39
40
  readonly toolbarDropdownProps: import("vue").PropType<Partial<import("../..").SelectProps>>;
@@ -98,6 +99,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
98
99
  markdownH2LineHeight: string;
99
100
  markdownH3LineHeight: string;
100
101
  markdownTextLineHeight: string;
102
+ countTextColor: string;
103
+ countFontSize: string;
104
+ countLineHeight: string;
101
105
  }, {
102
106
  Button: import("../../_mixins").Theme<"Button", {
103
107
  heightTiny: string;
@@ -733,6 +737,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
733
737
  markdownH2LineHeight: string;
734
738
  markdownH3LineHeight: string;
735
739
  markdownTextLineHeight: string;
740
+ countTextColor: string;
741
+ countFontSize: string;
742
+ countLineHeight: string;
736
743
  }, {
737
744
  Button: import("../../_mixins").Theme<"Button", {
738
745
  heightTiny: string;
@@ -1368,6 +1375,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1368
1375
  markdownH2LineHeight: string;
1369
1376
  markdownH3LineHeight: string;
1370
1377
  markdownTextLineHeight: string;
1378
+ countTextColor: string;
1379
+ countFontSize: string;
1380
+ countLineHeight: string;
1371
1381
  }, {
1372
1382
  Button: import("../../_mixins").Theme<"Button", {
1373
1383
  heightTiny: string;
@@ -2006,6 +2016,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2006
2016
  readonly autofocus: BooleanConstructor;
2007
2017
  readonly maxLength: NumberConstructor;
2008
2018
  readonly maxRows: NumberConstructor;
2019
+ readonly showCount: BooleanConstructor;
2009
2020
  readonly toolbarButtonProps: import("vue").PropType<Partial<import("../..").ButtonProps>>;
2010
2021
  readonly toolbarIconProps: import("vue").PropType<Partial<import("../..").IconProps>>;
2011
2022
  readonly toolbarDropdownProps: import("vue").PropType<Partial<import("../..").SelectProps>>;
@@ -2070,6 +2081,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2070
2081
  markdownH2LineHeight: string;
2071
2082
  markdownH3LineHeight: string;
2072
2083
  markdownTextLineHeight: string;
2084
+ countTextColor: string;
2085
+ countFontSize: string;
2086
+ countLineHeight: string;
2073
2087
  }, {
2074
2088
  Button: import("../../_mixins").Theme<"Button", {
2075
2089
  heightTiny: string;
@@ -2705,6 +2719,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2705
2719
  markdownH2LineHeight: string;
2706
2720
  markdownH3LineHeight: string;
2707
2721
  markdownTextLineHeight: string;
2722
+ countTextColor: string;
2723
+ countFontSize: string;
2724
+ countLineHeight: string;
2708
2725
  }, {
2709
2726
  Button: import("../../_mixins").Theme<"Button", {
2710
2727
  heightTiny: string;
@@ -3340,6 +3357,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
3340
3357
  markdownH2LineHeight: string;
3341
3358
  markdownH3LineHeight: string;
3342
3359
  markdownTextLineHeight: string;
3360
+ countTextColor: string;
3361
+ countFontSize: string;
3362
+ countLineHeight: string;
3343
3363
  }, {
3344
3364
  Button: import("../../_mixins").Theme<"Button", {
3345
3365
  heightTiny: string;
@@ -3932,6 +3952,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
3932
3952
  readonly disabled: boolean;
3933
3953
  readonly readonly: boolean;
3934
3954
  readonly autofocus: boolean;
3955
+ readonly showCount: boolean;
3935
3956
  readonly toolbar: import("./interface").EditorToolbar;
3936
3957
  readonly showSendButton: boolean;
3937
3958
  readonly sendOnEnter: boolean;
@@ -46,7 +46,7 @@ export default defineComponent({
46
46
  markdownOptions: props.markdownOptions,
47
47
  extensions: props.extensions,
48
48
  nodeProps: props.nodeProps,
49
- maxLength: props.maxLength,
49
+ maxLength: () => props.maxLength,
50
50
  onSendShortcut: props.sendOnEnter ? handleSend : undefined
51
51
  }),
52
52
  editable: editableRef.value,
@@ -203,6 +203,8 @@ export default defineComponent({
203
203
  contentPropsRef: toRef(props, 'contentProps'),
204
204
  maxRowsRef: toRef(props, 'maxRows'),
205
205
  showSendButtonRef: toRef(props, 'showSendButton'),
206
+ showCountRef: toRef(props, 'showCount'),
207
+ maxLengthRef: toRef(props, 'maxLength'),
206
208
  sendDisabledRef,
207
209
  sendTooltipRef: mergedSendTooltipRef,
208
210
  disabledRef: toRef(props, 'disabled'),
@@ -236,7 +238,8 @@ export default defineComponent({
236
238
  class: [`${this.mergedClsPrefix}-editor`, this.themeClass],
237
239
  style: this.inlineThemeDisabled ? undefined : this.cssVars
238
240
  }, (_d = (_c = (_b = this.$slots).toolbar) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : h(EditorToolbar, null), (_g = (_f = (_e = this.$slots).content) === null || _f === void 0 ? void 0 : _f.call(_e)) !== null && _g !== void 0 ? _g : h(EditorContent, null, {
239
- sendIcon: this.$slots.sendIcon
241
+ sendIcon: this.$slots.sendIcon,
242
+ count: this.$slots.count
240
243
  }));
241
244
  }
242
245
  });
@@ -13,6 +13,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
13
13
  };
14
14
  readonly sendDisabled: BooleanConstructor;
15
15
  readonly maxRows: NumberConstructor;
16
+ readonly showCount: BooleanConstructor;
17
+ readonly maxLength: NumberConstructor;
16
18
  readonly sendTooltip: StringConstructor;
17
19
  readonly disabled: BooleanConstructor;
18
20
  readonly sendButtonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
@@ -67,6 +69,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
67
69
  markdownH2LineHeight: string;
68
70
  markdownH3LineHeight: string;
69
71
  markdownTextLineHeight: string;
72
+ countTextColor: string;
73
+ countFontSize: string;
74
+ countLineHeight: string;
70
75
  }, {
71
76
  Button: import("../../../../_mixins").Theme<"Button", {
72
77
  heightTiny: string;
@@ -702,6 +707,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
702
707
  markdownH2LineHeight: string;
703
708
  markdownH3LineHeight: string;
704
709
  markdownTextLineHeight: string;
710
+ countTextColor: string;
711
+ countFontSize: string;
712
+ countLineHeight: string;
705
713
  }, {
706
714
  Button: import("../../../../_mixins").Theme<"Button", {
707
715
  heightTiny: string;
@@ -1337,6 +1345,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1337
1345
  markdownH2LineHeight: string;
1338
1346
  markdownH3LineHeight: string;
1339
1347
  markdownTextLineHeight: string;
1348
+ countTextColor: string;
1349
+ countFontSize: string;
1350
+ countLineHeight: string;
1340
1351
  }, {
1341
1352
  Button: import("../../../../_mixins").Theme<"Button", {
1342
1353
  heightTiny: string;
@@ -2157,6 +2168,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2157
2168
  mergedSendButtonProps: import("vue").ComputedRef<Partial<import("../../../..").ButtonProps> | undefined>;
2158
2169
  mergedSendIconProps: import("vue").ComputedRef<Partial<import("../../../..").IconProps> | undefined>;
2159
2170
  mergedContentProps: import("vue").ComputedRef<import("vue").HTMLAttributes | undefined>;
2171
+ mergedShowCount: import("vue").ComputedRef<boolean>;
2172
+ mergedMaxLength: import("vue").ComputedRef<number | undefined>;
2173
+ countAvailable: import("vue").ComputedRef<boolean>;
2174
+ characterCount: import("vue").Ref<number, number>;
2160
2175
  scrollbarInstRef: import("vue").Ref<{
2161
2176
  $el: HTMLElement;
2162
2177
  containerRef: HTMLElement | null;
@@ -2203,6 +2218,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2203
2218
  };
2204
2219
  readonly sendDisabled: BooleanConstructor;
2205
2220
  readonly maxRows: NumberConstructor;
2221
+ readonly showCount: BooleanConstructor;
2222
+ readonly maxLength: NumberConstructor;
2206
2223
  readonly sendTooltip: StringConstructor;
2207
2224
  readonly disabled: BooleanConstructor;
2208
2225
  readonly sendButtonProps: import("vue").PropType<Partial<import("../../../..").ButtonProps>>;
@@ -2257,6 +2274,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2257
2274
  markdownH2LineHeight: string;
2258
2275
  markdownH3LineHeight: string;
2259
2276
  markdownTextLineHeight: string;
2277
+ countTextColor: string;
2278
+ countFontSize: string;
2279
+ countLineHeight: string;
2260
2280
  }, {
2261
2281
  Button: import("../../../../_mixins").Theme<"Button", {
2262
2282
  heightTiny: string;
@@ -2892,6 +2912,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2892
2912
  markdownH2LineHeight: string;
2893
2913
  markdownH3LineHeight: string;
2894
2914
  markdownTextLineHeight: string;
2915
+ countTextColor: string;
2916
+ countFontSize: string;
2917
+ countLineHeight: string;
2895
2918
  }, {
2896
2919
  Button: import("../../../../_mixins").Theme<"Button", {
2897
2920
  heightTiny: string;
@@ -3527,6 +3550,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
3527
3550
  markdownH2LineHeight: string;
3528
3551
  markdownH3LineHeight: string;
3529
3552
  markdownTextLineHeight: string;
3553
+ countTextColor: string;
3554
+ countFontSize: string;
3555
+ countLineHeight: string;
3530
3556
  }, {
3531
3557
  Button: import("../../../../_mixins").Theme<"Button", {
3532
3558
  heightTiny: string;
@@ -4116,6 +4142,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
4116
4142
  }>>>;
4117
4143
  }>> & Readonly<{}>, {
4118
4144
  readonly disabled: boolean;
4145
+ readonly showCount: boolean;
4119
4146
  readonly showSendButton: boolean;
4120
4147
  readonly sendDisabled: boolean;
4121
4148
  }, SlotsType<EditorSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -2,6 +2,7 @@ import { EditorContent } from '@tiptap/vue-3';
2
2
  import { computed, defineComponent, h, inject, onBeforeUnmount, ref, watch } from 'vue';
3
3
  import { UScrollbar } from "../../../../_internal/index.mjs";
4
4
  import { useConfig, useTheme, useThemeClass } from "../../../../_mixins/index.mjs";
5
+ import { resolveSlotWithProps } from "../../../../_utils/index.mjs";
5
6
  import { createSendButtonThemeOverrides } from "../../../../chat/styles/light.mjs";
6
7
  import { editorLight } from "../../../styles/index.mjs";
7
8
  import useEditorCssVars from "../../composables/use-editor-css-vars.mjs";
@@ -34,6 +35,7 @@ export default defineComponent({
34
35
  const sendButtonThemeOverridesRef = computed(() => createSendButtonThemeOverrides(themeVarsRef.value));
35
36
  const scrollbarInstRef = ref(null);
36
37
  const contentInstRef = ref(null);
38
+ const characterCountRef = ref(0);
37
39
  const mergedMaxRowsRef = computed(() => {
38
40
  var _a;
39
41
  return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.maxRowsRef.value) !== null && _a !== void 0 ? _a : props.maxRows;
@@ -54,15 +56,26 @@ export default defineComponent({
54
56
  var _a;
55
57
  (_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.syncUnifiedContainer();
56
58
  }
59
+ function syncCharacterCount() {
60
+ var _a, _b, _c;
61
+ characterCountRef.value = (_c = (_b = (_a = editorInstanceRef.value) === null || _a === void 0 ? void 0 : _a.storage.characterCount) === null || _b === void 0 ? void 0 : _b.characters()) !== null && _c !== void 0 ? _c : 0;
62
+ }
63
+ function handleTransaction({
64
+ transaction
65
+ }) {
66
+ syncScrollbar();
67
+ if (transaction.docChanged) syncCharacterCount();
68
+ }
57
69
  function unsubscribe() {
58
- subscribed === null || subscribed === void 0 ? void 0 : subscribed.off('transaction', syncScrollbar);
70
+ subscribed === null || subscribed === void 0 ? void 0 : subscribed.off('transaction', handleTransaction);
59
71
  subscribed = undefined;
60
72
  }
61
73
  watch(editorInstanceRef, editor => {
62
74
  unsubscribe();
75
+ syncCharacterCount();
63
76
  if (!editor) return;
64
77
  subscribed = editor;
65
- editor.on('transaction', syncScrollbar);
78
+ editor.on('transaction', handleTransaction);
66
79
  }, {
67
80
  immediate: true
68
81
  });
@@ -108,6 +121,19 @@ export default defineComponent({
108
121
  var _a;
109
122
  return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.contentPropsRef.value) !== null && _a !== void 0 ? _a : props.contentProps;
110
123
  }),
124
+ mergedShowCount: computed(() => {
125
+ var _a;
126
+ return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.showCountRef.value) !== null && _a !== void 0 ? _a : props.showCount;
127
+ }),
128
+ mergedMaxLength: computed(() => {
129
+ var _a;
130
+ return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.maxLengthRef.value) !== null && _a !== void 0 ? _a : props.maxLength;
131
+ }),
132
+ countAvailable: computed(() => {
133
+ var _a;
134
+ return !!((_a = editorInstanceRef.value) === null || _a === void 0 ? void 0 : _a.storage.characterCount);
135
+ }),
136
+ characterCount: characterCountRef,
111
137
  scrollbarInstRef,
112
138
  contentInstRef,
113
139
  mergedMaxRows: mergedMaxRowsRef,
@@ -120,7 +146,7 @@ export default defineComponent({
120
146
  render() {
121
147
  var _a;
122
148
  (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
123
- const content = h("div", {
149
+ const contentWrapper = h("div", {
124
150
  class: [`${this.mergedClsPrefix}-editor__content-wrapper`, this.isStandalone && `${this.mergedClsPrefix}-editor__content-wrapper--standalone`]
125
151
  }, h(UScrollbar, {
126
152
  ref: "scrollbarInstRef",
@@ -145,6 +171,14 @@ export default defineComponent({
145
171
  }, {
146
172
  icon: this.$slots.sendIcon
147
173
  }));
174
+ const content = this.mergedShowCount ? h("div", {
175
+ class: `${this.mergedClsPrefix}-editor__body`
176
+ }, contentWrapper, this.countAvailable && h("span", {
177
+ class: `${this.mergedClsPrefix}-editor__count`
178
+ }, resolveSlotWithProps(this.$slots.count, {
179
+ count: this.characterCount,
180
+ maxLength: this.mergedMaxLength
181
+ }, () => [this.mergedMaxLength === undefined ? this.characterCount : `${this.characterCount} / ${this.mergedMaxLength}`]))) : contentWrapper;
148
182
  if (!this.isStandalone) return content;
149
183
  return h("div", {
150
184
  class: [`${this.mergedClsPrefix}-editor`, this.themeClass],
@@ -13,6 +13,8 @@ export declare const editorContentProps: {
13
13
  };
14
14
  readonly sendDisabled: BooleanConstructor;
15
15
  readonly maxRows: NumberConstructor;
16
+ readonly showCount: BooleanConstructor;
17
+ readonly maxLength: NumberConstructor;
16
18
  readonly sendTooltip: StringConstructor;
17
19
  readonly disabled: BooleanConstructor;
18
20
  readonly sendButtonProps: PropType<Partial<ButtonProps>>;
@@ -67,6 +69,9 @@ export declare const editorContentProps: {
67
69
  markdownH2LineHeight: string;
68
70
  markdownH3LineHeight: string;
69
71
  markdownTextLineHeight: string;
72
+ countTextColor: string;
73
+ countFontSize: string;
74
+ countLineHeight: string;
70
75
  }, {
71
76
  Button: import("../../../../_mixins").Theme<"Button", {
72
77
  heightTiny: string;
@@ -702,6 +707,9 @@ export declare const editorContentProps: {
702
707
  markdownH2LineHeight: string;
703
708
  markdownH3LineHeight: string;
704
709
  markdownTextLineHeight: string;
710
+ countTextColor: string;
711
+ countFontSize: string;
712
+ countLineHeight: string;
705
713
  }, {
706
714
  Button: import("../../../../_mixins").Theme<"Button", {
707
715
  heightTiny: string;
@@ -1337,6 +1345,9 @@ export declare const editorContentProps: {
1337
1345
  markdownH2LineHeight: string;
1338
1346
  markdownH3LineHeight: string;
1339
1347
  markdownTextLineHeight: string;
1348
+ countTextColor: string;
1349
+ countFontSize: string;
1350
+ countLineHeight: string;
1340
1351
  }, {
1341
1352
  Button: import("../../../../_mixins").Theme<"Button", {
1342
1353
  heightTiny: string;
@@ -8,6 +8,8 @@ export const editorContentProps = Object.assign(Object.assign({}, useTheme.props
8
8
  },
9
9
  sendDisabled: Boolean,
10
10
  maxRows: Number,
11
+ showCount: Boolean,
12
+ maxLength: Number,
11
13
  sendTooltip: String,
12
14
  disabled: Boolean,
13
15
  sendButtonProps: Object,
@@ -67,6 +67,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
67
67
  markdownH2LineHeight: string;
68
68
  markdownH3LineHeight: string;
69
69
  markdownTextLineHeight: string;
70
+ countTextColor: string;
71
+ countFontSize: string;
72
+ countLineHeight: string;
70
73
  }, {
71
74
  Button: import("../../../../_mixins").Theme<"Button", {
72
75
  heightTiny: string;
@@ -702,6 +705,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
702
705
  markdownH2LineHeight: string;
703
706
  markdownH3LineHeight: string;
704
707
  markdownTextLineHeight: string;
708
+ countTextColor: string;
709
+ countFontSize: string;
710
+ countLineHeight: string;
705
711
  }, {
706
712
  Button: import("../../../../_mixins").Theme<"Button", {
707
713
  heightTiny: string;
@@ -1337,6 +1343,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
1337
1343
  markdownH2LineHeight: string;
1338
1344
  markdownH3LineHeight: string;
1339
1345
  markdownTextLineHeight: string;
1346
+ countTextColor: string;
1347
+ countFontSize: string;
1348
+ countLineHeight: string;
1340
1349
  }, {
1341
1350
  Button: import("../../../../_mixins").Theme<"Button", {
1342
1351
  heightTiny: string;
@@ -2762,6 +2771,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
2762
2771
  markdownH2LineHeight: string;
2763
2772
  markdownH3LineHeight: string;
2764
2773
  markdownTextLineHeight: string;
2774
+ countTextColor: string;
2775
+ countFontSize: string;
2776
+ countLineHeight: string;
2765
2777
  }, {
2766
2778
  Button: import("../../../../_mixins").Theme<"Button", {
2767
2779
  heightTiny: string;
@@ -3397,6 +3409,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
3397
3409
  markdownH2LineHeight: string;
3398
3410
  markdownH3LineHeight: string;
3399
3411
  markdownTextLineHeight: string;
3412
+ countTextColor: string;
3413
+ countFontSize: string;
3414
+ countLineHeight: string;
3400
3415
  }, {
3401
3416
  Button: import("../../../../_mixins").Theme<"Button", {
3402
3417
  heightTiny: string;
@@ -4032,6 +4047,9 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
4032
4047
  markdownH2LineHeight: string;
4033
4048
  markdownH3LineHeight: string;
4034
4049
  markdownTextLineHeight: string;
4050
+ countTextColor: string;
4051
+ countFontSize: string;
4052
+ countLineHeight: string;
4035
4053
  }, {
4036
4054
  Button: import("../../../../_mixins").Theme<"Button", {
4037
4055
  heightTiny: string;
@@ -73,6 +73,9 @@ export declare const editorToolbarProps: {
73
73
  markdownH2LineHeight: string;
74
74
  markdownH3LineHeight: string;
75
75
  markdownTextLineHeight: string;
76
+ countTextColor: string;
77
+ countFontSize: string;
78
+ countLineHeight: string;
76
79
  }, {
77
80
  Button: import("../../../../_mixins").Theme<"Button", {
78
81
  heightTiny: string;
@@ -708,6 +711,9 @@ export declare const editorToolbarProps: {
708
711
  markdownH2LineHeight: string;
709
712
  markdownH3LineHeight: string;
710
713
  markdownTextLineHeight: string;
714
+ countTextColor: string;
715
+ countFontSize: string;
716
+ countLineHeight: string;
711
717
  }, {
712
718
  Button: import("../../../../_mixins").Theme<"Button", {
713
719
  heightTiny: string;
@@ -1343,6 +1349,9 @@ export declare const editorToolbarProps: {
1343
1349
  markdownH2LineHeight: string;
1344
1350
  markdownH3LineHeight: string;
1345
1351
  markdownTextLineHeight: string;
1352
+ countTextColor: string;
1353
+ countFontSize: string;
1354
+ countLineHeight: string;
1346
1355
  }, {
1347
1356
  Button: import("../../../../_mixins").Theme<"Button", {
1348
1357
  heightTiny: string;
@@ -43,7 +43,10 @@ export default function useEditorCssVars(themeRef, themeVarsRef) {
43
43
  markdownH1LineHeight,
44
44
  markdownH2LineHeight,
45
45
  markdownH3LineHeight,
46
- markdownTextLineHeight
46
+ markdownTextLineHeight,
47
+ countTextColor,
48
+ countFontSize,
49
+ countLineHeight
47
50
  } = themeVarsRef.value;
48
51
  return {
49
52
  '--u-bezier': cubicBezierEaseInOut,
@@ -83,7 +86,10 @@ export default function useEditorCssVars(themeRef, themeVarsRef) {
83
86
  '--u-editor-markdown-h1-line-height': markdownH1LineHeight,
84
87
  '--u-editor-markdown-h2-line-height': markdownH2LineHeight,
85
88
  '--u-editor-markdown-h3-line-height': markdownH3LineHeight,
86
- '--u-editor-markdown-text-line-height': markdownTextLineHeight
89
+ '--u-editor-markdown-text-line-height': markdownTextLineHeight,
90
+ '--u-editor-count-text-color': countTextColor,
91
+ '--u-editor-count-font-size': countFontSize,
92
+ '--u-editor-count-line-height': countLineHeight
87
93
  };
88
94
  });
89
95
  }
@@ -1,7 +1,8 @@
1
1
  import type { Extensions } from '@tiptap/core';
2
- import type { CreateEditorExtensionsOptions, MarkdownPasteOptions, SendShortcutOptions } from './interface';
2
+ import type { CharacterLimitOptions, CreateEditorExtensionsOptions, MarkdownPasteOptions, SendShortcutOptions } from './interface';
3
3
  import { Extension } from '@tiptap/core';
4
4
  export declare const MarkdownSource: Extension<any, any>;
5
+ export declare const CharacterLimit: Extension<CharacterLimitOptions, any>;
5
6
  export declare const SendShortcut: Extension<SendShortcutOptions, any>;
6
7
  export declare const MarkdownPaste: Extension<MarkdownPasteOptions, any>;
7
8
  export declare function createEditorExtensions({ placeholder, markdownOptions, extensions, nodeProps, maxLength, onSendShortcut }?: CreateEditorExtensionsOptions): Extensions;
@@ -21,6 +21,36 @@ export const MarkdownSource = Extension.create({
21
21
  }];
22
22
  }
23
23
  });
24
+ export const CharacterLimit = Extension.create({
25
+ name: 'characterLimit',
26
+ addOptions: () => ({
27
+ getLimit: () => undefined
28
+ }),
29
+ addProseMirrorPlugins() {
30
+ const {
31
+ getLimit
32
+ } = this.options;
33
+ const count = node => this.editor.storage.characterCount.characters({
34
+ node
35
+ });
36
+ return [new Plugin({
37
+ filterTransaction: (transaction, state) => {
38
+ const limit = getLimit();
39
+ if (!transaction.docChanged || transaction.getMeta('preventUpdate') || !limit) {
40
+ return true;
41
+ }
42
+ const oldSize = count(state.doc);
43
+ const newSize = count(transaction.doc);
44
+ if (newSize <= limit) return true;
45
+ if (oldSize > limit) return newSize <= oldSize;
46
+ if (!transaction.getMeta('paste')) return false;
47
+ const pos = transaction.selection.$head.pos;
48
+ transaction.deleteRange(pos - (newSize - limit), pos);
49
+ return count(transaction.doc) <= limit;
50
+ }
51
+ })];
52
+ }
53
+ });
24
54
  export const SendShortcut = Extension.create({
25
55
  name: 'sendShortcut',
26
56
  priority: 1000,
@@ -77,7 +107,7 @@ export const MarkdownPaste = Extension.create({
77
107
  }
78
108
  const single = document.childCount === 1 && ((_b = document.firstChild) === null || _b === void 0 ? void 0 : _b.type.name) === 'paragraph';
79
109
  const slice = single ? new Slice(document.content, 1, 1) : new Slice(document.content, 0, 0);
80
- view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
110
+ view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView().setMeta('paste', true).setMeta('uiEvent', 'paste'));
81
111
  return true;
82
112
  }
83
113
  }
@@ -125,9 +155,9 @@ export function createEditorExtensions({
125
155
  }
126
156
  }), Placeholder.configure({
127
157
  placeholder
128
- }), ...(maxLength === undefined ? [] : [CharacterCount.configure({
129
- limit: maxLength
130
- })]), MarkdownSource, MarkdownPaste.configure({
158
+ }), CharacterCount, CharacterLimit.configure({
159
+ getLimit: typeof maxLength === 'function' ? maxLength : () => maxLength
160
+ }), MarkdownSource, MarkdownPaste.configure({
131
161
  markdownOptions
132
162
  }), ...(onSendShortcut ? [SendShortcut.configure({
133
163
  onSend: onSendShortcut
@@ -1,7 +1,7 @@
1
1
  import type { Extensions } from '@tiptap/core';
2
2
  import type { Editor } from '@tiptap/vue-3';
3
3
  import type { MarkdownSerializer, MarkdownSerializerState } from 'prosemirror-markdown';
4
- import type { HTMLAttributes, PropType, Ref, UnwrapRef, VNodeChild } from 'vue';
4
+ import type { HTMLAttributes, PropType, Ref, UnwrapRef, VNode, VNodeChild } from 'vue';
5
5
  import type { MergedTheme } from '../../_mixins/use-theme';
6
6
  import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils';
7
7
  import type { MarkdownOptions } from '../../_utils/markdown';
@@ -18,12 +18,15 @@ export interface CreateEditorExtensionsOptions {
18
18
  markdownOptions?: MarkdownOptions;
19
19
  extensions?: Extensions;
20
20
  nodeProps?: EditorNodeProps;
21
- maxLength?: number;
21
+ maxLength?: number | (() => number | undefined);
22
22
  onSendShortcut?: VoidFunction;
23
23
  }
24
24
  export interface SendShortcutOptions {
25
25
  onSend: VoidFunction | null;
26
26
  }
27
+ export interface CharacterLimitOptions {
28
+ getLimit: () => number | undefined;
29
+ }
27
30
  export interface MarkdownPasteOptions {
28
31
  markdownOptions?: MarkdownOptions;
29
32
  }
@@ -31,6 +34,11 @@ export interface EditorSlots {
31
34
  toolbar?: () => VNodeChild;
32
35
  content?: () => VNodeChild;
33
36
  sendIcon?: () => VNodeChild;
37
+ count?: (props: EditorCountSlotProps) => VNode[];
38
+ }
39
+ export interface EditorCountSlotProps {
40
+ count: number;
41
+ maxLength: number | undefined;
34
42
  }
35
43
  export interface MarkdownSerializerStateOptions {
36
44
  tightLists?: boolean;
@@ -82,6 +90,8 @@ export declare const editorInjectionKey: import("vue").InjectionKey<{
82
90
  contentPropsRef: Ref<HTMLAttributes | undefined>;
83
91
  maxRowsRef: Ref<number | undefined>;
84
92
  showSendButtonRef: Ref<boolean>;
93
+ showCountRef: Ref<boolean>;
94
+ maxLengthRef: Ref<number | undefined>;
85
95
  sendDisabledRef: Ref<boolean>;
86
96
  sendTooltipRef: Ref<string>;
87
97
  disabledRef: Ref<boolean>;
@@ -122,6 +132,7 @@ export declare const editorProps: {
122
132
  readonly autofocus: BooleanConstructor;
123
133
  readonly maxLength: NumberConstructor;
124
134
  readonly maxRows: NumberConstructor;
135
+ readonly showCount: BooleanConstructor;
125
136
  readonly toolbarButtonProps: PropType<Partial<ButtonProps>>;
126
137
  readonly toolbarIconProps: PropType<Partial<IconProps>>;
127
138
  readonly toolbarDropdownProps: PropType<Partial<SelectProps>>;
@@ -186,6 +197,9 @@ export declare const editorProps: {
186
197
  markdownH2LineHeight: string;
187
198
  markdownH3LineHeight: string;
188
199
  markdownTextLineHeight: string;
200
+ countTextColor: string;
201
+ countFontSize: string;
202
+ countLineHeight: string;
189
203
  }, {
190
204
  Button: import("../../_mixins").Theme<"Button", {
191
205
  heightTiny: string;
@@ -821,6 +835,9 @@ export declare const editorProps: {
821
835
  markdownH2LineHeight: string;
822
836
  markdownH3LineHeight: string;
823
837
  markdownTextLineHeight: string;
838
+ countTextColor: string;
839
+ countFontSize: string;
840
+ countLineHeight: string;
824
841
  }, {
825
842
  Button: import("../../_mixins").Theme<"Button", {
826
843
  heightTiny: string;
@@ -1456,6 +1473,9 @@ export declare const editorProps: {
1456
1473
  markdownH2LineHeight: string;
1457
1474
  markdownH3LineHeight: string;
1458
1475
  markdownTextLineHeight: string;
1476
+ countTextColor: string;
1477
+ countFontSize: string;
1478
+ countLineHeight: string;
1459
1479
  }, {
1460
1480
  Button: import("../../_mixins").Theme<"Button", {
1461
1481
  heightTiny: string;
@@ -34,6 +34,7 @@ export const editorProps = Object.assign(Object.assign({}, useTheme.props), {
34
34
  autofocus: Boolean,
35
35
  maxLength: Number,
36
36
  maxRows: Number,
37
+ showCount: Boolean,
37
38
  toolbarButtonProps: Object,
38
39
  toolbarIconProps: Object,
39
40
  toolbarDropdownProps: Object,