@webcoder49/code-input 2.5.0 → 2.6.0
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/LICENSE +1 -1
- package/README.md +9 -126
- package/code-input.css +71 -33
- package/code-input.d.ts +135 -59
- package/code-input.js +201 -110
- package/code-input.min.css +1 -1
- package/code-input.min.js +12 -1
- package/docs/LICENSE +3 -0
- package/docs/LICENSE.CC-BY-SA-4.0 +116 -0
- package/docs/LICENSE.CC0-1.0 +30 -0
- package/docs/README.md +5 -0
- package/docs/_index.md +308 -0
- package/docs/i18n/_index.md +52 -0
- package/docs/interface/_index.md +3 -0
- package/docs/interface/css/_index.md +12 -0
- package/docs/interface/forms/_index.md +17 -0
- package/docs/interface/js/_index.md +11 -0
- package/docs/modules-and-frameworks/_index.md +3 -0
- package/docs/modules-and-frameworks/custom/_index.md +9 -0
- package/docs/modules-and-frameworks/hljs/_index.md +13 -0
- package/docs/modules-and-frameworks/hljs/esm/_index.md +71 -0
- package/docs/modules-and-frameworks/hljs/nuxt/_index.md +250 -0
- package/docs/modules-and-frameworks/hljs/nuxt/nuxt-demo-screenshot.png +0 -0
- package/docs/modules-and-frameworks/hljs/vue/_index.md +233 -0
- package/docs/modules-and-frameworks/hljs/vue/vue-demo-screenshot.png +0 -0
- package/docs/modules-and-frameworks/prism/_index.md +14 -0
- package/docs/plugins/_index.md +676 -0
- package/docs/plugins/new/_index.md +52 -0
- package/docs/theory/_index.md +9 -0
- package/esm/.code-input.mjs.kate-swp +0 -0
- package/esm/README.md +23 -0
- package/esm/code-input.mjs +2 -0
- package/package.json +83 -7
- package/plugins/README.md +2 -0
- package/plugins/auto-close-brackets.js +25 -7
- package/plugins/auto-close-brackets.min.js +1 -1
- package/plugins/autocomplete.js +6 -6
- package/plugins/autocomplete.min.js +1 -1
- package/plugins/autodetect.js +4 -2
- package/plugins/autodetect.min.js +1 -1
- package/plugins/find-and-replace.css +0 -4
- package/plugins/find-and-replace.js +34 -8
- package/plugins/find-and-replace.min.css +1 -1
- package/plugins/find-and-replace.min.js +1 -1
- package/plugins/go-to-line.css +10 -5
- package/plugins/go-to-line.js +43 -6
- package/plugins/go-to-line.min.css +1 -1
- package/plugins/go-to-line.min.js +1 -1
- package/plugins/indent.js +29 -4
- package/plugins/indent.min.js +1 -1
- package/plugins/prism-line-numbers.css +14 -5
- package/plugins/prism-line-numbers.min.css +1 -1
- package/plugins/select-token-callbacks.js +3 -1
- package/plugins/select-token-callbacks.min.js +1 -1
- package/plugins/special-chars.css +13 -1
- package/plugins/special-chars.js +14 -4
- package/plugins/special-chars.min.css +1 -1
- package/plugins/special-chars.min.js +1 -1
- package/plugins/test.js +22 -7
- package/plugins/test.min.js +1 -1
- package/.github/workflows/minify.yml +0 -22
- package/.github/workflows/npm-publish.yml +0 -21
- package/CODE_OF_CONDUCT.md +0 -130
- package/CONTRIBUTING.md +0 -35
- package/tests/hljs.html +0 -55
- package/tests/i18n.html +0 -197
- package/tests/prism-match-braces-compatibility.js +0 -215
- package/tests/prism-match-braces-compatibility.min.js +0 -1
- package/tests/prism.html +0 -54
- package/tests/tester.js +0 -593
- package/tests/tester.min.js +0 -21
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# This workflow will publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
publish-npm:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v3
|
|
15
|
-
- uses: actions/setup-node@v3
|
|
16
|
-
with:
|
|
17
|
-
node-version: 16
|
|
18
|
-
registry-url: https://registry.npmjs.org/
|
|
19
|
-
- run: npm publish
|
|
20
|
-
env:
|
|
21
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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/tests/hljs.html
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
-
<title>code-input Tester</title>
|
|
7
|
-
|
|
8
|
-
<!--Import Highlight.JS-->
|
|
9
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
|
10
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
|
11
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/xml.min.js"></script>
|
|
12
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/css.min.js"></script>
|
|
13
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/javascript.min.js"></script>
|
|
14
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/python.min.js"></script>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<!--Import code-input-->
|
|
18
|
-
<link rel="stylesheet" href="../code-input.css">
|
|
19
|
-
<script src="../code-input.js"></script>
|
|
20
|
-
|
|
21
|
-
<!--Import code-input plugins-->
|
|
22
|
-
<script src="../plugins/auto-close-brackets.js"></script>
|
|
23
|
-
<script src="../plugins/autocomplete.js"></script>
|
|
24
|
-
<link rel="stylesheet" href="../plugins/autocomplete.css">
|
|
25
|
-
<script src="../plugins/autodetect.js"></script>
|
|
26
|
-
<script src="../plugins/find-and-replace.js"></script>
|
|
27
|
-
<link rel="stylesheet" href="../plugins/find-and-replace.css">
|
|
28
|
-
<script src="../plugins/go-to-line.js"></script>
|
|
29
|
-
<link rel="stylesheet" href="../plugins/go-to-line.css">
|
|
30
|
-
<script src="../plugins/indent.js"></script>
|
|
31
|
-
<script src="../plugins/select-token-callbacks.js"></script>
|
|
32
|
-
<script src="../plugins/special-chars.js"></script>
|
|
33
|
-
<link rel="stylesheet" href="../plugins/special-chars.css">
|
|
34
|
-
|
|
35
|
-
<script src="tester.js"></script>
|
|
36
|
-
</head>
|
|
37
|
-
<body>
|
|
38
|
-
<h1>code-input Tester (highlight.js)</h1>
|
|
39
|
-
<h2>If the page doesn't load, please reload it, and answer the questions in alert boxes.</h2>
|
|
40
|
-
<h4><a href="prism.html">Test for Prism.js</a></h4>
|
|
41
|
-
<p>This page carries out automated tests for the code-input library to check that both the core components and the plugins work in some ways. It doesn't fully cover every scenario so you should test any code you change by hand, but it's good for quickly checking a wide range of functionality works.</p>
|
|
42
|
-
|
|
43
|
-
<details id="collapse-results"><summary>Test Results (Click to Open)</summary><pre id="test-results"></pre></details>
|
|
44
|
-
<form method="GET" action="https://google.com/search" target="_blank">
|
|
45
|
-
<code-input name="q">console.log("Hello, World!");
|
|
46
|
-
// A second line
|
|
47
|
-
// A third line with <html> tags</code-input>
|
|
48
|
-
<input type="submit" value="Search Google For Code"/>
|
|
49
|
-
</form>
|
|
50
|
-
|
|
51
|
-
<script>
|
|
52
|
-
beginTest(true);
|
|
53
|
-
</script>
|
|
54
|
-
</body>
|
|
55
|
-
</html>
|
package/tests/i18n.html
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title>code-input should be global</title>
|
|
5
|
-
|
|
6
|
-
<meta charset="utf-8"/>
|
|
7
|
-
|
|
8
|
-
<!--Import Prism-->
|
|
9
|
-
<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/prism.min.js"></script>
|
|
11
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
|
|
12
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
|
|
13
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css">
|
|
14
|
-
<script src="prism-match-braces-compatibility.js"></script>
|
|
15
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/match-braces/prism-match-braces.min.css">
|
|
16
|
-
|
|
17
|
-
<!--Import Highlight.JS-->
|
|
18
|
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
|
19
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
|
20
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/xml.min.js"></script>
|
|
21
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/css.min.js"></script>
|
|
22
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/javascript.min.js"></script>
|
|
23
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/python.min.js"></script>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<!--Import code-input-->
|
|
27
|
-
<link rel="stylesheet" href="../code-input.css">
|
|
28
|
-
<script src="../code-input.js"></script>
|
|
29
|
-
|
|
30
|
-
<!--Import code-input plugins-->
|
|
31
|
-
<script src="../plugins/auto-close-brackets.js"></script>
|
|
32
|
-
<script src="../plugins/autocomplete.js"></script>
|
|
33
|
-
<script src="../plugins/autodetect.js"></script>
|
|
34
|
-
<link rel="stylesheet" href="../plugins/autocomplete.css">
|
|
35
|
-
<script src="../plugins/find-and-replace.js"></script>
|
|
36
|
-
<link rel="stylesheet" href="../plugins/find-and-replace.css">
|
|
37
|
-
<script src="../plugins/go-to-line.js"></script>
|
|
38
|
-
<link rel="stylesheet" href="../plugins/go-to-line.css">
|
|
39
|
-
<script src="../plugins/indent.js"></script>
|
|
40
|
-
<link rel="stylesheet" href="../plugins/prism-line-numbers.css">
|
|
41
|
-
<script src="../plugins/select-token-callbacks.js"></script>
|
|
42
|
-
<script src="../plugins/special-chars.js"></script>
|
|
43
|
-
<link rel="stylesheet" href="../plugins/special-chars.css">
|
|
44
|
-
|
|
45
|
-
<!--Register templates-->
|
|
46
|
-
<script>
|
|
47
|
-
codeInput.registerTemplate("hljs", codeInput.templates.hljs(hljs, [
|
|
48
|
-
/*new codeInput.plugins.AutoCloseBrackets(),
|
|
49
|
-
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
|
|
50
|
-
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
|
|
51
|
-
// Show popup
|
|
52
|
-
popupElem.style.display = "block";
|
|
53
|
-
popupElem.innerHTML = "Here's your popup!";
|
|
54
|
-
} else {
|
|
55
|
-
popupElem.style.display = "none";
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
new codeInput.plugins.Autodetect(),
|
|
59
|
-
new codeInput.plugins.FindAndReplace(),
|
|
60
|
-
new codeInput.plugins.GoToLine(),
|
|
61
|
-
new codeInput.plugins.Indent(true, 2),
|
|
62
|
-
new codeInput.plugins.SelectTokenCallbacks(codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks.createClassSynchronisation("in-selection"), false, true, true, true, true, false),
|
|
63
|
-
new codeInput.plugins.SpecialChars(true),*/
|
|
64
|
-
]));
|
|
65
|
-
codeInput.registerTemplate("prism", codeInput.templates.prism(Prism, [
|
|
66
|
-
/*new codeInput.plugins.AutoCloseBrackets(),
|
|
67
|
-
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
|
|
68
|
-
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
|
|
69
|
-
// Show popup
|
|
70
|
-
popupElem.style.display = "block";
|
|
71
|
-
popupElem.innerHTML = "Here's your popup!";
|
|
72
|
-
} else {
|
|
73
|
-
popupElem.style.display = "none";
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
new codeInput.plugins.FindAndReplace(),
|
|
77
|
-
new codeInput.plugins.GoToLine(),
|
|
78
|
-
new codeInput.plugins.Indent(true, 2),
|
|
79
|
-
new codeInput.plugins.SelectTokenCallbacks(new codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks(selectBrace, deselectAllBraces), true),
|
|
80
|
-
new codeInput.plugins.SpecialChars(true),*/
|
|
81
|
-
]));
|
|
82
|
-
|
|
83
|
-
// Attribution: Translated by Oliver Geer with some help from English Wiktionary
|
|
84
|
-
let findAndReplaceTranslations = {
|
|
85
|
-
start: "Buscar términos en su código.",
|
|
86
|
-
none: "No hay sucesos",
|
|
87
|
-
oneFound: "1 suceso encontrado.",
|
|
88
|
-
matchIndex: (index, count) => `${index} de ${count} sucesos.`,
|
|
89
|
-
error: (message) => `Error: ${message}`,
|
|
90
|
-
infiniteLoopError: "Causa un ciclo infinito",
|
|
91
|
-
closeDialog: "Cerrar el Diálogo y Regresar al Editor",
|
|
92
|
-
findPlaceholder: "Buscar",
|
|
93
|
-
findCaseSensitive: "Prestar atención a las minúsculas/mayúsculas",
|
|
94
|
-
findRegExp: "Utilizar expresión regular de JavaScript",
|
|
95
|
-
replaceTitle: "Reemplazar",
|
|
96
|
-
replacePlaceholder: "Reemplazar con",
|
|
97
|
-
findNext: "Buscar Suceso Próximo",
|
|
98
|
-
findPrevious: "Buscar Suceso Previo",
|
|
99
|
-
replaceActionShort: "Reemplazar",
|
|
100
|
-
replaceAction: "Reemplazar este Suceso",
|
|
101
|
-
replaceAllActionShort: "Reemplazar Todos",
|
|
102
|
-
replaceAllAction: "Reemplazar Todos los Sucesos"
|
|
103
|
-
};
|
|
104
|
-
let goToLineTranslations = {
|
|
105
|
-
closeDialog: "Cerrar el Diálogo y Regresar al Editor",
|
|
106
|
-
input: "Línea:Columno o Línea luego Retorno",
|
|
107
|
-
};
|
|
108
|
-
let indentTranslations = {
|
|
109
|
-
tabForIndentation: "Tabulador y Mayús-Tabulador actualmente para la indentación. Tecla Escape para activar la navegación por el teclado.",
|
|
110
|
-
tabForNavigation: "Tabulador y Mayús-Tabulador actualmente para la navegación por el teclado. Tecla para activar la indentación.",
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
codeInput.registerTemplate("hljs+", codeInput.templates.hljs(hljs, [
|
|
114
|
-
new codeInput.plugins.AutoCloseBrackets(),
|
|
115
|
-
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
|
|
116
|
-
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
|
|
117
|
-
// Show popup
|
|
118
|
-
popupElem.style.display = "block";
|
|
119
|
-
popupElem.innerHTML = "Here's your popup!";
|
|
120
|
-
} else {
|
|
121
|
-
popupElem.style.display = "none";
|
|
122
|
-
}
|
|
123
|
-
}),
|
|
124
|
-
new codeInput.plugins.Autodetect(),
|
|
125
|
-
new codeInput.plugins.FindAndReplace(true, true, findAndReplaceTranslations),
|
|
126
|
-
new codeInput.plugins.GoToLine(true, goToLineTranslations),
|
|
127
|
-
new codeInput.plugins.Indent(true, 2, {"(": ")", "[": "]", "{": "}"}, true, indentTranslations),
|
|
128
|
-
new codeInput.plugins.SelectTokenCallbacks(codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks.createClassSynchronisation("in-selection"), false, true, true, true, true, false),
|
|
129
|
-
//new codeInput.plugins.SpecialChars(true),
|
|
130
|
-
]));
|
|
131
|
-
codeInput.registerTemplate("prism+", codeInput.templates.prism(Prism, [
|
|
132
|
-
new codeInput.plugins.AutoCloseBrackets(),
|
|
133
|
-
new codeInput.plugins.Autocomplete(function(popupElem, textarea, selectionEnd) {
|
|
134
|
-
if(textarea.value.substring(selectionEnd-5, selectionEnd) == "popup") {
|
|
135
|
-
// Show popup
|
|
136
|
-
popupElem.style.display = "block";
|
|
137
|
-
popupElem.innerHTML = "Here's your popup!";
|
|
138
|
-
} else {
|
|
139
|
-
popupElem.style.display = "none";
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
new codeInput.plugins.FindAndReplace(true, true, findAndReplaceTranslations),
|
|
143
|
-
new codeInput.plugins.GoToLine(true, goToLineTranslations),
|
|
144
|
-
new codeInput.plugins.Indent(true, 2, {"(": ")", "[": "]", "{": "}"}, true, indentTranslations),
|
|
145
|
-
new codeInput.plugins.SelectTokenCallbacks(new codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks(selectBrace, deselectAllBraces), true),
|
|
146
|
-
//new codeInput.plugins.SpecialChars(true),
|
|
147
|
-
]));
|
|
148
|
-
</script>
|
|
149
|
-
</head>
|
|
150
|
-
<body>
|
|
151
|
-
<textarea dir="rtl" placeholder="textarea rtl"></textarea>
|
|
152
|
-
<textarea dir="ltr" placeholder="textarea ltr"></textarea>
|
|
153
|
-
<code-input dir="rtl" template="prism" language="markdown" placeholder="prism rtl"></code-input>
|
|
154
|
-
<code-input dir="ltr" template="prism" language="markdown" placeholder="prism ltr"></code-input>
|
|
155
|
-
<code-input dir="rtl" template="hljs" language="markdown" placeholder="hljs rtl"></code-input>
|
|
156
|
-
<code-input dir="ltr" template="hljs" language="markdown" placeholder="hljs ltr"></code-input>
|
|
157
|
-
<code-input dir="rtl" template="prism+" language="markdown" placeholder="prism rtl" class="line-numbers"></code-input>
|
|
158
|
-
<code-input dir="ltr" template="prism+" language="markdown" placeholder="prism ltr" class="line-numbers"></code-input>
|
|
159
|
-
<code-input dir="rtl" template="hljs+" language="markdown" placeholder="hljs rtl"></code-input>
|
|
160
|
-
<code-input dir="ltr" template="hljs+" language="markdown" placeholder="hljs ltr"></code-input>
|
|
161
|
-
|
|
162
|
-
<script>
|
|
163
|
-
rtl = `# ערך מומלץ ערך מומלץ
|
|
164
|
-
|
|
165
|
-
**לוטרת** הים היא יונק ימי קטן יחסית, חבר במשפחת הסמורים, שחי לחופיו הצפוניים והמזרחיים של האוקיינוס השקט.
|
|
166
|
-
|
|
167
|
-
ההגנה מפני קור אצל לוטרת הים מבוססת על שכבה עבה של פרווה, שהיא מהצפופות בעולם החי,
|
|
168
|
-
וזאת בשונה ממרבית היונקים הימיים הנסמכים על שכבת שומן. CC-BY-SA he.wikipedia.org אף שהיא מסוגלת להלך על היבשה, מבלה לוטרת הים את מרבית זמנה באוקיינוס הפתוח.
|
|
169
|
-
|
|
170
|
-
# مقالة اليوم المختارة
|
|
171
|
-
|
|
172
|
-
**الواقعية في الأدب الإسبا**ني هي حركة أدبية شكلت جزءًا من الواقعية، وهو تيار ثقافي ظهر في أوروبا في منتصف القرن التاسع عشر عقب اضمحلال اتجاهات الرومانسية.
|
|
173
|
-
|
|
174
|
-
ظهر سابقًا في فرنسا سنة 1850 حيث تطورت أصوله التي كانت موجودة بالفعل في الرومانسية، وخصوصًا في الأدب الذي يتناول العادات والتقاليد. CC-BY-SA ar.wikipedia.org التي كانت تعج بكل ما هو خيالي وجمالي خلاب، وعمدوا إلى الملاحظة الموضوعية للأشخاص والمجتمع والأحداث المعاصرة في محاولة منهم إلى تقديم صورة واضحة للمجتمع آنذاك.`;
|
|
175
|
-
ltr = `# From today's featured article
|
|
176
|
-
|
|
177
|
-
CC-BY-SA en.wikipedia.org: History is the systematic study of the past with its main focus on the human past.
|
|
178
|
-
|
|
179
|
-
Historians analyse and interpret primary and secondary sources to construct narratives about what happened and explain why it happened. RTL: مقالة اليوم المختارة They engage in source criticism to assess the authenticity, content, and reliability of these sources.
|
|
180
|
-
|
|
181
|
-
# निर्वाचित लेख
|
|
182
|
-
|
|
183
|
-
CC-BY-SA hi.wikipedia.org: **ग्लेशियर नेशनल पार्क** अमेरिकी राष्ट्रीय उद्यान है, जो कि कनाडा-संयुक्त राज्य अमेरिका की सीमा पर स्थित है। उद्यान संयुक्त राज्य के उत्तर-पश्चिमी मोंटाना राज्य
|
|
184
|
-
|
|
185
|
-
में स्थित है और कनाडा की ओर अल्बर्टा और ब्रिटिश कोलम्बिया प्रांतों से सटा हुआ है। उद्यान दस लाख एकड़ RTL: ערך מומלץ ערך מומלץ (4,000 किमी2) से अधिक क्षेत्र में फैला हुआ है और इसमें दो पर्वत श्रृंखला (रॉकी पर्वत की उप-श्रेणियाँ), 130 से अधिक नामित झीलें...`;
|
|
186
|
-
window.addEventListener("load", function() {
|
|
187
|
-
|
|
188
|
-
const elems = document.querySelectorAll("body > code-input, body > textarea");
|
|
189
|
-
for(let i = 0; i < elems.length; i++) {
|
|
190
|
-
let dir = elems[i].getAttribute("dir");
|
|
191
|
-
if(dir == "rtl") elems[i].value = rtl;
|
|
192
|
-
else elems[i].value = ltr;
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
</script>
|
|
196
|
-
</body>
|
|
197
|
-
</html>
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/* Modified from https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/match-braces/prism-match-braces.js
|
|
2
|
-
to enable codeInput SelectTokenCallbacks compatibility. Use:
|
|
3
|
-
new codeInput.plugins.SelectTokenCallbacks(new codeInput.plugins.SelectTokenCallbacks.TokenSelectorCallbacks(selectBrace, deselectAllBraces), true) */
|
|
4
|
-
// Additions on lines 6-10, and lines 84-98.
|
|
5
|
-
|
|
6
|
-
// code-input modification: ADD
|
|
7
|
-
// Callbacks
|
|
8
|
-
let selectBrace;
|
|
9
|
-
let deselectAllBraces;
|
|
10
|
-
// END code-input modification
|
|
11
|
-
(function () {
|
|
12
|
-
|
|
13
|
-
if (typeof Prism === 'undefined' || typeof document === 'undefined') {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function mapClassName(name) {
|
|
18
|
-
var customClass = Prism.plugins.customClass;
|
|
19
|
-
if (customClass) {
|
|
20
|
-
return customClass.apply(name, 'none');
|
|
21
|
-
} else {
|
|
22
|
-
return name;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
var PARTNER = {
|
|
27
|
-
'(': ')',
|
|
28
|
-
'[': ']',
|
|
29
|
-
'{': '}',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// The names for brace types.
|
|
33
|
-
// These names have two purposes: 1) they can be used for styling and 2) they are used to pair braces. Only braces
|
|
34
|
-
// of the same type are paired.
|
|
35
|
-
var NAMES = {
|
|
36
|
-
'(': 'brace-round',
|
|
37
|
-
'[': 'brace-square',
|
|
38
|
-
'{': 'brace-curly',
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// A map for brace aliases.
|
|
42
|
-
// This is useful for when some braces have a prefix/suffix as part of the punctuation token.
|
|
43
|
-
var BRACE_ALIAS_MAP = {
|
|
44
|
-
'${': '{', // JS template punctuation (e.g. `foo ${bar + 1}`)
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var LEVEL_WARP = 12;
|
|
48
|
-
|
|
49
|
-
var pairIdCounter = 0;
|
|
50
|
-
|
|
51
|
-
var BRACE_ID_PATTERN = /^(pair-\d+-)(close|open)$/;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Returns the brace partner given one brace of a brace pair.
|
|
55
|
-
*
|
|
56
|
-
* @param {HTMLElement} brace
|
|
57
|
-
* @returns {HTMLElement}
|
|
58
|
-
*/
|
|
59
|
-
function getPartnerBrace(brace) {
|
|
60
|
-
var match = BRACE_ID_PATTERN.exec(brace.id);
|
|
61
|
-
return document.querySelector('#' + match[1] + (match[2] == 'open' ? 'close' : 'open'));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @this {HTMLElement}
|
|
66
|
-
*/
|
|
67
|
-
function hoverBrace() {
|
|
68
|
-
if (!Prism.util.isActive(this, 'brace-hover', true)) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[this, getPartnerBrace(this)].forEach(function (e) {
|
|
73
|
-
e.classList.add(mapClassName('brace-hover'));
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @this {HTMLElement}
|
|
78
|
-
*/
|
|
79
|
-
function leaveBrace() {
|
|
80
|
-
[this, getPartnerBrace(this)].forEach(function (e) {
|
|
81
|
-
e.classList.remove(mapClassName('brace-hover'));
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
// code-input modification: ADD
|
|
85
|
-
selectBrace = (token) => {
|
|
86
|
-
if(BRACE_ID_PATTERN.test(token.id)) { // Check it's a brace
|
|
87
|
-
hoverBrace.apply(token); // Move the brace from a this to a parameter
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
deselectAllBraces = (tokenContainer) => {
|
|
91
|
-
// Remove selected class
|
|
92
|
-
let selectedClassTokens = tokenContainer.getElementsByClassName(mapClassName('brace-hover'));
|
|
93
|
-
// Use it like a queue, because as elements have their class name removed they are live-removed from the collection.
|
|
94
|
-
while(selectedClassTokens.length > 0) {
|
|
95
|
-
selectedClassTokens[0].classList.remove(mapClassName('brace-hover'));
|
|
96
|
-
}
|
|
97
|
-
}; // Moves the brace from a this to a parameter
|
|
98
|
-
// end code-input modification
|
|
99
|
-
/**
|
|
100
|
-
* @this {HTMLElement}
|
|
101
|
-
*/
|
|
102
|
-
function clickBrace() {
|
|
103
|
-
if (!Prism.util.isActive(this, 'brace-select', true)) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
[this, getPartnerBrace(this)].forEach(function (e) {
|
|
108
|
-
e.classList.add(mapClassName('brace-selected'));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Prism.hooks.add('complete', function (env) {
|
|
113
|
-
|
|
114
|
-
/** @type {HTMLElement} */
|
|
115
|
-
var code = env.element;
|
|
116
|
-
var pre = code.parentElement;
|
|
117
|
-
|
|
118
|
-
if (!pre || pre.tagName != 'PRE') {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// find the braces to match
|
|
123
|
-
/** @type {string[]} */
|
|
124
|
-
var toMatch = [];
|
|
125
|
-
if (Prism.util.isActive(code, 'match-braces')) {
|
|
126
|
-
toMatch.push('(', '[', '{');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (toMatch.length == 0) {
|
|
130
|
-
// nothing to match
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!pre.__listenerAdded) {
|
|
135
|
-
// code blocks might be highlighted more than once
|
|
136
|
-
pre.addEventListener('mousedown', function removeBraceSelected() {
|
|
137
|
-
// the code element might have been replaced
|
|
138
|
-
var code = pre.querySelector('code');
|
|
139
|
-
var className = mapClassName('brace-selected');
|
|
140
|
-
Array.prototype.slice.call(code.querySelectorAll('.' + className)).forEach(function (e) {
|
|
141
|
-
e.classList.remove(className);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
Object.defineProperty(pre, '__listenerAdded', { value: true });
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** @type {HTMLSpanElement[]} */
|
|
148
|
-
var punctuation = Array.prototype.slice.call(
|
|
149
|
-
code.querySelectorAll('span.' + mapClassName('token') + '.' + mapClassName('punctuation'))
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
/** @type {{ index: number, open: boolean, element: HTMLElement }[]} */
|
|
153
|
-
var allBraces = [];
|
|
154
|
-
|
|
155
|
-
toMatch.forEach(function (open) {
|
|
156
|
-
var close = PARTNER[open];
|
|
157
|
-
var name = mapClassName(NAMES[open]);
|
|
158
|
-
|
|
159
|
-
/** @type {[number, number][]} */
|
|
160
|
-
var pairs = [];
|
|
161
|
-
/** @type {number[]} */
|
|
162
|
-
var openStack = [];
|
|
163
|
-
|
|
164
|
-
for (var i = 0; i < punctuation.length; i++) {
|
|
165
|
-
var element = punctuation[i];
|
|
166
|
-
if (element.childElementCount == 0) {
|
|
167
|
-
var text = element.textContent;
|
|
168
|
-
text = BRACE_ALIAS_MAP[text] || text;
|
|
169
|
-
if (text === open) {
|
|
170
|
-
allBraces.push({ index: i, open: true, element: element });
|
|
171
|
-
element.classList.add(name);
|
|
172
|
-
element.classList.add(mapClassName('brace-open'));
|
|
173
|
-
openStack.push(i);
|
|
174
|
-
} else if (text === close) {
|
|
175
|
-
allBraces.push({ index: i, open: false, element: element });
|
|
176
|
-
element.classList.add(name);
|
|
177
|
-
element.classList.add(mapClassName('brace-close'));
|
|
178
|
-
if (openStack.length) {
|
|
179
|
-
pairs.push([i, openStack.pop()]);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
pairs.forEach(function (pair) {
|
|
186
|
-
var pairId = 'pair-' + (pairIdCounter++) + '-';
|
|
187
|
-
|
|
188
|
-
var opening = punctuation[pair[0]];
|
|
189
|
-
var closing = punctuation[pair[1]];
|
|
190
|
-
|
|
191
|
-
opening.id = pairId + 'open';
|
|
192
|
-
closing.id = pairId + 'close';
|
|
193
|
-
|
|
194
|
-
[opening, closing].forEach(function (e) {
|
|
195
|
-
e.addEventListener('mouseenter', hoverBrace);
|
|
196
|
-
e.addEventListener('mouseleave', leaveBrace);
|
|
197
|
-
e.addEventListener('click', clickBrace);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
var level = 0;
|
|
203
|
-
allBraces.sort(function (a, b) { return a.index - b.index; });
|
|
204
|
-
allBraces.forEach(function (brace) {
|
|
205
|
-
if (brace.open) {
|
|
206
|
-
brace.element.classList.add(mapClassName('brace-level-' + (level % LEVEL_WARP + 1)));
|
|
207
|
-
level++;
|
|
208
|
-
} else {
|
|
209
|
-
level = Math.max(0, level - 1);
|
|
210
|
-
brace.element.classList.add(mapClassName('brace-level-' + (level % LEVEL_WARP + 1)));
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
}());
|