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: code-input.css
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ code-input {
27
27
/* --code-input_no-override-color: Set by JS for very short time to get whether color has been overriden */
28
28
color:var(--code-input_no-override-color, black);
29
29
/* --code-input_default-caret-color: Set by JS to be same as color property - currentColor won't work because it's lazily evaluated so gives transparent for the textarea */
Copy file name to clipboardExpand all lines: code-input.js
+32-9Lines changed: 32 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,8 @@ var codeInput = {
152
152
}
153
153
},
154
154
155
+
stylesheetI: 0,// Increments to give different classes to each code-input element so they can have custom styles synchronised internally without affecting the inline style
156
+
155
157
/**
156
158
* Please see `codeInput.templates.prism` or `codeInput.templates.hljs`.
157
159
* Templates are used in `<code-input>` elements and once registered with
@@ -445,6 +447,16 @@ var codeInput = {
445
447
*/
446
448
dialogContainerElement=null;
447
449
450
+
/**
451
+
* Like style attribute, but with a specificity of 1
452
+
* element, 1 class. Present so styles can be set on only
453
+
* this element while giving other code freedom of use of
Copy file name to clipboardExpand all lines: docs/interface/css/_index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,3 +10,5 @@ title = 'Styling `code-input` elements with CSS'
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`).
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
12
* For now, elements on top of `code-input` elements should have a CSS `z-index` at least 3 greater than the `code-input` element.
13
+
14
+
Please do **not** use `className` in JavaScript referring to code-input elements, because the code-input library needs to add its own classes to code-input elements for easier progressive enhancement. You can, however, use `classList` and `style` as much as you want - it will make your code cleaner anyway.
<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" data-manual></script><!--Remove data-manual if also using Prism normally-->
testAssertion("Core","Dark theme Caret/Placeholder Color Correct",confirm("Are the caret and placeholder near-white? (OK=Yes)"),"user-judged");
345
+
346
+
codeInputElement.style.color="red";
347
+
awaitwaitAsync(200);// Wait for colours to update
348
+
testAssertion("Core","Overriden color Caret/Placeholder Color Correct",confirm("Are the caret and placeholder (for Firefox) or just caret (for Chromium/WebKit, for consistency with textareas) red? (OK=Yes)"),"user-judged");
349
+
350
+
codeInputElement.style.removeProperty("color");
351
+
codeInputElement.style.caretColor="red";
352
+
awaitwaitAsync(200);// Wait for colours to update
353
+
testAssertion("Core","Overriden caret-color Caret/Placeholder Color Correct",confirm("Is the caret red and placeholder near-white? (OK=Yes)"),"user-judged");
0 commit comments