tess_edit 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/app/javascript/tess_edit/controllers/editor_controller.js +28 -28
- data/app/javascript/tess_edit/ui/blocks_panel.js +3 -3
- data/app/javascript/tess_edit/ui/code_input.js +8 -8
- data/app/javascript/tess_edit/ui/inspector.js +31 -31
- data/app/javascript/tess_edit/ui/text_editing.js +5 -5
- data/app/javascript/tess_edit/ui/tree.js +6 -6
- data/app/javascript/tess_edit/ui/variable_menu.js +7 -7
- data/lib/tess_edit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46b2b641773a8bea80c00c24e8aa0988627ad530f5122898bb660d6a9a43d7a7
|
|
4
|
+
data.tar.gz: 131766e1ec91c4ba8b68f1d9bfeaf71b9103522b12203161f9d1c349e76fa3c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73717af04235a460190ba466c6ba16dd54242bbd6f0dd85969c96c53cc23553732d9065ede759d07e2800a0824a36834e673fcaa1957a16aa60c6ae51055c437
|
|
7
|
+
data.tar.gz: 857820205087bde1fb46878e20d1e25d03a988257de588c21ab0e8ef4d004ada1dfb8c8681c0bfae07e9d411bc7bb708f7932081f2edcc0026e1fdadf1a2c38a
|
data/README.md
CHANGED
|
@@ -19,6 +19,7 @@ It completes Liquid tags and variables as you type, making it easier to work wit
|
|
|
19
19
|
- Undo/redo, duplicate, delete, keyboard shortcuts (⌘Z, ⇧⌘Z, ⌘D, Delete, Enter to edit text, Esc).
|
|
20
20
|
- Desktop and mobile preview, and a preview of the HTML as sent.
|
|
21
21
|
- Panels on both sides, or combined as tabs in one sidebar on the left or right to give the canvas more room.
|
|
22
|
+
- Dark mode that follows the host app's.
|
|
22
23
|
- Code dialog to view, copy or download the JSON, MJML and HTML, and to load JSON.
|
|
23
24
|
|
|
24
25
|
## Installation
|
|
@@ -62,6 +63,10 @@ Import the editor's styles after Tailwind itself:
|
|
|
62
63
|
|
|
63
64
|
`app/assets/builds/tailwind/tess_edit.css` is generated by `bin/rails tailwindcss:build` (and `tailwindcss:watch`, `bin/dev`) from the gem's `app/assets/tailwind/tess_edit/engine.css`. It points to wherever the gem is installed, so the line above is the same on every machine. Leave `app/assets/builds` out of version control, as Rails apps do by default. If the import fails because the file is missing, run `bin/rails tailwindcss:engines` or a build once.
|
|
64
65
|
|
|
66
|
+
### Dark mode
|
|
67
|
+
|
|
68
|
+
The editor's panels, menus and dialogs have `dark:` variants, so they follow your app's dark mode: by default the OS setting (`prefers-color-scheme`), or whatever your app makes `dark:` mean with `@custom-variant dark`, such as a `.dark` class on `<html>`. The email on the canvas keeps its own colours, as it is sent.
|
|
69
|
+
|
|
65
70
|
## Usage
|
|
66
71
|
|
|
67
72
|
Give the controller an element with a height and, optionally, hidden inputs to keep up to date:
|
|
@@ -43,7 +43,7 @@ import { renderBlocksPanel } from "tess_edit/ui/blocks_panel"
|
|
|
43
43
|
import { debounce, h } from "tess_edit/ui/dom"
|
|
44
44
|
import { icon } from "tess_edit/ui/icons"
|
|
45
45
|
|
|
46
|
-
const TOOL = "w-8 h-8 flex items-center justify-center rounded-md text-gray-600 hover:bg-gray-100 hover:text-gray-900 disabled:opacity-30 disabled:hover:bg-transparent"
|
|
46
|
+
const TOOL = "w-8 h-8 flex items-center justify-center rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-100 disabled:opacity-30 disabled:hover:bg-transparent"
|
|
47
47
|
const TAB = "px-3 h-12 text-[13px] font-medium border-b-2 -mb-px"
|
|
48
48
|
const PANELS = ["left", "split", "right"]
|
|
49
49
|
const PANELS_KEY = "tess_edit:panels"
|
|
@@ -200,24 +200,24 @@ export default class extends Controller {
|
|
|
200
200
|
build() {
|
|
201
201
|
this.blocksElement = h("div", { class: "flex-1 overflow-y-auto pb-4" })
|
|
202
202
|
this.treeElement = h("div", { class: "flex-1 overflow-y-auto" })
|
|
203
|
-
this.leftTabs = h("div", { class: "flex border-b border-gray-200 px-2 shrink-0" })
|
|
203
|
+
this.leftTabs = h("div", { class: "flex border-b border-gray-200 dark:border-gray-700 px-2 shrink-0" })
|
|
204
204
|
this.inspectorElement = h("div", { class: "flex flex-1 flex-col min-h-0", dataset: { tessEditPanel: "inspect" } })
|
|
205
205
|
this.sidePanel = h("aside")
|
|
206
206
|
this.inspectPanel = h("aside")
|
|
207
|
-
this.textToolbar = h("div", { class: "hidden absolute left-1/2 top-3 z-20 -translate-x-1/2 flex items-center gap-0.5 rounded-lg border border-gray-200 bg-white px-1.5 py-1 shadow-md" })
|
|
207
|
+
this.textToolbar = h("div", { class: "hidden absolute left-1/2 top-3 z-20 -translate-x-1/2 flex items-center gap-0.5 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 px-1.5 py-1 shadow-md" })
|
|
208
208
|
this.frame = h("iframe", { class: "block h-full w-full border-0 bg-white transition-[width] duration-200", title: "Email canvas" })
|
|
209
209
|
this.frameWrap = h("div", { class: "relative h-full mx-auto" }, this.frame)
|
|
210
|
-
this.topBar = h("div", { class: "flex items-center gap-1 h-12 px-3 border-b border-gray-200 bg-white shrink-0" })
|
|
210
|
+
this.topBar = h("div", { class: "flex items-center gap-1 h-12 px-3 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shrink-0" })
|
|
211
211
|
this.body = h("div", { class: "flex flex-1 min-h-0" })
|
|
212
212
|
|
|
213
213
|
this.root = h(
|
|
214
214
|
"div",
|
|
215
|
-
{ class: "tess-edit relative flex flex-col h-full min-h-[560px] overflow-hidden rounded-lg border border-gray-200 bg-gray-50 text-sm text-gray-800 antialiased", tabindex: "-1", onkeydown: (event) => this.onKeydown(event) },
|
|
215
|
+
{ class: "tess-edit relative flex flex-col h-full min-h-[560px] overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900 text-sm text-gray-800 dark:text-gray-200 antialiased dark:[color-scheme:dark]", tabindex: "-1", onkeydown: (event) => this.onKeydown(event) },
|
|
216
216
|
this.topBar,
|
|
217
217
|
this.body
|
|
218
218
|
)
|
|
219
|
-
this.errorBar = h("div", { class: "hidden absolute inset-x-3 bottom-3 z-20 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 shadow-sm", role: "alert" })
|
|
220
|
-
this.main = h("main", { class: "relative flex-1 min-w-0 bg-gray-100", ondragover: (event) => this.drag && event.preventDefault() }, this.textToolbar, this.frameWrap, this.errorBar)
|
|
219
|
+
this.errorBar = h("div", { class: "hidden absolute inset-x-3 bottom-3 z-20 rounded-md border border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/40 px-3 py-2 text-xs text-red-700 dark:text-red-300 shadow-sm", role: "alert" })
|
|
220
|
+
this.main = h("main", { class: "relative flex-1 min-w-0 bg-gray-100 dark:bg-gray-900", ondragover: (event) => this.drag && event.preventDefault() }, this.textToolbar, this.frameWrap, this.errorBar)
|
|
221
221
|
this.arrangePanels()
|
|
222
222
|
this.element.append(this.root)
|
|
223
223
|
|
|
@@ -249,7 +249,7 @@ export default class extends Controller {
|
|
|
249
249
|
// Split: Blocks and Layers on the left, Inspect on the right. Left or right:
|
|
250
250
|
// one sidebar on that side with Blocks, Layers and Inspect as tabs.
|
|
251
251
|
arrangePanels() {
|
|
252
|
-
const panelClass = (border, width) => `${width} shrink-0 flex flex-col ${border} border-gray-200 bg-white min-h-0`
|
|
252
|
+
const panelClass = (border, width) => `${width} shrink-0 flex flex-col ${border} border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 min-h-0`
|
|
253
253
|
// Only the sidebars move: moving <main> would reload the canvas iframe and blank it.
|
|
254
254
|
if (!this.main.isConnected) this.body.append(this.main)
|
|
255
255
|
this.sidePanel.replaceChildren(this.leftTabs, this.blocksElement, this.treeElement)
|
|
@@ -326,13 +326,13 @@ export default class extends Controller {
|
|
|
326
326
|
const toggle = (current, options, onchange) =>
|
|
327
327
|
h(
|
|
328
328
|
"div",
|
|
329
|
-
{ class: "flex rounded-lg bg-gray-100 p-0.5" },
|
|
329
|
+
{ class: "flex rounded-lg bg-gray-100 dark:bg-gray-900 p-0.5" },
|
|
330
330
|
options.map(([value, name, title, disabled = false]) =>
|
|
331
331
|
h("button", {
|
|
332
332
|
type: "button",
|
|
333
333
|
title,
|
|
334
334
|
disabled,
|
|
335
|
-
class: `w-8 h-7 flex items-center justify-center rounded-md disabled:opacity-40 disabled:pointer-events-none ${current === value ? "bg-white text-gray-900 shadow-sm" : "text-gray-500 hover:text-gray-800"}`,
|
|
335
|
+
class: `w-8 h-7 flex items-center justify-center rounded-md disabled:opacity-40 disabled:pointer-events-none ${current === value ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 shadow-sm" : "text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"}`,
|
|
336
336
|
html: icon(name),
|
|
337
337
|
onclick: () => onchange(value)
|
|
338
338
|
})
|
|
@@ -340,7 +340,7 @@ export default class extends Controller {
|
|
|
340
340
|
)
|
|
341
341
|
|
|
342
342
|
this.topBar.replaceChildren(
|
|
343
|
-
h("span", { class: "font-semibold text-gray-900 mr-3" }, "Email"),
|
|
343
|
+
h("span", { class: "font-semibold text-gray-900 dark:text-gray-100 mr-3" }, "Email"),
|
|
344
344
|
toggle(this.mode, [["edit", "edit", "Edit"], ["preview", "eye", "Preview the email as sent, with Liquid tags"]], (mode) => this.setMode(mode)),
|
|
345
345
|
toggle(this.device, [["desktop", "desktop", "Desktop"], ["mobile", "mobile", "Mobile"]], (device) => this.setDevice(device)),
|
|
346
346
|
h("div", { class: "flex-1" }),
|
|
@@ -353,12 +353,12 @@ export default class extends Controller {
|
|
|
353
353
|
],
|
|
354
354
|
(panels) => this.setPanels(panels)
|
|
355
355
|
),
|
|
356
|
-
h("span", { class: "mx-1 h-5 w-px bg-gray-200" }),
|
|
356
|
+
h("span", { class: "mx-1 h-5 w-px bg-gray-200 dark:bg-gray-700" }),
|
|
357
357
|
h("button", { type: "button", title: "Undo (⌘Z)", class: TOOL, disabled: !this.history.canUndo, html: icon("undo"), onclick: () => this.undo() }),
|
|
358
358
|
h("button", { type: "button", title: "Redo (⇧⌘Z)", class: TOOL, disabled: !this.history.canRedo, html: icon("redo"), onclick: () => this.redo() }),
|
|
359
359
|
h(
|
|
360
360
|
"button",
|
|
361
|
-
{ type: "button", class: "ml-2 flex items-center gap-1.5 h-8 rounded-md bg-gray-900 px-3 text-[13px] font-medium text-white hover:bg-gray-700", onclick: () => this.openCodeDialog() },
|
|
361
|
+
{ type: "button", class: "ml-2 flex items-center gap-1.5 h-8 rounded-md bg-gray-900 px-3 text-[13px] font-medium text-white hover:bg-gray-700 dark:bg-gray-100 dark:text-gray-900 dark:hover:bg-gray-300", onclick: () => this.openCodeDialog() },
|
|
362
362
|
h("span", { html: icon("export") }),
|
|
363
363
|
"Code"
|
|
364
364
|
)
|
|
@@ -367,7 +367,7 @@ export default class extends Controller {
|
|
|
367
367
|
|
|
368
368
|
renderLeftTabs() {
|
|
369
369
|
const tab = (key, name) =>
|
|
370
|
-
h("button", { type: "button", class: `${TAB} ${this.leftTab === key ? "border-blue-600 text-blue-700" : "border-transparent text-gray-500 hover:text-gray-800"}`, onclick: () => this.setLeftTab(key) }, name)
|
|
370
|
+
h("button", { type: "button", class: `${TAB} ${this.leftTab === key ? "border-blue-600 dark:border-blue-400 text-blue-700 dark:text-blue-300" : "border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200"}`, onclick: () => this.setLeftTab(key) }, name)
|
|
371
371
|
// replaceChildren would turn a null into the text "null", so only pass real tabs.
|
|
372
372
|
const tabs = [tab("blocks", "Blocks"), tab("layers", "Layers")]
|
|
373
373
|
if (this.combined) tabs.push(tab("inspect", "Inspect"))
|
|
@@ -615,21 +615,21 @@ export default class extends Controller {
|
|
|
615
615
|
if (!items.length) return
|
|
616
616
|
this.menu = h(
|
|
617
617
|
"div",
|
|
618
|
-
{ class: "fixed z-50 w-56 max-h-80 overflow-y-auto rounded-lg border border-gray-200 bg-white p-1 shadow-lg", role: "menu", "data-anchor": anchor, "data-tess-edit-menu": "insert" },
|
|
619
|
-
h("div", { class: "px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500" }, "Add block"),
|
|
618
|
+
{ class: "fixed z-50 w-56 max-h-80 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-1 shadow-lg", role: "menu", "data-anchor": anchor, "data-tess-edit-menu": "insert" },
|
|
619
|
+
h("div", { class: "px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, "Add block"),
|
|
620
620
|
items.map((item) =>
|
|
621
621
|
h(
|
|
622
622
|
"button",
|
|
623
623
|
{
|
|
624
624
|
type: "button",
|
|
625
625
|
role: "menuitem",
|
|
626
|
-
class: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-gray-700 hover:bg-blue-50 hover:text-blue-700",
|
|
626
|
+
class: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-gray-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:text-blue-700 dark:hover:text-blue-300",
|
|
627
627
|
onclick: () => {
|
|
628
628
|
this.closeMenu()
|
|
629
629
|
this.insertAt(item.key, parentId, index)
|
|
630
630
|
}
|
|
631
631
|
},
|
|
632
|
-
h("span", { class: "text-gray-400", html: icon(item.icon) }),
|
|
632
|
+
h("span", { class: "text-gray-400 dark:text-gray-500", html: icon(item.icon) }),
|
|
633
633
|
item.label
|
|
634
634
|
)
|
|
635
635
|
)
|
|
@@ -650,7 +650,7 @@ export default class extends Controller {
|
|
|
650
650
|
}
|
|
651
651
|
|
|
652
652
|
flash(message) {
|
|
653
|
-
const note = h("div", { class: "absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-md bg-gray-900 px-3 py-2 text-xs text-white shadow-lg" }, message)
|
|
653
|
+
const note = h("div", { class: "absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-md bg-gray-900 px-3 py-2 text-xs text-white shadow-lg dark:bg-gray-700 dark:ring-1 dark:ring-white/10" }, message)
|
|
654
654
|
this.root.append(note)
|
|
655
655
|
setTimeout(() => note.remove(), 3500)
|
|
656
656
|
}
|
|
@@ -704,8 +704,8 @@ export default class extends Controller {
|
|
|
704
704
|
this.stopEditing()
|
|
705
705
|
const { json, mjml, html, errors } = await this.export()
|
|
706
706
|
const contents = { json: JSON.stringify(JSON.parse(json), null, 2), mjml, html }
|
|
707
|
-
const textarea = h("textarea", { class: "flex-1 w-full resize-none rounded-md border border-gray-300 p-3 font-mono text-xs text-gray-800 outline-none focus:border-blue-500", spellcheck: false })
|
|
708
|
-
const status = h("span", { class: "text-xs text-gray-500" })
|
|
707
|
+
const textarea = h("textarea", { class: "flex-1 w-full resize-none rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 p-3 font-mono text-xs text-gray-800 dark:text-gray-200 outline-none focus:border-blue-500", spellcheck: false })
|
|
708
|
+
const status = h("span", { class: "text-xs text-gray-500 dark:text-gray-400" })
|
|
709
709
|
const tabs = h("div", { class: "flex gap-1" })
|
|
710
710
|
const apply = h("button", { type: "button", class: "rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-blue-700", onclick: () => {
|
|
711
711
|
try {
|
|
@@ -713,7 +713,7 @@ export default class extends Controller {
|
|
|
713
713
|
close()
|
|
714
714
|
} catch (error) {
|
|
715
715
|
status.textContent = error.message
|
|
716
|
-
status.className = "text-xs text-red-600"
|
|
716
|
+
status.className = "text-xs text-red-600 dark:text-red-400"
|
|
717
717
|
}
|
|
718
718
|
} }, "Load this JSON")
|
|
719
719
|
|
|
@@ -724,12 +724,12 @@ export default class extends Controller {
|
|
|
724
724
|
const loadable = key === "json" && !this.lock
|
|
725
725
|
textarea.readOnly = !loadable
|
|
726
726
|
apply.classList.toggle("hidden", !loadable)
|
|
727
|
-
status.className = "text-xs text-gray-500"
|
|
727
|
+
status.className = "text-xs text-gray-500 dark:text-gray-400"
|
|
728
728
|
status.textContent =
|
|
729
729
|
key === "json" ? (this.lock ? "The document. Parts of it are locked, so it can't be loaded here." : "The document. Edit and load it, or paste one in.") : key === "mjml" ? "Liquid loops and conditions are in <mj-raw> tags." : errors.length ? `The MJML could not be compiled: ${errors.join("; ")}` : "Liquid is left in place for rendering at send time."
|
|
730
730
|
tabs.replaceChildren(
|
|
731
731
|
...["json", "mjml", "html"].map((name) =>
|
|
732
|
-
h("button", { type: "button", class: `rounded-md px-3 py-1.5 text-xs font-medium ${name === tab ? "bg-gray-900 text-white" : "text-gray-600 hover:bg-gray-100"}`, onclick: () => show(name) }, name.toUpperCase())
|
|
732
|
+
h("button", { type: "button", class: `rounded-md px-3 py-1.5 text-xs font-medium ${name === tab ? "bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900" : "text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, onclick: () => show(name) }, name.toUpperCase())
|
|
733
733
|
)
|
|
734
734
|
)
|
|
735
735
|
}
|
|
@@ -744,17 +744,17 @@ export default class extends Controller {
|
|
|
744
744
|
|
|
745
745
|
const dialog = h(
|
|
746
746
|
"div",
|
|
747
|
-
{ class: "absolute inset-0 z-40 flex items-center justify-center bg-gray-900/40 p-6", onmousedown: (event) => event.target === dialog && close(), onkeydown: (event) => event.key === "Escape" && close() },
|
|
747
|
+
{ class: "absolute inset-0 z-40 flex items-center justify-center bg-gray-900/40 dark:bg-black/60 p-6", onmousedown: (event) => event.target === dialog && close(), onkeydown: (event) => event.key === "Escape" && close() },
|
|
748
748
|
h(
|
|
749
749
|
"div",
|
|
750
|
-
{ class: "flex h-full max-h-[720px] w-full max-w-4xl flex-col gap-3 rounded-xl bg-white p-4 shadow-xl" },
|
|
750
|
+
{ class: "flex h-full max-h-[720px] w-full max-w-4xl flex-col gap-3 rounded-xl bg-white dark:bg-gray-800 p-4 shadow-xl" },
|
|
751
751
|
h("div", { class: "flex items-center gap-3" }, tabs, status, h("button", { type: "button", class: "ml-auto " + TOOL, title: "Close", html: icon("close"), onclick: close })),
|
|
752
752
|
textarea,
|
|
753
753
|
h(
|
|
754
754
|
"div",
|
|
755
755
|
{ class: "flex items-center justify-end gap-2" },
|
|
756
|
-
h("button", { type: "button", class: "rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50", onclick: () => navigator.clipboard?.writeText(textarea.value).then(() => (status.textContent = "Copied.")) }, "Copy"),
|
|
757
|
-
h("button", { type: "button", class: "rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-700 hover:bg-gray-50", onclick: download }, "Download"),
|
|
756
|
+
h("button", { type: "button", class: "rounded-md border border-gray-300 dark:border-gray-600 px-3 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700", onclick: () => navigator.clipboard?.writeText(textarea.value).then(() => (status.textContent = "Copied.")) }, "Copy"),
|
|
757
|
+
h("button", { type: "button", class: "rounded-md border border-gray-300 dark:border-gray-600 px-3 py-1.5 text-xs font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700", onclick: download }, "Download"),
|
|
758
758
|
apply
|
|
759
759
|
)
|
|
760
760
|
)
|
|
@@ -11,7 +11,7 @@ export function renderBlocksPanel(editor, element) {
|
|
|
11
11
|
h(
|
|
12
12
|
"section",
|
|
13
13
|
{ class: "px-3 pt-3" },
|
|
14
|
-
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500" }, category.label),
|
|
14
|
+
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, category.label),
|
|
15
15
|
h(
|
|
16
16
|
"div",
|
|
17
17
|
{ class: "grid grid-cols-3 gap-1.5" },
|
|
@@ -24,7 +24,7 @@ export function renderBlocksPanel(editor, element) {
|
|
|
24
24
|
type: "button",
|
|
25
25
|
draggable: true,
|
|
26
26
|
title: `Drag onto the canvas, or click to add`,
|
|
27
|
-
class: `flex flex-col items-center justify-center gap-1 h-16 rounded-lg border border-gray-200 bg-white text-gray-600 hover:border-blue-400 hover:text-blue-600 hover:shadow-sm cursor-grab active:cursor-grabbing ${category.key === "liquid" ? "text-amber-700" : ""}`,
|
|
27
|
+
class: `flex flex-col items-center justify-center gap-1 h-16 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400 hover:shadow-sm cursor-grab active:cursor-grabbing ${category.key === "liquid" ? "text-amber-700 dark:text-amber-400" : ""}`,
|
|
28
28
|
ondragstart: (event) => {
|
|
29
29
|
event.dataTransfer.effectAllowed = "copy"
|
|
30
30
|
event.dataTransfer.setData("text/plain", item.key)
|
|
@@ -40,5 +40,5 @@ export function renderBlocksPanel(editor, element) {
|
|
|
40
40
|
)
|
|
41
41
|
)
|
|
42
42
|
)
|
|
43
|
-
element.replaceChildren(...groups, h("p", { class: "px-3 py-4 text-xs text-gray-500" }, "Drag blocks onto the canvas or into the Layers tree. Liquid blocks wrap other blocks in {% for %} or {% if %}."))
|
|
43
|
+
element.replaceChildren(...groups, h("p", { class: "px-3 py-4 text-xs text-gray-500 dark:text-gray-400" }, "Drag blocks onto the canvas or into the Layers tree. Liquid blocks wrap other blocks in {% for %} or {% if %}."))
|
|
44
44
|
}
|
|
@@ -13,13 +13,13 @@ const BOX = "m-0 w-full rounded-md border px-2 py-1.5 font-mono text-xs leading-
|
|
|
13
13
|
const LIQUID = /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/
|
|
14
14
|
const COLORS = {
|
|
15
15
|
liquid: "text-purple-700",
|
|
16
|
-
comment: "text-gray-400 italic",
|
|
17
|
-
tag: "text-blue-700",
|
|
18
|
-
attribute: "text-amber-700",
|
|
19
|
-
string: "text-green-700",
|
|
20
|
-
property: "text-blue-700",
|
|
16
|
+
comment: "text-gray-400 dark:text-gray-500 italic",
|
|
17
|
+
tag: "text-blue-700 dark:text-blue-300",
|
|
18
|
+
attribute: "text-amber-700 dark:text-amber-400",
|
|
19
|
+
string: "text-green-700 dark:text-green-400",
|
|
20
|
+
property: "text-blue-700 dark:text-blue-300",
|
|
21
21
|
at: "text-purple-700",
|
|
22
|
-
number: "text-amber-700"
|
|
22
|
+
number: "text-amber-700 dark:text-amber-400"
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function escape(text) {
|
|
@@ -110,9 +110,9 @@ function onKeydown(event) {
|
|
|
110
110
|
// value, language ("html" or "css"), oninput(value); class sizes the field
|
|
111
111
|
export function codeInput({ value = "", language = "html", oninput, class: className = "min-h-32", readOnly = false }) {
|
|
112
112
|
const highlight = HIGHLIGHT[language] || escape
|
|
113
|
-
const colored = h("pre", { "aria-hidden": "true", class: `${BOX} pointer-events-none absolute inset-0 h-full overflow-hidden border-transparent bg-white text-gray-800` })
|
|
113
|
+
const colored = h("pre", { "aria-hidden": "true", class: `${BOX} pointer-events-none absolute inset-0 h-full overflow-hidden border-transparent bg-white dark:bg-gray-700 text-gray-800 dark:text-gray-200` })
|
|
114
114
|
const textarea = h("textarea", {
|
|
115
|
-
class: `${BOX} ${className} relative block resize-y overflow-y-auto border-gray-300 bg-transparent text-transparent caret-gray-900 outline-none selection:bg-blue-500/25 focus:border-blue-500 focus:ring-1 focus:ring-blue-500`,
|
|
115
|
+
class: `${BOX} ${className} relative block resize-y overflow-y-auto border-gray-300 dark:border-gray-600 bg-transparent text-transparent caret-gray-900 dark:caret-gray-100 outline-none selection:bg-blue-500/25 focus:border-blue-500 focus:ring-1 focus:ring-blue-500`,
|
|
116
116
|
spellcheck: false,
|
|
117
117
|
autocapitalize: "off",
|
|
118
118
|
autocomplete: "off",
|
|
@@ -10,7 +10,7 @@ import { h } from "tess_edit/ui/dom"
|
|
|
10
10
|
import { icon } from "tess_edit/ui/icons"
|
|
11
11
|
import { inputAdapter, suggestIn } from "tess_edit/ui/variable_menu"
|
|
12
12
|
|
|
13
|
-
const INPUT = "w-full min-w-0 rounded-md border border-gray-300 bg-white px-2 py-1 text-[13px] text-gray-900 shadow-xs outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
|
|
13
|
+
const INPUT = "w-full min-w-0 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-[13px] text-gray-900 dark:text-gray-100 shadow-xs outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"
|
|
14
14
|
|
|
15
15
|
// "12" → "12px"; anything else is left alone.
|
|
16
16
|
export function withUnit(value) {
|
|
@@ -57,23 +57,23 @@ export class Inspector {
|
|
|
57
57
|
["copy", "Duplicate", () => this.editor.duplicate(node.id)],
|
|
58
58
|
["trash", "Delete", () => this.editor.remove(node.id)]
|
|
59
59
|
].map(([name, title, onclick]) =>
|
|
60
|
-
h("button", { type: "button", title, class: "w-7 h-7 flex items-center justify-center rounded-md text-gray-500 hover:bg-gray-100 hover:text-gray-900", html: icon(name), onclick })
|
|
60
|
+
h("button", { type: "button", title, class: "w-7 h-7 flex items-center justify-center rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-100", html: icon(name), onclick })
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
const header = h(
|
|
64
64
|
"div",
|
|
65
|
-
{ class: "flex items-center gap-2 px-4 h-12 border-b border-gray-200 shrink-0" },
|
|
66
|
-
h("span", { class: "text-gray-400", html: icon(definition.icon, "w-4 h-4") }),
|
|
67
|
-
h("h2", { class: "font-semibold text-gray-900 truncate" }, label(node)),
|
|
65
|
+
{ class: "flex items-center gap-2 px-4 h-12 border-b border-gray-200 dark:border-gray-700 shrink-0" },
|
|
66
|
+
h("span", { class: "text-gray-400 dark:text-gray-500", html: icon(definition.icon, "w-4 h-4") }),
|
|
67
|
+
h("h2", { class: "font-semibold text-gray-900 dark:text-gray-100 truncate" }, label(node)),
|
|
68
68
|
h("div", { class: "ml-auto flex items-center gap-0.5" }, actions)
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
const groups = (definition.fields || []).map((group) => this.group(node, group))
|
|
72
72
|
const locked = this.editor.lock && node.id !== doc.id && !this.editor.isFree(node.id)
|
|
73
|
-
? h("p", { class: "mx-4 mt-3 flex items-center gap-2 rounded-md bg-amber-50 px-3 py-2 text-xs text-amber-800" }, h("span", { html: icon("lock", "w-3.5 h-3.5") }), "Part of the layout")
|
|
73
|
+
? h("p", { class: "mx-4 mt-3 flex items-center gap-2 rounded-md bg-amber-50 dark:bg-amber-900/30 px-3 py-2 text-xs text-amber-800 dark:text-amber-200" }, h("span", { html: icon("lock", "w-3.5 h-3.5") }), "Part of the layout")
|
|
74
74
|
: null
|
|
75
75
|
// A block's hint explains how to edit it, which a locked block can't be.
|
|
76
|
-
const hint = definition.hint && !locked ? h("p", { class: "mx-4 mt-3 rounded-md bg-gray-50 px-3 py-2 text-xs text-gray-600" }, definition.hint) : null
|
|
76
|
+
const hint = definition.hint && !locked ? h("p", { class: "mx-4 mt-3 rounded-md bg-gray-50 dark:bg-gray-700/50 px-3 py-2 text-xs text-gray-600 dark:text-gray-300" }, definition.hint) : null
|
|
77
77
|
|
|
78
78
|
this.element.replaceChildren(header, h("div", { class: "flex-1 overflow-y-auto pb-6" }, locked, hint, groups))
|
|
79
79
|
}
|
|
@@ -83,10 +83,10 @@ export class Inspector {
|
|
|
83
83
|
const open = this.openGroups.has(key) ? this.openGroups.get(key) : !group.collapsed
|
|
84
84
|
const details = h(
|
|
85
85
|
"details",
|
|
86
|
-
{ class: "group/field border-b border-gray-100", open, ontoggle: (event) => this.openGroups.set(key, event.currentTarget.open) },
|
|
86
|
+
{ class: "group/field border-b border-gray-100 dark:border-gray-700", open, ontoggle: (event) => this.openGroups.set(key, event.currentTarget.open) },
|
|
87
87
|
h(
|
|
88
88
|
"summary",
|
|
89
|
-
{ class: "flex items-center gap-1.5 px-4 py-2.5 cursor-pointer select-none text-xs font-semibold uppercase tracking-wide text-gray-500 hover:text-gray-800 list-none [&::-webkit-details-marker]:hidden" },
|
|
89
|
+
{ class: "flex items-center gap-1.5 px-4 py-2.5 cursor-pointer select-none text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 list-none [&::-webkit-details-marker]:hidden" },
|
|
90
90
|
h("span", { html: icon("chevron", "w-3 h-3 transition-transform group-open/field:rotate-90") }),
|
|
91
91
|
group.title
|
|
92
92
|
),
|
|
@@ -105,20 +105,20 @@ export class Inspector {
|
|
|
105
105
|
? this.control(node, field, value, set)
|
|
106
106
|
: h("fieldset", { disabled: true, class: "opacity-60" }, this.control(node, field, value, set))
|
|
107
107
|
const expand = field.type === "code" && editable
|
|
108
|
-
? h("button", { type: "button", title: `Edit ${field.label} in a larger window`, class: "absolute right-0 top-0 rounded px-1 text-[11px] font-medium text-blue-600 hover:bg-blue-50", onclick: () => this.expand(node, field) }, "Expand")
|
|
108
|
+
? h("button", { type: "button", title: `Edit ${field.label} in a larger window`, class: "absolute right-0 top-0 rounded px-1 text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: () => this.expand(node, field) }, "Expand")
|
|
109
109
|
: null
|
|
110
110
|
const adapter = editable && field.liquid && this.adapters.get(field.key)
|
|
111
111
|
const variables = adapter
|
|
112
|
-
? h("button", { type: "button", title: "Insert a variable", class: "absolute right-0 top-0 rounded px-1 font-mono text-[11px] font-medium text-blue-600 hover:bg-blue-50", onclick: (event) => this.editor.variableMenu.browse(adapter, event.currentTarget) }, "{ }")
|
|
112
|
+
? h("button", { type: "button", title: "Insert a variable", class: "absolute right-0 top-0 rounded px-1 font-mono text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: (event) => this.editor.variableMenu.browse(adapter, event.currentTarget) }, "{ }")
|
|
113
113
|
: null
|
|
114
114
|
// A div, not a label: a label would forward clicks to the first button or color picker inside it.
|
|
115
115
|
return h(
|
|
116
116
|
"div",
|
|
117
117
|
{ class: "relative block" },
|
|
118
|
-
h("span", { class: "mb-1 block text-xs font-medium text-gray-700" }, field.label),
|
|
118
|
+
h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, field.label),
|
|
119
119
|
expand || variables,
|
|
120
120
|
control,
|
|
121
|
-
field.hint ? h("span", { class: "mt-1 block text-[11px] leading-snug text-gray-500" }, field.hint) : null
|
|
121
|
+
field.hint ? h("span", { class: "mt-1 block text-[11px] leading-snug text-gray-500 dark:text-gray-400" }, field.hint) : null
|
|
122
122
|
)
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -157,14 +157,14 @@ export class Inspector {
|
|
|
157
157
|
case "segmented":
|
|
158
158
|
return h(
|
|
159
159
|
"div",
|
|
160
|
-
{ class: "flex rounded-md border border-gray-300 overflow-hidden" },
|
|
160
|
+
{ class: "flex rounded-md border border-gray-300 dark:border-gray-600 overflow-hidden" },
|
|
161
161
|
field.options.map((option) =>
|
|
162
162
|
h(
|
|
163
163
|
"button",
|
|
164
164
|
{
|
|
165
165
|
type: "button",
|
|
166
166
|
title: value === option.value ? "Click again to use the default" : "",
|
|
167
|
-
class: `flex-1 px-2 py-1 text-xs border-l first:border-l-0 border-gray-300 ${value === option.value ? "bg-blue-600 text-white" : "bg-white text-gray-700 hover:bg-gray-50"}`,
|
|
167
|
+
class: `flex-1 px-2 py-1 text-xs border-l first:border-l-0 border-gray-300 dark:border-gray-600 ${value === option.value ? "bg-blue-600 text-white" : "bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600"}`,
|
|
168
168
|
onclick: (event) => {
|
|
169
169
|
event.preventDefault()
|
|
170
170
|
set(value === option.value ? "" : option.value)
|
|
@@ -182,11 +182,11 @@ export class Inspector {
|
|
|
182
182
|
{ class: "flex items-center gap-2" },
|
|
183
183
|
h("input", {
|
|
184
184
|
type: "checkbox",
|
|
185
|
-
class: "h-4 w-4 rounded border-gray-300 text-blue-600",
|
|
185
|
+
class: "h-4 w-4 rounded border-gray-300 dark:border-gray-600 dark:bg-gray-700 text-blue-600 dark:text-blue-400",
|
|
186
186
|
checked: value === field.on,
|
|
187
187
|
onchange: (event) => set(event.target.checked ? field.on : field.off)
|
|
188
188
|
}),
|
|
189
|
-
h("span", { class: "text-xs text-gray-600" }, value === field.on ? "On" : "Off")
|
|
189
|
+
h("span", { class: "text-xs text-gray-600 dark:text-gray-300" }, value === field.on ? "On" : "Off")
|
|
190
190
|
)
|
|
191
191
|
|
|
192
192
|
case "spacing":
|
|
@@ -260,11 +260,11 @@ export class Inspector {
|
|
|
260
260
|
"div",
|
|
261
261
|
{ class: "flex items-center gap-1.5" },
|
|
262
262
|
select,
|
|
263
|
-
h("button", { type: "button", class: "shrink-0 rounded-md border border-gray-300 bg-white px-2 py-1 text-xs text-gray-700 hover:bg-gray-50 disabled:opacity-50", disabled: uploading, onclick: () => file.click() }, uploading ? "Uploading…" : "Upload"),
|
|
263
|
+
h("button", { type: "button", class: "shrink-0 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50", disabled: uploading, onclick: () => file.click() }, uploading ? "Uploading…" : "Upload"),
|
|
264
264
|
file
|
|
265
265
|
),
|
|
266
|
-
error ? h("p", { class: "mt-1 text-[11px] text-red-600", role: "alert" }, error) : null,
|
|
267
|
-
current ? h("img", { src: current.url, alt: "", class: "mt-2 max-h-24 rounded border border-gray-200" }) : null
|
|
266
|
+
error ? h("p", { class: "mt-1 text-[11px] text-red-600 dark:text-red-400", role: "alert" }, error) : null,
|
|
267
|
+
current ? h("img", { src: current.url, alt: "", class: "mt-2 max-h-24 rounded border border-gray-200 dark:border-gray-700" }) : null
|
|
268
268
|
)
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -280,7 +280,7 @@ export class Inspector {
|
|
|
280
280
|
const dialog = h(
|
|
281
281
|
"div",
|
|
282
282
|
{
|
|
283
|
-
class: "absolute inset-0 z-40 flex items-center justify-center bg-gray-900/40 p-6",
|
|
283
|
+
class: "absolute inset-0 z-40 flex items-center justify-center bg-gray-900/40 dark:bg-black/60 p-6",
|
|
284
284
|
onmousedown: (event) => event.target === dialog && close(),
|
|
285
285
|
// Escape closes the dialog, not anything behind it
|
|
286
286
|
onkeydown: (event) => {
|
|
@@ -291,13 +291,13 @@ export class Inspector {
|
|
|
291
291
|
},
|
|
292
292
|
h(
|
|
293
293
|
"div",
|
|
294
|
-
{ role: "dialog", "aria-label": field.label, class: "flex h-full max-h-[800px] w-full max-w-5xl flex-col gap-3 rounded-xl bg-white p-4 shadow-xl" },
|
|
294
|
+
{ role: "dialog", "aria-label": field.label, class: "flex h-full max-h-[800px] w-full max-w-5xl flex-col gap-3 rounded-xl bg-white dark:bg-gray-800 p-4 shadow-xl" },
|
|
295
295
|
h(
|
|
296
296
|
"div",
|
|
297
297
|
{ class: "flex items-center gap-3" },
|
|
298
|
-
h("h3", { class: "text-sm font-semibold text-gray-900" }, label(node) === field.label ? field.label : `${label(node)} · ${field.label}`),
|
|
299
|
-
field.hint ? h("span", { class: "text-xs text-gray-500" }, field.hint) : null,
|
|
300
|
-
h("button", { type: "button", title: "Close", class: "ml-auto w-8 h-8 flex items-center justify-center rounded-md text-gray-600 hover:bg-gray-100", html: icon("close"), onclick: close })
|
|
298
|
+
h("h3", { class: "text-sm font-semibold text-gray-900 dark:text-gray-100" }, label(node) === field.label ? field.label : `${label(node)} · ${field.label}`),
|
|
299
|
+
field.hint ? h("span", { class: "text-xs text-gray-500 dark:text-gray-400" }, field.hint) : null,
|
|
300
|
+
h("button", { type: "button", title: "Close", class: "ml-auto w-8 h-8 flex items-center justify-center rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700", html: icon("close"), onclick: close })
|
|
301
301
|
),
|
|
302
302
|
input
|
|
303
303
|
)
|
|
@@ -315,7 +315,7 @@ export class Inspector {
|
|
|
315
315
|
})
|
|
316
316
|
const swatch = h("input", {
|
|
317
317
|
type: "color",
|
|
318
|
-
class: "h-7 w-8 shrink-0 cursor-pointer rounded border border-gray-300 bg-white p-0.5",
|
|
318
|
+
class: "h-7 w-8 shrink-0 cursor-pointer rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 p-0.5",
|
|
319
319
|
value: /^#[0-9a-f]{6}$/i.test(value) ? value : "#ffffff",
|
|
320
320
|
oninput: (event) => {
|
|
321
321
|
text.value = event.target.value
|
|
@@ -342,7 +342,7 @@ export class Inspector {
|
|
|
342
342
|
set(formatSpacing(values))
|
|
343
343
|
}
|
|
344
344
|
}),
|
|
345
|
-
h("span", { class: "block text-center text-[10px] text-gray-400" }, side)
|
|
345
|
+
h("span", { class: "block text-center text-[10px] text-gray-400 dark:text-gray-500" }, side)
|
|
346
346
|
)
|
|
347
347
|
)
|
|
348
348
|
return h("span", { class: "grid grid-cols-4 gap-1" }, inputs)
|
|
@@ -356,7 +356,7 @@ export class Inspector {
|
|
|
356
356
|
const rows = items.map((item, index) =>
|
|
357
357
|
h(
|
|
358
358
|
"div",
|
|
359
|
-
{ class: "rounded-md border border-gray-200 bg-gray-50 p-2 space-y-1.5" },
|
|
359
|
+
{ class: "rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-700/50 p-2 space-y-1.5" },
|
|
360
360
|
field.item.map((part) =>
|
|
361
361
|
part.type === "select"
|
|
362
362
|
? h(
|
|
@@ -379,13 +379,13 @@ export class Inspector {
|
|
|
379
379
|
"div",
|
|
380
380
|
{ class: "flex justify-end gap-1" },
|
|
381
381
|
h("button", {
|
|
382
|
-
type: "button", title: "Move up", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 hover:bg-gray-200 disabled:opacity-30", disabled: index === 0, html: icon("up", "w-3.5 h-3.5"), onclick: () => {
|
|
382
|
+
type: "button", title: "Move up", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 disabled:opacity-30", disabled: index === 0, html: icon("up", "w-3.5 h-3.5"), onclick: () => {
|
|
383
383
|
const next = [...items]
|
|
384
384
|
;[next[index - 1], next[index]] = [next[index], next[index - 1]]
|
|
385
385
|
update(next)
|
|
386
386
|
}
|
|
387
387
|
}),
|
|
388
|
-
h("button", { type: "button", title: "Remove", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 hover:bg-gray-200 hover:text-red-600", html: icon("trash", "w-3.5 h-3.5"), onclick: () => update(items.filter((_, i) => i !== index)) })
|
|
388
|
+
h("button", { type: "button", title: "Remove", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-red-600 dark:hover:text-red-400", html: icon("trash", "w-3.5 h-3.5"), onclick: () => update(items.filter((_, i) => i !== index)) })
|
|
389
389
|
)
|
|
390
390
|
)
|
|
391
391
|
)
|
|
@@ -393,7 +393,7 @@ export class Inspector {
|
|
|
393
393
|
"div",
|
|
394
394
|
{ class: "space-y-2" },
|
|
395
395
|
rows,
|
|
396
|
-
h("button", { type: "button", class: "w-full rounded-md border border-dashed border-gray-300 py-1.5 text-xs text-gray-600 hover:border-blue-400 hover:text-blue-600", onclick: () => update([...items, { ...field.newItem }]) }, "Add")
|
|
396
|
+
h("button", { type: "button", class: "w-full rounded-md border border-dashed border-gray-300 dark:border-gray-600 py-1.5 text-xs text-gray-600 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400", onclick: () => update([...items, { ...field.newItem }]) }, "Add")
|
|
397
397
|
)
|
|
398
398
|
}
|
|
399
399
|
}
|
|
@@ -7,8 +7,8 @@ import { Color, Editor, StarterKit, TextAlign, TextStyle } from "tess_edit/vendo
|
|
|
7
7
|
import { h } from "tess_edit/ui/dom"
|
|
8
8
|
import { icon } from "tess_edit/ui/icons"
|
|
9
9
|
|
|
10
|
-
const BUTTON = "w-7 h-7 flex items-center justify-center rounded-md text-gray-600 hover:bg-gray-100 hover:text-gray-900"
|
|
11
|
-
const ACTIVE = "bg-blue-50 text-blue-700"
|
|
10
|
+
const BUTTON = "w-7 h-7 flex items-center justify-center rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-100"
|
|
11
|
+
const ACTIVE = "bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300"
|
|
12
12
|
|
|
13
13
|
export class TextEditing {
|
|
14
14
|
constructor(toolbar, { menu = null } = {}) {
|
|
@@ -79,13 +79,13 @@ export class TextEditing {
|
|
|
79
79
|
onmousedown: (event) => event.preventDefault(),
|
|
80
80
|
onclick: run
|
|
81
81
|
})
|
|
82
|
-
const separator = () => h("span", { class: "mx-1 h-5 w-px bg-gray-200" })
|
|
82
|
+
const separator = () => h("span", { class: "mx-1 h-5 w-px bg-gray-200 dark:bg-gray-700" })
|
|
83
83
|
|
|
84
84
|
const level = [1, 2, 3].find((l) => editor.isActive("heading", { level: l }))
|
|
85
85
|
const style = h(
|
|
86
86
|
"select",
|
|
87
87
|
{
|
|
88
|
-
class: "h-7 rounded-md border border-gray-300 bg-white px-1.5 text-xs text-gray-800",
|
|
88
|
+
class: "h-7 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-1.5 text-xs text-gray-800 dark:text-gray-200",
|
|
89
89
|
title: "Paragraph style",
|
|
90
90
|
onchange: (event) => {
|
|
91
91
|
const value = Number(event.target.value)
|
|
@@ -100,7 +100,7 @@ export class TextEditing {
|
|
|
100
100
|
const color = h("input", {
|
|
101
101
|
type: "color",
|
|
102
102
|
title: "Text color",
|
|
103
|
-
class: "h-7 w-8 cursor-pointer rounded border border-gray-300 bg-white p-0.5",
|
|
103
|
+
class: "h-7 w-8 cursor-pointer rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 p-0.5",
|
|
104
104
|
value: /^#[0-9a-f]{6}$/i.test(currentColor || "") ? currentColor : "#000000",
|
|
105
105
|
onchange: (event) => chain().setColor(event.target.value).run()
|
|
106
106
|
})
|
|
@@ -32,7 +32,7 @@ export class Tree {
|
|
|
32
32
|
"button",
|
|
33
33
|
{
|
|
34
34
|
type: "button",
|
|
35
|
-
class: `w-4 h-4 shrink-0 flex items-center justify-center text-gray-400 hover:text-gray-700 ${children.length ? "" : "invisible"}`,
|
|
35
|
+
class: `w-4 h-4 shrink-0 flex items-center justify-center text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-200 ${children.length ? "" : "invisible"}`,
|
|
36
36
|
onclick: (event) => {
|
|
37
37
|
event.stopPropagation()
|
|
38
38
|
open ? this.collapsed.add(node.id) : this.collapsed.delete(node.id)
|
|
@@ -46,7 +46,7 @@ export class Tree {
|
|
|
46
46
|
? h("button", {
|
|
47
47
|
type: "button",
|
|
48
48
|
title: "Add a block inside",
|
|
49
|
-
class: "ml-auto hidden group-hover:flex w-5 h-5 items-center justify-center rounded text-gray-500 hover:bg-gray-200 hover:text-gray-900",
|
|
49
|
+
class: "ml-auto hidden group-hover:flex w-5 h-5 items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-gray-900 dark:hover:text-gray-100",
|
|
50
50
|
html: icon("plus", "w-3.5 h-3.5"),
|
|
51
51
|
onclick: (event) => {
|
|
52
52
|
event.stopPropagation()
|
|
@@ -58,7 +58,7 @@ export class Tree {
|
|
|
58
58
|
const line = h(
|
|
59
59
|
"div",
|
|
60
60
|
{
|
|
61
|
-
class: `group relative flex items-center gap-1.5 pr-2 h-7 cursor-pointer select-none rounded-md mx-1 ${selected ? "bg-blue-50 text-blue-700" : "text-gray-700 hover:bg-gray-100"}`,
|
|
61
|
+
class: `group relative flex items-center gap-1.5 pr-2 h-7 cursor-pointer select-none rounded-md mx-1 ${selected ? "bg-blue-50 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,
|
|
62
62
|
style: `padding-left:${depth * 14 + 4}px`,
|
|
63
63
|
role: "treeitem",
|
|
64
64
|
"aria-selected": selected ? "true" : "false",
|
|
@@ -79,9 +79,9 @@ export class Tree {
|
|
|
79
79
|
onmouseleave: () => this.editor.canvas?.setHover(null)
|
|
80
80
|
},
|
|
81
81
|
toggle,
|
|
82
|
-
h("span", { class: `shrink-0 ${getBlock(node.type)?.accepts === "inherit" ? "text-amber-600" : "text-gray-400"}`, html: icon(getBlock(node.type)?.icon, "w-4 h-4") }),
|
|
83
|
-
h("span", { class: `truncate text-[13px] ${locked ? "text-gray-400" : ""}` }, label(node)),
|
|
84
|
-
locked ? h("span", { class: "ml-auto shrink-0 text-gray-300", title: "Part of the layout", html: icon("lock", "w-3.5 h-3.5") }) : add,
|
|
82
|
+
h("span", { class: `shrink-0 ${getBlock(node.type)?.accepts === "inherit" ? "text-amber-600 dark:text-amber-400" : "text-gray-400 dark:text-gray-500"}`, html: icon(getBlock(node.type)?.icon, "w-4 h-4") }),
|
|
83
|
+
h("span", { class: `truncate text-[13px] ${locked ? "text-gray-400 dark:text-gray-500" : ""}` }, label(node)),
|
|
84
|
+
locked ? h("span", { class: "ml-auto shrink-0 text-gray-300 dark:text-gray-600", title: "Part of the layout", html: icon("lock", "w-3.5 h-3.5") }) : add,
|
|
85
85
|
h("div", { class: "tess-tree-marker pointer-events-none absolute left-1 right-1 hidden" })
|
|
86
86
|
)
|
|
87
87
|
|
|
@@ -134,7 +134,7 @@ export class VariableMenu {
|
|
|
134
134
|
this.state = state
|
|
135
135
|
if (!this.element) {
|
|
136
136
|
this.element = h("div", {
|
|
137
|
-
class: "absolute z-50 w-72 max-h-72 overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg",
|
|
137
|
+
class: "absolute z-50 w-72 max-h-72 overflow-y-auto rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 py-1 shadow-lg",
|
|
138
138
|
role: "listbox",
|
|
139
139
|
"aria-label": "Variables",
|
|
140
140
|
// Keep the focus (and caret) in the field being typed in
|
|
@@ -152,9 +152,9 @@ export class VariableMenu {
|
|
|
152
152
|
const header = browse
|
|
153
153
|
? h(
|
|
154
154
|
"div",
|
|
155
|
-
{ class: "flex items-center gap-1 border-b border-gray-100 px-2.5 pb-1.5 pt-0.5 text-xs text-gray-500" },
|
|
155
|
+
{ class: "flex items-center gap-1 border-b border-gray-100 dark:border-gray-700 px-2.5 pb-1.5 pt-0.5 text-xs text-gray-500 dark:text-gray-400" },
|
|
156
156
|
path
|
|
157
|
-
? h("button", { type: "button", class: "rounded px-1 text-blue-600 hover:bg-blue-50", onclick: () => this.browse(adapter, this.anchor, path.split(".").slice(0, -1).join(".")) }, "‹ Back")
|
|
157
|
+
? h("button", { type: "button", class: "rounded px-1 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: () => this.browse(adapter, this.anchor, path.split(".").slice(0, -1).join(".")) }, "‹ Back")
|
|
158
158
|
: null,
|
|
159
159
|
h("span", { class: "truncate font-mono" }, path || "Variables")
|
|
160
160
|
)
|
|
@@ -166,16 +166,16 @@ export class VariableMenu {
|
|
|
166
166
|
type: "button",
|
|
167
167
|
role: "option",
|
|
168
168
|
"aria-selected": i === index ? "true" : "false",
|
|
169
|
-
class: `${ITEM} ${i === index ? "bg-blue-50 text-blue-800" : "text-gray-800 hover:bg-gray-50"}`,
|
|
169
|
+
class: `${ITEM} ${i === index ? "bg-blue-50 dark:bg-blue-900/40 text-blue-800 dark:text-blue-200" : "text-gray-800 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700"}`,
|
|
170
170
|
title: item.hint || "",
|
|
171
171
|
onclick: () => choose(item)
|
|
172
172
|
},
|
|
173
173
|
h("span", { class: "min-w-0 flex-1 truncate" }, item.label || item.name),
|
|
174
|
-
h("span", { class: "shrink-0 font-mono text-[11px] text-gray-500" }, item.name),
|
|
175
|
-
item.children && !(adapter.mode === "collection" && item.collection) ? h("span", { class: "shrink-0 text-gray-400" }, "›") : null
|
|
174
|
+
h("span", { class: "shrink-0 font-mono text-[11px] text-gray-500 dark:text-gray-400" }, item.name),
|
|
175
|
+
item.children && !(adapter.mode === "collection" && item.collection) ? h("span", { class: "shrink-0 text-gray-400 dark:text-gray-500" }, "›") : null
|
|
176
176
|
)
|
|
177
177
|
)
|
|
178
|
-
const empty = !items.length ? h("p", { class: "px-2.5 py-1.5 text-xs text-gray-500" }, error || "No variables here") : null
|
|
178
|
+
const empty = !items.length ? h("p", { class: "px-2.5 py-1.5 text-xs text-gray-500 dark:text-gray-400" }, error || "No variables here") : null
|
|
179
179
|
this.element.replaceChildren(...[header, ...rows, empty].filter(Boolean))
|
|
180
180
|
this.place(browse ? this.anchor.getBoundingClientRect() : adapter.rect())
|
|
181
181
|
this.element.querySelector("[aria-selected='true']")?.scrollIntoView({ block: "nearest" })
|
data/lib/tess_edit/version.rb
CHANGED