@bikdotai/bik-component-library 0.0.858-beta.1 → 0.0.858

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 (77) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js +23 -23
  3. package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
  4. package/dist/cjs/components/agent-builder/components/AiTextArea.js +1 -1
  5. package/dist/cjs/components/agent-builder/components/AiTextArea.js.map +1 -1
  6. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
  7. package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  8. package/dist/cjs/components/bik-chatbot/components/ChatWindow.js +20 -20
  9. package/dist/cjs/components/bik-chatbot/components/ChatWindow.js.map +1 -1
  10. package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js +2 -2
  11. package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
  12. package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js +2 -2
  13. package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
  14. package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js +1 -1
  15. package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
  16. package/dist/cjs/components/input/ChipInput.js +1 -1
  17. package/dist/cjs/components/input/ChipInput.js.map +1 -1
  18. package/dist/cjs/components/input/Input-helper.js +1 -1
  19. package/dist/cjs/components/input/Input-helper.js.map +1 -1
  20. package/dist/cjs/components/input/Input.js +1 -1
  21. package/dist/cjs/components/input/Input.js.map +1 -1
  22. package/dist/cjs/components/plans/SubscriptionPlanSelector.js +5 -5
  23. package/dist/cjs/components/plans/SubscriptionPlanSelector.js.map +1 -1
  24. package/dist/cjs/editor/BikEditor.js +1 -1
  25. package/dist/cjs/editor/BikEditor.js.map +1 -1
  26. package/dist/cjs/editor/BikEditor.utils.js +3 -3
  27. package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
  28. package/dist/cjs/editor/extensions/buildExtensions.js +2 -2
  29. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  30. package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +2 -0
  31. package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -0
  32. package/dist/cjs/helpers/sanitize.js +2 -0
  33. package/dist/cjs/helpers/sanitize.js.map +1 -0
  34. package/dist/cjs/index.js +1 -1
  35. package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js +144 -143
  36. package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
  37. package/dist/esm/components/agent-builder/components/AiTextArea.js +24 -23
  38. package/dist/esm/components/agent-builder/components/AiTextArea.js.map +1 -1
  39. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +38 -37
  40. package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
  41. package/dist/esm/components/bik-chatbot/components/ChatWindow.js +54 -53
  42. package/dist/esm/components/bik-chatbot/components/ChatWindow.js.map +1 -1
  43. package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js +346 -420
  44. package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
  45. package/dist/esm/components/feature-announcements/MajorUpdatePopup.js +35 -33
  46. package/dist/esm/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
  47. package/dist/esm/components/feature-announcements/MinorUpdatePopup.js +48 -47
  48. package/dist/esm/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
  49. package/dist/esm/components/feature-announcements/types/props.types.d.ts +2 -2
  50. package/dist/esm/components/input/ChipInput.js +41 -40
  51. package/dist/esm/components/input/ChipInput.js.map +1 -1
  52. package/dist/esm/components/input/Input-helper.d.ts +7 -0
  53. package/dist/esm/components/input/Input-helper.js +16 -25
  54. package/dist/esm/components/input/Input-helper.js.map +1 -1
  55. package/dist/esm/components/input/Input.js +59 -57
  56. package/dist/esm/components/input/Input.js.map +1 -1
  57. package/dist/esm/components/input/Input.model.d.ts +1 -0
  58. package/dist/esm/components/plans/SubscriptionPlanSelector.js +42 -40
  59. package/dist/esm/components/plans/SubscriptionPlanSelector.js.map +1 -1
  60. package/dist/esm/editor/BikEditor.js +221 -217
  61. package/dist/esm/editor/BikEditor.js.map +1 -1
  62. package/dist/esm/editor/BikEditor.utils.d.ts +1 -1
  63. package/dist/esm/editor/BikEditor.utils.js +141 -140
  64. package/dist/esm/editor/BikEditor.utils.js.map +1 -1
  65. package/dist/esm/editor/extensions/buildExtensions.js +35 -25
  66. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  67. package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.d.ts +13 -0
  68. package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +64 -0
  69. package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -0
  70. package/dist/esm/helpers/index.d.ts +1 -0
  71. package/dist/esm/helpers/sanitize.d.ts +32 -0
  72. package/dist/esm/helpers/sanitize.js +207 -0
  73. package/dist/esm/helpers/sanitize.js.map +1 -0
  74. package/dist/esm/icons/index.d.ts +25 -25
  75. package/dist/esm/index.js +125 -115
  76. package/dist/esm/index.js.map +1 -1
  77. package/package.json +2 -1
@@ -1,90 +1,94 @@
1
1
  import { jsxs as u, jsx as d } from "react/jsx-runtime";
