@uzum-tech/ui 2.4.6 → 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 (52) hide show
  1. package/dist/index.js +109 -19
  2. package/dist/index.mjs +109 -19
  3. package/dist/index.prod.js +2 -2
  4. package/dist/index.prod.mjs +2 -2
  5. package/es/chat/src/styles/index.cssr.mjs +1 -1
  6. package/es/components.d.ts +66 -0
  7. package/es/editor/index.d.ts +1 -1
  8. package/es/editor/src/Editor.d.ts +21 -0
  9. package/es/editor/src/Editor.mjs +5 -2
  10. package/es/editor/src/EditorParts/EditorContent/EditorContent.d.ts +27 -0
  11. package/es/editor/src/EditorParts/EditorContent/EditorContent.mjs +37 -3
  12. package/es/editor/src/EditorParts/EditorContent/interface.d.ts +11 -0
  13. package/es/editor/src/EditorParts/EditorContent/interface.mjs +2 -0
  14. package/es/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +18 -0
  15. package/es/editor/src/EditorParts/EditorToolbar/interface.d.ts +9 -0
  16. package/es/editor/src/composables/use-editor-css-vars.mjs +8 -2
  17. package/es/editor/src/extensions.d.ts +2 -1
  18. package/es/editor/src/extensions.mjs +34 -4
  19. package/es/editor/src/interface.d.ts +22 -2
  20. package/es/editor/src/interface.mjs +1 -0
  21. package/es/editor/src/styles/index.cssr.mjs +21 -4
  22. package/es/editor/styles/dark.d.ts +3 -0
  23. package/es/editor/styles/light.d.ts +6 -0
  24. package/es/editor/styles/light.mjs +6 -1
  25. package/es/message-bubble/src/styles/index.cssr.mjs +1 -1
  26. package/es/version.d.ts +1 -1
  27. package/es/version.mjs +1 -1
  28. package/lib/chat/src/styles/index.cssr.js +1 -1
  29. package/lib/components.d.ts +66 -0
  30. package/lib/editor/index.d.ts +1 -1
  31. package/lib/editor/src/Editor.d.ts +21 -0
  32. package/lib/editor/src/Editor.js +4 -2
  33. package/lib/editor/src/EditorParts/EditorContent/EditorContent.d.ts +27 -0
  34. package/lib/editor/src/EditorParts/EditorContent/EditorContent.js +30 -3
  35. package/lib/editor/src/EditorParts/EditorContent/interface.d.ts +11 -0
  36. package/lib/editor/src/EditorParts/EditorContent/interface.js +1 -1
  37. package/lib/editor/src/EditorParts/EditorToolbar/EditorToolbar.d.ts +18 -0
  38. package/lib/editor/src/EditorParts/EditorToolbar/interface.d.ts +9 -0
  39. package/lib/editor/src/composables/use-editor-css-vars.js +5 -2
  40. package/lib/editor/src/extensions.d.ts +2 -1
  41. package/lib/editor/src/extensions.js +41 -5
  42. package/lib/editor/src/interface.d.ts +22 -2
  43. package/lib/editor/src/interface.js +1 -1
  44. package/lib/editor/src/styles/index.cssr.js +21 -4
  45. package/lib/editor/styles/dark.d.ts +3 -0
  46. package/lib/editor/styles/light.d.ts +6 -0
  47. package/lib/editor/styles/light.js +5 -2
  48. package/lib/message-bubble/src/styles/index.cssr.js +1 -1
  49. package/lib/version.d.ts +1 -1
  50. package/lib/version.js +1 -1
  51. package/package.json +1 -1
  52. package/web-types.json +21 -2
@@ -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;
@@ -43,7 +43,7 @@ exports.default = (0, vue_1.defineComponent)({
43
43
  markdownOptions: props.markdownOptions,
44
44
  extensions: props.extensions,
45
45
  nodeProps: props.nodeProps,
46
- maxLength: props.maxLength,
46
+ maxLength: () => props.maxLength,
47
47
  onSendShortcut: props.sendOnEnter ? handleSend : undefined
48
48
  }),
49
49
  editable: editableRef.value,
