weevar 1.2.0 → 2.0.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/README.md +5 -3
- package/dist/react.dev.js +37 -14
- package/dist/react.dev.js.map +1 -1
- package/dist/react.dev.mjs +37 -14
- package/dist/react.dev.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.dev.mjs
CHANGED
|
@@ -139,13 +139,36 @@ function isInsideWeevarOverlay(el) {
|
|
|
139
139
|
if (element.id === WEEVAR_HOST_ID) return true;
|
|
140
140
|
return false;
|
|
141
141
|
}
|
|
142
|
+
var weevarClosedShadowRoot = null;
|
|
143
|
+
function setWeevarClosedShadowRoot(root) {
|
|
144
|
+
weevarClosedShadowRoot = root;
|
|
145
|
+
}
|
|
142
146
|
function getDeepActiveElement() {
|
|
143
|
-
|
|
147
|
+
const hostActive = document.activeElement;
|
|
148
|
+
if (hostActive instanceof HTMLElement && hostActive.id === WEEVAR_HOST_ID && weevarClosedShadowRoot?.activeElement) {
|
|
149
|
+
return weevarClosedShadowRoot.activeElement;
|
|
150
|
+
}
|
|
151
|
+
let active = hostActive;
|
|
144
152
|
while (active?.shadowRoot?.activeElement) {
|
|
145
153
|
active = active.shadowRoot.activeElement;
|
|
146
154
|
}
|
|
147
155
|
return active;
|
|
148
156
|
}
|
|
157
|
+
function isEditableElement(el) {
|
|
158
|
+
if (!(el instanceof HTMLElement)) return false;
|
|
159
|
+
const tag = el.tagName;
|
|
160
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
161
|
+
return el.isContentEditable;
|
|
162
|
+
}
|
|
163
|
+
function shouldIgnoreWeevarShortcut(e) {
|
|
164
|
+
const target = e.target;
|
|
165
|
+
if (isEditableElement(target instanceof HTMLElement ? target : null)) return true;
|
|
166
|
+
if (isEditableElement(getDeepActiveElement())) return true;
|
|
167
|
+
for (const n of e.composedPath()) {
|
|
168
|
+
if (n instanceof HTMLElement && isEditableElement(n)) return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
149
172
|
function blurWeevarOverlayFocusIfPointerOutside(e) {
|
|
150
173
|
const ae = getDeepActiveElement();
|
|
151
174
|
if (!(ae instanceof HTMLElement)) return;
|
|
@@ -1640,7 +1663,7 @@ function readRadiusValues(el) {
|
|
|
1640
1663
|
}
|
|
1641
1664
|
|
|
1642
1665
|
// src/version.ts
|
|
1643
|
-
var WEEVAR_VERSION = "
|
|
1666
|
+
var WEEVAR_VERSION = "2.0.1";
|
|
1644
1667
|
function weevarVersionLabel() {
|
|
1645
1668
|
return `v${WEEVAR_VERSION}`;
|
|
1646
1669
|
}
|
|
@@ -2174,7 +2197,8 @@ function ColorPicker({
|
|
|
2174
2197
|
setHexRaw(displayOpaqueHex);
|
|
2175
2198
|
hexFieldBaselineRef.current = displayOpaqueHex.toLowerCase();
|
|
2176
2199
|
},
|
|
2177
|
-
onChange: (
|
|
2200
|
+
onChange: (e) => {
|
|
2201
|
+
const raw = e.target.value;
|
|
2178
2202
|
setHexRaw(raw);
|
|
2179
2203
|
if (isValidOpaqueHex(raw)) {
|
|
2180
2204
|
onChange(
|
|
@@ -2229,7 +2253,8 @@ function ColorPicker({
|
|
|
2229
2253
|
setAlphaRaw(formatAlphaPercent(displayAlphaPercent));
|
|
2230
2254
|
alphaFieldBaselineRef.current = formatAlphaPercent(displayAlphaPercent);
|
|
2231
2255
|
},
|
|
2232
|
-
onChange: (
|
|
2256
|
+
onChange: (e) => {
|
|
2257
|
+
const raw = e.target.value;
|
|
2233
2258
|
setAlphaRaw(raw);
|
|
2234
2259
|
const pct = parseAlphaPercentInput(raw);
|
|
2235
2260
|
if (pct != null) {
|
|
@@ -10373,10 +10398,8 @@ body *:focus {
|
|
|
10373
10398
|
const onShortcut = (e) => {
|
|
10374
10399
|
if (e.defaultPrevented) return;
|
|
10375
10400
|
if (e.metaKey || e.ctrlKey || e.altKey) return;
|
|
10376
|
-
|
|
10377
|
-
if (
|
|
10378
|
-
if (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) return;
|
|
10379
|
-
}
|
|
10401
|
+
if (editSelectionTrayVisible) return;
|
|
10402
|
+
if (shouldIgnoreWeevarShortcut(e)) return;
|
|
10380
10403
|
const k = e.key.toLowerCase();
|
|
10381
10404
|
if (k === "p") {
|
|
10382
10405
|
e.preventDefault();
|
|
@@ -10432,6 +10455,7 @@ body *:focus {
|
|
|
10432
10455
|
};
|
|
10433
10456
|
}, [
|
|
10434
10457
|
sessionOn,
|
|
10458
|
+
editSelectionTrayVisible,
|
|
10435
10459
|
cancelDrag,
|
|
10436
10460
|
setSessionOn,
|
|
10437
10461
|
generateFromBatch,
|
|
@@ -11508,6 +11532,7 @@ function Weevar(props) {
|
|
|
11508
11532
|
const owner = existingHost.getAttribute(WEEVAR_HOST_OWNER_ATTR);
|
|
11509
11533
|
if (owner && owner !== WEEVAR_HOST_OWNER_TOKEN) {
|
|
11510
11534
|
if (owner.startsWith("weevar-")) {
|
|
11535
|
+
setWeevarClosedShadowRoot(null);
|
|
11511
11536
|
existingHost.remove();
|
|
11512
11537
|
} else {
|
|
11513
11538
|
if (import.meta.env.DEV && !warnedAboutForeignHostOwner) {
|
|
@@ -11519,6 +11544,7 @@ function Weevar(props) {
|
|
|
11519
11544
|
return false;
|
|
11520
11545
|
}
|
|
11521
11546
|
} else {
|
|
11547
|
+
setWeevarClosedShadowRoot(null);
|
|
11522
11548
|
existingHost.remove();
|
|
11523
11549
|
}
|
|
11524
11550
|
}
|
|
@@ -11528,6 +11554,7 @@ function Weevar(props) {
|
|
|
11528
11554
|
host.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:2147483646;";
|
|
11529
11555
|
document.body.appendChild(host);
|
|
11530
11556
|
const shadow = host.attachShadow({ mode: "closed" });
|
|
11557
|
+
setWeevarClosedShadowRoot(shadow);
|
|
11531
11558
|
const mount = document.createElement("div");
|
|
11532
11559
|
shadow.appendChild(mount);
|
|
11533
11560
|
const root = createRoot(mount);
|
|
@@ -11570,12 +11597,7 @@ function Weevar(props) {
|
|
|
11570
11597
|
useEffect(() => {
|
|
11571
11598
|
if (disabled) return;
|
|
11572
11599
|
const onKey = (e) => {
|
|
11573
|
-
|
|
11574
|
-
if (target instanceof HTMLElement) {
|
|
11575
|
-
const tag = target.tagName;
|
|
11576
|
-
if (tag === "INPUT" || tag === "TEXTAREA" || target.isContentEditable)
|
|
11577
|
-
return;
|
|
11578
|
-
}
|
|
11600
|
+
if (shouldIgnoreWeevarShortcut(e)) return;
|
|
11579
11601
|
const match = keybind ? matchCustomKeybind(e, keybind) : defaultMatchKeybind(e);
|
|
11580
11602
|
if (!match) return;
|
|
11581
11603
|
e.preventDefault();
|
|
@@ -11593,6 +11615,7 @@ function Weevar(props) {
|
|
|
11593
11615
|
window.setTimeout(() => {
|
|
11594
11616
|
root?.unmount();
|
|
11595
11617
|
if (ownedHost && ownedHost.getAttribute(WEEVAR_HOST_OWNER_ATTR) === WEEVAR_HOST_OWNER_TOKEN) {
|
|
11618
|
+
setWeevarClosedShadowRoot(null);
|
|
11596
11619
|
ownedHost.remove();
|
|
11597
11620
|
}
|
|
11598
11621
|
}, 0);
|