@backmatter/studio 0.0.4 → 0.0.5
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/site-widget.js +28 -26
- package/package.json +1 -1
- package/src/site-widget.tsx +5 -1
package/dist/site-widget.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as p, jsx as n, Fragment as N } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { c as z, a as T, p as W, l as _, P as B, S as D, m as H, T as M, E as V, C as G, b as U, d as j, e as
|
|
2
|
+
import { useRef as m, useState as w, useLayoutEffect as O, useEffect as f } from "react";
|
|
3
|
+
import { c as z, a as T, p as W, l as _, P as B, S as D, m as H, T as M, E as V, C as G, b as U, d as j, e as q, u as J, D as I, f as S, i as $, g as y, h as K, j as Y } from "./chunks/status-bar-action-DiXhfcj3.js";
|
|
4
4
|
import { E as Q } from "./chunks/EmbedPublishPage-hx1xoAhI.js";
|
|
5
5
|
const t = "backmatter-devbar";
|
|
6
6
|
function be({
|
|
@@ -14,8 +14,8 @@ function be({
|
|
|
14
14
|
proxyPath: x = "/api/backmatter/cms",
|
|
15
15
|
version: i
|
|
16
16
|
}) {
|
|
17
|
-
const l =
|
|
18
|
-
l.current = b,
|
|
17
|
+
const l = m(b);
|
|
18
|
+
l.current = b, w(() => (z({
|
|
19
19
|
baseUrl: x.replace(/\/+$/, ""),
|
|
20
20
|
credentials: "same-origin",
|
|
21
21
|
dev: !1,
|
|
@@ -27,22 +27,22 @@ function be({
|
|
|
27
27
|
a === 401 && ((h = l.current) == null || h.call(l));
|
|
28
28
|
}
|
|
29
29
|
}), !0)), O(() => T(document.documentElement, W(_).className), []);
|
|
30
|
-
const [d, g] =
|
|
30
|
+
const [d, g] = w(!1), [k, v] = w(!1), [C, P] = w(0), A = e ? `${e.type}/${e.slug}` : "No document";
|
|
31
31
|
function R() {
|
|
32
32
|
s == null || s();
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
f(() => {
|
|
35
35
|
function a(h) {
|
|
36
|
-
|
|
36
|
+
q(h) === "chat" && (h.preventDefault(), v(!1), g((L) => !L));
|
|
37
37
|
}
|
|
38
38
|
return document.addEventListener("keydown", a, !0), () => document.removeEventListener("keydown", a, !0);
|
|
39
39
|
}, []);
|
|
40
40
|
const F = /* @__PURE__ */ p("footer", { "aria-label": "Backmatter", className: t, style: oe, children: [
|
|
41
41
|
/* @__PURE__ */ n("span", { style: ae, children: A }),
|
|
42
|
-
/* @__PURE__ */ n(
|
|
43
|
-
o ? /* @__PURE__ */ n(
|
|
44
|
-
r ? /* @__PURE__ */ n(
|
|
45
|
-
/* @__PURE__ */ p("button", { type: "button", className: `${t}-btn${
|
|
42
|
+
/* @__PURE__ */ n(E, { children: "Preview" }),
|
|
43
|
+
o ? /* @__PURE__ */ n(E, { children: o }) : null,
|
|
44
|
+
r ? /* @__PURE__ */ n(E, { children: "draft" }) : null,
|
|
45
|
+
/* @__PURE__ */ p("button", { type: "button", className: `${t}-btn${k ? ` ${t}-on` : ""}`, "aria-pressed": k, disabled: !e, onClick: () => {
|
|
46
46
|
g(!1), v((a) => !a);
|
|
47
47
|
}, children: [
|
|
48
48
|
/* @__PURE__ */ n(B, {}),
|
|
@@ -73,7 +73,7 @@ function be({
|
|
|
73
73
|
/* @__PURE__ */ n(ne, { doc: e }),
|
|
74
74
|
/* @__PURE__ */ n(U, { children: d ? /* @__PURE__ */ n(j, { site: !0 }) : null })
|
|
75
75
|
] }) }) }) : null,
|
|
76
|
-
e ? /* @__PURE__ */ n("div", { "data-backmatter-panel": "", hidden: !
|
|
76
|
+
e ? /* @__PURE__ */ n("div", { "data-backmatter-panel": "", hidden: !k, style: se, children: /* @__PURE__ */ n(Q, { workspaceId: e.workspaceId, onStatus: ({
|
|
77
77
|
changeCount: a
|
|
78
78
|
}) => P(a), onPublished: () => {
|
|
79
79
|
v(!1), P(0), R();
|
|
@@ -86,8 +86,8 @@ function X({
|
|
|
86
86
|
}) {
|
|
87
87
|
const {
|
|
88
88
|
setFocus: o
|
|
89
|
-
} =
|
|
90
|
-
return
|
|
89
|
+
} = J();
|
|
90
|
+
return f(() => {
|
|
91
91
|
o({
|
|
92
92
|
docRef: {
|
|
93
93
|
locale: e.locale,
|
|
@@ -103,8 +103,8 @@ function X({
|
|
|
103
103
|
function Z({
|
|
104
104
|
onDocChanged: e
|
|
105
105
|
}) {
|
|
106
|
-
const o =
|
|
107
|
-
return o.current = e,
|
|
106
|
+
const o = m(e);
|
|
107
|
+
return o.current = e, f(() => {
|
|
108
108
|
function r() {
|
|
109
109
|
o.current();
|
|
110
110
|
}
|
|
@@ -116,8 +116,8 @@ function ee({
|
|
|
116
116
|
}) {
|
|
117
117
|
const {
|
|
118
118
|
dispatch: o
|
|
119
|
-
} =
|
|
120
|
-
return
|
|
119
|
+
} = S();
|
|
120
|
+
return f(() => {
|
|
121
121
|
o({
|
|
122
122
|
type: e ? "open" : "close"
|
|
123
123
|
}), e && requestAnimationFrame(() => {
|
|
@@ -130,10 +130,10 @@ function te({
|
|
|
130
130
|
}) {
|
|
131
131
|
const {
|
|
132
132
|
panel: o
|
|
133
|
-
} =
|
|
134
|
-
return u.current = e,
|
|
135
|
-
const s =
|
|
136
|
-
c.current = r, s &&
|
|
133
|
+
} = S(), r = o.mode, c = m(r), u = m(e);
|
|
134
|
+
return u.current = e, f(() => {
|
|
135
|
+
const s = $(c.current);
|
|
136
|
+
c.current = r, s && !$(r) && u.current();
|
|
137
137
|
}, [r]), null;
|
|
138
138
|
}
|
|
139
139
|
function ne({
|
|
@@ -142,14 +142,16 @@ function ne({
|
|
|
142
142
|
const {
|
|
143
143
|
addPointer: o,
|
|
144
144
|
panel: r
|
|
145
|
-
} =
|
|
146
|
-
return u.current = c, s.current = e,
|
|
145
|
+
} = S(), c = $(r.mode), u = m(c), s = m(e);
|
|
146
|
+
return u.current = c, s.current = e, f(() => {
|
|
147
147
|
const b = K(document, {
|
|
148
148
|
bar: () => document.querySelector(`.${t}`),
|
|
149
149
|
ignore: (i) => !(i instanceof Element) || i.closest("[data-backmatter-panel]") ? !0 : i.closest("iframe") !== null,
|
|
150
150
|
onGrab: (i) => {
|
|
151
151
|
const l = Y(s.current, i);
|
|
152
|
-
l && o(l)
|
|
152
|
+
l && (o(l), requestAnimationFrame(() => {
|
|
153
|
+
window.dispatchEvent(new Event("backmatter:chat-focus"));
|
|
154
|
+
}));
|
|
153
155
|
},
|
|
154
156
|
onEscape: () => {
|
|
155
157
|
window.dispatchEvent(new CustomEvent(y, {
|
|
@@ -168,7 +170,7 @@ function ne({
|
|
|
168
170
|
};
|
|
169
171
|
}, [o]), null;
|
|
170
172
|
}
|
|
171
|
-
function
|
|
173
|
+
function E({
|
|
172
174
|
children: e
|
|
173
175
|
}) {
|
|
174
176
|
return /* @__PURE__ */ n("span", { style: ie, children: e });
|
package/package.json
CHANGED
package/src/site-widget.tsx
CHANGED
|
@@ -240,7 +240,11 @@ function SitePointer({ doc }: { doc: SiteWidgetDoc }) {
|
|
|
240
240
|
},
|
|
241
241
|
onGrab: (grab) => {
|
|
242
242
|
const next = chatPointerFromGrab(docRef.current, grab);
|
|
243
|
-
if (next)
|
|
243
|
+
if (!next) return;
|
|
244
|
+
addPointer(next);
|
|
245
|
+
requestAnimationFrame(() => {
|
|
246
|
+
window.dispatchEvent(new Event("backmatter:chat-focus"));
|
|
247
|
+
});
|
|
244
248
|
},
|
|
245
249
|
onEscape: () => {
|
|
246
250
|
window.dispatchEvent(new CustomEvent(POINTER_ARM_EVENT, { detail: { on: false } }));
|