Scroll editor line into view after inserting a symbol (#6164)

GitOrigin-RevId: 20f80ec93148d36f951c956a942021f01490d120
This commit is contained in:
Alf Eaton 2022-01-10 13:56:36 +00:00 committed by Copybot
parent a6625e872f
commit 6dec7fab63
2 changed files with 12 additions and 1 deletions

View file

@ -56,6 +56,10 @@ export default EditorManager = (function () {
},
}
window.addEventListener('editor:insert-symbol', event => {
this.$scope.editor.insertSymbol(event.detail)
})
this.$scope.$on('entity:selected', (event, entity) => {
if (this.$scope.ui.view !== 'history' && entity.type === 'doc') {
return this.openDoc(entity)

View file

@ -77,7 +77,6 @@ export function EditorProvider({ children, settings }) {
const [permissionsLevel] = useScopeValue('permissionsLevel')
const [showSymbolPalette] = useScopeValue('editor.showSymbolPalette')
const [toggleSymbolPalette] = useScopeValue('editor.toggleSymbolPalette')
const [insertSymbol] = useScopeValue('editor.insertSymbol')
useEffect(() => {
if (ide?.socket) {
@ -119,6 +118,14 @@ export function EditorProvider({ children, settings }) {
)
}, [projectName, setTitle])
const insertSymbol = useCallback(symbol => {
window.dispatchEvent(
new CustomEvent('editor:insert-symbol', {
detail: symbol,
})
)
}, [])
const value = useMemo(
() => ({
cobranding,