tess_edit 0.5.5 → 0.5.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f40808bae8dcda2f666c84361d3827261aaec15ae2260df2dede99b15d6783b2
|
|
4
|
+
data.tar.gz: 2f68441c824237fc96a258305d5583f473ad4f8fd4630d4a6d9b2cb65a946b7f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2dbde1a8dde3fbad145f33c77547547ed7cd9973557f8c54941ac9d26b78511f93ee283e722c866e1d4d893e93c4eddf3e4b8163c119be6acea14f5b86669136
|
|
7
|
+
data.tar.gz: 46eb21506a8e333555a6bd5c7454c1cae49286de3f8eaa0ad2292a8ae6b8a1922e28bfef7d8698f40e17da900b4d853af392ef730d3846c73a9af0fab087daba
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
// as tabs on one side). The default; a choice made in the editor's
|
|
12
12
|
// top bar is remembered per browser. Below NARROW_WIDTH the editor
|
|
13
13
|
// puts all panels on the left, whatever the choice, to leave room
|
|
14
|
-
// for the canvas
|
|
15
|
-
//
|
|
14
|
+
// for the canvas, and below COMPACT_WIDTH (a phone) in a sheet
|
|
15
|
+
// below the canvas, shown and hidden from the top bar and opened
|
|
16
|
+
// by a tap on a block. A kit without blocks (blocks: false) has
|
|
17
|
+
// Inspect on the right only, or in the sheet.
|
|
16
18
|
// compileUrl the endpoint that compiles the email kit's MJML to HTML (default
|
|
17
19
|
// /tess_edit/compile, the engine mounted at /tess_edit)
|
|
18
20
|
// mediaUrl the host's images, chosen and uploaded in Image blocks (see
|
|
@@ -71,6 +73,8 @@ const PANELS_KEY = "tess_edit:panels"
|
|
|
71
73
|
const TRANSLATION_LOCALE_KEY = "tess_edit:translation_locale"
|
|
72
74
|
// Two sidebars (256px + 320px) leave too little canvas below this editor width.
|
|
73
75
|
const NARROW_WIDTH = 1000
|
|
76
|
+
// Even one sidebar (320px) leaves too little canvas below this editor width.
|
|
77
|
+
const COMPACT_WIDTH = 640
|
|
74
78
|
const ARROWS = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }
|
|
75
79
|
|
|
76
80
|
// A new block where it was let go in a free layout
|
|
@@ -105,6 +109,8 @@ export default class extends Controller {
|
|
|
105
109
|
this.leftTab = "blocks"
|
|
106
110
|
this.panels = [this.storedPanels(), this.panelsValue].find((value) => PANELS.includes(value)) || "split"
|
|
107
111
|
this.narrow = false
|
|
112
|
+
this.compact = false
|
|
113
|
+
this.sheetOpen = false
|
|
108
114
|
this.requests = {}
|
|
109
115
|
this.media = { enabled: Boolean(this.mediaUrlValue), images: [], uploading: false, error: null }
|
|
110
116
|
this.variables = new Variables(this.variablesUrlValue)
|
|
@@ -387,6 +393,7 @@ export default class extends Controller {
|
|
|
387
393
|
this.inspectorElement = h("div", { class: "flex flex-1 flex-col min-h-0", dataset: { tessEditPanel: "inspect" } })
|
|
388
394
|
this.sidePanel = h("aside")
|
|
389
395
|
this.inspectPanel = h("aside")
|
|
396
|
+
this.sheetClose = h("button", { type: "button", title: "Hide panels", class: `${TOOL} ml-auto self-center`, html: icon("close"), onclick: () => this.setSheetOpen(false) })
|
|
390
397
|
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" })
|
|
391
398
|
this.frame = h("iframe", { class: "block h-full w-full border-0 bg-white transition-[width] duration-200", title: `${this.kit.name} canvas` })
|
|
392
399
|
this.frameWrap = h("div", { class: "relative h-full mx-auto" }, this.frame)
|
|
@@ -400,7 +407,7 @@ export default class extends Controller {
|
|
|
400
407
|
this.body
|
|
401
408
|
)
|
|
402
409
|
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" })
|
|
403
|
-
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)
|
|
410
|
+
this.main = h("main", { class: "relative flex-1 min-w-0 min-h-0 bg-gray-100 dark:bg-gray-900", ondragover: (event) => this.drag && event.preventDefault() }, this.textToolbar, this.frameWrap, this.errorBar)
|
|
404
411
|
this.arrangePanels()
|
|
405
412
|
this.element.append(this.root)
|
|
406
413
|
|
|
@@ -430,20 +437,30 @@ export default class extends Controller {
|
|
|
430
437
|
}
|
|
431
438
|
|
|
432
439
|
// Split: Blocks and Layers on the left, Inspect on the right. Left or right:
|
|
433
|
-
// one sidebar on that side with Blocks, Layers and Inspect as tabs.
|
|
440
|
+
// one sidebar on that side with Blocks, Layers and Inspect as tabs. Sheet:
|
|
441
|
+
// those tabs in the lower half, below the canvas, while it is open.
|
|
434
442
|
arrangePanels() {
|
|
435
443
|
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`
|
|
444
|
+
const sheetClass = `${panelClass("border-t", "h-1/2")}${this.sheetOpen ? "" : " hidden"}`
|
|
436
445
|
// Only the sidebars move: moving <main> would reload the canvas iframe and blank it.
|
|
437
446
|
if (!this.main.isConnected) this.body.append(this.main)
|
|
447
|
+
this.body.classList.toggle("flex-col", this.compact)
|
|
438
448
|
this.inspector?.freezeSlots()
|
|
439
449
|
if (!this.hasBlocks) {
|
|
440
|
-
this.inspectPanel.className = panelClass("border-l", "w-80")
|
|
441
|
-
|
|
450
|
+
this.inspectPanel.className = this.compact ? sheetClass : panelClass("border-l", "w-80")
|
|
451
|
+
const children = this.compact ? [this.sheetHeader("Inspect"), this.inspectorElement] : [this.inspectorElement]
|
|
452
|
+
const current = [...this.inspectPanel.children]
|
|
453
|
+
if (current.length !== children.length || children.some((child, index) => current[index] !== child)) this.inspectPanel.replaceChildren(...children)
|
|
442
454
|
if (this.main.nextSibling !== this.inspectPanel) this.main.after(this.inspectPanel)
|
|
443
455
|
return
|
|
444
456
|
}
|
|
445
457
|
this.sidePanel.replaceChildren(this.leftTabs, this.blocksElement, this.treeElement)
|
|
446
|
-
if (this.layout === "
|
|
458
|
+
if (this.layout === "sheet") {
|
|
459
|
+
this.sidePanel.className = sheetClass
|
|
460
|
+
this.sidePanel.append(this.inspectorElement)
|
|
461
|
+
this.inspectPanel.remove()
|
|
462
|
+
this.main.after(this.sidePanel)
|
|
463
|
+
} else if (this.layout === "split") {
|
|
447
464
|
this.sidePanel.className = panelClass("border-r", "w-64")
|
|
448
465
|
this.inspectPanel.className = panelClass("border-l", "w-80")
|
|
449
466
|
this.inspectPanel.replaceChildren(this.inspectorElement)
|
|
@@ -457,6 +474,22 @@ export default class extends Controller {
|
|
|
457
474
|
}
|
|
458
475
|
}
|
|
459
476
|
|
|
477
|
+
// The sheet's title bar for a kit without blocks, which has no tabs
|
|
478
|
+
sheetHeader(title) {
|
|
479
|
+
this.sheetTitle ||= h("div", { class: "flex items-center h-12 px-3 border-b border-gray-200 dark:border-gray-700 shrink-0 text-[13px] font-medium" })
|
|
480
|
+
this.sheetTitle.replaceChildren(title, this.sheetClose)
|
|
481
|
+
return this.sheetTitle
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Shows or hides the panels' sheet on a compact editor
|
|
485
|
+
setSheetOpen(open) {
|
|
486
|
+
if (!this.compact || open === this.sheetOpen) return
|
|
487
|
+
this.sheetOpen = open
|
|
488
|
+
;(this.hasBlocks ? this.sidePanel : this.inspectPanel).classList.toggle("hidden", !open)
|
|
489
|
+
this.renderTopBar()
|
|
490
|
+
this.canvas.refresh()
|
|
491
|
+
}
|
|
492
|
+
|
|
460
493
|
setPanels(panels) {
|
|
461
494
|
if (!PANELS.includes(panels)) return
|
|
462
495
|
this.panels = panels
|
|
@@ -473,13 +506,17 @@ export default class extends Controller {
|
|
|
473
506
|
this.renderLeftTabs()
|
|
474
507
|
}
|
|
475
508
|
|
|
476
|
-
// Combines the panels while the editor is narrower than NARROW_WIDTH
|
|
509
|
+
// Combines the panels while the editor is narrower than NARROW_WIDTH, and
|
|
510
|
+
// puts them in a sheet while it is narrower than COMPACT_WIDTH.
|
|
477
511
|
observeWidth() {
|
|
478
512
|
if (typeof ResizeObserver === "undefined") return
|
|
479
513
|
this.resizeObserver = new ResizeObserver(([entry]) => {
|
|
480
514
|
const narrow = entry.contentRect.width < NARROW_WIDTH
|
|
481
|
-
|
|
515
|
+
const compact = entry.contentRect.width < COMPACT_WIDTH
|
|
516
|
+
if (narrow === this.narrow && compact === this.compact) return
|
|
482
517
|
this.narrow = narrow
|
|
518
|
+
if (compact !== this.compact) this.sheetOpen = false
|
|
519
|
+
this.compact = compact
|
|
483
520
|
this.applyPanels()
|
|
484
521
|
this.canvas.refresh()
|
|
485
522
|
})
|
|
@@ -490,6 +527,7 @@ export default class extends Controller {
|
|
|
490
527
|
// split, or the kit has no blocks
|
|
491
528
|
get layout() {
|
|
492
529
|
if (!this.hasBlocks) return "split"
|
|
530
|
+
if (this.compact) return "sheet"
|
|
493
531
|
return this.narrow && this.panels === "split" ? "left" : this.panels
|
|
494
532
|
}
|
|
495
533
|
|
|
@@ -539,15 +577,18 @@ export default class extends Controller {
|
|
|
539
577
|
)
|
|
540
578
|
)
|
|
541
579
|
|
|
580
|
+
// A compact editor's top bar scrolls sideways rather than overflow
|
|
581
|
+
this.topBar.classList.toggle("overflow-x-auto", this.compact)
|
|
542
582
|
// replaceChildren would turn a null into the text "null", so only pass real elements.
|
|
543
583
|
this.topBar.replaceChildren(...[
|
|
544
|
-
h("span", { class: "font-semibold text-gray-900 dark:text-gray-100 mr-3" }, this.kit.name),
|
|
584
|
+
this.compact ? null : h("span", { class: "font-semibold text-gray-900 dark:text-gray-100 mr-3" }, this.kit.name),
|
|
545
585
|
toggle(this.mode, [["edit", "edit", "Edit"], ["preview", "eye", this.kit.previewTitle || "Preview"]], (mode) => this.setMode(mode)),
|
|
546
586
|
this.kit.devices?.length ? toggle(this.device, this.kit.devices.map((device) => [device.key, device.icon, device.title]), (device) => this.setDevice(device)) : null,
|
|
547
587
|
this.translations.enabled ? this.translationLocaleMenu() : null,
|
|
548
588
|
h("div", { class: "flex-1" }),
|
|
549
|
-
//
|
|
550
|
-
this.
|
|
589
|
+
// A compact editor shows its panels or not; one without blocks has none to arrange
|
|
590
|
+
this.compact && h("button", { type: "button", title: this.sheetOpen ? "Hide panels" : "Show panels", "aria-pressed": String(this.sheetOpen), class: `${TOOL} ${this.sheetOpen ? "bg-gray-100 dark:bg-gray-700" : ""}`, html: icon("panels-bottom"), onclick: () => this.setSheetOpen(!this.sheetOpen) }),
|
|
591
|
+
this.hasBlocks && !this.compact && toggle(
|
|
551
592
|
this.layout,
|
|
552
593
|
[
|
|
553
594
|
["left", "panels-left", "All panels on the left"],
|
|
@@ -556,7 +597,7 @@ export default class extends Controller {
|
|
|
556
597
|
],
|
|
557
598
|
(panels) => this.setPanels(panels)
|
|
558
599
|
),
|
|
559
|
-
this.hasBlocks && h("span", { class: "mx-1 h-5 w-px bg-gray-200 dark:bg-gray-700" }),
|
|
600
|
+
(this.hasBlocks || this.compact) && h("span", { class: "mx-1 h-5 w-px bg-gray-200 dark:bg-gray-700" }),
|
|
560
601
|
h("button", { type: "button", title: "Undo (⌘Z)", class: TOOL, disabled: !this.history.canUndo, html: icon("undo"), onclick: () => this.undo() }),
|
|
561
602
|
h("button", { type: "button", title: "Redo (⇧⌘Z)", class: TOOL, disabled: !this.history.canRedo, html: icon("redo"), onclick: () => this.redo() }),
|
|
562
603
|
h(
|
|
@@ -594,6 +635,7 @@ export default class extends Controller {
|
|
|
594
635
|
// replaceChildren would turn a null into the text "null", so only pass real tabs.
|
|
595
636
|
const tabs = [tab("blocks", "Blocks"), tab("layers", "Layers")]
|
|
596
637
|
if (this.combined) tabs.push(tab("inspect", "Inspect"))
|
|
638
|
+
if (this.compact && this.hasBlocks) tabs.push(this.sheetClose)
|
|
597
639
|
this.leftTabs.replaceChildren(...tabs)
|
|
598
640
|
this.blocksElement.classList.toggle("hidden", this.leftTab !== "blocks")
|
|
599
641
|
this.treeElement.classList.toggle("hidden", this.leftTab !== "layers")
|
|
@@ -704,9 +746,11 @@ export default class extends Controller {
|
|
|
704
746
|
|
|
705
747
|
// --- selection and editing ---------------------------------------------------
|
|
706
748
|
|
|
707
|
-
// `reveal` (a click on the canvas) shows the Inspect tab when the panels are
|
|
749
|
+
// `reveal` (a click on the canvas) shows the Inspect tab when the panels are
|
|
750
|
+
// combined, and opens their sheet on a compact editor.
|
|
708
751
|
select(id, { reveal = false } = {}) {
|
|
709
752
|
if (reveal && this.combined && this.leftTab !== "inspect") this.setLeftTab("inspect")
|
|
753
|
+
if (reveal) this.setSheetOpen(true)
|
|
710
754
|
if (this.editingId && this.editingId !== id) this.stopEditing()
|
|
711
755
|
if (!find(this.doc, id)) id = this.doc.id
|
|
712
756
|
if (this.selectedId === id) return
|
|
@@ -805,6 +849,8 @@ export default class extends Controller {
|
|
|
805
849
|
if (drag.kind === "move" && !this.isFree(drag.id)) return
|
|
806
850
|
this.closeMenu()
|
|
807
851
|
if (this.editingId) this.stopEditing()
|
|
852
|
+
// Out of the way of the canvas it goes onto
|
|
853
|
+
if (drag.kind !== "move") this.setSheetOpen(false)
|
|
808
854
|
this.drag = drag
|
|
809
855
|
this.canvas.setHover(null)
|
|
810
856
|
}
|
|
@@ -26,6 +26,7 @@ const paths = {
|
|
|
26
26
|
"cols-21": '<rect x="3" y="6" width="10.5" height="12" rx="1.5"/><rect x="15.5" y="6" width="5.5" height="12" rx="1.5"/>',
|
|
27
27
|
"panels-left": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M10 4v16"/><path d="M5.5 8h2M5.5 11h2" opacity=".6"/>',
|
|
28
28
|
"panels-split": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M8 4v16M16 4v16"/>',
|
|
29
|
+
"panels-bottom": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 13h18"/><path d="M7 16.5h4" opacity=".6"/>',
|
|
29
30
|
"panels-right": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M14 4v16"/><path d="M16.5 8h2M16.5 11h2" opacity=".6"/>',
|
|
30
31
|
lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/>',
|
|
31
32
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
data/lib/tess_edit/version.rb
CHANGED