@parallelworks/tandem-web 0.179.2 → 0.181.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/lib/docs.js CHANGED
@@ -5,21 +5,22 @@ import { useFavorites as c } from "./favorites.js";
5
5
  import { copyItem as l, useLinkItems as u } from "./menus.js";
6
6
  import { useNavigate as d } from "./router.js";
7
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";
8
+ import { useSubpageActions as p } from "./subpageViews.js";
9
+ import { menuDivider as m } from "@parallelworks/ui";
10
+ import { useCallback as h } from "react";
11
+ import { useFormatter as g, useTranslations as _ } from "use-intl";
12
+ import { useMutation as v, useQuery as y, useQueryClient as b } from "@tanstack/react-query";
12
13
  // src/lib/docs.tsx
13
- function b(e) {
14
+ function x(e) {
14
15
  return e.ref || (e.slug ? `${e.slug}-${e.key}` : e.key);
15
16
  }
16
- function x(e) {
17
+ function S(e) {
17
18
  let t = (e.split("-").pop() ?? e).toLowerCase();
18
19
  return /^[a-z2-7]{10}$/.test(t) ? t : e.toLowerCase();
19
20
  }
20
- function S() {
21
- let e = h(), { data: t } = v(i);
22
- return m(() => {
21
+ function C() {
22
+ let e = g(), { data: t } = y(i);
23
+ return h(() => {
23
24
  let n = /* @__PURE__ */ new Date();
24
25
  return {
25
26
  date: e.dateTime(n, { dateStyle: "long" }),
@@ -28,20 +29,20 @@ function S() {
28
29
  };
29
30
  }, [e, t]);
30
31
  }
31
- function C(e, t) {
32
- return `/${e}/docs/${b(t)}`;
32
+ function w(e, t) {
33
+ return `/${e}/docs/${x(t)}`;
33
34
  }
34
- function w(r) {
35
- let i = y(), o = d(), s = g("docs"), c = () => i.invalidateQueries({ queryKey: [
35
+ function T(r) {
36
+ let i = b(), o = d(), s = _("docs"), c = () => i.invalidateQueries({ queryKey: [
36
37
  "workspace",
37
38
  r,
38
39
  "docs"
39
40
  ] }), l = (e) => ({ path: {
40
41
  workspace: r,
41
42
  doc: e
42
- } }), u = S(), f = _({
43
+ } }), u = C(), f = v({
43
44
  mutationFn: async ({ team: n, parent: i, template: a }) => {
44
- let o = a ?? await C(n, i);
45
+ let o = a ?? await S(n, i);
45
46
  return t(await e.POST("/api/v1/workspaces/{workspace}/docs", {
46
47
  params: { path: { workspace: r } },
47
48
  body: {
@@ -59,24 +60,24 @@ function w(r) {
59
60
  to: "/$workspace/docs/$doc",
60
61
  params: {
61
62
  workspace: r,
62
- doc: b(e)
63
+ doc: x(e)
63
64
  },
64
65
  search: { rename: !0 }
65
66
  });
66
67
  }
67
- }), p = _({
68
+ }), p = v({
68
69
  mutationFn: async ({ doc: n, title: r }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
69
70
  params: l(n.key),
70
71
  body: { title: r }
71
72
  })),
72
73
  onSettled: c
73
- }), m = _({
74
+ }), m = v({
74
75
  mutationFn: async ({ doc: n, area: r }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
75
76
  params: l(n.key),
76
77
  body: { area: r }
77
78
  })),
78
79
  onSettled: c
79
- }), h = _({
80
+ }), h = v({
80
81
  mutationFn: async ({ doc: n, space: r, parent: i, after: a, before: o }) => t(await e.POST("/api/v1/workspaces/{workspace}/docs/{doc}/move", {
81
82
  params: l(n.key),
82
83
  body: {
@@ -87,16 +88,16 @@ function w(r) {
87
88
  }
88
89
  })),
89
90
  onSettled: c
90
- }), v = _({
91
+ }), g = v({
91
92
  mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/docs/{doc}/archive", { params: l(n.key) })),
92
93
  onSettled: c
93
- }), x = _({
94
+ }), y = v({
94
95
  mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/docs/{doc}/restore", { params: l(n.key) })),
95
96
  onSettled: c
96
- }), C = async (e, t) => {
97
+ }), S = async (e, t) => {
97
98
  let [o, s] = await Promise.all([i.fetchQuery(n(r)), i.fetchQuery(a(r))]), c = t ? t.teamId ?? "" : s.find((t) => t.key === e)?.id ?? "";
98
99
  return o.find((e) => e.spaceDefault && (e.teamId ?? "") === c)?.id;
99
- }, w = _({
100
+ }, w = v({
100
101
  mutationFn: async ({ doc: n, spaceDefault: r }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
101
102
  params: l(n.key),
102
103
  body: { spaceDefault: r }
@@ -108,9 +109,9 @@ function w(r) {
108
109
  rename: p,
109
110
  fileUnder: m,
110
111
  move: h,
111
- archive: v,
112
- restore: x,
113
- setTemplate: _({
112
+ archive: g,
113
+ restore: y,
114
+ setTemplate: v({
114
115
  mutationFn: async ({ doc: n, template: r }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
115
116
  params: l(n.key),
116
117
  body: { template: r }
@@ -118,7 +119,7 @@ function w(r) {
118
119
  onSettled: c
119
120
  }),
120
121
  setSpaceDefault: w,
121
- setLook: _({
122
+ setLook: v({
122
123
  mutationFn: async ({ doc: n, ...r }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}", {
123
124
  params: l(n.key),
124
125
  body: r
@@ -135,7 +136,7 @@ function w(r) {
135
136
  },
136
137
  onSettled: c
137
138
  }),
138
- duplicate: _({
139
+ duplicate: v({
139
140
  mutationFn: async ({ doc: n, team: i }) => {
140
141
  let a = t(await e.GET("/api/v1/workspaces/{workspace}/docs/{doc}", { params: l(n.key) })), o = a.ancestors?.at(-1)?.key, c = t(await e.POST("/api/v1/workspaces/{workspace}/docs", {
141
142
  params: { path: { workspace: r } },
@@ -156,7 +157,7 @@ function w(r) {
156
157
  to: "/$workspace/docs/$doc",
157
158
  params: {
158
159
  workspace: r,
159
- doc: b(e)
160
+ doc: x(e)
160
161
  },
161
162
  search: { rename: !0 }
162
163
  });
@@ -164,32 +165,32 @@ function w(r) {
164
165
  })
165
166
  };
166
167
  }
167
- function T(e) {
168
- let t = d(), n = g("docs"), i = g("common"), o = g("favorites"), s = u(), h = c(e), _ = w(e), { data: y = [] } = v(a(e)), { data: x = [] } = v(r(e, { top: !0 }));
169
- return m((r, { onRename: a } = {}) => {
170
- let c = y.find((e) => e.id === r.teamId), u = c?.key ?? "workspace", d = {
168
+ function E(e) {
169
+ let t = d(), n = _("docs"), i = _("common"), o = _("favorites"), s = u(), g = c(e), v = T(e), b = p(e), S = _("subpages"), { data: C = [] } = y(a(e)), { data: E = [] } = y(r(e, { top: !0 }));
170
+ return h((r, { onRename: a } = {}) => {
171
+ let c = C.find((e) => e.id === r.teamId), u = c?.key ?? "workspace", d = {
171
172
  label: i("open"),
172
173
  onClick: () => t({
173
174
  to: "/$workspace/docs/$doc",
174
175
  params: {
175
176
  workspace: e,
176
- doc: b(r)
177
+ doc: x(r)
177
178
  }
178
179
  })
179
- }, m = [...s(C(e, r)), l(n("copyKey"), r.key)];
180
+ }, p = [...s(w(e, r)), l(n("copyKey"), r.key)];
180
181
  if (r.archivedAt) return [
181
182
  d,
182
183
  {
183
184
  label: n("restore"),
184
- onClick: () => _.restore.mutate(r)
185
+ onClick: () => v.restore.mutate(r)
185
186
  },
186
- p,
187
- ...m
187
+ m,
188
+ ...p
188
189
  ];
189
- let g = x.filter((e) => e.id !== r.id), v = [{
190
+ let h = E.filter((e) => e.id !== r.id), _ = [{
190
191
  key: "workspace",
191
192
  name: n("workspaceSpace")
192
- }, ...y.filter((e) => !e.archivedAt).map((e) => ({
193
+ }, ...C.filter((e) => !e.archivedAt).map((e) => ({
193
194
  key: e.key,
194
195
  name: e.name
195
196
  }))];
@@ -197,11 +198,19 @@ function T(e) {
197
198
  d,
198
199
  {
199
200
  label: n("newInside"),
200
- onClick: () => _.create.mutate({ parent: r })
201
+ onClick: () => v.create.mutate({ parent: r })
202
+ },
203
+ {
204
+ label: n("showSubpagesAsCalendar"),
205
+ onClick: () => b.addView.mutate({
206
+ doc: r.key,
207
+ name: S("calendarView"),
208
+ layout: "calendar"
209
+ })
201
210
  },
202
211
  {
203
212
  label: n("duplicate"),
204
- onClick: () => _.duplicate.mutate({
213
+ onClick: () => v.duplicate.mutate({
205
214
  doc: r,
206
215
  team: c?.key
207
216
  })
@@ -213,24 +222,24 @@ function T(e) {
213
222
  {
214
223
  label: n("moveTo"),
215
224
  items: [
216
- ...v.map((e) => {
225
+ ..._.map((e) => {
217
226
  let t = !r.parentId && e.key === u;
218
227
  return {
219
228
  label: n("topOf", { space: e.name }),
220
229
  checked: t,
221
230
  disabled: t,
222
- onClick: () => _.move.mutate({
231
+ onClick: () => v.move.mutate({
223
232
  doc: r,
224
233
  space: e.key
225
234
  })
226
235
  };
227
236
  }),
228
- ...g.length > 0 ? [p] : [],
229
- ...g.map((e) => ({
237
+ ...h.length > 0 ? [m] : [],
238
+ ...h.map((e) => ({
230
239
  label: e.title,
231
240
  checked: e.id === r.parentId,
232
241
  disabled: e.id === r.parentId,
233
- onClick: () => _.move.mutate({
242
+ onClick: () => v.move.mutate({
234
243
  doc: r,
235
244
  parent: e
236
245
  })
@@ -245,20 +254,20 @@ function T(e) {
245
254
  })
246
255
  },
247
256
  {
248
- label: h.find("doc", r.id) ? o("remove") : o("add"),
249
- onClick: () => h.toggle("doc", r.id)
257
+ label: g.find("doc", r.id) ? o("remove") : o("add"),
258
+ onClick: () => g.toggle("doc", r.id)
250
259
  },
251
260
  {
252
261
  label: n("look.fullWidth"),
253
262
  checked: !!r.fullWidth,
254
- onClick: () => _.setLook.mutate({
263
+ onClick: () => v.setLook.mutate({
255
264
  doc: r,
256
265
  fullWidth: !r.fullWidth
257
266
  })
258
267
  },
259
268
  {
260
269
  label: r.template ? n("stopTemplate") : n("useAsTemplate"),
261
- onClick: () => _.setTemplate.mutate({
270
+ onClick: () => v.setTemplate.mutate({
262
271
  doc: r,
263
272
  template: !r.template
264
273
  })
@@ -266,45 +275,47 @@ function T(e) {
266
275
  ...r.template ? [{
267
276
  label: n("spaceDefault"),
268
277
  checked: !!r.spaceDefault,
269
- onClick: () => _.setSpaceDefault.mutate({
278
+ onClick: () => v.setSpaceDefault.mutate({
270
279
  doc: r,
271
280
  spaceDefault: !r.spaceDefault
272
281
  })
273
282
  }] : [],
274
283
  {
275
284
  label: n("exportMarkdown"),
276
- onClick: () => D(e, { doc: r.key })
285
+ onClick: () => O(e, { doc: r.key })
277
286
  },
278
- p,
279
- ...m,
280
- p,
287
+ m,
288
+ ...p,
289
+ m,
281
290
  {
282
291
  label: n("archive"),
283
292
  destructive: !0,
284
- onClick: () => _.archive.mutate(r)
293
+ onClick: () => v.archive.mutate(r)
285
294
  }
286
295
  ];
287
296
  }, [
288
- y,
289
- x,
297
+ C,
298
+ E,
290
299
  e,
291
300
  t,
292
301
  s,
293
- h,
294
- _,
302
+ g,
303
+ v,
304
+ b,
295
305
  n,
306
+ S,
296
307
  i,
297
308
  o
298
309
  ]);
299
310
  }
300
- function E(e, t) {
301
- return o(C(e, t));
302
- }
303
311
  function D(e, t) {
312
+ return o(w(e, t));
313
+ }
314
+ function O(e, t) {
304
315
  let n = new URLSearchParams({
305
316
  ...t,
306
317
  ...t.space && { knowledge: "true" }
307
318
  }), r = document.createElement("a");
308
319
  r.href = `${s}/api/v1/workspaces/${encodeURIComponent(e)}/docs/export?${n}`, r.download = "", r.click();
309
320
  }
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 };
321
+ export { S as docKey, w as docPath, x as docRef, D as docURL, O as downloadMarkdown, T as useDocActions, E as useDocMenu, C as useTemplateValues };
package/lib/glossary.js CHANGED
@@ -80,15 +80,19 @@ function p(e) {
80
80
  return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").replace(/\s+/g, "-");
81
81
  }
82
82
  function m(e) {
83
- let t = [], n = !1;
83
+ return e.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/(\*\*|__|~~|`)(.+?)\1/g, "$2").replace(/(^|[^\w*])[*_]([^*_]+)[*_](?=[^\w*]|$)/g, "$1$2").trim();
84
+ }
85
+ function h(e) {
86
+ let t = [], n = "";
84
87
  for (let r of e.split("\n")) {
85
- r.startsWith("```") && (n = !n);
86
- let e = n ? null : /^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(r);
87
- e?.[1] && e[2] && t.push({
88
- level: e[1].length,
89
- text: e[2]
88
+ let e = /^(`{3,}|~{3,})/.exec(r)?.[1];
89
+ e && (!n || e.startsWith(n)) && (n = n ? "" : e);
90
+ let i = n ? null : /^(#{1,6})\s+(.+?)\s*#*\s*$/.exec(r), a = i?.[2] ? m(i[2]) : "";
91
+ i?.[1] && a && t.push({
92
+ level: i[1].length,
93
+ text: a
90
94
  });
91
95
  }
92
96
  return t;
93
97
  }
94
- export { d as docForms, a as formsOf, f as glossary, p as headingAnchor, m as headings, l as mentions };
98
+ export { d as docForms, a as formsOf, f as glossary, p as headingAnchor, h as headings, l as mentions, m as plainHeading };
@@ -0,0 +1,85 @@
1
+ import { api as e, unwrap as t } from "../api/client.js";
2
+ import { docTemplatesQuery as n } from "../api/queries.js";
3
+ import { queryOptions as r, useMutation as i, useQueryClient as a } from "@tanstack/react-query";
4
+ // src/lib/subpageViews.ts
5
+ function o(e) {
6
+ let t = e ?? {};
7
+ return {
8
+ ...typeof t.dateProperty == "string" && { dateProperty: t.dateProperty },
9
+ ...typeof t.template == "string" && { template: t.template }
10
+ };
11
+ }
12
+ var s = (n, i) => r({
13
+ queryKey: [
14
+ "workspace",
15
+ n,
16
+ "docs",
17
+ "subpage-views",
18
+ i
19
+ ],
20
+ queryFn: async ({ signal: r }) => t(await e.GET("/api/v1/workspaces/{workspace}/docs/{doc}/views", {
21
+ params: { path: {
22
+ workspace: n,
23
+ doc: i
24
+ } },
25
+ signal: r
26
+ })).views
27
+ });
28
+ function c(r) {
29
+ let o = a(), s = () => o.invalidateQueries({ queryKey: [
30
+ "workspace",
31
+ r,
32
+ "docs"
33
+ ] });
34
+ return {
35
+ addView: i({
36
+ mutationFn: async ({ doc: n, ...i }) => t(await e.POST("/api/v1/workspaces/{workspace}/docs/{doc}/views", {
37
+ params: { path: {
38
+ workspace: r,
39
+ doc: n
40
+ } },
41
+ body: i
42
+ })),
43
+ onSettled: s
44
+ }),
45
+ updateView: i({
46
+ mutationFn: async ({ view: n, ...i }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/doc-views/{view}", {
47
+ params: { path: {
48
+ workspace: r,
49
+ view: n.id
50
+ } },
51
+ body: i
52
+ })),
53
+ onSettled: s
54
+ }),
55
+ removeView: i({
56
+ mutationFn: async (n) => t(await e.DELETE("/api/v1/workspaces/{workspace}/doc-views/{view}", { params: { path: {
57
+ workspace: r,
58
+ view: n.id
59
+ } } })),
60
+ onSettled: s
61
+ }),
62
+ newSubpage: i({
63
+ mutationFn: async ({ parent: i, title: a, template: s, dateProperty: c, date: l }) => {
64
+ let u = (s ? await o.fetchQuery(n(r)) : []).find((e) => e.id === s), d = t(await e.POST("/api/v1/workspaces/{workspace}/docs", {
65
+ params: { path: { workspace: r } },
66
+ body: {
67
+ title: a,
68
+ parent: i.key,
69
+ ...u && { template: u.id },
70
+ ...l && u && { variables: { date: l } }
71
+ }
72
+ }));
73
+ return c && l && await e.PATCH("/api/v1/workspaces/{workspace}/docs/{doc}/properties", {
74
+ params: { path: {
75
+ workspace: r,
76
+ doc: d.key
77
+ } },
78
+ body: { values: { [c]: l } }
79
+ }), d;
80
+ },
81
+ onSettled: s
82
+ })
83
+ };
84
+ }
85
+ export { o as readSubpageConfig, s as subpageViewsQuery, c as useSubpageActions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.179.2",
3
+ "version": "0.181.0",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",