tess_edit 0.5.5 → 0.5.7
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 +28 -0
- data/app/helpers/tess_edit/translations_helper.rb +23 -0
- data/app/javascript/tess_edit/blocks/button.js +2 -1
- data/app/javascript/tess_edit/controllers/editor_controller.js +92 -42
- data/app/javascript/tess_edit/core/i18n.js +32 -0
- data/app/javascript/tess_edit/core/media.js +4 -3
- data/app/javascript/tess_edit/core/registry.js +6 -2
- data/app/javascript/tess_edit/core/translations.js +5 -3
- data/app/javascript/tess_edit/core/variables.js +3 -2
- data/app/javascript/tess_edit/export/mjml.js +2 -1
- data/app/javascript/tess_edit/ui/blocks_panel.js +9 -8
- data/app/javascript/tess_edit/ui/canvas.js +6 -5
- data/app/javascript/tess_edit/ui/dialog.js +5 -4
- data/app/javascript/tess_edit/ui/font_picker.js +6 -5
- data/app/javascript/tess_edit/ui/free_layout.js +2 -1
- data/app/javascript/tess_edit/ui/icons.js +1 -0
- data/app/javascript/tess_edit/ui/inspector.js +37 -36
- data/app/javascript/tess_edit/ui/text_editing.js +24 -23
- data/app/javascript/tess_edit/ui/translate_dialog.js +7 -6
- data/app/javascript/tess_edit/ui/translation_popover.js +8 -7
- data/app/javascript/tess_edit/ui/tree.js +3 -2
- data/app/javascript/tess_edit/ui/variable_menu.js +5 -4
- data/config/locales/en.yml +230 -0
- data/config/locales/nl.yml +230 -0
- data/lib/tess_edit/engine.rb +5 -0
- data/lib/tess_edit/version.rb +1 -1
- metadata +5 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// allowed. The tiles of the host's palette sources (core/registry.js) follow,
|
|
4
4
|
// a list per source, to drag or click in the same way.
|
|
5
5
|
|
|
6
|
+
import { t } from "tess_edit/core/i18n"
|
|
6
7
|
import { categories, getBlock } from "tess_edit/core/registry"
|
|
7
8
|
import { h } from "tess_edit/ui/dom"
|
|
8
9
|
import { icon } from "tess_edit/ui/icons"
|
|
@@ -13,7 +14,7 @@ export function renderBlocksPanel(editor, element) {
|
|
|
13
14
|
h(
|
|
14
15
|
"section",
|
|
15
16
|
{ class: "px-3 pt-3" },
|
|
16
|
-
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, category.label),
|
|
17
|
+
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, t(category.label)),
|
|
17
18
|
h(
|
|
18
19
|
"div",
|
|
19
20
|
{ class: "grid grid-cols-3 gap-1.5" },
|
|
@@ -25,7 +26,7 @@ export function renderBlocksPanel(editor, element) {
|
|
|
25
26
|
{
|
|
26
27
|
type: "button",
|
|
27
28
|
draggable: true,
|
|
28
|
-
title:
|
|
29
|
+
title: t("Drag onto the canvas, or click to add"),
|
|
29
30
|
class: `flex flex-col items-center justify-center gap-1 h-16 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400 hover:shadow-sm cursor-grab active:cursor-grabbing ${category.key === "liquid" ? "text-amber-700 dark:text-amber-400" : ""}`,
|
|
30
31
|
ondragstart: (event) => {
|
|
31
32
|
event.dataTransfer.effectAllowed = "copy"
|
|
@@ -36,13 +37,13 @@ export function renderBlocksPanel(editor, element) {
|
|
|
36
37
|
onclick: () => editor.addFromPalette(item.key)
|
|
37
38
|
},
|
|
38
39
|
h("span", { html: icon(item.icon, "w-5 h-5") }),
|
|
39
|
-
h("span", { class: "text-[11px] leading-none" }, item.label)
|
|
40
|
+
h("span", { class: "text-[11px] leading-none" }, t(item.label))
|
|
40
41
|
)
|
|
41
42
|
)
|
|
42
43
|
)
|
|
43
44
|
)
|
|
44
45
|
)
|
|
45
|
-
element.replaceChildren(...groups, ...sourceSections(editor), h("p", { class: "px-3 py-4 text-xs text-gray-500 dark:text-gray-400" }, "Drag blocks onto the canvas or into the Layers tree. Liquid blocks wrap other blocks in {% for %} or {% if %}."))
|
|
46
|
+
element.replaceChildren(...groups, ...sourceSections(editor), h("p", { class: "px-3 py-4 text-xs text-gray-500 dark:text-gray-400" }, t("Drag blocks onto the canvas or into the Layers tree. Liquid blocks wrap other blocks in {% for %} or {% if %}.")))
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const SEARCH_FROM = 8
|
|
@@ -60,7 +61,7 @@ function sourceSections(editor) {
|
|
|
60
61
|
{
|
|
61
62
|
type: "button",
|
|
62
63
|
draggable: true,
|
|
63
|
-
title: item.description || "Drag onto the canvas, or click to add",
|
|
64
|
+
title: item.description || t("Drag onto the canvas, or click to add"),
|
|
64
65
|
"data-tess-edit-source-item": item.key,
|
|
65
66
|
class: "flex w-full items-center gap-2 rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 px-2 py-1.5 text-left text-[13px] text-gray-700 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400 cursor-grab active:cursor-grabbing",
|
|
66
67
|
ondragstart: (event) => {
|
|
@@ -76,15 +77,15 @@ function sourceSections(editor) {
|
|
|
76
77
|
item.version ? h("span", { class: "text-[11px] text-gray-400 dark:text-gray-500" }, `v${item.version}`) : null
|
|
77
78
|
)
|
|
78
79
|
),
|
|
79
|
-
...(matches.length ? [] : [h("p", { class: "text-xs text-gray-500 dark:text-gray-400" }, items.length ? "Nothing matches." : "There's nothing here yet.")])
|
|
80
|
+
...(matches.length ? [] : [h("p", { class: "text-xs text-gray-500 dark:text-gray-400" }, t(items.length ? "Nothing matches." : "There's nothing here yet."))])
|
|
80
81
|
)
|
|
81
82
|
}
|
|
82
83
|
show()
|
|
83
|
-
const search = items.length >= SEARCH_FROM ? h("input", { type: "search", placeholder:
|
|
84
|
+
const search = items.length >= SEARCH_FROM ? h("input", { type: "search", placeholder: t("Find in %{source}", { source: t(source.label) }), class: "mb-2 w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-[13px]", oninput: (event) => show(event.target.value) }) : null
|
|
84
85
|
return h(
|
|
85
86
|
"section",
|
|
86
87
|
{ class: "px-3 pt-3", "data-tess-edit-source": source.key },
|
|
87
|
-
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, source.label),
|
|
88
|
+
h("h3", { class: "mb-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400" }, t(source.label)),
|
|
88
89
|
error ? h("p", { class: "text-xs text-red-600 dark:text-red-400" }, error) : null,
|
|
89
90
|
search,
|
|
90
91
|
rows
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// filters show their text in the editor's language (see annotate).
|
|
6
6
|
|
|
7
7
|
import { ancestors, find, isDescendant, isHorizontal } from "tess_edit/core/document"
|
|
8
|
+
import { t } from "tess_edit/core/i18n"
|
|
8
9
|
import { imageFields } from "tess_edit/core/media"
|
|
9
10
|
import { getBlock, inlinePart, label } from "tess_edit/core/registry"
|
|
10
11
|
import { missingArguments, textParts, translationCalls } from "tess_edit/core/translations"
|
|
@@ -173,7 +174,7 @@ export class Canvas {
|
|
|
173
174
|
const unfilled = value === null ? [] : missingArguments(value, { args: span.dataset.tessArgs ? span.dataset.tessArgs.split(",") : [] })
|
|
174
175
|
if (value === null) span.textContent = span.dataset.tessCall
|
|
175
176
|
else showText(span, value)
|
|
176
|
-
span.title = unfilled.length ?
|
|
177
|
+
span.title = unfilled.length ? t("No argument for %{names} in the t filter", { names: unfilled.map((name) => `%{${name}}`).join(", ") }) : ""
|
|
177
178
|
span.classList.toggle("tess-t-missing", unfilled.length > 0 || (translations.has(key) && (locale ? value === null : translations.missing(key).length > 0)))
|
|
178
179
|
}
|
|
179
180
|
this.refresh()
|
|
@@ -278,7 +279,7 @@ export class Canvas {
|
|
|
278
279
|
if (!rect) return
|
|
279
280
|
const box = this.box(rect, editingId === selectedId ? "tess-selected tess-editing" : "tess-selected")
|
|
280
281
|
const free = this.editor.isFree(selectedId)
|
|
281
|
-
box.append(Object.assign(this.doc.createElement("div"), { className: "tess-label", textContent: editingId === selectedId ?
|
|
282
|
+
box.append(Object.assign(this.doc.createElement("div"), { className: "tess-label", textContent: editingId === selectedId ? t("Editing text · %{key} to finish", { key: this.editor.editingPart?.plain ? "Enter" : "Esc" }) : free || !this.editor.lock ? label(hit.node) : `${label(hit.node)} · ${t("Layout")}` }))
|
|
282
283
|
|
|
283
284
|
const handle = this.free.handle(selectedId)
|
|
284
285
|
if (handle) box.append(handle)
|
|
@@ -287,8 +288,8 @@ export class Canvas {
|
|
|
287
288
|
const tools = this.doc.createElement("div")
|
|
288
289
|
tools.className = "tess-tools"
|
|
289
290
|
tools.innerHTML = [
|
|
290
|
-
["parent", "Select parent"],
|
|
291
|
-
...(free ? [["drag", "Drag to move"], ["duplicate", "Duplicate"], ["delete", "Delete"]] : [])
|
|
291
|
+
["parent", t("Select parent")],
|
|
292
|
+
...(free ? [["drag", t("Drag to move")], ["duplicate", t("Duplicate")], ["delete", t("Delete")]] : [])
|
|
292
293
|
]
|
|
293
294
|
.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>`)
|
|
294
295
|
.join("")
|
|
@@ -315,7 +316,7 @@ export class Canvas {
|
|
|
315
316
|
if (hit.parent && this.editor.canFill(hit.parent.id)) {
|
|
316
317
|
const plus = this.doc.createElement("button")
|
|
317
318
|
plus.className = "tess-plus"
|
|
318
|
-
plus.title = "Add a block below"
|
|
319
|
+
plus.title = t("Add a block below")
|
|
319
320
|
plus.innerHTML = icon("plus")
|
|
320
321
|
plus.querySelector("svg").setAttribute("style", "width:12px;height:12px")
|
|
321
322
|
plus.addEventListener("click", (event) => {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// button resolves to "". `check(value)` may say what's wrong with it (a
|
|
6
6
|
// string), or ask to confirm it ({ confirm, label }: saving again confirms).
|
|
7
7
|
|
|
8
|
+
import { t } from "tess_edit/core/i18n"
|
|
8
9
|
import { h } from "tess_edit/ui/dom"
|
|
9
10
|
|
|
10
11
|
const BUTTON = "rounded-md px-3 py-1.5 text-xs font-medium"
|
|
@@ -20,7 +21,7 @@ export function askText(root, { title, label, value = "", hint = null, body = nu
|
|
|
20
21
|
oninput: () => {
|
|
21
22
|
confirmed = null
|
|
22
23
|
message.textContent = ""
|
|
23
|
-
save.textContent = "Save"
|
|
24
|
+
save.textContent = t("Save")
|
|
24
25
|
},
|
|
25
26
|
onkeydown: (event) => {
|
|
26
27
|
if (event.key === "Enter") {
|
|
@@ -30,7 +31,7 @@ export function askText(root, { title, label, value = "", hint = null, body = nu
|
|
|
30
31
|
}
|
|
31
32
|
})
|
|
32
33
|
const message = h("p", { class: "min-h-4 text-xs text-red-600 dark:text-red-400", role: "alert" })
|
|
33
|
-
const save = h("button", { type: "button", class: `${BUTTON} bg-blue-600 text-white hover:bg-blue-700`, onclick: () => submit() }, "Save")
|
|
34
|
+
const save = h("button", { type: "button", class: `${BUTTON} bg-blue-600 text-white hover:bg-blue-700`, onclick: () => submit() }, t("Save"))
|
|
34
35
|
const close = (result) => {
|
|
35
36
|
dialog.remove()
|
|
36
37
|
resolve(result)
|
|
@@ -88,9 +89,9 @@ export function askText(root, { title, label, value = "", hint = null, body = nu
|
|
|
88
89
|
h(
|
|
89
90
|
"div",
|
|
90
91
|
{ class: "flex gap-2" },
|
|
91
|
-
remove ? h("button", { type: "button", class: `${BUTTON} text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30`, onclick: () => close("") }, "Remove") : null,
|
|
92
|
+
remove ? h("button", { type: "button", class: `${BUTTON} text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30`, onclick: () => close("") }, t("Remove")) : null,
|
|
92
93
|
h("span", { class: "flex-1" }),
|
|
93
|
-
h("button", { type: "button", class: `${BUTTON} border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`, onclick: () => close(null) }, "Cancel"),
|
|
94
|
+
h("button", { type: "button", class: `${BUTTON} border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`, onclick: () => close(null) }, t("Cancel")),
|
|
94
95
|
save
|
|
95
96
|
)
|
|
96
97
|
].filter(Boolean)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// list only loads those seen; the host's page has to have the fonts (e.g. as
|
|
6
6
|
// @font-face rules, which load when used).
|
|
7
7
|
|
|
8
|
+
import { t } from "tess_edit/core/i18n"
|
|
8
9
|
import { h } from "tess_edit/ui/dom"
|
|
9
10
|
|
|
10
11
|
const ITEM = "flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[15px]"
|
|
@@ -28,7 +29,7 @@ export class FontPicker {
|
|
|
28
29
|
label() {
|
|
29
30
|
const option = this.options.find((option) => option.value === this.value) || this.options[0]
|
|
30
31
|
this.button.replaceChildren(
|
|
31
|
-
h("span", { class: "min-w-0 flex-1 truncate", style: fontStyle(option.value) }, option.label),
|
|
32
|
+
h("span", { class: "min-w-0 flex-1 truncate", style: fontStyle(option.value) }, t(option.label)),
|
|
32
33
|
h("span", { class: "shrink-0 text-gray-400 dark:text-gray-500", "aria-hidden": "true" }, "▾")
|
|
33
34
|
)
|
|
34
35
|
}
|
|
@@ -37,7 +38,7 @@ export class FontPicker {
|
|
|
37
38
|
this.query = ""
|
|
38
39
|
this.search = h("input", {
|
|
39
40
|
type: "search",
|
|
40
|
-
placeholder: "Search fonts",
|
|
41
|
+
placeholder: t("Search fonts"),
|
|
41
42
|
class: "w-full rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-[13px] text-gray-900 dark:text-gray-100 outline-none focus:border-blue-500",
|
|
42
43
|
oninput: (event) => {
|
|
43
44
|
this.query = event.target.value
|
|
@@ -46,7 +47,7 @@ export class FontPicker {
|
|
|
46
47
|
},
|
|
47
48
|
onkeydown: (event) => this.key(event)
|
|
48
49
|
})
|
|
49
|
-
this.list = h("div", { class: "max-h-72 overflow-y-auto py-1", role: "listbox", "aria-label": "Fonts" })
|
|
50
|
+
this.list = h("div", { class: "max-h-72 overflow-y-auto py-1", role: "listbox", "aria-label": t("Fonts") })
|
|
50
51
|
this.element = h("div", { class: "absolute z-50 w-72 rounded-md border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-lg" }, h("div", { class: "p-1.5 border-b border-gray-100 dark:border-gray-700" }, this.search), this.list)
|
|
51
52
|
this.editor.root.append(this.element)
|
|
52
53
|
this.observer = new IntersectionObserver((entries) => entries.forEach((entry) => entry.isIntersecting && show(entry.target)), { root: this.list })
|
|
@@ -78,12 +79,12 @@ export class FontPicker {
|
|
|
78
79
|
onclick: () => this.pick(option)
|
|
79
80
|
},
|
|
80
81
|
h("span", { class: "w-3 shrink-0 text-[11px]" }, chosen ? "✓" : ""),
|
|
81
|
-
h("span", { class: "min-w-0 flex-1 truncate" }, option.label)
|
|
82
|
+
h("span", { class: "min-w-0 flex-1 truncate" }, t(option.label))
|
|
82
83
|
)
|
|
83
84
|
this.observer.observe(row)
|
|
84
85
|
return row
|
|
85
86
|
})
|
|
86
|
-
const empty = matches.length ? null : h("p", { class: "px-2.5 py-1.5 text-xs text-gray-500 dark:text-gray-400" }, "No fonts with that name")
|
|
87
|
+
const empty = matches.length ? null : h("p", { class: "px-2.5 py-1.5 text-xs text-gray-500 dark:text-gray-400" }, t("No fonts with that name"))
|
|
87
88
|
this.list.replaceChildren(...rows, ...(empty ? [empty] : []))
|
|
88
89
|
rows[this.index]?.scrollIntoView({ block: "nearest" })
|
|
89
90
|
}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
// off. A block dropped from the palette lands where it is let go.
|
|
25
25
|
|
|
26
26
|
import { find, getValue } from "tess_edit/core/document"
|
|
27
|
+
import { t } from "tess_edit/core/i18n"
|
|
27
28
|
import { getBlock } from "tess_edit/core/registry"
|
|
28
29
|
|
|
29
30
|
// Screen pixels a press moves before it drags, and within which edges snap
|
|
@@ -135,7 +136,7 @@ export class FreeLayout {
|
|
|
135
136
|
if (!resize || !this.editor.isFree(id) || this.editor.editingId) return null
|
|
136
137
|
const handle = this.canvas.doc.createElement("div")
|
|
137
138
|
handle.className = "tess-resize"
|
|
138
|
-
handle.title = "Drag to resize"
|
|
139
|
+
handle.title = t("Drag to resize")
|
|
139
140
|
handle.addEventListener("pointerdown", (event) => {
|
|
140
141
|
event.preventDefault()
|
|
141
142
|
event.stopPropagation()
|
|
@@ -26,6 +26,7 @@ const paths = {
|
|
|
26
26
|
"cols-21": '<rect x="3" y="6" width="10.5" height="12" rx="1.5"/><rect x="15.5" y="6" width="5.5" height="12" rx="1.5"/>',
|
|
27
27
|
"panels-left": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M10 4v16"/><path d="M5.5 8h2M5.5 11h2" opacity=".6"/>',
|
|
28
28
|
"panels-split": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M8 4v16M16 4v16"/>',
|
|
29
|
+
"panels-bottom": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 13h18"/><path d="M7 16.5h4" opacity=".6"/>',
|
|
29
30
|
"panels-right": '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M14 4v16"/><path d="M16.5 8h2M16.5 11h2" opacity=".6"/>',
|
|
30
31
|
lock: '<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/>',
|
|
31
32
|
plus: '<path d="M12 5v14M5 12h14"/>',
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// host's Stimulus controllers in it keep their state: it and its group stay
|
|
15
15
|
// in Inspect, hidden while another block is selected (see place in ui/dom.js).
|
|
16
16
|
|
|
17
|
+
import { t } from "tess_edit/core/i18n"
|
|
17
18
|
import { imageSource } from "tess_edit/core/media"
|
|
18
19
|
import { fieldType, getBlock, label } from "tess_edit/core/registry"
|
|
19
20
|
import { fontOptions } from "tess_edit/blocks/fields"
|
|
@@ -89,9 +90,9 @@ export class Inspector {
|
|
|
89
90
|
!this.editor.isFree(node.id)
|
|
90
91
|
? []
|
|
91
92
|
: [
|
|
92
|
-
["parent", "Select parent", () => this.editor.selectParent()],
|
|
93
|
-
["copy", "Duplicate", () => this.editor.duplicate(node.id)],
|
|
94
|
-
["trash", "Delete", () => this.editor.remove(node.id)]
|
|
93
|
+
["parent", t("Select parent"), () => this.editor.selectParent()],
|
|
94
|
+
["copy", t("Duplicate"), () => this.editor.duplicate(node.id)],
|
|
95
|
+
["trash", t("Delete"), () => this.editor.remove(node.id)]
|
|
95
96
|
].map(([name, title, onclick]) =>
|
|
96
97
|
h("button", { type: "button", title, class: "w-7 h-7 flex items-center justify-center rounded-md text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-900 dark:hover:text-gray-100", html: icon(name), onclick })
|
|
97
98
|
)
|
|
@@ -105,10 +106,10 @@ export class Inspector {
|
|
|
105
106
|
// A group shows when one of its fields applies (see shows below)
|
|
106
107
|
const groups = (definition.fields || []).filter((group) => group.fields.some((field) => this.shows(node, field))).map((group) => this.group(node, group))
|
|
107
108
|
const locked = this.editor.lock && node.id !== doc.id && !this.editor.isFree(node.id)
|
|
108
|
-
? 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") }), "Part of the layout")
|
|
109
|
+
? 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"))
|
|
109
110
|
: null
|
|
110
111
|
// A block's hint explains how to edit it, which a locked block can't be.
|
|
111
|
-
const hint = definition.hint && !locked ? h("p", { class: "mx-4 mt-3 rounded-md bg-gray-50 dark:bg-gray-700/50 px-3 py-2 text-xs text-gray-600 dark:text-gray-300" }, definition.hint) : null
|
|
112
|
+
const hint = definition.hint && !locked ? h("p", { class: "mx-4 mt-3 rounded-md bg-gray-50 dark:bg-gray-700/50 px-3 py-2 text-xs text-gray-600 dark:text-gray-300" }, t(definition.hint)) : null
|
|
112
113
|
|
|
113
114
|
place(this.body, [locked, hint, ...groups].filter(Boolean), new Set([...this.keptGroups.values()].map((kept) => kept.details)))
|
|
114
115
|
}
|
|
@@ -141,7 +142,7 @@ export class Inspector {
|
|
|
141
142
|
"summary",
|
|
142
143
|
{ class: "flex items-center gap-1.5 px-4 py-2.5 cursor-pointer select-none text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 list-none [&::-webkit-details-marker]:hidden" },
|
|
143
144
|
h("span", { html: icon("chevron", "w-3 h-3 transition-transform group-open/field:rotate-90") }),
|
|
144
|
-
group.title
|
|
145
|
+
t(group.title)
|
|
145
146
|
),
|
|
146
147
|
list
|
|
147
148
|
)
|
|
@@ -165,30 +166,30 @@ export class Inspector {
|
|
|
165
166
|
? this.control(node, field, value, set)
|
|
166
167
|
: h("fieldset", { disabled: true, class: "opacity-60" }, this.control(node, field, value, set))
|
|
167
168
|
const expand = field.type === "code" && editable
|
|
168
|
-
? h("button", { type: "button", title:
|
|
169
|
+
? h("button", { type: "button", title: t("Edit %{label} in a larger window", { label: t(field.label) }), class: "rounded px-1 text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: () => this.expand(node, field) }, t("Expand"))
|
|
169
170
|
: null
|
|
170
171
|
const adapter = editable && field.liquid && this.editor.variables?.enabled && this.adapters.get(field.key)
|
|
171
172
|
const variables = adapter
|
|
172
|
-
? h("button", { type: "button", title: "Insert a variable", class: "whitespace-nowrap rounded px-1 font-mono text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: (event) => this.editor.variableMenu.browse(adapter, event.currentTarget) }, "{ }")
|
|
173
|
+
? h("button", { type: "button", title: t("Insert a variable"), class: "whitespace-nowrap rounded px-1 font-mono text-[11px] font-medium text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", onclick: (event) => this.editor.variableMenu.browse(adapter, event.currentTarget) }, "{ }")
|
|
173
174
|
: null
|
|
174
175
|
// Liquid in text can be translated
|
|
175
176
|
const input = field.liquid === true && ["text", "textarea"].includes(field.type) && this.editor.translations?.enabled && this.inputs.get(field.key)
|
|
176
177
|
const translate = input && editable
|
|
177
|
-
? h("button", { type: "button", title: "Make translatable: keep the selected text, or all of it, as a translation", class: "rounded px-1 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", html: icon("translate", "w-3.5 h-3.5"), onclick: () => this.makeTranslatable(input) })
|
|
178
|
+
? h("button", { type: "button", title: t("Make translatable: keep the selected text, or all of it, as a translation"), class: "rounded px-1 text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/40", html: icon("translate", "w-3.5 h-3.5"), onclick: () => this.makeTranslatable(input) })
|
|
178
179
|
: null
|
|
179
180
|
const tools = expand || variables || translate ? h("span", { class: "absolute right-0 top-0 flex items-center gap-0.5" }, expand, variables, translate) : null
|
|
180
181
|
// A hint can be a function of the value, kept up to date as it's typed: hint(value, node)
|
|
181
182
|
const hint = field.hint ? h("span", { class: "mt-1 block text-[11px] leading-snug text-gray-500 dark:text-gray-400" }) : null
|
|
182
183
|
const showHint = () => {
|
|
183
184
|
const current = find(this.editor.doc, node.id)?.node || node
|
|
184
|
-
hint.textContent = typeof field.hint === "function" ? field.hint(getValue(current, field.key) ?? "", current) : field.hint
|
|
185
|
+
hint.textContent = typeof field.hint === "function" ? field.hint(getValue(current, field.key) ?? "", current) : t(field.hint)
|
|
185
186
|
}
|
|
186
187
|
if (hint) showHint()
|
|
187
188
|
// A div, not a label: a label would forward clicks to the first button or color picker inside it.
|
|
188
189
|
return h(
|
|
189
190
|
"div",
|
|
190
191
|
{ class: "relative block", oninput: typeof field.hint === "function" ? showHint : null },
|
|
191
|
-
h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, field.label),
|
|
192
|
+
h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, t(field.label)),
|
|
192
193
|
tools,
|
|
193
194
|
control,
|
|
194
195
|
input ? this.translationHint(input) : null,
|
|
@@ -213,7 +214,7 @@ export class Inspector {
|
|
|
213
214
|
type: "text",
|
|
214
215
|
class: INPUT,
|
|
215
216
|
value,
|
|
216
|
-
placeholder: field.placeholder || "",
|
|
217
|
+
placeholder: t(field.placeholder) || "",
|
|
217
218
|
oninput: (event) => set(withUnit(event.target.value)),
|
|
218
219
|
onchange: (event) => (event.target.value = withUnit(event.target.value))
|
|
219
220
|
})
|
|
@@ -228,7 +229,7 @@ export class Inspector {
|
|
|
228
229
|
// options can depend on the editor's settings: options(editor)
|
|
229
230
|
(typeof field.options === "function" ? field.options(this.editor) : field.options).map((option) => {
|
|
230
231
|
const optionValue = typeof option === "string" ? option : option.value
|
|
231
|
-
const optionLabel = typeof option === "string" ? option || "Default" : option.label
|
|
232
|
+
const optionLabel = typeof option === "string" ? option || t("Default") : t(option.label)
|
|
232
233
|
return h("option", { value: optionValue, selected: optionValue === value }, optionLabel)
|
|
233
234
|
})
|
|
234
235
|
)
|
|
@@ -245,7 +246,7 @@ export class Inspector {
|
|
|
245
246
|
"button",
|
|
246
247
|
{
|
|
247
248
|
type: "button",
|
|
248
|
-
title: value === option.value ? "Click again to use the default" : "",
|
|
249
|
+
title: value === option.value ? t("Click again to use the default") : "",
|
|
249
250
|
class: `flex-1 px-2 py-1 text-xs border-l first:border-l-0 border-gray-300 dark:border-gray-600 ${value === 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"}`,
|
|
250
251
|
onclick: (event) => {
|
|
251
252
|
event.preventDefault()
|
|
@@ -253,13 +254,13 @@ export class Inspector {
|
|
|
253
254
|
this.render()
|
|
254
255
|
}
|
|
255
256
|
},
|
|
256
|
-
option.label
|
|
257
|
+
t(option.label)
|
|
257
258
|
)
|
|
258
259
|
)
|
|
259
260
|
)
|
|
260
261
|
|
|
261
262
|
case "toggle": {
|
|
262
|
-
const state = h("span", { class: "text-xs text-gray-600 dark:text-gray-300" }, value === field.on ? "On" : "Off")
|
|
263
|
+
const state = h("span", { class: "text-xs text-gray-600 dark:text-gray-300" }, t(value === field.on ? "On" : "Off"))
|
|
263
264
|
return h(
|
|
264
265
|
"span",
|
|
265
266
|
{ class: "flex items-center gap-2" },
|
|
@@ -269,7 +270,7 @@ export class Inspector {
|
|
|
269
270
|
checked: value === field.on,
|
|
270
271
|
onchange: (event) => {
|
|
271
272
|
set(event.target.checked ? field.on : field.off)
|
|
272
|
-
state.textContent = event.target.checked ? "On" : "Off"
|
|
273
|
+
state.textContent = t(event.target.checked ? "On" : "Off")
|
|
273
274
|
}
|
|
274
275
|
}),
|
|
275
276
|
state
|
|
@@ -286,7 +287,7 @@ export class Inspector {
|
|
|
286
287
|
return this.image(node, field, value, set)
|
|
287
288
|
|
|
288
289
|
default:
|
|
289
|
-
return this.variables(h("input", { type: "text", class: INPUT, value, placeholder: field.placeholder || "", oninput: (event) => set(event.target.value) }), node, field)
|
|
290
|
+
return this.variables(h("input", { type: "text", class: INPUT, value, placeholder: t(field.placeholder) || "", oninput: (event) => set(event.target.value) }), node, field)
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
|
|
@@ -305,7 +306,7 @@ export class Inspector {
|
|
|
305
306
|
button,
|
|
306
307
|
holder,
|
|
307
308
|
open: !field.summary || Boolean(field.open?.(element)),
|
|
308
|
-
wrapper: h("div", { class: "block" }, h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, field.label), h("div", { class: "flex items-center gap-2" }, summary, button), holder)
|
|
309
|
+
wrapper: h("div", { class: "block" }, h("span", { class: "mb-1 block text-xs font-medium text-gray-700 dark:text-gray-300" }, t(field.label)), h("div", { class: "flex items-center gap-2" }, summary, button), holder)
|
|
309
310
|
}
|
|
310
311
|
// Its only move: it reconnects, with what was typed so far
|
|
311
312
|
freeze(element)
|
|
@@ -326,7 +327,7 @@ export class Inspector {
|
|
|
326
327
|
const { open, field, element, button, holder, summary } = slot
|
|
327
328
|
holder.hidden = !open
|
|
328
329
|
button.parentElement.hidden = !field.summary
|
|
329
|
-
button.textContent = open ? "Done" : "Edit"
|
|
330
|
+
button.textContent = t(open ? "Done" : "Edit")
|
|
330
331
|
button.setAttribute("aria-expanded", String(open))
|
|
331
332
|
summary.hidden = open
|
|
332
333
|
summary.textContent = open ? "" : field.summary?.(element) || ""
|
|
@@ -359,7 +360,7 @@ export class Inspector {
|
|
|
359
360
|
const locale = call.locale || translationLocale
|
|
360
361
|
const value = locale ? translations.value(call.key, locale) : null
|
|
361
362
|
const missing = translations.has(call.key) && (locale ? value === null : translations.missing(call.key).length > 0)
|
|
362
|
-
const text = value !== null ? `${locale.toUpperCase()}: ${value}` : locale && translations.has(call.key) ?
|
|
363
|
+
const text = value !== null ? `${locale.toUpperCase()}: ${value}` : locale && translations.has(call.key) ? t("%{key} · no %{locale} text", { key: call.key, locale: locale.toUpperCase() }) : call.key
|
|
363
364
|
const chip = h(
|
|
364
365
|
"span",
|
|
365
366
|
{
|
|
@@ -387,7 +388,7 @@ export class Inspector {
|
|
|
387
388
|
const end = input.selectionEnd ?? 0
|
|
388
389
|
const whole = start === end
|
|
389
390
|
const text = whole ? input.value : input.value.slice(start, end)
|
|
390
|
-
if (!text.trim()) return this.editor.flash("Type the text to translate first.")
|
|
391
|
+
if (!text.trim()) return this.editor.flash(t("Type the text to translate first."))
|
|
391
392
|
const tag = await this.editor.makeTranslatable(text)
|
|
392
393
|
if (!tag) return
|
|
393
394
|
if (whole) input.value = tag
|
|
@@ -398,11 +399,11 @@ export class Inspector {
|
|
|
398
399
|
// An image URL, or with the host's images (editor.media, core/media.js) a
|
|
399
400
|
// choice between one of those, a new upload, and a URL
|
|
400
401
|
image(node, field, value, set) {
|
|
401
|
-
const url = this.variables(h("input", { type: "text", class: INPUT, value, placeholder: field.placeholder || "https://…", oninput: (event) => set(event.target.value) }), node, field)
|
|
402
|
+
const url = this.variables(h("input", { type: "text", class: INPUT, value, placeholder: t(field.placeholder) || "https://…", oninput: (event) => set(event.target.value) }), node, field)
|
|
402
403
|
if (!this.editor.media.enabled) return url
|
|
403
404
|
|
|
404
405
|
const source = imageSource(node, this.editor, field)
|
|
405
|
-
const sources = this.control(node, { type: "segmented", options: [{ value: "upload", label: "Uploaded" }, { value: "web", label: "Web" }] }, source, (next) =>
|
|
406
|
+
const sources = this.control(node, { type: "segmented", options: [{ value: "upload", label: t("Uploaded") }, { value: "web", label: t("Web") }] }, source, (next) =>
|
|
406
407
|
this.editor.setValue(node.id, field.source, next || source)
|
|
407
408
|
)
|
|
408
409
|
return h("div", { class: "space-y-1.5" }, sources, source === "upload" ? this.mediaPicker(node, field, getValue(node, field.image)) : url)
|
|
@@ -429,7 +430,7 @@ export class Inspector {
|
|
|
429
430
|
if (image) this.editor.chooseImage(node.id, image, field)
|
|
430
431
|
}
|
|
431
432
|
},
|
|
432
|
-
h("option", { value: "" }, images.length ? "Choose an image" : "No images yet"),
|
|
433
|
+
h("option", { value: "" }, t(images.length ? "Choose an image" : "No images yet")),
|
|
433
434
|
images.map((image) => h("option", { value: image.id, selected: image.id === value }, image.name))
|
|
434
435
|
)
|
|
435
436
|
return h(
|
|
@@ -439,7 +440,7 @@ export class Inspector {
|
|
|
439
440
|
"div",
|
|
440
441
|
{ class: "flex items-center gap-1.5" },
|
|
441
442
|
select,
|
|
442
|
-
h("button", { type: "button", class: "shrink-0 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50", disabled: uploading, onclick: () => file.click() }, uploading ? "Uploading…" : "Upload"),
|
|
443
|
+
h("button", { type: "button", class: "shrink-0 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 px-2 py-1 text-xs text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50", disabled: uploading, onclick: () => file.click() }, t(uploading ? "Uploading…" : "Upload")),
|
|
443
444
|
file
|
|
444
445
|
),
|
|
445
446
|
error ? h("p", { class: "mt-1 text-[11px] text-red-600 dark:text-red-400", role: "alert" }, error) : null,
|
|
@@ -470,13 +471,13 @@ export class Inspector {
|
|
|
470
471
|
},
|
|
471
472
|
h(
|
|
472
473
|
"div",
|
|
473
|
-
{ role: "dialog", "aria-label": field.label, class: "flex h-full max-h-[800px] w-full max-w-5xl flex-col gap-3 rounded-xl bg-white dark:bg-gray-800 p-4 shadow-xl" },
|
|
474
|
+
{ role: "dialog", "aria-label": t(field.label), class: "flex h-full max-h-[800px] w-full max-w-5xl flex-col gap-3 rounded-xl bg-white dark:bg-gray-800 p-4 shadow-xl" },
|
|
474
475
|
h(
|
|
475
476
|
"div",
|
|
476
477
|
{ class: "flex items-center gap-3" },
|
|
477
|
-
h("h3", { class: "text-sm font-semibold text-gray-900 dark:text-gray-100" }, label(node) === field.label ? field.label : `${label(node)} · ${field.label}`),
|
|
478
|
-
field.hint ? h("span", { class: "text-xs text-gray-500 dark:text-gray-400" }, field.hint) : null,
|
|
479
|
-
h("button", { type: "button", title: "Close", class: "ml-auto w-8 h-8 flex items-center justify-center rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700", html: icon("close"), onclick: close })
|
|
478
|
+
h("h3", { class: "text-sm font-semibold text-gray-900 dark:text-gray-100" }, label(node) === t(field.label) ? t(field.label) : `${label(node)} · ${t(field.label)}`),
|
|
479
|
+
typeof field.hint === "string" ? h("span", { class: "text-xs text-gray-500 dark:text-gray-400" }, t(field.hint)) : null,
|
|
480
|
+
h("button", { type: "button", title: t("Close"), class: "ml-auto w-8 h-8 flex items-center justify-center rounded-md text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700", html: icon("close"), onclick: close })
|
|
480
481
|
),
|
|
481
482
|
input
|
|
482
483
|
)
|
|
@@ -493,7 +494,7 @@ export class Inspector {
|
|
|
493
494
|
|
|
494
495
|
color(value, set) {
|
|
495
496
|
const text = h("input", {
|
|
496
|
-
type: "text", class: `${INPUT} font-mono text-xs`, value, placeholder: "Default", oninput: (event) => {
|
|
497
|
+
type: "text", class: `${INPUT} font-mono text-xs`, value, placeholder: t("Default"), oninput: (event) => {
|
|
497
498
|
set(event.target.value)
|
|
498
499
|
if (/^#[0-9a-f]{6}$/i.test(event.target.value)) swatch.value = event.target.value
|
|
499
500
|
}
|
|
@@ -512,7 +513,7 @@ export class Inspector {
|
|
|
512
513
|
|
|
513
514
|
spacing(value, set) {
|
|
514
515
|
const values = parseSpacing(value)
|
|
515
|
-
const inputs = ["Top", "Right", "Bottom", "Left"].map((side, i) =>
|
|
516
|
+
const inputs = [t("Top"), t("Right"), t("Bottom"), t("Left")].map((side, i) =>
|
|
516
517
|
h(
|
|
517
518
|
"span",
|
|
518
519
|
{ class: "block" },
|
|
@@ -552,7 +553,7 @@ export class Inspector {
|
|
|
552
553
|
: this.variables(h("input", {
|
|
553
554
|
type: "text",
|
|
554
555
|
class: INPUT,
|
|
555
|
-
placeholder: part.label,
|
|
556
|
+
placeholder: t(part.label),
|
|
556
557
|
value: item[part.name] ?? "",
|
|
557
558
|
oninput: (event) => {
|
|
558
559
|
items = items.map((it, i) => (i === index ? { ...it, [part.name]: event.target.value } : it))
|
|
@@ -564,13 +565,13 @@ export class Inspector {
|
|
|
564
565
|
"div",
|
|
565
566
|
{ class: "flex justify-end gap-1" },
|
|
566
567
|
h("button", {
|
|
567
|
-
type: "button", title: "Move up", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 disabled:opacity-30", disabled: index === 0, html: icon("up", "w-3.5 h-3.5"), onclick: () => {
|
|
568
|
+
type: "button", title: t("Move up"), class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 disabled:opacity-30", disabled: index === 0, html: icon("up", "w-3.5 h-3.5"), onclick: () => {
|
|
568
569
|
const next = [...items]
|
|
569
570
|
;[next[index - 1], next[index]] = [next[index], next[index - 1]]
|
|
570
571
|
update(next)
|
|
571
572
|
}
|
|
572
573
|
}),
|
|
573
|
-
h("button", { type: "button", title: "Remove", class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-red-600 dark:hover:text-red-400", html: icon("trash", "w-3.5 h-3.5"), onclick: () => update(items.filter((_, i) => i !== index)) })
|
|
574
|
+
h("button", { type: "button", title: t("Remove"), class: "w-6 h-6 flex items-center justify-center rounded text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-red-600 dark:hover:text-red-400", html: icon("trash", "w-3.5 h-3.5"), onclick: () => update(items.filter((_, i) => i !== index)) })
|
|
574
575
|
)
|
|
575
576
|
)
|
|
576
577
|
)
|
|
@@ -578,7 +579,7 @@ export class Inspector {
|
|
|
578
579
|
"div",
|
|
579
580
|
{ class: "space-y-2" },
|
|
580
581
|
rows,
|
|
581
|
-
h("button", { type: "button", class: "w-full rounded-md border border-dashed border-gray-300 dark:border-gray-600 py-1.5 text-xs text-gray-600 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400", onclick: () => update([...items, { ...field.newItem }]) }, "Add")
|
|
582
|
+
h("button", { type: "button", class: "w-full rounded-md border border-dashed border-gray-300 dark:border-gray-600 py-1.5 text-xs text-gray-600 dark:text-gray-300 hover:border-blue-400 hover:text-blue-600 dark:hover:text-blue-400", onclick: () => update([...items, { ...field.newItem }]) }, t("Add"))
|
|
582
583
|
)
|
|
583
584
|
}
|
|
584
585
|
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// marks: Enter or leaving it finishes (finish).
|
|
12
12
|
|
|
13
13
|
import { Color, Decoration, DecorationSet, Editor, Extension, Plugin, PluginKey, StarterKit, TextAlign, TextStyle } from "tess_edit/vendor/tiptap"
|
|
14
|
+
import { t } from "tess_edit/core/i18n"
|
|
14
15
|
import { missingArguments, translationCalls } from "tess_edit/core/translations"
|
|
15
16
|
import { showText } from "tess_edit/ui/canvas"
|
|
16
17
|
import { askText } from "tess_edit/ui/dialog"
|
|
@@ -119,7 +120,7 @@ export class TextEditing {
|
|
|
119
120
|
async makeTranslatable() {
|
|
120
121
|
const tiptap = this.tiptap
|
|
121
122
|
const { selection, doc } = tiptap.state
|
|
122
|
-
if (selection.empty) return this.editor.flash("Select the text to translate first.")
|
|
123
|
+
if (selection.empty) return this.editor.flash(t("Select the text to translate first."))
|
|
123
124
|
// Inside the text: a selection of everything starts before the first paragraph
|
|
124
125
|
const from = Math.max(selection.from, 1)
|
|
125
126
|
const to = Math.min(selection.to, doc.content.size - 1)
|
|
@@ -135,10 +136,10 @@ export class TextEditing {
|
|
|
135
136
|
const tiptap = this.tiptap
|
|
136
137
|
const previous = tiptap.getAttributes("link").href
|
|
137
138
|
const href = await askText(this.editor.root, {
|
|
138
|
-
title: previous ? "Edit link" : "Add link",
|
|
139
|
-
label: "URL",
|
|
139
|
+
title: t(previous ? "Edit link" : "Add link"),
|
|
140
|
+
label: t("URL"),
|
|
140
141
|
value: previous || "https://",
|
|
141
|
-
hint: "Liquid is allowed, e.g. {{ order.url }}",
|
|
142
|
+
hint: t("Liquid is allowed, e.g. {{ order.url }}"),
|
|
142
143
|
remove: Boolean(previous)
|
|
143
144
|
})
|
|
144
145
|
if (href === null || this.tiptap !== tiptap) return tiptap.commands.focus()
|
|
@@ -187,20 +188,20 @@ export class TextEditing {
|
|
|
187
188
|
"select",
|
|
188
189
|
{
|
|
189
190
|
class: "h-7 rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 py-0 pl-1.5 pr-7 text-xs text-gray-800 dark:text-gray-200",
|
|
190
|
-
title: "Paragraph style",
|
|
191
|
+
title: t("Paragraph style"),
|
|
191
192
|
onchange: (event) => {
|
|
192
193
|
const value = Number(event.target.value)
|
|
193
194
|
value ? chain().setHeading({ level: value }).run() : chain().setParagraph().run()
|
|
194
195
|
}
|
|
195
196
|
},
|
|
196
|
-
h("option", { value: "0", selected: !level }, "Paragraph"),
|
|
197
|
-
[1, 2, 3].map((l) => h("option", { value: String(l), selected: level === l },
|
|
197
|
+
h("option", { value: "0", selected: !level }, t("Paragraph")),
|
|
198
|
+
[1, 2, 3].map((l) => h("option", { value: String(l), selected: level === l }, t("Heading %{level}", { level: l })))
|
|
198
199
|
)
|
|
199
200
|
|
|
200
201
|
const currentColor = editor.getAttributes("textStyle").color
|
|
201
202
|
const color = h("input", {
|
|
202
203
|
type: "color",
|
|
203
|
-
title: "Text color",
|
|
204
|
+
title: t("Text color"),
|
|
204
205
|
class: "h-7 w-8 cursor-pointer rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 p-0.5",
|
|
205
206
|
value: /^#[0-9a-f]{6}$/i.test(currentColor || "") ? currentColor : "#000000",
|
|
206
207
|
onchange: (event) => chain().setColor(event.target.value).run()
|
|
@@ -209,28 +210,28 @@ export class TextEditing {
|
|
|
209
210
|
this.toolbar.replaceChildren(...[
|
|
210
211
|
style,
|
|
211
212
|
separator(),
|
|
212
|
-
button("bold", "Bold (⌘B)", editor.isActive("bold"), () => chain().toggleBold().run()),
|
|
213
|
-
button("italic", "Italic (⌘I)", editor.isActive("italic"), () => chain().toggleItalic().run()),
|
|
214
|
-
button("underline", "Underline (⌘U)", editor.isActive("underline"), () => chain().toggleUnderline().run()),
|
|
215
|
-
button("strike", "Strikethrough", editor.isActive("strike"), () => chain().toggleStrike().run()),
|
|
213
|
+
button("bold", t("Bold (⌘B)"), editor.isActive("bold"), () => chain().toggleBold().run()),
|
|
214
|
+
button("italic", t("Italic (⌘I)"), editor.isActive("italic"), () => chain().toggleItalic().run()),
|
|
215
|
+
button("underline", t("Underline (⌘U)"), editor.isActive("underline"), () => chain().toggleUnderline().run()),
|
|
216
|
+
button("strike", t("Strikethrough"), editor.isActive("strike"), () => chain().toggleStrike().run()),
|
|
216
217
|
color,
|
|
217
218
|
separator(),
|
|
218
|
-
button("link", "Link", editor.isActive("link"), () => this.editLink()),
|
|
219
|
-
editor.isActive("link") ? button("unlink", "Remove link", false, () => chain().extendMarkRange("link").unsetLink().run()) : null,
|
|
219
|
+
button("link", t("Link"), editor.isActive("link"), () => this.editLink()),
|
|
220
|
+
editor.isActive("link") ? button("unlink", t("Remove link"), false, () => chain().extendMarkRange("link").unsetLink().run()) : null,
|
|
220
221
|
separator(),
|
|
221
|
-
button("align-left", "Align left", editor.isActive({ textAlign: "left" }), () => chain().setTextAlign("left").run()),
|
|
222
|
-
button("align-center", "Align center", editor.isActive({ textAlign: "center" }), () => chain().setTextAlign("center").run()),
|
|
223
|
-
button("align-right", "Align right", editor.isActive({ textAlign: "right" }), () => chain().setTextAlign("right").run()),
|
|
222
|
+
button("align-left", t("Align left"), editor.isActive({ textAlign: "left" }), () => chain().setTextAlign("left").run()),
|
|
223
|
+
button("align-center", t("Align center"), editor.isActive({ textAlign: "center" }), () => chain().setTextAlign("center").run()),
|
|
224
|
+
button("align-right", t("Align right"), editor.isActive({ textAlign: "right" }), () => chain().setTextAlign("right").run()),
|
|
224
225
|
separator(),
|
|
225
|
-
button("list-bullet", "Bulleted list", editor.isActive("bulletList"), () => chain().toggleBulletList().run()),
|
|
226
|
-
button("list-ordered", "Numbered list", editor.isActive("orderedList"), () => chain().toggleOrderedList().run()),
|
|
226
|
+
button("list-bullet", t("Bulleted list"), editor.isActive("bulletList"), () => chain().toggleBulletList().run()),
|
|
227
|
+
button("list-ordered", t("Numbered list"), editor.isActive("orderedList"), () => chain().toggleOrderedList().run()),
|
|
227
228
|
separator(),
|
|
228
|
-
button("clear", "Clear formatting", false, () => chain().unsetAllMarks().clearNodes().run()),
|
|
229
|
-
this.translating ? button("translate", "Make translatable: keep the selected text as a translation", false, () => this.makeTranslatable()) : null,
|
|
229
|
+
button("clear", t("Clear formatting"), false, () => chain().unsetAllMarks().clearNodes().run()),
|
|
230
|
+
this.translating ? button("translate", t("Make translatable: keep the selected text as a translation"), false, () => this.makeTranslatable()) : null,
|
|
230
231
|
this.menu && this.editor?.variables?.enabled
|
|
231
232
|
? h("button", {
|
|
232
233
|
type: "button",
|
|
233
|
-
title: "Insert a variable",
|
|
234
|
+
title: t("Insert a variable"),
|
|
234
235
|
class: `${BUTTON.replace("w-7", "px-1.5")} whitespace-nowrap font-mono text-xs`,
|
|
235
236
|
onmousedown: (event) => event.preventDefault(),
|
|
236
237
|
onclick: (event) => this.menu.browse(this.adapter, event.currentTarget)
|
|
@@ -321,7 +322,7 @@ function translationChip(view, key, value, unfilled, edit) {
|
|
|
321
322
|
chip.className = unfilled.length ? "tess-t tess-t-missing" : "tess-t"
|
|
322
323
|
chip.contentEditable = "false"
|
|
323
324
|
chip.dataset.tessKey = key
|
|
324
|
-
if (unfilled.length) chip.title =
|
|
325
|
+
if (unfilled.length) chip.title = t("No argument for %{names} in the t filter", { names: unfilled.map((name) => `%{${name}}`).join(", ") })
|
|
325
326
|
showText(chip, value)
|
|
326
327
|
chip.addEventListener("mousedown", (event) => {
|
|
327
328
|
event.preventDefault()
|