Skip to content

HAR-9336 - fix toolbar state updates#412

Merged
harbournick merged 1 commit intomainfrom
artem-HAR-9336
Mar 24, 2025
Merged

HAR-9336 - fix toolbar state updates#412
harbournick merged 1 commit intomainfrom
artem-HAR-9336

Conversation

@artem-harbour
Copy link
Copy Markdown
Contributor

@artem-harbour artem-harbour commented Mar 24, 2025

Fixed updating the toolbar state when initialized and when updating the document mode.

@harbournick Please double check before merging as I'm not aware of the details of SuperToolbar and SuperDoc classes.

@artem-harbour artem-harbour self-assigned this Mar 24, 2025
this.config = { ...this.config, ...config };
this.toolbarItems = [];
this.overflowItems = [];
this.documentMode = 'editing';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document mode was set to 'editing' and never changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since the document mode is checked on toolbar state update, I can assume that it should change (on doc mode change).

if (editor) editor.setDocumentMode('editing');
});

if (this.toolbar) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set document mode for toolbar and update the state.


this.toolbar = new SuperToolbar(config);
this.toolbar.on('superdoc-command', this.onToolbarCommand.bind(this));
this.once('editorCreate', () => this.toolbar.updateToolbarState());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to wait for the editor to be created to update the toolbar state because there are a lot of asynchronous things behind.

@artem-harbour artem-harbour marked this pull request as ready for review March 24, 2025 16:34
Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harbournick harbournick merged commit 18c858b into main Mar 24, 2025
6 checks passed
@harbournick harbournick deleted the artem-HAR-9336 branch March 24, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants