overleaf/services/web/frontend/js/shared/context/ide-angular-provider.tsx
Tim Down 537673cdf6 Merge pull request #15415 from overleaf/td-scope-store-and-emitter-fixed
IDE scope store and emitter with fixed PDF URLs

GitOrigin-RevId: 9d33bad8a006bb55714878332f78932538dd8921
2023-10-25 08:05:07 +00:00

25 lines
878 B
TypeScript

import { FC, useState } from 'react'
import { AngularScopeValueStore } from '@/features/ide-react/scope-value-store/angular-scope-value-store'
import { AngularScopeEventEmitter } from '@/features/ide-react/scope-event-emitter/angular-scope-event-emitter'
import { Ide, IdeProvider } from '@/shared/context/ide-context'
import { getMockIde } from '@/shared/context/mock/mock-ide'
export const IdeAngularProvider: FC<{ ide?: Ide }> = ({ ide, children }) => {
const [ideValue] = useState(() => ide || getMockIde())
const [scopeStore] = useState(
() => new AngularScopeValueStore(ideValue.$scope)
)
const [scopeEventEmitter] = useState(
() => new AngularScopeEventEmitter(ideValue.$scope)
)
return (
<IdeProvider
ide={ideValue}
scopeStore={scopeStore}
scopeEventEmitter={scopeEventEmitter}
>
{children}
</IdeProvider>
)
}