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: README.md
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -76,9 +76,23 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
76
76
function(result_element) { /* Highlight function - with `pre code` code element */
77
77
/* Highlight code in result_element - code is already escaped so it doesn't become HTML */
78
78
},
79
-
true, /* Optional - Is the `pre` element styled as well as the `code` element? Changing this to false uses the code element as the scrollable one rather than the pre element */
80
-
true, /* Optional - This is used for editing code - setting this to true sets the `code` element's class to `language-<the code-input's lang attribute>` */
81
-
false/* Optional - Setting this to true passes the `<code-input>` element as a second argument to the highlight function to be used for getting data- attribute values and using the DOM for the code-input */,
79
+
80
+
true, /* Optional - Is the `pre` element styled as well as the `code` element?
81
+
* Changing this to false uses the code element as the scrollable one rather
82
+
* than the pre element */
83
+
84
+
true, /* Optional - This is used for editing code - setting this to true sets the `code`
85
+
* element's class to `language-<the code-input's lang attribute>` */
86
+
87
+
false/* Optional - Setting this to true passes the `<code-input>` element as a second
88
+
* argument to the highlight function to be used for getting data- attribute values
89
+
* and using the DOM for the code-input */,
90
+
91
+
true/* Optional - Leaving this as true uses code-input's default fix for preventing duplicate
92
+
* results in Ctrl+F searching from the input and result elements, and setting this to false
93
+
* indicates your highlighting function implements its own fix. The default fix works by moving
94
+
* text content from elements to CSS ::before pseudo-elements after highlighting. */
Copy file name to clipboardExpand all lines: code-input.d.ts
+13-2Lines changed: 13 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -164,10 +164,11 @@ export class Template {
164
164
* @param {boolean} preElementStyled - is the `<pre>` element CSS-styled as well as the `<code>` element? If true, `<pre>` element's scrolling is synchronised; if false, `<code>` element's scrolling is synchronised.
165
165
* @param {boolean} isCode - is this for writing code? If true, the code-input's lang HTML attribute can be used, and the `<code>` element will be given the class name 'language-[lang attribute's value]'.
166
166
* @param {false} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
167
+
* @param {boolean} autoDisableDuplicateSearching - Leaving this as true uses code-input's default fix for preventing duplicate results in Ctrl+F searching from the input and result elements, and setting this to false indicates your highlighting function implements its own fix. The default fix works by moving text content from elements to CSS `::before` pseudo-elements after highlighting.
167
168
* @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
* **When `includeCodeInputInHighlightFunc` is `true`, `highlight` takes two parameters: the `<pre><code>` element, and the `<code-input>` element.**
173
174
*
@@ -177,15 +178,25 @@ export class Template {
177
178
* @param {boolean} preElementStyled - is the `<pre>` element CSS-styled as well as the `<code>` element? If true, `<pre>` element's scrolling is synchronised; if false, `<code>` element's scrolling is synchronised.
178
179
* @param {boolean} isCode - is this for writing code? If true, the code-input's lang HTML attribute can be used, and the `<code>` element will be given the class name 'language-[lang attribute's value]'.
179
180
* @param {true} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
181
+
* @param {boolean} autoDisableDuplicateSearching - Leaving this as true uses code-input's default fix for preventing duplicate results in Ctrl+F searching from the input and result elements, and setting this to false indicates your highlighting function implements its own fix. The default fix works by moving text content from elements to CSS `::before` pseudo-elements after highlighting.
180
182
* @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
if(!(typeoftemplateName=="string"||templateNameinstanceofString))throwTypeError(`code-input: Template for "${templateName}" must be a string.`);
106
+
if(!(typeoftemplateName=="string"||templateNameinstanceofString))throwTypeError(`code-input: Name of template "${templateName}" must be a string.`);
107
107
if(!(typeoftemplate.highlight=="function"||template.highlightinstanceofFunction))throwTypeError(`code-input: Template for "${templateName}" invalid, because the highlight function provided is not a function; it is "${template.highlight}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
108
108
if(!(typeoftemplate.includeCodeInputInHighlightFunc=="boolean"||template.includeCodeInputInHighlightFuncinstanceofBoolean))throwTypeError(`code-input: Template for "${templateName}" invalid, because the includeCodeInputInHighlightFunc value provided is not a true or false; it is "${template.includeCodeInputInHighlightFunc}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
109
109
if(!(typeoftemplate.preElementStyled=="boolean"||template.preElementStyledinstanceofBoolean))throwTypeError(`code-input: Template for "${templateName}" invalid, because the preElementStyled value provided is not a true or false; it is "${template.preElementStyled}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
110
110
if(!(typeoftemplate.isCode=="boolean"||template.isCodeinstanceofBoolean))throwTypeError(`code-input: Template for "${templateName}" invalid, because the isCode value provided is not a true or false; it is "${template.isCode}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
111
+
if(!(typeoftemplate.autoDisableDuplicateSearching=="boolean"||template.autoDisableDuplicateSearchinginstanceofBoolean))throwTypeError(`code-input: Template for "${templateName}" invalid, because the autoDisableDuplicateSearching value provided is not a true or false; it is "${template.autoDisableDuplicateSearching}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
111
112
if(!Array.isArray(template.plugins))throwTypeError(`code-input: Template for "${templateName}" invalid, because the plugin array provided is not an array; it is "${template.plugins}". Please make sure you use one of the constructors in codeInput.templates, and that you provide the correct arguments.`);
112
113
113
114
template.plugins.forEach((plugin,i)=>{
@@ -163,13 +164,20 @@ var codeInput = {
163
164
* @param {boolean} isCode - is this for writing code? If true, the code-input's lang HTML attribute can be used, and the `<code>` element will be given the class name 'language-[lang attribute's value]'.
164
165
* @param {boolean} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
165
166
* @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
0 commit comments