Skip to content

Commit dbf7051

Browse files
Core: Add tabindex to code blocks to enable keyboard navigation (#2799)
1 parent 7e5f78f commit dbf7051

File tree

8 files changed

+33
-15
lines changed

8 files changed

+33
-15
lines changed

components/prism-core.js

+6
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,12 @@ var _ = {
558558

559559
_.hooks.run('before-sanity-check', env);
560560

561+
// plugins may change/add the parent/element
562+
parent = env.element.parentElement;
563+
if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
564+
parent.setAttribute('tabindex', '0');
565+
}
566+
561567
if (!env.code) {
562568
_.hooks.run('complete', env);
563569
callback && callback.call(env.element);

components/prism-core.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Prism.hooks.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h2>
7373

7474
<dt class="tag-source">Source:</dt>
7575
<dd class="tag-source"><ul class="dummy"><li>
76-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line671">line 671</a>
76+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line677">line 677</a>
7777
</li></ul></dd>
7878

7979

@@ -152,7 +152,7 @@ <h4 class="name" id=".add"><span class="type-signature">(static) </span>add<span
152152

153153
<dt class="tag-source">Source:</dt>
154154
<dd class="tag-source"><ul class="dummy"><li>
155-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line686">line 686</a>
155+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line692">line 692</a>
156156
</li></ul></dd>
157157

158158

@@ -314,7 +314,7 @@ <h4 class="name" id=".run"><span class="type-signature">(static) </span>run<span
314314

315315
<dt class="tag-source">Source:</dt>
316316
<dd class="tag-source"><ul class="dummy"><li>
317-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line703">line 703</a>
317+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line709">line 709</a>
318318
</li></ul></dd>
319319

320320

docs/Prism.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ <h4 class="name" id=".highlight"><span class="type-signature">(static) </span>hi
263263

264264
<dt class="tag-source">Source:</dt>
265265
<dd class="tag-source"><ul class="dummy"><li>
266-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line612">line 612</a>
266+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line618">line 618</a>
267267
</li></ul></dd>
268268

269269

@@ -1157,7 +1157,7 @@ <h4 class="name" id=".tokenize"><span class="type-signature">(static) </span>tok
11571157

11581158
<dt class="tag-source">Source:</dt>
11591159
<dd class="tag-source"><ul class="dummy"><li>
1160-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line648">line 648</a>
1160+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line654">line 654</a>
11611161
</li></ul></dd>
11621162

11631163

docs/Token.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ <h4 class="name" id="Token"><span class="type-signature"></span>new Token<span c
8080

8181
<dt class="tag-source">Source:</dt>
8282
<dd class="tag-source"><ul class="dummy"><li>
83-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line737">line 737</a>
83+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line743">line 743</a>
8484
</li></ul></dd>
8585

8686

@@ -364,7 +364,7 @@ <h4 class="name" id="alias"><span class="type-signature"></span>alias<span class
364364

365365
<dt class="tag-source">Source:</dt>
366366
<dd class="tag-source"><ul class="dummy"><li>
367-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line764">line 764</a>
367+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line770">line 770</a>
368368
</li></ul></dd>
369369

370370

@@ -447,7 +447,7 @@ <h4 class="name" id="content"><span class="type-signature"></span>content<span c
447447

448448
<dt class="tag-source">Source:</dt>
449449
<dd class="tag-source"><ul class="dummy"><li>
450-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line756">line 756</a>
450+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line762">line 762</a>
451451
</li></ul></dd>
452452

453453

@@ -524,7 +524,7 @@ <h4 class="name" id="type"><span class="type-signature"></span>type<span class="
524524

525525
<dt class="tag-source">Source:</dt>
526526
<dd class="tag-source"><ul class="dummy"><li>
527-
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line747">line 747</a>
527+
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line753">line 753</a>
528528
</li></ul></dd>
529529

530530

0 commit comments

Comments
 (0)