How to show the welcome markdown file in editor when plugin is installed? Follow
Answered
Hello,
I'm trying to display a welcome markdown page on the editor when the plugin is installed using <postStartUpActivity>
Using TextEditorWithPreview.openPreviewForFile to display the markdown page in the editor on project startUp.
But, openPreviewForFile is shown as "Unresolved reference"
Is there any alternate that I can make use of to display the markdown page, when plugin is first installed?
Bellow is the code snippet which I'm using.
<postStartupActivity implementation="com.java.loaders.welcomePage"/>
class welcomePage: StartupActivity.DumbAware {
override fun runActivity(project: Project) {
val welcomeText = String(javaClass.getResourceAsStream("/Welcome/WelcomePage.md").readAllBytes())
val welcomeFile = LightVirtualFile("Welcome Page", welcomeFile)
invokeLater {
TextEditorWithPreview.openPreviewForFile(project, welcomeFile)
}
}
}
Please sign in to leave a comment.
Probably you're compiling against older version of IDE platform where the method does not yet exist.
On another note, forcing users to read page on project load is quite disruptive, I'd suggest to show notification with possibility to open such page if user wishes to do so. https://jetbrains.org/intellij/sdk/docs/user_interface_components/notifications.html
Also consider using RunOnceUtil https://plugins.jetbrains.com/docs/intellij/ide-infrastructure.html#running-tasks-once
Is there a way, to get the markdown file as a virtual file using the path?
I have created a markdown file in plugin project structure, But when I'm trying to get the file it gives me "null"
LocalFileSystem.getInstance().findFileByPath("/Welcome/WelcomePage.md")
I think previous approach with LightVirtual is fine and should work.