@lark-apaas/coding-template-nestjs-react-fullstack 0.1.55-alpha.20261030035108 → 0.1.55-alpha.20261030081308
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/package.json +1 -1
- package/template/client/src/components/business-ui/README.md +1 -1
- package/template/client/src/components/business-ui/comment/README.md +54 -16
- package/template/client/src/components/business-ui/comment/comment-content.tsx +3 -7
- package/template/client/src/components/business-ui/comment/comment-input.tsx +468 -123
- package/template/client/src/components/business-ui/comment/comment-provider.tsx +175 -2
- package/template/client/src/components/business-ui/comment/content.ts +8 -76
- package/template/client/src/components/business-ui/comment/dom-editor.ts +4 -3
- package/template/client/src/components/business-ui/comment/image-attachments.tsx +1 -0
- package/template/client/src/components/business-ui/comment/mention-provider.tsx +97 -2
- package/template/client/src/components/business-ui/comment/mention-suggestions.tsx +103 -4
- package/template/client/src/components/business-ui/comment/mention-view.tsx +171 -0
- package/template/client/src/components/business-ui/comment/types.ts +0 -5
- package/template/client/src/components/business-ui/comment/app-source.ts +0 -175
- package/template/client/src/components/business-ui/comment/document-icon.tsx +0 -104
- package/template/client/src/components/business-ui/comment/document-icons.ts +0 -19
- package/template/client/src/components/business-ui/comment/editor.tsx +0 -496
- package/template/client/src/components/business-ui/comment/entity-store.ts +0 -97
- package/template/client/src/components/business-ui/comment/mention-appearance.ts +0 -35
- package/template/client/src/components/business-ui/comment/use-mention-search.ts +0 -107
package/package.json
CHANGED
|
@@ -522,7 +522,7 @@ function BasicExample() {
|
|
|
522
522
|
|
|
523
523
|
`comment/comment-content.tsx` 提供不依赖 Tiptap 的只读展示,配合 `comment/mention-provider.tsx` 批量补全人员和文档信息。
|
|
524
524
|
|
|
525
|
-
评论输入框已内置。从 `@/components/business-ui/comment/comment-input` 直接导入 `CommentInput`,组件提供 getContent/clear/setEditable/focus ref API 和 onSubmitRequest
|
|
525
|
+
评论输入框已内置。从 `@/components/business-ui/comment/comment-input` 直接导入 `CommentInput`,组件提供 getContent/clear/setEditable/focus ref API 和 onSubmitRequest 快捷键回调,发送、取消按钮及请求状态由页面组合,原生 div 编辑器直接可编辑;支持选择/粘贴图片并在正文下方展示附件,使用 getImages/clearImages 管理。只读 `CommentContent` 不依赖编辑器。作者、时间、线程与接口调用由消费页面组合。
|
|
526
526
|
|
|
527
527
|
数据源和真实服务的接入要求见 [CommentInput 使用说明](./comment/README.md)。输入与只读列表应共享同一 CommentProvider;CCM 的 Lark ID 与模板的 apaas ID 不能混用。
|
|
528
528
|
|
|
@@ -30,9 +30,16 @@ import { CommentInput } from '@/components/business-ui/comment/comment-input';
|
|
|
30
30
|
import { CommentContent } from '@/components/business-ui/comment/comment-content';
|
|
31
31
|
import { CommentProvider } from '@/components/business-ui/comment/comment-provider';
|
|
32
32
|
import { emptyComment } from '@/components/business-ui/comment/content';
|
|
33
|
-
import type {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
import type {
|
|
34
|
+
CommentInputHandle,
|
|
35
|
+
CommentSubmitPayload,
|
|
36
|
+
} from '@/components/business-ui/comment/types';
|
|
37
|
+
|
|
38
|
+
export function CommentExample({
|
|
39
|
+
save,
|
|
40
|
+
}: {
|
|
41
|
+
save: (body: CommentSubmitPayload) => Promise<void>;
|
|
42
|
+
}) {
|
|
36
43
|
const inputRef = useRef<CommentInputHandle>(null);
|
|
37
44
|
const busy = useRef(false);
|
|
38
45
|
const [value, setValue] = useState(emptyComment);
|
|
@@ -56,14 +63,32 @@ export function CommentExample({ save }: { save: (body: CommentSubmitPayload) =>
|
|
|
56
63
|
setSending(false);
|
|
57
64
|
}
|
|
58
65
|
};
|
|
59
|
-
return
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
return (
|
|
67
|
+
<CommentProvider>
|
|
68
|
+
<CommentInput
|
|
69
|
+
ref={inputRef}
|
|
70
|
+
documentKey="new"
|
|
71
|
+
value={value}
|
|
72
|
+
onChange={setValue}
|
|
73
|
+
onSubmitRequest={() => {
|
|
74
|
+
void handleSend();
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
<button disabled={sending} onClick={() => inputRef.current?.clear()}>
|
|
78
|
+
取消
|
|
79
|
+
</button>
|
|
80
|
+
<button
|
|
81
|
+
disabled={sending}
|
|
82
|
+
onClick={() => {
|
|
83
|
+
void handleSend();
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
发送
|
|
87
|
+
</button>
|
|
88
|
+
{error ? <p role="alert">{error}</p> : null}
|
|
89
|
+
<CommentContent value={value} />
|
|
90
|
+
</CommentProvider>
|
|
91
|
+
);
|
|
67
92
|
}
|
|
68
93
|
```
|
|
69
94
|
|
|
@@ -76,10 +101,10 @@ export function CommentExample({ save }: { save: (body: CommentSubmitPayload) =>
|
|
|
76
101
|
- `getImages()`:读取附件状态与上传结果的快照,不自动转换成多维表格图片协议。
|
|
77
102
|
- `clearImages()`:删除全部附件并取消/忽略上传,释放本地预览地址。附件独立于正文撤销历史。
|
|
78
103
|
- `setEditable(boolean)`:控制正文、上传按钮及附件删除/重试;disabled prop 是外部硬禁用。
|
|
79
|
-
- `focus()
|
|
104
|
+
- `focus()`:聚焦输入框。
|
|
80
105
|
- `onSubmitRequest`:Enter(或 submitMode="mod-enter")通知页面;输入法确认和 @候选选择优先处理,未配置时 Enter 换行。
|
|
81
106
|
|
|
82
|
-
|
|
107
|
+
原生 div 编辑器直接挂载,输入区无需二次点击激活;不依赖 Tiptap/ProseMirror。图片存储 SDK 仍按需导入。popover 挂在 Dialog/Sheet 时可传 portalContainer。React 管理外框、候选面板与附件,正文 DOM 由 DivEditor 独立管理,避免受控回写破坏光标和输入法。
|
|
83
108
|
|
|
84
109
|
## 搜索与回显
|
|
85
110
|
|
|
@@ -90,9 +115,14 @@ recommend 用于刚输入 @ 或清空关键词;search 防抖 200ms,并忽略
|
|
|
90
115
|
文档独立配置 `<CommentProvider documents={documents}>`,输入框再开启 enableDocuments:
|
|
91
116
|
|
|
92
117
|
```ts
|
|
93
|
-
import {
|
|
118
|
+
import {
|
|
119
|
+
createCcmDocumentSource,
|
|
120
|
+
createBrowserCcmRequest,
|
|
121
|
+
} from '@/components/business-ui/comment/ccm-document-source';
|
|
94
122
|
const documents = createCcmDocumentSource({
|
|
95
|
-
scopeKey: currentUserScope,
|
|
123
|
+
scopeKey: currentUserScope,
|
|
124
|
+
token: hostDocumentToken,
|
|
125
|
+
objType: hostDocumentType,
|
|
96
126
|
request: createBrowserCcmRequest(authenticatedProxyPath),
|
|
97
127
|
search: searchCloudDocuments, // 可选:宿主提供完整文档搜索
|
|
98
128
|
});
|
|
@@ -136,4 +166,12 @@ getImages 返回 `{ id, name, size, previewUrl, status, result?, error? }[]`:i
|
|
|
136
166
|
|
|
137
167
|
“授予提及的人阅读权限”仅在传入 onGrantMentionAccessChange 时显示,属于受控的业务意图,组件不直接调用文档授权接口。消费页面负责结合勾选值执行真实授权。
|
|
138
168
|
|
|
139
|
-
正文使用统一的自有撤销历史,覆盖文字、引用插入/删除、粘贴和 clear。连续文字合并为一组,输入法组合输入作为一组;元数据回显不产生编辑历史,外部替换 value
|
|
169
|
+
正文使用统一的自有撤销历史,覆盖文字、引用插入/删除、粘贴和 clear。连续文字合并为一组,输入法组合输入作为一组;元数据回显不产生编辑历史,外部替换 value 会重置正文历史。正文直接使用 CommentValue,不保留 Tiptap 文档结构转换层。
|
|
170
|
+
|
|
171
|
+
## 文件组织
|
|
172
|
+
|
|
173
|
+
comment-input.tsx 提供校验、错误边界与原生编辑交互,dom-editor.ts 管理正文与撤销,image-attachments.tsx 管理独立附件。comment-content.tsx 独立提供只读展示,不依赖编辑器。
|
|
174
|
+
|
|
175
|
+
mention-provider.tsx 放上下文和缓存;comment-provider.tsx 放默认人员服务、文档混合数据源与便捷 Provider。mention-suggestions.tsx 放候选面板和搜索 Hook;mention-view.tsx 放引用样式与文档图标。content.ts/types.ts 放协议转换与类型,ccm-document-source.ts 是可选的宿主文档适配器。
|
|
176
|
+
|
|
177
|
+
preloadCommentEditor 保留为兼容空操作;编辑器直接挂载后无需预加载。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DocumentIcon } from './document-icon';
|
|
2
1
|
import { fromApiContent } from './content';
|
|
3
2
|
import {
|
|
3
|
+
DocumentIcon,
|
|
4
4
|
USER_MENTION_CLASS,
|
|
5
5
|
INPUT_USER_MENTION_CLASS,
|
|
6
6
|
INPUT_USER_MENTION_LABEL_CLASS,
|
|
@@ -10,14 +10,10 @@ import {
|
|
|
10
10
|
USER_MENTION_LABEL_CLASS,
|
|
11
11
|
DOCUMENT_MENTION_CLASS,
|
|
12
12
|
DOCUMENT_MENTION_UNREADABLE_CLASS,
|
|
13
|
-
} from './mention-
|
|
13
|
+
} from './mention-view';
|
|
14
14
|
import * as React from 'react';
|
|
15
15
|
import { cn } from '@/lib/utils';
|
|
16
|
-
import {
|
|
17
|
-
mentionLabel,
|
|
18
|
-
normalizeValue,
|
|
19
|
-
safeUrl,
|
|
20
|
-
} from './content';
|
|
16
|
+
import { mentionLabel, normalizeValue, safeUrl } from './content';
|
|
21
17
|
import {
|
|
22
18
|
useMentionContext,
|
|
23
19
|
useMentionEntity,
|