@@ -202,6 +202,8 @@ exports.default = (0, vue_1.defineComponent)({
202
202
  contentPropsRef: (0, vue_1.toRef)(props, 'contentProps'),
203
203
  maxRowsRef: (0, vue_1.toRef)(props, 'maxRows'),
204
204
  showSendButtonRef: (0, vue_1.toRef)(props, 'showSendButton'),
205
+ showCountRef: (0, vue_1.toRef)(props, 'showCount'),
206
+ maxLengthRef: (0, vue_1.toRef)(props, 'maxLength'),
205
207
  sendDisabledRef,
206
208
  sendTooltipRef: mergedSendTooltipRef,
207
209
  disabledRef: (0, vue_1.toRef)(props, 'disabled'),
@@ -231,6 +233,6 @@ exports.default = (0, vue_1.defineComponent)({
231
233
  render() {
232
234
  var _a, _b, _c, _d, _e, _f, _g;
233
235
  (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
234
- return ((0, vue_1.h)("div", { class: [`${this.mergedClsPrefix}-editor`, this.themeClass], style: this.inlineThemeDisabled ? undefined : this.cssVars }, (_d = (_c = (_b = this.$slots).toolbar) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : (0, vue_1.h)(EditorToolbar_1.default, null), (_g = (_f = (_e = this.$slots).content) === null || _f === void 0 ? void 0 : _f.call(_e)) !== null && _g !== void 0 ? _g : ((0, vue_1.h)(EditorContent_1.default, null, { sendIcon: this.$slots.sendIcon }))));
236
+ return ((0, vue_1.h)("div", { class: [`${this.mergedClsPrefix}-editor`, this.themeClass], style: this.inlineThemeDisabled ? undefined : this.cssVars }, (_d = (_c = (_b = this.$slots).toolbar) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : (0, vue_1.h)(EditorToolbar_1.default, null), (_g = (_f = (_e = this.$slots).content) === null || _f === void 0 ? void 0 : _f.call(_e)) !== null && _g !== void 0 ? _g : ((0, vue_1.h)(EditorContent_1.default, null, { sendIcon: this.$slots.sendIcon, count: this.$slots.count }))));
235
237
  }
236
238
  });
@@ -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>;
@@ -7,6 +7,7 @@ const vue_3_1 = require("@tiptap/vue-3");
7
7
  const vue_1 = require("vue");
8
8
  const _internal_1 = require("../../../../_internal");
9
9
  const _mixins_1 = require("../../../../_mixins");
10
+ const _utils_1 = require("../../../../_utils");
10
11
  const light_1 = require("../../../../chat/styles/light");
11
12
  const styles_1 = require("../../../styles");
12
13
  const use_editor_css_vars_1 = __importDefault(require("../../composables/use-editor-css-vars"));
@@ -32,6 +33,7 @@ exports.default = (0, vue_1.defineComponent)({
32
33
  const sendButtonThemeOverridesRef = (0, vue_1.computed)(() => (0, light_1.createSendButtonThemeOverrides)(themeVarsRef.value));
33
34
  const scrollbarInstRef = (0, vue_1.ref)(null);
34
35
  const contentInstRef = (0, vue_1.ref)(null);
36
+ const characterCountRef = (0, vue_1.ref)(0);
35
37
  const mergedMaxRowsRef = (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.maxRowsRef.value) !== null && _a !== void 0 ? _a : props.maxRows; });
36
38
  const contentStyleRef = (0, vue_1.computed)(() => {
37
39
  const maxRows = mergedMaxRowsRef.value;
@@ -50,16 +52,27 @@ exports.default = (0, vue_1.defineComponent)({
50
52
  var _a;
51
53
  (_a = scrollbarInstRef.value) === null || _a === void 0 ? void 0 : _a.syncUnifiedContainer();
52
54
  }
55
+ function syncCharacterCount() {
56
+ var _a, _b, _c;
57
+ characterCountRef.value
58
+ = (_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;
59
+ }
60
+ function handleTransaction({ transaction }) {
61
+ syncScrollbar();
62
+ if (transaction.docChanged)
63
+ syncCharacterCount();
64
+ }
53
65
  function unsubscribe() {
54
- subscribed === null || subscribed === void 0 ? void 0 : subscribed.off('transaction', syncScrollbar);
66
+ subscribed === null || subscribed === void 0 ? void 0 : subscribed.off('transaction', handleTransaction);
55
67
  subscribed = undefined;
56
68
  }
57
69
  (0, vue_1.watch)(editorInstanceRef, (editor) => {
58
70
  unsubscribe();
71
+ syncCharacterCount();
59
72
  if (!editor)
60
73
  return;
61
74
  subscribed = editor;
62
- editor.on('transaction', syncScrollbar);
75
+ editor.on('transaction', handleTransaction);
63
76
  }, { immediate: true });
64
77
  (0, vue_1.onBeforeUnmount)(unsubscribe);
65
78
  function handleSend() {
@@ -89,6 +102,10 @@ exports.default = (0, vue_1.defineComponent)({
89
102
  mergedSendButtonProps: (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.sendButtonPropsRef.value) !== null && _a !== void 0 ? _a : props.sendButtonProps; }),
90
103
  mergedSendIconProps: (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.sendIconPropsRef.value) !== null && _a !== void 0 ? _a : props.sendIconProps; }),
91
104
  mergedContentProps: (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.contentPropsRef.value) !== null && _a !== void 0 ? _a : props.contentProps; }),
105
+ mergedShowCount: (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.showCountRef.value) !== null && _a !== void 0 ? _a : props.showCount; }),
106
+ mergedMaxLength: (0, vue_1.computed)(() => { var _a; return (_a = UEditor === null || UEditor === void 0 ? void 0 : UEditor.maxLengthRef.value) !== null && _a !== void 0 ? _a : props.maxLength; }),
107
+ countAvailable: (0, vue_1.computed)(() => { var _a; return !!((_a = editorInstanceRef.value) === null || _a === void 0 ? void 0 : _a.storage.characterCount); }),
108
+ characterCount: characterCountRef,
92
109
  scrollbarInstRef,
93
110
  contentInstRef,
94
111
  mergedMaxRows: mergedMaxRowsRef,
@@ -101,7 +118,7 @@ exports.default = (0, vue_1.defineComponent)({
101
118
  render() {
102
119
  var _a;
103
120
  (_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
104
- const content = ((0, vue_1.h)("div", { class: [
121
+ const contentWrapper = ((0, vue_1.h)("div", { class: [
105
122
  `${this.mergedClsPrefix}-editor__content-wrapper`,
106
123
  this.isStandalone
107
124
  && `${this.mergedClsPrefix}-editor__content-wrapper--standalone`
@@ -114,6 +131,16 @@ exports.default = (0, vue_1.defineComponent)({
114
131
  ], style: this.contentStyle, editor: this.editorInstance, onScroll: this.syncScrollbar }, this.mergedContentProps)))
115
132
  }),
116
133
  this.mergedShowSendButton && ((0, vue_1.h)(SendButton_1.default, { buttonThemeOverrides: this.sendButtonThemeOverrides, buttonProps: this.mergedSendButtonProps, iconProps: this.mergedSendIconProps, disabled: this.mergedSendDisabled, tooltip: this.mergedSendTooltip, onActivate: this.handleSend }, { icon: this.$slots.sendIcon }))));
134
+ const content = this.mergedShowCount ? ((0, vue_1.h)("div", { class: `${this.mergedClsPrefix}-editor__body` },
135
+ contentWrapper,
136
+ this.countAvailable && ((0, vue_1.h)("span", { class: `${this.mergedClsPrefix}-editor__count` }, (0, _utils_1.resolveSlotWithProps)(this.$slots.count, {
137
+ count: this.characterCount,
138
+ maxLength: this.mergedMaxLength
139
+ }, () => [
140
+ this.mergedMaxLength === undefined
141
+ ? this.characterCount
142
+ : `${this.characterCount} / ${this.mergedMaxLength}`
143
+ ]))))) : (contentWrapper);
117
144
  if (!this.isStandalone)
118
145
  return content;
119
146
  return ((0, vue_1.h)("div", { class: [`${this.mergedClsPrefix}-editor`, this.themeClass], style: this.inlineThemeDisabled ? undefined : this.cssVars }, content));
@@ -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;
@@ -5,4 +5,4 @@ const _mixins_1 = require("../../../../_mixins");
5
5
  exports.editorContentProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props), { editor: Object, themeVars: Object, showSendButton: {
6
6
  type: Boolean,
7
7
  default: true
8
- }, sendDisabled: Boolean, maxRows: Number, sendTooltip: String, disabled: Boolean, sendButtonProps: Object, sendIconProps: Object, contentProps: Object, onSend: Function });
8
+ }, sendDisabled: Boolean, maxRows: Number, showCount: Boolean, maxLength: Number, sendTooltip: String, disabled: Boolean, sendButtonProps: Object, sendIconProps: Object, contentProps: Object, onSend: Function });
@@ -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;
@@ -5,7 +5,7 @@ const vue_1 = require("vue");
5
5
  function useEditorCssVars(themeRef, themeVarsRef) {
6
6
  return (0, vue_1.computed)(() => {
7
7
  const { common: { cubicBezierEaseInOut } } = themeRef.value;
8
- const { backgroundColor, borderColor, borderRadius, toolbarBackgroundColor, toolbarDividerColor, toolbarButtonColorActive, toolbarButtonColorHover, toolbarButtonRippleColor, toolbarButtonWaveOpacity, toolbarIconColorDisabled, toolbarIconColorActive, toolbarIconColorHover, toolbarIconColor, contentBackgroundColor, contentTextColor, placeholderColor, sendButtonColor, sendButtonRippleColor, sendButtonWaveOpacity, blockTypeMenuWidth, blockTypeMenuColor, blockTypeMenuBorderColor, blockTypeMenuBorderRadius, blockTypeMenuBoxShadow, markdownQuoteBorderColor, markdownQuoteTextColor, markdownQuoteBackgroundColor, markdownQuoteMarkerColor, markdownDividerColor, markdownH1FontSize, markdownH2FontSize, markdownH3FontSize, markdownTextFontSize, markdownH1LineHeight, markdownH2LineHeight, markdownH3LineHeight, markdownTextLineHeight } = themeVarsRef.value;
8
+ const { backgroundColor, borderColor, borderRadius, toolbarBackgroundColor, toolbarDividerColor, toolbarButtonColorActive, toolbarButtonColorHover, toolbarButtonRippleColor, toolbarButtonWaveOpacity, toolbarIconColorDisabled, toolbarIconColorActive, toolbarIconColorHover, toolbarIconColor, contentBackgroundColor, contentTextColor, placeholderColor, sendButtonColor, sendButtonRippleColor, sendButtonWaveOpacity, blockTypeMenuWidth, blockTypeMenuColor, blockTypeMenuBorderColor, blockTypeMenuBorderRadius, blockTypeMenuBoxShadow, markdownQuoteBorderColor, markdownQuoteTextColor, markdownQuoteBackgroundColor, markdownQuoteMarkerColor, markdownDividerColor, markdownH1FontSize, markdownH2FontSize, markdownH3FontSize, markdownTextFontSize, markdownH1LineHeight, markdownH2LineHeight, markdownH3LineHeight, markdownTextLineHeight, countTextColor, countFontSize, countLineHeight } = themeVarsRef.value;
9
9
  return {
10
10
  '--u-bezier': cubicBezierEaseInOut,
11
11
  '--u-editor-background-color': backgroundColor,
@@ -44,7 +44,10 @@ function useEditorCssVars(themeRef, themeVarsRef) {
44
44
  '--u-editor-markdown-h1-line-height': markdownH1LineHeight,
45
45
  '--u-editor-markdown-h2-line-height': markdownH2LineHeight,
46
46
  '--u-editor-markdown-h3-line-height': markdownH3LineHeight,
47
- '--u-editor-markdown-text-line-height': markdownTextLineHeight
47
+ '--u-editor-markdown-text-line-height': markdownTextLineHeight,
48
+ '--u-editor-count-text-color': countTextColor,
49
+ '--u-editor-count-font-size': countFontSize,
50
+ '--u-editor-count-line-height': countLineHeight
48
51
  };
49
52
  });
50
53
  }
@@ -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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MarkdownPaste = exports.SendShortcut = exports.MarkdownSource = void 0;
3
+ exports.MarkdownPaste = exports.SendShortcut = exports.CharacterLimit = exports.MarkdownSource = void 0;
4
4
  exports.createEditorExtensions = createEditorExtensions;
5
5
  const core_1 = require("@tiptap/core");
6
6
  const extensions_1 = require("@tiptap/extensions");
@@ -27,6 +27,37 @@ exports.MarkdownSource = core_1.Extension.create({
27
27
  ];
28
28
  }
29
29
  });
30
+ exports.CharacterLimit = core_1.Extension.create({
31
+ name: 'characterLimit',
32
+ addOptions: () => ({ getLimit: () => undefined }),
33
+ addProseMirrorPlugins() {
34
+ const { getLimit } = this.options;
35
+ const count = (node) => this.editor.storage.characterCount.characters({ node });
36
+ return [
37
+ new state_1.Plugin({
38
+ filterTransaction: (transaction, state) => {
39
+ const limit = getLimit();
40
+ if (!transaction.docChanged
41
+ || transaction.getMeta('preventUpdate')
42
+ || !limit) {
43
+ return true;
44
+ }
45
+ const oldSize = count(state.doc);
46
+ const newSize = count(transaction.doc);
47
+ if (newSize <= limit)
48
+ return true;
49
+ if (oldSize > limit)
50
+ return newSize <= oldSize;
51
+ if (!transaction.getMeta('paste'))
52
+ return false;
53
+ const pos = transaction.selection.$head.pos;
54
+ transaction.deleteRange(pos - (newSize - limit), pos);
55
+ return count(transaction.doc) <= limit;
56
+ }
57
+ })
58
+ ];
59
+ }
60
+ });
30
61
  exports.SendShortcut = core_1.Extension.create({
31
62
  name: 'sendShortcut',
32
63
  priority: 1000,
@@ -91,7 +122,11 @@ exports.MarkdownPaste = core_1.Extension.create({
91
122
  const slice = single
92
123
  ? new model_1.Slice(document.content, 1, 1)
93
124
  : new model_1.Slice(document.content, 0, 0);
94
- view.dispatch(view.state.tr.replaceSelection(slice).scrollIntoView());
125
+ view.dispatch(view.state.tr
126
+ .replaceSelection(slice)
127
+ .scrollIntoView()
128
+ .setMeta('paste', true)
129
+ .setMeta('uiEvent', 'paste'));
95
130
  return true;
96
131
  }
97
132
  }
@@ -128,9 +163,10 @@ function createEditorExtensions({ placeholder = '', markdownOptions, extensions
128
163
  link: { openOnClick: false, autolink: false, linkOnPaste: false }
129
164
  }),
130
165
  extensions_1.Placeholder.configure({ placeholder }),
131
- ...(maxLength === undefined
132
- ? []
133
- : [extensions_1.CharacterCount.configure({ limit: maxLength })]),
166
+ extensions_1.CharacterCount,
167
+ exports.CharacterLimit.configure({
168
+ getLimit: typeof maxLength === 'function' ? maxLength : () => maxLength
169
+ }),
134
170
  exports.MarkdownSource,
135
171
  exports.MarkdownPaste.configure({ markdownOptions }),
136
172
  ...(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;
@@ -16,7 +16,7 @@ exports.editorProps = Object.assign(Object.assign({}, _mixins_1.useTheme.props),
16
16
  }, sendOnEnter: {
17
17
  type: Boolean,
18
18
  default: true
19
- }, disabled: Boolean, readonly: Boolean, autofocus: Boolean, maxLength: Number, maxRows: Number, toolbarButtonProps: Object, toolbarIconProps: Object, toolbarDropdownProps: Object, sendButtonProps: Object, sendIconProps: Object, contentProps: Object, extensions: {
19
+ }, disabled: Boolean, readonly: Boolean, autofocus: Boolean, maxLength: Number, maxRows: Number, showCount: Boolean, toolbarButtonProps: Object, toolbarIconProps: Object, toolbarDropdownProps: Object, sendButtonProps: Object, sendIconProps: Object, contentProps: Object, extensions: {
20
20
  type: Array,
21
21
  default: () => []
22
22
  }, nodeProps: Object, onSend: [Function, Array], onFocus: [Function, Array], onBlur: [Function, Array], 'onUpdate:value': [Function, Array], onUpdateValue: [Function, Array] });