Skip to content

Commit 27975f7

Browse files
authored
Update README.md
1 parent 612ab05 commit 27975f7

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# code-input
2-
[![View License](https://img.shields.io/github/license/webcoder49/code-input?style=for-the-badge)](LICENSE) [![View Releases](https://img.Shields.io/github/v/release/webcoder49/code-input?style=for-the-badge)](https://github.com/WebCoder49/code-input/releases) [![View the demo on CodePen](https://img.shields.io/static/v1?label=Demo&message=on%20CodePen&color=orange&logo=codepen&style=for-the-badge)](https://codepen.io/WebCoder49/details/jOypJOx)
2+
[![View License](https://img.shields.io/github/license/webcoder49/code-input?style=for-the-badge)](LICENSE) [![View Releases](https://img.sHields.io/github/v/release/webcoder49/code-input?style=for-the-badge)](https://github.com/WebCoder49/code-input/releases) [![View the demo on CodePen](https://img.shields.io/static/v1?label=Demo&message=on%20CodePen&color=orange&logo=codepen&style=for-the-badge)](https://codepen.io/WebCoder49/details/jOypJOx)
33

44
> ___Fully customisable syntax-highlighted textareas.___ [[🚀 View the Demo](https://codepen.io/WebCoder49/details/jOypJOx)]
55
@@ -14,21 +14,17 @@ Unlike other front-end code-editor projects, the simplicity of how `code-input`
1414

1515
The `<code-input>` element works like a `<textarea>` and therefore **works in HTML5 forms and supports using the `value` and `placeholder` attributes, as well as the `onchange` event.**
1616

17-
<details>
18-
<summary>
19-
20-
## Getting Started With `code-input`
21-
</summary>
17+
## 🚀 Getting Started With `code-input` (in 4 simple steps)
2218

2319
`code-input` is designed to be **both easy to use and customisable**. Here's how to use it to create syntax-highlighted textareas:
2420

25-
### Import `code-input`
21+
### 1. Import `code-input`
2622
- **First, import your favourite syntax-highlighter's JS and CSS theme files** to turn editable.
2723
- Then, import the CSS and JS files of `code-input` from a downloaded release or a CDN. The non-minified files are useful for using during development.
2824

2925
<details>
3026
<summary>
31-
Locally downloaded
27+
Locally downloaded (Click)
3228
</summary>
3329

3430
```html
@@ -39,17 +35,17 @@ Locally downloaded
3935
</details>
4036
<details>
4137
<summary>
42-
From JSDelivr CDN
38+
From JSDelivr CDN (click)
4339
</summary>
4440

4541
```html
4642
<!--In the <head>-->
47-
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.3/code-input.min.js"></script>
48-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.3/code-input.min.css">
43+
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1/code-input.min.js"></script>
44+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1/code-input.min.css">
4945
```
5046
</details>
5147

52-
### Creating a template
48+
### 2. Creating a template
5349
The next step is to set up a `template` to link `code-input` to your syntax-highlighter. If you're using Prism.js or highlight.js, you can use the built-in template, or you can create your own otherwise. In these examples, I am registering the template as `"syntax-highlighted"`, but you can use any template name as long as you are consistent.
5450

5551
- *Highlight.js:*
@@ -69,13 +65,13 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
6965
/* Highlight code in result_element - code is already escaped so it doesn't become HTML */
7066
},
7167
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 */
72-
true, /* Optional - This is used for editing code - setting this to true overrides the Tab key and uses it for indentation */
68+
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>` */
7369
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 */,
7470
[] // Array of plugins (see below)
7571
));
7672
```
7773

78-
### Adding plugins
74+
### 3. Adding plugins
7975
[Plugins](./plugins/) allow you to add extra features to a template, like [automatic indentation](plugins/indent.js) or [support for highlight.js's language autodetection](plugins/autodetect.js). To use them, just:
8076
- Import the plugins' JS files after you have imported `code-input` and before registering the template.
8177
- Place instances of the plugins in the array of plugins argument when registering, like this:
@@ -100,7 +96,7 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
10096

10197
To see a full list of plugins and their functions, please see [plugins/README.md](./plugins/README.md).
10298

103-
### Using the component
99+
### 4. Using the component
104100
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!
105101
```HTML
106102
<code-input lang="HTML"></code-input>
@@ -109,7 +105,6 @@ Now that you have registered a template, you can use the custom `<code-input>` e
109105
```HTML
110106
<code-input lang="HTML" placeholder="Type code here" value="<a href='https://github.com/WebCoder49/code-input'>code-input</a>" template="syntax-highlighted" onchange="console.log('Your code is', this.value)"></code-input>
111107
```
112-
</details>
113108

114109
## Contributing
115110
If you have any features you would like to add to `code-input`, or have found any bugs, please [open an issue](https://github.com/WebCoder49/code-input/issues) or [fork and submit a pull request](https://github.com/WebCoder49/code-input/fork)! All contributions to this open-source project would be greatly appreciated.

0 commit comments

Comments
 (0)