@bridge-ui/vue 0.15.0 → 0.16.0

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 (93) hide show
  1. package/ai/AGENTS.md +1 -1
  2. package/ai/README.md +1 -1
  3. package/ai/llms.txt +0 -1
  4. package/ai/skills/bridge-ui-components/SKILL.md +2 -1
  5. package/ai/skills/bridge-ui-setup/SKILL.md +8 -8
  6. package/dist/Actions/Snackbar/BridgeSnackbarItem.vue_vue_type_script_setup_true_lang.js +42 -44
  7. package/dist/Actions/Snackbar/createBridgeSnackbarApi.js +1 -1
  8. package/dist/Adapters/index.d.ts +0 -1
  9. package/dist/Adapters/index.js +1 -2
  10. package/dist/Components/Accordion/composables/useAccordion.js +1 -1
  11. package/dist/Components/Autocomplete/composables/useAutocomplete.js +248 -258
  12. package/dist/Components/Chart/Chart.js +5 -0
  13. package/dist/Components/Chart/Chart.vue.d.ts +14 -0
  14. package/dist/Components/Chart/Chart.vue_vue_type_script_setup_true_lang.js +52 -0
  15. package/dist/Components/Chart/chart.types.d.ts +126 -0
  16. package/dist/Components/Chart/chartInjectionKey.d.ts +94 -0
  17. package/dist/Components/Chart/chartInjectionKey.js +10 -0
  18. package/dist/Components/Chart/composables/useChart.d.ts +40 -0
  19. package/dist/Components/Chart/composables/useChart.js +344 -0
  20. package/dist/Components/Chart/echartsChart.d.ts +14 -0
  21. package/dist/Components/Chart/echartsChart.js +199 -0
  22. package/dist/Components/Chart/index.d.ts +4 -0
  23. package/dist/Components/Chart/index.js +4 -0
  24. package/dist/Components/ChartAxis/ChartAxis.js +5 -0
  25. package/dist/Components/ChartAxis/ChartAxis.vue.d.ts +7 -0
  26. package/dist/Components/ChartAxis/ChartAxis.vue_vue_type_script_setup_true_lang.js +30 -0
  27. package/dist/Components/ChartAxis/chartAxis.types.d.ts +56 -0
  28. package/dist/Components/ChartAxis/composables/useChartAxis.d.ts +5 -0
  29. package/dist/Components/ChartAxis/composables/useChartAxis.js +28 -0
  30. package/dist/Components/ChartAxis/index.d.ts +3 -0
  31. package/dist/Components/ChartAxis/index.js +3 -0
  32. package/dist/Components/ChartLegend/ChartLegend.js +5 -0
  33. package/dist/Components/ChartLegend/ChartLegend.vue.d.ts +6 -0
  34. package/dist/Components/ChartLegend/ChartLegend.vue_vue_type_script_setup_true_lang.js +33 -0
  35. package/dist/Components/ChartLegend/chartLegend.types.d.ts +71 -0
  36. package/dist/Components/ChartLegend/composables/useChartLegend.d.ts +16 -0
  37. package/dist/Components/ChartLegend/composables/useChartLegend.js +98 -0
  38. package/dist/Components/ChartLegend/index.d.ts +3 -0
  39. package/dist/Components/ChartLegend/index.js +3 -0
  40. package/dist/Components/ChartSeries/ChartSeries.js +5 -0
  41. package/dist/Components/ChartSeries/ChartSeries.vue.d.ts +4 -0
  42. package/dist/Components/ChartSeries/ChartSeries.vue_vue_type_script_setup_true_lang.js +24 -0
  43. package/dist/Components/ChartSeries/chartSeries.types.d.ts +37 -0
  44. package/dist/Components/ChartSeries/composables/useChartSeries.d.ts +10 -0
  45. package/dist/Components/ChartSeries/composables/useChartSeries.js +29 -0
  46. package/dist/Components/ChartSeries/index.d.ts +3 -0
  47. package/dist/Components/ChartSeries/index.js +3 -0
  48. package/dist/Components/ChartTooltip/ChartTooltip.js +5 -0
  49. package/dist/Components/ChartTooltip/ChartTooltip.vue.d.ts +11 -0
  50. package/dist/Components/ChartTooltip/ChartTooltip.vue_vue_type_script_setup_true_lang.js +25 -0
  51. package/dist/Components/ChartTooltip/chartTooltip.types.d.ts +82 -0
  52. package/dist/Components/ChartTooltip/composables/useChartTooltip.d.ts +15 -0
  53. package/dist/Components/ChartTooltip/composables/useChartTooltip.js +110 -0
  54. package/dist/Components/ChartTooltip/index.d.ts +3 -0
  55. package/dist/Components/ChartTooltip/index.js +3 -0
  56. package/dist/Components/DataTable/DataTableCellContent.vue.d.ts +1 -5
  57. package/dist/Components/DataTable/DataTableCellContent.vue_vue_type_script_setup_true_lang.js +24 -25
  58. package/dist/Components/DataTable/composables/useDataTable.d.ts +1 -1
  59. package/dist/Components/DataTable/composables/useDataTable.js +76 -74
  60. package/dist/Components/DataTable/composables/useDataTablePagination.js +1 -1
  61. package/dist/Components/Drawer/Drawer.vue_vue_type_script_setup_true_lang.js +3 -4
  62. package/dist/Components/Menu/Menu.vue_vue_type_script_setup_true_lang.js +5 -3
  63. package/dist/Components/Modal/Modal.vue_vue_type_script_setup_true_lang.js +3 -4
  64. package/dist/Components/Pagination/composables/usePagination.js +1 -1
  65. package/dist/Components/RichTextEditor/RichTextEditor.vue.d.ts +1 -1
  66. package/dist/Components/RichTextEditor/RichTextEditor.vue_vue_type_script_setup_true_lang.js +17 -17
  67. package/dist/Components/RichTextEditor/composables/useRichTextEditor.d.ts +2 -2
  68. package/dist/Components/RichTextEditor/composables/useRichTextEditor.js +67 -73
  69. package/dist/Components/RichTextEditor/richTextEditor.types.d.ts +1 -1
  70. package/dist/Components/RichTextEditor/tiptapEditor.d.ts +111 -0
  71. package/dist/Components/RichTextEditor/tiptapEditor.js +121 -0
  72. package/dist/Components/Select/composables/useSelect.js +147 -157
  73. package/dist/Components/Snackbar/Snackbar.vue.d.ts +1 -1
  74. package/dist/Components/Snackbar/Snackbar.vue_vue_type_script_setup_true_lang.js +6 -7
  75. package/dist/Components/Stepper/composables/useStepper.js +1 -1
  76. package/dist/Components/Table/composables/useTableCell.d.ts +1 -1
  77. package/dist/Components/Tabs/composables/useTabs.js +1 -1
  78. package/dist/Components/ToggleGroup/composables/useToggleGroup.js +3 -3
  79. package/dist/Components/Tooltip/Tooltip.vue_vue_type_script_setup_true_lang.js +6 -4
  80. package/dist/augments.d.ts +19 -1
  81. package/dist/index.d.ts +0 -3
  82. package/dist/index.js +180 -183
  83. package/dist/theme.css +1 -1
  84. package/docs/README.md +3 -3
  85. package/docs/components/BridgeUIProvider.md +0 -17
  86. package/docs/components/Chart.md +252 -0
  87. package/docs/components/RichTextEditor.md +2 -23
  88. package/package.json +27 -6
  89. package/dist/Adapters/RichText/index.d.ts +0 -1
  90. package/dist/Adapters/RichText/index.js +0 -2
  91. package/dist/Adapters/RichText/mockRichTextAdapter.d.ts +0 -5
  92. package/dist/Adapters/RichText/useRichTextAdapter.d.ts +0 -12
  93. package/dist/Adapters/RichText/useRichTextAdapter.js +0 -13
