File tree 1 file changed +5
-2
lines changed
src/frontend/apps/impress/src/features/docs/doc-editor/stores
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change
1
+ import _ from 'lodash' ;
1
2
import { create } from 'zustand' ;
2
3
3
4
import { DocsBlockNoteEditor , HeadingBlock } from '../types' ;
@@ -24,7 +25,7 @@ export interface UseHeadingStore {
24
25
resetHeadings : ( ) => void ;
25
26
}
26
27
27
- export const useHeadingStore = create < UseHeadingStore > ( ( set ) => ( {
28
+ export const useHeadingStore = create < UseHeadingStore > ( ( set , get ) => ( {
28
29
headings : [ ] ,
29
30
setHeadings : ( editor ) => {
30
31
const headingBlocks = editor ?. document
@@ -36,7 +37,9 @@ export const useHeadingStore = create<UseHeadingStore>((set) => ({
36
37
) ,
37
38
} ) ) as unknown as HeadingBlock [ ] ;
38
39
39
- set ( ( ) => ( { headings : headingBlocks } ) ) ;
40
+ if ( ! _ . isEqual ( get ( ) . headings , headingBlocks ) ) {
41
+ set ( ( ) => ( { headings : headingBlocks } ) ) ;
42
+ }
40
43
} ,
41
44
resetHeadings : ( ) => set ( ( ) => ( { headings : [ ] } ) ) ,
42
45
} ) ) ;
You can’t perform that action at this time.
0 commit comments