@zjlab-fe/data-hub-ui 0.33.1 → 0.33.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.
@@ -231,19 +231,30 @@ const NotionEditor = forwardRef(({ initContent, editable = false, className = ''
231
231
  useEffect(() => {
232
232
  if (editor) {
233
233
  editor.isEditable = editable;
234
- if (window.location.hash) {
235
- const id = window.location.hash.split('#')[1];
236
- if (id) {
237
- setTimeout(() => {
238
- var _a;
239
- // 将 hash 中指定 id 对应的 block 滚动到可视范围内
240
- const target = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.data-hub-ui-blocknote-editor [data-id="${CSS.escape(id)}"]`);
241
- target === null || target === void 0 ? void 0 : target.scrollIntoView({ behavior: 'smooth', block: 'start' });
242
- }, 500);
243
- }
244
- }
245
234
  }
246
235
  }, [editor, editable]);
236
+ useEffect(() => {
237
+ const onHashChange = () => {
238
+ if (editor) {
239
+ if (window.location.hash) {
240
+ const id = window.location.hash.split('#')[1];
241
+ if (id) {
242
+ setTimeout(() => {
243
+ var _a;
244
+ // 将 hash 中指定 id 对应的 block 滚动到可视范围内
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
+ target === null || target === void 0 ? void 0 : target.scrollIntoView({ behavior: 'smooth', block: 'start' });
247
+ }, 500);
248
+ }
249
+ }
250
+ }
251
+ };
252
+ onHashChange();
253
+ window.addEventListener('hashchange', onHashChange);
254
+ return () => {
255
+ window.removeEventListener('hashchange', onHashChange);
256
+ };
257
+ }, [editor]);
247
258
  const handleChange = useCallback(() => {
248
259
  if (editor) {
249
260
  const blocks = editor.document;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zjlab-fe/data-hub-ui",
3
- "version": "0.33.1",
3
+ "version": "0.33.2",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "types": "dist/types/index.d.ts",