@@ -1,14 +1,14 @@
1
1
  import { useResolveMessage as e } from "../../../Adapters/I18n/useI18nAdapter.js";
2
- import { useRichTextAdapter as t } from "../../../Adapters/RichText/useRichTextAdapter.js";
3
- import { mergePartBind as n, useBridgeUIComponent as r, useBridgeUIMergedRegistryClasses as ee } from "../../../Utils/index.js";
2
+ import { mergePartBind as t, useBridgeUIComponent as n, useBridgeUIMergedRegistryClasses as r } from "../../../Utils/index.js";
4
3
  import { formFieldBridgeKeys as i, useFormField as a } from "../../FormField/composables/useFormField.js";
5
- import { computed as o, onBeforeUnmount as s, ref as c, useAttrs as l, useSlots as u, watch as d } from "vue";
6
- import { DEFAULT_RICH_TEXT_TOOLS as f, RICH_TEXT_TOOL_ICONS as te, RICH_TEXT_TOOL_LABELS as ne, richTextValuesEqual as p } from "@bridge-ui/core/Adapters";
7
- import { get as re, isNil as m, omit as h } from "es-toolkit/compat";
8
- import { richTextEditorSizeProps as ie } from "@bridge-ui/core/Tokens";
9
- import { cn as g, mergeBridgeUILayeredClasses as _, splitComponentProps as v } from "@bridge-ui/core/Utils";
4
+ import { mountTiptapEditor as ee } from "../tiptapEditor.js";
5
+ import { computed as o, onBeforeUnmount as s, ref as c, useAttrs as l, useSlots as te, watch as u } from "vue";
6
+ import { get as d, isNil as f, omit as ne } from "es-toolkit/compat";
7
+ import { DEFAULT_RICH_TEXT_TOOLS as p, RICH_TEXT_TOOL_ICONS as m, RICH_TEXT_TOOL_LABELS as h, richTextValuesEqual as g } from "@bridge-ui/core/Domain";
8
+ import { richTextEditorSizeProps as _ } from "@bridge-ui/core/Tokens";
9
+ import { cn as v, mergeBridgeUILayeredClasses as y, splitComponentProps as b } from "@bridge-ui/core/Utils";
10
10
  //#region src/Components/RichTextEditor/composables/useRichTextEditor.ts
