@1doc/1ds-vue 2.11.0 → 2.11.1
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.
- package/CHANGELOG.md +16 -0
- package/dist/index.css +1 -1
- package/dist/index.mjs +1 -6
- package/dist/index.umd.js +1 -1
- package/package.json +3 -3
- package/src/teste/rich-text-editor-estilo-de-texto.test.mjs +4 -4
- package/src/utils/html-seguro.ts +1 -1
- package/src/teste/token-primary-lighter.test.mjs +0 -48
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1doc/1ds-vue",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
4
4
|
"main": "dist/index.umd.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"**/*.css"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"vite": "^7.3.1",
|
|
31
31
|
"vue": "^3.0.0",
|
|
32
32
|
"vue-tsc": "^2.0.0",
|
|
33
|
-
"@1doc/1ds-tokens": "0.
|
|
34
|
-
"@1doc/1ds-core": "2.11.
|
|
33
|
+
"@1doc/1ds-tokens": "0.7.0",
|
|
34
|
+
"@1doc/1ds-core": "2.11.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@1doc/1ds-tokens": ">=0.1.0",
|
|
@@ -51,14 +51,14 @@ test("cada ferramenta abre um painel nomeado; Fechar fecha", async () => {
|
|
|
51
51
|
assert.equal(m.raiz.querySelector('[role="group"]'), null);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
test("a fonte
|
|
54
|
+
test("a fonte do DS embrulha o texto selecionado num span com o token", async () => {
|
|
55
55
|
const m = await abrir({ toolbar: ["fontFamily"] });
|
|
56
56
|
selecionar(m);
|
|
57
57
|
await clicar(botao(m, "Fonte"));
|
|
58
58
|
await clicar(m.raiz.querySelector('[role="combobox"]'));
|
|
59
|
-
const
|
|
60
|
-
await clicar(
|
|
61
|
-
assert.deepEqual(chamadas.at(-1), ["insertHTML", false, '<span style="font-family: var(--umds-semantic-font-family-
|
|
59
|
+
const base = [...m.raiz.querySelectorAll('[role="option"]')].find((o) => o.textContent.includes("Padrão"));
|
|
60
|
+
await clicar(base);
|
|
61
|
+
assert.deepEqual(chamadas.at(-1), ["insertHTML", false, '<span style="font-family: var(--umds-semantic-font-family-base);">Parecer</span>']);
|
|
62
62
|
assert.equal(m.raiz.querySelector('[role="group"]'), null, "o painel fecha");
|
|
63
63
|
});
|
|
64
64
|
|
package/src/utils/html-seguro.ts
CHANGED
|
@@ -51,7 +51,7 @@ export const normalizarEndereco = (bruto: string): string => {
|
|
|
51
51
|
/** Cor, tamanho e família de fonte só valem como TOKEN do DS: `var(--umds-...)`. Cor em hex, rgb ou nome sai. */
|
|
52
52
|
const COR_TOKEN = /^var\(--umds-(?:primitive|semantic)-[a-z0-9-]+\)$/;
|
|
53
53
|
const TAMANHO_TOKEN = /^var\(--umds-primitive-font-size-[a-z0-9]+\)$/;
|
|
54
|
-
const FAMILIA_TOKEN = /^var\(--umds-(?:primitive|semantic)-font-family-
|
|
54
|
+
const FAMILIA_TOKEN = /^var\(--umds-(?:primitive|semantic)-font-family-base\)$/;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Declaração de estilo de texto que o editor aceita: `color`, `font-size` e `font-family`,
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/** Token primary-lighter (o fundo azul bem claro do CrisDoc): existe no semântico e em todos os temas, e o texto passa nele. */
|
|
2
|
-
import { test } from "node:test";
|
|
3
|
-
import assert from "node:assert/strict";
|
|
4
|
-
import { readFileSync, readdirSync } from "node:fs";
|
|
5
|
-
import { resolve } from "node:path";
|
|
6
|
-
|
|
7
|
-
const css = resolve(process.cwd(), "../tokens/dist/css");
|
|
8
|
-
const ler = (arquivo) => readFileSync(resolve(css, arquivo), "utf8");
|
|
9
|
-
const cor = (texto, nome) => texto.match(new RegExp("--umds-theme-" + nome + ":\\s*(#[0-9A-Fa-f]{6})"))[1];
|
|
10
|
-
const luz = (hex) => {
|
|
11
|
-
const c = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4));
|
|
12
|
-
return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
|
|
13
|
-
};
|
|
14
|
-
const contraste = (a, b) => {
|
|
15
|
-
const [x, y] = [luz(a), luz(b)].sort((m, n) => n - m);
|
|
16
|
-
return (x + 0.05) / (y + 0.05);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
test("o semântico aponta para o token do tema", () => {
|
|
20
|
-
assert.match(ler("semantic.css"), /--umds-semantic-color-primary-lighter:\s*var\(--umds-theme-primary-lighter\)/);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("o tema claro 1doc é o #EDF2FF do CrisDoc, e o escuro tem o seu", () => {
|
|
24
|
-
assert.equal(cor(ler("theme-1doc.css"), "primary-lighter").toUpperCase(), "#EDF2FF");
|
|
25
|
-
assert.ok(cor(ler("theme-1doc-dark.css"), "primary-lighter"));
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("todo tema tem o primary-lighter (sem ele a cor herdaria a do tema azul)", () => {
|
|
29
|
-
const temas = readdirSync(css).filter((f) => /^theme-.*\.css$/.test(f));
|
|
30
|
-
assert.ok(temas.length >= 13, "esperava os 13 temas");
|
|
31
|
-
for (const f of temas) assert.ok(cor(ler(f), "primary-lighter"), f);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("é mais claro que o primary-light nos temas claros e o texto escuro passa de 4,5:1 sobre ele", () => {
|
|
35
|
-
for (const f of ["theme-1doc.css"]) {
|
|
36
|
-
const t = ler(f);
|
|
37
|
-
assert.ok(luz(cor(t, "primary-lighter")) > luz(cor(t, "primary-light")), f);
|
|
38
|
-
assert.ok(contraste(cor(t, "neutral-dark-pure"), cor(t, "primary-lighter")) >= 4.5, f);
|
|
39
|
-
assert.ok(contraste(cor(t, "primary-dark"), cor(t, "primary-lighter")) >= 4.5, f);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("nos temas escuro e de alto contraste o texto do tema passa de 4,5:1 sobre ele", () => {
|
|
44
|
-
for (const f of ["theme-1doc-dark.css", "theme-1doc-high-contrast.css"]) {
|
|
45
|
-
const t = ler(f);
|
|
46
|
-
assert.ok(contraste(cor(t, "neutral-dark-pure"), cor(t, "primary-lighter")) >= 4.5, f);
|
|
47
|
-
}
|
|
48
|
-
});
|