@parallelworks/tandem-web 0.157.1 → 0.159.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.
@@ -6,86 +6,87 @@ import { DocButton as o } from "./DocButton.js";
6
6
  import { AttachmentFiles as s, AttachmentImage as c, DocLinkIcons as l, DocLinks as u, IssueMentions as d, KnowledgeTerms as f, LinkedIssues as p, PeopleMentions as m, TeamNames as h } from "./editorPlugins.js";
7
7
  import { DocLinkPicker as g } from "./DocLinkPicker.js";
8
8
  import { DocViewBlock as _ } from "./DocViewBlock.js";
9
- import { IssueListBlock as ee } from "./IssueListBlock.js";
10
- import { LinkCard as v } from "./LinkCard.js";
11
- import { MentionPicker as y } from "./MentionPicker.js";
12
- import { Diagrams as b, MathBlock as te, MathInline as ne } from "./mathDiagrams.js";
13
- import { SlashMenu as x } from "./SlashMenu.js";
14
- import { SubPages as S } from "./SubPages.js";
15
- import { MarkdownTable as C } from "./table.js";
16
- import { useEffect as w, useRef as T } from "react";
17
- import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
18
- import { CodeBlockLowlight as k } from "@tiptap/extension-code-block-lowlight";
19
- import { TaskItem as A, TaskList as j } from "@tiptap/extension-list";
20
- import { TableKit as M } from "@tiptap/extension-table";
21
- import { Placeholder as N } from "@tiptap/extensions";
22
- import { Markdown as P } from "@tiptap/markdown";
23
- import { EditorContent as F, useEditor as I } from "@tiptap/react";
24
- import L from "@tiptap/starter-kit";
25
- import re from "highlight.js/lib/languages/bash";
26
- import R from "highlight.js/lib/languages/css";
27
- import z from "highlight.js/lib/languages/diff";
28
- import B from "highlight.js/lib/languages/dockerfile";
29
- import V from "highlight.js/lib/languages/go";
30
- import H from "highlight.js/lib/languages/ini";
31
- import U from "highlight.js/lib/languages/javascript";
32
- import W from "highlight.js/lib/languages/json";
33
- import G from "highlight.js/lib/languages/markdown";
34
- import K from "highlight.js/lib/languages/python";
35
- import q from "highlight.js/lib/languages/rust";
36
- import J from "highlight.js/lib/languages/shell";
37
- import Y from "highlight.js/lib/languages/sql";
38
- import X from "highlight.js/lib/languages/typescript";
39
- import Z from "highlight.js/lib/languages/xml";
40
- import ie from "highlight.js/lib/languages/yaml";
41
- import { createLowlight as ae } from "lowlight";
9
+ import { FigmaEmbedBlock as v } from "./Figma.js";
10
+ import { IssueListBlock as y } from "./IssueListBlock.js";
11
+ import { LinkCard as b } from "./LinkCard.js";
12
+ import { MentionPicker as x } from "./MentionPicker.js";
13
+ import { Diagrams as ee, MathBlock as te, MathInline as ne } from "./mathDiagrams.js";
14
+ import { SlashMenu as S } from "./SlashMenu.js";
15
+ import { SubPages as C } from "./SubPages.js";
16
+ import { MarkdownTable as w } from "./table.js";
17
+ import { useEffect as T, useRef as E } from "react";
18
+ import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
19
+ import { CodeBlockLowlight as A } from "@tiptap/extension-code-block-lowlight";
20
+ import { TaskItem as j, TaskList as M } from "@tiptap/extension-list";
21
+ import { TableKit as N } from "@tiptap/extension-table";
22
+ import { Placeholder as P } from "@tiptap/extensions";
23
+ import { Markdown as F } from "@tiptap/markdown";
24
+ import { EditorContent as I, useEditor as L } from "@tiptap/react";
25
+ import re from "@tiptap/starter-kit";
26
+ import R from "highlight.js/lib/languages/bash";
27
+ import z from "highlight.js/lib/languages/css";
28
+ import B from "highlight.js/lib/languages/diff";
29
+ import V from "highlight.js/lib/languages/dockerfile";
30
+ import H from "highlight.js/lib/languages/go";
31
+ import U from "highlight.js/lib/languages/ini";
32
+ import W from "highlight.js/lib/languages/javascript";
33
+ import G from "highlight.js/lib/languages/json";
34
+ import K from "highlight.js/lib/languages/markdown";
35
+ import q from "highlight.js/lib/languages/python";
36
+ import J from "highlight.js/lib/languages/rust";
37
+ import Y from "highlight.js/lib/languages/shell";
38
+ import X from "highlight.js/lib/languages/sql";
39
+ import Z from "highlight.js/lib/languages/typescript";
40
+ import ie from "highlight.js/lib/languages/xml";
41
+ import ae from "highlight.js/lib/languages/yaml";
42
+ import { createLowlight as oe } from "lowlight";
42
43
  // src/components/Editor.tsx
43
- var oe = ae({
44
- bash: re,
45
- css: R,
46
- diff: z,
47
- dockerfile: B,
48
- go: V,
49
- ini: H,
50
- javascript: U,
51
- json: W,
52
- markdown: G,
53
- python: K,
54
- rust: q,
55
- shell: J,
56
- sql: Y,
57
- typescript: X,
58
- xml: Z,
59
- yaml: ie
44
+ var se = oe({
45
+ bash: R,
46
+ css: z,
47
+ diff: B,
48
+ dockerfile: V,
49
+ go: H,
50
+ ini: U,
51
+ javascript: W,
52
+ json: G,
53
+ markdown: K,
54
+ python: q,
55
+ rust: J,
56
+ shell: Y,
57
+ sql: X,
58
+ typescript: Z,
59
+ xml: ie,
60
+ yaml: ae
60
61
  });
61
- function Q({ editable: g = !0, placeholder: y = "", collaborative: x = !1 } = {}) {
62
+ function Q({ editable: g = !0, placeholder: x = "", collaborative: S = !1 } = {}) {
62
63
  return [
63
- L.configure({
64
+ re.configure({
64
65
  link: {
65
66
  openOnClick: !g,
66
67
  autolink: !0
67
68
  },
68
69
  codeBlock: !1,
69
70
  blockquote: !1,
70
- ...g && !x ? {} : { trailingNode: !1 },
71
- ...x ? { undoRedo: !1 } : {}
71
+ ...g && !S ? {} : { trailingNode: !1 },
72
+ ...S ? { undoRedo: !1 } : {}
72
73
  }),
73
- k.configure({ lowlight: oe }),
74
+ A.configure({ lowlight: se }),
74
75
  e,
75
- j,
76
- A.configure({ nested: !0 }),
76
+ M,
77
+ j.configure({ nested: !0 }),
77
78
  r,
78
- S,
79
+ C,
79
80
  n,
80
81
  t,
81
82
  i,
82
- M.configure({ table: !1 }),
83
- C.configure({
83
+ N.configure({ table: !1 }),
84
+ w.configure({
84
85
  resizable: !1,
85
86
  allowTableNodeSelection: !1
86
87
  }),
87
- N.configure({ placeholder: y }),
88
- P,
88
+ P.configure({ placeholder: x }),
89
+ F,
89
90
  f,
90
91
  u,
91
92
  l,
@@ -97,11 +98,12 @@ function Q({ editable: g = !0, placeholder: y = "", collaborative: x = !1 } = {}
97
98
  d,
98
99
  _,
99
100
  o,
101
+ b,
100
102
  v,
101
103
  ne,
102
104
  te,
103
- b,
104
105
  ee,
106
+ y,
105
107
  a
106
108
  ];
107
109
  }
@@ -120,8 +122,8 @@ function $(e) {
120
122
  }
121
123
  };
122
124
  }
123
- function se({ value: e, onChange: t, onSubmit: n, onBlur: r, onFocus: i, placeholder: a, editable: o = !0, autofocus: s = !1, className: c = "", label: l, onFiles: u, onEditor: d }) {
124
- let f = T({
125
+ function ce({ value: e, onChange: t, onSubmit: n, onBlur: r, onFocus: i, placeholder: a, editable: o = !0, autofocus: s = !1, className: c = "", label: l, onFiles: u, onEditor: d }) {
126
+ let f = E({
125
127
  onChange: t,
126
128
  onSubmit: n,
127
129
  onBlur: r,
@@ -133,9 +135,9 @@ function se({ value: e, onChange: t, onSubmit: n, onBlur: r, onFocus: i, placeho
133
135
  onBlur: r,
134
136
  onFocus: i
135
137
  };
136
- let p = T(u);
138
+ let p = E(u);
137
139
  p.current = u;
138
- let m = I({
140
+ let m = L({
139
141
  extensions: Q({
140
142
  editable: o,
141
143
  placeholder: a ?? ""
@@ -162,23 +164,23 @@ function se({ value: e, onChange: t, onSubmit: n, onBlur: r, onFocus: i, placeho
162
164
  onBlur: ({ editor: e }) => f.current.onBlur?.(e.getMarkdown()),
163
165
  onFocus: () => f.current.onFocus?.()
164
166
  });
165
- w(() => {
167
+ T(() => {
166
168
  m && !m.isFocused && m.getMarkdown() !== e && m.commands.setContent(e, {
167
169
  contentType: "markdown",
168
170
  emitUpdate: !1
169
171
  });
170
- }, [m, e]), w(() => {
172
+ }, [m, e]), T(() => {
171
173
  m?.setEditable(o);
172
174
  }, [m, o]);
173
- let h = T(d);
174
- return h.current = d, w(() => (h.current?.(m), () => h.current?.(null)), [m]), /* @__PURE__ */ O(E, { children: [
175
- /* @__PURE__ */ D(F, { editor: m }),
176
- o && /* @__PURE__ */ D(g, { editor: m }),
177
- o && /* @__PURE__ */ D(x, {
175
+ let h = E(d);
176
+ return h.current = d, T(() => (h.current?.(m), () => h.current?.(null)), [m]), /* @__PURE__ */ k(D, { children: [
177
+ /* @__PURE__ */ O(I, { editor: m }),
178
+ o && /* @__PURE__ */ O(g, { editor: m }),
179
+ o && /* @__PURE__ */ O(S, {
178
180
  editor: m,
179
181
  onFiles: p
180
182
  }),
181
- o && /* @__PURE__ */ D(y, { editor: m })
183
+ o && /* @__PURE__ */ O(x, { editor: m })
182
184
  ] });
183
185
  }
184
- export { se as Editor, Q as contentExtensions, $ as fileHandlers };
186
+ export { ce as Editor, Q as contentExtensions, $ as fileHandlers };
@@ -0,0 +1,215 @@
1
+ import { figmaPreviewQuery as e, issueFigmaQuery as t } from "../api/queries.js";
2
+ import { externalUrl as n } from "../lib/externalUrl.js";
3
+ import { useTime as r } from "../lib/time.js";
4
+ import { Card as i, Input as a, buttonClasses as o } from "@parallelworks/ui";
5
+ import { useParams as s } from "@tanstack/react-router";
6
+ import { useState as c } from "react";
7
+ import { useTranslations as l } from "use-intl";
8
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
+ import { useQuery as p } from "@tanstack/react-query";
10
+ import { Node as m, NodeViewWrapper as h, ReactNodeViewRenderer as g, mergeAttributes as _ } from "@tiptap/react";
11
+ // src/components/Figma.tsx
12
+ var v = /^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[^/\s?#]+/, y = (e) => v.test(e);
13
+ function b(e) {
14
+ return e.nodeName && e.fileName ? `${e.nodeName} · ${e.fileName}` : e.nodeName || e.fileName || "";
15
+ }
16
+ function x({ url: t }) {
17
+ let i = l("figma"), a = r(), { workspace: c = "" } = s({ strict: !1 }), { data: m, isPending: h } = p({
18
+ ...e(c, t),
19
+ enabled: !!c
20
+ }), g = m?.design, _ = n(t);
21
+ return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f("a", {
22
+ href: _,
23
+ target: "_blank",
24
+ rel: "noreferrer noopener",
25
+ className: "link-card-link",
26
+ "data-card-ui": !0,
27
+ children: [g?.access && g.thumbnail && /* @__PURE__ */ d("img", {
28
+ src: g.thumbnail,
29
+ alt: "",
30
+ className: "h-20 w-32 shrink-0 rounded-sm bg-muted object-contain"
31
+ }), /* @__PURE__ */ f("span", {
32
+ className: "min-w-0 flex-1",
33
+ children: [
34
+ /* @__PURE__ */ d("span", {
35
+ className: "link-card-title",
36
+ children: g?.access ? b(g) : i(h ? "reading" : "file")
37
+ }),
38
+ /* @__PURE__ */ d("span", {
39
+ className: "link-card-description",
40
+ children: g?.access ? g.lastModified && (g.editedBy ? i("editedBy", {
41
+ when: a.relative(g.lastModified),
42
+ who: g.editedBy
43
+ }) : i("edited", { when: a.relative(g.lastModified) })) : m?.enabled && !m.connected ? i("connectToPreview") : m?.connected && g && !g.access ? i("noAccess") : t
44
+ }),
45
+ /* @__PURE__ */ d("span", {
46
+ className: "link-card-site",
47
+ children: /* @__PURE__ */ d("span", {
48
+ className: "truncate",
49
+ children: i("site")
50
+ })
51
+ })
52
+ ]
53
+ })]
54
+ }), m?.enabled && !m.connected && m.linkUrl && /* @__PURE__ */ d("a", {
55
+ "data-card-ui": !0,
56
+ href: m.linkUrl,
57
+ className: `${o({
58
+ variant: "outline",
59
+ size: "sm"
60
+ })} mt-1.5`,
61
+ children: i("connect")
62
+ })] });
63
+ }
64
+ function S(e) {
65
+ return `https://www.figma.com/embed?embed_host=tandem&url=${encodeURIComponent(e)}`;
66
+ }
67
+ var C = /^:::figma[ \t]+(https:\/\/\S+)[ \t]*\n[ \t]*:::[ \t]*(?:\n|$)/, w = m.create({
68
+ name: "figmaEmbed",
69
+ group: "block",
70
+ atom: !0,
71
+ draggable: !0,
72
+ addAttributes: () => ({ url: { default: "" } }),
73
+ parseHTML: () => [{ tag: "div[data-figma-embed]" }],
74
+ renderHTML: ({ node: e, HTMLAttributes: t }) => [
75
+ "div",
76
+ _(t, { "data-figma-embed": "" }),
77
+ [
78
+ "a",
79
+ { href: e.attrs.url },
80
+ e.attrs.url
81
+ ]
82
+ ],
83
+ addNodeView: () => g(T, { stopEvent: ({ event: e }) => e.target instanceof Element && !!e.target.closest("[data-embed-ui]") }),
84
+ markdownTokenName: "figmaEmbed",
85
+ markdownTokenizer: {
86
+ name: "figmaEmbed",
87
+ level: "block",
88
+ start: (e) => e.search(/^:::figma/m),
89
+ tokenize: (e) => {
90
+ let t = C.exec(e);
91
+ return t ? {
92
+ type: "figmaEmbed",
93
+ raw: t[0],
94
+ text: t[1] ?? ""
95
+ } : void 0;
96
+ }
97
+ },
98
+ parseMarkdown: (e, t) => t.createNode("figmaEmbed", { url: e.text ?? "" }),
99
+ renderMarkdown: (e) => `:::figma ${String(e.attrs?.url ?? "")}\n:::`
100
+ });
101
+ function T({ node: e, editor: t, updateAttributes: n }) {
102
+ let r = l("figma"), [i, s] = c(""), u = String(e.attrs.url ?? "");
103
+ return !u || !y(u) ? /* @__PURE__ */ d(h, {
104
+ className: "link-card link-card-empty",
105
+ contentEditable: !1,
106
+ children: /* @__PURE__ */ f("form", {
107
+ "data-embed-ui": !0,
108
+ className: "flex flex-wrap items-center gap-2",
109
+ onSubmit: (e) => {
110
+ e.preventDefault(), y(i.trim()) && n({ url: i.trim() });
111
+ },
112
+ children: [/* @__PURE__ */ d(a, {
113
+ value: i,
114
+ onChange: (e) => s(e.target.value),
115
+ placeholder: "https://www.figma.com/design/…",
116
+ "aria-label": r("embedAddress"),
117
+ className: "min-w-0 flex-1",
118
+ disabled: !t.isEditable
119
+ }), /* @__PURE__ */ d("button", {
120
+ type: "submit",
121
+ className: o({
122
+ variant: "primary",
123
+ size: "sm"
124
+ }),
125
+ disabled: !y(i.trim()),
126
+ children: r("embed")
127
+ })]
128
+ })
129
+ }) : /* @__PURE__ */ d(h, {
130
+ className: "not-prose my-2",
131
+ contentEditable: !1,
132
+ "data-drag-handle": !0,
133
+ children: /* @__PURE__ */ d("div", {
134
+ "data-embed-ui": !0,
135
+ className: "overflow-hidden rounded-md border border-border",
136
+ children: /* @__PURE__ */ d("iframe", {
137
+ title: r("embedTitle"),
138
+ src: S(u),
139
+ className: "block aspect-video w-full",
140
+ allowFullScreen: !0,
141
+ loading: "lazy"
142
+ })
143
+ })
144
+ });
145
+ }
146
+ function E({ workspace: e, identifier: a }) {
147
+ let o = l("figma"), s = r(), { data: c } = p(t(e, a));
148
+ return !c?.enabled || c.designs.length === 0 ? null : /* @__PURE__ */ f("section", {
149
+ className: "mt-6",
150
+ "aria-label": o("issueSection"),
151
+ children: [
152
+ /* @__PURE__ */ f("h2", {
153
+ className: "text-xs font-medium text-muted-foreground",
154
+ children: [o("issueSection"), /* @__PURE__ */ d("span", {
155
+ className: "ml-1.5",
156
+ children: c.designs.length
157
+ })]
158
+ }),
159
+ !c.connected && /* @__PURE__ */ f("p", {
160
+ className: "mt-1 text-xs text-muted-foreground",
161
+ children: [
162
+ o("connectToPreview"),
163
+ " ",
164
+ c.linkUrl && /* @__PURE__ */ d("a", {
165
+ href: c.linkUrl,
166
+ className: "text-primary hover:underline",
167
+ children: o("connect")
168
+ })
169
+ ]
170
+ }),
171
+ /* @__PURE__ */ d(i, {
172
+ size: "fill",
173
+ padding: "none",
174
+ divided: !0,
175
+ interactive: !1,
176
+ render: /* @__PURE__ */ d("ul", {}),
177
+ className: "mt-1",
178
+ children: c.designs.map((e) => /* @__PURE__ */ d("li", {
179
+ className: "hover:bg-muted",
180
+ children: /* @__PURE__ */ f("a", {
181
+ href: n(e.url),
182
+ target: "_blank",
183
+ rel: "noopener noreferrer",
184
+ className: "flex min-w-0 items-center gap-3 px-3 py-2 text-sm",
185
+ children: [
186
+ e.access && e.thumbnail ? /* @__PURE__ */ d("img", {
187
+ src: e.thumbnail,
188
+ alt: "",
189
+ className: "h-10 w-16 shrink-0 rounded-sm bg-muted object-contain"
190
+ }) : /* @__PURE__ */ d("span", { className: "h-10 w-16 shrink-0 rounded-sm bg-muted" }),
191
+ /* @__PURE__ */ f("span", {
192
+ className: "min-w-0 flex-1",
193
+ children: [/* @__PURE__ */ d("span", {
194
+ className: "block truncate",
195
+ children: e.access ? b(e) : c.connected ? o("noAccess") : o("file")
196
+ }), e.access && e.lastModified && /* @__PURE__ */ d("span", {
197
+ className: "block truncate text-xs text-muted-foreground",
198
+ children: e.editedBy ? o("editedBy", {
199
+ when: s.relative(e.lastModified),
200
+ who: e.editedBy
201
+ }) : o("edited", { when: s.relative(e.lastModified) })
202
+ })]
203
+ }),
204
+ e.changed && /* @__PURE__ */ d("span", {
205
+ className: "shrink-0 rounded-sm bg-warning/15 px-1.5 py-0.5 text-xs text-warning",
206
+ children: o("changed")
207
+ })
208
+ ]
209
+ })
210
+ }, e.url))
211
+ })
212
+ ]
213
+ });
214
+ }
215
+ export { x as FigmaCard, w as FigmaEmbedBlock, E as IssueDesigns, y as isFigma };
@@ -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 { Button as r, ErrorText as i, Input as a } from "@parallelworks/ui";
4
- import { useParams as o } from "@tanstack/react-router";
5
- import { useEffect as s, useState as c } from "react";
6
- import { useErrorMessage as l } from "@parallelworks/problem/react";
7
- import { useTranslations as u } from "use-intl";
8
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
- import { useMutation as p } from "@tanstack/react-query";
10
- import { GlobeIcon as m } from "@parallelworks/ui/icons";
11
- import { Node as h, NodeViewWrapper as g, ReactNodeViewRenderer as _, mergeAttributes as v } from "@tiptap/react";
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 y = /^<(https?:\/\/[^\s<>]+)>[ \t]*(?:\n|$)/, b = h.create({
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
- v(t, { "data-link-card": "" }),
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: () => _(S, { stopEvent: ({ event: e }) => e.target instanceof Element && !!e.target.closest("[data-card-ui]") }),
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(/^<https?:\/\//m),
42
+ start: (e) => e.search(/^(?:<https?:\/\/|https:\/\/(?:www\.)?figma\.com\/)/m),
42
43
  tokenize: (e) => {
43
- let t = y.exec(e);
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 x(e) {
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 S({ node: h, updateAttributes: _, editor: v }) {
73
- let y = u("linkCard"), b = l(), { workspace: x = "" } = o({ strict: !1 }), S = String(h.attrs.url ?? ""), C = String(h.attrs.title ?? ""), [w, T] = c(""), E = p({
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: x } },
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
- }), D = !!S && !C && v.isEditable && !!x, { mutate: O, isIdle: k } = E;
86
- if (s(() => {
87
- D && k && O(S);
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
- O,
92
- S
93
- ]), !S) return /* @__PURE__ */ d(g, {
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__ */ f("form", {
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(), w.trim() && E.mutate(w.trim());
101
+ e.preventDefault(), E.trim() && O.mutate(E.trim());
101
102
  },
102
103
  children: [
103
- /* @__PURE__ */ d(a, {
104
- value: w,
105
- onChange: (e) => T(e.target.value),
104
+ /* @__PURE__ */ p(s, {
105
+ value: E,
106
+ onChange: (e) => D(e.target.value),
106
107
  placeholder: "https://",
107
- "aria-label": y("address"),
108
+ "aria-label": x("address"),
108
109
  className: "min-w-0 flex-1",
109
- disabled: !v.isEditable
110
+ disabled: !b.isEditable
110
111
  }),
111
- /* @__PURE__ */ d(r, {
112
+ /* @__PURE__ */ p(a, {
112
113
  type: "submit",
113
114
  size: "sm",
114
115
  variant: "primary",
115
- loading: E.isPending,
116
- children: y("make")
116
+ loading: O.isPending,
117
+ children: x("make")
117
118
  }),
118
- E.error && /* @__PURE__ */ d(i, {
119
+ O.error && /* @__PURE__ */ p(o, {
119
120
  className: "w-full",
120
- children: b(E.error)
121
+ children: S(O.error)
121
122
  })
122
123
  ]
123
124
  })
124
125
  });
125
- let A = n(S), j = (() => {
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(S).host;
134
+ return new URL(w).host;
128
135
  } catch {
129
- return S;
136
+ return w;
130
137
  }
131
- })(), M = String(h.attrs.icon ?? "");
132
- return /* @__PURE__ */ d(g, {
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__ */ d("a", {
137
- href: A,
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__ */ f("span", {
149
+ children: /* @__PURE__ */ m("span", {
143
150
  className: "min-w-0 flex-1",
144
151
  children: [
145
- /* @__PURE__ */ d("span", {
152
+ /* @__PURE__ */ p("span", {
146
153
  className: "link-card-title",
147
- children: C || (E.isPending ? y("reading") : j)
154
+ children: T || (O.isPending ? x("reading") : N)
148
155
  }),
149
- h.attrs.description && /* @__PURE__ */ d("span", {
156
+ _.attrs.description && /* @__PURE__ */ p("span", {
150
157
  className: "link-card-description",
151
- children: String(h.attrs.description)
158
+ children: String(_.attrs.description)
152
159
  }),
153
- /* @__PURE__ */ f("span", {
160
+ /* @__PURE__ */ m("span", {
154
161
  className: "link-card-site",
155
- children: [M.startsWith("data:image/") ? /* @__PURE__ */ d("img", {
156
- src: M,
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__ */ d(m, { className: "size-4 shrink-0" }), /* @__PURE__ */ d("span", {
166
+ }) : /* @__PURE__ */ p(g, { className: "size-4 shrink-0" }), /* @__PURE__ */ p("span", {
160
167
  className: "truncate",
161
- children: h.attrs.siteName || j
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 { b as LinkCard, x as insertLinkCard };
176
+ export { C as LinkCard, w as insertLinkCard };
@@ -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),