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 +4 -4
- data/app/javascript/tess_edit/ui/canvas.js +14 -2
- data/lib/tess_edit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f4b5f4ef4129509f715c9bc44635cc111793c474e6867eec0ce39bbf1c96314f
|
|
4
|
+
data.tar.gz: b9f65e03f04e39949fb1a9cbb673b2e6d3e6af1d10b6249ae515a33902bfdd4c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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)
|
data/lib/tess_edit/version.rb
CHANGED