diff --git a/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt b/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt new file mode 100644 index 000000000000..9cfff8651e39 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/codeInsight/actions/ReaderModeMatcher.kt @@ -0,0 +1,18 @@ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.intellij.codeInsight.actions + +import com.intellij.codeInsight.actions.ReaderModeProvider.ReaderMode +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile + +/** + * Use it to override file <--> reader mode matching + */ +interface ReaderModeMatcher { + /** + * It's triggered on Reader Mode to check if file matches mode specified. + * + * @return null if unable to decide + */ + fun matches(project: Project, file: VirtualFile, mode: ReaderMode): Boolean? +} \ No newline at end of file diff --git a/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt b/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt index e9d23e1c1b2b..5c665ba4a67e 100644 --- a/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt +++ b/platform/platform-api/src/com/intellij/codeInsight/actions/ReaderModeSettings.kt @@ -14,6 +14,7 @@ import com.intellij.psi.PsiManager class ReaderModeSettings : PersistentStateComponentWithModificationTracker { companion object { private var EP_READER_MODE_PROVIDER = ExtensionPointName("com.intellij.readerModeProvider") + private var EP_READER_MODE_MATCHER = ExtensionPointName("com.intellij.readerModeMatcher") @JvmStatic fun instance(project: Project): ReaderModeSettings { @@ -32,12 +33,19 @@ class ReaderModeSettings : PersistentStateComponentWithModificationTracker inLibraries || !isWritable ReaderMode.LIBRARIES -> inLibraries ReaderMode.READ_ONLY -> !isWritable diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index accca6a61508..39a9526800fc 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -581,6 +581,7 @@ +