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