Skip to content

Commit de24423

Browse files
committed
fix: swift highlight position scroll fix
1 parent 0706744 commit de24423

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

examples.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,22 @@ fun main(args: Array<String>) {
235235

236236
</div>
237237

238+
<div class="kotlin-code" data-target-platform="swift-export" data-version="2.0.0-RC3" theme="kotlin-docs">
239+
240+
```kotlin
241+
fun mul(a: Int, b: Int): Int {
242+
return a * b
243+
}
244+
245+
fun main(args: Array<String>) {
246+
print(mul(-2, 4))
247+
println(" + 7 =")
248+
print(mul(-2, 4) + 7)
249+
}
250+
```
251+
252+
</div>
253+
238254
Use `data-target-platform` attribute with value `junit` for creating examples with tests:
239255

240256
<div class="kotlin-code" data-target-platform="junit">

src/executable-code/executable-fragment.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ export default class ExecutableFragment extends ExecutableCodeTemplate {
515515
(elt) => code.parentNode.replaceChild(elt, code),
516516
{
517517
mode: 'swift',
518-
readOnly: 'nocursorgit st',
518+
readOnly: 'nocursor',
519+
scrollbarStyle: 'native',
519520
theme: this.state.theme,
520521
value: code.innerText,
521522
},

src/styles.scss

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ $wt-color-athens: #eaeaec;
2424
$wt-color-azure: #167dff;
2525

2626
.executable-fragment-wrapper {
27+
--playground-code-output-padding: 10px;
28+
2729
margin-bottom: 35px;
2830
position: relative;
2931

@@ -274,7 +276,7 @@ $wt-color-azure: #167dff;
274276
flex-grow: 1;
275277
font-family: $font-family-mono;
276278
overflow: auto;
277-
padding-left: 10px;
279+
padding-left: var(--playground-code-output-padding, 10px);
278280
padding-top: 15px;
279281
}
280282

@@ -560,3 +562,8 @@ div[label]:hover:after {
560562
color: black;
561563
border: 1px solid $wt-color-code;
562564
}
565+
566+
.code-output .CodeMirror {
567+
margin-left: calc(-1 * var(--playground-code-output-padding));
568+
padding-left: var(--playground-code-output-padding);
569+
}

0 commit comments

Comments
 (0)