overtype 2.0.0 → 2.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 +6 -5
- package/dist/overtype-webcomponent.esm.js +111 -53
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +111 -53
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +55 -54
- package/dist/overtype.cjs +111 -53
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +111 -53
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +111 -53
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +51 -50
- package/package.json +9 -5
- package/src/link-tooltip.js +100 -9
- package/src/overtype.js +2 -15
- package/src/parser.js +1 -1
- package/src/styles.js +35 -34
- package/src/toolbar.js +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.0.
|
|
2
|
+
* OverType v2.0.2
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author Demo User
|
|
@@ -128,7 +128,7 @@ var OverTypeEditor = (() => {
|
|
|
128
128
|
return html.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/, (match, indent, checked, content) => {
|
|
129
129
|
if (isPreviewMode) {
|
|
130
130
|
const isChecked = checked.toLowerCase() === "x";
|
|
131
|
-
return `${indent}<li class="task-list"><input type="checkbox"
|
|
131
|
+
return `${indent}<li class="task-list"><input type="checkbox" ${isChecked ? "checked" : ""}> ${content}</li>`;
|
|
132
132
|
} else {
|
|
133
133
|
return `${indent}<li class="task-list"><span class="syntax-marker">- [${checked}] </span>${content}</li>`;
|
|
134
134
|
}
|
|
@@ -1862,8 +1862,8 @@ ${blockSuffix}` : suffix;
|
|
|
1862
1862
|
|
|
1863
1863
|
/* Container base styles after reset */
|
|
1864
1864
|
.overtype-container {
|
|
1865
|
-
display:
|
|
1866
|
-
|
|
1865
|
+
display: flex !important;
|
|
1866
|
+
flex-direction: column !important;
|
|
1867
1867
|
width: 100% !important;
|
|
1868
1868
|
height: 100% !important;
|
|
1869
1869
|
position: relative !important; /* Override reset - needed for absolute children */
|
|
@@ -1883,10 +1883,10 @@ ${blockSuffix}` : suffix;
|
|
|
1883
1883
|
/* Auto-resize mode styles */
|
|
1884
1884
|
.overtype-container.overtype-auto-resize {
|
|
1885
1885
|
height: auto !important;
|
|
1886
|
-
grid-template-rows: auto auto auto !important;
|
|
1887
1886
|
}
|
|
1888
|
-
|
|
1887
|
+
|
|
1889
1888
|
.overtype-container.overtype-auto-resize .overtype-wrapper {
|
|
1889
|
+
flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */
|
|
1890
1890
|
height: auto !important;
|
|
1891
1891
|
min-height: 60px !important;
|
|
1892
1892
|
overflow: visible !important;
|
|
@@ -1895,11 +1895,10 @@ ${blockSuffix}` : suffix;
|
|
|
1895
1895
|
.overtype-wrapper {
|
|
1896
1896
|
position: relative !important; /* Override reset - needed for absolute children */
|
|
1897
1897
|
width: 100% !important;
|
|
1898
|
-
|
|
1898
|
+
flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */
|
|
1899
1899
|
min-height: 60px !important; /* Minimum usable height */
|
|
1900
1900
|
overflow: hidden !important;
|
|
1901
1901
|
background: var(--bg-secondary, #ffffff) !important;
|
|
1902
|
-
grid-row: 2 !important; /* Always second row in grid */
|
|
1903
1902
|
z-index: 1; /* Below toolbar and dropdown */
|
|
1904
1903
|
}
|
|
1905
1904
|
|
|
@@ -2234,7 +2233,7 @@ ${blockSuffix}` : suffix;
|
|
|
2234
2233
|
|
|
2235
2234
|
/* Stats bar */
|
|
2236
2235
|
|
|
2237
|
-
/* Stats bar - positioned by
|
|
2236
|
+
/* Stats bar - positioned by flexbox */
|
|
2238
2237
|
.overtype-stats {
|
|
2239
2238
|
height: 40px !important;
|
|
2240
2239
|
padding: 0 20px !important;
|
|
@@ -2246,7 +2245,7 @@ ${blockSuffix}` : suffix;
|
|
|
2246
2245
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
2247
2246
|
font-size: 0.85rem !important;
|
|
2248
2247
|
color: #666 !important;
|
|
2249
|
-
|
|
2248
|
+
flex-shrink: 0 !important; /* Don't shrink */
|
|
2250
2249
|
}
|
|
2251
2250
|
|
|
2252
2251
|
/* Dark theme stats bar */
|
|
@@ -2289,7 +2288,6 @@ ${blockSuffix}` : suffix;
|
|
|
2289
2288
|
-webkit-overflow-scrolling: touch !important;
|
|
2290
2289
|
flex-shrink: 0 !important;
|
|
2291
2290
|
height: auto !important;
|
|
2292
|
-
grid-row: 1 !important; /* Always first row in grid */
|
|
2293
2291
|
position: relative !important; /* Override reset */
|
|
2294
2292
|
z-index: 100 !important; /* Ensure toolbar is above wrapper */
|
|
2295
2293
|
scrollbar-width: thin; /* Thin scrollbar on Firefox */
|
|
@@ -2359,9 +2357,6 @@ ${blockSuffix}` : suffix;
|
|
|
2359
2357
|
}
|
|
2360
2358
|
|
|
2361
2359
|
/* Adjust wrapper when toolbar is present */
|
|
2362
|
-
.overtype-container .overtype-toolbar + .overtype-wrapper {
|
|
2363
|
-
}
|
|
2364
|
-
|
|
2365
2360
|
/* Mobile toolbar adjustments */
|
|
2366
2361
|
@media (max-width: 640px) {
|
|
2367
2362
|
.overtype-toolbar {
|
|
@@ -2632,36 +2627,42 @@ ${blockSuffix}` : suffix;
|
|
|
2632
2627
|
height: 2px !important;
|
|
2633
2628
|
}
|
|
2634
2629
|
|
|
2635
|
-
/* Link Tooltip -
|
|
2630
|
+
/* Link Tooltip - Base styles (all browsers) */
|
|
2631
|
+
.overtype-link-tooltip {
|
|
2632
|
+
/* Visual styles that work for both positioning methods */
|
|
2633
|
+
background: #333 !important;
|
|
2634
|
+
color: white !important;
|
|
2635
|
+
padding: 6px 10px !important;
|
|
2636
|
+
border-radius: 16px !important;
|
|
2637
|
+
font-size: 12px !important;
|
|
2638
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
2639
|
+
display: none !important;
|
|
2640
|
+
z-index: 10000 !important;
|
|
2641
|
+
cursor: pointer !important;
|
|
2642
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
2643
|
+
max-width: 300px !important;
|
|
2644
|
+
white-space: nowrap !important;
|
|
2645
|
+
overflow: hidden !important;
|
|
2646
|
+
text-overflow: ellipsis !important;
|
|
2647
|
+
|
|
2648
|
+
/* Base positioning for Floating UI fallback */
|
|
2649
|
+
position: absolute;
|
|
2650
|
+
}
|
|
2651
|
+
|
|
2652
|
+
.overtype-link-tooltip.visible {
|
|
2653
|
+
display: flex !important;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
/* CSS Anchor Positioning (modern browsers only) */
|
|
2636
2657
|
@supports (position-anchor: --x) and (position-area: center) {
|
|
2637
2658
|
.overtype-link-tooltip {
|
|
2638
|
-
|
|
2659
|
+
/* Only anchor positioning specific properties */
|
|
2639
2660
|
position-anchor: var(--target-anchor, --link-0);
|
|
2640
2661
|
position-area: block-end center;
|
|
2641
2662
|
margin-top: 8px !important;
|
|
2642
|
-
|
|
2643
|
-
background: #333 !important;
|
|
2644
|
-
color: white !important;
|
|
2645
|
-
padding: 6px 10px !important;
|
|
2646
|
-
border-radius: 16px !important;
|
|
2647
|
-
font-size: 12px !important;
|
|
2648
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
2649
|
-
display: none !important;
|
|
2650
|
-
z-index: 10000 !important;
|
|
2651
|
-
cursor: pointer !important;
|
|
2652
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
2653
|
-
max-width: 300px !important;
|
|
2654
|
-
white-space: nowrap !important;
|
|
2655
|
-
overflow: hidden !important;
|
|
2656
|
-
text-overflow: ellipsis !important;
|
|
2657
|
-
|
|
2658
2663
|
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
2659
2664
|
position-visibility: anchors-visible;
|
|
2660
2665
|
}
|
|
2661
|
-
|
|
2662
|
-
.overtype-link-tooltip.visible {
|
|
2663
|
-
display: flex !important;
|
|
2664
|
-
}
|
|
2665
2666
|
}
|
|
2666
2667
|
|
|
2667
2668
|
${mobileStyles}
|
|
@@ -2694,7 +2695,7 @@ ${blockSuffix}` : suffix;
|
|
|
2694
2695
|
this.container.appendChild(button);
|
|
2695
2696
|
}
|
|
2696
2697
|
});
|
|
2697
|
-
this.editor.
|
|
2698
|
+
this.editor.container.insertBefore(this.container, this.editor.wrapper);
|
|
2698
2699
|
}
|
|
2699
2700
|
/**
|
|
2700
2701
|
* Create a toolbar separator
|
|
@@ -2919,9 +2920,26 @@ ${blockSuffix}` : suffix;
|
|
|
2919
2920
|
this.currentLink = null;
|
|
2920
2921
|
this.hideTimeout = null;
|
|
2921
2922
|
this.visibilityChangeHandler = null;
|
|
2923
|
+
this.useFloatingUI = false;
|
|
2924
|
+
this.floatingUI = null;
|
|
2922
2925
|
this.init();
|
|
2923
2926
|
}
|
|
2924
|
-
init() {
|
|
2927
|
+
async init() {
|
|
2928
|
+
const supportsAnchorPositioning = CSS.supports("position-anchor: --x") && CSS.supports("position-area: center");
|
|
2929
|
+
if (!supportsAnchorPositioning) {
|
|
2930
|
+
try {
|
|
2931
|
+
const importFn = new Function("url", "return import(url)");
|
|
2932
|
+
const { computePosition, offset, shift, flip } = await importFn(
|
|
2933
|
+
"https://cdn.jsdelivr.net/npm/@floating-ui/dom@1.7.4/+esm"
|
|
2934
|
+
);
|
|
2935
|
+
this.floatingUI = { computePosition, offset, shift, flip };
|
|
2936
|
+
this.useFloatingUI = true;
|
|
2937
|
+
} catch (error) {
|
|
2938
|
+
console.warn("Failed to load Floating UI fallback:", error);
|
|
2939
|
+
this.floatingUI = null;
|
|
2940
|
+
this.useFloatingUI = false;
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2925
2943
|
this.createTooltip();
|
|
2926
2944
|
this.editor.textarea.addEventListener("selectionchange", () => this.checkCursorPosition());
|
|
2927
2945
|
this.editor.textarea.addEventListener("keyup", (e) => {
|
|
@@ -2930,7 +2948,13 @@ ${blockSuffix}` : suffix;
|
|
|
2930
2948
|
}
|
|
2931
2949
|
});
|
|
2932
2950
|
this.editor.textarea.addEventListener("input", () => this.hide());
|
|
2933
|
-
this.editor.textarea.addEventListener("scroll", () =>
|
|
2951
|
+
this.editor.textarea.addEventListener("scroll", () => {
|
|
2952
|
+
if (this.useFloatingUI && this.currentLink) {
|
|
2953
|
+
this.showWithFloatingUI(this.currentLink);
|
|
2954
|
+
} else {
|
|
2955
|
+
this.hide();
|
|
2956
|
+
}
|
|
2957
|
+
});
|
|
2934
2958
|
this.editor.textarea.addEventListener("blur", () => this.hide());
|
|
2935
2959
|
this.visibilityChangeHandler = () => {
|
|
2936
2960
|
if (document.hidden) {
|
|
@@ -2939,7 +2963,6 @@ ${blockSuffix}` : suffix;
|
|
|
2939
2963
|
};
|
|
2940
2964
|
document.addEventListener("visibilitychange", this.visibilityChangeHandler);
|
|
2941
2965
|
this.tooltip.addEventListener("mouseenter", () => this.cancelHide());
|
|
2942
|
-
this.tooltip.addEventListener("mouseleave", () => this.scheduleHide());
|
|
2943
2966
|
}
|
|
2944
2967
|
createTooltip() {
|
|
2945
2968
|
this.tooltip = document.createElement("div");
|
|
@@ -3000,9 +3023,52 @@ ${blockSuffix}` : suffix;
|
|
|
3000
3023
|
this.cancelHide();
|
|
3001
3024
|
const urlSpan = this.tooltip.querySelector(".overtype-link-tooltip-url");
|
|
3002
3025
|
urlSpan.textContent = linkInfo.url;
|
|
3003
|
-
this.
|
|
3026
|
+
if (this.useFloatingUI) {
|
|
3027
|
+
this.showWithFloatingUI(linkInfo);
|
|
3028
|
+
} else {
|
|
3029
|
+
this.showWithAnchorPositioning(linkInfo);
|
|
3030
|
+
}
|
|
3004
3031
|
this.tooltip.classList.add("visible");
|
|
3005
3032
|
}
|
|
3033
|
+
showWithAnchorPositioning(linkInfo) {
|
|
3034
|
+
this.tooltip.style.setProperty("--target-anchor", `--link-${linkInfo.index}`);
|
|
3035
|
+
}
|
|
3036
|
+
async showWithFloatingUI(linkInfo) {
|
|
3037
|
+
const anchorElement = this.findAnchorElement(linkInfo.index);
|
|
3038
|
+
if (!anchorElement) {
|
|
3039
|
+
return;
|
|
3040
|
+
}
|
|
3041
|
+
const rect = anchorElement.getBoundingClientRect();
|
|
3042
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
3043
|
+
return;
|
|
3044
|
+
}
|
|
3045
|
+
try {
|
|
3046
|
+
const { x, y } = await this.floatingUI.computePosition(
|
|
3047
|
+
anchorElement,
|
|
3048
|
+
this.tooltip,
|
|
3049
|
+
{
|
|
3050
|
+
placement: "bottom",
|
|
3051
|
+
middleware: [
|
|
3052
|
+
this.floatingUI.offset(8),
|
|
3053
|
+
this.floatingUI.shift({ padding: 8 }),
|
|
3054
|
+
this.floatingUI.flip()
|
|
3055
|
+
]
|
|
3056
|
+
}
|
|
3057
|
+
);
|
|
3058
|
+
Object.assign(this.tooltip.style, {
|
|
3059
|
+
left: `${x}px`,
|
|
3060
|
+
top: `${y}px`,
|
|
3061
|
+
position: "absolute"
|
|
3062
|
+
});
|
|
3063
|
+
} catch (error) {
|
|
3064
|
+
console.warn("Floating UI positioning failed:", error);
|
|
3065
|
+
return;
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
findAnchorElement(linkIndex) {
|
|
3069
|
+
const preview = this.editor.preview;
|
|
3070
|
+
return preview.querySelector(`a[style*="--link-${linkIndex}"]`);
|
|
3071
|
+
}
|
|
3006
3072
|
hide() {
|
|
3007
3073
|
this.tooltip.classList.remove("visible");
|
|
3008
3074
|
this.currentLink = null;
|
|
@@ -3028,6 +3094,8 @@ ${blockSuffix}` : suffix;
|
|
|
3028
3094
|
}
|
|
3029
3095
|
this.tooltip = null;
|
|
3030
3096
|
this.currentLink = null;
|
|
3097
|
+
this.floatingUI = null;
|
|
3098
|
+
this.useFloatingUI = false;
|
|
3031
3099
|
}
|
|
3032
3100
|
};
|
|
3033
3101
|
|
|
@@ -3482,22 +3550,10 @@ ${blockSuffix}` : suffix;
|
|
|
3482
3550
|
this._updateStats();
|
|
3483
3551
|
}
|
|
3484
3552
|
this.element.appendChild(this.container);
|
|
3485
|
-
if (window.location.pathname.includes("demo.html")) {
|
|
3486
|
-
console.log("_createDOM completed:", {
|
|
3487
|
-
elementId: this.element.id,
|
|
3488
|
-
autoResize: this.options.autoResize,
|
|
3489
|
-
containerClasses: this.container.className,
|
|
3490
|
-
hasStats: !!this.statsBar,
|
|
3491
|
-
hasToolbar: this.options.toolbar
|
|
3492
|
-
});
|
|
3493
|
-
}
|
|
3494
3553
|
if (this.options.autoResize) {
|
|
3495
3554
|
this._setupAutoResize();
|
|
3496
3555
|
} else {
|
|
3497
3556
|
this.container.classList.remove("overtype-auto-resize");
|
|
3498
|
-
if (window.location.pathname.includes("demo.html")) {
|
|
3499
|
-
console.log("Removed auto-resize class from:", this.element.id);
|
|
3500
|
-
}
|
|
3501
3557
|
}
|
|
3502
3558
|
}
|
|
3503
3559
|
/**
|
|
@@ -4000,6 +4056,7 @@ ${blockSuffix}` : suffix;
|
|
|
4000
4056
|
*/
|
|
4001
4057
|
showNormalEditMode() {
|
|
4002
4058
|
this.container.dataset.mode = "normal";
|
|
4059
|
+
this.updatePreview();
|
|
4003
4060
|
requestAnimationFrame(() => {
|
|
4004
4061
|
this.textarea.scrollTop = this.preview.scrollTop;
|
|
4005
4062
|
this.textarea.scrollLeft = this.preview.scrollLeft;
|
|
@@ -4027,6 +4084,7 @@ ${blockSuffix}` : suffix;
|
|
|
4027
4084
|
*/
|
|
4028
4085
|
showPreviewMode() {
|
|
4029
4086
|
this.container.dataset.mode = "preview";
|
|
4087
|
+
this.updatePreview();
|
|
4030
4088
|
return this;
|
|
4031
4089
|
}
|
|
4032
4090
|
/**
|