@zjlab-fe/data-hub-ui 0.32.0 → 0.32.2
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.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { Flex, Tag, Popover } from 'antd';
|
|
3
3
|
import { useRef, useState, useMemo, useEffect } from 'react';
|
|
4
|
-
import { "new-task-card-item" as new_task_card_item, "card-actived" as card_actived, "new-task-card-header" as new_task_card_header, "new-task-card-title" as new_task_card_title, "new-task-card-update-time" as new_task_card_update_time, "new-task-card-update-time-icon" as new_task_card_update_time_icon, "new-task-card-update-time-text" as new_task_card_update_time_text, "new-task-card-tags" as new_task_card_tags, "new-task-card-tags-measure" as new_task_card_tags_measure, "new-task-card-tag-measure-item" as new_task_card_tag_measure_item, "new-task-card-tags-visible" as new_task_card_tags_visible, "new-task-card-tags-ellipsis" as new_task_card_tags_ellipsis, "new-task-card-tags-popover-content" as new_task_card_tags_popover_content, "new-task-card-description" as new_task_card_description } from './index.module.scss.js';
|
|
4
|
+
import { "new-task-card-item" as new_task_card_item, "card-actived" as card_actived, "new-task-card-header" as new_task_card_header, "new-task-card-title" as new_task_card_title, "new-task-card-update-time" as new_task_card_update_time, "new-task-card-update-time-icon" as new_task_card_update_time_icon, "new-task-card-update-time-text" as new_task_card_update_time_text, "new-task-card-tags" as new_task_card_tags, "new-task-card-tags-measure" as new_task_card_tags_measure, "new-task-card-tag-measure-item" as new_task_card_tag_measure_item, "new-task-card-tags-visible" as new_task_card_tags_visible, "new-task-card-tags-ellipsis" as new_task_card_tags_ellipsis, "new-task-card-tags-popover-content" as new_task_card_tags_popover_content, "new-task-card-description" as new_task_card_description, "new-task-card-description-popover-content" as new_task_card_description_popover_content } from './index.module.scss.js';
|
|
5
5
|
import sourceIcon from '../../assets/source.png.js';
|
|
6
6
|
|
|
7
7
|
function CorpusCard({ card, isActive, width, onClick, onCardClick }) {
|
|
8
8
|
const tagContainerRef = useRef(null);
|
|
9
|
+
const descriptionRef = useRef(null);
|
|
9
10
|
const tagMeasureRefs = useRef([]);
|
|
10
11
|
const [visibleTagCount, setVisibleTagCount] = useState(card.labels.length);
|
|
12
|
+
const [isDescriptionOverflow, setIsDescriptionOverflow] = useState(false);
|
|
11
13
|
const labelTypeColorMap = useMemo(() => {
|
|
12
14
|
var _a;
|
|
13
15
|
return (_a = card.labelTypeColorMap) !== null && _a !== void 0 ? _a : [];
|
|
@@ -77,12 +79,32 @@ function CorpusCard({ card, isActive, width, onClick, onCardClick }) {
|
|
|
77
79
|
resizeObserver.disconnect();
|
|
78
80
|
};
|
|
79
81
|
}, [card.labels, width]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const checkDescriptionOverflow = () => {
|
|
84
|
+
const element = descriptionRef.current;
|
|
85
|
+
if (!element) {
|
|
86
|
+
setIsDescriptionOverflow(false);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setIsDescriptionOverflow(element.scrollHeight > element.clientHeight);
|
|
90
|
+
};
|
|
91
|
+
checkDescriptionOverflow();
|
|
92
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
93
|
+
checkDescriptionOverflow();
|
|
94
|
+
});
|
|
95
|
+
if (descriptionRef.current) {
|
|
96
|
+
resizeObserver.observe(descriptionRef.current);
|
|
97
|
+
}
|
|
98
|
+
return () => {
|
|
99
|
+
resizeObserver.disconnect();
|
|
100
|
+
};
|
|
101
|
+
}, [card.description, width]);
|
|
80
102
|
const needCollapseTags = visibleTagCount < card.labels.length;
|
|
81
103
|
const visibleTags = needCollapseTags ? card.labels.slice(0, visibleTagCount) : card.labels;
|
|
82
104
|
const hiddenTags = needCollapseTags ? card.labels.slice(visibleTagCount) : [];
|
|
83
105
|
return (jsx("div", { className: `${new_task_card_item} ${isActive ? card_actived : ''}`, style: { width: width || 375 }, onClick: () => handleCardClick(card.id), children: jsxs(Flex, { vertical: true, gap: 16, children: [jsxs("div", { className: new_task_card_header, children: [jsx("div", { className: new_task_card_title, children: card.name }), jsxs("span", { className: new_task_card_update_time, children: [jsx("img", { src: sourceIcon, alt: "update-time-icon", className: new_task_card_update_time_icon }), jsx("span", { className: new_task_card_update_time_text, children: formattedUpdateTime })] })] }), jsxs("div", { className: new_task_card_tags, children: [jsx("div", { className: new_task_card_tags_measure, children: card.labels.map((label, index) => (jsx("span", { ref: (element) => {
|
|
84
106
|
tagMeasureRefs.current[index] = element;
|
|
85
|
-
}, className: new_task_card_tag_measure_item, children: jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }) }, `measure-${card.id}-${label.type}-${label.name}`))) }), jsxs("div", { ref: tagContainerRef, className: new_task_card_tags_visible, children: [visibleTags.map((label) => (jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }, `${card.id}-${label.type}-${label.name}`))), needCollapseTags ? (jsx(Popover, { trigger: "hover", content: jsx("div", { className: new_task_card_tags_popover_content, children: hiddenTags.map((label) => (jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }, `hidden-${card.id}-${label.type}-${label.name}`))) }), children: jsx(Tag, { className: new_task_card_tags_ellipsis, children: "..." }) })) : null] })] }), jsx("div", { className: new_task_card_description, children: card.description })] }) }, card.id));
|
|
107
|
+
}, className: new_task_card_tag_measure_item, children: jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }) }, `measure-${card.id}-${label.type}-${label.name}`))) }), jsxs("div", { ref: tagContainerRef, className: new_task_card_tags_visible, children: [visibleTags.map((label) => (jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }, `${card.id}-${label.type}-${label.name}`))), needCollapseTags ? (jsx(Popover, { trigger: "hover", content: jsx("div", { className: new_task_card_tags_popover_content, children: hiddenTags.map((label) => (jsx(Tag, { style: getLabelColor(label.type, labelTypeColorMap), bordered: true, children: label.name }, `hidden-${card.id}-${label.type}-${label.name}`))) }), children: jsx(Tag, { className: new_task_card_tags_ellipsis, children: "..." }) })) : null] })] }), jsx(Popover, { trigger: isDescriptionOverflow ? 'hover' : [], content: jsx("div", { className: new_task_card_description_popover_content, children: card.description }), children: jsx("div", { ref: descriptionRef, className: new_task_card_description, children: card.description }) })] }) }, card.id));
|
|
86
108
|
}
|
|
87
109
|
|
|
88
110
|
export { CorpusCard as default };
|
|
@@ -130,6 +130,16 @@ style.textContent = `@charset "UTF-8";
|
|
|
130
130
|
gap: 4px;
|
|
131
131
|
max-width: 260px;
|
|
132
132
|
}
|
|
133
|
+
.index-module__new-task-card-description-popover-content___Qw4N7 {
|
|
134
|
+
max-width: 320px;
|
|
135
|
+
font-family: "AlibabaPuHuiTi-3-55-Regular";
|
|
136
|
+
font-style: normal;
|
|
137
|
+
font-weight: 400;
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
line-height: 20px;
|
|
140
|
+
color: #545b64;
|
|
141
|
+
word-break: break-word;
|
|
142
|
+
}
|
|
133
143
|
.index-module__new-task-card-tags-ellipsis___GVtdA {
|
|
134
144
|
display: flex;
|
|
135
145
|
flex-direction: row;
|
|
@@ -167,7 +177,7 @@ style.textContent = `@charset "UTF-8";
|
|
|
167
177
|
}`;
|
|
168
178
|
document.head.appendChild(style);
|
|
169
179
|
|
|
170
|
-
var new_task_cards_container = "index-module__new-task-cards-container___ydHyH";var new_task_card_item = "index-module__new-task-card-item___4Ij8K";var card_actived = "index-module__card-actived___Ds-rJ";var new_task_card_header = "index-module__new-task-card-header___YNZyQ";var new_task_card_title = "index-module__new-task-card-title___ij3JL";var new_task_card_update_time = "index-module__new-task-card-update-time___-v0WT";var new_task_card_update_time_icon = "index-module__new-task-card-update-time-icon___1BRTB";var new_task_card_update_time_text = "index-module__new-task-card-update-time-text___JDOy0";var new_task_card_description = "index-module__new-task-card-description___a-I9s";var new_task_card_tags = "index-module__new-task-card-tags___kIHzm";var new_task_card_tags_visible = "index-module__new-task-card-tags-visible___r4txK";var new_task_card_tags_measure = "index-module__new-task-card-tags-measure___B-jpV";var new_task_card_tag_measure_item = "index-module__new-task-card-tag-measure-item___yWIae";var new_task_card_tags_popover_content = "index-module__new-task-card-tags-popover-content___rrMoB";var new_task_card_tags_ellipsis = "index-module__new-task-card-tags-ellipsis___GVtdA";var new_task_card_empty_title = "index-module__new-task-card-empty-title___di6z-";var card_detail_btn = "index-module__card-detail-btn___QHpSP";
|
|
171
|
-
var styles = {"new-task-cards-container":"index-module__new-task-cards-container___ydHyH","new-task-card-item":"index-module__new-task-card-item___4Ij8K","card-actived":"index-module__card-actived___Ds-rJ","new-task-card-header":"index-module__new-task-card-header___YNZyQ","new-task-card-title":"index-module__new-task-card-title___ij3JL","new-task-card-update-time":"index-module__new-task-card-update-time___-v0WT","new-task-card-update-time-icon":"index-module__new-task-card-update-time-icon___1BRTB","new-task-card-update-time-text":"index-module__new-task-card-update-time-text___JDOy0","new-task-card-description":"index-module__new-task-card-description___a-I9s","new-task-card-tags":"index-module__new-task-card-tags___kIHzm","new-task-card-tags-visible":"index-module__new-task-card-tags-visible___r4txK","new-task-card-tags-measure":"index-module__new-task-card-tags-measure___B-jpV","new-task-card-tag-measure-item":"index-module__new-task-card-tag-measure-item___yWIae","new-task-card-tags-popover-content":"index-module__new-task-card-tags-popover-content___rrMoB","new-task-card-tags-ellipsis":"index-module__new-task-card-tags-ellipsis___GVtdA","new-task-card-empty-title":"index-module__new-task-card-empty-title___di6z-","card-detail-btn":"index-module__card-detail-btn___QHpSP"};
|
|
180
|
+
var new_task_cards_container = "index-module__new-task-cards-container___ydHyH";var new_task_card_item = "index-module__new-task-card-item___4Ij8K";var card_actived = "index-module__card-actived___Ds-rJ";var new_task_card_header = "index-module__new-task-card-header___YNZyQ";var new_task_card_title = "index-module__new-task-card-title___ij3JL";var new_task_card_update_time = "index-module__new-task-card-update-time___-v0WT";var new_task_card_update_time_icon = "index-module__new-task-card-update-time-icon___1BRTB";var new_task_card_update_time_text = "index-module__new-task-card-update-time-text___JDOy0";var new_task_card_description = "index-module__new-task-card-description___a-I9s";var new_task_card_tags = "index-module__new-task-card-tags___kIHzm";var new_task_card_tags_visible = "index-module__new-task-card-tags-visible___r4txK";var new_task_card_tags_measure = "index-module__new-task-card-tags-measure___B-jpV";var new_task_card_tag_measure_item = "index-module__new-task-card-tag-measure-item___yWIae";var new_task_card_tags_popover_content = "index-module__new-task-card-tags-popover-content___rrMoB";var new_task_card_description_popover_content = "index-module__new-task-card-description-popover-content___Qw4N7";var new_task_card_tags_ellipsis = "index-module__new-task-card-tags-ellipsis___GVtdA";var new_task_card_empty_title = "index-module__new-task-card-empty-title___di6z-";var card_detail_btn = "index-module__card-detail-btn___QHpSP";
|
|
181
|
+
var styles = {"new-task-cards-container":"index-module__new-task-cards-container___ydHyH","new-task-card-item":"index-module__new-task-card-item___4Ij8K","card-actived":"index-module__card-actived___Ds-rJ","new-task-card-header":"index-module__new-task-card-header___YNZyQ","new-task-card-title":"index-module__new-task-card-title___ij3JL","new-task-card-update-time":"index-module__new-task-card-update-time___-v0WT","new-task-card-update-time-icon":"index-module__new-task-card-update-time-icon___1BRTB","new-task-card-update-time-text":"index-module__new-task-card-update-time-text___JDOy0","new-task-card-description":"index-module__new-task-card-description___a-I9s","new-task-card-tags":"index-module__new-task-card-tags___kIHzm","new-task-card-tags-visible":"index-module__new-task-card-tags-visible___r4txK","new-task-card-tags-measure":"index-module__new-task-card-tags-measure___B-jpV","new-task-card-tag-measure-item":"index-module__new-task-card-tag-measure-item___yWIae","new-task-card-tags-popover-content":"index-module__new-task-card-tags-popover-content___rrMoB","new-task-card-description-popover-content":"index-module__new-task-card-description-popover-content___Qw4N7","new-task-card-tags-ellipsis":"index-module__new-task-card-tags-ellipsis___GVtdA","new-task-card-empty-title":"index-module__new-task-card-empty-title___di6z-","card-detail-btn":"index-module__card-detail-btn___QHpSP"};
|
|
172
182
|
|
|
173
|
-
export { card_actived as "card-actived", card_detail_btn as "card-detail-btn", styles as default, new_task_card_description as "new-task-card-description", new_task_card_empty_title as "new-task-card-empty-title", new_task_card_header as "new-task-card-header", new_task_card_item as "new-task-card-item", new_task_card_tag_measure_item as "new-task-card-tag-measure-item", new_task_card_tags as "new-task-card-tags", new_task_card_tags_ellipsis as "new-task-card-tags-ellipsis", new_task_card_tags_measure as "new-task-card-tags-measure", new_task_card_tags_popover_content as "new-task-card-tags-popover-content", new_task_card_tags_visible as "new-task-card-tags-visible", new_task_card_title as "new-task-card-title", new_task_card_update_time as "new-task-card-update-time", new_task_card_update_time_icon as "new-task-card-update-time-icon", new_task_card_update_time_text as "new-task-card-update-time-text", new_task_cards_container as "new-task-cards-container" };
|
|
183
|
+
export { card_actived as "card-actived", card_detail_btn as "card-detail-btn", styles as default, new_task_card_description as "new-task-card-description", new_task_card_description_popover_content as "new-task-card-description-popover-content", new_task_card_empty_title as "new-task-card-empty-title", new_task_card_header as "new-task-card-header", new_task_card_item as "new-task-card-item", new_task_card_tag_measure_item as "new-task-card-tag-measure-item", new_task_card_tags as "new-task-card-tags", new_task_card_tags_ellipsis as "new-task-card-tags-ellipsis", new_task_card_tags_measure as "new-task-card-tags-measure", new_task_card_tags_popover_content as "new-task-card-tags-popover-content", new_task_card_tags_visible as "new-task-card-tags-visible", new_task_card_title as "new-task-card-title", new_task_card_update_time as "new-task-card-update-time", new_task_card_update_time_icon as "new-task-card-update-time-icon", new_task_card_update_time_text as "new-task-card-update-time-text", new_task_cards_container as "new-task-cards-container" };
|
|
@@ -112,6 +112,7 @@ const parseCopyPasteBlocks = (plainText, docId) => {
|
|
|
112
112
|
const NotionEditor = forwardRef(({ initContent, editable = false, className = '', docId, onChange, onImageUpload, onFileUpload, onImageUploadByUrl, }, ref) => {
|
|
113
113
|
const placeholder = '输入 "/" 快速插入内容';
|
|
114
114
|
const docIdRef = useRef(docId);
|
|
115
|
+
const containerRef = useRef(null);
|
|
115
116
|
const [tocCollapsed, setTocCollapsed] = useState(false);
|
|
116
117
|
const [tocItems, setTocItems] = useState([]);
|
|
117
118
|
docIdRef.current = docId;
|
|
@@ -239,7 +240,8 @@ const NotionEditor = forwardRef(({ initContent, editable = false, className = ''
|
|
|
239
240
|
const showToc = tocItems.length > 0;
|
|
240
241
|
const tocTitle = useMemo(() => (tocCollapsed ? '展开目录' : '收起目录'), [tocCollapsed]);
|
|
241
242
|
const handleTocItemClick = useCallback((blockId) => {
|
|
242
|
-
|
|
243
|
+
var _a;
|
|
244
|
+
const target = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.data-hub-ui-blocknote-editor [data-id="${CSS.escape(blockId)}"]`);
|
|
243
245
|
target === null || target === void 0 ? void 0 : target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
244
246
|
}, []);
|
|
245
247
|
useImperativeHandle(ref, () => ({
|
|
@@ -254,7 +256,7 @@ const NotionEditor = forwardRef(({ initContent, editable = false, className = ''
|
|
|
254
256
|
focus: () => editor === null || editor === void 0 ? void 0 : editor.focus(),
|
|
255
257
|
isEmpty: () => { var _a; return (_a = editor === null || editor === void 0 ? void 0 : editor.isEmpty) !== null && _a !== void 0 ? _a : true; },
|
|
256
258
|
}));
|
|
257
|
-
return (jsxs("div", { className: `data-hub-ui-blocknote-editor-wrapper ${tocCollapsed ? 'is-toc-collapsed' : ''} ${className}`, children: [jsx(BlockNoteView, { editor: editor, formattingToolbar: false, onChange: handleChange, theme: "light", className: "data-hub-ui-blocknote-editor", children: jsx(FormattingToolbarController, { formattingToolbar: () => (jsxs(FormattingToolbar, { children: [getFormattingToolbarItems(), jsx(BasicTextStyleButton, { basicTextStyle: "code" })] })) }) }), showToc && (jsxs("aside", { className: `data-hub-ui-blocknote-toc ${tocCollapsed ? 'is-collapsed' : ''}`, children: [jsxs("button", { type: "button", className: "data-hub-ui-blocknote-toc__toggle", "aria-label": tocTitle, "aria-expanded": !tocCollapsed, onClick: () => setTocCollapsed((value) => !value), children: [jsx("span", { children: "\u76EE\u5F55" }), jsx("span", { className: "data-hub-ui-blocknote-toc__toggle-icon", children: tocCollapsed ? '‹' : '›' })] }), !tocCollapsed && (jsx("nav", { className: "data-hub-ui-blocknote-toc__list", "aria-label": "\u6587\u6863\u76EE\u5F55", children: tocItems.map((item) => (jsx("button", { type: "button", className: "data-hub-ui-blocknote-toc__item", style: { '--toc-level': item.level }, title: item.title, onClick: () => handleTocItemClick(item.id), children: item.title }, item.id))) }))] }))] }));
|
|
259
|
+
return (jsxs("div", { ref: containerRef, className: `data-hub-ui-blocknote-editor-wrapper ${tocCollapsed ? 'is-toc-collapsed' : ''} ${className}`, children: [jsx(BlockNoteView, { editor: editor, formattingToolbar: false, onChange: handleChange, theme: "light", className: "data-hub-ui-blocknote-editor", children: jsx(FormattingToolbarController, { formattingToolbar: () => (jsxs(FormattingToolbar, { children: [getFormattingToolbarItems(), jsx(BasicTextStyleButton, { basicTextStyle: "code" })] })) }) }), showToc && (jsxs("aside", { className: `data-hub-ui-blocknote-toc ${tocCollapsed ? 'is-collapsed' : ''}`, children: [jsxs("button", { type: "button", className: "data-hub-ui-blocknote-toc__toggle", "aria-label": tocTitle, "aria-expanded": !tocCollapsed, onClick: () => setTocCollapsed((value) => !value), children: [jsx("span", { children: "\u76EE\u5F55" }), jsx("span", { className: "data-hub-ui-blocknote-toc__toggle-icon", children: tocCollapsed ? '‹' : '›' })] }), !tocCollapsed && (jsx("nav", { className: "data-hub-ui-blocknote-toc__list", "aria-label": "\u6587\u6863\u76EE\u5F55", children: tocItems.map((item) => (jsx("button", { type: "button", className: "data-hub-ui-blocknote-toc__item", style: { '--toc-level': item.level }, title: item.title, onClick: () => handleTocItemClick(item.id), children: item.title }, item.id))) }))] }))] }));
|
|
258
260
|
});
|
|
259
261
|
NotionEditor.displayName = 'NotionEditor';
|
|
260
262
|
|
|
@@ -24,11 +24,10 @@ function useStyle() {
|
|
|
24
24
|
}
|
|
25
25
|
.data-hub-ui-blocknote-toc {
|
|
26
26
|
position: sticky;
|
|
27
|
-
top:
|
|
27
|
+
top: 30px;
|
|
28
28
|
display: flex;
|
|
29
29
|
flex-direction: column;
|
|
30
30
|
width: 240px;
|
|
31
|
-
max-height: 560px;
|
|
32
31
|
overflow: hidden;
|
|
33
32
|
color: #334155;
|
|
34
33
|
font-size: 13px;
|
|
@@ -76,7 +75,7 @@ function useStyle() {
|
|
|
76
75
|
flex: 1;
|
|
77
76
|
gap: 2px;
|
|
78
77
|
min-height: 0;
|
|
79
|
-
max-height:
|
|
78
|
+
max-height: 500px;
|
|
80
79
|
margin-top: 8px;
|
|
81
80
|
padding: 4px 0 4px 8px;
|
|
82
81
|
overflow-y: auto;
|
|
@@ -105,25 +104,9 @@ function useStyle() {
|
|
|
105
104
|
color: #2563eb;
|
|
106
105
|
background: #eff6ff;
|
|
107
106
|
}
|
|
108
|
-
@media (max-
|
|
109
|
-
.data-hub-ui-blocknote-editor-wrapper {
|
|
110
|
-
display: block;
|
|
111
|
-
padding: 16px 24px;
|
|
112
|
-
}
|
|
113
|
-
.data-hub-ui-blocknote-toc {
|
|
114
|
-
position: sticky;
|
|
115
|
-
top: 0;
|
|
116
|
-
right: auto;
|
|
117
|
-
width: 100%;
|
|
118
|
-
max-height: none;
|
|
119
|
-
margin-bottom: 12px;
|
|
120
|
-
background: #ffffff;
|
|
121
|
-
}
|
|
122
|
-
.data-hub-ui-blocknote-toc.is-collapsed {
|
|
123
|
-
width: 42px;
|
|
124
|
-
}
|
|
107
|
+
@media (max-height: 640px) {
|
|
125
108
|
.data-hub-ui-blocknote-toc__list {
|
|
126
|
-
max-height:
|
|
109
|
+
max-height: 400px;
|
|
127
110
|
}
|
|
128
111
|
}
|
|
129
112
|
.data-hub-ui-blocknote-editor .bn-editor {
|