@zjlab-fe/data-hub-ui 0.33.2 → 0.33.3
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.
|
@@ -236,23 +236,27 @@ const NotionEditor = forwardRef(({ initContent, editable = false, className = ''
|
|
|
236
236
|
useEffect(() => {
|
|
237
237
|
const onHashChange = () => {
|
|
238
238
|
if (editor) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (
|
|
242
|
-
|
|
243
|
-
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
var _a;
|
|
241
|
+
if (window.location.hash) {
|
|
242
|
+
const id = window.location.hash.slice(1);
|
|
243
|
+
if (id) {
|
|
244
244
|
// 将 hash 中指定 id 对应的 block 滚动到可视范围内
|
|
245
245
|
const target = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.data-hub-ui-blocknote-editor [data-id="${CSS.escape(id)}"]`);
|
|
246
246
|
target === null || target === void 0 ? void 0 : target.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
247
|
-
}
|
|
247
|
+
}
|
|
248
248
|
}
|
|
249
|
-
}
|
|
249
|
+
}, 500);
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
252
|
onHashChange();
|
|
253
|
-
window.
|
|
253
|
+
if (window.navigation) {
|
|
254
|
+
window.navigation.addEventListener('navigate', onHashChange);
|
|
255
|
+
}
|
|
254
256
|
return () => {
|
|
255
|
-
window.
|
|
257
|
+
if (window.navigation) {
|
|
258
|
+
window.navigation.removeEventListener('navigate', onHashChange);
|
|
259
|
+
}
|
|
256
260
|
};
|
|
257
261
|
}, [editor]);
|
|
258
262
|
const handleChange = useCallback(() => {
|