@parallelworks/tandem-web 0.178.1 → 0.179.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.
@@ -1,30 +1,32 @@
1
1
  import { attachmentIdOf as e, attachmentPrefix as t, attachmentSizes as n, attachmentURL as r, githubMedia as i, githubUpload as a, mediaURL as o, playableLink as s, videoName as c } from "../lib/attachments.js";
2
- import { docLooks as l } from "../lib/docLooks.js";
3
- import { githubLinkPage as u } from "../lib/githubLink.js";
4
- import { glossary as d, mentions as f } from "../lib/glossary.js";
5
- import { issueKeyOfHref as p, issueKeyPattern as m, issueRefs as h } from "../lib/issueRefs.js";
2
+ import { basePath as l } from "../lib/base.js";
3
+ import { issuePath as u } from "../lib/branch.js";
4
+ import { docLooks as d } from "../lib/docLooks.js";
5
+ import { githubLinkPage as f } from "../lib/githubLink.js";
6
+ import { glossary as p, mentions as m } from "../lib/glossary.js";
7
+ import { issueKeyOfHref as ee, issueKeyPattern as te, issueRefs as h } from "../lib/issueRefs.js";
6
8
  import { linkedIssues as g } from "../lib/linkedIssues.js";
7
- import { mentionable as _, mentionsIn as ee } from "../lib/mentions.js";
9
+ import { mentionable as _, mentionsIn as ne } from "../lib/mentions.js";
8
10
  import { statusGroup as v } from "../lib/statusGroup.js";
9
11
  import { teamNames as y } from "../lib/teamNames.js";
10
- import { docIcons as te } from "./DocIcon.js";
11
- import { iconImageURL as ne } from "./EntityIcon.js";
12
- import { createElement as re } from "react";
13
- import { Extension as b } from "@tiptap/react";
14
- import { Plugin as x, PluginKey as S, TextSelection as ie } from "@tiptap/pm/state";
15
- import { Decoration as C, DecorationSet as w } from "@tiptap/pm/view";
12
+ import { docIcons as re } from "./DocIcon.js";
13
+ import { iconImageURL as b } from "./EntityIcon.js";
14
+ import { createElement as x } from "react";
15
+ import { Extension as S } from "@tiptap/react";
16
+ import { Plugin as C, PluginKey as w, TextSelection as ie } from "@tiptap/pm/state";
17
+ import { Decoration as T, DecorationSet as E } from "@tiptap/pm/view";
16
18
  import ae from "@tiptap/extension-image";
17
- import { createRoot as oe } from "react-dom/client";
19
+ import { createRoot as D } from "react-dom/client";
18
20
  // src/components/editorPlugins.ts
19
- var T = new S("knowledgeTerms"), E = /* @__PURE__ */ new Set([
21
+ var O = new w("knowledgeTerms"), oe = /* @__PURE__ */ new Set([
20
22
  "ArrowLeft",
21
23
  "ArrowRight",
22
24
  "ArrowUp",
23
25
  "ArrowDown",
24
26
  "Home",
25
27
  "End"
26
- ]), D = "tandem:term-caret";
27
- function O(e, t) {
28
+ ]), k = "tandem:term-caret";
29
+ function A(e, t) {
28
30
  e.descendants((e, n) => {
29
31
  if (!e.isTextblock) return !0;
30
32
  if (e.type.spec.code) return !1;
@@ -37,12 +39,12 @@ function O(e, t) {
37
39
  }), t(r, n + 1), !1;
38
40
  });
39
41
  }
