Skip to content

Commit 5f481ad

Browse files
authored
Merge pull request #84 from WebCoder49/several-bug-fixes
Several bug fixes - Fixes #80, #81, #82, #83
2 parents 0ff837d + 11c305f commit 5f481ad

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
118118
To see a full list of plugins and their functions, please see [plugins/README.md](./plugins/README.md).
119119

120120
### 4. Using the component
121-
Now that you have registered a template, you can use the custom `<code-input>` element in HTML. If you have more than one template registered, you need to add the template name as the `template` attribute. With the element, using the `lang` attribute will add a `language-{value}` class to the `pre code` block. You can now use HTML attributes and events to make your element as simple or interactive as you like!
121+
Now that you have registered a template, you can use the custom `<code-input>` element in HTML. If you have more than one template registered, you need to add the template name as the `template` attribute. With the element, using the `language` attribute will add a `language-{value}` class to the `pre code` block. You can now use HTML attributes and events to make your element as simple or interactive as you like!
122122
```HTML
123-
<code-input lang="HTML"></code-input>
123+
<code-input language="HTML"></code-input>
124124
```
125125
*or*
126126
```HTML
127-
<code-input lang="HTML" placeholder="Type code here" template="syntax-highlighted" onchange="console.log('Your code is', this.value)">&lt; href='https://github.com/WebCoder49/code-input'>code-input&lt;/a></code-input>
127+
<code-input language="HTML" placeholder="Type code here" template="syntax-highlighted" onchange="console.log('Your code is', this.value)">&lt; href='https://github.com/WebCoder49/code-input'>code-input&lt;/a></code-input>
128128
```
129129

130130
## Contributing

code-input.css

+3
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,7 @@ code-input .code-input_dialog-container {
137137
left: 0;
138138
width: 100%;
139139
height: 0;
140+
141+
/* Dialog boxes' text is left-aligned */
142+
text-align: left;
140143
}

code-input.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ var codeInput = {
427427
* Exposed child pre element where syntax-highlighted code is outputted.
428428
* Contains this.codeElement as its only child.
429429
*/
430-
preElement = null;
430+
preElement = null
431431
/**
432432
* Exposed child pre element's child code element where syntax-highlighted code is outputted.
433433
* Has this.preElement as its parent.

plugins/find-and-replace.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ codeInput.plugins.FindAndReplace = class extends codeInput.Plugin {
3434
if(!codeInput.pluginData.findAndReplace.dialog.classList.contains("code-input_find-and-replace_hidden-dialog")) {
3535
// Code updated and dialog open - re-highlight find matches
3636
codeInput.pluginData.findAndReplace.dialog.findMatchState.rehighlightMatches();
37+
this.updateMatchDescription(codeInput.pluginData.findAndReplace.dialog);
3738

3839
if(codeInput.pluginData.findAndReplace.dialog.findMatchState.numMatches == 0) {
3940
// No more matches after editing
@@ -429,15 +430,7 @@ codeInput.plugins.FindAndReplace.FindMatchState = class {
429430

430431
/* Highlight all currently found matches again if there are any matches */
431432
rehighlightMatches() {
432-
if(this.codeInput.value != this.lastValue) {
433-
this.updateMatches(this.lastSearchRegexp);
434-
} else {
435-
if(this.matchStartIndexes.length > 0) {
436-
for(let i = 0; i < this.matchStartIndexes.length; i++) {
437-
this.highlightMatch(i, this.codeInput.codeElement, this.matchStartIndexes[i], this.matchEndIndexes[i]);
438-
}
439-
}
440-
}
433+
this.updateMatches(this.lastSearchRegexp);
441434
this.focusMatch();
442435
}
443436

tests/prism.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<!--Import Prism-->
99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css">
10-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
1111
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
1212
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
1313
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css">

0 commit comments

Comments
 (0)