tess_edit 0.5.10 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f6042f88897f04e6d501d19ca8401a2ea70148a4414538a496b8162f328d49f
4
- data.tar.gz: cb820e8b65766ec830db06e612fa9bb5bbf686f95319bfe0c7e5a9bcf6b2437f
3
+ metadata.gz: ca98a5df42d18e55649fb75c9e3df79e3b4625f76114f362872ed8340bfdee37
4
+ data.tar.gz: 25023d749d04c4ddd1e508131354632bcfa5165d9ca0a2166929a9a408ea9728
5
5
  SHA512:
6
- metadata.gz: 2319bc7fb805278335b0a2cdfb7746b90ad69fef7cb61f339b4363655b5c7a9ed5e8dc7ba23460f53ad6ab55f6cede811b1b40e3096f8cf3d9f110cc2338af35
7
- data.tar.gz: be46f4863517eba03f9b28387ed0799ffd30b3f6909fd727cdf3d7322930a08dafc7fae3c091f21a979621e1c5233bcea787c2791b4f51954103077366c04d89
6
+ metadata.gz: 618cd69b5a1c90e4ca7d8d17882f8e73148eb753d2d3e6bce78e6418f3ff9ec0b4037280f1150bec51a3a16e0f174fa1133221ec06cd7603fe677e7618144baf
7
+ data.tar.gz: '0028d406120c409203369393781af3eef1e9863f13b46c43a36168850b9a145b11af3d1e81cb83a2462e2a0a2229d4b4c8d77773572d6c6ff9d365a8cad99e07'
data/README.md CHANGED
@@ -15,13 +15,14 @@ It completes Liquid tags and variables as you type, making it easier to work wit
15
15
 
16
16
  - Blocks: Section (1-4 columns), Column, Wrapper, Hero, Text, Heading, Image, Button, Divider, Spacer, Social, Navbar and raw HTML.
17
17
  - Liquid blocks: **Loop** (`{% for line in order.lines %}`) and **Condition** (`{% if order.total > 100 %}`) wrap other blocks.
18
+ - **Tables**: Table, Row and Cell blocks, a cell holding any blocks, with Loops and Conditions (and Assigns) between the rows. On the canvas a cell's menu adds and deletes rows and columns and puts its row in a Loop or Condition, a column's border is dragged to set its width, Tab goes from cell to cell (adding a row after the last), and a bracket by a Loop's or Condition's rows shows what they are.
18
19
  - Drag from the Blocks panel onto the canvas or into the Layers tree; move blocks on the canvas (drag handle) or in the tree; plus buttons and empty-column placeholders open an "Add block" menu.
