@blocklet/editor 2.5.16 → 2.5.18

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.
@@ -5,7 +5,7 @@ export interface PostInfo {
5
5
  id: string;
6
6
  title: string;
7
7
  link: string;
8
- type: 'post' | 'blog' | 'doc';
8
+ type: 'post' | 'blog' | 'doc' | 'task';
9
9
  boardId: string;
10
10
  external?: boolean;
11
11
  }
@@ -36,6 +36,8 @@ function PostLinkComponent(postInfo) {
36
36
  ? joinURL(window.blocklet.prefix, postInfo.boardId, locale, postInfo.id)
37
37
  : joinURL(discussKitMountPoint, '/docs', postInfo.boardId, locale, postInfo.id);
38
38
  break;
39
+ case 'task':
40
+ break;
39
41
  default:
40
42
  exhaustiveGuard(postInfo.type);
41
43
  }
@@ -50,7 +52,7 @@ function PostLinkComponent(postInfo) {
50
52
  display: 'flex',
51
53
  alignItems: 'center',
52
54
  '&:hover': { bgcolor: 'grey.200', boxShadow: `0 0 0 3px ${palette.grey[200]}`, borderRadius: 1 },
53
- }, children: [_jsx(Box, { component: "i", className: "iconify", "data-icon": "ri:file-list-2-line", sx: { flex: '0 0 auto', width: 18, height: 18, mr: 0.25, color: 'grey.600' } }), _jsx(Box, { component: "a", href: link, sx: {
55
+ }, children: [_jsx(Box, { component: "i", className: "iconify", "data-icon": postInfo.type === 'task' ? 'lucide:list-todo' : 'ri:file-list-2-line', sx: { flex: '0 0 auto', width: 18, height: 18, mr: 0.25, color: 'grey.600' } }), _jsx(Box, { component: "a", href: link, sx: {
54
56
  display: 'inline-block',
55
57
  overflow: 'hidden',
56
58
  textOverflow: 'ellipsis',
@@ -2,7 +2,7 @@ import { LexicalCommand, LexicalEditor } from 'lexical';
2
2
  import { type JSX } from 'react';
3
3
  import { AutoEmbedOption } from '@lexical/react/LexicalAutoEmbedPlugin';
4
4
  import { EditorConfig } from '../../config';
5
- type PostType = 'post' | 'blog' | 'doc';
5
+ type PostType = 'post' | 'blog' | 'doc' | 'task';
6
6
  type Payload = {
7
7
  id: string;
8
8
  type: PostType;
@@ -8,6 +8,7 @@ import { joinURL } from 'ufo';
8
8
  import { $createPostLinkNode, PostLinkNode } from './PostLinkNode';
9
9
  import { $createEmojiNode } from '../../main/nodes/EmojiNode';
10
10
  import { $getLinkNode, getBlockletMountPointInfo, isSameHost } from '../utils';
11
+ const taskMountPoint = window.blocklet.componentMountPoints?.find((x) => x.did === 'z2qa4xMVAJxvA1GgfnPpMFqhdSjU9pe37NCiY')?.mountPoint;
11
12
  const paths = [
12
13
  { path: '/discussions/:id', type: 'post' },
13
14
  { path: '/blog/:locale/:id', type: 'blog' },
@@ -18,10 +19,19 @@ const paths = [
18
19
  },
19
20
  { path: '/docs/:board/:locale/:id', type: 'doc' },
20
21
  ];
22
+ if (taskMountPoint) {
23
+ paths.push({ path: joinURL(taskMountPoint, '/task/:id'), type: 'task' });
24
+ }
21
25
  const discussKitMountPoint = getBlockletMountPointInfo('did-comments')?.mountPoint;
22
- const fetchPostInfo = async ({ id, url, }) => {
26
+ const fetchPostInfo = async ({ id, url, type, }) => {
23
27
  try {
24
28
  const urlObj = new URL(url);
29
+ if (type === 'task' && taskMountPoint) {
30
+ const taskRes = await fetch(joinURL(urlObj.origin, taskMountPoint, `/api/task/item/${id}`)).then((res) => res.json());
31
+ if (taskRes.data.task) {
32
+ return { id, title: taskRes.data.task.title, boardId: '', external: true };
33
+ }
34
+ }
25
35
  if (isSameHost(urlObj)) {
26
36
  const res = await fetch(joinURL(discussKitMountPoint, `/api/embed/posts/slug/${id}`));
27
37
  return await res.json();
@@ -82,10 +92,10 @@ export const createPostLinkAutoEmbedOption = (editor, editorConfig) => {
82
92
  $insertNodes([loadingNode, whitespace]);
83
93
  try {
84
94
  const postInfo = await fetchPostInfo(parsed);
95
+ if (!postInfo) {
96
+ throw new Error('PostLinkEmbedPlugin: postInfo not found');
97
+ }
85
98
  editor.update(() => {
86
- if (!postInfo) {
87
- throw new Error('PostLinkEmbedPlugin: postInfo not found');
88
- }
89
99
  loadingNode.remove();
90
100
  editor.dispatchCommand(INSERT_POST_LINK_COMMAND, { ...postInfo, type: parsed.type, url });
91
101
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/editor",
3
- "version": "2.5.16",
3
+ "version": "2.5.18",
4
4
  "main": "lib/index.js",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -73,7 +73,7 @@
73
73
  "ufo": "^1.5.4",
74
74
  "url-join": "^4.0.1",
75
75
  "zustand": "^4.5.5",
76
- "@blocklet/pdf": "2.5.16"
76
+ "@blocklet/pdf": "2.5.18"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@babel/core": "^7.25.2",