overtype 1.0.0 → 1.0.2
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 +1 -1
- package/diagram.png +0 -0
- package/dist/overtype.esm.js +25 -15
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +25 -15
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +27 -31
- package/package.json +8 -7
- package/src/overtype.js +29 -6
- package/src/styles.js +0 -5
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ A lightweight markdown editor library with perfect WYSIWYG alignment using an in
|
|
|
16
16
|
|
|
17
17
|
## How it works
|
|
18
18
|
|
|
19
|
-

|
|
19
|
+
<!--  -->
|
|
20
20
|
|
|
21
21
|
We overlap an invisible textarea on top of styled output, giving the illusion of editing styled text using a plain textarea.
|
|
22
22
|
|
package/diagram.png
ADDED
|
Binary file
|
package/dist/overtype.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v1.0.
|
|
2
|
+
* OverType v1.0.1
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Demo User
|
|
@@ -340,18 +340,18 @@ function insertText(textarea, { text, selectionStart, selectionEnd }) {
|
|
|
340
340
|
}
|
|
341
341
|
const originalValue = textarea.value;
|
|
342
342
|
const hasSelection = originalSelectionStart !== originalSelectionEnd;
|
|
343
|
-
if (
|
|
343
|
+
if (canInsertText === null || canInsertText === true) {
|
|
344
344
|
textarea.contentEditable = "true";
|
|
345
345
|
try {
|
|
346
346
|
canInsertText = document.execCommand("insertText", false, text);
|
|
347
|
+
if (debugMode2)
|
|
348
|
+
console.log("execCommand returned:", canInsertText, "for text with", text.split("\n").length, "lines");
|
|
347
349
|
} catch (error) {
|
|
348
350
|
canInsertText = false;
|
|
351
|
+
if (debugMode2)
|
|
352
|
+
console.log("execCommand threw error:", error);
|
|
349
353
|
}
|
|
350
354
|
textarea.contentEditable = "false";
|
|
351
|
-
} else if (hasSelection) {
|
|
352
|
-
if (debugMode2)
|
|
353
|
-
console.log("Has selection, skipping execCommand and using manual mode");
|
|
354
|
-
canInsertText = false;
|
|
355
355
|
}
|
|
356
356
|
if (debugMode2) {
|
|
357
357
|
console.log("canInsertText before:", canInsertText);
|
|
@@ -1647,9 +1647,6 @@ function generateStyles(options = {}) {
|
|
|
1647
1647
|
gap: 4px;
|
|
1648
1648
|
padding: 8px;
|
|
1649
1649
|
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa));
|
|
1650
|
-
border: 1px solid var(--toolbar-border, var(--border, #e0e0e0));
|
|
1651
|
-
border-bottom: none;
|
|
1652
|
-
border-radius: 8px 8px 0 0;
|
|
1653
1650
|
overflow-x: auto;
|
|
1654
1651
|
-webkit-overflow-scrolling: touch;
|
|
1655
1652
|
}
|
|
@@ -1712,8 +1709,6 @@ function generateStyles(options = {}) {
|
|
|
1712
1709
|
|
|
1713
1710
|
/* Adjust wrapper when toolbar is present */
|
|
1714
1711
|
.overtype-container .overtype-toolbar + .overtype-wrapper {
|
|
1715
|
-
border-radius: 0 0 8px 8px;
|
|
1716
|
-
border-top: none;
|
|
1717
1712
|
}
|
|
1718
1713
|
|
|
1719
1714
|
/* Mobile toolbar adjustments */
|
|
@@ -2030,6 +2025,7 @@ var _OverType = class _OverType {
|
|
|
2030
2025
|
*/
|
|
2031
2026
|
_init(element, options = {}) {
|
|
2032
2027
|
this.element = element;
|
|
2028
|
+
this.instanceTheme = options.theme || null;
|
|
2033
2029
|
this.options = this._mergeOptions(options);
|
|
2034
2030
|
this.instanceId = ++_OverType.instanceCount;
|
|
2035
2031
|
this.initialized = false;
|
|
@@ -2107,11 +2103,18 @@ var _OverType = class _OverType {
|
|
|
2107
2103
|
this.wrapper = wrapper;
|
|
2108
2104
|
this.container = document.createElement("div");
|
|
2109
2105
|
this.container.className = "overtype-container";
|
|
2110
|
-
const
|
|
2111
|
-
const themeName = typeof
|
|
2106
|
+
const themeToUse = this.instanceTheme || _OverType.currentTheme || solar;
|
|
2107
|
+
const themeName = typeof themeToUse === "string" ? themeToUse : themeToUse.name;
|
|
2112
2108
|
if (themeName) {
|
|
2113
2109
|
this.container.setAttribute("data-theme", themeName);
|
|
2114
2110
|
}
|
|
2111
|
+
if (this.instanceTheme) {
|
|
2112
|
+
const themeObj = typeof this.instanceTheme === "string" ? getTheme(this.instanceTheme) : this.instanceTheme;
|
|
2113
|
+
if (themeObj && themeObj.colors) {
|
|
2114
|
+
const cssVars = themeToCSSVars(themeObj.colors);
|
|
2115
|
+
this.container.style.cssText += cssVars;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2115
2118
|
wrapper.parentNode.insertBefore(this.container, wrapper);
|
|
2116
2119
|
this.container.appendChild(wrapper);
|
|
2117
2120
|
}
|
|
@@ -2173,11 +2176,18 @@ var _OverType = class _OverType {
|
|
|
2173
2176
|
_createDOM() {
|
|
2174
2177
|
this.container = document.createElement("div");
|
|
2175
2178
|
this.container.className = "overtype-container";
|
|
2176
|
-
const
|
|
2177
|
-
const themeName = typeof
|
|
2179
|
+
const themeToUse = this.instanceTheme || _OverType.currentTheme || solar;
|
|
2180
|
+
const themeName = typeof themeToUse === "string" ? themeToUse : themeToUse.name;
|
|
2178
2181
|
if (themeName) {
|
|
2179
2182
|
this.container.setAttribute("data-theme", themeName);
|
|
2180
2183
|
}
|
|
2184
|
+
if (this.instanceTheme) {
|
|
2185
|
+
const themeObj = typeof this.instanceTheme === "string" ? getTheme(this.instanceTheme) : this.instanceTheme;
|
|
2186
|
+
if (themeObj && themeObj.colors) {
|
|
2187
|
+
const cssVars = themeToCSSVars(themeObj.colors);
|
|
2188
|
+
this.container.style.cssText += cssVars;
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2181
2191
|
this.wrapper = document.createElement("div");
|
|
2182
2192
|
this.wrapper.className = "overtype-wrapper";
|
|
2183
2193
|
if (this.options.showStats) {
|