@@ -155,7 +155,7 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
155
155
placeholder,
156
156
read_only,
157
157
registerEditor,
158
- saveDebounceMs,
158
+ saveDebounceMs = SAVE_DEBOUNCE_MS ,
159
159
selectionRef,
160
160
style,
161
161
submitMentionsRef,
@@ -257,7 +257,7 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
257
257
// hook up to syncstring if available:
258
258
useEffect ( ( ) => {
259
259
if ( actions . _syncstring == null ) return ;
260
- const beforeChange = setSyncstringFromSlate ;
260
+ const beforeChange = setSyncstringFromSlateNOW ;
261
261
const change = ( ) => {
262
262
setEditorToValue ( actions . _syncstring . to_str ( ) ) ;
263
263
} ;
@@ -496,29 +496,31 @@ export const EditableMarkdown: React.FC<Props> = React.memo((props: Props) => {
496
496
}
497
497
} , [ value ] ) ;
498
498
499
- const setSyncstringFromSlate = useMemo ( ( ) => {
500
- const f = ( ) => {
501
- if ( actions . set_value == null ) {
502
- // no way to save the value out (e.g., just beginning to test
503
- // using the component).
504
- return ;
505
- }
506
- if ( ! editor . hasUnsavedChanges ( ) ) {
507
- // there are no changes to save
508
- return ;
509
- }
499
+ const setSyncstringFromSlateNOW = ( ) => {
500
+ if ( actions . set_value == null ) {
501
+ // no way to save the value out (e.g., just beginning to test
502
+ // using the component).
503
+ return ;
504
+ }
505
+ if ( ! editor . hasUnsavedChanges ( ) ) {
506
+ // there are no changes to save
507
+ return ;
508
+ }
510
509
511
- const markdown = editor . getMarkdownValue ( ) ;
512
- actions . set_value ( markdown ) ;
513
- actions . syncstring_commit ?.( ) ;
510
+ const markdown = editor . getMarkdownValue ( ) ;
511
+ actions . set_value ( markdown ) ;
512
+ actions . syncstring_commit ?.( ) ;
514
513
515
- // Record that the syncstring's value is now equal to ours:
516
- editor . resetHasUnsavedChanges ( ) ;
517
- } ;
514
+ // Record that the syncstring's value is now equal to ours:
515
+ editor . resetHasUnsavedChanges ( ) ;
516
+ } ;
517
+
518
+ const setSyncstringFromSlate = useMemo ( ( ) => {
518
519
if ( saveDebounceMs ) {
519
- return debounce ( f , saveDebounceMs ) ;
520
+ return debounce ( setSyncstringFromSlateNOW , saveDebounceMs ) ;
520
521
} else {
521
- return f ;
522
+ // this case shouldn't happen
523
+ return setSyncstringFromSlateNOW ;
522
524
}
523
525
} , [ ] ) ;
524
526
0 commit comments