tess_edit 0.5.16 → 0.5.18

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: f94d3bf110ca08ee76b35571622ff9637dc1c0bd2ebe6959429da9bc37de14ce
4
- data.tar.gz: fe49f2095f43a1238c6a9b4a58ef8e7f099453325a25090ea831821c2573b8d3
3
+ metadata.gz: f4b5f4ef4129509f715c9bc44635cc111793c474e6867eec0ce39bbf1c96314f
4
+ data.tar.gz: b9f65e03f04e39949fb1a9cbb673b2e6d3e6af1d10b6249ae515a33902bfdd4c
5
5
  SHA512:
6
- metadata.gz: b7e299e82c79d5c321ac33c305305a3398bed106c6b2060eeaebf7fee01370b1dec5f8c859195eaca41912d7c37b85ede67cd21715f490999496c820201a6d56
7
- data.tar.gz: 2f5fbac84e32432ab410de4b731d91fd664be39ba0bd5145707d9418f07380f20b354004137de2cf77c555d4e97dfadd67131397cf7aed326e77290a06a60218
6
+ metadata.gz: 5da14c83a17cf9199fb67990d89220c7f4545da1896b1409aaf58ff9c700018919d5173e6709937ffe46e77ee4d8907583ab26e822f0c9eb87ba7ec1ad01f70d
7
+ data.tar.gz: d6e2c1719a9998ed7587c9f1e1e0824137881f71a517d4b06e09b8b232982e9a75f09c296de6388d7f6a33c5cca6d997496ac746549538cf1ffbf6b1a0660ac1
@@ -256,7 +256,7 @@ async function checkPath(path, context, local) {
256
256
  if (!own) {
257
257
  context.roots ||= await variables.options("", context.scope).catch(() => [])
258
258
  if (!context.roots.length) return null
259
- if (!context.roots.some((variable) => variable.name === root)) return { at: 0, length: root.length, message: t("There's no variable %{name}", { name: root }) }
259
+ if (!context.roots.some((variable) => [root, names[0]].includes(variable.name))) return { at: 0, length: root.length, message: t("There's no variable %{name}", { name: root }) }
260
260
  }
261
261
  // Each name after it, as far as its parent's variables are known
262
262
  let at = names[0].length + 1
@@ -266,8 +266,9 @@ async function checkPath(path, context, local) {
266
266
  if (!variable?.children) return null
267
267
  const options = await variables.options(parent, scope).catch(() => [])
268
268
  if (!options.length) return null
269
+ // A method's name may end in ? (screening.payment_needed?), as Liquid allows, with or without it
269
270
  const name = names[i].replace(/\?$/, "")
270
- if (name !== "size" && !options.some((option) => option.name === name)) return { at, length: names[i].length, message: t("%{path} has no %{name}", { path: parent, name }) }
271
+ if (name !== "size" && !options.some((option) => [name, `${name}?`].includes(option.name))) return { at, length: names[i].length, message: t("%{path} has no %{name}", { path: parent, name }) }
271
272
  at += names[i].length + 1
272
273
  }
273
274
  return null
@@ -12,7 +12,7 @@ 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
14
  import { cellOf, columnCount, rowGroups, rows, setColumnAt, span, tableOf } from "tess_edit/core/table"
15
- import { FREE_CSS, FreeLayout } from "tess_edit/ui/free_layout"
15
+ import { FREE_CSS, FreeLayout, freeChild } from "tess_edit/ui/free_layout"
16
16
  import { icon } from "tess_edit/ui/icons"
17
17
 
18
18
  const OVERLAY_CSS = `
@@ -359,6 +359,11 @@ export class Canvas {
359
359
  if (editingId !== selectedId && !this.free.dragging) {
360
360
  // In a table's cell (the cell, or its text): its rows and columns
361
361
  const cell = free && cellOf(this.editor.doc, selectedId)
362
+ // A free container's own block moves by its handle as when it's dragged
363
+ // itself (ui/free_layout.js): as it goes, on the grid and the guides;
364
+ // any other block by dragging it elsewhere in the document
365
+ const placed = freeChild(this.editor.doc, selectedId)
366
+ const freeMove = placed?.node.id === selectedId
362
367
  const tools = this.doc.createElement("div")
363
368
  tools.className = "tess-tools"
364
369
  tools.innerHTML = [
@@ -366,7 +371,7 @@ export class Canvas {
366
371
  ...(cell ? [["table", t("Rows and columns")]] : []),
367
372
  ...(free ? [["drag", t("Drag to move")], ["duplicate", t("Duplicate")], ["delete", t("Delete")]] : [])
368
373
  ]
369
- .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>`)
374
+ .map(([tool, title]) => `<span data-tool="${tool}" title="${title}" ${tool === "drag" && !freeMove ? 'draggable="true"' : ""}>${icon({ parent: "parent", drag: "move", duplicate: "copy", delete: "trash", table: TABLE_ICON }[tool], "tess-icon")}</span>`)
370
375
  .join("")
371
376
  tools.querySelectorAll("svg").forEach((svg) => svg.setAttribute("style", "width:14px;height:14px"))
372
377
  tools.addEventListener("mousedown", (event) => event.stopPropagation())
@@ -379,6 +384,13 @@ export class Canvas {
379
384
  if (tool === "duplicate") this.editor.duplicate(selectedId)
380
385
  if (tool === "delete") this.editor.remove(selectedId)
381
386
  })
387
+ if (freeMove) {
388
+ tools.querySelector('[data-tool="drag"]')?.addEventListener("pointerdown", (event) => {
389
+ event.preventDefault()
390
+ event.stopPropagation()
391
+ this.free.start(event, "move", placed)
392
+ })
393
+ }
382
394
  tools.querySelector('[data-tool="drag"]')?.addEventListener("dragstart", (event) => {
383
395
  event.dataTransfer.effectAllowed = "move"
384
396
  event.dataTransfer.setData("text/plain", selectedId)
@@ -1,3 +1,3 @@
1
1
  module TessEdit
2
- VERSION = "0.5.16"
2
+ VERSION = "0.5.18"
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.16
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt