@nivaro/react 0.3.123 → 0.3.124
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/shared/components/CollectionBrowserView.js +93 -91
- package/dist/shared/components/DataTable.js +240 -228
- package/dist/shared/components/RecordReadView.js +1 -1
- package/dist/shared/components/TipLayer.js +86 -63
- package/dist/shared/components/integrations/IntegrationDots.js +1 -0
- package/dist/shared/components/item-edit/HeaderRollupExplainer.js +156 -119
- package/dist/shared/components/item-edit/InlineGridField.js +1 -1
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +154 -179
- package/dist/shared/components/item-edit/UserChip.js +248 -232
- package/dist/shared/components/panels/PipelinePanel.js +252 -243
- package/dist/shared/components/panels/RevisionsPanel.js +1788 -662
- package/dist/shared/components/panels/revision-changes.js +229 -0
- package/dist/shared/components/panels/revision-table-parts.js +448 -0
- package/dist/shared/lib/activity-sentence.js +74 -68
- package/dist/shared/lib/editorjs.js +68 -0
- package/dist/shared/lib/revision-prefs.js +81 -0
- package/dist/shared/lib/xlsx-lite.js +125 -0
- package/package.json +1 -1
|
@@ -1,70 +1,45 @@
|
|
|
1
|
-
import { jsxs as g, Fragment as
|
|
1
|
+
import { jsxs as g, Fragment as X, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as U } from "@tanstack/react-query";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { useEditor as
|
|
7
|
-
import
|
|
8
|
-
import { Bold as
|
|
9
|
-
import { useState as w, useRef as
|
|
10
|
-
import { useApiFetchConfig as
|
|
11
|
-
import { useFieldEditors as
|
|
3
|
+
import Y from "@tiptap/extension-link";
|
|
4
|
+
import G from "@tiptap/extension-placeholder";
|
|
5
|
+
import Z from "@tiptap/extension-underline";
|
|
6
|
+
import { useEditor as ee, EditorContent as te } from "@tiptap/react";
|
|
7
|
+
import re from "@tiptap/starter-kit";
|
|
8
|
+
import { Bold as ie, Italic as ne, UnderlineIcon as oe, Strikethrough as ae, Heading1 as le, Heading2 as se, Heading3 as ce, List as de, ListOrdered as pe, Quote as ue, Code as he, Minus as fe, Link as me, Link2Off as ge, FileSymlink as W, Check as be, X as K, Loader2 as ke } from "lucide-react";
|
|
9
|
+
import { useState as w, useRef as L, useMemo as j, useEffect as T } from "react";
|
|
10
|
+
import { useApiFetchConfig as xe, useItemNavigation as ve } from "../../context.js";
|
|
11
|
+
import { useFieldEditors as _e } from "../../lib/co-edit.js";
|
|
12
12
|
import { cn as z } from "../../lib/utils.js";
|
|
13
|
-
import { SimpleSelect as
|
|
14
|
-
import { COEDIT_REMOTE as
|
|
15
|
-
import { CoeditCursors as
|
|
16
|
-
import { isSafeLinkHref as
|
|
13
|
+
import { SimpleSelect as ye } from "../ui/SimpleSelect.js";
|
|
14
|
+
import { COEDIT_REMOTE as we } from "./coedit/collab.js";
|
|
15
|
+
import { CoeditCursors as Ne, COEDIT_CURSOR_CSS as Ce } from "./coedit/cursors.js";
|
|
16
|
+
import { isSafeLinkHref as Le } from "./coedit/safe-link.js";
|
|
17
17
|
import { coeditColor as De } from "./coedit/session.js";
|
|
18
18
|
import { useCoedit as Ae } from "./coedit/useCoedit.js";
|
|
19
|
-
|
|
20
|
-
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
21
|
-
}
|
|
22
|
-
function $e(t) {
|
|
23
|
-
try {
|
|
24
|
-
return (JSON.parse(t || "{}").blocks ?? []).map((a) => {
|
|
25
|
-
const s = E(String(a.data.text ?? "")), c = Math.max(1, Math.min(6, Number(a.data.level ?? 2)));
|
|
26
|
-
switch (a.type) {
|
|
27
|
-
case "paragraph":
|
|
28
|
-
return `<p>${s}</p>`;
|
|
29
|
-
case "header":
|
|
30
|
-
return `<h${c}>${s}</h${c}>`;
|
|
31
|
-
case "list": {
|
|
32
|
-
const l = (a.data.items ?? []).map((N) => `<li>${E(N)}</li>`).join("");
|
|
33
|
-
return a.data.style === "ordered" ? `<ol>${l}</ol>` : `<ul>${l}</ul>`;
|
|
34
|
-
}
|
|
35
|
-
case "quote":
|
|
36
|
-
return `<blockquote><p>${s}</p></blockquote>`;
|
|
37
|
-
default:
|
|
38
|
-
return s ? `<p>${s}</p>` : "";
|
|
39
|
-
}
|
|
40
|
-
}).join("");
|
|
41
|
-
} catch {
|
|
42
|
-
return `<p>${E(t)}</p>`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
19
|
+
import { editorJsToHtml as Se } from "../../lib/editorjs.js";
|
|
45
20
|
const He = 2e3;
|
|
46
|
-
function
|
|
47
|
-
return t ? t.trimStart().startsWith('{"time":') && t.includes('"blocks":') ?
|
|
21
|
+
function R(t) {
|
|
22
|
+
return t ? t.trimStart().startsWith('{"time":') && t.includes('"blocks":') ? Se(t) : t : "";
|
|
48
23
|
}
|
|
49
|
-
function
|
|
24
|
+
function s({
|
|
50
25
|
active: t,
|
|
51
|
-
title:
|
|
52
|
-
onClick:
|
|
53
|
-
children:
|
|
26
|
+
title: c,
|
|
27
|
+
onClick: l,
|
|
28
|
+
children: p
|
|
54
29
|
}) {
|
|
55
30
|
return /* @__PURE__ */ e(
|
|
56
31
|
"button",
|
|
57
32
|
{
|
|
58
33
|
type: "button",
|
|
59
|
-
title:
|
|
60
|
-
onMouseDown: (
|
|
61
|
-
|
|
34
|
+
title: c,
|
|
35
|
+
onMouseDown: (d) => {
|
|
36
|
+
d.preventDefault(), l();
|
|
62
37
|
},
|
|
63
38
|
className: z(
|
|
64
39
|
"flex h-6 w-6 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-200 hover:text-slate-700 dark:text-slate-300 dark:hover:bg-[#334155] dark:hover:text-white",
|
|
65
40
|
t && "bg-slate-200 text-slate-900 dark:bg-[#334155] dark:text-white"
|
|
66
41
|
),
|
|
67
|
-
children:
|
|
42
|
+
children: p
|
|
68
43
|
}
|
|
69
44
|
);
|
|
70
45
|
}
|
|
@@ -73,47 +48,47 @@ function H() {
|
|
|
73
48
|
}
|
|
74
49
|
function et({
|
|
75
50
|
value: t,
|
|
76
|
-
onChange:
|
|
77
|
-
placeholder:
|
|
78
|
-
disabled:
|
|
79
|
-
pastePlain:
|
|
80
|
-
coedit:
|
|
51
|
+
onChange: c,
|
|
52
|
+
placeholder: l,
|
|
53
|
+
disabled: p,
|
|
54
|
+
pastePlain: d,
|
|
55
|
+
coedit: a
|
|
81
56
|
}) {
|
|
82
|
-
const [
|
|
57
|
+
const [E, x] = w(!1), [N, b] = w(""), [D, y] = w(!1), v = L(null), _ = xe(), k = ve(), A = j(() => R(t), [t]), n = L(null), u = L([]), r = ee({
|
|
83
58
|
immediatelyRender: !1,
|
|
84
59
|
extensions: [
|
|
85
60
|
// StarterKit 3 bundles its own Link (autolink on) and Underline; they are
|
|
86
61
|
// registered below with this editor's options, so the kit's copies stay out.
|
|
87
|
-
|
|
62
|
+
re.configure({
|
|
88
63
|
bulletList: { keepMarks: !0 },
|
|
89
64
|
orderedList: { keepMarks: !0 },
|
|
90
65
|
link: !1,
|
|
91
66
|
underline: !1
|
|
92
67
|
}),
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
Z,
|
|
69
|
+
G.configure({ placeholder: l ?? "Start writing…" }),
|
|
95
70
|
// 'record' protocol (#666): record://<collection>/<id> links survive the
|
|
96
71
|
// Link extension's allowed-URI validation and render as record chips.
|
|
97
72
|
// No autolink while typing: EFP site codes read like domains (byron.il,
|
|
98
73
|
// oswego.il) and every one became a bogus http:// link in notes that go
|
|
99
74
|
// to suppliers. Links are explicit — the toolbar, or pasting a URL.
|
|
100
75
|
// Never a script / data / file href, whoever typed it (co-edited text included, L7).
|
|
101
|
-
|
|
76
|
+
Y.configure({
|
|
102
77
|
openOnClick: !1,
|
|
103
78
|
autolink: !1,
|
|
104
79
|
protocols: ["record"],
|
|
105
|
-
isAllowedUri: (i, o) =>
|
|
80
|
+
isAllowedUri: (i, o) => Le(i) && o.defaultValidate(i)
|
|
106
81
|
}),
|
|
107
82
|
// Others' cursors while people write here together (inert otherwise).
|
|
108
|
-
|
|
83
|
+
Ne
|
|
109
84
|
],
|
|
110
85
|
content: A,
|
|
111
|
-
editable: !
|
|
86
|
+
editable: !p,
|
|
112
87
|
// NEVER undefined: an explicit `editorProps: undefined` overrides tiptap's
|
|
113
88
|
// `{}` default in the options merge, and 3.26's createView reads
|
|
114
89
|
// `editorProps.dispatchTransaction` unguarded — every non-pastePlain
|
|
115
90
|
// editor crashed at mount ("Cannot read properties of undefined").
|
|
116
|
-
editorProps:
|
|
91
|
+
editorProps: d ? {
|
|
117
92
|
handlePaste(i, o) {
|
|
118
93
|
var h;
|
|
119
94
|
const m = (h = o.clipboardData) == null ? void 0 : h.getData("text/plain");
|
|
@@ -121,206 +96,206 @@ function et({
|
|
|
121
96
|
}
|
|
122
97
|
} : {},
|
|
123
98
|
onUpdate({ editor: i, transaction: o }) {
|
|
124
|
-
var
|
|
125
|
-
if (o.getMeta(
|
|
99
|
+
var C;
|
|
100
|
+
if (o.getMeta(we) && !((C = n.current) != null && C.tracking())) return;
|
|
126
101
|
const m = i.getHTML(), h = u.current;
|
|
127
|
-
h.push({ html: m, at: Date.now() }), h.length > 64 && h.shift(),
|
|
102
|
+
h.push({ html: m, at: Date.now() }), h.length > 64 && h.shift(), c(m);
|
|
128
103
|
}
|
|
129
|
-
}), f = Ae(r,
|
|
104
|
+
}), f = Ae(r, a ?? null, t, R);
|
|
130
105
|
n.current = f.session;
|
|
131
|
-
const
|
|
132
|
-
() => f.peers.length || !f.diverged ||
|
|
133
|
-
[f.peers, f.diverged,
|
|
134
|
-
),
|
|
135
|
-
|
|
106
|
+
const J = _e(a == null ? void 0 : a.collection, a == null ? void 0 : a.item), S = a ? J[a.field] : void 0, Q = j(
|
|
107
|
+
() => f.peers.length || !f.diverged || !S ? f.peers : [{ name: S.name, color: De(String(S.id)) }],
|
|
108
|
+
[f.peers, f.diverged, S]
|
|
109
|
+
), M = L(null);
|
|
110
|
+
T(() => {
|
|
136
111
|
var o;
|
|
137
|
-
const i = (o =
|
|
112
|
+
const i = (o = M.current) == null ? void 0 : o.closest("[data-field]");
|
|
138
113
|
if (i)
|
|
139
114
|
return i.toggleAttribute("data-coedit-live", f.live), () => i.removeAttribute("data-coedit-live");
|
|
140
115
|
}, [f.live]);
|
|
141
|
-
const O =
|
|
142
|
-
if (
|
|
116
|
+
const O = L(t);
|
|
117
|
+
if (T(() => {
|
|
143
118
|
if (!r || O.current === t) return;
|
|
144
119
|
O.current = t;
|
|
145
120
|
const i = Date.now();
|
|
146
121
|
if (u.current.some((h) => h.html === t && i - h.at < He)) return;
|
|
147
122
|
const o = n.current;
|
|
148
123
|
if (o != null && o.isLive() && (r.isFocused || !o.tracking())) return;
|
|
149
|
-
const m =
|
|
124
|
+
const m = R(t);
|
|
150
125
|
r.getHTML() !== m && r.commands.setContent(m, { emitUpdate: !1 });
|
|
151
126
|
}, [r, t]), !r) return null;
|
|
152
|
-
const
|
|
127
|
+
const V = () => {
|
|
153
128
|
const i = r.getAttributes("link").href;
|
|
154
129
|
b(i ?? "https://"), x(!0), setTimeout(() => {
|
|
155
130
|
var o;
|
|
156
131
|
return (o = v.current) == null ? void 0 : o.select();
|
|
157
132
|
}, 0);
|
|
158
|
-
}, T = () => {
|
|
159
|
-
C === "" ? r.chain().focus().extendMarkRange("link").unsetLink().run() : r.chain().focus().extendMarkRange("link").setLink({ href: C }).run(), x(!1), b("");
|
|
160
133
|
}, I = () => {
|
|
134
|
+
N === "" ? r.chain().focus().extendMarkRange("link").unsetLink().run() : r.chain().focus().extendMarkRange("link").setLink({ href: N }).run(), x(!1), b("");
|
|
135
|
+
}, $ = () => {
|
|
161
136
|
x(!1), b("");
|
|
162
137
|
};
|
|
163
138
|
return /* @__PURE__ */ g(
|
|
164
139
|
"div",
|
|
165
140
|
{
|
|
166
|
-
ref:
|
|
141
|
+
ref: M,
|
|
167
142
|
className: z(
|
|
168
143
|
"overflow-hidden rounded-md border border-slate-200 bg-background focus-within:ring-1 focus-within:ring-nvr-cyan focus-within:border-nvr-cyan dark:border-border",
|
|
169
|
-
|
|
144
|
+
p && "opacity-60"
|
|
170
145
|
),
|
|
171
146
|
children: [
|
|
172
|
-
!
|
|
147
|
+
!p && /* @__PURE__ */ g(X, { children: [
|
|
173
148
|
/* @__PURE__ */ g("div", { className: "flex flex-wrap items-center gap-0.5 border-b border-slate-200 bg-slate-50 px-2 py-1.5 dark:border-border dark:bg-muted", children: [
|
|
174
149
|
/* @__PURE__ */ e(
|
|
175
|
-
|
|
150
|
+
s,
|
|
176
151
|
{
|
|
177
152
|
title: "Bold",
|
|
178
153
|
active: r.isActive("bold"),
|
|
179
154
|
onClick: () => r.chain().focus().toggleBold().run(),
|
|
180
|
-
children: /* @__PURE__ */ e(
|
|
155
|
+
children: /* @__PURE__ */ e(ie, { className: "h-3.5 w-3.5" })
|
|
181
156
|
}
|
|
182
157
|
),
|
|
183
158
|
/* @__PURE__ */ e(
|
|
184
|
-
|
|
159
|
+
s,
|
|
185
160
|
{
|
|
186
161
|
title: "Italic",
|
|
187
162
|
active: r.isActive("italic"),
|
|
188
163
|
onClick: () => r.chain().focus().toggleItalic().run(),
|
|
189
|
-
children: /* @__PURE__ */ e(
|
|
164
|
+
children: /* @__PURE__ */ e(ne, { className: "h-3.5 w-3.5" })
|
|
190
165
|
}
|
|
191
166
|
),
|
|
192
167
|
/* @__PURE__ */ e(
|
|
193
|
-
|
|
168
|
+
s,
|
|
194
169
|
{
|
|
195
170
|
title: "Underline",
|
|
196
171
|
active: r.isActive("underline"),
|
|
197
172
|
onClick: () => r.chain().focus().toggleUnderline().run(),
|
|
198
|
-
children: /* @__PURE__ */ e(
|
|
173
|
+
children: /* @__PURE__ */ e(oe, { className: "h-3.5 w-3.5" })
|
|
199
174
|
}
|
|
200
175
|
),
|
|
201
176
|
/* @__PURE__ */ e(
|
|
202
|
-
|
|
177
|
+
s,
|
|
203
178
|
{
|
|
204
179
|
title: "Strikethrough",
|
|
205
180
|
active: r.isActive("strike"),
|
|
206
181
|
onClick: () => r.chain().focus().toggleStrike().run(),
|
|
207
|
-
children: /* @__PURE__ */ e(
|
|
182
|
+
children: /* @__PURE__ */ e(ae, { className: "h-3.5 w-3.5" })
|
|
208
183
|
}
|
|
209
184
|
),
|
|
210
185
|
/* @__PURE__ */ e(H, {}),
|
|
211
186
|
/* @__PURE__ */ e(
|
|
212
|
-
|
|
187
|
+
s,
|
|
213
188
|
{
|
|
214
189
|
title: "Heading 1",
|
|
215
190
|
active: r.isActive("heading", { level: 1 }),
|
|
216
191
|
onClick: () => r.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
217
|
-
children: /* @__PURE__ */ e(
|
|
192
|
+
children: /* @__PURE__ */ e(le, { className: "h-3.5 w-3.5" })
|
|
218
193
|
}
|
|
219
194
|
),
|
|
220
195
|
/* @__PURE__ */ e(
|
|
221
|
-
|
|
196
|
+
s,
|
|
222
197
|
{
|
|
223
198
|
title: "Heading 2",
|
|
224
199
|
active: r.isActive("heading", { level: 2 }),
|
|
225
200
|
onClick: () => r.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
226
|
-
children: /* @__PURE__ */ e(
|
|
201
|
+
children: /* @__PURE__ */ e(se, { className: "h-3.5 w-3.5" })
|
|
227
202
|
}
|
|
228
203
|
),
|
|
229
204
|
/* @__PURE__ */ e(
|
|
230
|
-
|
|
205
|
+
s,
|
|
231
206
|
{
|
|
232
207
|
title: "Heading 3",
|
|
233
208
|
active: r.isActive("heading", { level: 3 }),
|
|
234
209
|
onClick: () => r.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
235
|
-
children: /* @__PURE__ */ e(
|
|
210
|
+
children: /* @__PURE__ */ e(ce, { className: "h-3.5 w-3.5" })
|
|
236
211
|
}
|
|
237
212
|
),
|
|
238
213
|
/* @__PURE__ */ e(H, {}),
|
|
239
214
|
/* @__PURE__ */ e(
|
|
240
|
-
|
|
215
|
+
s,
|
|
241
216
|
{
|
|
242
217
|
title: "Bullet list",
|
|
243
218
|
active: r.isActive("bulletList"),
|
|
244
219
|
onClick: () => r.chain().focus().toggleBulletList().run(),
|
|
245
|
-
children: /* @__PURE__ */ e(
|
|
220
|
+
children: /* @__PURE__ */ e(de, { className: "h-3.5 w-3.5" })
|
|
246
221
|
}
|
|
247
222
|
),
|
|
248
223
|
/* @__PURE__ */ e(
|
|
249
|
-
|
|
224
|
+
s,
|
|
250
225
|
{
|
|
251
226
|
title: "Ordered list",
|
|
252
227
|
active: r.isActive("orderedList"),
|
|
253
228
|
onClick: () => r.chain().focus().toggleOrderedList().run(),
|
|
254
|
-
children: /* @__PURE__ */ e(
|
|
229
|
+
children: /* @__PURE__ */ e(pe, { className: "h-3.5 w-3.5" })
|
|
255
230
|
}
|
|
256
231
|
),
|
|
257
232
|
/* @__PURE__ */ e(H, {}),
|
|
258
233
|
/* @__PURE__ */ e(
|
|
259
|
-
|
|
234
|
+
s,
|
|
260
235
|
{
|
|
261
236
|
title: "Blockquote",
|
|
262
237
|
active: r.isActive("blockquote"),
|
|
263
238
|
onClick: () => r.chain().focus().toggleBlockquote().run(),
|
|
264
|
-
children: /* @__PURE__ */ e(
|
|
239
|
+
children: /* @__PURE__ */ e(ue, { className: "h-3.5 w-3.5" })
|
|
265
240
|
}
|
|
266
241
|
),
|
|
267
242
|
/* @__PURE__ */ e(
|
|
268
|
-
|
|
243
|
+
s,
|
|
269
244
|
{
|
|
270
245
|
title: "Code block",
|
|
271
246
|
active: r.isActive("codeBlock"),
|
|
272
247
|
onClick: () => r.chain().focus().toggleCodeBlock().run(),
|
|
273
|
-
children: /* @__PURE__ */ e(
|
|
248
|
+
children: /* @__PURE__ */ e(he, { className: "h-3.5 w-3.5" })
|
|
274
249
|
}
|
|
275
250
|
),
|
|
276
251
|
/* @__PURE__ */ e(
|
|
277
|
-
|
|
252
|
+
s,
|
|
278
253
|
{
|
|
279
254
|
title: "Horizontal rule",
|
|
280
255
|
onClick: () => r.chain().focus().setHorizontalRule().run(),
|
|
281
|
-
children: /* @__PURE__ */ e(
|
|
256
|
+
children: /* @__PURE__ */ e(fe, { className: "h-3.5 w-3.5" })
|
|
282
257
|
}
|
|
283
258
|
),
|
|
284
259
|
/* @__PURE__ */ e(H, {}),
|
|
285
260
|
/* @__PURE__ */ e(
|
|
286
|
-
|
|
261
|
+
s,
|
|
287
262
|
{
|
|
288
263
|
title: "Link",
|
|
289
264
|
active: r.isActive("link"),
|
|
290
|
-
onClick:
|
|
291
|
-
children: /* @__PURE__ */ e(
|
|
265
|
+
onClick: V,
|
|
266
|
+
children: /* @__PURE__ */ e(me, { className: "h-3.5 w-3.5" })
|
|
292
267
|
}
|
|
293
268
|
),
|
|
294
269
|
r.isActive("link") && /* @__PURE__ */ e(
|
|
295
|
-
|
|
270
|
+
s,
|
|
296
271
|
{
|
|
297
272
|
title: "Remove link",
|
|
298
273
|
onClick: () => r.chain().focus().unsetLink().run(),
|
|
299
|
-
children: /* @__PURE__ */ e(
|
|
274
|
+
children: /* @__PURE__ */ e(ge, { className: "h-3.5 w-3.5" })
|
|
300
275
|
}
|
|
301
276
|
),
|
|
302
277
|
/* @__PURE__ */ e(
|
|
303
|
-
|
|
278
|
+
s,
|
|
304
279
|
{
|
|
305
280
|
title: "Link record",
|
|
306
281
|
active: D,
|
|
307
282
|
onClick: () => {
|
|
308
283
|
y((i) => !i), x(!1);
|
|
309
284
|
},
|
|
310
|
-
children: /* @__PURE__ */ e(
|
|
285
|
+
children: /* @__PURE__ */ e(W, { className: "h-3.5 w-3.5" })
|
|
311
286
|
}
|
|
312
287
|
)
|
|
313
288
|
] }),
|
|
314
|
-
|
|
289
|
+
E && /* @__PURE__ */ g("div", { className: "flex items-center gap-1.5 border-b border-slate-200 bg-slate-50 px-2 py-1.5 dark:border-border dark:bg-muted", children: [
|
|
315
290
|
/* @__PURE__ */ e(
|
|
316
291
|
"input",
|
|
317
292
|
{
|
|
318
293
|
ref: v,
|
|
319
294
|
type: "url",
|
|
320
|
-
value:
|
|
295
|
+
value: N,
|
|
321
296
|
onChange: (i) => b(i.target.value),
|
|
322
297
|
onKeyDown: (i) => {
|
|
323
|
-
i.key === "Enter" && (i.preventDefault(),
|
|
298
|
+
i.key === "Enter" && (i.preventDefault(), I()), i.key === "Escape" && (i.preventDefault(), $());
|
|
324
299
|
},
|
|
325
300
|
placeholder: "https://example.com",
|
|
326
301
|
"aria-label": "Link URL",
|
|
@@ -333,10 +308,10 @@ function et({
|
|
|
333
308
|
type: "button",
|
|
334
309
|
title: "Apply link",
|
|
335
310
|
onMouseDown: (i) => {
|
|
336
|
-
i.preventDefault(),
|
|
311
|
+
i.preventDefault(), I();
|
|
337
312
|
},
|
|
338
313
|
className: "flex h-5 w-5 items-center justify-center rounded text-emerald-600 hover:bg-emerald-50",
|
|
339
|
-
children: /* @__PURE__ */ e(
|
|
314
|
+
children: /* @__PURE__ */ e(be, { className: "h-3.5 w-3.5" })
|
|
340
315
|
}
|
|
341
316
|
),
|
|
342
317
|
/* @__PURE__ */ e(
|
|
@@ -345,15 +320,15 @@ function et({
|
|
|
345
320
|
type: "button",
|
|
346
321
|
title: "Cancel",
|
|
347
322
|
onMouseDown: (i) => {
|
|
348
|
-
i.preventDefault(),
|
|
323
|
+
i.preventDefault(), $();
|
|
349
324
|
},
|
|
350
325
|
className: "flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100 dark:hover:bg-[#334155]",
|
|
351
|
-
children: /* @__PURE__ */ e(
|
|
326
|
+
children: /* @__PURE__ */ e(K, { className: "h-3.5 w-3.5" })
|
|
352
327
|
}
|
|
353
328
|
)
|
|
354
329
|
] }),
|
|
355
330
|
D && /* @__PURE__ */ e(
|
|
356
|
-
|
|
331
|
+
Me,
|
|
357
332
|
{
|
|
358
333
|
apiBase: _.apiBase,
|
|
359
334
|
authHeaders: _.authHeaders,
|
|
@@ -377,98 +352,98 @@ function et({
|
|
|
377
352
|
}
|
|
378
353
|
.nivaro-rich-text a[href^="record://"]::before { content: '↗ '; opacity: 0.55; }
|
|
379
354
|
.nivaro-rich-text .tiptap ::selection { background: rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.26); }
|
|
380
|
-
${
|
|
355
|
+
${Ce}
|
|
381
356
|
.nivaro-rich-text .tiptap > :first-child .nvr-coedit-flag {
|
|
382
357
|
bottom: auto; top: 100%; margin: 1px 0 0; border-radius: 0 3px 3px 3px;
|
|
383
358
|
}
|
|
384
359
|
` }),
|
|
385
360
|
/* @__PURE__ */ e(
|
|
386
|
-
|
|
361
|
+
te,
|
|
387
362
|
{
|
|
388
363
|
onClick: (i) => {
|
|
389
|
-
var h,
|
|
390
|
-
const o = (
|
|
364
|
+
var h, C;
|
|
365
|
+
const o = (C = (h = i.target).closest) == null ? void 0 : C.call(h, "a"), m = (o == null ? void 0 : o.getAttribute("href")) ?? "";
|
|
391
366
|
if (m.startsWith("record://")) {
|
|
392
367
|
i.preventDefault();
|
|
393
|
-
const [
|
|
394
|
-
|
|
368
|
+
const [q, B] = m.slice(9).split("/");
|
|
369
|
+
q && B && k.open({ collection: q, itemId: B });
|
|
395
370
|
}
|
|
396
371
|
},
|
|
397
372
|
editor: r,
|
|
398
373
|
className: "nivaro-rich-text min-h-[120px] px-3 py-2 text-[13px] [&_.tiptap]:outline-none [&_.tiptap]:min-h-[100px] [&_.tiptap_p]:my-1 [&_.tiptap_h1]:text-xl [&_.tiptap_h2]:text-lg [&_.tiptap_h3]:text-base [&_.tiptap_h1,&_.tiptap_h2,&_.tiptap_h3]:font-semibold [&_.tiptap_ul]:list-disc [&_.tiptap_ol]:list-decimal [&_.tiptap_ul]:!pl-6 [&_.tiptap_ol]:!pl-6 [&_.tiptap_ul]:list-outside [&_.tiptap_ol]:list-outside [&_.tiptap_li]:my-0.5 [&_.tiptap_blockquote]:border-l-2 [&_.tiptap_blockquote]:border-slate-300 [&_.tiptap_blockquote]:pl-3 [&_.tiptap_blockquote]:text-slate-500 dark:[&_.tiptap_blockquote]:border-slate-600 dark:[&_.tiptap_blockquote]:text-slate-400 [&_.tiptap_code]:bg-slate-100 dark:[&_.tiptap_code]:bg-[#1e293b] [&_.tiptap_code]:rounded [&_.tiptap_code]:px-1 [&_.tiptap_pre]:bg-slate-100 dark:[&_.tiptap_pre]:bg-[#1e293b] [&_.tiptap_pre]:rounded [&_.tiptap_pre]:p-2 [&_.tiptap_pre]:font-mono [&_.tiptap_p.is-editor-empty:first-child::before]:content-[attr(data-placeholder)] [&_.tiptap_p.is-editor-empty:first-child::before]:text-slate-400 dark:[&_.tiptap_p.is-editor-empty:first-child::before]:text-slate-500 [&_.tiptap_p.is-editor-empty:first-child::before]:pointer-events-none [&_.tiptap_p.is-editor-empty:first-child::before]:float-left [&_.tiptap_p.is-editor-empty:first-child::before]:h-0"
|
|
399
374
|
}
|
|
400
375
|
),
|
|
401
|
-
/* @__PURE__ */ e(Ee, { peers:
|
|
376
|
+
/* @__PURE__ */ e(Ee, { peers: Q, diverged: f.diverged })
|
|
402
377
|
]
|
|
403
378
|
}
|
|
404
379
|
);
|
|
405
380
|
}
|
|
406
|
-
const
|
|
407
|
-
function
|
|
381
|
+
const F = (t) => t.trim().split(/\s+/)[0] || t;
|
|
382
|
+
function P(t) {
|
|
408
383
|
return t.length <= 1 ? t[0] ?? "" : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t[0]}, ${t[1]} and ${t.length - 2} more`;
|
|
409
384
|
}
|
|
410
385
|
function Ee({
|
|
411
386
|
peers: t,
|
|
412
|
-
diverged:
|
|
387
|
+
diverged: c
|
|
413
388
|
}) {
|
|
414
|
-
return !
|
|
389
|
+
return !c && t.length === 0 ? null : /* @__PURE__ */ g(
|
|
415
390
|
"div",
|
|
416
391
|
{
|
|
417
392
|
className: "flex min-h-[26px] items-center gap-1.5 border-t border-slate-100 px-3 py-1 text-[11px] text-slate-500 dark:border-border dark:text-slate-400",
|
|
418
393
|
"aria-live": "polite",
|
|
419
394
|
children: [
|
|
420
|
-
/* @__PURE__ */ e("span", { className: "flex -space-x-0.5", "aria-hidden": "true", children: (t.length ? t : [{ name: "", color: "#94a3b8" }]).slice(0, 4).map((
|
|
395
|
+
/* @__PURE__ */ e("span", { className: "flex -space-x-0.5", "aria-hidden": "true", children: (t.length ? t : [{ name: "", color: "#94a3b8" }]).slice(0, 4).map((l) => /* @__PURE__ */ e(
|
|
421
396
|
"span",
|
|
422
397
|
{
|
|
423
398
|
className: "h-2 w-2 rounded-full ring-2 ring-background",
|
|
424
|
-
style: { backgroundColor:
|
|
399
|
+
style: { backgroundColor: l.color }
|
|
425
400
|
},
|
|
426
|
-
|
|
401
|
+
l.name || "someone"
|
|
427
402
|
)) }),
|
|
428
|
-
|
|
429
|
-
t.length ?
|
|
403
|
+
c ? /* @__PURE__ */ g("span", { className: "min-w-0", children: [
|
|
404
|
+
t.length ? P(t.map((l) => F(l.name))) : "Someone else",
|
|
430
405
|
" ",
|
|
431
406
|
t.length > 1 ? "are" : "is",
|
|
432
407
|
" writing here too. Your unsaved changes stay separate until you save."
|
|
433
408
|
] }) : /* @__PURE__ */ g("span", { className: "truncate", children: [
|
|
434
409
|
"Writing together with ",
|
|
435
|
-
|
|
410
|
+
P(t.map((l) => F(l.name)))
|
|
436
411
|
] })
|
|
437
412
|
]
|
|
438
413
|
}
|
|
439
414
|
);
|
|
440
415
|
}
|
|
441
|
-
function
|
|
442
|
-
return t ? t.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (
|
|
443
|
-
if (
|
|
444
|
-
const
|
|
445
|
-
return
|
|
416
|
+
function Re(t, c) {
|
|
417
|
+
return t ? t.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (l, p) => {
|
|
418
|
+
if (p.includes(".")) return "";
|
|
419
|
+
const d = c[p];
|
|
420
|
+
return d == null ? "" : String(d);
|
|
446
421
|
}).replace(/\s+/g, " ").trim() : "";
|
|
447
422
|
}
|
|
448
|
-
function
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
for (const
|
|
452
|
-
const
|
|
453
|
-
if (typeof
|
|
423
|
+
function Te(t, c) {
|
|
424
|
+
const l = Re(c, t);
|
|
425
|
+
if (l) return l;
|
|
426
|
+
for (const p of ["name", "title", "label", "subject"]) {
|
|
427
|
+
const d = t[p];
|
|
428
|
+
if (typeof d == "string" && d.trim()) return d.trim();
|
|
454
429
|
}
|
|
455
430
|
return `#${String(t.id ?? "")}`;
|
|
456
431
|
}
|
|
457
|
-
function
|
|
432
|
+
function Me({
|
|
458
433
|
apiBase: t,
|
|
459
|
-
authHeaders:
|
|
460
|
-
credentials:
|
|
461
|
-
onInsert:
|
|
462
|
-
onClose:
|
|
434
|
+
authHeaders: c,
|
|
435
|
+
credentials: l,
|
|
436
|
+
onInsert: p,
|
|
437
|
+
onClose: d
|
|
463
438
|
}) {
|
|
464
|
-
const [
|
|
465
|
-
|
|
439
|
+
const [a, E] = w(""), [x, N] = w(""), [b, D] = w("");
|
|
440
|
+
T(() => {
|
|
466
441
|
const n = setTimeout(() => D(x), 300);
|
|
467
442
|
return () => clearTimeout(n);
|
|
468
443
|
}, [x]);
|
|
469
444
|
const y = (n) => fetch(`${t}${n}`, {
|
|
470
|
-
headers:
|
|
471
|
-
credentials:
|
|
445
|
+
headers: c,
|
|
446
|
+
credentials: l
|
|
472
447
|
}).then((u) => {
|
|
473
448
|
if (!u.ok) throw new Error(String(u.status));
|
|
474
449
|
return u.json();
|
|
@@ -480,11 +455,11 @@ function qe({
|
|
|
480
455
|
)
|
|
481
456
|
),
|
|
482
457
|
staleTime: 5 * 6e4
|
|
483
|
-
}), _ = v == null ? void 0 : v.find((n) => n.collection ===
|
|
484
|
-
queryKey: ["rte-record-link-search",
|
|
485
|
-
enabled: !!
|
|
458
|
+
}), _ = v == null ? void 0 : v.find((n) => n.collection === a), { data: k, isFetching: A } = U({
|
|
459
|
+
queryKey: ["rte-record-link-search", a, b],
|
|
460
|
+
enabled: !!a && b.trim().length > 0,
|
|
486
461
|
queryFn: () => y(
|
|
487
|
-
`/items/${
|
|
462
|
+
`/items/${a}?limit=10&search=${encodeURIComponent(b.trim())}`
|
|
488
463
|
).then(
|
|
489
464
|
(n) => Array.isArray(n == null ? void 0 : n.data) ? n.data : []
|
|
490
465
|
)
|
|
@@ -492,10 +467,10 @@ function qe({
|
|
|
492
467
|
return /* @__PURE__ */ g("div", { className: "space-y-1.5 border-b border-slate-200 bg-slate-50 px-2 py-1.5 dark:border-border dark:bg-muted", children: [
|
|
493
468
|
/* @__PURE__ */ g("div", { className: "flex items-center gap-1.5", children: [
|
|
494
469
|
/* @__PURE__ */ e(
|
|
495
|
-
|
|
470
|
+
ye,
|
|
496
471
|
{
|
|
497
|
-
value:
|
|
498
|
-
onChange:
|
|
472
|
+
value: a,
|
|
473
|
+
onChange: E,
|
|
499
474
|
ariaLabel: "Collection",
|
|
500
475
|
className: "h-6 w-44 rounded border-slate-200 bg-white text-[12px] dark:border-border dark:bg-background",
|
|
501
476
|
options: [
|
|
@@ -511,41 +486,41 @@ function qe({
|
|
|
511
486
|
"input",
|
|
512
487
|
{
|
|
513
488
|
value: x,
|
|
514
|
-
onChange: (n) =>
|
|
515
|
-
onKeyDown: (n) => n.key === "Escape" &&
|
|
516
|
-
placeholder:
|
|
517
|
-
disabled: !
|
|
489
|
+
onChange: (n) => N(n.target.value),
|
|
490
|
+
onKeyDown: (n) => n.key === "Escape" && d(),
|
|
491
|
+
placeholder: a ? "Search records…" : "Pick a collection first",
|
|
492
|
+
disabled: !a,
|
|
518
493
|
"aria-label": "Search records",
|
|
519
494
|
className: "flex-1 rounded border border-slate-200 bg-white px-2 py-0.5 text-[12px] text-slate-700 outline-none focus:border-nvr-cyan disabled:opacity-50"
|
|
520
495
|
}
|
|
521
496
|
),
|
|
522
|
-
A && /* @__PURE__ */ e(
|
|
497
|
+
A && /* @__PURE__ */ e(ke, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }),
|
|
523
498
|
/* @__PURE__ */ e(
|
|
524
499
|
"button",
|
|
525
500
|
{
|
|
526
501
|
type: "button",
|
|
527
502
|
title: "Close",
|
|
528
503
|
onMouseDown: (n) => {
|
|
529
|
-
n.preventDefault(),
|
|
504
|
+
n.preventDefault(), d();
|
|
530
505
|
},
|
|
531
506
|
className: "flex h-5 w-5 items-center justify-center rounded text-slate-400 hover:bg-slate-100",
|
|
532
|
-
children: /* @__PURE__ */ e(
|
|
507
|
+
children: /* @__PURE__ */ e(K, { className: "h-3.5 w-3.5" })
|
|
533
508
|
}
|
|
534
509
|
)
|
|
535
510
|
] }),
|
|
536
|
-
|
|
511
|
+
a && b.trim() && ((k == null ? void 0 : k.length) ?? 0) === 0 && !A && /* @__PURE__ */ e("p", { className: "px-1 text-[11px] text-slate-400", children: "No matching records." }),
|
|
537
512
|
((k == null ? void 0 : k.length) ?? 0) > 0 && /* @__PURE__ */ e("div", { className: "max-h-40 overflow-y-auto rounded border border-slate-200 bg-white", children: (k ?? []).map((n) => {
|
|
538
|
-
const u =
|
|
513
|
+
const u = Te(n, _ == null ? void 0 : _.display_template), r = String(n.id ?? "");
|
|
539
514
|
return /* @__PURE__ */ g(
|
|
540
515
|
"button",
|
|
541
516
|
{
|
|
542
517
|
type: "button",
|
|
543
518
|
onMouseDown: (f) => {
|
|
544
|
-
f.preventDefault(), r &&
|
|
519
|
+
f.preventDefault(), r && p(u, `record://${a}/${r}`);
|
|
545
520
|
},
|
|
546
521
|
className: "flex w-full items-center gap-1.5 px-2 py-1 text-left text-[12px] text-slate-700 hover:bg-muted",
|
|
547
522
|
children: [
|
|
548
|
-
/* @__PURE__ */ e(
|
|
523
|
+
/* @__PURE__ */ e(W, { className: "h-3 w-3 shrink-0 text-[#00a5cc]" }),
|
|
549
524
|
/* @__PURE__ */ e("span", { className: "min-w-0 flex-1 truncate", children: u }),
|
|
550
525
|
/* @__PURE__ */ g("span", { className: "shrink-0 font-mono text-[10.5px] text-slate-400", children: [
|
|
551
526
|
"#",
|
|
@@ -561,6 +536,6 @@ function qe({
|
|
|
561
536
|
export {
|
|
562
537
|
et as RichTextEditor,
|
|
563
538
|
H as TiptapDivider,
|
|
564
|
-
|
|
565
|
-
|
|
539
|
+
s as TiptapToolbarButton,
|
|
540
|
+
Se as editorJsToHtml
|
|
566
541
|
};
|