@bikdotai/bik-component-library 0.0.823 → 0.0.824

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