19
20
  - Rich text editing on the canvas with [Tiptap](https://tiptap.dev): bold, italic, underline, strikethrough, colour, links (Liquid allowed in the URL), alignment, lists and headings. A block can have several texts edited on the canvas, rich or a plain line, such as a question's label and its description.
20
21
  - Your app's Liquid variables suggested while typing `{{`, in text and in settings, and browsable from `{ }` buttons, including those of the Loop blocks around a block.
21
22
  - Your app's translations for Liquid's `t` filter (`{{ '.greeting' | t }}`) shown as their text in a language of your choice, with every language's text, missing ones marked, editable when pointed at, and selected text made translatable.
22
23
  - Your app's values for the Liquid in a document (`{{ customer.first_name }}` as "Ada"), shown in its place until the caret goes into it.
23
24
  - Clicking a tile in the Blocks panel adds the block in or after the selection, or else at the end of the last block it fits in.
24
- - Undo/redo, duplicate, delete, keyboard shortcuts (⌘Z, ⇧⌘Z, ⌘D, Delete, Enter to edit text, Esc).
25
+ - Undo/redo, duplicate, delete, keyboard shortcuts (⌘Z, ⇧⌘Z, ⌘D, Delete, Enter to edit text, Tab to the next table cell, Esc).
25
26
  - Desktop and mobile preview, and a preview of the HTML as sent.
26
27
  - Panels on both sides, or combined as tabs in one sidebar on the left or right to give the canvas more room.
27
28
  - Dark mode that follows the host app's.
@@ -62,6 +62,7 @@ import { IMAGE_FIELD, fetchMedia, uploadMedia } from "tess_edit/core/media"
62
62
  import { Translations, keysIn, suggestKey, toTranslation, translationTag } from "tess_edit/core/translations"
63
63
  import { Values } from "tess_edit/core/values"
64
64
  import { Variables, loopScope } from "tess_edit/core/variables"
65
+ import { addColumn, addRow, cellOf, columnCount, deleteColumn, deleteRow, nextCell, position, rows, wrapRow } from "tess_edit/core/table"
65
66
  import { Canvas } from "tess_edit/ui/canvas"
66
67
  import { freeChild, number } from "tess_edit/ui/free_layout"
67
68
  import { Tree } from "tess_edit/ui/tree"
@@ -995,9 +996,43 @@ export default class extends Controller {
995
996
  }
996
997
 
997
998
  openInsertMenu(parentId, index, rect) {
998
- const anchor = `${parentId}:${index}`
999
- // A second click on the same plus button or placeholder closes the menu.
1000
- // Its mousedown already closed it as an outside click, so check for that.
999
+ const allowed = this.accepted(parentId)
1000
+ const items = this.paletteItems().filter((item) => allowed.includes(item.type))
1001
+ if (!items.length) return this.closeMenu()
1002
+ this.showMenu(`${parentId}:${index}`, "insert", t("Add block"), rect,
1003
+ items.map((item) => ({ label: t(item.label), icon: icon(item.icon), action: () => this.insertAt(item.key, parentId, index) })))
1004
+ }
1005
+
1006
+ // A cell's rows and columns (core/table.js), as on the Cell in Inspect, and
1007
+ // wrapping its row in a Loop or Condition, selected to fill in
1008
+ openTableMenu(cellId, rect) {
1009
+ const at = position(this.doc, cellId)
1010
+ if (!at) return
1011
+ const rowParent = find(this.doc, at.row.id)?.parent
1012
+ const change = (mutate) => () => {
1013
+ let next = null
1014
+ this.commit((doc) => (next = mutate(doc, cellId)))
1015
+ if (next) this.select(next.id)
1016
+ }
1017
+ const entries = [
1018
+ { label: t("Add row above"), action: change((doc, id) => addRow(doc, id, "above")) },
1019
+ { label: t("Add row below"), action: change((doc, id) => addRow(doc, id, "below")) },
1020
+ { label: t("Add column left"), action: change((doc, id) => addColumn(doc, id, "left")) },
1021
+ { label: t("Add column right"), action: change((doc, id) => addColumn(doc, id, "right")) },
1022
+ { label: t("Delete row"), disabled: rows(at.table).length < 2, action: change(deleteRow) },
1023
+ { label: t("Delete column"), disabled: columnCount(at.table) < 2, action: change(deleteColumn) }
1024
+ ]
1025
+ for (const type of ["loop", "condition"]) {
1026
+ if (!rowParent || !this.allows(type) || !this.accepted(rowParent.id).includes(type)) continue
1027
+ entries.push({ label: t(type === "loop" ? "Repeat the row in a Loop" : "Show the row in a Condition"), icon: icon(type), separator: entries.every((entry) => !entry.separator), action: change((doc, id) => wrapRow(doc, id, type)) })
1028
+ }
1029
+ this.showMenu(`table:${cellId}`, "table", t("Rows and columns"), rect, entries)
1030
+ }
1031
+
1032
+ // A menu below (or above) `rect`, in the page's coordinates; a second click
1033
+ // on what opened it (`anchor`) closes it. Its mousedown already closed it
1034
+ // as an outside click, so that's checked too.
1035
+ showMenu(anchor, kind, title, rect, entries) {
1001
1036
  const closed = this.menuClosed
1002
1037
  if (this.menu?.dataset.anchor === anchor || (closed?.anchor === anchor && Date.now() - closed.at < 500)) {
1003
1038
  this.closeMenu()
@@ -1005,29 +1040,28 @@ export default class extends Controller {
1005
1040
  return
1006
1041
  }
1007
1042
  this.closeMenu()
1008
- const allowed = this.accepted(parentId)
1009
- const items = this.paletteItems().filter((item) => allowed.includes(item.type))
1010
- if (!items.length) return
1011
1043
  this.menu = h(
1012
1044
  "div",
1013
- { class: "fixed z-50 w-56 max-h-80 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-1 shadow-lg", role: "menu", "data-anchor": anchor, "data-tess-edit-menu": "insert" },
1014
- h("div", { class: "px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, t("Add block")),
1015
- items.map((item) =>
1045
+ { class: "fixed z-50 w-56 max-h-80 overflow-y-auto rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-1 shadow-lg", role: "menu", "data-anchor": anchor, "data-tess-edit-menu": kind },
1046
+ h("div", { class: "px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, title),
1047
+ entries.flatMap((entry) => [
1048
+ ...(entry.separator ? [h("div", { class: "my-1 border-t border-gray-200 dark:border-gray-700" })] : []),
1016
1049
  h(
1017
1050
  "button",
1018
1051
  {
1019
1052
  type: "button",
1020
1053
  role: "menuitem",
1021
- class: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-gray-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:text-blue-700 dark:hover:text-blue-300",
1054
+ disabled: !!entry.disabled,
1055
+ class: "flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-gray-700 dark:text-gray-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:text-blue-700 dark:hover:text-blue-300 disabled:opacity-40 disabled:pointer-events-none",
1022
1056
  onclick: () => {
1023
1057
  this.closeMenu()
1024
- this.insertAt(item.key, parentId, index)
1058
+ entry.action()
1025
1059
  }
1026
1060
  },
1027
- h("span", { class: "text-gray-400 dark:text-gray-500", html: icon(item.icon) }),
1028
- t(item.label)
1061
+ ...(entry.icon ? [h("span", { class: "text-gray-400 dark:text-gray-500", html: entry.icon })] : []),
1062
+ entry.label
1029
1063
  )
1030
- )
1064
+ ])
1031
1065
  )
1032
1066
  document.body.append(this.menu)
1033
1067
  const width = 224
@@ -1062,6 +1096,13 @@ export default class extends Controller {
1062
1096
  this.closeMenu()
1063
1097
  return
1064
1098
  }
1099
+ // Tab to the next cell of a table (Shift+Tab to the one before), from the
1100
+ // text being edited in one or the block selected in one; unless the
1101
+ // variable menu took it
1102
+ if (event.key === "Tab" && !mod && !event.altKey && !event.defaultPrevented && (this.editingId || !typing) && this.tabToCell(event.shiftKey)) {
1103
+ event.preventDefault()
1104
+ return
1105
+ }
1065
1106
  if (this.editingId) {
1066
1107
  if (event.key === "Escape") {
1067
1108
  event.preventDefault()
@@ -1096,6 +1137,39 @@ export default class extends Controller {
1096
1137
  }
1097
1138
  }
1098
1139
 
1140
+ // Edits the next cell's first text, or selects the cell when it has none;
1141
+ // from the last cell it adds a row and goes to its first, once the canvas
1142
+ // has it. False when the block isn't in a table's cell, or there's no cell
1143
+ // before the first
1144
+ tabToCell(backwards) {
1145
+ const id = this.editingId || this.selectedId
1146
+ const cell = id && cellOf(this.doc, id)
1147
+ if (!cell) return false
1148
+ let next = nextCell(this.doc, cell.id, { backwards })
1149
+ const added = !next && !backwards
1150
+ if (added) {
1151
+ this.stopEditing()
1152
+ this.commit((doc) => addRow(doc, cell.id, "below") && (next = nextCell(doc, cell.id)))
1153
+ }
1154
+ if (!next) return false
1155
+ let text = null
1156
+ walk(next, (node) => {
1157
+ if (text) return false
1158
+ const part = node !== next && inlineParts(node.type)[0]
1159
+ if (part && this.canEditField(node.id, part.key)) text = node
1160
+ })
1161
+ if (!text) {
1162
+ this.select(next.id)
1163
+ } else if (added) {
1164
+ this.select(text.id)
1165
+ this.scheduleCanvas.cancel()
1166
+ this.renderCanvas().then(() => this.selectedId === text.id && this.startEditing(text.id))
1167
+ } else {
1168
+ this.startEditing(text.id)
1169
+ }
1170
+ return true
1171
+ }
1172
+
1099
1173
  // --- code dialog ----------------------------------------------------------------
1100
1174
 
1101
1175
  async openCodeDialog(tab = "json") {
@@ -223,6 +223,40 @@ export function hasTable(doc) {
223
223
  export function setColumn(doc, cellId, key, value) {
224
224
  const at = position(doc, cellId)
225
225
  if (!at) return
226
- const list = columns(at.table)
227
- list[at.column] = { ...list[at.column], [key]: value }
226
+ setColumnAt(doc, at.table.id, at.column, key, value)
227
+ }
228
+
229
+ // Sets the width or align of a table's column by its index, as dragging its
230
+ // border on the canvas does
231
+ export function setColumnAt(doc, tableId, column, key, value) {
232
+ const table = find(doc, tableId)?.node
233
+ if (table?.type !== TABLE) return
234
+ const list = columns(table)
235
+ if (column < 0 || column >= list.length) return
236
+ list[column] = { ...list[column], [key]: value }
237
+ }
238
+
239
+ // Wraps the cell's row in a new Loop or Condition (`type`), in the row's
240
+ // place; returns it
241
+ export function wrapRow(doc, cellId, type) {
242
+ const at = position(doc, cellId)
243
+ if (!at) return null
244
+ const hit = find(doc, at.row.id)
245
+ remove(doc, at.row.id)
246
+ return insert(doc, hit.parent.id, hit.index, createNode(type, { children: [at.row] }))
247
+ }
248
+
249
+ // The Loops and Conditions among a table's rows, each with the rows it holds,
250
+ // for the canvas to mark them: [{ node, depth }], outer ones first
251
+ export function rowGroups(table) {
252
+ const found = []
253
+ const visit = (node, depth) => {
254
+ for (const child of node.children || []) {
255
+ if (child.type === ROW || child.type === TABLE || child.type === CELL) continue
256
+ if (rows(child).length) found.push({ node: child, depth })
257
+ visit(child, depth + 1)
258
+ }
259
+ }
260
+ visit(table, 0)
261
+ return found
228
262
  }
@@ -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}
@@ -59,6 +66,7 @@ function isFileDrag(event, editor) {
59
66
  return !editor.drag && Array.from(event.dataTransfer?.types || []).includes("Files")
60
67
  }
61
68
 
69
+ const TABLE_ICON = '<rect x="3" y="5" width="18" height="14" rx="1"/><path d="M3 10h18M3 15h18M9 10v9M15 10v9"/>'
62
70
  const CLASS = /\btess-(b[a-z0-9]+)\b/
63
71
  const PLACEHOLDER = /\btessph-(b[a-z0-9]+)\b/
64
72
 
@@ -81,6 +89,8 @@ export class Canvas {
81
89
 
82
90
  // Replaces the iframe's content, keeping the scroll position.
83
91
  write(html, mode) {
92
+ // A column being dragged is let go: its listeners were the old document's
93
+ this.resizing = false
84
94
  const scrollY = this.win?.scrollY || 0
85
95
  this.mode = mode
86
96
  const doc = this.doc
@@ -317,7 +327,7 @@ export class Canvas {
317
327
  }
318
328
 
319
329
  refresh() {
320
- if (!this.overlay) return
330
+ if (!this.overlay || this.resizing) return
321
331
  this.overlay.replaceChildren()
322
332
  if (this.mode !== "edit") return
323
333
  this.free.drawGuides(this.overlay)
@@ -335,6 +345,7 @@ export class Canvas {
335
345
 
336
346
  const hit = selectedId && find(this.editor.doc, selectedId)
337
347
  if (!hit || hit.node === this.editor.doc) return
348
+ this.drawTable(selectedId, editingId)
338
349
  const rect = this.rectOf(selectedId)
339
350
  if (!rect) return
340
351
  const box = this.box(rect, editingId === selectedId ? "tess-selected tess-editing" : "tess-selected")
@@ -345,13 +356,16 @@ export class Canvas {
345
356
  if (handle) box.append(handle)
346
357
 
347
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)
348
361
  const tools = this.doc.createElement("div")
349
362
  tools.className = "tess-tools"
350
363
  tools.innerHTML = [
351
364
  ["parent", t("Select parent")],
365
+ ...(cell ? [["table", t("Rows and columns")]] : []),
352
366
  ...(free ? [["drag", t("Drag to move")], ["duplicate", t("Duplicate")], ["delete", t("Delete")]] : [])
353
367
  ]
354
- .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>`)
355
369
  .join("")
356
370
  tools.querySelectorAll("svg").forEach((svg) => svg.setAttribute("style", "width:14px;height:14px"))
357
371
  tools.addEventListener("mousedown", (event) => event.stopPropagation())
@@ -360,6 +374,7 @@ export class Canvas {
360
374
  event.preventDefault()
361
375
  event.stopPropagation()
362
376
  if (tool === "parent") this.editor.selectParent()
377
+ if (tool === "table") this.editor.openTableMenu(cell.id, this.toParentRect(event.target.closest("[data-tool]").getBoundingClientRect()))
363
378
  if (tool === "duplicate") this.editor.duplicate(selectedId)
364
379
  if (tool === "delete") this.editor.remove(selectedId)
365
380
  })
@@ -390,6 +405,78 @@ export class Canvas {
390
405
  this.overlay.append(box)
391
406
  }
392
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
+
393
480
  setHover(id) {
394
481
  if (this.hoverId === id) return
395
482
  this.hoverId = id
@@ -405,7 +492,7 @@ export class Canvas {
405
492
  // --- events ---------------------------------------------------------------
406
493
 
407
494
  onMove(event) {
408
- if (this.editor.drag || this.free.dragging) return
495
+ if (this.editor.drag || this.free.dragging || this.resizing) return
409
496
  const hit = this.hit(event.target)
410
497
  const element = hit && !hit.placeholder ? hit.element : null
411
498
  if (element !== this.hoverElement) {
@@ -419,6 +506,7 @@ export class Canvas {
419
506
  if (this.editor.editingId && event.target.closest?.(".ProseMirror, .tess-plain")) return
420
507
  if (event.target.closest?.("#tess-overlay")) return
421
508
  event.preventDefault()
509
+ if (this.resized) return
422
510
  if (this.openLink(event)) return
423
511
  if (this.free.swallowClick()) return
424
512
  const hit = this.hit(event.target)
@@ -22,9 +22,13 @@ en:
22
22
  add_above: "Add above"
23
23
  add_below: "Add below"
24
24
  add_block: "Add block"
25
+ add_column_left: "Add column left"
26
+ add_column_right: "Add column right"
25
27
  add_left: "Add left"
26
28
  add_link: "Add link"
27
29
  add_right: "Add right"
30
+ add_row_above: "Add row above"
31
+ add_row_below: "Add row below"
28
32
  added_to_the_email_s_style_block: "Added to the email's <style> block."
29
33
  align: "Align"
30
34
  align_center: "Align center"
@@ -77,6 +81,8 @@ en:
77
81
  dashed: "Dashed"
78
82
  default: "Default"
79
83
  delete: "Delete"
84
+ delete_column: "Delete column"
85
+ delete_row: "Delete row"
80
86
  desktop: "Desktop"
81
87
  divider: "Divider"
82
88
  done: "Done"
@@ -87,6 +93,7 @@ en:
87
93
  drag_onto_the_canvas_or_click_to_add: "Drag onto the canvas, or click to add"
88
94
  drag_to_move: "Drag to move"
89
95
  drag_to_resize: "Drag to resize"
96
+ drag_to_set_the_column_s_width: "Drag to set the column's width"
90
97
  drop_a_cell_here: "Drop a cell here"
91
98
  drop_a_column_here: "Drop a column here"
92
99
  drop_a_row_here: "Drop a row here"
@@ -206,11 +213,13 @@ en:
206
213
  redo_z: "Redo (⇧⌘Z)"
207
214
  remove: "Remove"
208
215
  remove_link: "Remove link"
216
+ repeat_the_row_in_a_loop: "Repeat the row in a Loop"
209
217
  repeats_its_blocks_for_each_item_for_variable_in_collection: "Repeats its blocks for each item: {% for variable in collection %}."
210
218
  replace: "Replace"
211
219
  right: "Right"
212
220
  right_to_left: "Right to left"
213
221
  row: "Row"
222
+ rows_and_columns: "Rows and columns"
214
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."
215
224
  same_tab: "Same tab"
216
225
  save: "Save"
@@ -221,6 +230,7 @@ en:
221
230
  select_the_text_to_translate_first: "Select the text to translate first."
222
231
  sets_a_liquid_variable_for_the_blocks_after_it_assign_variab: "Sets a Liquid variable for the blocks after it: {% assign variable = value %}."
223
232
  show_panels: "Show panels"
233
+ show_the_row_in_a_condition: "Show the row in a Condition"
224
234
  show_translations_in: "Show translations in"
225
235
  show_when: "Show when"
226
236
  shown_after_the_subject_in_most_inboxes: "Shown after the subject in most inboxes."
@@ -22,9 +22,13 @@ nl:
22
22
  add_above: "Erboven toevoegen"
23
23
  add_below: "Eronder toevoegen"
24
24
  add_block: "Blok toevoegen"
25
+ add_column_left: "Kolom links toevoegen"
26
+ add_column_right: "Kolom rechts toevoegen"
25
27
  add_left: "Links toevoegen"
26
28
  add_link: "Link toevoegen"
27
29
  add_right: "Rechts toevoegen"
30
+ add_row_above: "Rij erboven toevoegen"
31
+ add_row_below: "Rij eronder toevoegen"
28
32
  added_to_the_email_s_style_block: "Wordt toegevoegd aan het <style>-blok van de e-mail."
29
33
  align: "Uitlijning"
30
34
  align_center: "Centreren"
@@ -77,6 +81,8 @@ nl:
77
81
  dashed: "Gestreept"
78
82
  default: "Standaard"
79
83
  delete: "Verwijderen"
84
+ delete_column: "Kolom verwijderen"
85
+ delete_row: "Rij verwijderen"
80
86
  desktop: "Desktop"
81
87
  divider: "Scheidingslijn"
82
88
  done: "Klaar"
@@ -87,6 +93,7 @@ nl:
87
93
  drag_onto_the_canvas_or_click_to_add: "Sleep naar het canvas, of klik om toe te voegen"
88
94
  drag_to_move: "Sleep om te verplaatsen"
89
95
  drag_to_resize: "Sleep om het formaat te wijzigen"
96
+ drag_to_set_the_column_s_width: "Sleep om de kolombreedte in te stellen"
90
97
  drop_a_cell_here: "Zet hier een cel neer"
91
98
  drop_a_column_here: "Zet hier een kolom neer"
92
99
  drop_a_row_here: "Zet hier een rij neer"
@@ -206,11 +213,13 @@ nl:
206
213
  redo_z: "Opnieuw (⇧⌘Z)"
207
214
  remove: "Verwijderen"
208
215
  remove_link: "Link verwijderen"
216
+ repeat_the_row_in_a_loop: "Rij herhalen in een Loop"
209
217
  repeats_its_blocks_for_each_item_for_variable_in_collection: "Herhaalt zijn blokken voor elk item: {% for variable in collection %}."
210
218
  replace: "Vervangen"
211
219
  right: "Rechts"
212
220
  right_to_left: "Rechts naar links"
213
221
  row: "Rij"
222
+ rows_and_columns: "Rijen en kolommen"
214
223
  rows_of_cells_select_a_cell_to_add_rows_and_columns_put_rows: "Rijen met cellen. Selecteer een cel om rijen en kolommen toe te voegen. Zet rijen in een Loop om ze voor elk item te herhalen."
215
224
  same_tab: "Zelfde tabblad"
216
225
  save: "Opslaan"
@@ -221,6 +230,7 @@ nl:
221
230
  select_the_text_to_translate_first: "Selecteer eerst de tekst om te vertalen."
222
231
  sets_a_liquid_variable_for_the_blocks_after_it_assign_variab: "Zet een Liquid-variabele voor de blokken erna: {% assign variable = value %}."
223
232
  show_panels: "Panelen tonen"
233
+ show_the_row_in_a_condition: "Rij tonen in een Condition"
224
234
  show_translations_in: "Vertalingen tonen in"
225
235
  show_when: "Tonen als"
226
236
  shown_after_the_subject_in_most_inboxes: "In de meeste inboxen getoond na het onderwerp."
@@ -1,3 +1,3 @@
1
1
  module TessEdit
2
- VERSION = "0.5.10"
2
+ VERSION = "0.5.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tess_edit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt