dictate-button 1.3.0 → 1.4.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/dist/dictate-button.js
CHANGED
|
@@ -605,7 +605,7 @@ const Vt = `
|
|
|
605
605
|
}
|
|
606
606
|
`;
|
|
607
607
|
var qt = /* @__PURE__ */ O('<div part=container class=dictate-button__container><style></style><div aria-live=polite class=dictate-button__status-announcer style="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0"></div><button part=button class=dictate-button__button>'), Ht = /* @__PURE__ */ O('<svg part=icon class="dictate-button__icon dictate-button__icon--idle"fill=none viewBox="0 0 24 24"stroke-width=1.5 stroke=currentColor role=img aria-hidden=true><path stroke-linecap=round stroke-linejoin=round d="M12 18.75a6 6 0 0 0 6-6v-1.5m-6 7.5a6 6 0 0 1-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 0 1-3-3V4.5a3 3 0 1 1 6 0v8.25a3 3 0 0 1-3 3Z">'), Gt = /* @__PURE__ */ O('<svg part=icon class="dictate-button__icon dictate-button__icon--recording"viewBox="0 0 24 24"fill=currentColor role=img aria-hidden=true><circle cx=12 cy=12 r=10>'), Wt = /* @__PURE__ */ O('<svg part=icon class="dictate-button__icon dictate-button__icon--processing"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><path d="M12 2v4"></path><path d="m16.2 7.8 2.9-2.9"></path><path d="M18 12h4"></path><path d="m16.2 16.2 2.9 2.9"></path><path d="M12 18v4"></path><path d="m4.9 19.1 2.9-2.9"></path><path d="M2 12h4"></path><path d="m4.9 4.9 2.9 2.9">'), Xt = /* @__PURE__ */ O('<svg part=icon class="dictate-button__icon dictate-button__icon--error"viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=4 stroke-linecap=round stroke-linejoin=round role=img aria-hidden=true><line x1=12 x2=12 y1=4 y2=14></line><line x1=12 x2=12.01 y1=20 y2=20>');
|
|
608
|
-
console.debug("dictate-button version:", "1.
|
|
608
|
+
console.debug("dictate-button version:", "1.4.1");
|
|
609
609
|
const Jt = "https://api.dictate-button.io/transcribe", v = "dictate-button.io", H = -70, ot = -10, it = 0, Zt = 4, Qt = 0.25, Yt = 0.05;
|
|
610
610
|
zt("dictate-button", {
|
|
611
611
|
size: 30,
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { buttonSize: i = 30, verbose: o = !1, customApiEndpoint: r } = c,
|
|
3
|
-
for (const n of
|
|
1
|
+
function v(t, c = {}) {
|
|
2
|
+
const { buttonSize: i = 30, verbose: o = !1, customApiEndpoint: r } = c, d = document.querySelectorAll(t);
|
|
3
|
+
for (const n of d) {
|
|
4
4
|
if (n.hasAttribute("data-dictate-button-enabled")) continue;
|
|
5
|
-
const
|
|
6
|
-
if (!n.isConnected || !
|
|
5
|
+
const u = n.parentNode;
|
|
6
|
+
if (!n.isConnected || !u) {
|
|
7
7
|
o && console.debug("injectDictateButton: skipping detached field", n);
|
|
8
8
|
continue;
|
|
9
9
|
}
|
|
10
10
|
n.setAttribute("data-dictate-button-enabled", "");
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const l = getComputedStyle(n),
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
);
|
|
18
|
-
n.style.paddingRight = `${i + g * 2}px`;
|
|
11
|
+
const a = document.createElement("div");
|
|
12
|
+
a.style.position = "relative";
|
|
13
|
+
const l = getComputedStyle(n), g = l.display === "block";
|
|
14
|
+
a.style.display = g ? "block" : "inline-block", a.style.width = g ? "100%" : "auto", a.style.color = "inherit", a.classList.add("dictate-button-wrapper"), u.insertBefore(a, n), a.appendChild(n), a.style.margin = l.margin, n.style.margin = "0", n.style.boxSizing = "border-box";
|
|
15
|
+
const p = y(l);
|
|
16
|
+
n.style.paddingRight = `${i + p * 2}px`;
|
|
19
17
|
const e = document.createElement("dictate-button");
|
|
20
18
|
e.size = i, e.style.position = "absolute", e.style.right = "0", e.style.top = m(
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
a,
|
|
20
|
+
l,
|
|
21
|
+
n.tagName,
|
|
23
22
|
i
|
|
24
|
-
), e.style.marginRight = e.style.marginLeft = `${
|
|
25
|
-
o && console.debug("recording:started",
|
|
26
|
-
}), e.addEventListener("recording:stopped", (
|
|
27
|
-
o && console.debug("recording:stopped",
|
|
28
|
-
}), e.addEventListener("recording:failed", (
|
|
29
|
-
o && console.debug("recording:failed",
|
|
30
|
-
}), e.addEventListener("transcribing:started", (
|
|
31
|
-
o && console.debug("transcribing:started",
|
|
32
|
-
}), e.addEventListener("transcribing:finished", (
|
|
33
|
-
o && console.debug("transcribing:finished",
|
|
34
|
-
const
|
|
35
|
-
T(n,
|
|
36
|
-
}), e.addEventListener("transcribing:failed", (
|
|
37
|
-
o && console.debug("transcribing:failed",
|
|
38
|
-
}),
|
|
23
|
+
) + "px", e.style.marginRight = e.style.marginLeft = `${p}px`, e.style.marginTop = "0", e.style.marginBottom = "0", r && (e.apiEndpoint = r), e.language = h(), e.addEventListener("recording:started", (s) => {
|
|
24
|
+
o && console.debug("recording:started", s);
|
|
25
|
+
}), e.addEventListener("recording:stopped", (s) => {
|
|
26
|
+
o && console.debug("recording:stopped", s);
|
|
27
|
+
}), e.addEventListener("recording:failed", (s) => {
|
|
28
|
+
o && console.debug("recording:failed", s), b(n);
|
|
29
|
+
}), e.addEventListener("transcribing:started", (s) => {
|
|
30
|
+
o && console.debug("transcribing:started", s);
|
|
31
|
+
}), e.addEventListener("transcribing:finished", (s) => {
|
|
32
|
+
o && console.debug("transcribing:finished", s);
|
|
33
|
+
const f = s.detail;
|
|
34
|
+
T(n, f);
|
|
35
|
+
}), e.addEventListener("transcribing:failed", (s) => {
|
|
36
|
+
o && console.debug("transcribing:failed", s), b(n);
|
|
37
|
+
}), a.appendChild(e);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
function h() {
|
|
@@ -47,29 +46,35 @@ function h() {
|
|
|
47
46
|
return t.split(/[-_]/)[0].toLowerCase();
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
function m(t, c, i) {
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
function m(t, c, i, o) {
|
|
50
|
+
if (i.toLowerCase() === "textarea") {
|
|
51
|
+
const d = parseFloat(c.paddingTop || "0");
|
|
52
|
+
return Math.max(4, d);
|
|
53
|
+
}
|
|
54
|
+
const r = Math.round(t.clientHeight / 2 - o / 2);
|
|
55
|
+
return Math.max(4, r);
|
|
56
|
+
}
|
|
57
|
+
function y(t) {
|
|
58
|
+
const c = parseFloat(t.paddingRight || "0");
|
|
59
|
+
return Math.max(c, 4);
|
|
55
60
|
}
|
|
56
61
|
function T(t, c) {
|
|
57
62
|
const i = typeof c == "string" ? c.trim() : String(c ?? "").trim();
|
|
58
63
|
if (i.length === 0)
|
|
59
64
|
return;
|
|
60
|
-
const o = t.selectionStart ?? 0, r = t.selectionEnd ?? 0,
|
|
65
|
+
const o = t.selectionStart ?? 0, r = t.selectionEnd ?? 0, d = o > 0 ? t.value.charAt(o - 1) : "", n = d && !/\s/.test(d), u = r < t.value.length ? t.value.charAt(r) : "", a = u && !/\s/.test(u), l = (n ? " " : "") + i + (a ? " " : ""), g = o + l.length, p = typeof t.scrollTop == "number" ? t.scrollTop : null;
|
|
61
66
|
if (typeof t.setRangeText == "function")
|
|
62
67
|
t.setRangeText(l, o, r, "end");
|
|
63
68
|
else {
|
|
64
69
|
t.value = t.value.substring(0, o) + l + t.value.substring(r);
|
|
65
70
|
try {
|
|
66
|
-
t.selectionStart =
|
|
71
|
+
t.selectionStart = g, t.selectionEnd = g;
|
|
67
72
|
} catch {
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
|
-
|
|
75
|
+
p !== null && (t.scrollTop = p), t.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), b(t);
|
|
71
76
|
}
|
|
72
|
-
function
|
|
77
|
+
function b(t) {
|
|
73
78
|
try {
|
|
74
79
|
t.focus({ preventScroll: !0 });
|
|
75
80
|
} catch {
|
|
@@ -77,5 +82,5 @@ function f(t) {
|
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
export {
|
|
80
|
-
|
|
85
|
+
v as injectDictateButton
|
|
81
86
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dictate-button",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Dictate Button (Web Component)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"custom-element",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"prettier": "^3.6.2",
|
|
67
67
|
"typescript": "^5.9.2",
|
|
68
|
-
"vite": "^7.1.
|
|
68
|
+
"vite": "^7.1.5",
|
|
69
69
|
"vite-plugin-dts": "^4.5.4",
|
|
70
70
|
"vite-plugin-solid": "^2.11.8",
|
|
71
71
|
"vite-plugin-static-copy": "^3.1.2"
|