@zjlab-fe/data-hub-ui 0.32.0 → 0.32.1

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.
@@ -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
- const target = document.querySelector(`.data-hub-ui-blocknote-editor [data-id="${CSS.escape(blockId)}"]`);
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: 10px;
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: 516px;
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-width: 960px) {
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: 220px;
109
+ max-height: 400px;
127
110
  }
128
111
  }
129
112
  .data-hub-ui-blocknote-editor .bn-editor {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zjlab-fe/data-hub-ui",
3
- "version": "0.32.0",
3
+ "version": "0.32.1",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "types": "dist/types/index.d.ts",