40
- function k(e, t) {
41
- let n = d.forms();
42
- if (n.length === 0) return w.empty;
42
+ function j(e, t) {
43
+ let n = p.forms();
44
+ if (n.length === 0) return E.empty;
43
45
  let r = [];
44
- return O(e, (e, i) => {
45
- for (let a of f(e, n)) r.push(C.inline(i + a.from, i + a.to, {
46
+ return A(e, (e, i) => {
47
+ for (let a of m(e, n)) r.push(T.inline(i + a.from, i + a.to, {
46
48
  class: "kb-term",
47
49
  "data-term": a.id,
48
50
  ...t && {
@@ -50,19 +52,19 @@ function k(e, t) {
50
52
  role: "button"
51
53
  }
52
54
  }));
53
- }), w.create(e, r);
55
+ }), E.create(e, r);
54
56
  }
55
- function A(e) {
57
+ function M(e) {
56
58
  let t = /* @__PURE__ */ new Set();
57
59
  return e.descendants((e) => {
58
60
  for (let n of e.marks) n.type.name === "link" && t.add(String(n.attrs.href ?? ""));
59
61
  return !0;
60
62
  }), t;
61
63
  }
62
- function j(e, t, n) {
64
+ function N(e, t, n) {
63
65
  let r = [], i = /* @__PURE__ */ new Set();
64
- return O(e, (e, a) => {
65
- for (let o of f(e, t)) i.has(o.id) || (i.add(o.id), n(o.id) || r.push({
66
+ return A(e, (e, a) => {
67
+ for (let o of m(e, t)) i.has(o.id) || (i.add(o.id), n(o.id) || r.push({
66
68
  from: a + o.from,
67
69
  to: a + o.to,
68
70
  id: o.id,
@@ -70,49 +72,49 @@ function j(e, t, n) {
70
72
  }));
71
73
  }), r;
72
74
  }
73
- var M = b.create({
75
+ var se = S.create({
74
76
  name: "knowledgeTerms",
75
77
  addProseMirrorPlugins() {
76
78
  let e = this.editor, t = "";
77
- return [new x({
78
- key: T,
79
+ return [new C({
80
+ key: O,
79
81
  state: {
80
- init: (t, n) => k(n.doc, !e.isEditable),
81
- apply: (t, n) => t.docChanged || t.getMeta(T) ? k(t.doc, !e.isEditable) : n.map(t.mapping, t.doc)
82
+ init: (t, n) => j(n.doc, !e.isEditable),
83
+ apply: (t, n) => t.docChanged || t.getMeta(O) ? j(t.doc, !e.isEditable) : n.map(t.mapping, t.doc)
82
84
  },
83
85
  props: {
84
- decorations: (e) => T.getState(e),
86
+ decorations: (e) => O.getState(e),
85
87
  handleKeyDown: (e, n) => (t = n.key, !1)
86
88
  },
87
89
  view: (e) => ({
88
90
  update: (e, n) => {
89
91
  let { selection: r } = e.state;
90
- if (!E.has(t) || !r.empty || n.selection.eq(r)) return;
92
+ if (!oe.has(t) || !r.empty || n.selection.eq(r)) return;
91
93
  t = "";
92
94
  let i = e.domAtPos(r.from);
93
- (i.node.nodeType === 1 ? i.node : i.node.parentElement)?.closest(".kb-term")?.dispatchEvent(new CustomEvent(D, { bubbles: !0 }));
95
+ (i.node.nodeType === 1 ? i.node : i.node.parentElement)?.closest(".kb-term")?.dispatchEvent(new CustomEvent(k, { bubbles: !0 }));
94
96
  },
95
- destroy: d.subscribe(() => {
96
- e.isDestroyed || e.dispatch(e.state.tr.setMeta(T, !0));
97
+ destroy: p.subscribe(() => {
98
+ e.isDestroyed || e.dispatch(e.state.tr.setMeta(O, !0));
97
99
  })
98
100
  })
99
101
  })];
100
102
  }
101
103
  });
102
- function N(e) {
104
+ function ce(e) {
103
105
  return e.docLinks;
104
106
  }
105
- var se = b.create({
107
+ var le = S.create({
106
108
  name: "docLinks",
107
109
  addStorage: () => ({ handlers: /* @__PURE__ */ new Set() }),
108
110
  addProseMirrorPlugins() {
109
111
  let e = this.storage;
110
- return [new x({ props: { handleKeyDown: (t, n) => {
112
+ return [new C({ props: { handleKeyDown: (t, n) => {
111
113
  for (let t of e.handlers) if (t(n)) return !0;
112
114
  return !1;
113
115
  } } })];
114
116
  }
115
- }), P = "tandem:open-image", ce = ae.extend({
117
+ }), P = "tandem:open-image", ue = ae.extend({
116
118
  parseHTML() {
117
119
  return [{
118
120
  tag: "img[src]",
@@ -159,7 +161,7 @@ function F(e, t) {
159
161
  var I = { linkHint: "" };
160
162
  function L(e, t, n) {
161
163
  let r = document.createElement("span");
162
- r.className = "recording-unplayable", r.contentEditable = "false", n && r.append(R(t)), e.replaceWith(r), a(t) && u().then((e) => {
164
+ r.className = "recording-unplayable", r.contentEditable = "false", n && r.append(R(t)), e.replaceWith(r), a(t) && f().then((e) => {
163
165
  if (!e || !I.linkHint) return;
164
166
  let t = document.createElement("a");
165
167
  t.className = "recording-hint", t.href = e, t.textContent = I.linkHint, r.append(t);
@@ -169,12 +171,12 @@ function R(e) {
169
171
  let t = document.createElement("a");
170
172
  return t.href = r(e), t.textContent = e, t.rel = "noopener noreferrer", t.target = "_blank", t;
171
173
  }
172
- var z = new S("attachmentFiles");
174
+ var z = new w("attachmentFiles");
173
175
  function B(e, t) {
174
176
  e.descendants((e, n) => {
175
177
  if (e.type.name !== "paragraph") return !0;
176
178
  let r = e.childCount === 1 ? e.firstChild : null, i = r?.marks.find((e) => e.type.name === "link")?.attrs.href;
177
- return r?.isText && i && s(i) && r.text?.trim() === i && t.push(C.widget(n + e.nodeSize - 1, () => {
179
+ return r?.isText && i && s(i) && r.text?.trim() === i && t.push(T.widget(n + e.nodeSize - 1, () => {
178
180
  let e = document.createElement("span");
179
181
  return e.className = "recording-box", e.contentEditable = "false", e.append(F(i, (e) => L(e, i, !1))), e;
180
182
  }, {
@@ -190,11 +192,11 @@ function V(t) {
190
192
  return B(t, i), t.descendants((t, a) => {
191
193
  if (!t.isText) return !0;
192
194
  let o = t.marks.find((e) => e.type.name === "link"), s = e(o?.attrs.href), l = s && n.get(s);
193
- l && i.push(C.inline(a, a + t.nodeSize, { "data-size": l }));
195
+ l && i.push(T.inline(a, a + t.nodeSize, { "data-size": l }));
194
196
  let u = !n.get(s ?? "") && c.test(t.text ?? "");
195
197
  if (s && (n.isVideo(s) || u) && o) {
196
198
  let e = r(String(o.attrs.href));
197
- i.push(C.widget(a + t.nodeSize, () => {
199
+ i.push(T.widget(a + t.nodeSize, () => {
198
200
  let t = document.createElement("video");
199
201
  return t.className = "attachment-video", t.src = e, t.controls = !0, t.preload = "metadata", t.contentEditable = "false", u && t.addEventListener("error", () => t.remove(), { once: !0 }), t;
200
202
  }, {
@@ -205,13 +207,13 @@ function V(t) {
205
207
  }));
206
208
  }
207
209
  return !1;
208
- }), w.create(t, i);
210
+ }), E.create(t, i);
209
211
  }
210
- var H = b.create({
212
+ var H = S.create({
211
213
  name: "attachmentFiles",
212
214
  priority: 1e3,
213
215
  addProseMirrorPlugins() {
214
- return [new x({
216
+ return [new C({
215
217
  key: z,
216
218
  state: {
217
219
  init: (e, t) => V(t.doc),
@@ -239,13 +241,13 @@ var H = b.create({
239
241
  }) })
240
242
  })];
241
243
  }
242
- }), U = new S("linkedIssues");
244
+ }), U = new w("linkedIssues");
243
245
  function W(e) {
244
246
  let t = [], n, r = () => {
245
247
  let e = n && g.get(n.href);
246
248
  if (n && e) {
247
249
  let { identifier: r, title: i, status: a } = e;
248
- t.push(C.widget(n.end, () => {
250
+ t.push(T.widget(n.end, () => {
249
251
  let e = document.createElement("button");
250
252
  return e.type = "button", e.className = "linked-issue", e.dataset.linkedIssue = r, e.dataset.category = v(a), e.contentEditable = "false", e.title = `${r} ${i}`, e.textContent = `${r} · ${a.name}`, e;
251
253
  }, {
@@ -262,12 +264,12 @@ function W(e) {
262
264
  href: i,
263
265
  end: t + e.nodeSize
264
266
  }), !1;
265
- }), r(), w.create(e, t);
267
+ }), r(), E.create(e, t);
266
268
  }
267
- var le = b.create({
269
+ var de = S.create({
268
270
  name: "linkedIssues",
269
271
  addProseMirrorPlugins() {
270
- return [new x({
272
+ return [new C({
271
273
  key: U,
272
274
  state: {
273
275
  init: (e, t) => W(t.doc),
@@ -285,44 +287,48 @@ var le = b.create({
285
287
  }) })
286
288
  })];
287
289
  }
288
- }), G = new S("issueMentions");
289
- function ue(e) {
290
+ }), G = new w("issueMentions");
291
+ function fe(e) {
290
292
  let t = document.createElement("span");
291
293
  return t.className = "issue-mention-status", t.dataset.category = e, t.contentEditable = "false", t;
292
294
  }
293
295
  function K(e) {
294
296
  let t = h.workspace();
295
- if (!t) return w.empty;
296
- let n = [], r = [], i = (e, t, i, a) => {
297
- let o = h.get(i);
298
- if (!o) {
299
- r.push(i);
297
+ if (!t) return E.empty;
298
+ let n = [], r = [], i = (e, i, a, o) => {
299
+ let s = h.get(a);
300
+ if (!s) {
301
+ r.push(a);
300
302
  return;
301
303
  }
302
- let s = v(o.status);
303
- n.push(C.widget(e, () => ue(s), {
304
+ let c = v(s.status);
305
+ n.push(T.widget(e, () => fe(c), {
304
306
  side: -1,
305
- key: `dot-${i}-${s}`
306
- }), C.inline(e, t, {
307
- class: a ? "issue-mention issue-mention-key" : "issue-mention",
308
- "data-issue": o.identifier,
309
- title: `${o.identifier} ${o.title} · ${o.status.name}`
310
- })), a && n.push(C.widget(t, () => {
307
+ key: `dot-${a}-${c}`
308
+ }), T.inline(e, i, {
309
+ ...o ? {
310
+ nodeName: "a",
311
+ href: `${l}${u(t, s.identifier)}`
312
+ } : {},
313
+ class: o ? "issue-mention issue-mention-key" : "issue-mention",
314
+ "data-issue": s.identifier,
315
+ title: `${s.identifier} ${s.title} · ${s.status.name}`
316
+ })), o && n.push(T.widget(i, () => {
311
317
  let e = document.createElement("span");
312
- return e.className = "issue-mention-title", e.contentEditable = "false", e.textContent = o.title, e;
318
+ return e.className = "issue-mention-title", e.contentEditable = "false", e.textContent = s.title, e;
313
319
  }, {
314
320
  side: 1,
315
- key: `title-${i}-${o.title}`
321
+ key: `title-${a}-${s.title}`
316
322
  }));
317
323
  };
318
- O(e, (e, t) => {
319
- for (let n of e.matchAll(m)) {
324
+ A(e, (e, t) => {
325
+ for (let n of e.matchAll(te)) {
320
326
  let e = n[1] ?? "";
321
327
  i(t + (n.index ?? 0), t + (n.index ?? 0) + e.length, e, !0);
322
328
  }
323
329
  });
324
330
  let a, o = () => {
325
- let e = a && p(a.href, t);
331
+ let e = a && ee(a.href, t);
326
332
  a && e && i(a.from, a.to, e, !1), a = void 0;
327
333
  };
328
334
  return e.descendants((e, t) => {
@@ -336,12 +342,12 @@ function K(e) {
336
342
  from: t,
337
343
  to: t + e.nodeSize
338
344
  }), !1;
339
- }), o(), r.length > 0 && h.want(r), w.create(e, n);
345
+ }), o(), r.length > 0 && h.want(r), E.create(e, n);
340
346
  }
341
- var de = b.create({
347
+ var pe = S.create({
342
348
  name: "issueMentions",
343
349
  addProseMirrorPlugins() {
344
- return [new x({
350
+ return [new C({
345
351
  key: G,
346
352
  state: {
347
353
  init: (e, t) => K(t.doc),
@@ -353,22 +359,22 @@ var de = b.create({
353
359
  }) })
354
360
  })];
355
361
  }
356
- }), q = new S("teamNames");
362
+ }), q = new w("teamNames");
357
363
  function J(e) {
358
364
  let t = y.forms();
359
- if (t.length === 0) return w.empty;
365
+ if (t.length === 0) return E.empty;
360
366
  let n = [];
361
- return O(e, (e, r) => {
362
- for (let i of f(e, t, !0)) n.push(C.inline(r + i.from, r + i.to, {
367
+ return A(e, (e, r) => {
368
+ for (let i of m(e, t, !0)) n.push(T.inline(r + i.from, r + i.to, {
363
369
  class: "team-mention",
364
370
  "data-team": i.id
365
371
  }));
366
- }), w.create(e, n);
372
+ }), E.create(e, n);
367
373
  }
368
- var fe = b.create({
374
+ var me = S.create({
369
375
  name: "teamNames",
370
376
  addProseMirrorPlugins() {
371
- return [new x({
377
+ return [new C({
372
378
  key: q,
373
379
  state: {
374
380
  init: (e, t) => J(t.doc),
@@ -380,20 +386,20 @@ var fe = b.create({
380
386
  }) })
381
387
  })];
382
388
  }
383
- }), Y = new S("peopleMentions");
389
+ }), Y = new w("peopleMentions");
384
390
  function X(e) {
385
391
  let t = [];
386
- return O(e, (e, n) => {
387
- for (let r of ee(e)) _.has(r.username) && t.push(C.inline(n + r.from, n + r.to, {
392
+ return A(e, (e, n) => {
393
+ for (let r of ne(e)) _.has(r.username) && t.push(T.inline(n + r.from, n + r.to, {
388
394
  class: "person-mention",
389
395
  "data-username": r.username
390
396
  }));
391
- }), w.create(e, t);
397
+ }), E.create(e, t);
392
398
  }
393
- var pe = b.create({
399
+ var he = S.create({
394
400
  name: "peopleMentions",
395
401
  addProseMirrorPlugins() {
396
- return [new x({
402
+ return [new C({
397
403
  key: Y,
398
404
  state: {
399
405
  init: (e, t) => X(t.doc),
@@ -405,17 +411,17 @@ var pe = b.create({
405
411
  }) })
406
412
  })];
407
413
  }
408
- }), Z = new S("docLinkIcons"), Q = /* @__PURE__ */ new WeakMap();
409
- function me(e) {
414
+ }), Z = new w("docLinkIcons"), Q = /* @__PURE__ */ new WeakMap();
415
+ function ge(e) {
410
416
  let t = document.createElement("span");
411
417
  t.className = "doc-link-icon", t.contentEditable = "false";
412
- let n = ne(e), r = e.startsWith("icon:") ? te[e.slice(5)] : void 0;
418
+ let n = b(e), r = e.startsWith("icon:") ? re[e.slice(5)] : void 0;
413
419
  if (n) {
414
420
  let e = document.createElement("img");
415
421
  e.src = n, e.alt = "", t.appendChild(e);
416
422
  } else if (r) {
417
- let e = oe(t);
418
- queueMicrotask(() => e.render(re(r, { className: "size-[0.95em]" }))), Q.set(t, e);
423
+ let e = D(t);
424
+ queueMicrotask(() => e.render(x(r, { className: "size-[0.95em]" }))), Q.set(t, e);
419
425
  } else t.textContent = e;
420
426
  return t;
421
427
  }
@@ -425,8 +431,8 @@ function $(e) {
425
431
  if (!e.isText) return !0;
426
432
  let a = e.marks.find((e) => e.type.name === "link"), o = String(a?.attrs.href ?? ""), s = !!a && o === r && i === n;
427
433
  if (r = a ? o : "", n = i + e.nodeSize, !a || s || !o.includes("/docs/")) return !1;
428
- let c = l.iconAt(o);
429
- return c && t.push(C.widget(i, () => me(c), {
434
+ let c = d.iconAt(o);
435
+ return c && t.push(T.widget(i, () => ge(c), {
430
436
  side: 1,
431
437
  marks: [a],
432
438
  key: `doc-icon:${c}`,
@@ -436,24 +442,24 @@ function $(e) {
436
442
  t && queueMicrotask(() => t.unmount());
437
443
  }
438
444
  })), !1;
439
- }), w.create(e, t);
445
+ }), E.create(e, t);
440
446
  }
441
- var he = b.create({
447
+ var _e = S.create({
442
448
  name: "docLinkIcons",
443
449
  addProseMirrorPlugins() {
444
- return [new x({
450
+ return [new C({
445
451
  key: Z,
446
452
  state: {
447
453
  init: (e, t) => $(t.doc),
448
454
  apply: (e, t) => e.docChanged || e.getMeta(Z) ? $(e.doc) : t
449
455
  },
450
456
  props: { decorations: (e) => Z.getState(e) },
451
- view: (e) => ({ destroy: l.subscribe(() => {
457
+ view: (e) => ({ destroy: d.subscribe(() => {
452
458
  e.isDestroyed || e.dispatch(e.state.tr.setMeta(Z, !0));
453
459
  }) })
454
460
  })];
455
461
  }
456
- }), ge = b.create({
462
+ }), ve = S.create({
457
463
  name: "moveBlock",
458
464
  addKeyboardShortcuts() {
459
465
  let e = (e) => () => {
@@ -470,4 +476,4 @@ var he = b.create({
470
476
  };
471
477
  }
472
478
  });
473
- export { H as AttachmentFiles, ce as AttachmentImage, he as DocLinkIcons, se as DocLinks, de as IssueMentions, M as KnowledgeTerms, le as LinkedIssues, ge as MoveBlock, pe as PeopleMentions, fe as TeamNames, A as linksIn, P as openImageEvent, N as pickerKeys, R as plainLink, F as recordingPlayer, I as recordingText, D as termCaretEvent, j as unlinkedMentions, L as unplayable };
479
+ export { H as AttachmentFiles, ue as AttachmentImage, _e as DocLinkIcons, le as DocLinks, pe as IssueMentions, se as KnowledgeTerms, de as LinkedIssues, ve as MoveBlock, he as PeopleMentions, me as TeamNames, M as linksIn, P as openImageEvent, ce as pickerKeys, R as plainLink, F as recordingPlayer, I as recordingText, k as termCaretEvent, N as unlinkedMentions, L as unplayable };
package/lib/knowledge.js CHANGED
@@ -107,12 +107,6 @@ function N(e, t) {
107
107
  id: s.id,
108
108
  status: "decided"
109
109
  })
110
- }] : s.status === "added" ? [{
111
- label: n("confirm"),
112
- onClick: () => i.update.mutate({
113
- id: s.id,
114
- status: "decided"
115
- })
116
110
  }] : [],
117
111
  ...s.status === "superseded" ? [] : [{
118
112
  label: n("supersede"),
@@ -4,4 +4,10 @@ function t() {
4
4
  let t = e("agent");
5
5
  return (e) => t(e === "default" ? "permissionDefault" : e === "accept-edits" ? "permissionAcceptEdits" : e === "auto" ? "permissionAuto" : "permissionBypass");
6
6
  }
7
- export { t as usePermissionModeName };
7
+ var n = [
8
+ "default",
9
+ "accept-edits",
10
+ "auto",
11
+ "bypass"
12
+ ], r = (e, t) => n.indexOf(e) < n.indexOf(t), i = (e) => `tandem runner --permission-mode ${e}${e === "bypass" ? " --allow-bypass" : ""}`;
13
+ export { r as modeBelow, i as runnerModeCommand, t as usePermissionModeName };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.178.1",
3
+ "version": "0.179.1",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",