overtype 1.1.4 → 1.1.6
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/README.md +4 -1
- package/dist/overtype.esm.js +16 -9
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +16 -9
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +8 -7
- package/package.json +3 -2
- package/src/overtype.d.ts +147 -0
- package/src/parser.js +38 -15
- package/src/styles.js +1 -0
package/README.md
CHANGED
|
@@ -483,7 +483,10 @@ OverType uses a unique invisible textarea overlay approach:
|
|
|
483
483
|
## Contributors
|
|
484
484
|
|
|
485
485
|
Special thanks to:
|
|
486
|
-
- [Josh Doman](https://github.com/joshdoman) - Fixed inline code formatting preservation ([#6](https://github.com/panphora/overtype/pull/6))
|
|
486
|
+
- [Josh Doman](https://github.com/joshdoman) - Fixed inline code formatting preservation ([#6](https://github.com/panphora/overtype/pull/6)), improved code fence detection ([#19](https://github.com/panphora/overtype/pull/19))
|
|
487
|
+
- [kbhomes](https://github.com/kbhomes) - Fixed text selection desynchronization during overscroll ([#17](https://github.com/panphora/overtype/pull/17))
|
|
488
|
+
- [merlinz01](https://github.com/merlinz01) - Initial TypeScript definitions implementation ([#20](https://github.com/panphora/overtype/pull/20))
|
|
489
|
+
- [Max Bernstein](https://github.com/tekknolagi) - Fixed typo in website ([#11](https://github.com/panphora/overtype/pull/11))
|
|
487
490
|
|
|
488
491
|
## License
|
|
489
492
|
|
package/dist/overtype.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v1.1.
|
|
2
|
+
* OverType v1.1.6
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Demo User
|
|
@@ -105,7 +105,8 @@ var MarkdownParser = class {
|
|
|
105
105
|
* @returns {string|null} Parsed code fence or null
|
|
106
106
|
*/
|
|
107
107
|
static parseCodeBlock(html) {
|
|
108
|
-
|
|
108
|
+
const codeFenceRegex = /^`{3}[^`]*$/;
|
|
109
|
+
if (codeFenceRegex.test(html)) {
|
|
109
110
|
return `<div><span class="code-fence">${html}</span></div>`;
|
|
110
111
|
}
|
|
111
112
|
return null;
|
|
@@ -137,7 +138,7 @@ var MarkdownParser = class {
|
|
|
137
138
|
* @returns {string} HTML with code styling
|
|
138
139
|
*/
|
|
139
140
|
static parseInlineCode(html) {
|
|
140
|
-
return html.replace(
|
|
141
|
+
return html.replace(new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)", "g"), '<code><span class="syntax-marker">$1</span>$2<span class="syntax-marker">$3</span></code>');
|
|
141
142
|
}
|
|
142
143
|
/**
|
|
143
144
|
* Parse links
|
|
@@ -147,7 +148,7 @@ var MarkdownParser = class {
|
|
|
147
148
|
static parseLinks(html) {
|
|
148
149
|
return html.replace(/\[(.+?)\]\((.+?)\)/g, (match, text, url) => {
|
|
149
150
|
const anchorName = `--link-${this.linkIndex++}`;
|
|
150
|
-
return `<a href="${url}" style="anchor-name: ${anchorName}"><span class="syntax-marker">[</span>${text}<span class="syntax-marker">](</span><span class="syntax-marker">${url}</span><span class="syntax-marker">)</span></a>`;
|
|
151
|
+
return `<a href="${url}" style="anchor-name: ${anchorName}"><span class="syntax-marker">[</span>${text}<span class="syntax-marker">](</span><span class="syntax-marker link-url">${url}</span><span class="syntax-marker">)</span></a>`;
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
@@ -158,17 +159,22 @@ var MarkdownParser = class {
|
|
|
158
159
|
static parseInlineElements(text) {
|
|
159
160
|
let html = text;
|
|
160
161
|
html = this.parseInlineCode(html);
|
|
161
|
-
const
|
|
162
|
+
const sanctuaries = /* @__PURE__ */ new Map();
|
|
162
163
|
html = html.replace(/(<code>.*?<\/code>)/g, (match) => {
|
|
163
|
-
const placeholder = `\uE000${
|
|
164
|
-
|
|
164
|
+
const placeholder = `\uE000${sanctuaries.size}\uE001`;
|
|
165
|
+
sanctuaries.set(placeholder, match);
|
|
165
166
|
return placeholder;
|
|
166
167
|
});
|
|
167
168
|
html = this.parseLinks(html);
|
|
169
|
+
html = html.replace(/(<a[^>]*>.*?<\/a>)/g, (match) => {
|
|
170
|
+
const placeholder = `\uE000${sanctuaries.size}\uE001`;
|
|
171
|
+
sanctuaries.set(placeholder, match);
|
|
172
|
+
return placeholder;
|
|
173
|
+
});
|
|
168
174
|
html = this.parseBold(html);
|
|
169
175
|
html = this.parseItalic(html);
|
|
170
|
-
|
|
171
|
-
html = html.replace(placeholder,
|
|
176
|
+
sanctuaries.forEach((content, placeholder) => {
|
|
177
|
+
html = html.replace(placeholder, content);
|
|
172
178
|
});
|
|
173
179
|
return html;
|
|
174
180
|
}
|
|
@@ -1417,6 +1423,7 @@ function generateStyles(options = {}) {
|
|
|
1417
1423
|
/* Overflow */
|
|
1418
1424
|
overflow-y: auto !important;
|
|
1419
1425
|
overflow-x: auto !important;
|
|
1426
|
+
overscroll-behavior: none !important;
|
|
1420
1427
|
scrollbar-width: auto !important;
|
|
1421
1428
|
scrollbar-gutter: auto !important;
|
|
1422
1429
|
|