mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Fix preview floating panel compatibility with both 2020.3 and 2021.1 (#973)
This commit is contained in:
@@ -11,5 +11,5 @@ plugin.until.build=212.*
|
||||
plugin.verifier.ide.versions=2020.3.2, 2021.1
|
||||
|
||||
platform.type=IC
|
||||
platform.version=2020.3.2
|
||||
platform.version=2021.1
|
||||
platform.download.sources=true
|
||||
|
||||
@@ -26,14 +26,20 @@ class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_E
|
||||
override fun register(toolbar: FloatingToolbarComponent, parentDisposable: Disposable) {
|
||||
try {
|
||||
// todo: use provided data context once 2020.3 is no longer supported
|
||||
val toolbarImpl = toolbar as? FloatingToolbarComponentImpl ?: return
|
||||
val editor = toolbarImpl.getData(CommonDataKeys.EDITOR.name) as? Editor ?: return
|
||||
val toolbarClass = FloatingToolbarComponentImpl::class.java
|
||||
val getDataMethod = toolbarClass.getMethod("getData", String::class.java)
|
||||
val editor = getDataMethod.invoke(toolbar, CommonDataKeys.EDITOR.name) as? Editor ?: return
|
||||
registerComponent(toolbar, editor, parentDisposable)
|
||||
} catch (e: Exception) {
|
||||
LOG.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun register(dataContext: DataContext, component: FloatingToolbarComponent, parentDisposable: Disposable) {
|
||||
val editor = dataContext.getData(CommonDataKeys.EDITOR) ?: return
|
||||
registerComponent(component, editor, parentDisposable)
|
||||
}
|
||||
|
||||
private fun registerComponent(
|
||||
component: FloatingToolbarComponent,
|
||||
editor: Editor,
|
||||
|
||||
Reference in New Issue
Block a user