11
- var y = [
11
+ var re = [
12
12
  "tools",
13
13
  "format",
14
14
  "classes",
@@ -17,16 +17,16 @@ var y = [
17
17
  "placeholder",
18
18
  "defaultValue"
19
19
  ];
20
- function b(b, x, ae, S) {
21
- let C = l(), w = u(), T = e(), E = t(), D = c(""), O = c(0), k = c(null), A = c(null), j = c(null), M = o(() => v({
22
- bridgeKeys: y,
20
+ function x(x, S, ie, C) {
21
+ let w = l(), T = te(), E = e(), D = c(""), O = c(0), k = c(null), A = c(null), j = c(null), M = o(() => b({
22
+ bridgeKeys: re,
23
23
  props: {
24
- ...b,
25
- ...C
24
+ ...x,
25
+ ...w
26
26
  }
27
- })), N = o(() => M.value.componentProps), P = o(() => v({
27
+ })), N = o(() => M.value.componentProps), P = o(() => b({
28
28
  bridgeKeys: i,
29
- props: h(M.value.inheritedAttrs, ["class", "onUpdate:modelValue"])
29
+ props: ne(M.value.inheritedAttrs, ["class", "onUpdate:modelValue"])
30
30
  })), F = o(() => P.value.componentProps), I = o(() => P.value.inheritedAttrs), L = o(() => {
31
31
  let { content: e, toolbar: t, toolbarButton: n, ...r } = N.value.customProps ?? {};
32
32
  return r;
@@ -38,7 +38,7 @@ function b(b, x, ae, S) {
38
38
  color: F.value.color,
39
39
  rounded: F.value.rounded,
40
40
  variant: F.value.variant
41
- })), { merged: B, entry: V } = r({
41
+ })), { merged: B, entry: V } = n({
42
42
  chrome: "FormField",
43
43
  componentName: "RichTextEditor",
44
44
  props: () => z.value,
@@ -49,12 +49,12 @@ function b(b, x, ae, S) {
49
49
  color: "primary",
50
50
  variant: "outline"
51
51
  }
52
- }), H = ee({
52
+ }), H = r({
53
53
  entry: V,
54
54
  props: () => z.value
55
- }), U = o(() => B.value.format ?? "html"), W = o(() => [...N.value.tools ?? B.value.tools ?? f]), G = o(() => N.value.readOnly === !0 || F.value.readonly === !0), K = o(() => !(G.value || F.value.disabled === !0) && W.value.length > 0), q = o(() => {
56
- let e = _(ie, V.value?.tokens?.size);
57
- return re(e, F.value.size ?? B.value.size ?? "md");
55
+ }), U = o(() => B.value.format ?? "html"), W = o(() => [...N.value.tools ?? B.value.tools ?? p]), G = o(() => N.value.readOnly === !0 || F.value.readonly === !0), K = o(() => !(G.value || F.value.disabled === !0) && W.value.length > 0), q = o(() => {
56
+ let e = y(_, V.value?.tokens?.size);
57
+ return d(e, F.value.size ?? B.value.size ?? "md");
58
58
  }), J = a(() => ({
59
59
  ...I.value,
60
60
  ...F.value,
@@ -70,8 +70,8 @@ function b(b, x, ae, S) {
70
70
  }, {
71
71
  control: () => "textarea",
72
72
  componentName: "RichTextEditor"
73
- }), Y = o(() => J.merged.value.color ?? "primary"), oe = o(() => J.invalidated.value ? "error" : Y.value);
74
- function se(e) {
73
+ }), Y = o(() => J.merged.value.color ?? "primary"), ae = o(() => J.invalidated.value ? "error" : Y.value);
74
+ function oe(e) {
75
75
  return !!(J.isDisabled.value || G.value || !(j.value?.can(e) ?? !0));
76
76
  }
77
77
  function X() {
@@ -80,13 +80,13 @@ function b(b, x, ae, S) {
80
80
  function Z() {
81
81
  D.value = "", A.value = null;
82
82
  }
83
- function ce() {
83
+ function se() {
84
84
  let e = D.value.trim();
85
85
  e.length !== 0 && (j.value?.run("link", { href: e }), X(), Z());
86
86
  }
87
- function le(e, t) {
87
+ function Q(e, t) {
88
88
  let n = j.value;
89
- if (!m(n)) {
89
+ if (!f(n)) {
90
90
  if (e === "link") {
91
91
  if (n.isActive("link")) {
92
92
  n.run("link"), X(), Z();
@@ -99,32 +99,30 @@ function b(b, x, ae, S) {
99
99
  n.run(e), X();
100
100
  }
101
101
  }
102
- let Q = o({
102
+ let ce = o({
103
103
  get() {
104
- return !m(A.value);
104
+ return !f(A.value);
105
105
  },
106
106
  set(e) {
107
107
  e || Z();
108
108
  }
109
- }), ue = o(() => D.value.trim().length > 0), de = o(() => T("URL"));
110
- d(K, (e) => {
109
+ }), le = o(() => D.value.trim().length > 0), ue = o(() => E("URL"));
110
+ u(K, (e) => {
111
111
  e || Z();
112
112
  });
113
113
  function $() {
114
114
  j.value?.destroy(), j.value = null;
115
115
  let e = k.value;
116
- m(e) || (e.remove(), k.value = null);
116
+ f(e) || (e.remove(), k.value = null);
117
117
  }
118
- function fe() {
118
+ function de() {
119
119
  $();
120
- let e = S.value, t = E.value;
121
- if (m(e)) return;
122
- if (m(t)) throw Error("[BridgeUI] RichTextEditor requires BridgeUIProvider global.richText. See @bridge-ui/adapters/vue/rich-text-tiptap.");
123
- let n = document.createElement("div");
124
- n.className = "flex min-h-0 min-w-0 w-full flex-1 flex-col outline-none", e.appendChild(n), k.value = n, j.value = t.mount({
125
- element: n,
126
- tools: W.value,
127
- value: x.value,
120
+ let e = C.value;
121
+ if (f(e)) return;
122
+ let t = document.createElement("div");
123
+ t.className = "flex min-h-0 min-w-0 w-full flex-1 flex-col outline-none", e.appendChild(t), k.value = t, j.value = ee({
124
+ element: t,
125
+ value: S.value,
128
126
  format: U.value,
129
127
  readOnly: G.value,
130
128
  id: J.controlId.value,
@@ -136,24 +134,20 @@ function b(b, x, ae, S) {
136
134
  ariaInvalid: J.invalidated.value,
137
135
  ariaDescribedBy: J.ariaDescribedBy.value,
138
136
  onChange: (e) => {
139
- x.value = e, ae("update:modelValue", e);
137
+ S.value = e;
140
138
  }
141
139
  });
142
140
  }
143
- d([
144
- U,
145
- E,
146
- S
147
- ], () => {
148
- fe();
149
- }, { flush: "post" }), d(() => x.value, (e) => {
141
+ u([U, C], () => {
142
+ de();
143
+ }, { flush: "post" }), u(() => S.value, (e) => {
150
144
  let t = j.value;
151
- m(t) || e === void 0 || p(t.getValue(), e) || t.setValue(e);
152
- }), d(() => J.isDisabled.value, (e) => {
145
+ f(t) || e === void 0 || g(t.getValue(), e) || t.setValue(e);
146
+ }), u(() => J.isDisabled.value, (e) => {
153
147
  j.value?.setDisabled(e);
154
- }), d(G, (e) => {
148
+ }), u(G, (e) => {
155
149
  j.value?.setReadOnly(e);
156
- }), d([
150
+ }), u([
157
151
  G,
158
152
  () => N.value.placeholder,
159
153
  () => J.controlId.value,
@@ -172,57 +166,57 @@ function b(b, x, ae, S) {
172
166
  }), s(() => {
173
167
  $();
174
168
  });
175
- let pe = o(() => n(N.value.customProps?.toolbar, {
169
+ let fe = o(() => t(N.value.customProps?.toolbar, {
176
170
  role: "toolbar",
177
- "aria-label": T("Formatting")
178
- }, g({
171
+ "aria-label": E("Formatting")
172
+ }, v({
179
173
  [q.value?.toolbar ?? ""]: !0,
180
174
  [H.value.toolbar ?? ""]: !0
181
- }))), me = o(() => n(N.value.customProps?.content, {}, g({
175
+ }))), pe = o(() => t(N.value.customProps?.content, {}, v({
182
176
  "min-w-0 flex-1": !0,
183
177
  [q.value?.content ?? ""]: !0,
184
178
  [H.value.content ?? ""]: !0,
185
179
  [H.value.input ?? ""]: !0
186
180
  })));
187
- function he(e) {
181
+ function me(e) {
188
182
  O.value;
189
- let t = j.value, r = T(ne[e]);
190
- return n(R.value, {
183
+ let n = j.value, r = E(h[e]);
184
+ return t(R.value, {
191
185
  type: "button",
192
186
  density: "mini",
193
187
  variant: "flat",
194
188
  "aria-label": r,
195
- color: oe.value,
196
- icon: te[e],
197
- disabled: se(e),
189
+ color: ae.value,
190
+ icon: m[e],
191
+ disabled: oe(e),
198
192
  size: J.merged.value.size ?? "md",
199
- selected: t?.isActive(e) ?? !1,
193
+ selected: n?.isActive(e) ?? !1,
200
194
  rounded: J.merged.value.rounded ?? "md"
201
- }, g({
195
+ }, v({
202
196
  [q.value?.toolbarButton ?? ""]: !0,
203
197
  [H.value.toolbarButton ?? ""]: !0
204
198
  }));
205
199
  }
206
200
  return {
207
201
  color: Y,
208
- slots: w,
202
+ slots: T,
209
203
  tools: W,
210
204
  format: U,
211
205
  linkHref: D,
212
- linkOpen: Q,
206
+ linkOpen: ce,
213
207
  formField: J,
214
208
  linkAnchor: A,
215
209
  isReadOnly: G,
216
- contentBind: me,
217
- confirmLink: ce,
218
- onToolClick: le,
219
- toolbarBind: pe,
210
+ contentBind: pe,
211
+ confirmLink: se,
212
+ onToolClick: Q,
213
+ toolbarBind: fe,
220
214
  showToolbar: K,
221
- linkUrlLabel: de,
222
- canConfirmLink: ue,
215
+ linkUrlLabel: ue,
216
+ canConfirmLink: le,
223
217
  closeLinkEditor: Z,
224
- getToolbarButtonBind: he
218
+ getToolbarButtonBind: me
225
219
  };
226
220
  }
227
221
  //#endregion
228
- export { b as useRichTextEditor };
222
+ export { x as useRichTextEditor };
@@ -1,5 +1,5 @@
1
1
  import { HTMLAttributes, Slot } from 'vue';
2
- import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/Adapters';
2
+ import { RichTextFormat, RichTextTool, RichTextValue } from '@bridge-ui/core/Domain';
3
3
  import { MergeHtmlProps } from '@bridge-ui/core/Utils';
4
4
  import { ButtonOwnProps } from '../Button/button.types';
5
5
  import { FormFieldClasses, FormFieldCustomProps, FormFieldOwnProps, FormFieldSlots } from '../FormField/formField.types';
@@ -0,0 +1,111 @@
1
+ import { RichTextA11yOptions, RichTextFormat, RichTextTool, RichTextToolPayload, RichTextValue } from '@bridge-ui/core/Domain';
2
+ /**
3
+ * Options for {@link mountTiptapEditor}.
4
+ */
5
+ export type TiptapMountOptions = {
6
+ /**
7
+ * `aria-describedby` on the editable root.
8
+ */
9
+ ariaDescribedBy?: string;
10
+ /**
11
+ * `aria-disabled` on the editable root.
12
+ */
13
+ ariaDisabled?: boolean;
14
+ /**
15
+ * `aria-invalid` on the editable root.
16
+ */
17
+ ariaInvalid?: boolean;
18
+ /**
19
+ * `aria-readonly` on the editable root.
20
+ */
21
+ ariaReadonly?: boolean;
22
+ /**
23
+ * Disable editing and command execution.
24
+ */
25
+ disabled?: boolean;
26
+ /**
27
+ * Host element the editor mounts into.
28
+ */
29
+ element: HTMLElement;
30
+ /**
31
+ * Document format for `value` / `onChange` / handle get/set.
32
+ */
33
+ format: RichTextFormat;
34
+ /**
35
+ * Optional `id` applied to the editable root (for FormField label association).
36
+ */
37
+ id?: string;
38
+ /**
39
+ * Called whenever the document changes.
40
+ */
41
+ onChange: (value: RichTextValue) => void;
42
+ /**
43
+ * Called when the selection changes (toolbar active state).
44
+ */
45
+ onSelectionChange?: () => void;
46
+ /**
47
+ * Empty-state hint in the content area.
48
+ */
49
+ placeholder?: string;
50
+ /**
51
+ * View-only surface; commands should no-op.
52
+ */
53
+ readOnly?: boolean;
54
+ /**
55
+ * Initial document for the mount `format`.
56
+ */
57
+ value?: RichTextValue;
58
+ };
59
+ /**
60
+ * Per-editor handle returned by {@link mountTiptapEditor}.
61
+ */
62
+ export type TiptapEditorHandle = {
63
+ /**
64
+ * Blurs the editable surface when supported.
65
+ */
66
+ blur: () => void;
67
+ /**
68
+ * Whether `tool` can run in the current selection / state.
69
+ */
70
+ can: (tool: RichTextTool) => boolean;
71
+ /**
72
+ * Tears down the editor instance.
73
+ */
74
+ destroy: () => void;
75
+ /**
76
+ * Focuses the editable surface.
77
+ */
78
+ focus: () => void;
79
+ /**
80
+ * Returns the current document in the mount `format`.
81
+ */
82
+ getValue: () => RichTextValue;
83
+ /**
84
+ * Whether `tool` is active in the current selection.
85
+ */
86
+ isActive: (tool: RichTextTool) => boolean;
87
+ /**
88
+ * Runs a toolbar command (toggle mark, set link, …).
89
+ */
90
+ run: (tool: RichTextTool, payload?: RichTextToolPayload) => void;
91
+ /**
92
+ * Updates a11y attributes and the empty-state placeholder after mount.
93
+ */
94
+ setA11y: (options: RichTextA11yOptions) => void;
95
+ /**
96
+ * Updates the disabled flag after mount.
97
+ */
98
+ setDisabled: (disabled: boolean) => void;
99
+ /**
100
+ * Updates the read-only flag after mount.
101
+ */
102
+ setReadOnly: (readOnly: boolean) => void;
103
+ /**
104
+ * Replaces the document. Must match the mount `format`.
105
+ */
106
+ setValue: (value: RichTextValue) => void;
107
+ };
108
+ /**
109
+ * Mounts a TipTap editor into `options.element` and returns a handle.
110
+ */
111
+ export declare function mountTiptapEditor(options: TiptapMountOptions): TiptapEditorHandle;
@@ -0,0 +1,121 @@
1
+ import { get as e, isNil as t, isString as n } from "es-toolkit/compat";
2
+ import { applyRichTextEditableA11y as r } from "@bridge-ui/core/Domain";
3
+ import { Editor as i } from "@tiptap/core";
4
+ import a from "@tiptap/extension-placeholder";
5
+ import o from "@tiptap/starter-kit";
6
+ //#region src/Components/RichTextEditor/tiptapEditor.ts
7
+ var s = "bridge-rich-text-editable";
8
+ function c(e, t) {
9
+ return t === "json" ? e.getJSON() : e.getHTML();
10
+ }
11
+ function l(e, n) {
12
+ let r = e.extensionManager.extensions.find((e) => e.name === "placeholder");
13
+ t(r) || r.options.placeholder === n || (r.options.placeholder = n, e.view.dispatch(e.state.tr));
14
+ }
15
+ var u = {
16
+ bold: (e) => e.isActive("bold"),
17
+ link: (e) => e.isActive("link"),
18
+ italic: (e) => e.isActive("italic"),
19
+ strike: (e) => e.isActive("strike"),
20
+ codeBlock: (e) => e.isActive("codeBlock"),
21
+ underline: (e) => e.isActive("underline"),
22
+ blockquote: (e) => e.isActive("blockquote"),
23
+ bulletList: (e) => e.isActive("bulletList"),
24
+ orderedList: (e) => e.isActive("orderedList"),
25
+ heading1: (e) => e.isActive("heading", { level: 1 }),
26
+ heading2: (e) => e.isActive("heading", { level: 2 }),
27
+ heading3: (e) => e.isActive("heading", { level: 3 })
28
+ }, d = {
29
+ link: () => !0,
30
+ bold: (e) => e.can().toggleBold(),
31
+ italic: (e) => e.can().toggleItalic(),
32
+ strike: (e) => e.can().toggleStrike(),
33
+ codeBlock: (e) => e.can().toggleCodeBlock(),
34
+ underline: (e) => e.can().toggleUnderline(),
35
+ blockquote: (e) => e.can().toggleBlockquote(),
36
+ bulletList: (e) => e.can().toggleBulletList(),
37
+ orderedList: (e) => e.can().toggleOrderedList(),
38
+ heading1: (e) => e.can().toggleHeading({ level: 1 }),
39
+ heading2: (e) => e.can().toggleHeading({ level: 2 }),
40
+ heading3: (e) => e.can().toggleHeading({ level: 3 })
41
+ }, f = {
42
+ bold: (e) => e.chain().focus().toggleBold().run(),
43
+ italic: (e) => e.chain().focus().toggleItalic().run(),
44
+ strike: (e) => e.chain().focus().toggleStrike().run(),
45
+ codeBlock: (e) => e.chain().focus().toggleCodeBlock().run(),
46
+ underline: (e) => e.chain().focus().toggleUnderline().run(),
47
+ blockquote: (e) => e.chain().focus().toggleBlockquote().run(),
48
+ bulletList: (e) => e.chain().focus().toggleBulletList().run(),
49
+ orderedList: (e) => e.chain().focus().toggleOrderedList().run(),
50
+ heading1: (e) => e.chain().focus().toggleHeading({ level: 1 }).run(),
51
+ heading2: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
52
+ heading3: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
53
+ link: (e, n) => {
54
+ if (!t(n?.href) && n.href.length > 0) {
55
+ e.chain().focus().extendMarkRange("link").setLink({ href: n.href }).run();
56
+ return;
57
+ }
58
+ e.isActive("link") && e.chain().focus().unsetLink().run();
59
+ }
60
+ };
61
+ function p(t, n) {
62
+ return e(u, n, () => !1)(t);
63
+ }
64
+ function m(t, n) {
65
+ return e(d, n, () => !1)(t);
66
+ }
67
+ function h(t, n, r) {
68
+ e(f, n, () => void 0)(t, r);
69
+ }
70
+ function g(e) {
71
+ let t = e.disabled === !0, u = e.readOnly === !0, d = !1, f = new i({
72
+ autofocus: !1,
73
+ element: e.element,
74
+ editable: !t && !u,
75
+ onSelectionUpdate: () => {
76
+ e.onSelectionChange?.();
77
+ },
78
+ editorProps: { attributes: { class: s } },
79
+ onUpdate: ({ editor: t }) => {
80
+ e.onChange(c(t, e.format));
81
+ },
82
+ content: e.value ?? (e.format === "json" ? {
83
+ type: "doc",
84
+ content: []
85
+ } : ""),
86
+ extensions: [o.configure({ link: { openOnClick: !1 } }), a.configure({ placeholder: e.placeholder ?? "" })]
87
+ });
88
+ return r(f.view.dom, e), {
89
+ getValue: () => c(f, e.format),
90
+ blur: () => {
91
+ d || f.commands.blur();
92
+ },
93
+ focus: () => {
94
+ d || f.commands.focus();
95
+ },
96
+ isActive: (e) => !d && p(f, e),
97
+ destroy: () => {
98
+ d || (d = !0, f.destroy());
99
+ },
100
+ can: (e) => d || t || u ? !1 : m(f, e),
101
+ setDisabled: (e) => {
102
+ d || (t = e, f.setEditable(!t && !u, !1));
103
+ },
104
+ setReadOnly: (e) => {
105
+ d || (u = e, f.setEditable(!t && !u, !1));
106
+ },
107
+ run: (e, n) => {
108
+ d || t || u || h(f, e, n);
109
+ },
110
+ setA11y: (e) => {
111
+ d || (r(f.view.dom, e), l(f, e.placeholder ?? ""));
112
+ },
113
+ setValue: (t) => {
114
+ if (d) return;
115
+ let r = e.format === "html" ? n(t) ? t : "" : t;
116
+ f.commands.setContent(r, { emitUpdate: !1 });
117
+ }
118
+ };
119
+ }
120
+ //#endregion
121
+ export { g as mountTiptapEditor };