@parallelworks/tandem-web 0.151.0 → 0.152.1
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/_virtual/_virtual_i18n/en/common.js +6 -17
- package/_virtual/_virtual_i18n/es/common.js +6 -17
- package/_virtual/_virtual_i18n/ja/common.js +6 -17
- package/_virtual/_virtual_i18n/ko/common.js +6 -17
- package/_virtual/_virtual_i18n/zh/common.js +6 -17
- package/api/queries.js +42 -91
- package/components/ShareDialog.js +71 -125
- package/components/SharedViewer.js +82 -155
- package/package.json +1 -1
- package/routeTree.gen.js +186 -192
- package/routes/_workspace/settings/import2.js +31 -19
- package/routes/sites._workspace._site.js +0 -6
- package/routes/sites2._workspace._site.js +0 -15
|
@@ -1,57 +1,50 @@
|
|
|
1
1
|
import { ApiError as e } from "../api/client.js";
|
|
2
2
|
import { Link as t, useNavigate as n } from "../lib/router.js";
|
|
3
|
-
import { sharedDocQuery as r, sharedQuery as i
|
|
4
|
-
import { docKey as
|
|
5
|
-
import { DocIcon as
|
|
6
|
-
import { Editor as
|
|
7
|
-
import { Logo as
|
|
8
|
-
import { DocOutline as
|
|
9
|
-
import { Disclosure as
|
|
10
|
-
import { useEffect as
|
|
11
|
-
import { useTranslations as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import {
|
|
3
|
+
import { sharedDocQuery as r, sharedQuery as i } from "../api/queries.js";
|
|
4
|
+
import { docKey as a } from "../lib/docs.js";
|
|
5
|
+
import { DocIcon as o } from "./DocIcon.js";
|
|
6
|
+
import { Editor as s } from "./Editor.js";
|
|
7
|
+
import { Logo as c } from "./Logo.js";
|
|
8
|
+
import { DocOutline as l } from "./DocOutline.js";
|
|
9
|
+
import { Disclosure as u, buttonClasses as d, cx as f } from "@parallelworks/ui";
|
|
10
|
+
import { useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
11
|
+
import { useTranslations as _ } from "use-intl";
|
|
12
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
13
|
+
import { useQuery as b } from "@tanstack/react-query";
|
|
14
14
|
// src/components/SharedViewer.tsx
|
|
15
|
-
function
|
|
16
|
-
let w =
|
|
17
|
-
...
|
|
18
|
-
enabled: !!
|
|
19
|
-
}),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, [
|
|
23
|
-
let
|
|
15
|
+
function x({ source: x, doc: S }) {
|
|
16
|
+
let w = _("shared"), T = n(), E = b(i(x.secret)), D = E.data?.docs ?? [], O = S ?? E.data?.root ?? D[0]?.key, k = b({
|
|
17
|
+
...r(x.secret, O ?? ""),
|
|
18
|
+
enabled: !!O
|
|
19
|
+
}), A = m(() => new Set(D.map((e) => e.key)), [D]), [j, M] = g(null), N = h(null);
|
|
20
|
+
p(() => {
|
|
21
|
+
O && N.current?.scrollTo({ top: 0 });
|
|
22
|
+
}, [O]);
|
|
23
|
+
let P = (e) => T({
|
|
24
24
|
to: "/share/$secret",
|
|
25
|
-
params: { secret:
|
|
26
|
-
search: { doc: e }
|
|
27
|
-
}) : E({
|
|
28
|
-
to: "/sites/$workspace/$site",
|
|
29
|
-
params: {
|
|
30
|
-
workspace: s.workspace,
|
|
31
|
-
site: s.site
|
|
32
|
-
},
|
|
25
|
+
params: { secret: x.secret },
|
|
33
26
|
search: { doc: e }
|
|
34
27
|
});
|
|
35
|
-
if (
|
|
36
|
-
let n =
|
|
37
|
-
return /* @__PURE__ */
|
|
28
|
+
if (E.error) {
|
|
29
|
+
let n = E.error instanceof e && E.error.status === 401;
|
|
30
|
+
return /* @__PURE__ */ v("main", {
|
|
38
31
|
className: "flex min-h-screen items-center justify-center px-4",
|
|
39
|
-
children: /* @__PURE__ */
|
|
32
|
+
children: /* @__PURE__ */ y("div", {
|
|
40
33
|
className: "w-full max-w-sm",
|
|
41
34
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
35
|
+
/* @__PURE__ */ v(c, { className: "mb-10" }),
|
|
36
|
+
/* @__PURE__ */ v("h1", {
|
|
44
37
|
className: "text-2xl font-semibold tracking-tight",
|
|
45
|
-
children: w(n ? "signInTitle" : "
|
|
38
|
+
children: w(n ? "signInTitle" : "goneTitle")
|
|
46
39
|
}),
|
|
47
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ v("p", {
|
|
48
41
|
className: "mt-1 text-sm text-muted-foreground",
|
|
49
|
-
children: w(n ? "signInDetail" : "
|
|
42
|
+
children: w(n ? "signInDetail" : "goneDetail")
|
|
50
43
|
}),
|
|
51
|
-
n && /* @__PURE__ */
|
|
44
|
+
n && /* @__PURE__ */ v(t, {
|
|
52
45
|
to: "/login",
|
|
53
46
|
search: { next: window.location.href },
|
|
54
|
-
className:
|
|
47
|
+
className: f(d({
|
|
55
48
|
variant: "primary",
|
|
56
49
|
size: "lg"
|
|
57
50
|
}), "mt-6"),
|
|
@@ -61,88 +54,82 @@ function E({ source: s, doc: m }) {
|
|
|
61
54
|
})
|
|
62
55
|
});
|
|
63
56
|
}
|
|
64
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ y("div", {
|
|
65
58
|
className: "flex h-screen flex-col",
|
|
66
59
|
children: [
|
|
67
|
-
/* @__PURE__ */
|
|
60
|
+
/* @__PURE__ */ y("header", {
|
|
68
61
|
className: "flex h-12 shrink-0 items-center gap-3 border-b border-border px-4 md:px-5",
|
|
69
62
|
children: [
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ v(c, { className: "h-5 max-sm:hidden" }),
|
|
64
|
+
/* @__PURE__ */ v("span", {
|
|
72
65
|
className: "truncate text-sm font-semibold",
|
|
73
|
-
children:
|
|
66
|
+
children: E.data?.title
|
|
74
67
|
}),
|
|
75
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ v("span", {
|
|
76
69
|
className: "truncate text-xs text-muted-foreground max-sm:hidden",
|
|
77
|
-
children:
|
|
70
|
+
children: E.data && E.data.title !== E.data.workspace && w("from", { workspace: E.data.workspace })
|
|
78
71
|
}),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
className: "ml-auto
|
|
81
|
-
children:
|
|
82
|
-
source: s,
|
|
83
|
-
onOpen: L
|
|
84
|
-
}), /* @__PURE__ */ S("span", {
|
|
85
|
-
className: "rounded border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",
|
|
86
|
-
children: w("readOnly")
|
|
87
|
-
})]
|
|
72
|
+
/* @__PURE__ */ v("span", {
|
|
73
|
+
className: "ml-auto shrink-0 rounded border border-border px-1.5 py-0.5 text-[11px] text-muted-foreground",
|
|
74
|
+
children: w("readOnly")
|
|
88
75
|
})
|
|
89
76
|
]
|
|
90
77
|
}),
|
|
91
|
-
|
|
78
|
+
D.length > 1 && /* @__PURE__ */ v(u, {
|
|
92
79
|
className: "shrink-0 border-b border-border px-2 py-1 md:hidden",
|
|
93
80
|
summaryClassName: "px-2 py-1 text-sm text-muted-foreground",
|
|
94
81
|
summary: w("docs"),
|
|
95
|
-
children: /* @__PURE__ */
|
|
96
|
-
docs:
|
|
82
|
+
children: /* @__PURE__ */ v(C, {
|
|
83
|
+
docs: D,
|
|
97
84
|
parent: "",
|
|
98
85
|
depth: 0,
|
|
99
|
-
current:
|
|
100
|
-
source:
|
|
86
|
+
current: O,
|
|
87
|
+
source: x
|
|
101
88
|
})
|
|
102
89
|
}),
|
|
103
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ y("div", {
|
|
104
91
|
className: "flex min-h-0 flex-1",
|
|
105
|
-
children: [
|
|
92
|
+
children: [D.length > 1 && /* @__PURE__ */ v("nav", {
|
|
106
93
|
"aria-label": w("docs"),
|
|
107
94
|
className: "w-64 shrink-0 overflow-y-auto border-r border-border p-2 max-md:hidden",
|
|
108
|
-
children: /* @__PURE__ */
|
|
109
|
-
docs:
|
|
95
|
+
children: /* @__PURE__ */ v(C, {
|
|
96
|
+
docs: D,
|
|
110
97
|
parent: "",
|
|
111
98
|
depth: 0,
|
|
112
|
-
current:
|
|
113
|
-
source:
|
|
99
|
+
current: O,
|
|
100
|
+
source: x
|
|
114
101
|
})
|
|
115
|
-
}), /* @__PURE__ */
|
|
116
|
-
ref:
|
|
102
|
+
}), /* @__PURE__ */ v("main", {
|
|
103
|
+
ref: N,
|
|
117
104
|
className: "min-w-0 flex-1 overflow-y-auto",
|
|
118
|
-
children: /* @__PURE__ */
|
|
105
|
+
children: /* @__PURE__ */ y("div", {
|
|
119
106
|
className: "flex w-full gap-10 px-4 py-6 md:px-8",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
107
|
+
children: [/* @__PURE__ */ y("article", {
|
|
121
108
|
onClickCapture: (e) => {
|
|
122
|
-
let t = e.target.closest("a")?.getAttribute("href") ?? "", n = /\/docs\/([A-Za-z0-9-]+)/.exec(t)?.[1], r = n &&
|
|
123
|
-
r &&
|
|
109
|
+
let t = e.target.closest("a")?.getAttribute("href") ?? "", n = /\/docs\/([A-Za-z0-9-]+)/.exec(t)?.[1], r = n && a(n);
|
|
110
|
+
r && A.has(r) && (e.preventDefault(), P(r));
|
|
124
111
|
},
|
|
125
112
|
className: "mx-auto min-w-0 max-w-3xl flex-1 pb-24",
|
|
126
113
|
children: [
|
|
127
|
-
|
|
128
|
-
icon:
|
|
114
|
+
k.data?.icon && /* @__PURE__ */ v(o, {
|
|
115
|
+
icon: k.data.icon,
|
|
129
116
|
className: "mb-2 size-12",
|
|
130
117
|
emojiClassName: "text-4xl"
|
|
131
118
|
}),
|
|
132
|
-
/* @__PURE__ */
|
|
119
|
+
/* @__PURE__ */ v("h1", {
|
|
133
120
|
className: "text-2xl font-semibold tracking-tight",
|
|
134
|
-
children:
|
|
121
|
+
children: k.data?.title
|
|
135
122
|
}),
|
|
136
|
-
|
|
137
|
-
value:
|
|
123
|
+
k.data && /* @__PURE__ */ v(s, {
|
|
124
|
+
value: k.data.body ?? "",
|
|
138
125
|
editable: !1,
|
|
139
|
-
onEditor:
|
|
126
|
+
onEditor: M,
|
|
140
127
|
className: "mt-4"
|
|
141
|
-
},
|
|
128
|
+
}, k.data.key)
|
|
142
129
|
]
|
|
143
|
-
}), /* @__PURE__ */
|
|
144
|
-
editor:
|
|
145
|
-
scroller:
|
|
130
|
+
}), /* @__PURE__ */ v(l, {
|
|
131
|
+
editor: j,
|
|
132
|
+
scroller: N
|
|
146
133
|
})]
|
|
147
134
|
})
|
|
148
135
|
})]
|
|
@@ -150,48 +137,38 @@ function E({ source: s, doc: m }) {
|
|
|
150
137
|
]
|
|
151
138
|
});
|
|
152
139
|
}
|
|
153
|
-
function
|
|
154
|
-
let a = r ? "page" : void 0
|
|
155
|
-
return
|
|
140
|
+
function S({ source: e, doc: n, current: r, children: i }) {
|
|
141
|
+
let a = r ? "page" : void 0;
|
|
142
|
+
return /* @__PURE__ */ v(t, {
|
|
156
143
|
to: "/share/$secret",
|
|
157
144
|
params: { secret: e.secret },
|
|
158
145
|
search: { doc: n },
|
|
159
146
|
"aria-current": a,
|
|
160
|
-
className:
|
|
161
|
-
children: i
|
|
162
|
-
}) : /* @__PURE__ */ S(t, {
|
|
163
|
-
to: "/sites/$workspace/$site",
|
|
164
|
-
params: {
|
|
165
|
-
workspace: e.workspace,
|
|
166
|
-
site: e.site
|
|
167
|
-
},
|
|
168
|
-
search: { doc: n },
|
|
169
|
-
"aria-current": a,
|
|
170
|
-
className: o,
|
|
147
|
+
className: "flex items-center gap-2 rounded-md py-1 pr-2 text-sm text-muted-foreground hover:bg-muted hover:text-foreground aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground",
|
|
171
148
|
children: i
|
|
172
149
|
});
|
|
173
150
|
}
|
|
174
|
-
function
|
|
151
|
+
function C({ docs: e, parent: t, depth: n, current: r, source: i }) {
|
|
175
152
|
let a = e.filter((e) => (e.parent ?? "") === t);
|
|
176
|
-
return a.length === 0 ? null : /* @__PURE__ */
|
|
153
|
+
return a.length === 0 ? null : /* @__PURE__ */ v("ul", {
|
|
177
154
|
className: "space-y-px",
|
|
178
|
-
children: a.map((t) => /* @__PURE__ */
|
|
155
|
+
children: a.map((t) => /* @__PURE__ */ y("li", { children: [/* @__PURE__ */ v(S, {
|
|
179
156
|
source: i,
|
|
180
157
|
doc: t.key,
|
|
181
158
|
current: t.key === r,
|
|
182
|
-
children: /* @__PURE__ */
|
|
159
|
+
children: /* @__PURE__ */ y("span", {
|
|
183
160
|
style: { paddingLeft: `${.5 + n * .75}rem` },
|
|
184
161
|
className: "flex min-w-0 items-center gap-2",
|
|
185
|
-
children: [/* @__PURE__ */
|
|
162
|
+
children: [/* @__PURE__ */ v(o, {
|
|
186
163
|
icon: t.icon,
|
|
187
164
|
className: "size-3.5",
|
|
188
165
|
emojiClassName: "text-xs"
|
|
189
|
-
}), /* @__PURE__ */
|
|
166
|
+
}), /* @__PURE__ */ v("span", {
|
|
190
167
|
className: "truncate",
|
|
191
168
|
children: t.title
|
|
192
169
|
})]
|
|
193
170
|
})
|
|
194
|
-
}), /* @__PURE__ */
|
|
171
|
+
}), /* @__PURE__ */ v(C, {
|
|
195
172
|
docs: e,
|
|
196
173
|
parent: t.key,
|
|
197
174
|
depth: n + 1,
|
|
@@ -200,54 +177,4 @@ function O({ docs: e, parent: t, depth: n, current: r, source: i }) {
|
|
|
200
177
|
})] }, t.key))
|
|
201
178
|
});
|
|
202
179
|
}
|
|
203
|
-
|
|
204
|
-
let n = x("shared"), [r, i] = b(""), [a, o] = b("");
|
|
205
|
-
_(() => {
|
|
206
|
-
let e = setTimeout(() => o(r.trim()), 200);
|
|
207
|
-
return () => clearTimeout(e);
|
|
208
|
-
}, [r]);
|
|
209
|
-
let { data: c } = T({
|
|
210
|
-
...s(e.workspace, e.site, a),
|
|
211
|
-
enabled: a !== "",
|
|
212
|
-
placeholderData: w
|
|
213
|
-
}), l = a ? c?.docs ?? [] : [];
|
|
214
|
-
return /* @__PURE__ */ C("div", {
|
|
215
|
-
className: "relative",
|
|
216
|
-
children: [/* @__PURE__ */ S(m, {
|
|
217
|
-
value: r,
|
|
218
|
-
onValueChange: i,
|
|
219
|
-
placeholder: n("search"),
|
|
220
|
-
label: n("search"),
|
|
221
|
-
size: "sm",
|
|
222
|
-
className: "w-56 max-sm:w-40"
|
|
223
|
-
}), a && /* @__PURE__ */ S("ul", {
|
|
224
|
-
"aria-label": n("results"),
|
|
225
|
-
className: "absolute right-0 z-20 mt-1 max-h-96 w-96 overflow-y-auto rounded-md border border-border bg-background p-1 shadow-md max-sm:w-72",
|
|
226
|
-
children: l.length === 0 ? /* @__PURE__ */ S("li", {
|
|
227
|
-
className: "px-2 py-2 text-sm text-muted-foreground",
|
|
228
|
-
children: n("noResults")
|
|
229
|
-
}) : l.map((e) => /* @__PURE__ */ S("li", { children: /* @__PURE__ */ C("button", {
|
|
230
|
-
type: "button",
|
|
231
|
-
onClick: () => {
|
|
232
|
-
i(""), t(e.key);
|
|
233
|
-
},
|
|
234
|
-
className: "block w-full rounded px-2 py-1.5 text-left hover:bg-muted",
|
|
235
|
-
children: [/* @__PURE__ */ S("span", {
|
|
236
|
-
className: "block text-sm font-medium",
|
|
237
|
-
children: e.title
|
|
238
|
-
}), /* @__PURE__ */ S(A, { text: e.snippet })]
|
|
239
|
-
}) }, e.key))
|
|
240
|
-
})]
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function A({ text: e }) {
|
|
244
|
-
let t = e.split("**");
|
|
245
|
-
return /* @__PURE__ */ S("span", {
|
|
246
|
-
className: "mt-0.5 line-clamp-2 block text-xs text-muted-foreground",
|
|
247
|
-
children: t.map((e, t) => t % 2 == 1 ? /* @__PURE__ */ S("mark", {
|
|
248
|
-
className: "bg-transparent font-semibold text-foreground",
|
|
249
|
-
children: e
|
|
250
|
-
}, t) : /* @__PURE__ */ S("span", { children: e }, t))
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
export { E as SharedViewer };
|
|
180
|
+
export { x as SharedViewer };
|