How can I add component in level viewport at editor mode using code

Hi. I’m trying make tool. Using my custom component.
But when I add component in level viewport at editor mode using code, it is not work. I make function in actor and when I run my code it crash when component call resgistercomponent. I know it caused by a world is missing. But I confused that I know world belong to persistant level, But editor mode don’t have a world? Then I saw engine code. Unreal engine use SSCSEditor class when the addcomponent in level viewport and editor mode. But I don’t know how can I access SSCSEditor class in actor. Do you have any idea adding component in editor mode. Please let me know.