import React, { createContext, useContext, ReactNode } from 'react';
import { WhpConfig } from '../types';

interface EditorConfigContextValue {
  whpConfig: WhpConfig | null;
  isWHP: boolean;
}

const EditorConfigContext = createContext<EditorConfigContextValue>({
  whpConfig: null,
  isWHP: false,
});

export const useEditorConfig = () => useContext(EditorConfigContext);

export const EditorConfigProvider: React.FC<{ config: WhpConfig | null; children: ReactNode }> = ({ config, children }) => {
  return (
    <EditorConfigContext.Provider value={{ whpConfig: config, isWHP: !!config }}>
      {children}
    </EditorConfigContext.Provider>
  );
};
