mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Merge pull request #24253 from overleaf/jdt-move-wf-instance-to-context
moving WF to editor context in anticipation for calling functionality… GitOrigin-RevId: 368554e9308fe8e9e7ef42a4abd78690ec834520
This commit is contained in:
committed by
Copybot
parent
9eb84d6ad5
commit
5ba43eb56c
@@ -19,6 +19,7 @@ import { useUserContext } from './user-context'
|
||||
import { saveProjectSettings } from '@/features/editor-left-menu/utils/api'
|
||||
import { PermissionsLevel } from '@/features/ide-react/types/permissions'
|
||||
import { useModalsContext } from '@/features/ide-react/context/modals-context'
|
||||
import { WritefullAPI } from './types/writefull-instance'
|
||||
|
||||
export const EditorContext = createContext<
|
||||
| {
|
||||
@@ -54,6 +55,8 @@ export const EditorContext = createContext<
|
||||
setHasPremiumSuggestion: (value: boolean) => void
|
||||
setPremiumSuggestionResetDate: (date: Date) => void
|
||||
premiumSuggestionResetDate: Date
|
||||
writefullInstance: WritefullAPI | null
|
||||
setWritefullInstance: (instance: WritefullAPI) => void
|
||||
}
|
||||
| undefined
|
||||
>(undefined)
|
||||
@@ -182,6 +185,9 @@ export const EditorProvider: FC = ({ children }) => {
|
||||
)
|
||||
}, [])
|
||||
|
||||
const [writefullInstance, setWritefullInstance] =
|
||||
useState<WritefullAPI | null>(null)
|
||||
|
||||
const value = useMemo(
|
||||
() => ({
|
||||
cobranding,
|
||||
@@ -206,6 +212,8 @@ export const EditorProvider: FC = ({ children }) => {
|
||||
setPremiumSuggestionResetDate,
|
||||
assistantUpgraded,
|
||||
setAssistantUpgraded,
|
||||
writefullInstance,
|
||||
setWritefullInstance,
|
||||
}),
|
||||
[
|
||||
cobranding,
|
||||
@@ -231,6 +239,8 @@ export const EditorProvider: FC = ({ children }) => {
|
||||
setPremiumSuggestionResetDate,
|
||||
assistantUpgraded,
|
||||
setAssistantUpgraded,
|
||||
writefullInstance,
|
||||
setWritefullInstance,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
export interface WritefullEvents {
|
||||
'writefull-login-complete': {
|
||||
method: 'email-password' | 'login-with-overleaf'
|
||||
}
|
||||
'writefull-received-suggestions': { numberOfSuggestions: number }
|
||||
'writefull-register-as-auto-account': { email: string }
|
||||
}
|
||||
|
||||
export interface WritefullAPI {
|
||||
init({
|
||||
hasAgreedToTOS,
|
||||
overleafUserId,
|
||||
}: {
|
||||
hasAgreedToTOS: boolean
|
||||
overleafUserId: string
|
||||
}): Promise<void>
|
||||
addEventListener<eventName extends keyof WritefullEvents>(
|
||||
name: eventName,
|
||||
callback: (detail: WritefullEvents[eventName]) => void
|
||||
): void
|
||||
}
|
||||
Reference in New Issue
Block a user