tess_edit 0.5.17 → 0.6.0
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 +91 -68
- data/app/controllers/tess_edit/compilations_controller.rb +6 -3
- data/app/javascript/tess_edit/blocks/assign.js +2 -5
- data/app/javascript/tess_edit/blocks/builtin.js +6 -9
- data/app/javascript/tess_edit/blocks/button.js +1 -4
- data/app/javascript/tess_edit/blocks/column.js +1 -4
- data/app/javascript/tess_edit/blocks/condition.js +2 -5
- data/app/javascript/tess_edit/blocks/content.js +4 -11
- data/app/javascript/tess_edit/blocks/divider.js +1 -4
- data/app/javascript/tess_edit/blocks/image.js +1 -4
- data/app/javascript/tess_edit/blocks/loop.js +2 -5
- data/app/javascript/tess_edit/blocks/raw.js +1 -10
- data/app/javascript/tess_edit/blocks/section.js +1 -5
- data/app/javascript/tess_edit/blocks/spacer.js +1 -4
- data/app/javascript/tess_edit/blocks/table.js +8 -15
- data/app/javascript/tess_edit/blocks/text.js +1 -4
- data/app/javascript/tess_edit/controllers/editor_controller.js +32 -20
- data/app/javascript/tess_edit/core/document.js +8 -8
- data/app/javascript/tess_edit/core/media.js +1 -1
- data/app/javascript/tess_edit/core/registry.js +29 -25
- data/app/javascript/tess_edit/export/compile.js +15 -6
- data/app/javascript/tess_edit/export/richtext.js +1 -1
- data/app/javascript/tess_edit/export/table.js +9 -7
- data/app/javascript/tess_edit/index.js +2 -3
- data/app/javascript/tess_edit/ui/canvas.js +19 -7
- data/config/locales/en.yml +1 -39
- data/config/locales/nl.yml +1 -39
- data/lib/tess_edit/content.rb +5 -4
- data/lib/tess_edit/version.rb +1 -1
- data/lib/tess_edit.rb +34 -8
- metadata +1 -24
- data/app/javascript/tess_edit/blocks/email.js +0 -83
- data/app/javascript/tess_edit/blocks/hero.js +0 -60
- data/app/javascript/tess_edit/blocks/navbar.js +0 -49
- data/app/javascript/tess_edit/blocks/social.js +0 -39
- data/app/javascript/tess_edit/blocks/wrapper.js +0 -24
- data/app/javascript/tess_edit/core/starter.js +0 -89
- data/app/javascript/tess_edit/export/mjml.js +0 -117
- data/app/javascript/tess_edit/kits/builtin.js +0 -5
- data/app/javascript/tess_edit/kits/email.js +0 -28
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { VERTICAL_ALIGN, background, padding } from "tess_edit/blocks/fields"
|
|
2
|
-
import { imageField } from "tess_edit/core/media"
|
|
3
|
-
|
|
4
|
-
const headline = { type: "doc", content: [{ type: "paragraph", content: [{ type: "text", text: "A big headline" }] }] }
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
type: "hero",
|
|
8
|
-
name: "Hero",
|
|
9
|
-
icon: "hero",
|
|
10
|
-
roles: ["body"],
|
|
11
|
-
accepts: ["content"],
|
|
12
|
-
defaults: () => ({
|
|
13
|
-
attributes: {
|
|
14
|
-
mode: "fixed-height",
|
|
15
|
-
height: "320px",
|
|
16
|
-
"background-url": "https://placehold.co/1200x640/1f2937/1f2937.png",
|
|
17
|
-
"background-width": "600px",
|
|
18
|
-
"background-height": "320px",
|
|
19
|
-
"background-color": "#1f2937",
|
|
20
|
-
"vertical-align": "middle",
|
|
21
|
-
padding: "40px 0px"
|
|
22
|
-
}
|
|
23
|
-
}),
|
|
24
|
-
fields: [
|
|
25
|
-
{
|
|
26
|
-
title: "Hero",
|
|
27
|
-
fields: [
|
|
28
|
-
{ key: "attributes.mode", label: "Mode", type: "segmented", options: [{ value: "fixed-height", label: "Fixed height" }, { value: "fluid-height", label: "Fluid" }] },
|
|
29
|
-
{ key: "attributes.height", label: "Height", type: "size" },
|
|
30
|
-
{ key: "attributes.vertical-align", label: "Vertical align", type: "segmented", options: VERTICAL_ALIGN },
|
|
31
|
-
padding
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
title: "Background",
|
|
36
|
-
fields: [
|
|
37
|
-
imageField("attributes.background-url", "Image", "data.background"),
|
|
38
|
-
{ key: "attributes.background-width", label: "Image width", type: "size" },
|
|
39
|
-
{ key: "attributes.background-height", label: "Image height", type: "size" },
|
|
40
|
-
{ key: "attributes.background-position", label: "Position", type: "text", placeholder: "center center" },
|
|
41
|
-
background
|
|
42
|
-
]
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
palette: [
|
|
46
|
-
{
|
|
47
|
-
key: "hero",
|
|
48
|
-
label: "Hero",
|
|
49
|
-
category: "layout",
|
|
50
|
-
create: ({ createNode }) =>
|
|
51
|
-
createNode("hero", {
|
|
52
|
-
children: [
|
|
53
|
-
createNode("text", { attributes: { align: "center", color: "#ffffff", "font-size": "32px", "font-weight": "700", padding: "10px 25px" }, data: { content: headline } }),
|
|
54
|
-
createNode("button", { attributes: { align: "center", "background-color": "#ffffff", color: "#111827" }, data: { content: "Find out more" } })
|
|
55
|
-
]
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
render: { mjml: (node, { container }) => container("mj-hero", node) }
|
|
60
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { align } from "tess_edit/blocks/fields"
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: "navbar",
|
|
5
|
-
name: "Navbar",
|
|
6
|
-
icon: "navbar",
|
|
7
|
-
category: "content",
|
|
8
|
-
roles: ["content"],
|
|
9
|
-
defaults: () => ({
|
|
10
|
-
attributes: { align: "center" },
|
|
11
|
-
data: {
|
|
12
|
-
links: [
|
|
13
|
-
{ label: "Home", href: "https://example.com/" },
|
|
14
|
-
{ label: "Products", href: "https://example.com/products" },
|
|
15
|
-
{ label: "Contact", href: "https://example.com/contact" }
|
|
16
|
-
],
|
|
17
|
-
color: "#111827",
|
|
18
|
-
fontSize: "14px",
|
|
19
|
-
linkPadding: "10px 15px"
|
|
20
|
-
}
|
|
21
|
-
}),
|
|
22
|
-
fields: [
|
|
23
|
-
{
|
|
24
|
-
title: "Navbar",
|
|
25
|
-
fields: [
|
|
26
|
-
{ key: "data.links", label: "Links", type: "list", item: [{ name: "label", label: "Label" }, { name: "href", label: "URL" }], newItem: { label: "Link", href: "https://" } },
|
|
27
|
-
align,
|
|
28
|
-
{ key: "attributes.hamburger", label: "Hamburger on mobile", type: "toggle", on: "hamburger", off: "" }
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
title: "Links",
|
|
33
|
-
fields: [
|
|
34
|
-
{ key: "data.color", label: "Color", type: "color" },
|
|
35
|
-
{ key: "data.fontSize", label: "Font size", type: "size" },
|
|
36
|
-
{ key: "data.fontFamily", label: "Font family", type: "font", placeholder: "Inherit" },
|
|
37
|
-
{ key: "data.linkPadding", label: "Padding", type: "spacing" }
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
render: {
|
|
42
|
-
mjml(node, { element, attrs, escapeText }) {
|
|
43
|
-
const d = node.data
|
|
44
|
-
const linkAttrs = { color: d.color, "font-size": d.fontSize, "font-family": d.fontFamily, padding: d.linkPadding }
|
|
45
|
-
const links = (d.links || []).map((link) => ` <mj-navbar-link${attrs({ href: link.href, ...linkAttrs })}>${escapeText(link.label)}</mj-navbar-link>`)
|
|
46
|
-
return element("mj-navbar", node, `\n${links.join("\n")}\n`)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { align, padding, typography } from "tess_edit/blocks/fields"
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
type: "social",
|
|
5
|
-
name: "Social",
|
|
6
|
-
icon: "social",
|
|
7
|
-
category: "content",
|
|
8
|
-
roles: ["content"],
|
|
9
|
-
defaults: () => ({
|
|
10
|
-
attributes: { mode: "horizontal", align: "center", "icon-size": "24px", padding: "10px 25px" },
|
|
11
|
-
data: {
|
|
12
|
-
elements: [
|
|
13
|
-
{ name: "facebook", href: "https://facebook.com/", label: "" },
|
|
14
|
-
{ name: "instagram", href: "https://instagram.com/", label: "" },
|
|
15
|
-
{ name: "linkedin", href: "https://linkedin.com/", label: "" }
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
}),
|
|
19
|
-
fields: [
|
|
20
|
-
{
|
|
21
|
-
title: "Social",
|
|
22
|
-
fields: [
|
|
23
|
-
{ key: "data.elements", label: "Links", type: "list", item: [{ name: "name", label: "Network", type: "select", options: ["facebook", "instagram", "linkedin", "x", "youtube", "github", "pinterest", "web"] }, { name: "href", label: "URL" }, { name: "label", label: "Label" }], newItem: { name: "web", href: "https://", label: "" } },
|
|
24
|
-
{ key: "attributes.mode", label: "Mode", type: "segmented", options: [{ value: "horizontal", label: "Horizontal" }, { value: "vertical", label: "Vertical" }] },
|
|
25
|
-
{ key: "attributes.icon-size", label: "Icon size", type: "size" },
|
|
26
|
-
{ key: "attributes.icon-padding", label: "Icon padding", type: "spacing" },
|
|
27
|
-
align,
|
|
28
|
-
padding
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
typography()
|
|
32
|
-
],
|
|
33
|
-
render: {
|
|
34
|
-
mjml(node, { element, attrs, escapeText }) {
|
|
35
|
-
const elements = (node.data.elements || []).map((item) => ` <mj-social-element${attrs({ name: item.name, href: item.href })}>${escapeText(item.label)}</mj-social-element>`)
|
|
36
|
-
return element("mj-social", node, `\n${elements.join("\n")}\n`)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { background, border, padding } from "tess_edit/blocks/fields"
|
|
2
|
-
import { imageField } from "tess_edit/core/media"
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
type: "wrapper",
|
|
6
|
-
name: "Wrapper",
|
|
7
|
-
icon: "wrapper",
|
|
8
|
-
category: "layout",
|
|
9
|
-
roles: ["wrapper"],
|
|
10
|
-
accepts: ["body"],
|
|
11
|
-
defaults: () => ({ attributes: { padding: "20px 0px", "background-color": "#ffffff" } }),
|
|
12
|
-
fields: [
|
|
13
|
-
{ title: "Wrapper", fields: [background, imageField("attributes.background-url", "Background image", "data.background"), { key: "attributes.full-width", label: "Full width", type: "toggle", on: "full-width", off: "" }, padding] },
|
|
14
|
-
border
|
|
15
|
-
],
|
|
16
|
-
palette: [
|
|
17
|
-
{
|
|
18
|
-
key: "wrapper",
|
|
19
|
-
label: "Wrapper",
|
|
20
|
-
create: ({ createNode }) => createNode("wrapper", { children: [createNode("section", { children: [createNode("column")] })] })
|
|
21
|
-
}
|
|
22
|
-
],
|
|
23
|
-
render: { mjml: (node, { container }) => container("mj-wrapper", node) }
|
|
24
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// A sample document for new, empty editors and the demo page.
|
|
2
|
-
|
|
3
|
-
import { createDocument, createNode } from "tess_edit/core/document"
|
|
4
|
-
|
|
5
|
-
const paragraph = (...content) => ({ type: "paragraph", content })
|
|
6
|
-
const text = (value, marks) => (marks ? { type: "text", text: value, marks } : { type: "text", text: value })
|
|
7
|
-
const doc = (...content) => ({ type: "doc", content })
|
|
8
|
-
|
|
9
|
-
const section = (attributes, ...columns) => createNode("section", { attributes, children: columns })
|
|
10
|
-
const column = (attributes, ...children) => createNode("column", { attributes, children })
|
|
11
|
-
|
|
12
|
-
export function starterDocument() {
|
|
13
|
-
const page = createDocument()
|
|
14
|
-
page.data.subject = "Your order {{ order.number }}"
|
|
15
|
-
page.data.preheader = "Thanks for shopping with us, {{ customer.first_name }}."
|
|
16
|
-
|
|
17
|
-
page.children = [
|
|
18
|
-
section(
|
|
19
|
-
{ padding: "24px 0px 8px" },
|
|
20
|
-
column(
|
|
21
|
-
{},
|
|
22
|
-
createNode("text", {
|
|
23
|
-
attributes: { align: "center", "font-size": "20px", "font-weight": "700", "letter-spacing": "1px" },
|
|
24
|
-
data: { content: doc(paragraph(text("ACME STORE"))) }
|
|
25
|
-
})
|
|
26
|
-
)
|
|
27
|
-
),
|
|
28
|
-
section(
|
|
29
|
-
{ "background-color": "#ffffff", padding: "32px 0px", "border-radius": "8px" },
|
|
30
|
-
column(
|
|
31
|
-
{},
|
|
32
|
-
createNode("text", {
|
|
33
|
-
attributes: { "font-size": "26px", "font-weight": "700", "line-height": "1.3" },
|
|
34
|
-
data: { content: doc(paragraph(text("Thanks for your order, {{ customer.first_name }}!"))) }
|
|
35
|
-
}),
|
|
36
|
-
createNode("text", {
|
|
37
|
-
data: {
|
|
38
|
-
content: doc(
|
|
39
|
-
paragraph(text("We've received order "), text("{{ order.number }}", [{ type: "bold" }]), text(" and will let you know when it ships.")),
|
|
40
|
-
paragraph(),
|
|
41
|
-
paragraph(text("Here's what you ordered:"))
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
}),
|
|
45
|
-
createNode("loop", {
|
|
46
|
-
data: { variable: "line", collection: "order.lines" },
|
|
47
|
-
children: [
|
|
48
|
-
createNode("text", {
|
|
49
|
-
attributes: { padding: "4px 25px" },
|
|
50
|
-
data: { content: doc(paragraph(text("{{ line.quantity }} × {{ line.name }} — {{ line.total | money }}"))) }
|
|
51
|
-
})
|
|
52
|
-
]
|
|
53
|
-
}),
|
|
54
|
-
createNode("divider", { attributes: { padding: "16px 25px" } }),
|
|
55
|
-
createNode("button", { attributes: { href: "{{ order.url }}" }, data: { content: "View your order" } })
|
|
56
|
-
)
|
|
57
|
-
),
|
|
58
|
-
createNode("condition", {
|
|
59
|
-
data: { expression: "customer.orders_count == 1" },
|
|
60
|
-
children: [
|
|
61
|
-
section(
|
|
62
|
-
{ padding: "24px 0px 0px" },
|
|
63
|
-
column(
|
|
64
|
-
{ width: "50%" },
|
|
65
|
-
createNode("image", { attributes: { src: "https://placehold.co/600x400/dbeafe/1e3a8a.png?text=Welcome", padding: "0px 12px 0px 25px", "border-radius": "6px" } })
|
|
66
|
-
),
|
|
67
|
-
column(
|
|
68
|
-
{ width: "50%", "vertical-align": "middle" },
|
|
69
|
-
createNode("text", {
|
|
70
|
-
data: { content: doc(paragraph(text("Welcome!", [{ type: "bold" }])), paragraph(text("This is your first order. Here's 10% off the next one with code WELCOME10."))) }
|
|
71
|
-
})
|
|
72
|
-
)
|
|
73
|
-
)
|
|
74
|
-
]
|
|
75
|
-
}),
|
|
76
|
-
section(
|
|
77
|
-
{ padding: "24px 0px" },
|
|
78
|
-
column(
|
|
79
|
-
{},
|
|
80
|
-
createNode("social"),
|
|
81
|
-
createNode("text", {
|
|
82
|
-
attributes: { align: "center", "font-size": "12px", color: "#6b7280" },
|
|
83
|
-
data: { content: doc(paragraph(text("ACME Store · Main Street 1 · Amsterdam")), paragraph(text("Unsubscribe", [{ type: "link", attrs: { href: "{{ unsubscribe_url }}" } }]))) }
|
|
84
|
-
})
|
|
85
|
-
)
|
|
86
|
-
)
|
|
87
|
-
]
|
|
88
|
-
return page
|
|
89
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// JSON document → MJML. Each block renders itself through its render.mjml(node,
|
|
2
|
-
// ctx) hook (see blocks/*.js); this file holds the shared helpers in `ctx`.
|
|
3
|
-
//
|
|
4
|
-
// With { editor: true } the output is meant for the editing canvas: every
|
|
5
|
-
// element gets a css-class "tess-<id>" so clicks map back to blocks, empty
|
|
6
|
-
// containers get a placeholder ("tessph-<id>"), and Liquid tags are left out so
|
|
7
|
-
// loops and conditions show their content once.
|
|
8
|
-
//
|
|
9
|
-
// Without it, Loop and Condition blocks emit their Liquid tags inside <mj-raw>,
|
|
10
|
-
// which MJML copies into the HTML unchanged, so Liquid can run on the compiled HTML.
|
|
11
|
-
//
|
|
12
|
-
// The ctx a block's render.mjml gets:
|
|
13
|
-
// editor true when rendering for the canvas
|
|
14
|
-
// context where the node sits: "body" (mj-body, mj-wrapper),
|
|
15
|
-
// "section" (mj-section) or "column" (mj-column, mj-hero)
|
|
16
|
-
// attrs(a, extra) ` name="value"` pairs, empty values left out
|
|
17
|
-
// cssClass(node) { "css-class": "tess-<id> <the block's own css-class>" }
|
|
18
|
-
// in the editor, {} otherwise
|
|
19
|
-
// element(tag, node, inner?) <tag> with the node's attributes and class;
|
|
20
|
-
// self-closing without inner
|
|
21
|
-
// container(tag, node) <tag> around the node's rendered children
|
|
22
|
-
// children(node, context?) the children's MJML, as an array
|
|
23
|
-
// liquid(node, open, close) children wrapped in Liquid tags (not in the editor)
|
|
24
|
-
// indent(text, level), escapeText, escapeAttribute, richText(content)
|
|
25
|
-
|
|
26
|
-
import { t } from "tess_edit/core/i18n"
|
|
27
|
-
import { getBlock } from "tess_edit/core/registry"
|
|
28
|
-
import { escapeAttribute, escapeText, richTextToHtml } from "tess_edit/export/richtext"
|
|
29
|
-
|
|
30
|
-
const PLACEHOLDER_COLOR = "#94a3b8"
|
|
31
|
-
|
|
32
|
-
function attrs(attributes = {}, extra = {}) {
|
|
33
|
-
return Object.entries({ ...attributes, ...extra })
|
|
34
|
-
.filter(([, value]) => value !== undefined && value !== null && value !== "")
|
|
35
|
-
.map(([name, value]) => ` ${name}="${escapeAttribute(value)}"`)
|
|
36
|
-
.join("")
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function indent(text, level) {
|
|
40
|
-
const pad = " ".repeat(level)
|
|
41
|
-
return text
|
|
42
|
-
.split("\n")
|
|
43
|
-
.map((line) => (line ? pad + line : line))
|
|
44
|
-
.join("\n")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// What a container's children render as, from the roles it accepts.
|
|
48
|
-
function childContext(definition, context) {
|
|
49
|
-
const accepts = definition?.accepts
|
|
50
|
-
if (!Array.isArray(accepts)) return context
|
|
51
|
-
if (accepts.includes("column")) return "section"
|
|
52
|
-
if (accepts.includes("content")) return "column"
|
|
53
|
-
return "body"
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class Renderer {
|
|
57
|
-
constructor(options) {
|
|
58
|
-
this.editor = !!options.editor
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// The marker class goes first, before the block's own css-class, so the
|
|
62
|
-
// canvas finds blocks by the start of the class attribute.
|
|
63
|
-
cssClass(node) {
|
|
64
|
-
if (!this.editor) return {}
|
|
65
|
-
return { "css-class": [`tess-${node.id}`, node.attributes?.["css-class"]].filter(Boolean).join(" ") }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
children(node, context) {
|
|
69
|
-
const kids = node.children || []
|
|
70
|
-
if (!kids.length && this.editor) return [this.placeholder(node, context)]
|
|
71
|
-
return kids.map((child) => this.node(child, context))
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
placeholder(node, context) {
|
|
75
|
-
const text = t(context === "body" ? "Drop a section here" : context === "section" ? "Drop a column here" : "Drop content here")
|
|
76
|
-
const mjText = `<mj-text css-class="tessph-${node.id}" align="center" color="${PLACEHOLDER_COLOR}" font-size="13px" padding="18px 25px">${text}</mj-text>`
|
|
77
|
-
if (context === "column") return mjText
|
|
78
|
-
if (context === "section") return `<mj-column css-class="tessph-${node.id}">\n ${mjText}\n</mj-column>`
|
|
79
|
-
return `<mj-section css-class="tessph-${node.id}">\n <mj-column>\n ${mjText}\n </mj-column>\n</mj-section>`
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
context(context) {
|
|
83
|
-
return {
|
|
84
|
-
editor: this.editor,
|
|
85
|
-
context,
|
|
86
|
-
attrs,
|
|
87
|
-
indent,
|
|
88
|
-
escapeText,
|
|
89
|
-
escapeAttribute,
|
|
90
|
-
richText: richTextToHtml,
|
|
91
|
-
cssClass: (node) => this.cssClass(node),
|
|
92
|
-
children: (node, childCtx) => this.children(node, childCtx ?? childContext(getBlock(node.type), context)),
|
|
93
|
-
element: (tag, node, inner) => {
|
|
94
|
-
const open = `<${tag}${attrs(node.attributes, this.cssClass(node))}`
|
|
95
|
-
return inner === undefined ? `${open} />` : `${open}>${inner}</${tag}>`
|
|
96
|
-
},
|
|
97
|
-
container: (tag, node) => {
|
|
98
|
-
const inner = this.children(node, childContext(getBlock(node.type), context)).join("\n")
|
|
99
|
-
return `<${tag}${attrs(node.attributes, this.cssClass(node))}>\n${indent(inner, 1)}\n</${tag}>`
|
|
100
|
-
},
|
|
101
|
-
liquid: (node, open, close) => {
|
|
102
|
-
const inner = this.children(node, context)
|
|
103
|
-
if (this.editor) return inner.join("\n")
|
|
104
|
-
return [`<mj-raw>${open}</mj-raw>`, ...inner, `<mj-raw>${close}</mj-raw>`].join("\n")
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
node(node, context) {
|
|
110
|
-
const render = getBlock(node.type)?.render?.mjml
|
|
111
|
-
return render ? render(node, this.context(context)) : ""
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function toMjml(doc, options = {}) {
|
|
116
|
-
return new Renderer(options).node(doc, null)
|
|
117
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// The email kit: the document becomes MJML in the browser, which the server
|
|
2
|
-
// compiles to HTML with MRML (export/compile.js), for the canvas and the
|
|
3
|
-
// html output alike. Liquid stays in both, for rendering at send time.
|
|
4
|
-
|
|
5
|
-
import { toMjml } from "tess_edit/export/mjml"
|
|
6
|
-
import { compile } from "tess_edit/export/compile"
|
|
7
|
-
import { starterDocument } from "tess_edit/core/starter"
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
key: "email",
|
|
11
|
-
name: "Email",
|
|
12
|
-
root: "email",
|
|
13
|
-
starter: starterDocument,
|
|
14
|
-
devices: [
|
|
15
|
-
{ key: "desktop", icon: "desktop", title: "Desktop" },
|
|
16
|
-
{ key: "mobile", icon: "mobile", title: "Mobile", width: "375px" }
|
|
17
|
-
],
|
|
18
|
-
previewTitle: "Preview the email as sent, with Liquid tags",
|
|
19
|
-
canvas: (doc, { editor, compileUrl, signal }) => compile(toMjml(doc, { editor }), { url: compileUrl, signal }),
|
|
20
|
-
async outputs(doc, { compileUrl, signal }) {
|
|
21
|
-
const mjml = toMjml(doc)
|
|
22
|
-
const result = await compile(mjml, { url: compileUrl, signal })
|
|
23
|
-
if (!result) return null
|
|
24
|
-
return { outputs: { mjml, html: result.html || "" }, errors: result.errors }
|
|
25
|
-
},
|
|
26
|
-
notes: { mjml: "Liquid loops and conditions are in <mj-raw> tags.", html: "Liquid is left in place for rendering at send time." },
|
|
27
|
-
errors: "The email could not be compiled"
|
|
28
|
-
}
|