@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.
- package/README.md +4 -4
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js +23 -23
- package/dist/cjs/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js +1 -1
- package/dist/cjs/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js +2 -2
- package/dist/cjs/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js +20 -20
- package/dist/cjs/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js +2 -2
- package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js +2 -2
- package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js +1 -1
- package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
- package/dist/cjs/components/input/ChipInput.js +1 -1
- package/dist/cjs/components/input/ChipInput.js.map +1 -1
- package/dist/cjs/components/input/Input-helper.js +1 -1
- package/dist/cjs/components/input/Input-helper.js.map +1 -1
- package/dist/cjs/components/input/Input.js +1 -1
- package/dist/cjs/components/input/Input.js.map +1 -1
- package/dist/cjs/components/plans/SubscriptionPlanSelector.js +5 -5
- package/dist/cjs/components/plans/SubscriptionPlanSelector.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.utils.js +3 -3
- package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js +2 -2
- package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +2 -0
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -0
- package/dist/cjs/helpers/sanitize.js +2 -0
- package/dist/cjs/helpers/sanitize.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js +144 -143
- package/dist/esm/components/WhatsAppTextEditor/WhatsAppTextEditor.js.map +1 -1
- package/dist/esm/components/agent-builder/components/AiTextArea.js +24 -23
- package/dist/esm/components/agent-builder/components/AiTextArea.js.map +1 -1
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js +38 -37
- package/dist/esm/components/agent-builder/components/ToolInstructionsField.js.map +1 -1
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js +54 -53
- package/dist/esm/components/bik-chatbot/components/ChatWindow.js.map +1 -1
- package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js +346 -420
- package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.js +35 -33
- package/dist/esm/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.js +48 -47
- package/dist/esm/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
- package/dist/esm/components/feature-announcements/types/props.types.d.ts +2 -2
- package/dist/esm/components/input/ChipInput.js +41 -40
- package/dist/esm/components/input/ChipInput.js.map +1 -1
- package/dist/esm/components/input/Input-helper.d.ts +7 -0
- package/dist/esm/components/input/Input-helper.js +16 -25
- package/dist/esm/components/input/Input-helper.js.map +1 -1
- package/dist/esm/components/input/Input.js +59 -57
- package/dist/esm/components/input/Input.js.map +1 -1
- package/dist/esm/components/input/Input.model.d.ts +1 -0
- package/dist/esm/components/plans/SubscriptionPlanSelector.js +42 -40
- package/dist/esm/components/plans/SubscriptionPlanSelector.js.map +1 -1
- package/dist/esm/editor/BikEditor.js +221 -217
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.utils.d.ts +1 -1
- package/dist/esm/editor/BikEditor.utils.js +141 -140
- package/dist/esm/editor/BikEditor.utils.js.map +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js +35 -25
- package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.d.ts +13 -0
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +64 -0
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -0
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/sanitize.d.ts +32 -0
- package/dist/esm/helpers/sanitize.js +207 -0
- package/dist/esm/helpers/sanitize.js.map +1 -0
- package/dist/esm/icons/index.d.ts +25 -25
- package/dist/esm/index.js +125 -115
- package/dist/esm/index.js.map +1 -1
- 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
|
|
3
|
-
import { useEditor as
|
|
4
|
-
import { forwardRef as
|
|
5
|
-
import { BodyCaption as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
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
|
-
([
|
|
18
|
+
([v, C]) => `${v.replace(/([A-Z])/g, (y) => `-${y.toLowerCase()}`)}:${C}`
|
|
18
19
|
).join(";");
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
+
const Xt = (k, v) => {
|
|
21
22
|
const {
|
|
22
23
|
initialContent: C,
|
|
23
24
|
sections: y,
|
|
24
25
|
features: B,
|
|
25
|
-
disabled:
|
|
26
|
-
maxCharacters:
|
|
27
|
-
characterLimit:
|
|
28
|
-
characterLimitHard:
|
|
29
|
-
shortcuts:
|
|
30
|
-
sendShortcut:
|
|
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:
|
|
34
|
-
onPaste:
|
|
35
|
-
onReady:
|
|
36
|
-
onChange:
|
|
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:
|
|
41
|
-
minHeight:
|
|
42
|
-
maxHeight:
|
|
43
|
-
style:
|
|
44
|
-
className:
|
|
45
|
-
editorClassName:
|
|
46
|
-
editorStyle:
|
|
47
|
-
renderJsonError:
|
|
48
|
-
} = k, m = !!B?.jsonMode,
|
|
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
|
-
), [
|
|
54
|
+
), [yt, q] = x(!1), Bt = m ? wt(C ?? "") : y?.length ? rt(
|
|
51
55
|
i(C ?? ""),
|
|
52
|
-
y.map((
|
|
53
|
-
) : i(C ?? ""), A = a([]),
|
|
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:
|
|
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:
|
|
76
|
-
characterLimit:
|
|
77
|
-
characterLimitHard:
|
|
79
|
+
maxCharacters: I,
|
|
80
|
+
characterLimit: lt,
|
|
81
|
+
characterLimitHard: dt,
|
|
78
82
|
hasSections: (y?.length ?? 0) > 0,
|
|
79
83
|
mentions: {
|
|
80
|
-
agents: l ?
|
|
81
|
-
teams: l ?
|
|
84
|
+
agents: l ? K : void 0,
|
|
85
|
+
teams: l ? X : void 0
|
|
82
86
|
},
|
|
83
|
-
slashCommands: S ?
|
|
84
|
-
onPaste:
|
|
85
|
-
onSend: E ? (
|
|
86
|
-
sendShortcut:
|
|
87
|
-
shortcuts:
|
|
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:
|
|
98
|
-
editable: !
|
|
101
|
+
content: Bt,
|
|
102
|
+
editable: !at,
|
|
99
103
|
immediatelyRender: !1,
|
|
100
104
|
// SSR-safe — NEVER remove this
|
|
101
105
|
editorProps: {
|
|
102
106
|
attributes: {
|
|
103
|
-
...
|
|
104
|
-
...
|
|
107
|
+
...F ? { class: F } : {},
|
|
108
|
+
...j ? { style: Kt(j) } : {}
|
|
105
109
|
}
|
|
106
110
|
},
|
|
107
|
-
onUpdate: ({ editor:
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
|
|
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:
|
|
114
|
-
const
|
|
115
|
-
(o.bold !==
|
|
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
|
-
|
|
122
|
+
q(!0), Q.current?.();
|
|
119
123
|
},
|
|
120
124
|
onBlur: () => {
|
|
121
|
-
|
|
125
|
+
q(!1), Z.current?.();
|
|
122
126
|
}
|
|
123
127
|
});
|
|
124
|
-
function s(
|
|
125
|
-
n ?
|
|
128
|
+
function s(t) {
|
|
129
|
+
n ? t(n) : A.current.push(t);
|
|
126
130
|
}
|
|
127
|
-
|
|
128
|
-
if (n && (A.current.length > 0 && A.current.splice(0).forEach((
|
|
129
|
-
const
|
|
130
|
-
|
|
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]),
|
|
133
|
-
|
|
136
|
+
}, [n, m]), Mt(
|
|
137
|
+
v,
|
|
134
138
|
() => ({
|
|
135
139
|
// ── Focus ────────────────────────────────────────────────────────
|
|
136
|
-
focus: (
|
|
137
|
-
blur: () => s((
|
|
140
|
+
focus: (t) => s((e) => e.commands.focus(t)),
|
|
141
|
+
blur: () => s((t) => t.commands.blur()),
|
|
138
142
|
// ── Content ──────────────────────────────────────────────────────
|
|
139
|
-
clearContent: () => s((
|
|
140
|
-
setContent: (
|
|
141
|
-
const
|
|
142
|
-
s((o) => o.commands.setContent(
|
|
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: (
|
|
145
|
-
const
|
|
146
|
-
s((o) => o.commands.insertContent(
|
|
148
|
+
insertContent: (t) => {
|
|
149
|
+
const e = i(t);
|
|
150
|
+
s((o) => o.commands.insertContent(e));
|
|
147
151
|
},
|
|
148
|
-
insertInlineContent: (
|
|
149
|
-
s((
|
|
152
|
+
insertInlineContent: (t) => {
|
|
153
|
+
s((e) => $t(e, t));
|
|
150
154
|
},
|
|
151
|
-
insertAtStart: (
|
|
152
|
-
const
|
|
153
|
-
s((o) => o.commands.insertContentAt(1,
|
|
155
|
+
insertAtStart: (t) => {
|
|
156
|
+
const e = i(t);
|
|
157
|
+
s((o) => o.commands.insertContentAt(1, e));
|
|
154
158
|
},
|
|
155
|
-
insertBlock: (
|
|
156
|
-
const
|
|
159
|
+
insertBlock: (t) => {
|
|
160
|
+
const e = i(t);
|
|
157
161
|
s(
|
|
158
|
-
(o) => o.commands.insertContentAt(o.state.doc.content.size,
|
|
162
|
+
(o) => o.commands.insertContentAt(o.state.doc.content.size, e)
|
|
159
163
|
);
|
|
160
164
|
},
|
|
161
|
-
appendInline: (
|
|
162
|
-
const
|
|
165
|
+
appendInline: (t) => {
|
|
166
|
+
const e = i(t);
|
|
163
167
|
s(
|
|
164
|
-
(o) => o.commands.insertContentAt(o.state.doc.content.size - 1,
|
|
168
|
+
(o) => o.commands.insertContentAt(o.state.doc.content.size - 1, e)
|
|
165
169
|
);
|
|
166
170
|
},
|
|
167
171
|
// Backwards-compatible aliases
|
|
168
|
-
insertAtEnd(
|
|
169
|
-
this.insertBlock(
|
|
172
|
+
insertAtEnd(t) {
|
|
173
|
+
this.insertBlock(t);
|
|
170
174
|
},
|
|
171
|
-
appendContent(
|
|
172
|
-
this.appendInline(
|
|
175
|
+
appendContent(t) {
|
|
176
|
+
this.appendInline(t);
|
|
173
177
|
},
|
|
174
|
-
getContent: () => n ?
|
|
178
|
+
getContent: () => n ? it(n) : { html: "", text: "", isEmpty: !0, characterCount: 0 },
|
|
175
179
|
getJSON: () => n?.getJSON() ?? null,
|
|
176
180
|
getMentions: () => {
|
|
177
|
-
const
|
|
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 ?
|
|
180
|
-
}), { agentIds: Array.from(
|
|
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:
|
|
186
|
-
return { from:
|
|
189
|
+
const { from: t, to: e } = n.state.selection;
|
|
190
|
+
return { from: t, to: e };
|
|
187
191
|
},
|
|
188
|
-
insertAtPosition: (
|
|
189
|
-
const o = i(
|
|
190
|
-
s((r) => r.commands.insertContentAt(
|
|
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:
|
|
198
|
+
const { state: t } = n, { from: e, to: o, empty: r } = t.selection;
|
|
195
199
|
if (!r)
|
|
196
|
-
return
|
|
197
|
-
const c =
|
|
200
|
+
return t.doc.textBetween(e, o, " ");
|
|
201
|
+
const c = t.schema.marks.link;
|
|
198
202
|
if (c) {
|
|
199
|
-
const h =
|
|
203
|
+
const h = Tt(t.doc.resolve(e), c);
|
|
200
204
|
if (h)
|
|
201
|
-
return
|
|
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:
|
|
212
|
+
limit: I ?? null
|
|
209
213
|
}),
|
|
210
214
|
// ── Sections ─────────────────────────────────────────────────────
|
|
211
|
-
getSectionContent: (
|
|
212
|
-
setSectionContent: (
|
|
213
|
-
const o = i(
|
|
214
|
-
s((r) =>
|
|
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: (
|
|
217
|
-
s((
|
|
218
|
-
if (
|
|
219
|
-
let r =
|
|
220
|
-
|
|
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
|
-
|
|
228
|
+
e.state.doc.descendants((r, c) => {
|
|
225
229
|
if (o !== -1) return !1;
|
|
226
|
-
r.type.name === "sectionDivider" && r.attrs.sectionId ===
|
|
227
|
-
}), o !== -1 &&
|
|
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: (
|
|
231
|
-
s((
|
|
234
|
+
clearSection: (t) => {
|
|
235
|
+
s((e) => R(e, t, "<p></p>"));
|
|
232
236
|
},
|
|
233
237
|
// ── Convenience body shorthands ───────────────────────────────────
|
|
234
|
-
getBodyContent: () => n ?
|
|
235
|
-
setBodyContent: (
|
|
236
|
-
const
|
|
237
|
-
s((o) =>
|
|
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: (
|
|
240
|
-
const o =
|
|
241
|
-
i(
|
|
242
|
-
|
|
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: (
|
|
250
|
-
const
|
|
253
|
+
appendBodyContent: (t) => {
|
|
254
|
+
const e = i(t);
|
|
251
255
|
s((o) => {
|
|
252
|
-
const r =
|
|
253
|
-
o.commands.insertContentAt(r - 1,
|
|
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: (
|
|
259
|
-
const o = i(
|
|
262
|
+
insertAtSectionStart: (t, e) => {
|
|
263
|
+
const o = i(e);
|
|
260
264
|
s((r) => {
|
|
261
|
-
const c =
|
|
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: (
|
|
268
|
-
const o = i(
|
|
271
|
+
insertAtSectionEnd: (t, e) => {
|
|
272
|
+
const o = i(e);
|
|
269
273
|
s((r) => {
|
|
270
|
-
const c =
|
|
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 ?
|
|
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: (
|
|
288
|
-
setFontFamily: (
|
|
289
|
-
setFontSize: (
|
|
290
|
-
setColor: (
|
|
291
|
-
setHighlight: (
|
|
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: (
|
|
295
|
-
n && (
|
|
296
|
-
const { from: c, to: h } = o.selection,
|
|
297
|
-
if (!
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
]),
|
|
301
|
-
return o.replaceWith(c, h, [
|
|
302
|
-
}).run() : n.chain().focus().extendMarkRange("link").setLink({ href:
|
|
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: (
|
|
308
|
+
updateLink: (t) => n?.chain().focus().extendMarkRange("link").setLink({ href: t }).run(),
|
|
305
309
|
removeLink: () => n?.chain().focus().extendMarkRange("link").unsetLink().run(),
|
|
306
|
-
insertEmoji: (
|
|
307
|
-
insertVariable: (
|
|
308
|
-
insertHtml: (
|
|
309
|
-
openMentionMenu: (
|
|
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:
|
|
313
|
-
n.chain().focus().setTextSelection(
|
|
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: (
|
|
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: (
|
|
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: (
|
|
330
|
-
const { valid: o, value: r } = p(g(
|
|
331
|
-
!o || r === null ||
|
|
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((
|
|
334
|
-
const { valid:
|
|
335
|
-
!
|
|
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
|
|
346
|
+
const xt = () => {
|
|
343
347
|
if (!n) return;
|
|
344
|
-
const { valid:
|
|
345
|
-
!
|
|
346
|
-
},
|
|
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
|
-
|
|
354
|
+
zt,
|
|
351
355
|
{
|
|
352
|
-
minHeight:
|
|
353
|
-
maxHeight:
|
|
356
|
+
minHeight: ht,
|
|
357
|
+
maxHeight: pt,
|
|
354
358
|
tightParagraphs: !B?.richPaste,
|
|
355
359
|
jsonMode: m,
|
|
356
|
-
style:
|
|
357
|
-
className:
|
|
360
|
+
style: Ct,
|
|
361
|
+
className: St,
|
|
358
362
|
children: [
|
|
359
|
-
m && /* @__PURE__ */ u(
|
|
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:
|
|
370
|
+
onClick: xt,
|
|
367
371
|
disabled: !!f || T,
|
|
368
372
|
title: "Format JSON",
|
|
369
373
|
children: [
|
|
370
|
-
/* @__PURE__ */ d(
|
|
371
|
-
/* @__PURE__ */ d(
|
|
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:
|
|
383
|
+
onClick: bt,
|
|
380
384
|
disabled: T,
|
|
381
385
|
title: "Copy JSON",
|
|
382
386
|
children: [
|
|
383
|
-
/* @__PURE__ */ d(
|
|
384
|
-
|
|
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(
|
|
391
|
-
/* @__PURE__ */ d(
|
|
392
|
-
T && !
|
|
393
|
-
/* @__PURE__ */ d(
|
|
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(
|
|
397
|
-
/* @__PURE__ */ d(
|
|
398
|
-
m && f ?
|
|
399
|
-
/* @__PURE__ */ d(
|
|
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
|
-
},
|
|
415
|
-
|
|
418
|
+
}, Yt = Rt(
|
|
419
|
+
Xt
|
|
416
420
|
);
|
|
417
|
-
|
|
421
|
+
Yt.displayName = "BikEditor";
|
|
418
422
|
export {
|
|
419
|
-
|
|
423
|
+
Yt as BikEditor
|
|
420
424
|
};
|
|
421
425
|
//# sourceMappingURL=BikEditor.js.map
|