tess_edit 0.3.0 → 0.4.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 +85 -6
- data/app/javascript/tess_edit/blocks/builtin.js +3 -2
- data/app/javascript/tess_edit/blocks/button.js +3 -1
- data/app/javascript/tess_edit/blocks/column.js +3 -1
- data/app/javascript/tess_edit/blocks/condition.js +3 -1
- data/app/javascript/tess_edit/blocks/content.js +36 -0
- data/app/javascript/tess_edit/blocks/divider.js +3 -1
- data/app/javascript/tess_edit/blocks/{root.js → email.js} +3 -3
- data/app/javascript/tess_edit/blocks/fields.js +4 -2
- data/app/javascript/tess_edit/blocks/image.js +3 -1
- data/app/javascript/tess_edit/blocks/loop.js +3 -1
- data/app/javascript/tess_edit/blocks/section.js +4 -2
- data/app/javascript/tess_edit/blocks/spacer.js +3 -1
- data/app/javascript/tess_edit/blocks/text.js +3 -1
- data/app/javascript/tess_edit/controllers/editor_controller.js +156 -57
- data/app/javascript/tess_edit/core/document.js +66 -16
- data/app/javascript/tess_edit/core/registry.js +119 -11
- data/app/javascript/tess_edit/index.js +4 -3
- data/app/javascript/tess_edit/kits/builtin.js +5 -0
- data/app/javascript/tess_edit/kits/email.js +28 -0
- data/app/javascript/tess_edit/ui/blocks_panel.js +54 -5
- data/app/javascript/tess_edit/ui/canvas.js +12 -9
- data/app/javascript/tess_edit/ui/icons.js +1 -0
- data/app/javascript/tess_edit/ui/inspector.js +4 -2
- data/app/javascript/tess_edit/ui/tree.js +2 -2
- data/lib/tess_edit/content.rb +62 -0
- data/lib/tess_edit/version.rb +1 -1
- data/lib/tess_edit.rb +1 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34a34ebde5272be05d2110672f0de3a54f5d0b1dd3092b0d4af19677376eef0d
|
|
4
|
+
data.tar.gz: 709b9b602cee9c5b3c217e8a78d84a25f99358794ba539517587829350ac4de0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ccce363718a5d6739d3ce383569cdc1806e244664ad5ed1ca34ac65df38def903d11ee2051c4af8704be49ad033de93dd8a3a2d9f4d1515b9e7b0dce8e756bc
|
|
7
|
+
data.tar.gz: a154489406d7669ae43ba0d4bd776b8040663ab8f77541a4b11027feaf3360afa119b5552a653f515a9b1a90ed66e4df6cfbbd2f933520b0382f39231665f457
|
data/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
TessEdit is a drag-and-drop email editor for Rails, written in plain JavaScript with Stimulus. You build an email from blocks; the editor stores the design as JSON and exports [MJML](https://mjml.io) and responsive HTML. Blocks can hold [Liquid](https://shopify.github.io/liquid/), which survives into the HTML so it can be rendered at send time.
|
|
4
4
|
|
|
5
|
+
What it makes is a kit: the email is built in, and your app can add its own, such as the demo's Note, with blocks of its own and TessEdit's (see [Kits](#kits)).
|
|
6
|
+
|
|
5
7
|
The interface follows familiar layout: blocks and a layers tree on the left, the email in the middle, and Inspect, with the selected block's settings, on the right.
|
|
6
8
|
|
|
7
9
|

|
|
@@ -22,6 +24,9 @@ It completes Liquid tags and variables as you type, making it easier to work wit
|
|
|
22
24
|
- Panels on both sides, or combined as tabs in one sidebar on the left or right to give the canvas more room.
|
|
23
25
|
- Dark mode that follows the host app's.
|
|
24
26
|
- Code dialog to view, copy or download the JSON, MJML and HTML, and to load JSON.
|
|
27
|
+
- Kits: other kinds of documents, registered by your app, with its own blocks and output and TessEdit's blocks brought in.
|
|
28
|
+
- Layouts: a Content block marks where the documents using a layout put their own blocks, and a lock keeps the rest of the layout as it is.
|
|
29
|
+
- Palette sources: tiles from your app in the Blocks panel, such as saved snippets, inserted as a copy that remembers where it came from.
|
|
25
30
|
|
|
26
31
|
## Installation
|
|
27
32
|
|
|
@@ -84,6 +89,8 @@ The editor loads the document from the `jsonInput` (or from `data-tess-edit-docu
|
|
|
84
89
|
|
|
85
90
|
`data-tess-edit-panels-value` sets the default panel layout: `split` (Blocks and Layers on the left, Inspect on the right, the default), `left` or `right` (Blocks, Layers and Inspect as tabs in one sidebar on that side). People can switch with the buttons in the top bar; their choice is remembered in the browser. When the editor is narrower than 1000px, it puts all panels on the left so the canvas keeps its room, and goes back to the chosen layout when it is wide enough again.
|
|
86
91
|
|
|
92
|
+
The editor has a border with rounded corners. A page that frames it itself, such as a card it fills, turns it off with `data-tess-edit-frame-value="false"`.
|
|
93
|
+
|
|
87
94
|
Every change updates the inputs and dispatches `tess-edit:change` with `{ json, mjml, html, errors, document }` in `event.detail`. When the MJML can't be compiled, `html` is empty and `errors` says why; the editor shows the reason under the canvas. The controller instance is available as `element.tessEdit`, with `getDocument()`, `setDocument(json)` and `export()`.
|
|
88
95
|
|
|
89
96
|
### What gets stored
|
|
@@ -117,7 +124,7 @@ TessEdit.parent_controller = "Admin::BaseController"
|
|
|
117
124
|
|
|
118
125
|
```json
|
|
119
126
|
{
|
|
120
|
-
"version": 1, "id": "b1x2y3z", "type": "
|
|
127
|
+
"version": 1, "id": "b1x2y3z", "type": "email",
|
|
121
128
|
"attributes": { "width": "600px", "background-color": "#f3f4f6" },
|
|
122
129
|
"data": { "subject": "...", "preheader": "...", "fontFamily": "..." },
|
|
123
130
|
"children": [
|
|
@@ -130,7 +137,7 @@ TessEdit.parent_controller = "Admin::BaseController"
|
|
|
130
137
|
}
|
|
131
138
|
```
|
|
132
139
|
|
|
133
|
-
The top node is the `
|
|
140
|
+
The top node is the `email` block, which renders the `<mjml>` document with the subject, preview text and theme. Documents from before its renames, with `"type": "page"` or `"type": "root"`, still load. `attributes` map onto MJML attributes; `data` holds everything else. Text content is Tiptap (ProseMirror) JSON, so other renderers, such as a kit's own, can walk it.
|
|
134
141
|
|
|
135
142
|
### Locking a layout
|
|
136
143
|
|
|
@@ -141,7 +148,48 @@ To let people fill in one part of a design that is otherwise fixed, such as a te
|
|
|
141
148
|
data-tess-edit-lock-value='<%= {except: ["content"], fields: ["data.subject", "data.preheader"]}.to_json %>'>
|
|
142
149
|
```
|
|
143
150
|
|
|
144
|
-
Only what is inside blocks of the types in `except` can change: those blocks take new blocks, and everything in them can be edited, moved, duplicated and deleted. The blocks themselves stay where they are. Of the root, only the listed `fields` can change. Everything else still shows on the canvas and can be selected, with its settings disabled in Inspect and a lock in Layers. A tile clicked while a locked block is selected goes at the end of the first block it is allowed in, and the Code dialog shows the JSON without loading it. The editor still stores the whole document; taking the open part out of it is up to the host app. The `except`
|
|
151
|
+
Only what is inside blocks of the types in `except` can change: those blocks take new blocks, and everything in them can be edited, moved, duplicated and deleted. The blocks themselves stay where they are. Of the root, only the listed `fields` can change. Everything else still shows on the canvas and can be selected, with its settings disabled in Inspect and a lock in Layers. A tile clicked while a locked block is selected goes at the end of the first block it is allowed in, and the Code dialog shows the JSON without loading it. The editor still stores the whole document; taking the open part out of it is up to the host app. The `except` type is usually `content`, the Content block (see Layouts).
|
|
152
|
+
|
|
153
|
+
### Layouts
|
|
154
|
+
|
|
155
|
+
The Content block (in the Layout category of the Blocks panel) marks where the documents using a layout put their own blocks; a layout has one. What a layout has inside it is example content to design the layout with. Outside the editor its contents are between two comments, in `<mj-raw>` tags in MJML:
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<!-- tess-edit:content --> … <!-- /tess-edit:content -->
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
A document using a layout stores its own blocks. `TessEdit::Content` puts them in and takes them out again, and puts a document's output into its layout's, so a document follows its layout when the layout changes:
|
|
162
|
+
|
|
163
|
+
```ruby
|
|
164
|
+
document = TessEdit::Content.document_with(layout.json, template.blocks) # for the editor, locked to the Content block
|
|
165
|
+
blocks = TessEdit::Content.nodes(JSON.parse(params[:json])) # what to store when it is saved
|
|
166
|
+
html = TessEdit::Content.merge(layout.html, TessEdit::Content.content_of(params[:html]))
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Palette sources
|
|
170
|
+
|
|
171
|
+
A palette source adds a section of tiles from your app to the Blocks panel, such as saved snippets. People drag a tile onto the canvas or click it, and the source creates the node that goes in:
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
import { registerPaletteSource, renumber } from "tess_edit"
|
|
175
|
+
|
|
176
|
+
registerPaletteSource({
|
|
177
|
+
key: "snippets",
|
|
178
|
+
label: "Snippets",
|
|
179
|
+
// null leaves the section out, e.g. without the setting it needs
|
|
180
|
+
items: async (editor) => {
|
|
181
|
+
if (!editor.options.snippetsUrl) return null
|
|
182
|
+
const response = await fetch(editor.options.snippetsUrl)
|
|
183
|
+
return (await response.json()).snippets // [{ key, label, type, … }]
|
|
184
|
+
},
|
|
185
|
+
// The node to insert, here a copy of the snippet's block
|
|
186
|
+
create: async (item, editor) => renumber(item.block, { origin: true })
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
An item's `type` says where the tile can go; a container with `accepts: "inherit"` goes where its children go, so a snippet with sections can't go into a column, and the editor says so. `renumber(node, { origin: true })` gives every copied block an `origin`, the id of the block it is a copy of, so your app can compare the copy with what it came from, block by block. A duplicated block is new content and has no origin. `data-tess-edit-options-value` passes settings such as `snippetsUrl` to sources and blocks, as `editor.options`.
|
|
191
|
+
|
|
192
|
+
`data-tess-edit-blocks-value` limits the blocks people can add, e.g. `["text", "image"]`; blocks already in the document, and tiles from sources, aren't affected.
|
|
145
193
|
|
|
146
194
|
### Images
|
|
147
195
|
|
|
@@ -226,7 +274,32 @@ registerBlock({
|
|
|
226
274
|
registerTessEdit(application)
|
|
227
275
|
```
|
|
228
276
|
|
|
229
|
-
Roles say where a block may go: `body` (in the
|
|
277
|
+
Roles say where a block may go: `body` (in the email or a wrapper, like sections and heroes), `wrapper`, `column` (in a section) and `content` (in a column or hero). A container lists the roles it takes in `accepts`; Loop and Condition use `"inherit"`. The full definition, and the helpers a render hook gets (`element`, `container`, `children`, `liquid`, `attrs`, `richText`, ...), are described at the top of `core/registry.js` and `export/mjml.js`. Blocks render only through their `render` hooks: `mjml` for emails, and a hook of its own for each kit. Stored documents don't change; a document with a block type that isn't registered fails `normalize`.
|
|
278
|
+
|
|
279
|
+
A select field's `options` can be a function of the editor, `options: (editor) => [...]`, for choices from your app. Give the editor those with `data-tess-edit-options-value` (JSON), which blocks read as `editor.options`.
|
|
280
|
+
|
|
281
|
+
## Kits
|
|
282
|
+
|
|
283
|
+
What the editor makes is a kit: a root block, the blocks that name the kit in their `kits`, and what the canvas shows and the editor outputs. The email is the built-in kit and its reference. Your app registers its own with `registerKit` before its root block, and picks it with `data-tess-edit-kit-value`:
|
|
284
|
+
|
|
285
|
+
```js
|
|
286
|
+
import { createDocument, extendBlock, registerBlock, registerKit } from "tess_edit"
|
|
287
|
+
|
|
288
|
+
registerKit({
|
|
289
|
+
key: "note", name: "Note", root: "note",
|
|
290
|
+
starter: () => createDocument("note"),
|
|
291
|
+
canvas: async (doc, { editor }) => ({ html: toNoteHtml(doc, { editor }), errors: [] }), // with tess-<id> classes in the editor
|
|
292
|
+
outputs: async (doc) => ({ outputs: { html: toNoteHtml(doc) }, errors: [] }) // into the htmlInput
|
|
293
|
+
})
|
|
294
|
+
registerBlock({ type: "note", name: "Note", kits: ["note"], accepts: ["body", "content"], render: { note: … } })
|
|
295
|
+
|
|
296
|
+
// TessEdit's own blocks, in the kit, with how they render in it
|
|
297
|
+
extendBlock("text", { kits: ["note"], render: { note: (node, ctx) => … } })
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
A block is part of the email kit unless it says otherwise. `extendBlock` adds kits, render hooks and field groups to a block that is registered, also when another gem replaced it, so the kit can use TessEdit's Text, Image, Section, Loop, Condition, Content and others. The kit renders its documents itself, through its blocks' hooks; the canvas needs every block's element to have the class `tess-<id>`, and an empty container a placeholder with `tessph-<id>`. `core/registry.js` describes the definition. `kits/email.js` is the reference, and the demo's Note kit (`test/dummy/app/javascript/kits/note.js`) a small one of a host app's own.
|
|
301
|
+
|
|
302
|
+
Loading a document into the editor of another kit fails with a message saying which editor it is for.
|
|
230
303
|
|
|
231
304
|
## Development
|
|
232
305
|
|
|
@@ -242,17 +315,23 @@ cd test/dummy && bin/dev
|
|
|
242
315
|
|
|
243
316
|
`/?variables=1` gives the editor the demo's variables (`VariablesController`), an order's, to try the suggestions.
|
|
244
317
|
|
|
318
|
+
`/?kit=note` designs a note: the demo's own kit (`app/javascript/kits/note.js`).
|
|
319
|
+
|
|
320
|
+
`/?snippets=1` adds the demo's snippets source (`app/javascript/snippets.js`, `SnippetsController`): a greeting and a footer section.
|
|
321
|
+
|
|
322
|
+
`/?blocks=text,image` only offers those blocks.
|
|
323
|
+
|
|
245
324
|
`/?translations=1` gives the editor the demo's translations (`TranslationsController`, in memory, in English, Dutch and German). The options combine, e.g. `/?lock=1&media=1&variables=1&translations=1`.
|
|
246
325
|
|
|
247
326
|
Tests:
|
|
248
327
|
|
|
249
328
|
```bash
|
|
250
|
-
npm test # JavaScript: document model,
|
|
329
|
+
npm test # JavaScript: document model, kits, export and MJML snapshots (Node 22+)
|
|
251
330
|
bin/rails test # Rails: engine, compile endpoint, MRML and Liquid rendering of the snapshots
|
|
252
331
|
bin/rails test:system # The editor in Chrome, through Selenium
|
|
253
332
|
```
|
|
254
333
|
|
|
255
|
-
`npm test` compares the MJML of every block, and of the sample email, with the files in `test/javascript/snapshots`. The Rails tests compile those files with MRML and render the sample with Liquid. After an intended change in output, regenerate them and review the diff:
|
|
334
|
+
`npm test` compares the MJML of every email block, and of the sample email, with the files in `test/javascript/snapshots`. The Rails tests compile those files with MRML and render the sample with Liquid. After an intended change in output, regenerate them and review the diff:
|
|
256
335
|
|
|
257
336
|
```bash
|
|
258
337
|
UPDATE_SNAPSHOTS=1 npm test
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The built-in blocks, registered by core/registry.js in this order. The
|
|
2
2
|
// order is also the order of tiles in the Blocks panel.
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import email from "tess_edit/blocks/email"
|
|
5
|
+
import content from "tess_edit/blocks/content"
|
|
5
6
|
import wrapper from "tess_edit/blocks/wrapper"
|
|
6
7
|
import section from "tess_edit/blocks/section"
|
|
7
8
|
import column from "tess_edit/blocks/column"
|
|
@@ -23,4 +24,4 @@ export const builtinCategories = [
|
|
|
23
24
|
{ key: "liquid", label: "Liquid", order: 30 }
|
|
24
25
|
]
|
|
25
26
|
|
|
26
|
-
export const builtinBlocks = [
|
|
27
|
+
export const builtinBlocks = [email, section, column, wrapper, hero, content, text, image, button, divider, spacer, social, navbar, raw, loop, condition]
|
|
@@ -28,5 +28,7 @@ export default {
|
|
|
28
28
|
border
|
|
29
29
|
],
|
|
30
30
|
label: (node) => `Button · ${node.data.content || ""}`,
|
|
31
|
-
render: {
|
|
31
|
+
render: {
|
|
32
|
+
mjml: (node, { element, escapeText }) => element("mj-button", node, escapeText(node.data.content))
|
|
33
|
+
}
|
|
32
34
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const ifTag = (node) => `{% if ${node.data.expression || "true"} %}`
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "condition",
|
|
3
5
|
name: "Condition",
|
|
@@ -10,6 +12,6 @@ export default {
|
|
|
10
12
|
hint: "Shows its blocks only when the condition is true: {% if expression %}.",
|
|
11
13
|
label: (node) => `If ${node.data.expression || "…"}`,
|
|
12
14
|
render: {
|
|
13
|
-
mjml: (node, { liquid }) => liquid(node,
|
|
15
|
+
mjml: (node, { liquid }) => liquid(node, ifTag(node), "{% endif %}")
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Where the documents using a layout put their own blocks. What a layout has
|
|
2
|
+
// inside it is example content to design the layout with; a document using
|
|
3
|
+
// the layout replaces it with its own. A layout has one.
|
|
4
|
+
//
|
|
5
|
+
// Outside the editor its contents are marked with two comments, so the host
|
|
6
|
+
// can put a document's content into the layout's output (see
|
|
7
|
+
// TessEdit::Content):
|
|
8
|
+
//
|
|
9
|
+
// <!-- tess-edit:content --> … <!-- /tess-edit:content -->
|
|
10
|
+
//
|
|
11
|
+
// In MJML the comments are in <mj-raw> tags, which MJML keeps. A kit that
|
|
12
|
+
// uses it renders the same comments (see extendBlock in core/registry.js).
|
|
13
|
+
|
|
14
|
+
export const CONTENT_START = "<!-- tess-edit:content -->"
|
|
15
|
+
export const CONTENT_END = "<!-- /tess-edit:content -->"
|
|
16
|
+
|
|
17
|
+
const mjRaw = (comment) => `<mj-raw>${comment}</mj-raw>`
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
type: "content",
|
|
21
|
+
name: "Content",
|
|
22
|
+
icon: "content",
|
|
23
|
+
category: "layout",
|
|
24
|
+
unique: true,
|
|
25
|
+
// Like Loop and Condition it adds no HTML of its own and takes what its
|
|
26
|
+
// parent takes, so it works at the top level and inside a column.
|
|
27
|
+
roles: ["body", "content"],
|
|
28
|
+
accepts: "inherit",
|
|
29
|
+
hint: "The content of the documents using this layout goes here. What you put inside is example content for designing the layout.",
|
|
30
|
+
render: {
|
|
31
|
+
mjml(node, { editor, children }) {
|
|
32
|
+
const inner = children(node)
|
|
33
|
+
return editor ? inner.join("\n") : [mjRaw(CONTENT_START), ...inner, mjRaw(CONTENT_END)].join("\n")
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// The root of
|
|
1
|
+
// The root of an email: renders the whole <mjml> document, with the
|
|
2
2
|
// email's subject, preview text and theme in <mj-head>.
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
type: "
|
|
6
|
-
name: "
|
|
5
|
+
type: "email",
|
|
6
|
+
name: "Email",
|
|
7
7
|
icon: "root",
|
|
8
8
|
roles: [],
|
|
9
9
|
accepts: ["body", "wrapper"],
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Field definitions shared by the built-in blocks, and usable by custom ones.
|
|
2
2
|
// A field: { key: "attributes.padding" | "data.subject", label, type, ... }.
|
|
3
3
|
// Types: text, textarea, code, size, color, select, segmented, toggle,
|
|
4
|
-
// spacing and list; see ui/inspector.js.
|
|
5
|
-
//
|
|
4
|
+
// spacing and list; see ui/inspector.js. A select's options can be a
|
|
5
|
+
// function of the editor, options(editor), for choices the host gives.
|
|
6
|
+
// `liquid` gives a field a button to insert the host's variables (see
|
|
7
|
+
// Inspector#variables).
|
|
6
8
|
|
|
7
9
|
export const ALIGN = [
|
|
8
10
|
{ value: "left", label: "Left" },
|
|
@@ -25,5 +25,7 @@ export default {
|
|
|
25
25
|
},
|
|
26
26
|
{ title: "Border", collapsed: true, fields: [{ key: "attributes.border", label: "Border", type: "text" }, { key: "attributes.border-radius", label: "Radius", type: "size" }, { key: "attributes.container-background-color", label: "Background", type: "color" }] }
|
|
27
27
|
],
|
|
28
|
-
render: {
|
|
28
|
+
render: {
|
|
29
|
+
mjml: (node, { element }) => element("mj-image", node)
|
|
30
|
+
}
|
|
29
31
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const forTag = (node) => `{% for ${node.data.variable || "item"} in ${node.data.collection || "items"} %}`
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "loop",
|
|
3
5
|
name: "Loop",
|
|
@@ -18,6 +20,6 @@ export default {
|
|
|
18
20
|
hint: "Repeats its blocks for each item: {% for variable in collection %}.",
|
|
19
21
|
label: (node) => `For ${node.data.variable || "item"} in ${node.data.collection || "…"}`,
|
|
20
22
|
render: {
|
|
21
|
-
mjml: (node, { liquid }) => liquid(node,
|
|
23
|
+
mjml: (node, { liquid }) => liquid(node, forTag(node), "{% endfor %}")
|
|
22
24
|
}
|
|
23
25
|
}
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
fields: [
|
|
28
28
|
background,
|
|
29
29
|
imageField("attributes.background-url", "Background image", "data.background"),
|
|
30
|
-
{ key: "attributes.full-width", label: "Full width", type: "toggle", on: "full-width", off: "" },
|
|
30
|
+
{ key: "attributes.full-width", label: "Full width", type: "toggle", on: "full-width", off: "", visible: (node, editor) => editor?.kit?.key === "email" },
|
|
31
31
|
{ key: "attributes.direction", label: "Column order", type: "segmented", options: [{ value: "ltr", label: "Left to right" }, { value: "rtl", label: "Right to left" }] },
|
|
32
32
|
{ key: "attributes.text-align", label: "Align", type: "segmented", options: ALIGN },
|
|
33
33
|
padding
|
|
@@ -36,5 +36,7 @@ export default {
|
|
|
36
36
|
border
|
|
37
37
|
],
|
|
38
38
|
palette: layouts.map(([key, label, icon, widths]) => ({ key, label, icon, category: "layout", create: ({ createNode }) => section(createNode, widths) })),
|
|
39
|
-
render: {
|
|
39
|
+
render: {
|
|
40
|
+
mjml: (node, { container }) => container("mj-section", node)
|
|
41
|
+
}
|
|
40
42
|
}
|
|
@@ -6,5 +6,7 @@ export default {
|
|
|
6
6
|
roles: ["content"],
|
|
7
7
|
defaults: () => ({ attributes: { height: "24px" } }),
|
|
8
8
|
fields: [{ title: "Spacer", fields: [{ key: "attributes.height", label: "Height", type: "size" }, { key: "attributes.container-background-color", label: "Background", type: "color" }] }],
|
|
9
|
-
render: {
|
|
9
|
+
render: {
|
|
10
|
+
mjml: (node, { element }) => element("mj-spacer", node)
|
|
11
|
+
}
|
|
10
12
|
}
|
|
@@ -35,5 +35,7 @@ export default {
|
|
|
35
35
|
create: ({ createNode }) => createNode("text", { attributes: { "font-size": "24px", "font-weight": "700", "line-height": "1.3" }, data: { content: doc("Heading") } })
|
|
36
36
|
}
|
|
37
37
|
],
|
|
38
|
-
render: {
|
|
38
|
+
render: {
|
|
39
|
+
mjml: (node, { element, richText }) => element("mj-text", node, richText(node.data.content))
|
|
40
|
+
}
|
|
39
41
|
}
|