@parallelworks/tandem-web 0.157.1 → 0.158.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 +20 -0
- package/_virtual/_virtual_i18n/es/common.js +20 -0
- package/_virtual/_virtual_i18n/ja/common.js +20 -0
- package/_virtual/_virtual_i18n/ko/common.js +20 -0
- package/_virtual/_virtual_i18n/zh/common.js +20 -0
- package/api/queries.js +28 -1
- package/components/Editor.js +78 -76
- package/components/Figma.js +215 -0
- package/components/LinkCard.js +63 -56
- package/components/SlashMenu.js +2 -0
- package/package.json +1 -1
- package/routes/_workspace/issues/_identifier2.js +167 -162
package/components/LinkCard.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { api as e, unwrap as t } from "../api/client.js";
|
|
2
2
|
import { externalUrl as n } from "../lib/externalUrl.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
3
|
+
import { FigmaCard as r, isFigma as i } from "./Figma.js";
|
|
4
|
+
import { Button as a, ErrorText as o, Input as s } from "@parallelworks/ui";
|
|
5
|
+
import { useParams as c } from "@tanstack/react-router";
|
|
6
|
+
import { useEffect as l, useState as u } from "react";
|
|
7
|
+
import { useErrorMessage as d } from "@parallelworks/problem/react";
|
|
8
|
+
import { useTranslations as f } from "use-intl";
|
|
9
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
|
+
import { useMutation as h } from "@tanstack/react-query";
|
|
11
|
+
import { GlobeIcon as g } from "@parallelworks/ui/icons";
|
|
12
|
+
import { Node as _, NodeViewWrapper as v, ReactNodeViewRenderer as y, mergeAttributes as b } from "@tiptap/react";
|
|
12
13
|
// src/components/LinkCard.tsx
|
|
13
|
-
var
|
|
14
|
+
var x = /^<(https?:\/\/[^\s<>]+)>[ \t]*(?:\n|$)/, S = /^(https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[^\s<>]+)[ \t]*(?:\n|$)/, C = _.create({
|
|
14
15
|
name: "linkCard",
|
|
15
16
|
group: "block",
|
|
16
17
|
atom: !0,
|
|
@@ -26,21 +27,21 @@ var y = /^<(https?:\/\/[^\s<>]+)>[ \t]*(?:\n|$)/, b = h.create({
|
|
|
26
27
|
parseHTML: () => [{ tag: "div[data-link-card]" }],
|
|
27
28
|
renderHTML: ({ node: e, HTMLAttributes: t }) => [
|
|
28
29
|
"div",
|
|
29
|
-
|
|
30
|
+
b(t, { "data-link-card": "" }),
|
|
30
31
|
[
|
|
31
32
|
"a",
|
|
32
33
|
{ href: e.attrs.url },
|
|
33
34
|
e.attrs.title || e.attrs.url
|
|
34
35
|
]
|
|
35
36
|
],
|
|
36
|
-
addNodeView: () =>
|
|
37
|
+
addNodeView: () => y(T, { stopEvent: ({ event: e }) => e.target instanceof Element && !!e.target.closest("[data-card-ui]") }),
|
|
37
38
|
markdownTokenName: "linkCard",
|
|
38
39
|
markdownTokenizer: {
|
|
39
40
|
name: "linkCard",
|
|
40
41
|
level: "block",
|
|
41
|
-
start: (e) => e.search(
|
|
42
|
+
start: (e) => e.search(/^(?:<https?:\/\/|https:\/\/(?:www\.)?figma\.com\/)/m),
|
|
42
43
|
tokenize: (e) => {
|
|
43
|
-
let t =
|
|
44
|
+
let t = x.exec(e) ?? S.exec(e);
|
|
44
45
|
return t ? {
|
|
45
46
|
type: "linkCard",
|
|
46
47
|
raw: t[0],
|
|
@@ -51,7 +52,7 @@ var y = /^<(https?:\/\/[^\s<>]+)>[ \t]*(?:\n|$)/, b = h.create({
|
|
|
51
52
|
parseMarkdown: (e, t) => t.createNode("linkCard", { url: e.text ?? "" }),
|
|
52
53
|
renderMarkdown: (e) => `<${String(e.attrs?.url ?? "")}>`
|
|
53
54
|
});
|
|
54
|
-
function
|
|
55
|
+
function w(e) {
|
|
55
56
|
let { $from: t } = e.state.selection, n = t.parent, r = "";
|
|
56
57
|
if (n.type.name === "paragraph" && n.childCount === 1) {
|
|
57
58
|
let e = n.firstChild, t = e?.marks.find((e) => e.type.name === "link");
|
|
@@ -69,96 +70,102 @@ function x(e) {
|
|
|
69
70
|
}, i).run();
|
|
70
71
|
} else e.chain().focus().insertContent(i).run();
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
-
let
|
|
73
|
+
function T({ node: _, updateAttributes: y, editor: b }) {
|
|
74
|
+
let x = f("linkCard"), S = d(), { workspace: C = "" } = c({ strict: !1 }), w = String(_.attrs.url ?? ""), T = String(_.attrs.title ?? ""), [E, D] = u(""), O = h({
|
|
74
75
|
mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/link-previews", {
|
|
75
|
-
params: { path: { workspace:
|
|
76
|
+
params: { path: { workspace: C } },
|
|
76
77
|
body: { url: n }
|
|
77
78
|
})),
|
|
78
|
-
onSuccess: (e) =>
|
|
79
|
+
onSuccess: (e) => y({
|
|
79
80
|
url: e.url,
|
|
80
81
|
title: e.title,
|
|
81
82
|
description: e.description ?? "",
|
|
82
83
|
siteName: e.siteName ?? "",
|
|
83
84
|
icon: e.icon ?? ""
|
|
84
85
|
})
|
|
85
|
-
}),
|
|
86
|
-
if (
|
|
87
|
-
|
|
86
|
+
}), k = !!w && !T && b.isEditable && !!C && !i(w), { mutate: A, isIdle: j } = O;
|
|
87
|
+
if (l(() => {
|
|
88
|
+
k && j && A(w);
|
|
88
89
|
}, [
|
|
89
|
-
D,
|
|
90
90
|
k,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
j,
|
|
92
|
+
A,
|
|
93
|
+
w
|
|
94
|
+
]), !w) return /* @__PURE__ */ p(v, {
|
|
94
95
|
className: "link-card link-card-empty",
|
|
95
96
|
contentEditable: !1,
|
|
96
|
-
children: /* @__PURE__ */
|
|
97
|
+
children: /* @__PURE__ */ m("form", {
|
|
97
98
|
"data-card-ui": !0,
|
|
98
99
|
className: "flex flex-wrap items-center gap-2",
|
|
99
100
|
onSubmit: (e) => {
|
|
100
|
-
e.preventDefault(),
|
|
101
|
+
e.preventDefault(), E.trim() && O.mutate(E.trim());
|
|
101
102
|
},
|
|
102
103
|
children: [
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
value:
|
|
105
|
-
onChange: (e) =>
|
|
104
|
+
/* @__PURE__ */ p(s, {
|
|
105
|
+
value: E,
|
|
106
|
+
onChange: (e) => D(e.target.value),
|
|
106
107
|
placeholder: "https://",
|
|
107
|
-
"aria-label":
|
|
108
|
+
"aria-label": x("address"),
|
|
108
109
|
className: "min-w-0 flex-1",
|
|
109
|
-
disabled: !
|
|
110
|
+
disabled: !b.isEditable
|
|
110
111
|
}),
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ p(a, {
|
|
112
113
|
type: "submit",
|
|
113
114
|
size: "sm",
|
|
114
115
|
variant: "primary",
|
|
115
|
-
loading:
|
|
116
|
-
children:
|
|
116
|
+
loading: O.isPending,
|
|
117
|
+
children: x("make")
|
|
117
118
|
}),
|
|
118
|
-
|
|
119
|
+
O.error && /* @__PURE__ */ p(o, {
|
|
119
120
|
className: "w-full",
|
|
120
|
-
children:
|
|
121
|
+
children: S(O.error)
|
|
121
122
|
})
|
|
122
123
|
]
|
|
123
124
|
})
|
|
124
125
|
});
|
|
125
|
-
|
|
126
|
+
if (i(w)) return /* @__PURE__ */ p(v, {
|
|
127
|
+
className: "link-card",
|
|
128
|
+
contentEditable: !1,
|
|
129
|
+
"data-drag-handle": !0,
|
|
130
|
+
children: /* @__PURE__ */ p(r, { url: w })
|
|
131
|
+
});
|
|
132
|
+
let M = n(w), N = (() => {
|
|
126
133
|
try {
|
|
127
|
-
return new URL(
|
|
134
|
+
return new URL(w).host;
|
|
128
135
|
} catch {
|
|
129
|
-
return
|
|
136
|
+
return w;
|
|
130
137
|
}
|
|
131
|
-
})(),
|
|
132
|
-
return /* @__PURE__ */
|
|
138
|
+
})(), P = String(_.attrs.icon ?? "");
|
|
139
|
+
return /* @__PURE__ */ p(v, {
|
|
133
140
|
className: "link-card",
|
|
134
141
|
contentEditable: !1,
|
|
135
142
|
"data-drag-handle": !0,
|
|
136
|
-
children: /* @__PURE__ */
|
|
137
|
-
href:
|
|
143
|
+
children: /* @__PURE__ */ p("a", {
|
|
144
|
+
href: M,
|
|
138
145
|
target: "_blank",
|
|
139
146
|
rel: "noreferrer noopener",
|
|
140
147
|
className: "link-card-link",
|
|
141
148
|
"data-card-ui": !0,
|
|
142
|
-
children: /* @__PURE__ */
|
|
149
|
+
children: /* @__PURE__ */ m("span", {
|
|
143
150
|
className: "min-w-0 flex-1",
|
|
144
151
|
children: [
|
|
145
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ p("span", {
|
|
146
153
|
className: "link-card-title",
|
|
147
|
-
children:
|
|
154
|
+
children: T || (O.isPending ? x("reading") : N)
|
|
148
155
|
}),
|
|
149
|
-
|
|
156
|
+
_.attrs.description && /* @__PURE__ */ p("span", {
|
|
150
157
|
className: "link-card-description",
|
|
151
|
-
children: String(
|
|
158
|
+
children: String(_.attrs.description)
|
|
152
159
|
}),
|
|
153
|
-
/* @__PURE__ */
|
|
160
|
+
/* @__PURE__ */ m("span", {
|
|
154
161
|
className: "link-card-site",
|
|
155
|
-
children: [
|
|
156
|
-
src:
|
|
162
|
+
children: [P.startsWith("data:image/") ? /* @__PURE__ */ p("img", {
|
|
163
|
+
src: P,
|
|
157
164
|
alt: "",
|
|
158
165
|
className: "size-4 shrink-0 rounded-sm"
|
|
159
|
-
}) : /* @__PURE__ */
|
|
166
|
+
}) : /* @__PURE__ */ p(g, { className: "size-4 shrink-0" }), /* @__PURE__ */ p("span", {
|
|
160
167
|
className: "truncate",
|
|
161
|
-
children:
|
|
168
|
+
children: _.attrs.siteName || N
|
|
162
169
|
})]
|
|
163
170
|
})
|
|
164
171
|
]
|
|
@@ -166,4 +173,4 @@ function S({ node: h, updateAttributes: _, editor: v }) {
|
|
|
166
173
|
})
|
|
167
174
|
});
|
|
168
175
|
}
|
|
169
|
-
export {
|
|
176
|
+
export { C as LinkCard, w as insertLinkCard };
|
package/components/SlashMenu.js
CHANGED
|
@@ -50,6 +50,7 @@ var w = {
|
|
|
50
50
|
mathBlock: "∑",
|
|
51
51
|
mathInline: "√",
|
|
52
52
|
linkCard: "↗",
|
|
53
|
+
figma: "◈",
|
|
53
54
|
toggle: "▸",
|
|
54
55
|
divider: "—",
|
|
55
56
|
columns2: "▥",
|
|
@@ -93,6 +94,7 @@ var w = {
|
|
|
93
94
|
mathBlock: (e) => e.insertContent({ type: "mathBlock" }),
|
|
94
95
|
mathInline: (e) => e.insertContent({ type: "mathInline" }),
|
|
95
96
|
linkCard: (e) => e,
|
|
97
|
+
figma: (e) => e.insertContent({ type: "figmaEmbed" }),
|
|
96
98
|
toggle: (e) => e.setDetails(),
|
|
97
99
|
divider: (e) => e.setHorizontalRule(),
|
|
98
100
|
columns2: (e) => s(e, 2),
|