forked from JetBrains/jewel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Markdown: synchronize scrolling between editor and preview (JetBrains…
…#690) Only ScrollState is supported because of its natural ability to scroll the view to an arbitrary coordinate, LazyListState doesn't allow this, and it only gives an opportunity to scroll to an item in a LazyColumn list and then to a position within the item. So, it requires a different approach (which can hopefully be adjusted to the proposed ScrollingSynchronizer API). Note that the change only enables auto-scrolling in a preview to match the position in the source, it doesn't work the other way around.
- Loading branch information
1 parent
547e4c2
commit 65e3f14
Showing
15 changed files
with
720 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
markdown/core/src/main/kotlin/org/jetbrains/jewel/markdown/MarkdownMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.jetbrains.jewel.markdown | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.CompositionLocalProvider | ||
import org.jetbrains.jewel.foundation.ExperimentalJewelApi | ||
import org.jetbrains.jewel.markdown.extensions.LocalMarkdownMode | ||
import org.jetbrains.jewel.markdown.scrolling.ScrollingSynchronizer | ||
|
||
@ExperimentalJewelApi | ||
public sealed interface MarkdownMode { | ||
public val withEditor: Boolean | ||
public val scrollingSynchronizer: ScrollingSynchronizer? | ||
|
||
public object PreviewOnly : MarkdownMode { | ||
override val withEditor: Boolean = false | ||
override val scrollingSynchronizer: ScrollingSynchronizer? = null | ||
} | ||
|
||
public class WithEditor(public override val scrollingSynchronizer: ScrollingSynchronizer?) : MarkdownMode { | ||
override val withEditor: Boolean = true | ||
} | ||
} | ||
|
||
@ExperimentalJewelApi | ||
@Composable | ||
public fun WithMarkdownMode(mode: MarkdownMode, content: @Composable () -> Unit) { | ||
CompositionLocalProvider(LocalMarkdownMode provides mode) { content() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.