tess_edit 0.5.9 → 0.5.11
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 +2 -1
- data/app/javascript/tess_edit/blocks/assign.js +33 -0
- data/app/javascript/tess_edit/blocks/builtin.js +3 -1
- data/app/javascript/tess_edit/blocks/condition.js +2 -1
- data/app/javascript/tess_edit/blocks/loop.js +2 -1
- data/app/javascript/tess_edit/blocks/table.js +112 -0
- data/app/javascript/tess_edit/controllers/editor_controller.js +88 -14
- data/app/javascript/tess_edit/core/registry.js +15 -8
- data/app/javascript/tess_edit/core/table.js +262 -0
- data/app/javascript/tess_edit/core/values.js +20 -5
- data/app/javascript/tess_edit/export/table.js +162 -0
- data/app/javascript/tess_edit/index.js +1 -0
- data/app/javascript/tess_edit/ui/canvas.js +130 -7
- data/app/javascript/tess_edit/ui/inspector.js +64 -1
- data/app/javascript/tess_edit/ui/text_editing.js +3 -1
- data/config/locales/en.yml +47 -0
- data/config/locales/nl.yml +47 -0
- data/lib/tess_edit/version.rb +1 -1
- metadata +5 -1
|
@@ -11,6 +11,7 @@ import { imageFields } from "tess_edit/core/media"
|
|
|
11
11
|
import { getBlock, inlinePart, label } from "tess_edit/core/registry"
|
|
12
12
|
import { missingArguments, textParts, translationCalls } from "tess_edit/core/translations"
|
|
13
13
|
import { valueCalls } from "tess_edit/core/values"
|
|
14
|
+
import { cellOf, columnCount, rowGroups, rows, setColumnAt, span, tableOf } from "tess_edit/core/table"
|
|
14
15
|
import { FREE_CSS, FreeLayout } from "tess_edit/ui/free_layout"
|
|
15
16
|
import { icon } from "tess_edit/ui/icons"
|
|
16
17
|
|
|
@@ -34,6 +35,12 @@ body{min-height:100vh;margin:0}
|
|
|
34
35
|
.tess-tools [data-tool="drag"]{cursor:grab}
|
|
35
36
|
.tess-plus{position:absolute;left:50%;top:100%;transform:translate(-50%,-50%);pointer-events:auto;width:20px;height:20px;border-radius:999px;background:#2563eb;color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;border:2px solid #fff;padding:0;box-shadow:0 1px 3px rgba(0,0,0,.25)}
|
|
36
37
|
.tess-plus:hover{background:#1d4ed8}
|
|
38
|
+
.tess-bracket{position:absolute;box-sizing:border-box;width:6px;border:2px solid #8b5cf6;border-right:0;border-radius:3px 0 0 3px;pointer-events:auto;cursor:pointer}
|
|
39
|
+
.tess-bracket:hover,.tess-bracket.tess-on{border-color:#6d28d9}
|
|
40
|
+
.tess-bracket span{position:absolute;right:calc(100% + 4px);top:-2px;color:#6d28d9;white-space:nowrap;max-width:160px;overflow:hidden;text-overflow:ellipsis}
|
|
41
|
+
.tess-column{position:absolute;width:9px;margin-left:-4px;pointer-events:auto;cursor:col-resize}
|
|
42
|
+
.tess-column::after{content:"";position:absolute;left:4px;top:0;bottom:0;width:1px;background:#2563eb;opacity:0}
|
|
43
|
+
.tess-column:hover::after,.tess-column.tess-on::after{opacity:1}
|
|
37
44
|
.tess-indicator{position:absolute;background:#2563eb;border-radius:2px;pointer-events:none;box-shadow:0 0 0 2px rgba(37,99,235,.2)}
|
|
38
45
|
.tess-indicator.tess-fill{background:rgba(37,99,235,.08);outline:2px dashed #2563eb;outline-offset:-2px;box-shadow:none}
|
|
39
46
|
[class*="tessph-"]{cursor:pointer}
|
|
@@ -51,6 +58,7 @@ a{cursor:default}
|
|
|
51
58
|
.tess-v-filled,.tess-v-raw{border-radius:3px;background:rgba(5,150,105,.08);box-shadow:inset 0 -1px 0 rgba(5,150,105,.55)}
|
|
52
59
|
.ProseMirror .tess-v-filled{cursor:text}
|
|
53
60
|
.tess-v-hidden{display:none}
|
|
61
|
+
.tess-v-empty{border-radius:3px;background:rgba(220,38,38,.08);box-shadow:inset 0 -1px 0 rgba(220,38,38,.65)}
|
|
54
62
|
`
|
|
55
63
|
|
|
56
64
|
// A file dragged in from outside the browser (block drags set editor.drag)
|
|
@@ -58,6 +66,7 @@ function isFileDrag(event, editor) {
|
|
|
58
66
|
return !editor.drag && Array.from(event.dataTransfer?.types || []).includes("Files")
|
|
59
67
|
}
|
|
60
68
|
|
|
69
|
+
const TABLE_ICON = '<rect x="3" y="5" width="18" height="14" rx="1"/><path d="M3 10h18M3 15h18M9 10v9M15 10v9"/>'
|
|
61
70
|
const CLASS = /\btess-(b[a-z0-9]+)\b/
|
|
62
71
|
const PLACEHOLDER = /\btessph-(b[a-z0-9]+)\b/
|
|
63
72
|
|
|
@@ -80,6 +89,8 @@ export class Canvas {
|
|
|
80
89
|
|
|
81
90
|
// Replaces the iframe's content, keeping the scroll position.
|
|
82
91
|
write(html, mode) {
|
|
92
|
+
// A column being dragged is let go: its listeners were the old document's
|
|
93
|
+
this.resizing = false
|
|
83
94
|
const scrollY = this.win?.scrollY || 0
|
|
84
95
|
this.mode = mode
|
|
85
96
|
const doc = this.doc
|
|
@@ -187,9 +198,11 @@ export class Canvas {
|
|
|
187
198
|
if (!values || !this.doc?.body) return
|
|
188
199
|
for (const span of this.doc.querySelectorAll(".tess-v[data-tess-call]")) {
|
|
189
200
|
const value = values.value(span.dataset.tessExpression)
|
|
201
|
+
const empty = value === null && values.empty(span.dataset.tessExpression)
|
|
190
202
|
span.textContent = value ?? span.dataset.tessCall
|
|
191
|
-
span.title = value === null ? "" : span.dataset.tessCall
|
|
203
|
+
span.title = empty ? t("Empty for now: fill it in where it comes from") : value === null ? "" : span.dataset.tessCall
|
|
192
204
|
span.classList.toggle("tess-v-filled", value !== null)
|
|
205
|
+
span.classList.toggle("tess-v-empty", empty)
|
|
193
206
|
}
|
|
194
207
|
this.refresh()
|
|
195
208
|
}
|
|
@@ -228,8 +241,33 @@ export class Canvas {
|
|
|
228
241
|
return null
|
|
229
242
|
}
|
|
230
243
|
|
|
244
|
+
// A block's element. A Loop's blocks can show once per item, as a Table's
|
|
245
|
+
// rows do with a record's values (a host's canvas), each copy with the
|
|
246
|
+
// block's class: the copy clicked last is the one meant, and so are the
|
|
247
|
+
// blocks in it and around it, until another is clicked. The copy is kept
|
|
248
|
+
// by its place among them, as the canvas is written again.
|
|
231
249
|
elementOf(id) {
|
|
232
|
-
|
|
250
|
+
const anchor = this.anchorElement()
|
|
251
|
+
const near = anchor && (anchor.closest(`.tess-${id}`) || anchor.querySelector(`.tess-${id}, .tessph-${id}`))
|
|
252
|
+
return near || this.doc?.querySelector(`.tess-${id}`) || this.doc?.querySelector(`.tessph-${id}`)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Remembers the copy of a block that was clicked
|
|
256
|
+
anchorAt(hit) {
|
|
257
|
+
if (!hit || hit.placeholder) return
|
|
258
|
+
const copies = [...this.doc.querySelectorAll(`.tess-${hit.id}`)]
|
|
259
|
+
this.anchor = copies.length > 1 ? { id: hit.id, index: Math.max(0, copies.indexOf(hit.element)) } : null
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
anchorElement() {
|
|
263
|
+
if (!this.anchor || !this.doc) return null
|
|
264
|
+
return this.doc.querySelectorAll(`.tess-${this.anchor.id}`)[this.anchor.index] || null
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// The rectangle of the copy of a block an element is in, else its first
|
|
268
|
+
hoverRect(id) {
|
|
269
|
+
const element = this.hoverElement?.isConnected && this.hoverElement.closest(`.tess-${id}`)
|
|
270
|
+
return element ? element.getBoundingClientRect() : this.rectOf(id)
|
|
233
271
|
}
|
|
234
272
|
|
|
235
273
|
// The rectangle of a block in viewport coordinates of the iframe. Blocks
|
|
@@ -256,7 +294,7 @@ export class Canvas {
|
|
|
256
294
|
// Where an inline part is edited: the element its render marks with
|
|
257
295
|
// data-tess-edit-field, or for the richText shorthand the block's own
|
|
258
296
|
textContainer(id, key) {
|
|
259
|
-
const cell = this.
|
|
297
|
+
const cell = this.elementOf(id)
|
|
260
298
|
const part = this.partElement(cell, key)
|
|
261
299
|
if (part) return part
|
|
262
300
|
if (key !== getBlock(find(this.editor.doc, id)?.node.type)?.richText) return null
|
|
@@ -289,7 +327,7 @@ export class Canvas {
|
|
|
289
327
|
}
|
|
290
328
|
|
|
291
329
|
refresh() {
|
|
292
|
-
if (!this.overlay) return
|
|
330
|
+
if (!this.overlay || this.resizing) return
|
|
293
331
|
this.overlay.replaceChildren()
|
|
294
332
|
if (this.mode !== "edit") return
|
|
295
333
|
this.free.drawGuides(this.overlay)
|
|
@@ -297,7 +335,7 @@ export class Canvas {
|
|
|
297
335
|
|
|
298
336
|
if (this.hoverId && this.hoverId !== selectedId) {
|
|
299
337
|
const hit = find(this.editor.doc, this.hoverId)
|
|
300
|
-
const rect = hit && this.
|
|
338
|
+
const rect = hit && this.hoverRect(this.hoverId)
|
|
301
339
|
if (rect && hit.node !== this.editor.doc) {
|
|
302
340
|
const box = this.box(rect, "tess-hover")
|
|
303
341
|
box.append(Object.assign(this.doc.createElement("div"), { className: "tess-label", textContent: getBlock(hit.node.type)?.name || hit.node.type }))
|
|
@@ -307,6 +345,7 @@ export class Canvas {
|
|
|
307
345
|
|
|
308
346
|
const hit = selectedId && find(this.editor.doc, selectedId)
|
|
309
347
|
if (!hit || hit.node === this.editor.doc) return
|
|
348
|
+
this.drawTable(selectedId, editingId)
|
|
310
349
|
const rect = this.rectOf(selectedId)
|
|
311
350
|
if (!rect) return
|
|
312
351
|
const box = this.box(rect, editingId === selectedId ? "tess-selected tess-editing" : "tess-selected")
|
|
@@ -317,13 +356,16 @@ export class Canvas {
|
|
|
317
356
|
if (handle) box.append(handle)
|
|
318
357
|
|
|
319
358
|
if (editingId !== selectedId && !this.free.dragging) {
|
|
359
|
+
// In a table's cell (the cell, or its text): its rows and columns
|
|
360
|
+
const cell = free && cellOf(this.editor.doc, selectedId)
|
|
320
361
|
const tools = this.doc.createElement("div")
|
|
321
362
|
tools.className = "tess-tools"
|
|
322
363
|
tools.innerHTML = [
|
|
323
364
|
["parent", t("Select parent")],
|
|
365
|
+
...(cell ? [["table", t("Rows and columns")]] : []),
|
|
324
366
|
...(free ? [["drag", t("Drag to move")], ["duplicate", t("Duplicate")], ["delete", t("Delete")]] : [])
|
|
325
367
|
]
|
|
326
|
-
.map(([tool, title]) => `<span data-tool="${tool}" title="${title}" ${tool === "drag" ? 'draggable="true"' : ""}>${icon({ parent: "parent", drag: "move", duplicate: "copy", delete: "trash" }[tool], "tess-icon")}</span>`)
|
|
368
|
+
.map(([tool, title]) => `<span data-tool="${tool}" title="${title}" ${tool === "drag" ? 'draggable="true"' : ""}>${icon({ parent: "parent", drag: "move", duplicate: "copy", delete: "trash", table: TABLE_ICON }[tool], "tess-icon")}</span>`)
|
|
327
369
|
.join("")
|
|
328
370
|
tools.querySelectorAll("svg").forEach((svg) => svg.setAttribute("style", "width:14px;height:14px"))
|
|
329
371
|
tools.addEventListener("mousedown", (event) => event.stopPropagation())
|
|
@@ -332,6 +374,7 @@ export class Canvas {
|
|
|
332
374
|
event.preventDefault()
|
|
333
375
|
event.stopPropagation()
|
|
334
376
|
if (tool === "parent") this.editor.selectParent()
|
|
377
|
+
if (tool === "table") this.editor.openTableMenu(cell.id, this.toParentRect(event.target.closest("[data-tool]").getBoundingClientRect()))
|
|
335
378
|
if (tool === "duplicate") this.editor.duplicate(selectedId)
|
|
336
379
|
if (tool === "delete") this.editor.remove(selectedId)
|
|
337
380
|
})
|
|
@@ -362,6 +405,78 @@ export class Canvas {
|
|
|
362
405
|
this.overlay.append(box)
|
|
363
406
|
}
|
|
364
407
|
|
|
408
|
+
// The table the selection is in: a bracket at its side by each Loop's and
|
|
409
|
+
// Condition's rows, labelled as the block, which a click selects; and, when
|
|
410
|
+
// not editing text, a handle on each column's right border, dragged to set
|
|
411
|
+
// its width (in pt when it was in pt, else px)
|
|
412
|
+
drawTable(selectedId, editingId) {
|
|
413
|
+
const table = tableOf(this.editor.doc, selectedId)
|
|
414
|
+
// The table element itself, not a wrapper with its padding
|
|
415
|
+
const element = table && this.elementOf(table.id)
|
|
416
|
+
const inner = element && (element.tagName === "TABLE" ? element : element.querySelector("table"))
|
|
417
|
+
const tableRect = inner ? inner.getBoundingClientRect() : table && this.rectOf(table.id)
|
|
418
|
+
if (!tableRect) return
|
|
419
|
+
for (const { node, depth } of rowGroups(table)) {
|
|
420
|
+
const rect = this.rectOf(node.id)
|
|
421
|
+
if (!rect) continue
|
|
422
|
+
const bracket = this.box({ left: tableRect.left - 10 - depth * 10, top: rect.top, width: 6, height: rect.height }, "tess-bracket")
|
|
423
|
+
if (node.id === selectedId) bracket.classList.add("tess-on")
|
|
424
|
+
bracket.dataset.tessBracket = node.id
|
|
425
|
+
bracket.title = label(node)
|
|
426
|
+
bracket.append(Object.assign(this.doc.createElement("span"), { textContent: label(node) }))
|
|
427
|
+
bracket.addEventListener("mousedown", (event) => event.stopPropagation())
|
|
428
|
+
bracket.addEventListener("click", (event) => {
|
|
429
|
+
event.preventDefault()
|
|
430
|
+
event.stopPropagation()
|
|
431
|
+
this.editor.select(node.id, { reveal: true })
|
|
432
|
+
})
|
|
433
|
+
this.overlay.append(bracket)
|
|
434
|
+
}
|
|
435
|
+
if (editingId || !this.editor.isFree(table.id)) return
|
|
436
|
+
for (const handle of this.columnHandles(table, tableRect)) this.overlay.append(handle)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// A row of single cells shows where the columns are
|
|
440
|
+
columnHandles(table, tableRect) {
|
|
441
|
+
const count = columnCount(table)
|
|
442
|
+
const row = rows(table).find((candidate) => candidate.children.length === count && candidate.children.every((cell) => span(cell) === 1))
|
|
443
|
+
const cells = row ? [...(this.elementOf(row.id)?.children || [])].filter((element) => /^T[DH]$/.test(element.tagName)) : []
|
|
444
|
+
if (cells.length !== count) return []
|
|
445
|
+
return cells.map((cell, column) => {
|
|
446
|
+
const right = cell.getBoundingClientRect().right
|
|
447
|
+
const handle = this.box({ left: right, top: tableRect.top, width: 9, height: tableRect.height }, "tess-column")
|
|
448
|
+
handle.title = t("Drag to set the column's width")
|
|
449
|
+
handle.addEventListener("mousedown", (event) => this.resizeColumn(event, table, column, cell, handle))
|
|
450
|
+
return handle
|
|
451
|
+
})
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
resizeColumn(event, table, column, cell, handle) {
|
|
455
|
+
event.preventDefault()
|
|
456
|
+
event.stopPropagation()
|
|
457
|
+
const startX = event.clientX
|
|
458
|
+
const startLeft = parseFloat(handle.style.left)
|
|
459
|
+
const startWidth = cell.getBoundingClientRect().width
|
|
460
|
+
const inPt = /pt$/.test(table.data?.columns?.[column]?.width || "")
|
|
461
|
+
const width = (clientX) => Math.max(12, startWidth + clientX - startX)
|
|
462
|
+
this.resizing = true
|
|
463
|
+
handle.classList.add("tess-on")
|
|
464
|
+
const move = (moved) => (handle.style.left = `${startLeft + width(moved.clientX) - startWidth}px`)
|
|
465
|
+
const up = (released) => {
|
|
466
|
+
this.doc.removeEventListener("mousemove", move)
|
|
467
|
+
this.doc.removeEventListener("mouseup", up)
|
|
468
|
+
this.resizing = false
|
|
469
|
+
this.resized = true
|
|
470
|
+
setTimeout(() => (this.resized = false))
|
|
471
|
+
const px = width(released.clientX)
|
|
472
|
+
if (Math.abs(px - startWidth) < 1) return this.refresh()
|
|
473
|
+
const value = inPt ? `${Math.round(px * 0.75)}pt` : `${Math.round(px)}px`
|
|
474
|
+
this.editor.commit((doc) => setColumnAt(doc, table.id, column, "width", value))
|
|
475
|
+
}
|
|
476
|
+
this.doc.addEventListener("mousemove", move)
|
|
477
|
+
this.doc.addEventListener("mouseup", up)
|
|
478
|
+
}
|
|
479
|
+
|
|
365
480
|
setHover(id) {
|
|
366
481
|
if (this.hoverId === id) return
|
|
367
482
|
this.hoverId = id
|
|
@@ -377,8 +492,13 @@ export class Canvas {
|
|
|
377
492
|
// --- events ---------------------------------------------------------------
|
|
378
493
|
|
|
379
494
|
onMove(event) {
|
|
380
|
-
if (this.editor.drag || this.free.dragging) return
|
|
495
|
+
if (this.editor.drag || this.free.dragging || this.resizing) return
|
|
381
496
|
const hit = this.hit(event.target)
|
|
497
|
+
const element = hit && !hit.placeholder ? hit.element : null
|
|
498
|
+
if (element !== this.hoverElement) {
|
|
499
|
+
this.hoverElement = element
|
|
500
|
+
this.hoverId = null
|
|
501
|
+
}
|
|
382
502
|
this.setHover(hit && !hit.placeholder ? hit.id : null)
|
|
383
503
|
}
|
|
384
504
|
|
|
@@ -386,9 +506,11 @@ export class Canvas {
|
|
|
386
506
|
if (this.editor.editingId && event.target.closest?.(".ProseMirror, .tess-plain")) return
|
|
387
507
|
if (event.target.closest?.("#tess-overlay")) return
|
|
388
508
|
event.preventDefault()
|
|
509
|
+
if (this.resized) return
|
|
389
510
|
if (this.openLink(event)) return
|
|
390
511
|
if (this.free.swallowClick()) return
|
|
391
512
|
const hit = this.hit(event.target)
|
|
513
|
+
this.anchorAt(hit)
|
|
392
514
|
if (hit?.placeholder) {
|
|
393
515
|
const rect = this.toParentRect(hit.element.getBoundingClientRect())
|
|
394
516
|
this.editor.select(hit.id)
|
|
@@ -414,6 +536,7 @@ export class Canvas {
|
|
|
414
536
|
|
|
415
537
|
onDoubleClick(event) {
|
|
416
538
|
const hit = this.hit(event.target)
|
|
539
|
+
this.anchorAt(hit)
|
|
417
540
|
const part = hit && !hit.placeholder && this.partAt(event.target, hit.id)
|
|
418
541
|
if (part) this.editor.startEditing(hit.id, part)
|
|
419
542
|
}
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
import { t } from "tess_edit/core/i18n"
|
|
18
18
|
import { imageSource } from "tess_edit/core/media"
|
|
19
19
|
import { fieldType, getBlock, label } from "tess_edit/core/registry"
|
|
20
|
-
import { fontOptions } from "tess_edit/blocks/fields"
|
|
20
|
+
import { ALIGN, fontOptions } from "tess_edit/blocks/fields"
|
|
21
21
|
import { find, getValue } from "tess_edit/core/document"
|
|
22
22
|
import { translationCalls } from "tess_edit/core/translations"
|
|
23
23
|
import { loopScope } from "tess_edit/core/variables"
|
|
24
|
+
import { CELL, ROW, TABLE, addColumn, addRow, cellOf, columnCount, deleteColumn, deleteRow, position, rows, setColumn } from "tess_edit/core/table"
|
|
24
25
|
import { codeInput } from "tess_edit/ui/code_input"
|
|
25
26
|
import { FontPicker } from "tess_edit/ui/font_picker"
|
|
26
27
|
import { freeze, h, place } from "tess_edit/ui/dom"
|
|
@@ -105,6 +106,9 @@ export class Inspector {
|
|
|
105
106
|
|
|
106
107
|
// A group shows when one of its fields applies (see shows below)
|
|
107
108
|
const groups = (definition.fields || []).filter((group) => group.fields.some((field) => this.shows(node, field))).map((group) => this.group(node, group))
|
|
109
|
+
// A block in a table's cell, such as its Text, has the cell's table first
|
|
110
|
+
const cell = ![CELL, ROW, TABLE].includes(node.type) && cellOf(doc, node.id)
|
|
111
|
+
if (cell) groups.unshift(this.groupElement("table_cell:Table", { title: "Table" }, this.openGroups.get("table_cell:Table") ?? true, h("div", { class: "px-4 pb-4 space-y-3" }, this.table(cell))))
|
|
108
112
|
const locked = this.editor.lock && node.id !== doc.id && !this.editor.isFree(node.id)
|
|
109
113
|
? 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") }), t("Part of the layout"))
|
|
110
114
|
: null
|
|
@@ -283,6 +287,9 @@ export class Inspector {
|
|
|
283
287
|
case "list":
|
|
284
288
|
return this.list(node, field, Array.isArray(value) ? value : [], set)
|
|
285
289
|
|
|
290
|
+
case "table":
|
|
291
|
+
return this.table(node)
|
|
292
|
+
|
|
286
293
|
case "image":
|
|
287
294
|
return this.image(node, field, value, set)
|
|
288
295
|
|
|
@@ -534,6 +541,62 @@ export class Inspector {
|
|
|
534
541
|
return h("span", { class: "grid grid-cols-4 gap-1" }, inputs)
|
|
535
542
|
}
|
|
536
543
|
|
|
544
|
+
// A Cell's table (a Row's, through its first cell): the cell's column's
|
|
545
|
+
// width and alignment, and adding and deleting rows and columns
|
|
546
|
+
// (core/table.js), each one undo step, selecting the cell it gives
|
|
547
|
+
table(node) {
|
|
548
|
+
const cellId = node.type === CELL ? node.id : node.children?.find((child) => child.type === CELL)?.id
|
|
549
|
+
const at = cellId && position(this.editor.doc, cellId)
|
|
550
|
+
if (!at) return h("p", { class: "text-xs text-gray-500 dark:text-gray-400" }, t("Not in a table"))
|
|
551
|
+
|
|
552
|
+
const change = (mutate) => {
|
|
553
|
+
let next = null
|
|
554
|
+
this.editor.commit((doc) => (next = mutate(doc, cellId)))
|
|
555
|
+
if (next) this.editor.select(next.id)
|
|
556
|
+
}
|
|
557
|
+
const button = (label, mutate, disabled = false) =>
|
|
558
|
+
h("button", { type: "button", class: "flex-1 rounded-md border border-gray-300 dark:border-gray-600 px-2 py-1 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-40", disabled, onclick: () => change(mutate) }, t(label))
|
|
559
|
+
const line = (title, ...buttons) => h("div", { class: "space-y-1" }, h("span", { class: "block text-xs font-medium text-gray-700 dark:text-gray-300" }, t(title)), h("div", { class: "flex gap-1" }, ...buttons))
|
|
560
|
+
const rowCount = rows(at.table).length
|
|
561
|
+
const parts = [
|
|
562
|
+
line("Row", button("Add above", (doc, id) => addRow(doc, id, "above")), button("Add below", (doc, id) => addRow(doc, id, "below")), button("Delete", deleteRow, rowCount < 2))
|
|
563
|
+
]
|
|
564
|
+
if (node.type === CELL) {
|
|
565
|
+
const column = at.table.data?.columns?.[at.column] || {}
|
|
566
|
+
const setting = (key, value) => this.editor.commit((doc) => setColumn(doc, cellId, key, value), { coalesce: `${at.table.id}:column:${at.column}:${key}`, skipInspector: key === "width" })
|
|
567
|
+
parts.push(
|
|
568
|
+
line("Column", button("Add left", (doc, id) => addColumn(doc, id, "left")), button("Add right", (doc, id) => addColumn(doc, id, "right")), button("Delete", deleteColumn, columnCount(at.table) < 2)),
|
|
569
|
+
h(
|
|
570
|
+
"label",
|
|
571
|
+
{ class: "block" },
|
|
572
|
+
h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, t("Column width")),
|
|
573
|
+
h("input", { type: "text", class: INPUT, value: column.width || "", placeholder: t("Auto"), oninput: (event) => setting("width", event.target.value) })
|
|
574
|
+
),
|
|
575
|
+
h(
|
|
576
|
+
"div",
|
|
577
|
+
{ class: "block" },
|
|
578
|
+
h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, t("Column align")),
|
|
579
|
+
h(
|
|
580
|
+
"div",
|
|
581
|
+
{ class: "flex rounded-md border border-gray-300 dark:border-gray-600 overflow-hidden" },
|
|
582
|
+
ALIGN.map((option) =>
|
|
583
|
+
h(
|
|
584
|
+
"button",
|
|
585
|
+
{
|
|
586
|
+
type: "button",
|
|
587
|
+
class: `flex-1 px-2 py-1 text-xs border-l first:border-l-0 border-gray-300 dark:border-gray-600 ${column.align === 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"}`,
|
|
588
|
+
onclick: () => setting("align", column.align === option.value ? "" : option.value)
|
|
589
|
+
},
|
|
590
|
+
t(option.label)
|
|
591
|
+
)
|
|
592
|
+
)
|
|
593
|
+
)
|
|
594
|
+
)
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
return h("div", { class: "space-y-3" }, ...parts)
|
|
598
|
+
}
|
|
599
|
+
|
|
537
600
|
list(node, field, items, set) {
|
|
538
601
|
const update = (next) => {
|
|
539
602
|
set(next, { coalesce: false })
|
|
@@ -364,9 +364,11 @@ function valueDecorations(state, editing) {
|
|
|
364
364
|
const text = node.textBetween(0, node.content.size, undefined, "\ufffc")
|
|
365
365
|
for (const call of valueCalls(text)) {
|
|
366
366
|
const value = values.value(call.expression)
|
|
367
|
-
if (value === null) continue
|
|
368
367
|
const start = pos + 1 + call.start
|
|
369
368
|
const end = pos + 1 + call.end
|
|
369
|
+
// Empty for now: its Liquid, in red
|
|
370
|
+
if (value === null && values.empty(call.expression)) decorations.push(Decoration.inline(start, end, { class: "tess-v-empty" }))
|
|
371
|
+
if (value === null) continue
|
|
370
372
|
if (from < end && to > start) {
|
|
371
373
|
decorations.push(Decoration.inline(start, end, { class: "tess-v-raw" }))
|
|
372
374
|
} else {
|
data/config/locales/en.yml
CHANGED
|
@@ -4,41 +4,60 @@
|
|
|
4
4
|
en:
|
|
5
5
|
tess_edit:
|
|
6
6
|
editor:
|
|
7
|
+
0_for_no_borders: "0 for no borders."
|
|
7
8
|
1_column: "1 column"
|
|
8
9
|
2_columns: "2 columns"
|
|
9
10
|
3_columns: "3 columns"
|
|
10
11
|
4_columns: "4 columns"
|
|
12
|
+
a_background_for_every_other_row_from_the_second: "A background for every other row, from the second."
|
|
13
|
+
a_heavier_line_above_the_row_e_g_3pt_above_a_total: "A heavier line above the row, e.g. 3pt above a total."
|
|
11
14
|
a_key_is_made_of_letters_digits_and_separated_by_dots_e_g_or: "A key is made of letters, digits, _ and -, separated by dots, e.g. .order.thanks"
|
|
12
15
|
a_key_starting_with_a_dot_belongs_to_this_template: "A key starting with a dot belongs to this template."
|
|
13
16
|
a_liquid_condition_e_g_order_total_100: "A Liquid condition, e.g. order.total > 100."
|
|
17
|
+
a_liquid_expression_with_filters_e_g_order_lines_where_kind: "A Liquid expression, with filters, e.g. order.lines | where: \"kind\", \"product\"."
|
|
14
18
|
action_failed_status: "%{action} failed (%{status})"
|
|
15
19
|
add: "Add"
|
|
16
20
|
add_a_block_below: "Add a block below"
|
|
17
21
|
add_a_block_inside: "Add a block inside"
|
|
22
|
+
add_above: "Add above"
|
|
23
|
+
add_below: "Add below"
|
|
18
24
|
add_block: "Add block"
|
|
25
|
+
add_column_left: "Add column left"
|
|
26
|
+
add_column_right: "Add column right"
|
|
27
|
+
add_left: "Add left"
|
|
19
28
|
add_link: "Add link"
|
|
29
|
+
add_right: "Add right"
|
|
30
|
+
add_row_above: "Add row above"
|
|
31
|
+
add_row_below: "Add row below"
|
|
20
32
|
added_to_the_email_s_style_block: "Added to the email's <style> block."
|
|
21
33
|
align: "Align"
|
|
22
34
|
align_center: "Align center"
|
|
23
35
|
align_left: "Align left"
|
|
24
36
|
align_right: "Align right"
|
|
37
|
+
all: "All"
|
|
25
38
|
all_panels_on_the_left: "All panels on the left"
|
|
26
39
|
all_panels_on_the_right: "All panels on the right"
|
|
27
40
|
alt_text: "Alt text"
|
|
41
|
+
assign: "Assign"
|
|
28
42
|
auto: "Auto"
|
|
29
43
|
background: "Background"
|
|
30
44
|
background_image: "Background image"
|
|
31
45
|
below_this_width_columns_stack: "Below this width columns stack."
|
|
46
|
+
between_rows: "Between rows"
|
|
32
47
|
blocks: "Blocks"
|
|
33
48
|
blocks_on_the_left_inspect_on_the_right: "Blocks on the left, Inspect on the right"
|
|
34
49
|
bold_b: "Bold (⌘B)"
|
|
35
50
|
border: "Border"
|
|
51
|
+
border_color: "Border color"
|
|
52
|
+
border_width: "Border width"
|
|
36
53
|
bottom: "Bottom"
|
|
37
54
|
breakpoint: "Breakpoint"
|
|
38
55
|
bulleted_list: "Bulleted list"
|
|
39
56
|
button: "Button"
|
|
40
57
|
button_color: "Button color"
|
|
41
58
|
cancel: "Cancel"
|
|
59
|
+
cell: "Cell"
|
|
60
|
+
cell_padding: "Cell padding"
|
|
42
61
|
center: "Center"
|
|
43
62
|
center_center: "center center"
|
|
44
63
|
choose_an_image: "Choose an image"
|
|
@@ -49,7 +68,9 @@ en:
|
|
|
49
68
|
collection: "Collection"
|
|
50
69
|
color: "Color"
|
|
51
70
|
column: "Column"
|
|
71
|
+
column_align: "Column align"
|
|
52
72
|
column_order: "Column order"
|
|
73
|
+
column_width: "Column width"
|
|
53
74
|
condition: "Condition"
|
|
54
75
|
content: "Content"
|
|
55
76
|
copied: "Copied."
|
|
@@ -60,6 +81,8 @@ en:
|
|
|
60
81
|
dashed: "Dashed"
|
|
61
82
|
default: "Default"
|
|
62
83
|
delete: "Delete"
|
|
84
|
+
delete_column: "Delete column"
|
|
85
|
+
delete_row: "Delete row"
|
|
63
86
|
desktop: "Desktop"
|
|
64
87
|
divider: "Divider"
|
|
65
88
|
done: "Done"
|
|
@@ -70,7 +93,10 @@ en:
|
|
|
70
93
|
drag_onto_the_canvas_or_click_to_add: "Drag onto the canvas, or click to add"
|
|
71
94
|
drag_to_move: "Drag to move"
|
|
72
95
|
drag_to_resize: "Drag to resize"
|
|
96
|
+
drag_to_set_the_column_s_width: "Drag to set the column's width"
|
|
97
|
+
drop_a_cell_here: "Drop a cell here"
|
|
73
98
|
drop_a_column_here: "Drop a column here"
|
|
99
|
+
drop_a_row_here: "Drop a row here"
|
|
74
100
|
drop_a_section_here: "Drop a section here"
|
|
75
101
|
drop_content_here: "Drop content here"
|
|
76
102
|
duplicate: "Duplicate"
|
|
@@ -82,6 +108,8 @@ en:
|
|
|
82
108
|
editing_text_key_to_finish: "Editing text · %{key} to finish"
|
|
83
109
|
email: "Email"
|
|
84
110
|
empty: "(empty)"
|
|
111
|
+
empty_for_now_fill_it_in_where_it_comes_from: "Empty for now: fill it in where it comes from"
|
|
112
|
+
every_other_row: "Every other row"
|
|
85
113
|
expand: "Expand"
|
|
86
114
|
find_in_source: "Find in %{source}"
|
|
87
115
|
fixed_height: "Fixed height"
|
|
@@ -95,10 +123,13 @@ en:
|
|
|
95
123
|
hamburger_on_mobile: "Hamburger on mobile"
|
|
96
124
|
heading: "Heading"
|
|
97
125
|
heading_level: "Heading %{level}"
|
|
126
|
+
heading_row: "Heading row"
|
|
127
|
+
heading_rows: "Heading rows"
|
|
98
128
|
height: "Height"
|
|
99
129
|
hero: "Hero"
|
|
100
130
|
hide_panels: "Hide panels"
|
|
101
131
|
horizontal: "Horizontal"
|
|
132
|
+
how_many_columns_the_cell_takes_merging_it_with_the_cells_to: "How many columns the cell takes, merging it with the cells to its right."
|
|
102
133
|
html: "HTML"
|
|
103
134
|
icon_padding: "Icon padding"
|
|
104
135
|
icon_size: "Icon size"
|
|
@@ -106,10 +137,12 @@ en:
|
|
|
106
137
|
image_height: "Image height"
|
|
107
138
|
image_width: "Image width"
|
|
108
139
|
in_px_or_e_g_50: "In px or %, e.g. 50%."
|
|
140
|
+
in_the_heading_rows_style_heading_rows_at_the_top_repeat_on: "In the heading rows' style. Heading rows at the top repeat on every page."
|
|
109
141
|
inherit: "Inherit"
|
|
110
142
|
inner_padding: "Inner padding"
|
|
111
143
|
insert_a_variable: "Insert a variable"
|
|
112
144
|
inspect: "Inspect"
|
|
145
|
+
instead_of_the_table_s_cell_padding: "Instead of the table's cell padding."
|
|
113
146
|
italic_i: "Italic (⌘I)"
|
|
114
147
|
key: "Key"
|
|
115
148
|
key_already_says_current_in_locale: "%{key} already says “%{current}” in %{locale}."
|
|
@@ -121,7 +154,10 @@ en:
|
|
|
121
154
|
left: "Left"
|
|
122
155
|
left_to_right: "Left to right"
|
|
123
156
|
letter_spacing: "Letter spacing"
|
|
157
|
+
line_above: "Line above"
|
|
124
158
|
line_height: "Line height"
|
|
159
|
+
lines: "Lines"
|
|
160
|
+
lines_around_every_cell_or_only_under_each_row: "Lines around every cell, or only under each row."
|
|
125
161
|
link: "Link"
|
|
126
162
|
links: "Links"
|
|
127
163
|
liquid: "Liquid"
|
|
@@ -157,6 +193,7 @@ en:
|
|
|
157
193
|
no_images_yet: "No images yet"
|
|
158
194
|
no_languages_yet: "No languages yet"
|
|
159
195
|
no_variables_here: "No variables here"
|
|
196
|
+
not_in_a_table: "Not in a table"
|
|
160
197
|
nothing_matches: "Nothing matches."
|
|
161
198
|
numbered_list: "Numbered list"
|
|
162
199
|
off_word: "Off"
|
|
@@ -176,10 +213,14 @@ en:
|
|
|
176
213
|
redo_z: "Redo (⇧⌘Z)"
|
|
177
214
|
remove: "Remove"
|
|
178
215
|
remove_link: "Remove link"
|
|
216
|
+
repeat_the_row_in_a_loop: "Repeat the row in a Loop"
|
|
179
217
|
repeats_its_blocks_for_each_item_for_variable_in_collection: "Repeats its blocks for each item: {% for variable in collection %}."
|
|
180
218
|
replace: "Replace"
|
|
181
219
|
right: "Right"
|
|
182
220
|
right_to_left: "Right to left"
|
|
221
|
+
row: "Row"
|
|
222
|
+
rows_and_columns: "Rows and columns"
|
|
223
|
+
rows_of_cells_select_a_cell_to_add_rows_and_columns_put_rows: "Rows of cells. Select a cell to add rows and columns. Put rows in a Loop to repeat them for each item."
|
|
183
224
|
same_tab: "Same tab"
|
|
184
225
|
save: "Save"
|
|
185
226
|
saving_the_translation_failed_status: "Saving the translation failed (%{status})"
|
|
@@ -187,7 +228,9 @@ en:
|
|
|
187
228
|
section: "Section"
|
|
188
229
|
select_parent: "Select parent"
|
|
189
230
|
select_the_text_to_translate_first: "Select the text to translate first."
|
|
231
|
+
sets_a_liquid_variable_for_the_blocks_after_it_assign_variab: "Sets a Liquid variable for the blocks after it: {% assign variable = value %}."
|
|
190
232
|
show_panels: "Show panels"
|
|
233
|
+
show_the_row_in_a_condition: "Show the row in a Condition"
|
|
191
234
|
show_translations_in: "Show translations in"
|
|
192
235
|
show_when: "Show when"
|
|
193
236
|
shown_after_the_subject_in_most_inboxes: "Shown after the subject in most inboxes."
|
|
@@ -195,9 +238,11 @@ en:
|
|
|
195
238
|
social: "Social"
|
|
196
239
|
solid: "Solid"
|
|
197
240
|
spacer: "Spacer"
|
|
241
|
+
spans_columns: "Spans columns"
|
|
198
242
|
strikethrough: "Strikethrough"
|
|
199
243
|
style: "Style"
|
|
200
244
|
subject: "Subject"
|
|
245
|
+
table: "Table"
|
|
201
246
|
text: "Text"
|
|
202
247
|
text_color: "Text color"
|
|
203
248
|
the_content_of_the_documents_using_this_layout_goes_here_wha: "The content of the documents using this layout goes here. What you put inside is example content for designing the layout."
|
|
@@ -206,6 +251,7 @@ en:
|
|
|
206
251
|
the_email_could_not_be_compiled: "The email could not be compiled"
|
|
207
252
|
the_name_could_not_be_rendered: "The %{name} could not be rendered"
|
|
208
253
|
the_name_each_item_gets_e_g_line: "The name each item gets, e.g. line."
|
|
254
|
+
the_name_the_blocks_after_it_use_e_g_lines: "The name the blocks after it use, e.g. lines."
|
|
209
255
|
the_upload: "The upload"
|
|
210
256
|
theme: "Theme"
|
|
211
257
|
there_are_no_languages_to_translate_into_yet: "There are no languages to translate into yet."
|
|
@@ -224,6 +270,7 @@ en:
|
|
|
224
270
|
uploaded: "Uploaded"
|
|
225
271
|
uploading: "Uploading…"
|
|
226
272
|
url: "URL"
|
|
273
|
+
value: "Value"
|
|
227
274
|
variable: "Variable"
|
|
228
275
|
variables: "Variables"
|
|
229
276
|
vertical: "Vertical"
|