2
- import { getMarkRange as Ee } from "../node_modules/@tiptap/core/dist/index.js";
3
- import { useEditor as Te, EditorContent as ee } from "@tiptap/react";
4
- import { forwardRef as Ae, useState as x, useRef as a, useEffect as Ie, useImperativeHandle as Je } from "react";
5
- import { BodyCaption as te } from "../components/TypographyStyle.js";
6
- import { BikEditorShell as Me, BikJsonHeader as Re, BikJsonBody as Le, BikJsonEmptyState as Oe, BikJsonError as Fe } from "./BikEditor.styles.js";
7
- import { DEFAULT_FORMAT_STATE as ne } from "./BikEditor.types.js";
8
- import { buildJsonCodeBlockHtml as je, buildSectionedContent as oe, normalizeHtml as i, extractActiveFormats as re, extractContent as se, getCodeBlockText as g, parseJson as p, extractBodyContent as ze, extractSectionContent as Ne, setCodeBlockText as v, findSectionEndPos as ie, findSectionStartPos as He, setSectionContentInEditor as I, insertInlineHtml as we } from "./BikEditor.utils.js";
9
- import { buildExtensions as Pe } from "./extensions/buildExtensions.js";
10
- import { LinkBubbleMenu as De } from "./floating/LinkBubbleMenu.js";
11
- import qe from "../icons/BIK AI specific/WandSparkles.js";
12
- import Ue from "../icons/Actions/Formatting/Copy.js";
13
- import $e from "../icons/Actions/Common actions/Code.js";
14
- import We from "../icons/Informational/General/Info.js";
15
- function Ve(k) {
2
+ import { getMarkRange as Tt } from "../node_modules/@tiptap/core/dist/index.js";
3
+ import { useEditor as At, EditorContent as et } from "@tiptap/react";
4
+ import { forwardRef as Rt, useCallback as It, useState as x, useRef as a, useEffect as Jt, useImperativeHandle as Mt } from "react";
5
+ import { BodyCaption as nt } from "../components/TypographyStyle.js";
6
+ import { sanitizeEmailHtml as Lt, sanitizeBasicHtml as Ot } from "../helpers/sanitize.js";
7
+ import { BikEditorShell as zt, BikJsonHeader as Ft, BikJsonBody as jt, BikJsonEmptyState as Ht, BikJsonError as Nt } from "./BikEditor.styles.js";
8
+ import { DEFAULT_FORMAT_STATE as ot } from "./BikEditor.types.js";
9
+ import { normalizeHtml as Pt, buildJsonCodeBlockHtml as wt, buildSectionedContent as rt, extractActiveFormats as st, extractContent as it, getCodeBlockText as g, parseJson as p, extractBodyContent as Dt, extractSectionContent as qt, setCodeBlockText as b, findSectionEndPos as ct, findSectionStartPos as Ut, setSectionContentInEditor as R, insertInlineHtml as $t } from "./BikEditor.utils.js";
10
+ import { buildExtensions as Wt } from "./extensions/buildExtensions.js";
11
+ import { LinkBubbleMenu as Vt } from "./floating/LinkBubbleMenu.js";
12
+ import _t from "../icons/BIK AI specific/WandSparkles.js";
13
+ import Qt from "../icons/Actions/Formatting/Copy.js";
14
+ import Zt from "../icons/Actions/Common actions/Code.js";
15
+ import Gt from "../icons/Informational/General/Info.js";
16
+ function Kt(k) {
16
17
  return Object.entries(k).map(
17
- ([b, C]) => `${b.replace(/([A-Z])/g, (y) => `-${y.toLowerCase()}`)}:${C}`
18
+ ([v, C]) => `${v.replace(/([A-Z])/g, (y) => `-${y.toLowerCase()}`)}:${C}`
18
19
  ).join(";");
19
20
  }
20
- const _e = (k, b) => {
21
+ const Xt = (k, v) => {
21
22
  const {
22
23
  initialContent: C,
23
24
  sections: y,
24
25
  features: B,
25
- disabled: ce,
26
- maxCharacters: J,
27
- characterLimit: ae,
28
- characterLimitHard: le,
29
- shortcuts: de,
30
- sendShortcut: ue,
26
+ disabled: at,
27
+ maxCharacters: I,
28
+ characterLimit: lt,
29
+ characterLimitHard: dt,
30
+ shortcuts: ut,
31
+ sendShortcut: mt,
31
32
  mentions: l,
32
33
  slashCommands: S,
33
- link: me,
34
- onPaste: fe,
35
- onReady: M,
36
- onChange: R,
34
+ link: ft,
35
+ onPaste: gt,
36
+ onReady: J,
37
+ onChange: M,
37
38
  onSend: E,
38
39
  onFocus: L,
39
40
  onBlur: O,
40
- onSelectionChange: F,
41
- minHeight: ge,
42
- maxHeight: he,
43
- style: pe,
44
- className: Ce,
45
- editorClassName: j,
46
- editorStyle: z,
47
- renderJsonError: N
48
- } = k, m = !!B?.jsonMode, [f, H] = x(null), [Se, w] = x(!1), [T, P] = x(
41
+ onSelectionChange: z,
42
+ minHeight: ht,
43
+ maxHeight: pt,
44
+ style: Ct,
45
+ className: St,
46
+ editorClassName: F,
47
+ editorStyle: j,
48
+ renderJsonError: H
49
+ } = k, m = !!B?.jsonMode, N = !!B?.richPaste ? Lt : Ot, i = It(
50
+ (t) => Pt(t, N),
51
+ [N]
52
+ ), [f, P] = x(null), [kt, w] = x(!1), [T, D] = x(
49
53
  m && !(C ?? "").trim()
50
- ), [ke, D] = x(!1), ye = m ? je(C ?? "") : y?.length ? oe(
54
+ ), [yt, q] = x(!1), Bt = m ? wt(C ?? "") : y?.length ? rt(
51
55
  i(C ?? ""),
52
- y.map((e) => ({ ...e, content: i(e.content) }))
53
- ) : i(C ?? ""), A = a([]), q = a(!1), U = a(M);
54
- U.current = M;
55
- const $ = a(R);
56
- $.current = R;
57
- const W = a(F);
58
- W.current = F;
59
- const V = a(ne), _ = a(L);
60
- _.current = L;
61
- const Q = a(O);
62
- Q.current = O;
63
- const Z = a(E);
64
- Z.current = E;
65
- const G = a(l?.agents ?? []);
66
- G.current = l?.agents ?? [];
67
- const K = a(l?.teams ?? []);
68
- K.current = l?.teams ?? [];
69
- const X = a(S?.items ?? []);
70
- X.current = S?.items ?? [];
71
- const n = Te({
72
- extensions: Pe({
56
+ y.map((t) => ({ ...t, content: i(t.content) }))
57
+ ) : i(C ?? ""), A = a([]), U = a(!1), $ = a(J);
58
+ $.current = J;
59
+ const W = a(M);
60
+ W.current = M;
61
+ const V = a(z);
62
+ V.current = z;
63
+ const _ = a(ot), Q = a(L);
64
+ Q.current = L;
65
+ const Z = a(O);
66
+ Z.current = O;
67
+ const G = a(E);
68
+ G.current = E;
69
+ const K = a(l?.agents ?? []);
70
+ K.current = l?.agents ?? [];
71
+ const X = a(l?.teams ?? []);
72
+ X.current = l?.teams ?? [];
73
+ const Y = a(S?.items ?? []);
74
+ Y.current = S?.items ?? [];
75
+ const n = At({
76
+ extensions: Wt({
73
77
  features: B,
74
78
  placeholder: k.placeholder,
75
- maxCharacters: J,
76
- characterLimit: ae,
77
- characterLimitHard: le,
79
+ maxCharacters: I,
80
+ characterLimit: lt,
81
+ characterLimitHard: dt,
78
82
  hasSections: (y?.length ?? 0) > 0,
79
83
  mentions: {
80
- agents: l ? G : void 0,
81
- teams: l ? K : void 0
84
+ agents: l ? K : void 0,
85
+ teams: l ? X : void 0
82
86
  },
83
- slashCommands: S ? X : void 0,
84
- onPaste: fe,
85
- onSend: E ? (e) => Z.current?.(e) : void 0,
86
- sendShortcut: ue,
87
- shortcuts: de,
87
+ slashCommands: S ? Y : void 0,
88
+ onPaste: gt,
89
+ onSend: E ? (t) => G.current?.(t) : void 0,
90
+ sendShortcut: mt,
91
+ shortcuts: ut,
88
92
  onMentionSelected: l?.onSelect,
89
93
  onSlashCommandSelected: S?.onSelect,
90
94
  renderMentionItem: l?.renderItem,
@@ -94,187 +98,187 @@ const _e = (k, b) => {
94
98
  renderSlashCommandItem: S?.renderItem,
95
99
  renderSlashCommandDropdown: S?.renderDropdown
96
100
  }),
97
- content: ye,
98
- editable: !ce,
101
+ content: Bt,
102
+ editable: !at,
99
103
  immediatelyRender: !1,
100
104
  // SSR-safe — NEVER remove this
101
105
  editorProps: {
102
106
  attributes: {
103
- ...j ? { class: j } : {},
104
- ...z ? { style: Ve(z) } : {}
107
+ ...F ? { class: F } : {},
108
+ ...j ? { style: Kt(j) } : {}
105
109
  }
106
110
  },
107
- onUpdate: ({ editor: e }) => {
108
- if ($.current?.(se(e)), m) {
109
- const t = g(e), o = p(t);
110
- H(o.valid ? null : o), P(!t.trim());
111
+ onUpdate: ({ editor: t }) => {
112
+ if (W.current?.(it(t)), m) {
113
+ const e = g(t), o = p(e);
114
+ P(o.valid ? null : o), D(!e.trim());
111
115
  }
112
116
  },
113
- onTransaction: ({ editor: e }) => {
114
- const t = re(e), o = V.current;
115
- (o.bold !== t.bold || o.italic !== t.italic || o.underline !== t.underline || o.strike !== t.strike || o.bulletList !== t.bulletList || o.orderedList !== t.orderedList || o.blockquote !== t.blockquote || o.codeBlock !== t.codeBlock || o.superscript !== t.superscript || o.subscript !== t.subscript || o.textAlign !== t.textAlign || o.fontFamily !== t.fontFamily || o.fontSize !== t.fontSize || o.color !== t.color || o.highlight !== t.highlight || o.link?.href !== t.link?.href) && (V.current = t, W.current?.(t));
117
+ onTransaction: ({ editor: t }) => {
118
+ const e = st(t), o = _.current;
119
+ (o.bold !== e.bold || o.italic !== e.italic || o.underline !== e.underline || o.strike !== e.strike || o.bulletList !== e.bulletList || o.orderedList !== e.orderedList || o.blockquote !== e.blockquote || o.codeBlock !== e.codeBlock || o.superscript !== e.superscript || o.subscript !== e.subscript || o.textAlign !== e.textAlign || o.fontFamily !== e.fontFamily || o.fontSize !== e.fontSize || o.color !== e.color || o.highlight !== e.highlight || o.link?.href !== e.link?.href) && (_.current = e, V.current?.(e));
116
120
  },
117
121
  onFocus: () => {
118
- D(!0), _.current?.();
122
+ q(!0), Q.current?.();
119
123
  },
120
124
  onBlur: () => {
121
- D(!1), Q.current?.();
125
+ q(!1), Z.current?.();
122
126
  }
123
127
  });
124
- function s(e) {
125
- n ? e(n) : A.current.push(e);
128
+ function s(t) {
129
+ n ? t(n) : A.current.push(t);
126
130
  }
127
- Ie(() => {
128
- if (n && (A.current.length > 0 && A.current.splice(0).forEach((t) => t(n)), q.current || (q.current = !0, U.current?.()), m)) {
129
- const e = g(n), t = p(e);
130
- H(t.valid ? null : t), P(!e.trim());
131
+ Jt(() => {
132
+ if (n && (A.current.length > 0 && A.current.splice(0).forEach((e) => e(n)), U.current || (U.current = !0, $.current?.()), m)) {
133
+ const t = g(n), e = p(t);
134
+ P(e.valid ? null : e), D(!t.trim());
131
135
  }
132
- }, [n, m]), Je(
133
- b,
136
+ }, [n, m]), Mt(
137
+ v,
134
138
  () => ({
135
139
  // ── Focus ────────────────────────────────────────────────────────
136
- focus: (e) => s((t) => t.commands.focus(e)),
137
- blur: () => s((e) => e.commands.blur()),
140
+ focus: (t) => s((e) => e.commands.focus(t)),
141
+ blur: () => s((t) => t.commands.blur()),
138
142
  // ── Content ──────────────────────────────────────────────────────
139
- clearContent: () => s((e) => e.commands.clearContent(!0)),
140
- setContent: (e) => {
141
- const t = i(e);
142
- s((o) => o.commands.setContent(t, { emitUpdate: !0 }));
143
+ clearContent: () => s((t) => t.commands.clearContent(!0)),
144
+ setContent: (t) => {
145
+ const e = i(t);
146
+ s((o) => o.commands.setContent(e, { emitUpdate: !0 }));
143
147
  },
144
- insertContent: (e) => {
145
- const t = i(e);
146
- s((o) => o.commands.insertContent(t));
148
+ insertContent: (t) => {
149
+ const e = i(t);
150
+ s((o) => o.commands.insertContent(e));
147
151
  },
148
- insertInlineContent: (e) => {
149
- s((t) => we(t, e));
152
+ insertInlineContent: (t) => {
153
+ s((e) => $t(e, t));
150
154
  },
151
- insertAtStart: (e) => {
152
- const t = i(e);
153
- s((o) => o.commands.insertContentAt(1, t));
155
+ insertAtStart: (t) => {
156
+ const e = i(t);
157
+ s((o) => o.commands.insertContentAt(1, e));
154
158
  },
155
- insertBlock: (e) => {
156
- const t = i(e);
159
+ insertBlock: (t) => {
160
+ const e = i(t);
157
161
  s(
158
- (o) => o.commands.insertContentAt(o.state.doc.content.size, t)
162
+ (o) => o.commands.insertContentAt(o.state.doc.content.size, e)
159
163
  );
160
164
  },
161
- appendInline: (e) => {
162
- const t = i(e);
165
+ appendInline: (t) => {
166
+ const e = i(t);
163
167
  s(
164
- (o) => o.commands.insertContentAt(o.state.doc.content.size - 1, t)
168
+ (o) => o.commands.insertContentAt(o.state.doc.content.size - 1, e)
165
169
  );
166
170
  },
167
171
  // Backwards-compatible aliases
168
- insertAtEnd(e) {
169
- this.insertBlock(e);
172
+ insertAtEnd(t) {
173
+ this.insertBlock(t);
170
174
  },
171
- appendContent(e) {
172
- this.appendInline(e);
175
+ appendContent(t) {
176
+ this.appendInline(t);
173
177
  },
174
- getContent: () => n ? se(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
178
+ getContent: () => n ? it(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
175
179
  getJSON: () => n?.getJSON() ?? null,
176
180
  getMentions: () => {
177
- const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
181
+ const t = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Set();
178
182
  return n ? (n.state.doc.descendants((o) => {
179
- o.type.name === "mentionAgent" && o.attrs.id != null ? e.add(String(o.attrs.id)) : o.type.name === "mentionTeam" && o.attrs.id != null && t.add(String(o.attrs.id));
180
- }), { agentIds: Array.from(e), teamIds: Array.from(t) }) : { agentIds: [], teamIds: [] };
183
+ o.type.name === "mentionAgent" && o.attrs.id != null ? t.add(String(o.attrs.id)) : o.type.name === "mentionTeam" && o.attrs.id != null && e.add(String(o.attrs.id));
184
+ }), { agentIds: Array.from(t), teamIds: Array.from(e) }) : { agentIds: [], teamIds: [] };
181
185
  },
182
186
  // ── Selection ────────────────────────────────────────────────────
183
187
  getCursorPosition: () => {
184
188
  if (!n) return { from: 0, to: 0 };
185
- const { from: e, to: t } = n.state.selection;
186
- return { from: e, to: t };
189
+ const { from: t, to: e } = n.state.selection;
190
+ return { from: t, to: e };
187
191
  },
188
- insertAtPosition: (e, t) => {
189
- const o = i(t);
190
- s((r) => r.commands.insertContentAt(e, o));
192
+ insertAtPosition: (t, e) => {
193
+ const o = i(e);
194
+ s((r) => r.commands.insertContentAt(t, o));
191
195
  },
192
196
  getSelectedText: () => {
193
197
  if (!n) return "";
194
- const { state: e } = n, { from: t, to: o, empty: r } = e.selection;
198
+ const { state: t } = n, { from: e, to: o, empty: r } = t.selection;
195
199
  if (!r)
196
- return e.doc.textBetween(t, o, " ");
197
- const c = e.schema.marks.link;
200
+ return t.doc.textBetween(e, o, " ");
201
+ const c = t.schema.marks.link;
198
202
  if (c) {
199
- const h = Ee(e.doc.resolve(t), c);
203
+ const h = Tt(t.doc.resolve(e), c);
200
204
  if (h)
201
- return e.doc.textBetween(h.from, h.to, " ");
205
+ return t.doc.textBetween(h.from, h.to, " ");
202
206
  }
203
207
  return "";
204
208
  },
205
209
  // ── Character count ───────────────────────────────────────────────
206
210
  getCharacterCount: () => ({
207
211
  count: n?.storage.characterCount?.characters?.() ?? n?.getText().length ?? 0,
208
- limit: J ?? null
212
+ limit: I ?? null
209
213
  }),
210
214
  // ── Sections ─────────────────────────────────────────────────────
211
- getSectionContent: (e) => n ? Ne(n, e) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
212
- setSectionContent: (e, t) => {
213
- const o = i(t);
214
- s((r) => I(r, e, o));
215
+ getSectionContent: (t) => n ? qt(n, t) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
216
+ setSectionContent: (t, e) => {
217
+ const o = i(e);
218
+ s((r) => R(r, t, o));
215
219
  },
216
- focusSection: (e) => {
217
- s((t) => {
218
- if (e === "body") {
219
- let r = t.state.doc.content.size - 1;
220
- t.state.doc.descendants((c, h) => (c.type.name === "sectionDivider" && r === t.state.doc.content.size - 1 && (r = h - 1), r === t.state.doc.content.size - 1)), r < 1 && (r = 1), t.chain().focus().setTextSelection(r).run();
220
+ focusSection: (t) => {
221
+ s((e) => {
222
+ if (t === "body") {
223
+ let r = e.state.doc.content.size - 1;
224
+ e.state.doc.descendants((c, h) => (c.type.name === "sectionDivider" && r === e.state.doc.content.size - 1 && (r = h - 1), r === e.state.doc.content.size - 1)), r < 1 && (r = 1), e.chain().focus().setTextSelection(r).run();
221
225
  return;
222
226
  }
223
227
  let o = -1;
224
- t.state.doc.descendants((r, c) => {
228
+ e.state.doc.descendants((r, c) => {
225
229
  if (o !== -1) return !1;
226
- r.type.name === "sectionDivider" && r.attrs.sectionId === e && (o = c + r.nodeSize + 1);
227
- }), o !== -1 && t.chain().focus().setTextSelection(o).run();
230
+ r.type.name === "sectionDivider" && r.attrs.sectionId === t && (o = c + r.nodeSize + 1);
231
+ }), o !== -1 && e.chain().focus().setTextSelection(o).run();
228
232
  });
229
233
  },
230
- clearSection: (e) => {
231
- s((t) => I(t, e, "<p></p>"));
234
+ clearSection: (t) => {
235
+ s((e) => R(e, t, "<p></p>"));
232
236
  },
233
237
  // ── Convenience body shorthands ───────────────────────────────────
234
- getBodyContent: () => n ? ze(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
235
- setBodyContent: (e) => {
236
- const t = i(e);
237
- s((o) => I(o, "body", t));
238
+ getBodyContent: () => n ? Dt(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
239
+ setBodyContent: (t) => {
240
+ const e = i(t);
241
+ s((o) => R(o, "body", e));
238
242
  },
239
- setBodyAndSections: (e, t) => {
240
- const o = oe(
241
- i(e),
242
- t.map((r) => ({
243
+ setBodyAndSections: (t, e) => {
244
+ const o = rt(
245
+ i(t),
246
+ e.map((r) => ({
243
247
  id: r.id,
244
248
  content: i(r.content)
245
249
  }))
246
250
  );
247
251
  s((r) => r.commands.setContent(o, { emitUpdate: !0 }));
248
252
  },
249
- appendBodyContent: (e) => {
250
- const t = i(e);
253
+ appendBodyContent: (t) => {
254
+ const e = i(t);
251
255
  s((o) => {
252
- const r = ie(o, "body");
253
- o.commands.insertContentAt(r - 1, t, {
256
+ const r = ct(o, "body");
257
+ o.commands.insertContentAt(r - 1, e, {
254
258
  parseOptions: { preserveWhitespace: !0 }
255
259
  });
256
260
  });
257
261
  },
258
- insertAtSectionStart: (e, t) => {
259
- const o = i(t);
262
+ insertAtSectionStart: (t, e) => {
263
+ const o = i(e);
260
264
  s((r) => {
261
- const c = He(r, e);
265
+ const c = Ut(r, t);
262
266
  c !== -1 && r.commands.insertContentAt(c, o, {
263
267
  parseOptions: { preserveWhitespace: !0 }
264
268
  });
265
269
  });
266
270
  },
267
- insertAtSectionEnd: (e, t) => {
268
- const o = i(t);
271
+ insertAtSectionEnd: (t, e) => {
272
+ const o = i(e);
269
273
  s((r) => {
270
- const c = ie(r, e);
274
+ const c = ct(r, t);
271
275
  r.commands.insertContentAt(c, o, {
272
276
  parseOptions: { preserveWhitespace: !0 }
273
277
  });
274
278
  });
275
279
  },
276
280
  // ── Formats & actions ─────────────────────────────────────────────
277
- getActiveFormats: () => n ? re(n) : ne,
281
+ getActiveFormats: () => n ? st(n) : ot,
278
282
  actions: {
279
283
  toggleBold: () => n?.chain().focus().toggleBold().run(),
280
284
  toggleItalic: () => n?.chain().focus().toggleItalic().run(),
@@ -284,33 +288,33 @@ const _e = (k, b) => {
284
288
  toggleOrderedList: () => n?.chain().focus().toggleOrderedList().run(),
285
289
  toggleBlockquote: () => n?.chain().focus().toggleBlockquote().run(),
286
290
  toggleCodeBlock: () => n?.chain().focus().toggleCodeBlock().run(),
287
- setTextAlign: (e) => n?.chain().focus().setTextAlign(e).run(),
288
- setFontFamily: (e) => n?.chain().focus().setFontFamily(e).run(),
289
- setFontSize: (e) => n?.chain().focus().setFontSize(e).run(),
290
- setColor: (e) => n?.chain().focus().setColor(e).run(),
291
- setHighlight: (e) => n?.chain().focus().toggleHighlight({ color: e }).run(),
291
+ setTextAlign: (t) => n?.chain().focus().setTextAlign(t).run(),
292
+ setFontFamily: (t) => n?.chain().focus().setFontFamily(t).run(),
293
+ setFontSize: (t) => n?.chain().focus().setFontSize(t).run(),
294
+ setColor: (t) => n?.chain().focus().setColor(t).run(),
295
+ setHighlight: (t) => n?.chain().focus().toggleHighlight({ color: t }).run(),
292
296
  unsetColor: () => n?.chain().focus().unsetColor().run(),
293
297
  unsetHighlight: () => n?.chain().focus().unsetHighlight().run(),
294
- setLink: (e, t) => {
295
- n && (t !== void 0 ? n.chain().focus().extendMarkRange("link").command(({ tr: o, state: r }) => {
296
- const { from: c, to: h } = o.selection, Y = r.schema.marks.link;
297
- if (!Y) return !1;
298
- const ve = r.schema.text(t, [
299
- Y.create({ href: e })
300
- ]), be = r.schema.text(" ");
301
- return o.replaceWith(c, h, [ve, be]), !0;
302
- }).run() : n.chain().focus().extendMarkRange("link").setLink({ href: e }).insertContent(" ").run());
298
+ setLink: (t, e) => {
299
+ n && (e !== void 0 ? n.chain().focus().extendMarkRange("link").command(({ tr: o, state: r }) => {
300
+ const { from: c, to: h } = o.selection, tt = r.schema.marks.link;
301
+ if (!tt) return !1;
302
+ const vt = r.schema.text(e, [
303
+ tt.create({ href: t })
304
+ ]), Et = r.schema.text(" ");
305
+ return o.replaceWith(c, h, [vt, Et]), !0;
306
+ }).run() : n.chain().focus().extendMarkRange("link").setLink({ href: t }).insertContent(" ").run());
303
307
  },
304
- updateLink: (e) => n?.chain().focus().extendMarkRange("link").setLink({ href: e }).run(),
308
+ updateLink: (t) => n?.chain().focus().extendMarkRange("link").setLink({ href: t }).run(),
305
309
  removeLink: () => n?.chain().focus().extendMarkRange("link").unsetLink().run(),
306
- insertEmoji: (e) => n?.chain().focus().insertContent(e).run(),
307
- insertVariable: (e) => n?.chain().focus().insertContent(`{{${e}}}`).run(),
308
- insertHtml: (e) => n?.commands.insertContent(i(e)),
309
- openMentionMenu: (e = "@") => {
310
+ insertEmoji: (t) => n?.chain().focus().insertContent(t).run(),
311
+ insertVariable: (t) => n?.chain().focus().insertContent(`{{${t}}}`).run(),
312
+ insertHtml: (t) => n?.commands.insertContent(i(t)),
313
+ openMentionMenu: (t = "@") => {
310
314
  if (!n)
311
315
  return;
312
- const { to: t } = n.state.selection, o = t > 1 ? n.state.doc.textBetween(t - 1, t) : "", r = o !== "" && !/\s/.test(o);
313
- n.chain().focus().setTextSelection(t).insertContent(r ? ` ${e}` : e).run();
316
+ const { to: e } = n.state.selection, o = e > 1 ? n.state.doc.textBetween(e - 1, e) : "", r = o !== "" && !/\s/.test(o);
317
+ n.chain().focus().setTextSelection(e).insertContent(r ? ` ${t}` : t).run();
314
318
  },
315
319
  undo: () => n?.chain().focus().undo().run(),
316
320
  redo: () => n?.chain().focus().redo().run(),
@@ -318,57 +322,57 @@ const _e = (k, b) => {
318
322
  canRedo: () => n?.can().redo() ?? !1,
319
323
  toggleSuperscript: () => n?.chain().focus().toggleSuperscript().run(),
320
324
  toggleSubscript: () => n?.chain().focus().toggleSubscript().run(),
321
- insertImage: (e) => n?.chain().focus().setImage({ src: e }).run()
325
+ insertImage: (t) => n?.chain().focus().setImage({ src: t }).run()
322
326
  },
323
327
  // ── JSON body ─────────────────────────────────────────────────────
324
328
  json: B?.jsonMode ? {
325
329
  getText: () => n ? g(n) : "",
326
- setText: (e) => s((t) => v(t, e)),
330
+ setText: (t) => s((e) => b(e, t)),
327
331
  parse: () => p(n ? g(n) : ""),
328
332
  isValid: () => p(n ? g(n) : "").valid,
329
- format: (e = 2) => s((t) => {
330
- const { valid: o, value: r } = p(g(t));
331
- !o || r === null || v(t, JSON.stringify(r, null, e));
333
+ format: (t = 2) => s((e) => {
334
+ const { valid: o, value: r } = p(g(e));
335
+ !o || r === null || b(e, JSON.stringify(r, null, t));
332
336
  }),
333
- minify: () => s((e) => {
334
- const { valid: t, value: o } = p(g(e));
335
- !t || o === null || v(e, JSON.stringify(o));
337
+ minify: () => s((t) => {
338
+ const { valid: e, value: o } = p(g(t));
339
+ !e || o === null || b(t, JSON.stringify(o));
336
340
  })
337
341
  } : void 0
338
342
  }),
339
343
  // eslint-disable-next-line react-hooks/exhaustive-deps
340
344
  [n]
341
345
  );
342
- const Be = () => {
346
+ const xt = () => {
343
347
  if (!n) return;
344
- const { valid: e, value: t } = p(g(n));
345
- !e || t === null || v(n, JSON.stringify(t, null, 2));
346
- }, xe = () => {
348
+ const { valid: t, value: e } = p(g(n));
349
+ !t || e === null || b(n, JSON.stringify(e, null, 2));
350
+ }, bt = () => {
347
351
  n && (navigator.clipboard?.writeText(g(n)), w(!0), setTimeout(() => w(!1), 1500));
348
352
  };
349
353
  return n ? /* @__PURE__ */ u(
350
- Me,
354
+ zt,
351
355
  {
352
- minHeight: ge,
353
- maxHeight: he,
356
+ minHeight: ht,
357
+ maxHeight: pt,
354
358
  tightParagraphs: !B?.richPaste,
355
359
  jsonMode: m,
356
- style: pe,
357
- className: Ce,
360
+ style: Ct,
361
+ className: St,
358
362
  children: [
359
- m && /* @__PURE__ */ u(Re, { children: [
363
+ m && /* @__PURE__ */ u(Ft, { children: [
360
364
  /* @__PURE__ */ d("span", { className: "bik-json-header-label", children: "JSON" }),
361
365
  /* @__PURE__ */ u("div", { className: "bik-json-header-actions", children: [
362
366
  /* @__PURE__ */ u(
363
367
  "button",
364
368
  {
365
369
  type: "button",
366
- onClick: Be,
370
+ onClick: xt,
367
371
  disabled: !!f || T,
368
372
  title: "Format JSON",
369
373
  children: [
370
- /* @__PURE__ */ d(qe, { size: 16 }),
371
- /* @__PURE__ */ d(te, { children: "Beautify" })
374
+ /* @__PURE__ */ d(_t, { size: 16 }),
375
+ /* @__PURE__ */ d(nt, { children: "Beautify" })
372
376
  ]
373
377
  }
374
378
  ),
@@ -376,27 +380,27 @@ const _e = (k, b) => {
376
380
  "button",
377
381
  {
378
382
  type: "button",
379
- onClick: xe,
383
+ onClick: bt,
380
384
  disabled: T,
381
385
  title: "Copy JSON",
382
386
  children: [
383
- /* @__PURE__ */ d(Ue, { size: 16 }),
384
- Se && /* @__PURE__ */ d(te, { children: "Copied" })
387
+ /* @__PURE__ */ d(Qt, { size: 16 }),
388
+ kt && /* @__PURE__ */ d(nt, { children: "Copied" })
385
389
  ]
386
390
  }
387
391
  )
388
392
  ] })
389
393
  ] }),
390
- m ? /* @__PURE__ */ u(Le, { $error: !!f, children: [
391
- /* @__PURE__ */ d(ee, { editor: n }),
392
- T && !ke && /* @__PURE__ */ u(Oe, { "aria-hidden": !0, children: [
393
- /* @__PURE__ */ d($e, { size: 20 }),
394
+ m ? /* @__PURE__ */ u(jt, { $error: !!f, children: [
395
+ /* @__PURE__ */ d(et, { editor: n }),
396
+ T && !yt && /* @__PURE__ */ u(Ht, { "aria-hidden": !0, children: [
397
+ /* @__PURE__ */ d(Zt, { size: 20 }),
394
398
  /* @__PURE__ */ d("span", { children: k.placeholder ?? "Type or paste JSON here" })
395
399
  ] })
396
- ] }) : /* @__PURE__ */ d(ee, { editor: n }),
397
- /* @__PURE__ */ d(De, { editor: n, renderLinkTooltip: me?.renderTooltip }),
398
- m && f ? N ? N(f) : /* @__PURE__ */ u(Fe, { children: [
399
- /* @__PURE__ */ d(We, { size: 16 }),
400
+ ] }) : /* @__PURE__ */ d(et, { editor: n }),
401
+ /* @__PURE__ */ d(Vt, { editor: n, renderLinkTooltip: ft?.renderTooltip }),
402
+ m && f ? H ? H(f) : /* @__PURE__ */ u(Nt, { children: [
403
+ /* @__PURE__ */ d(Gt, { size: 16 }),
400
404
  /* @__PURE__ */ u("span", { children: [
401
405
  f.line != null && /* @__PURE__ */ u("strong", { children: [
402
406
  "Line ",
@@ -411,11 +415,11 @@ const _e = (k, b) => {
411
415
  ]
412
416
  }
413
417
  ) : null;
414
- }, Qe = Ae(
415
- _e
418
+ }, Yt = Rt(
419
+ Xt
416
420
  );
417
- Qe.displayName = "BikEditor";
421
+ Yt.displayName = "BikEditor";
418
422
  export {
419
- Qe as BikEditor
423
+ Yt as BikEditor
420
424
  };
421
425
  //# sourceMappingURL=BikEditor.js.map