tess_edit 0.5.1 → 0.5.2
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 +1 -1
- data/app/javascript/tess_edit/blocks/email.js +1 -1
- data/app/javascript/tess_edit/blocks/fields.js +25 -3
- data/app/javascript/tess_edit/blocks/navbar.js +1 -1
- data/app/javascript/tess_edit/ui/inspector.js +22 -0
- 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: 56237e4ae78a71ad87e395e50e51b32b7d5b45c36643aea13bf39e55fb731dcf
|
|
4
|
+
data.tar.gz: 269a64d4e87297bbd25f3827b3c762b50e29e78d8fdfff86c11a6f950a0eb309
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3063da8d408f7337c482b9e6f0f0bd0a6f5efa04519683a38a96d1e1a2cb4945900210c022d350f946652ffffc33d88b8debe0faeb0676a47a0694e9dbe179a8
|
|
7
|
+
data.tar.gz: 28393958e0d69c307e87b9b1ca9053d75ecc30e200cbe93c2272a4d4ecfdfffd06ced51350598ff89ac2a38d9127f9bf1e7e7fad34cd457db27cfbbb7119e295
|
data/README.md
CHANGED
|
@@ -304,7 +304,7 @@ extendBlock("email", {
|
|
|
304
304
|
|
|
305
305
|
With a `summary` the field shows collapsed to it, with a button to edit it; without one the element always shows. Its values are your form fields, submitted with the form; without the element the field doesn't show. The element moves into Inspect once and stays there, hidden while another block is selected, so your Stimulus controllers in it keep their state. Combining or splitting the panels moves it again: its controllers reconnect then, with the values typed and chosen written into the fields' attributes first. The demo has one at `/?slots=1` (`test/dummy/app/javascript/slots.js`).
|
|
306
306
|
|
|
307
|
-
A select field's `options` can be a function of the editor, `options: (editor) => [...]`, for choices from your app. Give the editor those with `data-tess-edit-options-value` (JSON), which blocks read as `editor.options`.
|
|
307
|
+
A select field's `options` can be a function of the editor, `options: (editor) => [...]`, for choices from your app. Give the editor those with `data-tess-edit-options-value` (JSON), which blocks read as `editor.options`. Font family fields are a select of `editor.options.fonts`: CSS font families as text, `"Maytra"` or `"'EB Garamond', serif"`, or `{ value, label }`; without them, common web fonts (`fields.FONTS`). A font a design has that isn't among them stays selected.
|
|
308
308
|
|
|
309
309
|
## Kits
|
|
310
310
|
|
|
@@ -39,7 +39,7 @@ export default {
|
|
|
39
39
|
{
|
|
40
40
|
title: "Theme",
|
|
41
41
|
fields: [
|
|
42
|
-
{ key: "data.fontFamily", label: "Font family", type: "
|
|
42
|
+
{ key: "data.fontFamily", label: "Font family", type: "font" },
|
|
43
43
|
{ key: "data.fontSize", label: "Font size", type: "size" },
|
|
44
44
|
{ key: "data.lineHeight", label: "Line height", type: "text" },
|
|
45
45
|
{ key: "data.textColor", label: "Text color", type: "color" }
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Field definitions shared by the built-in blocks, and usable by custom ones.
|
|
2
2
|
// A field: { key: "attributes.padding" | "data.subject", label, type, ... }.
|
|
3
|
-
// Types: text, textarea, code, size, color, select, segmented, toggle,
|
|
4
|
-
// spacing, list and slot (an element of the host's); see ui/inspector.js. A
|
|
3
|
+
// Types: text, textarea, code, size, color, select, font, segmented, toggle,
|
|
4
|
+
// spacing, list and slot (an element of the host's); see ui/inspector.js. A
|
|
5
|
+
// font field is a select of the host's fonts, the editor's options.fonts, or
|
|
6
|
+
// FONTS without them. A select's options can be a
|
|
5
7
|
// function of the editor, options(editor), for choices the host gives. A
|
|
6
8
|
// field's hint can be a function of its value, hint(value, node), shown as
|
|
7
9
|
// it's typed (a counter).
|
|
@@ -20,6 +22,26 @@ export const VERTICAL_ALIGN = [
|
|
|
20
22
|
{ value: "bottom", label: "Bottom" }
|
|
21
23
|
]
|
|
22
24
|
|
|
25
|
+
// Fonts every browser and mail client has, with fallbacks
|
|
26
|
+
export const FONTS = [
|
|
27
|
+
{ value: "Arial, Helvetica, sans-serif", label: "Arial" },
|
|
28
|
+
{ value: "Helvetica, Arial, sans-serif", label: "Helvetica" },
|
|
29
|
+
{ value: "Verdana, Geneva, sans-serif", label: "Verdana" },
|
|
30
|
+
{ value: "Tahoma, Geneva, sans-serif", label: "Tahoma" },
|
|
31
|
+
{ value: "'Trebuchet MS', Helvetica, sans-serif", label: "Trebuchet MS" },
|
|
32
|
+
{ value: "Georgia, serif", label: "Georgia" },
|
|
33
|
+
{ value: "'Times New Roman', Times, serif", label: "Times New Roman" },
|
|
34
|
+
{ value: "'Courier New', Courier, monospace", label: "Courier New" }
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
// A font field's options: none (the placeholder, inherited), the host's
|
|
38
|
+
// fonts or FONTS, and a value that is neither, as it is
|
|
39
|
+
export function fontOptions(fonts, value, placeholder = "Default") {
|
|
40
|
+
const options = (fonts?.length ? fonts : FONTS).map((font) => (typeof font === "string" ? { value: font, label: font.split(",")[0].replace(/['"]/g, "").trim() } : font))
|
|
41
|
+
const other = value && !options.some((option) => option.value === value) ? [{ value, label: value }] : []
|
|
42
|
+
return [{ value: "", label: placeholder }, ...options, ...other]
|
|
43
|
+
}
|
|
44
|
+
|
|
23
45
|
export const padding = { key: "attributes.padding", label: "Padding", type: "spacing" }
|
|
24
46
|
export const align = { key: "attributes.align", label: "Align", type: "segmented", options: ALIGN }
|
|
25
47
|
export const background = { key: "attributes.background-color", label: "Background", type: "color" }
|
|
@@ -27,7 +49,7 @@ export const background = { key: "attributes.background-color", label: "Backgrou
|
|
|
27
49
|
export const typography = (extra = []) => ({
|
|
28
50
|
title: "Typography",
|
|
29
51
|
fields: [
|
|
30
|
-
{ key: "attributes.font-family", label: "Font family", type: "
|
|
52
|
+
{ key: "attributes.font-family", label: "Font family", type: "font", placeholder: "Inherit" },
|
|
31
53
|
{ key: "attributes.font-size", label: "Font size", type: "size", placeholder: "13px" },
|
|
32
54
|
{ key: "attributes.line-height", label: "Line height", type: "text", placeholder: "1" },
|
|
33
55
|
{ key: "attributes.letter-spacing", label: "Letter spacing", type: "size" },
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
fields: [
|
|
34
34
|
{ key: "data.color", label: "Color", type: "color" },
|
|
35
35
|
{ key: "data.fontSize", label: "Font size", type: "size" },
|
|
36
|
-
{ key: "data.fontFamily", label: "Font family", type: "
|
|
36
|
+
{ key: "data.fontFamily", label: "Font family", type: "font", placeholder: "Inherit" },
|
|
37
37
|
{ key: "data.linkPadding", label: "Padding", type: "spacing" }
|
|
38
38
|
]
|
|
39
39
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { imageSource } from "tess_edit/core/media"
|
|
18
18
|
import { getBlock, label } from "tess_edit/core/registry"
|
|
19
|
+
import { fontOptions } from "tess_edit/blocks/fields"
|
|
19
20
|
import { find, getValue } from "tess_edit/core/document"
|
|
20
21
|
import { translationCalls } from "tess_edit/core/translations"
|
|
21
22
|
import { loopScope } from "tess_edit/core/variables"
|
|
@@ -227,6 +228,9 @@ export class Inspector {
|
|
|
227
228
|
})
|
|
228
229
|
)
|
|
229
230
|
|
|
231
|
+
case "font":
|
|
232
|
+
return this.font(field, value, set)
|
|
233
|
+
|
|
230
234
|
case "segmented":
|
|
231
235
|
return h(
|
|
232
236
|
"div",
|
|
@@ -476,6 +480,24 @@ export class Inspector {
|
|
|
476
480
|
input.textarea.focus()
|
|
477
481
|
}
|
|
478
482
|
|
|
483
|
+
// The host's fonts (options.fonts) or common ones, each shown in itself
|
|
484
|
+
font(field, value, set) {
|
|
485
|
+
return h(
|
|
486
|
+
"select",
|
|
487
|
+
{
|
|
488
|
+
class: `${INPUT} pr-7`,
|
|
489
|
+
style: value ? `font-family: ${value}` : "",
|
|
490
|
+
onchange: (event) => {
|
|
491
|
+
event.target.style.fontFamily = event.target.value
|
|
492
|
+
set(event.target.value)
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
fontOptions(this.editor.options?.fonts, value, field.placeholder).map((option) =>
|
|
496
|
+
h("option", { value: option.value, selected: option.value === (value || ""), style: option.value ? `font-family: ${option.value}` : "" }, option.label)
|
|
497
|
+
)
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
|
|
479
501
|
color(value, set) {
|
|
480
502
|
const text = h("input", {
|
|
481
503
|
type: "text", class: `${INPUT} font-mono text-xs`, value, placeholder: "Default", oninput: (event) => {
|
data/lib/tess_edit/version.rb
CHANGED