tess_edit 0.5.17 → 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: 81bf024320e1b26b908b234509c20f2d3d0b28486246f677f697a73c004ec464
4
- data.tar.gz: 6fee53efa892077a3ab1e55111de4d67a827f52091cff03e3c052bae15fc108f
3
+ metadata.gz: f4b5f4ef4129509f715c9bc44635cc111793c474e6867eec0ce39bbf1c96314f
4
+ data.tar.gz: b9f65e03f04e39949fb1a9cbb673b2e6d3e6af1d10b6249ae515a33902bfdd4c
5
5
  SHA512:
6
- metadata.gz: ba363c92cb29469719787c21fe62d2d4d2d0fa0c53d9d9764eee878e546ba5e675c9434335f45fb4a1bfb2c5f84de258e7946276743b893a8ceb93d2e8c7e312
7
- data.tar.gz: 9fa13068fed9c8fe57d31f0abe2834a0f0aa981b5f1cf1600fc700e6c6af2217e7e812105ca7784fcbba74d653b1e8abdd40177de83f007764c99137a023672d
6
+ metadata.gz: 5da14c83a17cf9199fb67990d89220c7f4545da1896b1409aaf58ff9c700018919d5173e6709937ffe46e77ee4d8907583ab26e822f0c9eb87ba7ec1ad01f70d
7
+ data.tar.gz: d6e2c1719a9998ed7587c9f1e1e0824137881f71a517d4b06e09b8b232982e9a75f09c296de6388d7f6a33c5cca6d997496ac746549538cf1ffbf6b1a0660ac1
@@ -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.17"
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.17
4
+ version: 0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt