-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspec.tsx
More file actions
37 lines (35 loc) · 1.15 KB
/
spec.tsx
File metadata and controls
37 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { createReactInlineContentSpec } from "@blocknote/react";
import { InlineWorkPackageChip } from "./InlineWorkPackageChip";
import { linkToWorkPackage } from "../../services/openProjectApi";
export const openProjectWorkPackageInlineSpec = createReactInlineContentSpec(
{
type: "openProjectWorkPackageInline" as const,
propSchema: {
wpid: { default: "" },
instanceId: { default: "" },
size: { default: "s" },
},
content: "none",
},
{
render: ({ inlineContent, contentRef, editor }) => (
<InlineWorkPackageChip inlineContent={inlineContent} contentRef={contentRef} editor={editor}/>
),
toExternalHTML: ({ inlineContent }) => {
const { wpid, instanceId, size } = inlineContent.props;
if (!wpid || wpid.startsWith("pending:")) return <></>;
return (
<a
href={linkToWorkPackage(Number(wpid))}
target="_blank"
rel="noopener noreferrer"
data-inline-wp={wpid}
data-inline-wp-instance={instanceId}
data-inline-wp-size={size ?? "s"}
>
#{wpid}
</a>
);
},
}
);