File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
src/frontend/apps/impress/src/features/docs/doc-editor/stores Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1+ import _ from 'lodash' ;
12import { create } from 'zustand' ;
23
34import { DocsBlockNoteEditor , HeadingBlock } from '../types' ;
@@ -24,7 +25,7 @@ export interface UseHeadingStore {
2425 resetHeadings : ( ) => void ;
2526}
2627
27- export const useHeadingStore = create < UseHeadingStore > ( ( set ) => ( {
28+ export const useHeadingStore = create < UseHeadingStore > ( ( set , get ) => ( {
2829 headings : [ ] ,
2930 setHeadings : ( editor ) => {
3031 const headingBlocks = editor ?. document
@@ -36,7 +37,9 @@ export const useHeadingStore = create<UseHeadingStore>((set) => ({
3637 ) ,
3738 } ) ) as unknown as HeadingBlock [ ] ;
3839
39- set ( ( ) => ( { headings : headingBlocks } ) ) ;
40+ if ( ! _ . isEqual ( get ( ) . headings , headingBlocks ) ) {
41+ set ( ( ) => ( { headings : headingBlocks } ) ) ;
42+ }
4043 } ,
4144 resetHeadings : ( ) => set ( ( ) => ( { headings : [ ] } ) ) ,
4245} ) ) ;
You can’t perform that action at this time.
0 commit comments