|
|
@ -26,14 +26,20 @@ class PreviewFloatingToolbarProvider : AbstractFloatingToolbarProvider(PREVIEW_E |
|
|
|
override fun register(toolbar: FloatingToolbarComponent, parentDisposable: Disposable) { |
|
|
|
override fun register(toolbar: FloatingToolbarComponent, parentDisposable: Disposable) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// todo: use provided data context once 2020.3 is no longer supported |
|
|
|
// todo: use provided data context once 2020.3 is no longer supported |
|
|
|
val toolbarImpl = toolbar as? FloatingToolbarComponentImpl ?: return |
|
|
|
val toolbarClass = FloatingToolbarComponentImpl::class.java |
|
|
|
val editor = toolbarImpl.getData(CommonDataKeys.EDITOR.name) as? Editor ?: return |
|
|
|
val getDataMethod = toolbarClass.getMethod("getData", String::class.java) |
|
|
|
|
|
|
|
val editor = getDataMethod.invoke(toolbar, CommonDataKeys.EDITOR.name) as? Editor ?: return |
|
|
|
registerComponent(toolbar, editor, parentDisposable) |
|
|
|
registerComponent(toolbar, editor, parentDisposable) |
|
|
|
} catch (e: Exception) { |
|
|
|
} catch (e: Exception) { |
|
|
|
LOG.error(e) |
|
|
|
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( |
|
|
|
private fun registerComponent( |
|
|
|
component: FloatingToolbarComponent, |
|
|
|
component: FloatingToolbarComponent, |
|
|
|
editor: Editor, |
|
|
|
editor: Editor, |
|
|
|