-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AI Assistant: Display AI sidebar on first highlight hover (#38468)
* rename localStorage entries * show sidebar on first hover * changelog * check if section is already open * move hover event to highlight instead of popover * remove async
- Loading branch information
Showing
5 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/update-jetpack-ai-breve-first-hover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: other | ||
|
||
AI Assistant: Display AI sidebar on first highlight hover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...xtensions/plugins/ai-assistant-plugin/components/breve/utils/show-ai-assistant-section.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { dispatch } from '@wordpress/data'; | ||
|
||
export const showAiAssistantSection = async () => { | ||
const { clearSelectedBlock } = dispatch( 'core/block-editor' ); | ||
const { enableComplementaryArea } = dispatch( 'core/interface' ) as { | ||
enableComplementaryArea: ( area: string, slot: string ) => Promise< void >; | ||
}; | ||
|
||
// Clear any block selection, because selected blocks have precedence on settings sidebar | ||
clearSelectedBlock(); | ||
await enableComplementaryArea( 'core/edit-post', 'jetpack-sidebar/jetpack' ); | ||
|
||
const panel = document.querySelector( '.jetpack-ai-assistant-panel' ); | ||
const isAlreadyOpen = panel?.classList.contains( 'is-opened' ); | ||
const button: HTMLElement | null | undefined = panel?.querySelector( 'h2 button' ); | ||
|
||
if ( isAlreadyOpen ) { | ||
// Close it before opening it to ensure the content is scrolled to view | ||
button?.click(); | ||
} | ||
|
||
setTimeout( () => { | ||
button?.click(); | ||
}, 50 ); | ||
}; |