@@ -348,20 +348,18 @@ export class SuperToolbar extends EventEmitter {
348348
349349 /**
350350 * Toggles the ruler visibility
351- * @param {Object } [_params=null] - Command parameters (not used)
352351 * @returns {void }
353352 */
354- toggleRuler : ( _params = null ) => {
353+ toggleRuler : ( ) => {
355354 this . superdoc . toggleRuler ( ) ;
356355 } ,
357356
358357 /**
359358 * Initiates the image upload process
360359 * @async
361- * @param {Object } [_params=null - Command parameters (not used)
362360 * @returns {Promise<void> }
363361 */
364- startImageUpload : async ( _params = null ) => {
362+ startImageUpload : async ( ) => {
365363 let open = getFileOpener ( ) ;
366364 let result = await open ( ) ;
367365
@@ -521,12 +519,11 @@ export class SuperToolbar extends EventEmitter {
521519 /**
522520 * Executes a table-related command
523521 * @param {Object } params - Command parameters
524- * @param {CommandItem } params.item - The command item
525522 * @param {Object } params.argument - The table command and its parameters
526523 * @param {string } params.argument.command - The specific table command to execute
527524 * @returns {void }
528525 */
529- executeTableCommand : ( { item , argument } ) => {
526+ executeTableCommand : ( { argument } ) => {
530527 if ( ! argument ) return ;
531528
532529 let command = argument . command ;
@@ -733,8 +730,13 @@ export class SuperToolbar extends EventEmitter {
733730 const linkedStyles = this . activeEditor . converter ?. linkedStyles . find (
734731 ( style ) => style . id === styleIdMark . attrs . styleId ,
735732 ) ;
736- if ( linkedStyles && markToStyleMap [ item . name . value ] in linkedStyles ?. definition . styles ) {
737- const linkedStylesItem = linkedStyles ?. definition . styles [ markToStyleMap [ item . name . value ] ] ;
733+ if (
734+ linkedStyles &&
735+ linkedStyles . definition &&
736+ linkedStyles . definition . styles &&
737+ markToStyleMap [ item . name . value ] in linkedStyles . definition . styles
738+ ) {
739+ const linkedStylesItem = linkedStyles . definition . styles [ markToStyleMap [ item . name . value ] ] ;
738740 const value = {
739741 [ item . name . value ] : linkedStylesItem ,
740742 } ;
@@ -815,11 +817,10 @@ export class SuperToolbar extends EventEmitter {
815817 /**
816818 * React to editor transactions. Might want to debounce this.
817819 * @param {Object } params - Transaction parameters
818- * @param {Object } params.editor - The editor instance (not used)
819820 * @param {Object } params.transaction - The transaction object
820821 * @returns {void }
821822 */
822- onEditorTransaction ( { editor , transaction } ) {
823+ onEditorTransaction ( { transaction } ) {
823824 if ( ! transaction . docChanged && ! transaction . selectionSet ) return ;
824825 this . updateToolbarState ( ) ;
825826 }
@@ -849,7 +850,7 @@ export class SuperToolbar extends EventEmitter {
849850 return this . #interceptedCommands[ command ] ( { item, argument } ) ;
850851 }
851852
852- if ( command in this . activeEditor ? .commands ) {
853+ if ( this . activeEditor && this . activeEditor . commands && command in this . activeEditor . commands ) {
853854 this . activeEditor . commands [ command ] ( argument ) ;
854855 }
855856
@@ -882,14 +883,19 @@ export class SuperToolbar extends EventEmitter {
882883 let command = item . command ;
883884 const noArgumentCommand = item . noArgumentCommand ;
884885
885- if ( argument === 'none' && noArgumentCommand in this . activeEditor ?. commands ) {
886+ if (
887+ argument === 'none' &&
888+ this . activeEditor &&
889+ this . activeEditor . commands &&
890+ noArgumentCommand in this . activeEditor . commands
891+ ) {
886892 this . activeEditor . commands [ noArgumentCommand ] ( ) ;
887893 if ( typeof callback === 'function' && noArgumentCallback ) callback ( argument ) ;
888894 this . updateToolbarState ( ) ;
889895 return ;
890896 }
891897
892- if ( command in this . activeEditor ? .commands ) {
898+ if ( this . activeEditor && this . activeEditor . commands && command in this . activeEditor . commands ) {
893899 this . activeEditor . commands [ command ] ( argument ) ;
894900 if ( typeof callback === 'function' ) callback ( argument ) ;
895901 this . updateToolbarState ( ) ;
0 commit comments