@webcoder49/code-input 2.0.3 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +130 -0
- package/CONTRIBUTING.md +35 -0
- package/README.md +19 -10
- package/code-input.css +51 -23
- package/code-input.d.ts +70 -4
- package/code-input.js +128 -180
- package/code-input.min.css +1 -1
- package/code-input.min.js +1 -1
- package/package.json +1 -1
- package/plugins/README.md +28 -7
- package/plugins/auto-close-brackets.js +61 -0
- package/plugins/auto-close-brackets.min.js +1 -0
- package/plugins/autocomplete.js +20 -13
- package/plugins/autocomplete.min.js +1 -1
- package/plugins/autodetect.js +8 -8
- package/plugins/autodetect.min.js +1 -1
- package/plugins/find-and-replace.css +145 -0
- package/plugins/find-and-replace.js +652 -0
- package/plugins/find-and-replace.min.css +1 -0
- package/plugins/find-and-replace.min.js +1 -0
- package/plugins/go-to-line.css +77 -0
- package/plugins/go-to-line.js +157 -0
- package/plugins/go-to-line.min.css +1 -0
- package/plugins/go-to-line.min.js +1 -0
- package/plugins/indent.js +162 -78
- package/plugins/indent.min.js +1 -1
- package/plugins/special-chars.css +0 -4
- package/plugins/special-chars.js +60 -88
- package/plugins/special-chars.min.css +1 -1
- package/plugins/special-chars.min.js +1 -1
- package/plugins/test.js +1 -2
- package/plugins/test.min.js +1 -1
- package/tests/hljs.html +54 -0
- package/tests/prism.html +55 -0
- package/tests/tester.js +529 -0
- package/tests/tester.min.js +18 -0
- package/plugins/debounce-update.js +0 -41
- package/plugins/debounce-update.min.js +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
🎉 This project is fuelled by open-source contributions, but to sustain this community we need to all follow the rules below.
|
|
4
|
+
|
|
5
|
+
## Our Pledge
|
|
6
|
+
|
|
7
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
8
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
9
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
10
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
11
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
12
|
+
and orientation.
|
|
13
|
+
|
|
14
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
15
|
+
diverse, inclusive, and healthy community.
|
|
16
|
+
|
|
17
|
+
## Our Standards
|
|
18
|
+
|
|
19
|
+
Examples of behavior that contributes to a positive environment for our
|
|
20
|
+
community include:
|
|
21
|
+
|
|
22
|
+
* Demonstrating empathy and kindness toward other people
|
|
23
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
24
|
+
* Giving and gracefully accepting constructive feedback
|
|
25
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
26
|
+
and learning from the experience
|
|
27
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
28
|
+
overall community
|
|
29
|
+
|
|
30
|
+
Examples of unacceptable behavior include:
|
|
31
|
+
|
|
32
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
33
|
+
advances of any kind
|
|
34
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
35
|
+
* Public or private harassment
|
|
36
|
+
* Publishing others' private information, such as a physical or email
|
|
37
|
+
address, without their explicit permission
|
|
38
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
39
|
+
professional setting
|
|
40
|
+
|
|
41
|
+
## Enforcement Responsibilities
|
|
42
|
+
|
|
43
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
44
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
45
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
46
|
+
or harmful.
|
|
47
|
+
|
|
48
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
49
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
50
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
51
|
+
decisions when appropriate.
|
|
52
|
+
|
|
53
|
+
## Scope
|
|
54
|
+
|
|
55
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
56
|
+
an individual is officially representing the community in public spaces.
|
|
57
|
+
Examples of representing our community include using an official e-mail address,
|
|
58
|
+
posting via an official social media account, or acting as an appointed
|
|
59
|
+
representative at an online or offline event.
|
|
60
|
+
|
|
61
|
+
## Enforcement
|
|
62
|
+
|
|
63
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
64
|
+
reported to the community leaders responsible for enforcement at
|
|
65
|
+
legal@webcoder49.dev.
|
|
66
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
67
|
+
|
|
68
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
69
|
+
reporter of any incident.
|
|
70
|
+
|
|
71
|
+
## Enforcement Guidelines
|
|
72
|
+
|
|
73
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
74
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
75
|
+
|
|
76
|
+
### 1. Correction
|
|
77
|
+
|
|
78
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
79
|
+
unprofessional or unwelcome in the community.
|
|
80
|
+
|
|
81
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
82
|
+
clarity around the nature of the violation and an explanation of why the
|
|
83
|
+
behavior was inappropriate. A public apology may be requested.
|
|
84
|
+
|
|
85
|
+
### 2. Warning
|
|
86
|
+
|
|
87
|
+
**Community Impact**: A violation through a single incident or series
|
|
88
|
+
of actions.
|
|
89
|
+
|
|
90
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
91
|
+
interaction with the people involved, including unsolicited interaction with
|
|
92
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
93
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
94
|
+
like social media. Violating these terms may lead to a temporary or
|
|
95
|
+
permanent ban.
|
|
96
|
+
|
|
97
|
+
### 3. Temporary Ban
|
|
98
|
+
|
|
99
|
+
**Community Impact**: A serious violation of community standards, including
|
|
100
|
+
sustained inappropriate behavior.
|
|
101
|
+
|
|
102
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
103
|
+
communication with the community for a specified period of time. No public or
|
|
104
|
+
private interaction with the people involved, including unsolicited interaction
|
|
105
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
106
|
+
Violating these terms may lead to a permanent ban.
|
|
107
|
+
|
|
108
|
+
### 4. Permanent Ban
|
|
109
|
+
|
|
110
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
111
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
112
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
113
|
+
|
|
114
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
115
|
+
the community.
|
|
116
|
+
|
|
117
|
+
## Attribution
|
|
118
|
+
|
|
119
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
120
|
+
version 2.0, available at
|
|
121
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
122
|
+
|
|
123
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
124
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
125
|
+
|
|
126
|
+
[homepage]: https://www.contributor-covenant.org
|
|
127
|
+
|
|
128
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
129
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
130
|
+
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributing to `code-input`
|
|
2
|
+
|
|
3
|
+
🎉**Here at `code-input`, contributions of all sizes are more than welcome. Below are some scenarios where you could contribute and how to do so.** Contributions are generally accepted when they help achieve at least one of the aims below, but others will be considered:
|
|
4
|
+
|
|
5
|
+
* The `code-input` element should act like a normal HTML `textarea` in all browsers, working with all of the normal attributes, events and other types of behaviour.
|
|
6
|
+
* The `code-input` element should be easy to use with all popular syntax-highlighting libraries.
|
|
7
|
+
* Any modifications of `code-input` that would be useful for the open-source community but are not core to this functionality should be available as optional plugins in the `plugins` folder. Here's where most feature contributions will go.
|
|
8
|
+
|
|
9
|
+
We will generally *not* consider the following contributions:
|
|
10
|
+
* Excess functionality and/or complexity in the main code-input files - these types of contributions should go in the plugin folder instead.
|
|
11
|
+
* Issues that have been closed as not planned in the past (you can search the issue list to check), unless you bring a change that overcomes the reason they were not planned.
|
|
12
|
+
|
|
13
|
+
This said, if you're not sure whether your change will be accepted, please ask in an issue.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
To keep this community productive and enjoyable, please [don't break our code of conduct](https://github.com/WebCoder49/code-input/blob/main/CODE_OF_CONDUCT.md).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
# Ways you could contribute:
|
|
21
|
+
## 1. I've found a bug but don't know how / don't have time to fix it.
|
|
22
|
+
If you think you've found a bug, please [submit an issue](https://github.com/WebCoder49/code-input/issues) with screenshots, how you found the bug, and copies of the console's logs if an error is in them. Please also mention the template and plugins you used (your `codeInput.registerTemplate(...)` snippet). We'd be more than happy to help you fix it. A demo using [CodePen](https://codepen.io/) would be incredibly useful.
|
|
23
|
+
|
|
24
|
+
## 2. I have implemented a feature / have thought of a potential feature for the library and think it could be useful for others.
|
|
25
|
+
The best way to implement a feature is as a plugin like those in the `plugins` folder of `code-input`. If you do this, you could contribute it as in point 3 below.
|
|
26
|
+
Otherwise, if you do not have the time needed / do not want to implement it, any potential plugins would be [welcome as an Issue](https://github.com/WebCoder49/code-input/issues) which specifies the uses and desired characteristics.
|
|
27
|
+
|
|
28
|
+
## 3. I want to contribute code that I need / have seen in the Issues.
|
|
29
|
+
Firstly, thank you for doing this! This is probably the most time consuming way of contributing but is also the most rewarding for both you and me as a maintainer.
|
|
30
|
+
|
|
31
|
+
Please first open an issue if one doesn't already exist, and assign yourself to it. Then, [make a fork of the repo and submit a pull request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
|
|
32
|
+
|
|
33
|
+
In the pull request, include the code updates for your feature / bug, and if you're adding a new feature make sure you comment your code so it's understandable to future contributors, and if you can, add unit tests for it in tests/tester.js. If you have any questions, just let me (@WebCoder49) know!
|
|
34
|
+
|
|
35
|
+
If an issue is open but already assigned to someone, it is probably already being worked on - you could still suggest a method of fixing it in the comments but shouldn't open a pull request as it would waste your time.
|
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/WebCoder49/code-input)[](https://www.npmjs.com/package/@webcoder49/code-input)
|
|
4
4
|
|
|
5
|
-
[](LICENSE) [](https://github.com/WebCoder49/code-input/releases) [](https://codepen.io/WebCoder49/
|
|
5
|
+
[](LICENSE) [](https://github.com/WebCoder49/code-input/releases) [](https://codepen.io/WebCoder49/full/jOypJOx)
|
|
6
6
|
|
|
7
|
-
> ___Fully customisable, editable syntax-highlighted textareas that can be placed in any HTML form.___ [[🚀 View the Demo](https://codepen.io/WebCoder49/
|
|
7
|
+
> ___Fully customisable, editable syntax-highlighted textareas that can be placed in any HTML form.___ [[🚀 View the Demo](https://codepen.io/WebCoder49/full/jOypJOx)]
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
*This demonstration uses themes from [Prism.js](https://prismjs.com/) and [highlight.js](https://highlightjs.org/), two syntax-highlighting programs which work well with and have compatibility built-in with code-input.*
|
|
@@ -76,9 +76,18 @@ 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
|
-
|
|
80
|
-
true, /* Optional -
|
|
81
|
-
|
|
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
|
+
|
|
82
91
|
[] // Array of plugins (see below)
|
|
83
92
|
));
|
|
84
93
|
```
|
|
@@ -99,7 +108,7 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
|
|
|
99
108
|
hljs,
|
|
100
109
|
[
|
|
101
110
|
new codeInput.plugins.Autodetect(),
|
|
102
|
-
new codeInput.plugins.Indent()
|
|
111
|
+
new codeInput.plugins.Indent(true, 2) // 2 spaces indentation
|
|
103
112
|
]
|
|
104
113
|
)
|
|
105
114
|
);
|
|
@@ -109,17 +118,17 @@ The next step is to set up a `template` to link `code-input` to your syntax-high
|
|
|
109
118
|
To see a full list of plugins and their functions, please see [plugins/README.md](./plugins/README.md).
|
|
110
119
|
|
|
111
120
|
### 4. Using the component
|
|
112
|
-
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 `
|
|
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!
|
|
113
122
|
```HTML
|
|
114
|
-
<code-input
|
|
123
|
+
<code-input language="HTML"></code-input>
|
|
115
124
|
```
|
|
116
125
|
*or*
|
|
117
126
|
```HTML
|
|
118
|
-
<code-input
|
|
127
|
+
<code-input language="HTML" placeholder="Type code here" template="syntax-highlighted" onchange="console.log('Your code is', this.value)">< href='https://github.com/WebCoder49/code-input'>code-input</a></code-input>
|
|
119
128
|
```
|
|
120
129
|
|
|
121
130
|
## Contributing
|
|
122
|
-
If you have any features you would like to add to `code-input
|
|
131
|
+
If you have any features you would like to add to `code-input` as plugins or core functionality, 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 will be greatly appreciated. You can see [more info in our `CONTRIBUTING.md` file](CONTRIBUTING.md).
|
|
123
132
|
|
|
124
133
|
|
|
125
134
|
|[](https://github.com/WebCoder49/code-input/graphs/contributors)|
|
package/code-input.css
CHANGED
|
@@ -4,42 +4,54 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
code-input {
|
|
7
|
-
/* Allow other
|
|
7
|
+
/* Allow other elements to be inside */
|
|
8
|
+
display: block;
|
|
9
|
+
overflow-y: auto;
|
|
10
|
+
overflow-x: auto;
|
|
8
11
|
position: relative;
|
|
9
12
|
top: 0;
|
|
10
13
|
left: 0;
|
|
11
|
-
display: block;
|
|
12
|
-
/* Only scroll inside elems */
|
|
13
|
-
overflow: hidden;
|
|
14
14
|
|
|
15
15
|
/* Normal inline styles */
|
|
16
16
|
margin: 8px;
|
|
17
17
|
--padding: 16px;
|
|
18
18
|
height: 250px;
|
|
19
|
-
|
|
20
|
-
font-size: normal;
|
|
19
|
+
font-size: inherit;
|
|
21
20
|
font-family: monospace;
|
|
22
21
|
line-height: 1.5; /* Inherited to child elements */
|
|
23
22
|
tab-size: 2;
|
|
24
23
|
caret-color: darkgrey;
|
|
25
24
|
white-space: pre;
|
|
26
|
-
padding: 0!important; /* Use --padding */
|
|
25
|
+
padding: 0!important; /* Use --padding to set the code-input element's padding */
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-template-columns: 100%;
|
|
28
|
+
grid-template-rows: 100%;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
code-input:not(.code-input_loaded) {
|
|
31
33
|
margin: 0px!important;
|
|
34
|
+
margin-bottom: calc(-1 * var(--padding, 16px))!important;
|
|
32
35
|
padding: var(--padding, 16px)!important;
|
|
33
36
|
border: 0;
|
|
34
|
-
width: calc(100% - var(--padding, 16px) * 2);
|
|
35
|
-
height: calc(100% - var(--padding, 16px) * 2);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
code-input:not(.code-
|
|
39
|
+
code-input textarea, code-input:not(.code-input_pre-element-styled) pre code, code-input.code-input_pre-element-styled pre {
|
|
40
|
+
/* Both elements need the same text and space styling so they are directly on top of each other */
|
|
39
41
|
margin: 0px!important;
|
|
40
|
-
margin-bottom: calc(-1 * var(--padding, 16px))!important;
|
|
41
42
|
padding: var(--padding, 16px)!important;
|
|
42
43
|
border: 0;
|
|
44
|
+
min-width: calc(100% - var(--padding, 16px) * 2);
|
|
45
|
+
min-height: calc(100% - var(--padding, 16px) * 2);
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
resize: none;
|
|
48
|
+
grid-row: 1;
|
|
49
|
+
grid-column: 1;
|
|
50
|
+
display: block;
|
|
51
|
+
}
|
|
52
|
+
code-input:not(.code-input_pre-element-styled) pre code, code-input.code-input_pre-element-styled pre {
|
|
53
|
+
height: max-content;
|
|
54
|
+
width: max-content;
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
code-input:not(.code-input_pre-element-styled) pre, code-input.code-input_pre-element-styled pre code {
|
|
@@ -58,15 +70,12 @@ code-input textarea, code-input pre, code-input pre * {
|
|
|
58
70
|
tab-size: inherit!important;
|
|
59
71
|
}
|
|
60
72
|
|
|
61
|
-
|
|
62
73
|
code-input textarea, code-input pre {
|
|
63
74
|
/* In the same place */
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
left: 0;
|
|
75
|
+
grid-column: 1;
|
|
76
|
+
grid-row: 1;
|
|
67
77
|
}
|
|
68
78
|
|
|
69
|
-
|
|
70
79
|
/* Move the textarea in front of the result */
|
|
71
80
|
|
|
72
81
|
code-input textarea {
|
|
@@ -79,22 +88,23 @@ code-input pre {
|
|
|
79
88
|
code-input:not(.code-input_loaded) pre, code-input:not(.code-input_loaded) textarea {
|
|
80
89
|
opacity: 0;
|
|
81
90
|
}
|
|
82
|
-
code-input:not(.code-input_loaded)::
|
|
91
|
+
code-input:not(.code-input_loaded)::before {
|
|
83
92
|
color: #ccc;
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
/* Make textarea almost completely transparent */
|
|
95
|
+
/* Make textarea almost completely transparent, except for caret and placeholder */
|
|
87
96
|
|
|
88
97
|
code-input textarea {
|
|
89
98
|
color: transparent;
|
|
90
99
|
background: transparent;
|
|
91
100
|
caret-color: inherit!important; /* Or choose your favourite color */
|
|
92
101
|
}
|
|
102
|
+
code-input textarea::placeholder {
|
|
103
|
+
color: lightgrey;
|
|
104
|
+
}
|
|
93
105
|
|
|
94
106
|
/* Can be scrolled */
|
|
95
107
|
code-input textarea, code-input pre {
|
|
96
|
-
overflow: auto!important;
|
|
97
|
-
|
|
98
108
|
white-space: inherit;
|
|
99
109
|
word-spacing: normal;
|
|
100
110
|
word-break: normal;
|
|
@@ -107,9 +117,27 @@ code-input textarea {
|
|
|
107
117
|
outline: none!important;
|
|
108
118
|
}
|
|
109
119
|
|
|
110
|
-
code-input:not(.code-input_registered)::
|
|
120
|
+
code-input:not(.code-input_registered)::before {
|
|
111
121
|
/* Display message to register */
|
|
112
122
|
content: "Use codeInput.registerTemplate to set up.";
|
|
113
123
|
display: block;
|
|
114
124
|
color: grey;
|
|
115
125
|
}
|
|
126
|
+
|
|
127
|
+
/* Contains dialog boxes that might appear as the result of a plugin.
|
|
128
|
+
Sticks to the top of the code-input element */
|
|
129
|
+
code-input .code-input_dialog-container {
|
|
130
|
+
z-index: 2;
|
|
131
|
+
|
|
132
|
+
position: sticky;
|
|
133
|
+
grid-row: 1;
|
|
134
|
+
grid-column: 1;
|
|
135
|
+
|
|
136
|
+
top: 0px;
|
|
137
|
+
left: 0;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 0;
|
|
140
|
+
|
|
141
|
+
/* Dialog boxes' text is left-aligned */
|
|
142
|
+
text-align: left;
|
|
143
|
+
}
|
package/code-input.d.ts
CHANGED
|
@@ -76,13 +76,26 @@ export namespace plugins {
|
|
|
76
76
|
constructor();
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Automatically closes pairs of brackets/quotes/other syntaxes in code, but also lets you choose the brackets this
|
|
81
|
+
* is activated for.
|
|
82
|
+
* Files: auto-close-brackets.js
|
|
83
|
+
*/
|
|
84
|
+
class AutoCloseBrackets extends Plugin {
|
|
85
|
+
/**
|
|
86
|
+
* Create an auto-close brackets plugin to pass into a template
|
|
87
|
+
* @param {Object} bracketPairs Opening brackets mapped to closing brackets, default and example {"(": ")", "[": "]", "{": "}", '"': '"'}. All brackets must only be one character.
|
|
88
|
+
*/
|
|
89
|
+
constructor(bracketPairs: Object);
|
|
90
|
+
}
|
|
91
|
+
|
|
79
92
|
/**
|
|
80
93
|
* Display a popup under the caret using the text in the code-input element. This works well with autocomplete suggestions.
|
|
81
94
|
* Files: autocomplete.js / autocomplete.css
|
|
82
95
|
*/
|
|
83
96
|
class Autocomplete extends Plugin {
|
|
84
97
|
/**
|
|
85
|
-
* Pass in a function to
|
|
98
|
+
* Pass in a function to create a plugin that displays the popup that takes in (popup element, textarea, textarea.selectionEnd).
|
|
86
99
|
* @param {function} updatePopupCallback a function to display the popup that takes in (popup element, textarea, textarea.selectionEnd).
|
|
87
100
|
*/
|
|
88
101
|
constructor(updatePopupCallback: (popupElem: HTMLElement, textarea: HTMLTextAreaElement, selectionEnd: number) => void);
|
|
@@ -110,13 +123,55 @@ export namespace plugins {
|
|
|
110
123
|
constructor(delayMs: number);
|
|
111
124
|
}
|
|
112
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Add Find-and-Replace (Ctrl+F for find, Ctrl+H for replace by default) functionality to the code editor.
|
|
128
|
+
* Files: find-and-replace.js / find-and-replace.css
|
|
129
|
+
*/
|
|
130
|
+
class FindAndReplace extends Plugin {
|
|
131
|
+
/**
|
|
132
|
+
* Create a find-and-replace command plugin to pass into a template
|
|
133
|
+
* @param {boolean} useCtrlF Should Ctrl+F be overriden for find-and-replace find functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, false)`.
|
|
134
|
+
* @param {boolean} useCtrlH Should Ctrl+H be overriden for find-and-replace replace functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element, true)`.
|
|
135
|
+
*/
|
|
136
|
+
constructor(useCtrlF?: boolean, useCtrlH?: boolean);
|
|
137
|
+
/**
|
|
138
|
+
* Show a find-and-replace dialog.
|
|
139
|
+
* @param {codeInput.CodeInput} codeInputElement the `<code-input>` element.
|
|
140
|
+
* @param {boolean} replacePartExpanded whether the replace part of the find-and-replace dialog should be expanded
|
|
141
|
+
*/
|
|
142
|
+
showPrompt(codeInput: CodeInput, replacePartExpanded: boolean): void;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Add basic Go-To-Line (ctrl-G by default) functionality to the code editor.
|
|
147
|
+
* Files: go-to-line.js / go-to-line.css
|
|
148
|
+
*/
|
|
149
|
+
class GoToLine extends Plugin {
|
|
150
|
+
/**
|
|
151
|
+
* Create a go-to-line command plugin to pass into a template
|
|
152
|
+
* @param {boolean} useCtrlG Should Ctrl+G be overriden for go-to-line functionality? If not, you can trigger it yourself using (instance of this plugin)`.showPrompt(code-input element)`.
|
|
153
|
+
*/
|
|
154
|
+
constructor(useCtrlG: boolean);
|
|
155
|
+
/**
|
|
156
|
+
* Show a search-like dialog prompting line number.
|
|
157
|
+
* @param {codeInput.CodeInput} codeInput the `<code-input>` element.
|
|
158
|
+
*/
|
|
159
|
+
showPrompt(codeInput: CodeInput): void;
|
|
160
|
+
}
|
|
161
|
+
|
|
113
162
|
/**
|
|
114
163
|
* Adds indentation using the `Tab` key, and auto-indents after a newline, as well as making it
|
|
115
164
|
* possible to indent/unindent multiple lines using Tab/Shift+Tab
|
|
116
165
|
* Files: indent.js
|
|
117
166
|
*/
|
|
118
167
|
class Indent extends Plugin {
|
|
119
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Create an indentation plugin to pass into a template
|
|
170
|
+
* @param {Boolean} defaultSpaces Should the Tab key enter spaces rather than tabs? Defaults to false.
|
|
171
|
+
* @param {Number} numSpaces How many spaces is each tab character worth? Defaults to 4.
|
|
172
|
+
* @param {Object} bracketPairs Opening brackets mapped to closing brackets, default and example {"(": ")", "[": "]", "{": "}"}. All brackets must only be one character, and this can be left as null to remove bracket-based indentation behaviour.
|
|
173
|
+
*/
|
|
174
|
+
constructor(defaultSpaces?: boolean, numSpaces?: Number, bracketPairs?: Object);
|
|
120
175
|
}
|
|
121
176
|
|
|
122
177
|
/**
|
|
@@ -159,10 +214,11 @@ export class Template {
|
|
|
159
214
|
* @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.
|
|
160
215
|
* @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]'.
|
|
161
216
|
* @param {false} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
|
|
217
|
+
* @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.
|
|
162
218
|
* @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
|
|
163
219
|
* @returns template object
|
|
164
220
|
*/
|
|
165
|
-
constructor(highlight?: (code: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, plugins?: Plugin[])
|
|
221
|
+
constructor(highlight?: (code: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, autoDisableDuplicateSearching?: boolean, plugins?: Plugin[])
|
|
166
222
|
/**
|
|
167
223
|
* **When `includeCodeInputInHighlightFunc` is `true`, `highlight` takes two parameters: the `<pre><code>` element, and the `<code-input>` element.**
|
|
168
224
|
*
|
|
@@ -172,15 +228,25 @@ export class Template {
|
|
|
172
228
|
* @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.
|
|
173
229
|
* @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]'.
|
|
174
230
|
* @param {true} includeCodeInputInHighlightFunc - Setting this to true passes the `<code-input>` element as a second argument to the highlight function.
|
|
231
|
+
* @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.
|
|
175
232
|
* @param {codeInput.Plugin[]} plugins - An array of plugin objects to add extra features - see `codeInput.Plugin`
|
|
176
233
|
* @returns template object
|
|
177
234
|
*/
|
|
178
|
-
constructor(highlight?: (code: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, plugins?: Plugin[])
|
|
235
|
+
constructor(highlight?: (code: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, autoDisableDuplicateSearching?: boolean, plugins?: Plugin[])
|
|
179
236
|
highlight: Function
|
|
180
237
|
preElementStyled: boolean
|
|
181
238
|
isCode: boolean
|
|
182
239
|
includeCodeInputInHighlightFunc: boolean
|
|
240
|
+
autoDisableDuplicateSearching: boolean
|
|
183
241
|
plugins: Plugin[]
|
|
242
|
+
/**
|
|
243
|
+
* @deprecated Please give a value for the `autoDisableDuplicateSearching` parameter.
|
|
244
|
+
*/
|
|
245
|
+
constructor(highlight?: (code: HTMLElement) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: false, plugins?: Plugin[])
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Please give a value for the `autoDisableDuplicateSearching` parameter.
|
|
248
|
+
*/
|
|
249
|
+
constructor(highlight?: (code: HTMLElement, codeInput: CodeInput) => void, preElementStyled?: boolean, isCode?: boolean, includeCodeInputInHighlightFunc?: true, plugins?: Plugin[])
|
|
184
250
|
}
|
|
185
251
|
|
|
186
252
|
/**
|