@tideworthy/tidysites-platform 0.10.4 → 0.10.6
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/src/editor/TidyEditor.astro +1 -1
- package/src/editor/confirm.ts +48 -0
- package/src/editor/revisions.ts +3 -2
- package/src/editor/runtime.ts +4 -2
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.6
|
|
4
|
+
|
|
5
|
+
- Editor: Publish live, Restore and Remove section confirm in a dialog of the editor's own, never the browser's box. The bar's note reads "A private copy to see working changes on the website, not publicly accessible."
|
|
6
|
+
|
|
7
|
+
## 0.10.5
|
|
8
|
+
|
|
9
|
+
- Editor bar: an interim note.
|
|
10
|
+
|
|
11
|
+
## 0.10.5
|
|
12
|
+
|
|
13
|
+
- Editor: the bar's note reads "Changes here go live when you publish."
|
|
14
|
+
|
|
3
15
|
## 0.10.4
|
|
4
16
|
|
|
5
17
|
- Editor: the bar has a 1px white bottom edge, so it stands off a dark header as well as a light one.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tideworthy/tidysites-platform",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"description": "The Tidysites platform integration for EmDash sites: bootstrap, sessions, maintenance, health, and publish hooks under /_tidy/*.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -55,7 +55,7 @@ const htmlClass = !signedIn ? (signInUrl ? "tidy-has-bar tidy-idle" : "") : !act
|
|
|
55
55
|
{(signedIn || signInUrl) && (
|
|
56
56
|
<>
|
|
57
57
|
<div class="tidy-bar" id="tidy-bar" role="region" aria-label="Site editing">
|
|
58
|
-
<span class="tidy-bar-label"><span class="tidy-bar-dot" aria-hidden="true"></span>{label} website<span class="tidy-bar-note">
|
|
58
|
+
<span class="tidy-bar-label"><span class="tidy-bar-dot" aria-hidden="true"></span>{label} website<span class="tidy-bar-note">Changes here go live when you publish.</span></span>
|
|
59
59
|
<div class="tidy-bar-actions" id="tidy-bar-actions">
|
|
60
60
|
{!signedIn && <a class="tidy-btn tidy-btn-primary" href={signInUrl!}>Sign in to edit</a>}
|
|
61
61
|
{signedIn && !active && <a class="tidy-btn tidy-btn-primary" href={toggle(true)}>Edit</a>}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A yes-or-no dialog in the page, in the editor's own style: never the
|
|
3
|
+
* browser's confirm box. Resolves true on the action, false on Cancel,
|
|
4
|
+
* Escape or a click on the backdrop.
|
|
5
|
+
*/
|
|
6
|
+
export function tidyConfirm(opts: { title: string; body: string; cta: string; danger?: boolean }): Promise<boolean> {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const backdrop = document.createElement("div");
|
|
9
|
+
backdrop.className = "tidy-dialog-backdrop";
|
|
10
|
+
const dialog = document.createElement("div");
|
|
11
|
+
dialog.className = "tidy-dialog";
|
|
12
|
+
dialog.setAttribute("role", "alertdialog");
|
|
13
|
+
dialog.setAttribute("aria-modal", "true");
|
|
14
|
+
const h = document.createElement("h2");
|
|
15
|
+
h.textContent = opts.title;
|
|
16
|
+
const p = document.createElement("p");
|
|
17
|
+
p.textContent = opts.body;
|
|
18
|
+
const actions = document.createElement("div");
|
|
19
|
+
actions.className = "tidy-dialog-actions";
|
|
20
|
+
const cancel = document.createElement("button");
|
|
21
|
+
cancel.type = "button";
|
|
22
|
+
cancel.className = "tidy-btn";
|
|
23
|
+
cancel.textContent = "Cancel";
|
|
24
|
+
const go = document.createElement("button");
|
|
25
|
+
go.type = "button";
|
|
26
|
+
go.className = `tidy-btn ${opts.danger ? "tidy-btn-danger" : "tidy-btn-primary"}`;
|
|
27
|
+
go.textContent = opts.cta;
|
|
28
|
+
actions.append(cancel, go);
|
|
29
|
+
dialog.append(h, p, actions);
|
|
30
|
+
backdrop.append(dialog);
|
|
31
|
+
const done = (ok: boolean) => {
|
|
32
|
+
document.removeEventListener("keydown", onKey);
|
|
33
|
+
backdrop.remove();
|
|
34
|
+
resolve(ok);
|
|
35
|
+
};
|
|
36
|
+
const onKey = (e: KeyboardEvent) => {
|
|
37
|
+
if (e.key === "Escape") done(false);
|
|
38
|
+
};
|
|
39
|
+
cancel.addEventListener("click", () => done(false));
|
|
40
|
+
go.addEventListener("click", () => done(true));
|
|
41
|
+
backdrop.addEventListener("click", (e) => {
|
|
42
|
+
if (e.target === backdrop) done(false);
|
|
43
|
+
});
|
|
44
|
+
document.addEventListener("keydown", onKey);
|
|
45
|
+
document.body.append(backdrop);
|
|
46
|
+
go.focus();
|
|
47
|
+
});
|
|
48
|
+
}
|
package/src/editor/revisions.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* Deep links: ?tidy-revisions=1 opens the list; ?tidy-revision=<id> opens
|
|
11
11
|
* that revision of this page.
|
|
12
12
|
*/
|
|
13
|
+
import { tidyConfirm } from "./confirm";
|
|
13
14
|
|
|
14
15
|
interface Revision {
|
|
15
16
|
id: string;
|
|
@@ -111,7 +112,7 @@ export function startRevisions(): void {
|
|
|
111
112
|
}
|
|
112
113
|
viewer.hidden = false;
|
|
113
114
|
restoreBtn.onclick = async () => {
|
|
114
|
-
if (!
|
|
115
|
+
if (!(await tidyConfirm({ title: `Restore the website to ${when(rev.at)}?`, body: "The live site goes back to how it was then, and so does staging: every change made since is lost.", cta: "Restore", danger: true }))) return;
|
|
115
116
|
restoreBtn.disabled = true;
|
|
116
117
|
restoreBtn.textContent = "Restoring";
|
|
117
118
|
const p = await fetch(ROUTE, { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify({ action: "restore", id: rev.id }) });
|
|
@@ -135,7 +136,7 @@ export function startRevisions(): void {
|
|
|
135
136
|
});
|
|
136
137
|
|
|
137
138
|
liveBtn.addEventListener("click", async () => {
|
|
138
|
-
if (!
|
|
139
|
+
if (!(await tidyConfirm({ title: "Publish the website?", body: "Everything on staging goes live, every change made since the last publish.", cta: "Publish" }))) return;
|
|
139
140
|
liveBtn.disabled = true;
|
|
140
141
|
liveBtn.textContent = "Publishing";
|
|
141
142
|
const p = await fetch(ROUTE, { method: "POST", credentials: "same-origin", headers: { "content-type": "application/json" }, body: JSON.stringify({ action: "publish" }) });
|
package/src/editor/runtime.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
/// <reference lib="dom.iterable" />
|
|
3
|
+
import { tidyConfirm } from "./confirm";
|
|
3
4
|
/**
|
|
4
5
|
* The Tideworthy on-site editor. Runs on a page rendered in edit mode.
|
|
5
6
|
*
|
|
@@ -295,8 +296,9 @@ export function start(config: Config): void {
|
|
|
295
296
|
bUp.addEventListener("click", () => current?.dataset.tidyBlock && moved(moveBlock(value, current.dataset.tidyBlock, -1)));
|
|
296
297
|
bDown.addEventListener("click", () => current?.dataset.tidyBlock && moved(moveBlock(value, current.dataset.tidyBlock, 1)));
|
|
297
298
|
bRemove.addEventListener("click", () => {
|
|
298
|
-
|
|
299
|
-
if (
|
|
299
|
+
const key = current?.dataset.tidyBlock;
|
|
300
|
+
if (!key) return;
|
|
301
|
+
void tidyConfirm({ title: `Remove this ${chipLabel.textContent} section?`, body: "The section comes off the page. Publish for the change to show on the live website.", cta: "Remove", danger: true }).then((ok) => { if (ok) void saveBlocks(removeBlock(value, key)); });
|
|
300
302
|
});
|
|
301
303
|
bAdd.addEventListener("click", () => current?.dataset.tidyBlock && openAdd(current.dataset.tidyBlock));
|
|
302
304
|
function moved(next: Block[]) {
|
package/src/version.ts
CHANGED