Skip to content

Commit 985393b

Browse files
author
WebCoder49
committed
Fix merge conflicts
2 parents 3cbc75e + 27975f7 commit 985393b

File tree

3 files changed

+609
-277
lines changed

3 files changed

+609
-277
lines changed

README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,17 @@ Unlike other front-end code-editor projects, the simplicity of how `code-input`
1616

1717
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.**
1818

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

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

27-
### Import `code-input`
23+
### 1. Import `code-input`
2824
- **First, import your favourite syntax-highlighter's JS and CSS theme files** to turn editable.
2925
- 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.
3026

3127
<details>
3228
<summary>
33-
Locally downloaded
29+
Locally downloaded (Click)
3430
</summary>
3531

3632
```html
@@ -41,17 +37,17 @@ Locally downloaded
4137
</details>
4238
<details>
4339
<summary>
44-
From JSDelivr CDN
40+
From JSDelivr CDN (click)
4541
</summary>
4642

4743
```html
4844
<!--In the <head>-->
49-
<script src="https://cdn.jsdelivr.net/npm/@webcoder49/code-input@1.5/code-input.min.js"></script>
50-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@webcoder49/code-input@1.5/code-input.min.css">
45+
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.3/code-input.min.js"></script>
46+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.3/code-input.min.css">
5147
```
5248
</details>
5349

54-
### Creating a template
50+
### 2. Creating a template
5551
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.
5652

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

80-
### Adding plugins
76+
### 3. Adding plugins
8177
[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:
8278
- Import the plugins' JS files after you have imported `code-input` and before registering the template.
8379
- Place instances of the plugins in the array of plugins argument when registering, like this:
@@ -102,7 +98,7 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
10298

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

105-
### Using the component
101+
### 4. Using the component
106102
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!
107103
```HTML
108104
<code-input lang="HTML"></code-input>
@@ -111,7 +107,6 @@ Now that you have registered a template, you can use the custom `<code-input>` e
111107
```HTML
112108
<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>
113109
```
114-
</details>
115110

116111
## Contributing
117112
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)