You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/interface/css/_index.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ title = 'Styling `code-input` elements with CSS'
9
9
`code-input` elements can be styled like `textarea` elements in most cases; however, there are some exceptions:
10
10
* The CSS variable `--padding` should be used rather than the property `padding` (e.g. `<code-input style="--padding: 10px;">...`), or `--padding-left`, `--padding-right`, `--padding-top` and `--padding-bottom` instead of the CSS properties of the same names. For technical reasons, the value must have a unit (i.e. `0px`, not `0`). To avoid overcomplicating the code, this padding is always *included in* any width/heights of `code-input` elements, so if you want to style `textarea`s and `code-input` elements with best consistency set `box-sizing: border-box` on them.
11
11
* Background colours set on `code-input` elements will not work with highlighters that set background colours themselves - use `(code-input's selector) pre[class*="language-"]` for Prism.js or `.hljs` for highlight.js to target the highlighted element with higher specificity than the highlighter's theme. You may also set the `background-color` of the code-input element for its appearance when its template is unregistered / there is no JavaScript.
12
+
* To minimise the chance of [this bug](https://github.com/WebCoder49/code-input/issues/130): if you import a monospace font family from an online source (for example, Google Fonts or Bunny Fonts) to style `code-input` elements, and use a syntax highlighting theme that includes **bold text**, import both the standard (400) and bold (700) weights of the font.
12
13
* The caret and placeholder colour by default follow and give good contrast with the highlighted theme. Setting a CSS rule for `color` and/or `caret-color` properties on the code-input element will override this behaviour.
13
14
* For technical reasons, `code-input:focus` won't match anything. Use `code-input:has(textarea:focus)` instead.
14
15
* For now, elements on top of `code-input` elements should have a CSS `z-index` at least 3 greater than the `code-input` element.
--code-input_autogrow_internal-min-height:calc(1lh+2em+var(--padding-top,16px) +var(--padding-bottom,16px)); /* So minimum height possible while containing highlighted code */
height:calc(var(--code-input_autogrow_true-min-height) -var(--padding-top,16px) -var(--padding-bottom,16px)-2em)!important;/* So minimum height possible while containing highlighted code */
Copy file name to clipboardExpand all lines: tests/prism.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ <h4><a href="hljs.html">Test for highlight.js</a></h4>
41
41
<p>This page carries out automated tests for the code-input library to check that both the core components and the plugins work in some ways. It doesn't fully cover every scenario so you should test any code you change by hand, but it's good for quickly checking a wide range of functionality works.</p>
42
42
43
43
<detailsid="collapse-results"><summary>Test Results (Click to Open)</summary><preid="test-results"></pre></details>
testAssertion("Load","code-input_load Event Fired Late Enough",codeInputElem.querySelector("textarea:not([data-code-input-fallback])")!=null,"code-input_load event fired before non-fallback textarea element appeared");
testAssertion("FallbackTextarea","Displayed Correctly With More Padding",confirm("Is the highlighted 'log' properly aligned after the 'console.', which is then properly aligned inside the visible (non-highlighted) textarea? Also, there should be a lot of padding."),"user-judged");
testAssertion("FallbackTextarea","Displayed Correctly With No Padding",confirm("Does the element have zero padding, but otherwise the display remains correct?"),"user-judged");
145
+
codeInputElem.style.removeProperty("--padding");
146
+
awaitwaitAsync(50);// Wait for display to update
147
+
testAssertion("FallbackTextarea","Displayed Correctly By Default",confirm("Is the highlighted 'log' properly aligned after the 'console.', which is then properly aligned inside the visible (non-highlighted) textarea?"),"user-judged");
testAssertion("FallbackTextarea-Autogrow","Displayed Correctly With Default Autogrow Height",confirm("Is the element not very tall (but tall enough to properly show some code), but otherwise the display remains correct?"),"user-judged");
testAssertion("FallbackTextarea-Autogrow","Displayed Correctly With Default Autogrow Width",confirm("Is the element a sensible but narrow width, and otherwise the display remains correct?"),"user-judged");
testAssertion("FallbackTextarea-PrismLineNumbers","Displayed Correctly With line-numbers Class",confirm("Is there more padding to the left now, but otherwise the display remains correct?"),"user-judged");
testAssertion("Load","code-input_load Event Fired Early Enough",loadEventFired,"non-fallback textarea element appeared before code-input_load event");
225
+
window.clearInterval(interval);
226
+
timeToLoad+=10;
227
+
testData("Load","Time Taken for Textarea to Appear",timeToLoad+"ms (nearest 10)");
228
+
beginTestsAfterLoad(textarea,isHLJS);
229
+
}
161
230
},10);
162
231
}
163
232
@@ -178,16 +247,27 @@ function allowInputEvents(inputElement, codeInputElement=undefined) {
178
247
}
179
248
180
249
/* Start the tests using the textarea inside the code-input element and whether highlight.js is being used (as the Autodetect plugin only works with highlight.js, for example) */
testAssertion("FallbackTextarea-PrismLineNumbers","Alignment between Fallback and Loaded Texareas",confirm("Now with the highlighting, is all the code in the same horizontal position (don't mind the vertical offset by keyboard navigation instructions) as with the last question?"),"user-judged");
255
+
256
+
}else{
257
+
awaitwaitAsync(200);// Wait for display to update
258
+
testAssertion("FallbackTextarea+PrismLineNumbers","Alignment between Fallback and Loaded Texareas",confirm("Now with the highlighting, is all the code in the same horizontal position (don't mind the vertical offset by keyboard navigation instructions) as with the last question?"),"user-judged");
0 commit comments