@parallelworks/tandem-web 0.139.3 → 0.141.0
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 +45 -0
- package/_virtual/_virtual_i18n/es/common.js +45 -0
- package/_virtual/_virtual_i18n/ja/common.js +45 -0
- package/_virtual/_virtual_i18n/ko/common.js +45 -0
- package/_virtual/_virtual_i18n/zh/common.js +45 -0
- package/api/queries.js +80 -70
- package/components/DocButton.js +221 -0
- package/components/Editor.js +77 -75
- package/components/SettingsNav.js +55 -47
- package/components/SlashMenu.js +2 -0
- package/lib/docs.js +158 -123
- package/package.json +1 -1
- package/routeTree.gen.js +164 -158
- package/routes/_workspace/settings/slack.js +12 -0
- package/routes/_workspace/settings/slack2.js +109 -0
- package/routes/_workspace/settings/slack3.js +4 -0
- package/styles.css +4 -0
package/lib/docs.js
CHANGED
|
@@ -1,99 +1,126 @@
|
|
|
1
1
|
import { appURL as e, basePath as t } from "./base.js";
|
|
2
2
|
import { api as n, unwrap as r } from "../api/client.js";
|
|
3
3
|
import { useNavigate as i } from "./router.js";
|
|
4
|
-
import {
|
|
5
|
-
import { useFavorites as
|
|
6
|
-
import { copyItem as
|
|
7
|
-
import { openShare as
|
|
8
|
-
import { menuDivider as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { useTranslations as
|
|
11
|
-
import { useMutation as
|
|
4
|
+
import { docTemplatesQuery as a, docsQuery as o, meQuery as s, teamsQuery as c } from "../api/queries.js";
|
|
5
|
+
import { useFavorites as l } from "./favorites.js";
|
|
6
|
+
import { copyItem as u, useLinkItems as d } from "./menus.js";
|
|
7
|
+
import { openShare as f } from "./share.js";
|
|
8
|
+
import { menuDivider as p } from "@parallelworks/ui";
|
|
9
|
+
import { useCallback as m } from "react";
|
|
10
|
+
import { useFormatter as h, useTranslations as g } from "use-intl";
|
|
11
|
+
import { useMutation as _, useQuery as v, useQueryClient as y } from "@tanstack/react-query";
|
|
12
12
|
// src/lib/docs.tsx
|
|
13
|
-
function
|
|
13
|
+
function b(e) {
|
|
14
14
|
return e.ref || (e.slug ? `${e.slug}-${e.key}` : e.key);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function x(e) {
|
|
17
17
|
let t = (e.split("-").pop() ?? e).toLowerCase();
|
|
18
18
|
return /^[a-z2-7]{10}$/.test(t) ? t : e.toLowerCase();
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
20
|
+
function S() {
|
|
21
|
+
let e = h(), { data: t } = v(s);
|
|
22
|
+
return m(() => {
|
|
23
|
+
let n = /* @__PURE__ */ new Date();
|
|
24
|
+
return {
|
|
25
|
+
date: e.dateTime(n, { dateStyle: "long" }),
|
|
26
|
+
time: e.dateTime(n, { timeStyle: "short" }),
|
|
27
|
+
author: t?.user.name ?? ""
|
|
28
|
+
};
|
|
29
|
+
}, [e, t]);
|
|
22
30
|
}
|
|
23
|
-
function
|
|
24
|
-
|
|
31
|
+
function C(e, t) {
|
|
32
|
+
return `/${e}/docs/${b(t)}`;
|
|
33
|
+
}
|
|
34
|
+
function w(e) {
|
|
35
|
+
let t = y(), o = i(), s = g("docs"), l = () => t.invalidateQueries({ queryKey: [
|
|
25
36
|
"workspace",
|
|
26
37
|
e,
|
|
27
38
|
"docs"
|
|
28
|
-
] }),
|
|
39
|
+
] }), u = (t) => ({ path: {
|
|
29
40
|
workspace: e,
|
|
30
41
|
doc: t
|
|
31
|
-
} })
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
} }), d = S(), f = _({
|
|
43
|
+
mutationFn: async ({ team: t, parent: i, template: a }) => {
|
|
44
|
+
let o = a ?? await C(t, i);
|
|
45
|
+
return r(await n.POST("/api/v1/workspaces/{workspace}/docs", {
|
|
35
46
|
params: { path: { workspace: e } },
|
|
36
47
|
body: {
|
|
37
|
-
...
|
|
48
|
+
...o ? {
|
|
49
|
+
template: o,
|
|
50
|
+
variables: d()
|
|
51
|
+
} : { title: s("untitled") },
|
|
38
52
|
...t && { team: t },
|
|
39
53
|
...i && { parent: i.key }
|
|
40
54
|
}
|
|
41
|
-
}))
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
55
|
+
}));
|
|
56
|
+
},
|
|
57
|
+
onSuccess: (t) => {
|
|
58
|
+
l(), o({
|
|
59
|
+
to: "/$workspace/docs/$doc",
|
|
60
|
+
params: {
|
|
61
|
+
workspace: e,
|
|
62
|
+
doc: b(t)
|
|
63
|
+
},
|
|
64
|
+
search: { rename: !0 }
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}), p = _({
|
|
68
|
+
mutationFn: async ({ doc: e, title: t }) => r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
69
|
+
params: u(e.key),
|
|
70
|
+
body: { title: t }
|
|
71
|
+
})),
|
|
72
|
+
onSettled: l
|
|
73
|
+
}), m = _({
|
|
74
|
+
mutationFn: async ({ doc: e, area: t }) => r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
75
|
+
params: u(e.key),
|
|
76
|
+
body: { area: t }
|
|
77
|
+
})),
|
|
78
|
+
onSettled: l
|
|
79
|
+
}), h = _({
|
|
80
|
+
mutationFn: async ({ doc: e, space: t, parent: i, after: a, before: o }) => r(await n.POST("/api/v1/workspaces/{workspace}/docs/{doc}/move", {
|
|
81
|
+
params: u(e.key),
|
|
82
|
+
body: {
|
|
83
|
+
...t && { space: t },
|
|
84
|
+
...i && { parent: i.key },
|
|
85
|
+
...a && { after: a.key },
|
|
86
|
+
...o && { before: o.key }
|
|
51
87
|
}
|
|
52
|
-
}),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}),
|
|
79
|
-
archive: m({
|
|
80
|
-
mutationFn: async (e) => r(await n.POST("/api/v1/workspaces/{workspace}/docs/{doc}/archive", { params: c(e.key) })),
|
|
81
|
-
onSettled: s
|
|
82
|
-
}),
|
|
83
|
-
restore: m({
|
|
84
|
-
mutationFn: async (e) => r(await n.POST("/api/v1/workspaces/{workspace}/docs/{doc}/restore", { params: c(e.key) })),
|
|
85
|
-
onSettled: s
|
|
86
|
-
}),
|
|
87
|
-
setTemplate: m({
|
|
88
|
+
})),
|
|
89
|
+
onSettled: l
|
|
90
|
+
}), v = _({
|
|
91
|
+
mutationFn: async (e) => r(await n.POST("/api/v1/workspaces/{workspace}/docs/{doc}/archive", { params: u(e.key) })),
|
|
92
|
+
onSettled: l
|
|
93
|
+
}), x = _({
|
|
94
|
+
mutationFn: async (e) => r(await n.POST("/api/v1/workspaces/{workspace}/docs/{doc}/restore", { params: u(e.key) })),
|
|
95
|
+
onSettled: l
|
|
96
|
+
}), C = async (n, r) => {
|
|
97
|
+
let [i, o] = await Promise.all([t.fetchQuery(a(e)), t.fetchQuery(c(e))]), s = r ? r.teamId ?? "" : o.find((e) => e.key === n)?.id ?? "";
|
|
98
|
+
return i.find((e) => e.spaceDefault && (e.teamId ?? "") === s)?.id;
|
|
99
|
+
}, w = _({
|
|
100
|
+
mutationFn: async ({ doc: e, spaceDefault: t }) => r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
101
|
+
params: u(e.key),
|
|
102
|
+
body: { spaceDefault: t }
|
|
103
|
+
})),
|
|
104
|
+
onSettled: l
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
create: f,
|
|
108
|
+
rename: p,
|
|
109
|
+
fileUnder: m,
|
|
110
|
+
move: h,
|
|
111
|
+
archive: v,
|
|
112
|
+
restore: x,
|
|
113
|
+
setTemplate: _({
|
|
88
114
|
mutationFn: async ({ doc: e, template: t }) => r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
89
|
-
params:
|
|
115
|
+
params: u(e.key),
|
|
90
116
|
body: { template: t }
|
|
91
117
|
})),
|
|
92
|
-
onSettled:
|
|
118
|
+
onSettled: l
|
|
93
119
|
}),
|
|
94
|
-
|
|
120
|
+
setSpaceDefault: w,
|
|
121
|
+
setLook: _({
|
|
95
122
|
mutationFn: async ({ doc: e, ...t }) => r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
96
|
-
params:
|
|
123
|
+
params: u(e.key),
|
|
97
124
|
body: t
|
|
98
125
|
})),
|
|
99
126
|
onMutate: ({ doc: n, ...r }) => {
|
|
@@ -106,30 +133,30 @@ function b(e) {
|
|
|
106
133
|
...r
|
|
107
134
|
} : e);
|
|
108
135
|
},
|
|
109
|
-
onSettled:
|
|
136
|
+
onSettled: l
|
|
110
137
|
}),
|
|
111
|
-
duplicate:
|
|
138
|
+
duplicate: _({
|
|
112
139
|
mutationFn: async ({ doc: t, team: i }) => {
|
|
113
|
-
let a = r(await n.GET("/api/v1/workspaces/{workspace}/docs/{doc}", { params:
|
|
140
|
+
let a = r(await n.GET("/api/v1/workspaces/{workspace}/docs/{doc}", { params: u(t.key) })), o = a.ancestors?.at(-1)?.key, c = r(await n.POST("/api/v1/workspaces/{workspace}/docs", {
|
|
114
141
|
params: { path: { workspace: e } },
|
|
115
142
|
body: {
|
|
116
|
-
title:
|
|
143
|
+
title: s("copyOf", { title: a.title }),
|
|
117
144
|
body: a.body ?? "",
|
|
118
145
|
...i && { team: i },
|
|
119
|
-
...
|
|
146
|
+
...o && { parent: o }
|
|
120
147
|
}
|
|
121
148
|
}));
|
|
122
149
|
return a.icon ? r(await n.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
|
|
123
|
-
params: c
|
|
150
|
+
params: u(c.key),
|
|
124
151
|
body: { icon: a.icon }
|
|
125
|
-
})) :
|
|
152
|
+
})) : c;
|
|
126
153
|
},
|
|
127
154
|
onSuccess: (t) => {
|
|
128
|
-
|
|
155
|
+
l(), o({
|
|
129
156
|
to: "/$workspace/docs/$doc",
|
|
130
157
|
params: {
|
|
131
158
|
workspace: e,
|
|
132
|
-
doc:
|
|
159
|
+
doc: b(t)
|
|
133
160
|
},
|
|
134
161
|
search: { rename: !0 }
|
|
135
162
|
});
|
|
@@ -137,73 +164,73 @@ function b(e) {
|
|
|
137
164
|
})
|
|
138
165
|
};
|
|
139
166
|
}
|
|
140
|
-
function
|
|
141
|
-
let t = i(), n =
|
|
142
|
-
return
|
|
143
|
-
let
|
|
167
|
+
function T(e) {
|
|
168
|
+
let t = i(), n = g("docs"), r = g("common"), a = g("favorites"), s = d(), h = l(e), _ = w(e), { data: y = [] } = v(c(e)), { data: x = [] } = v(o(e, { top: !0 }));
|
|
169
|
+
return m((i, { onRename: o } = {}) => {
|
|
170
|
+
let c = y.find((e) => e.id === i.teamId), l = c?.key ?? "workspace", d = {
|
|
144
171
|
label: r("open"),
|
|
145
172
|
onClick: () => t({
|
|
146
173
|
to: "/$workspace/docs/$doc",
|
|
147
174
|
params: {
|
|
148
175
|
workspace: e,
|
|
149
|
-
doc:
|
|
176
|
+
doc: b(i)
|
|
150
177
|
}
|
|
151
178
|
})
|
|
152
|
-
},
|
|
179
|
+
}, m = [...s(C(e, i)), u(n("copyKey"), i.key)];
|
|
153
180
|
if (i.archivedAt) return [
|
|
154
|
-
|
|
181
|
+
d,
|
|
155
182
|
{
|
|
156
183
|
label: n("restore"),
|
|
157
|
-
onClick: () =>
|
|
184
|
+
onClick: () => _.restore.mutate(i)
|
|
158
185
|
},
|
|
159
|
-
|
|
160
|
-
...
|
|
186
|
+
p,
|
|
187
|
+
...m
|
|
161
188
|
];
|
|
162
|
-
let
|
|
189
|
+
let g = x.filter((e) => e.id !== i.id), v = [{
|
|
163
190
|
key: "workspace",
|
|
164
191
|
name: n("workspaceSpace")
|
|
165
|
-
}, ...
|
|
192
|
+
}, ...y.filter((e) => !e.archivedAt).map((e) => ({
|
|
166
193
|
key: e.key,
|
|
167
194
|
name: e.name
|
|
168
195
|
}))];
|
|
169
196
|
return [
|
|
170
|
-
|
|
197
|
+
d,
|
|
171
198
|
{
|
|
172
199
|
label: n("newInside"),
|
|
173
|
-
onClick: () =>
|
|
200
|
+
onClick: () => _.create.mutate({ parent: i })
|
|
174
201
|
},
|
|
175
202
|
{
|
|
176
203
|
label: n("duplicate"),
|
|
177
|
-
onClick: () =>
|
|
204
|
+
onClick: () => _.duplicate.mutate({
|
|
178
205
|
doc: i,
|
|
179
|
-
team:
|
|
206
|
+
team: c?.key
|
|
180
207
|
})
|
|
181
208
|
},
|
|
182
|
-
...
|
|
209
|
+
...o ? [{
|
|
183
210
|
label: n("rename"),
|
|
184
|
-
onClick:
|
|
211
|
+
onClick: o
|
|
185
212
|
}] : [],
|
|
186
213
|
{
|
|
187
214
|
label: n("moveTo"),
|
|
188
215
|
items: [
|
|
189
|
-
...
|
|
190
|
-
let t = !i.parentId && e.key ===
|
|
216
|
+
...v.map((e) => {
|
|
217
|
+
let t = !i.parentId && e.key === l;
|
|
191
218
|
return {
|
|
192
219
|
label: n("topOf", { space: e.name }),
|
|
193
220
|
checked: t,
|
|
194
221
|
disabled: t,
|
|
195
|
-
onClick: () =>
|
|
222
|
+
onClick: () => _.move.mutate({
|
|
196
223
|
doc: i,
|
|
197
224
|
space: e.key
|
|
198
225
|
})
|
|
199
226
|
};
|
|
200
227
|
}),
|
|
201
|
-
...
|
|
202
|
-
...
|
|
228
|
+
...g.length > 0 ? [p] : [],
|
|
229
|
+
...g.map((e) => ({
|
|
203
230
|
label: e.title,
|
|
204
231
|
checked: e.id === i.parentId,
|
|
205
232
|
disabled: e.id === i.parentId,
|
|
206
|
-
onClick: () =>
|
|
233
|
+
onClick: () => _.move.mutate({
|
|
207
234
|
doc: i,
|
|
208
235
|
parent: e
|
|
209
236
|
})
|
|
@@ -212,64 +239,72 @@ function x(e) {
|
|
|
212
239
|
},
|
|
213
240
|
{
|
|
214
241
|
label: n("share"),
|
|
215
|
-
onClick: () =>
|
|
242
|
+
onClick: () => f({
|
|
216
243
|
doc: i.key,
|
|
217
244
|
title: i.title
|
|
218
245
|
})
|
|
219
246
|
},
|
|
220
247
|
{
|
|
221
|
-
label:
|
|
222
|
-
onClick: () =>
|
|
248
|
+
label: h.find("doc", i.id) ? a("remove") : a("add"),
|
|
249
|
+
onClick: () => h.toggle("doc", i.id)
|
|
223
250
|
},
|
|
224
251
|
{
|
|
225
252
|
label: n("look.fullWidth"),
|
|
226
253
|
checked: !!i.fullWidth,
|
|
227
|
-
onClick: () =>
|
|
254
|
+
onClick: () => _.setLook.mutate({
|
|
228
255
|
doc: i,
|
|
229
256
|
fullWidth: !i.fullWidth
|
|
230
257
|
})
|
|
231
258
|
},
|
|
232
259
|
{
|
|
233
260
|
label: i.template ? n("stopTemplate") : n("useAsTemplate"),
|
|
234
|
-
onClick: () =>
|
|
261
|
+
onClick: () => _.setTemplate.mutate({
|
|
235
262
|
doc: i,
|
|
236
263
|
template: !i.template
|
|
237
264
|
})
|
|
238
265
|
},
|
|
266
|
+
...i.template ? [{
|
|
267
|
+
label: n("spaceDefault"),
|
|
268
|
+
checked: !!i.spaceDefault,
|
|
269
|
+
onClick: () => _.setSpaceDefault.mutate({
|
|
270
|
+
doc: i,
|
|
271
|
+
spaceDefault: !i.spaceDefault
|
|
272
|
+
})
|
|
273
|
+
}] : [],
|
|
239
274
|
{
|
|
240
275
|
label: n("exportMarkdown"),
|
|
241
|
-
onClick: () =>
|
|
276
|
+
onClick: () => D(e, { doc: i.key })
|
|
242
277
|
},
|
|
243
|
-
|
|
244
|
-
...
|
|
245
|
-
|
|
278
|
+
p,
|
|
279
|
+
...m,
|
|
280
|
+
p,
|
|
246
281
|
{
|
|
247
282
|
label: n("archive"),
|
|
248
283
|
destructive: !0,
|
|
249
|
-
onClick: () =>
|
|
284
|
+
onClick: () => _.archive.mutate(i)
|
|
250
285
|
}
|
|
251
286
|
];
|
|
252
287
|
}, [
|
|
253
|
-
|
|
254
|
-
|
|
288
|
+
y,
|
|
289
|
+
x,
|
|
255
290
|
e,
|
|
256
291
|
t,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
292
|
+
s,
|
|
293
|
+
h,
|
|
294
|
+
_,
|
|
260
295
|
n,
|
|
261
296
|
r,
|
|
262
|
-
|
|
297
|
+
a
|
|
263
298
|
]);
|
|
264
299
|
}
|
|
265
|
-
function
|
|
266
|
-
return e(
|
|
300
|
+
function E(t, n) {
|
|
301
|
+
return e(C(t, n));
|
|
267
302
|
}
|
|
268
|
-
function
|
|
303
|
+
function D(e, n) {
|
|
269
304
|
let r = new URLSearchParams({
|
|
270
305
|
...n,
|
|
271
306
|
...n.space && { knowledge: "true" }
|
|
272
307
|
}), i = document.createElement("a");
|
|
273
308
|
i.href = `${t}/api/v1/workspaces/${encodeURIComponent(e)}/docs/export?${r}`, i.download = "", i.click();
|
|
274
309
|
}
|
|
275
|
-
export {
|
|
310
|
+
export { x as docKey, C as docPath, b as docRef, E as docURL, D as downloadMarkdown, w as useDocActions, T as useDocMenu, S as useTemplateValues };
|