@tooark/wysiwyg 1.2.2 → 1.4.0

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ---
11
11
 
12
- ## Contents
12
+ ## 📑 Contents
13
13
 
14
14
  - [Overview](#-overview)
15
15
  - [Installation](#-installation)
@@ -18,6 +18,8 @@
18
18
  - [Usage examples](#-usage-examples)
19
19
  - [Dependencies](#-dependencies)
20
20
  - [Contributing](#-contributing)
21
+ - [Help & Security](#-help--security)
22
+ - [Support](#-support)
21
23
  - [License](#-license)
22
24
 
23
25
  ---
@@ -53,6 +55,8 @@ import { registerTooarkWysiwyg } from "@tooark/wysiwyg";
53
55
  registerTooarkWysiwyg();
54
56
  ```
55
57
 
58
+ In React, Vue or Angular use the tag directly (the framework READMEs show how); a JS property the framework assigns before this call, such as `content` bound on the tag, is applied when the element upgrades, so the order does not matter.
59
+
56
60
  Pick the toolbar groups per instance with `toolbar` and, to enable images and videos, assign the `uploadFile` property (a function that stores the file and resolves `{ src, alt?, title?, poster? }`).
57
61
 
58
62
  ---
@@ -61,14 +65,16 @@ Pick the toolbar groups per instance with `toolbar` and, to enable images and vi
61
65
 
62
66
  ### `ark-wysiwyg-editor`
63
67
 
64
- - Attributes: `toolbar` (groups and/or items, comma-separated; `all`; `none`; default `style,marks,lists,link,blocks,clear,history`), `theme` (`auto` | `light` | `dark`), `placeholder`, `editable="false"`, `lang` (`en` | `pt` | `es`, or `custom` with `locale-json`), `colors`/`highlights` (JSON arrays of CSS colors: hex, a color name or `rgb()`/`hsl()`; others, such as `oklch()` or `var()`, are dropped), `max-file-size` (bytes, default 10 MiB).
68
+ - Attributes: `toolbar` (groups and/or items, comma-separated; `all`; `none`; default `style,marks,lists,link,blocks,clear,history`), `theme` (`auto` | `light` | `dark`), `placeholder`, `editable="false"`, `lang` (`en` | `pt` | `es`, or `custom` with `locale-json`), `colors`/`highlights` (JSON arrays of CSS colors: hex, a color name or `rgb()`/`hsl()`; others, such as `oklch()` or `var()`, are dropped), `max-file-size` (bytes, default 10 MiB), `aria-label` (names the editable content, Tiptap's `role="textbox"`), `testid`.
65
69
  - Toolbar items, to mix with the groups in `toolbar` (unknown names are ignored; `image`/`video` only with `uploadFile`): `heading` (block style select), `heading-1` to `heading-4`, `bold`, `italic`, `underline`, `strike`, `code`, `text-color`, `highlight`, `align-left`, `align-center`, `align-right`, `align-justify`, `bullet-list`, `ordered-list`, `outdent`, `indent`, `link`, `image`, `video`, `blockquote`, `horizontal-rule`, `clear-format`, `undo`, `redo`.
66
- - Properties: `content` (Tiptap JSON, sanitized; setting it does not emit `ark-wysiwyg-change` and stays out of the undo history), `uploadFile`, `colors`, `highlights`, `resolvedTheme`, `editor` (the Tiptap instance); `insertFile(file)`.
70
+ - Properties: `content` (Tiptap JSON, sanitized; setting it does not emit `ark-wysiwyg-change` and stays out of the undo history), `uploadFile`, `colors`, `highlights` (an array, or the attribute's JSON string, which is what a framework assigns), `resolvedTheme`, `editor` (the Tiptap instance); `insertFile(file)`.
67
71
  - Events: `ark-wysiwyg-change` (`detail` = JSON), `ark-wysiwyg-upload-error` (`detail: { reason, file, error? }`, reasons `no-uploader`, `unsupported-type`, `too-large`, `invalid-src`, `failed`).
72
+ - Hooks: the root carries `data-ark="wysiwyg-editor"`, the toolbar `wysiwyg-editor-toolbar` and the editable content `wysiwyg-editor-content`; with `testid`, `data-testid` is the testid and `<testid>-toolbar`/`<testid>-content`.
68
73
 
69
74
  ### `ark-wysiwyg-viewer`
70
75
 
71
- - Attributes: `theme`. Properties: `content`, `resolvedTheme`.
76
+ - Attributes: `theme`, `testid`. Properties: `content`, `resolvedTheme`.
77
+ - Hooks: the root carries `data-ark="wysiwyg-viewer"` and the content `wysiwyg-viewer-content`, with the `testid` as in the editor.
72
78
 
73
79
  ### Engine and helpers
74
80
 
@@ -126,7 +132,7 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
126
132
  | [`@tiptap/extension-text-style`](https://www.npmjs.com/package/@tiptap/extension-text-style) | ^3.31.3 | Text style mark with color |
127
133
  | [`@tiptap/pm`](https://www.npmjs.com/package/@tiptap/pm) | ^3.31.3 | ProseMirror packages used by Tiptap |
128
134
  | [`@tiptap/starter-kit`](https://www.npmjs.com/package/@tiptap/starter-kit) | ^3.31.3 | Base nodes and marks (paragraph, heading, lists, bold, link, underline…) |
129
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.2 | Design tokens (colors, sizes, motion) and primitive types |
135
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.4.0 | Design tokens (colors, sizes, motion) and primitive types |
130
136
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
131
137
 
132
138
  ---
@@ -137,6 +143,24 @@ Contributions are welcome! Open issues and pull requests in the [Tooark/web-comp
137
143
 
138
144
  ---
139
145
 
146
+ ## 🆘 Help & Security
147
+
148
+ - ❓ **Questions, bugs, feature ideas** — see [SUPPORT.md](https://github.com/Tooark/web-components/blob/main/SUPPORT.md) for the right channel
149
+ - 🔒 **Security vulnerabilities** — do **not** open a public issue; follow [SECURITY.md](https://github.com/Tooark/web-components/blob/main/SECURITY.md)
150
+
151
+ ---
152
+
153
+ ## 💖 Support
154
+
155
+ If this project helps your workflow, consider supporting its development:
156
+
157
+ - 💙 [GitHub Sponsors](https://github.com/sponsors/paulosfjunior)
158
+ - ☕ [Ko-fi](https://ko-fi.com/paulosfjunior)
159
+
160
+ Every contribution helps keep the project maintained and improving. Thank you! 🙏
161
+
162
+ ---
163
+
140
164
  ## 📄 License
141
165
 
142
166
  This project is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/Tooark/web-components/blob/main/LICENSE) file for details.
package/README.pt-BR.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ---
11
11
 
12
- ## Conteúdo
12
+ ## 📑 Conteúdo
13
13
 
14
14
  - [Visão Geral](#-visão-geral)
15
15
  - [Instalação](#-instalação)
@@ -18,6 +18,8 @@
18
18
  - [Exemplos de Uso](#-exemplos-de-uso)
19
19
  - [Dependências](#-dependências)
20
20
  - [Contribuição](#-contribuição)
21
+ - [Ajuda & Segurança](#-ajuda--segurança)
22
+ - [Apoie](#-apoie)
21
23
  - [Licença](#-licença)
22
24
 
23
25
  ---
@@ -53,6 +55,8 @@ import { registerTooarkWysiwyg } from "@tooark/wysiwyg";
53
55
  registerTooarkWysiwyg();
54
56
  ```
55
57
 
58
+ Em React, Vue ou Angular use a tag diretamente (os READMEs dos wrappers mostram como); uma propriedade JS que o framework atribui antes desta chamada, como `content` ligada na tag, é aplicada quando o elemento faz o upgrade, então a ordem não importa.
59
+
56
60
  Escolha os grupos da toolbar por instância com `toolbar` e, para ligar imagens e vídeos, atribua a propriedade `uploadFile` (uma função que guarda o arquivo e resolve `{ src, alt?, title?, poster? }`).
57
61
 
58
62
  ---
@@ -61,14 +65,16 @@ Escolha os grupos da toolbar por instância com `toolbar` e, para ligar imagens
61
65
 
62
66
  ### `ark-wysiwyg-editor`
63
67
 
64
- - Atributos: `toolbar` (grupos e/ou itens separados por vírgula; `all`; `none`; padrão `style,marks,lists,link,blocks,clear,history`), `theme` (`auto` | `light` | `dark`), `placeholder`, `editable="false"`, `lang` (`en` | `pt` | `es`, ou `custom` com `locale-json`), `colors`/`highlights` (arrays JSON de cores CSS: hex, nome de cor ou `rgb()`/`hsl()`; as demais, como `oklch()` ou `var()`, são descartadas), `max-file-size` (bytes, padrão 10 MiB).
68
+ - Atributos: `toolbar` (grupos e/ou itens separados por vírgula; `all`; `none`; padrão `style,marks,lists,link,blocks,clear,history`), `theme` (`auto` | `light` | `dark`), `placeholder`, `editable="false"`, `lang` (`en` | `pt` | `es`, ou `custom` com `locale-json`), `colors`/`highlights` (arrays JSON de cores CSS: hex, nome de cor ou `rgb()`/`hsl()`; as demais, como `oklch()` ou `var()`, são descartadas), `max-file-size` (bytes, padrão 10 MiB), `aria-label` (nomeia o conteúdo editável, o `role="textbox"` do Tiptap), `testid`.
65
69
  - Itens da toolbar, para combinar com os grupos em `toolbar` (nomes desconhecidos são ignorados; `image`/`video` só com `uploadFile`): `heading` (seletor de estilo do bloco), `heading-1` a `heading-4`, `bold`, `italic`, `underline`, `strike`, `code`, `text-color`, `highlight`, `align-left`, `align-center`, `align-right`, `align-justify`, `bullet-list`, `ordered-list`, `outdent`, `indent`, `link`, `image`, `video`, `blockquote`, `horizontal-rule`, `clear-format`, `undo`, `redo`.
66
- - Propriedades: `content` (JSON do Tiptap, sanitizado; atribuir não emite `ark-wysiwyg-change` e fica fora do histórico), `uploadFile`, `colors`, `highlights`, `resolvedTheme`, `editor` (a instância do Tiptap); `insertFile(file)`.
70
+ - Propriedades: `content` (JSON do Tiptap, sanitizado; atribuir não emite `ark-wysiwyg-change` e fica fora do histórico), `uploadFile`, `colors`, `highlights` (um array, ou a string JSON do atributo, que é o que um framework atribui), `resolvedTheme`, `editor` (a instância do Tiptap); `insertFile(file)`.
67
71
  - Eventos: `ark-wysiwyg-change` (`detail` = JSON), `ark-wysiwyg-upload-error` (`detail: { reason, file, error? }`, motivos `no-uploader`, `unsupported-type`, `too-large`, `invalid-src`, `failed`).
72
+ - Hooks: a raiz leva `data-ark="wysiwyg-editor"`, a toolbar `wysiwyg-editor-toolbar` e o conteúdo editável `wysiwyg-editor-content`; com `testid`, o `data-testid` é o testid e `<testid>-toolbar`/`<testid>-content`.
68
73
 
69
74
  ### `ark-wysiwyg-viewer`
70
75
 
71
- - Atributos: `theme`. Propriedades: `content`, `resolvedTheme`.
76
+ - Atributos: `theme`, `testid`. Propriedades: `content`, `resolvedTheme`.
77
+ - Hooks: a raiz leva `data-ark="wysiwyg-viewer"` e o conteúdo `wysiwyg-viewer-content`, com o `testid` como no editor.
72
78
 
73
79
  ### Engine e helpers
74
80
 
@@ -126,7 +132,7 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
126
132
  | [`@tiptap/extension-text-style`](https://www.npmjs.com/package/@tiptap/extension-text-style) | ^3.31.3 | Marca de estilo de texto com cor |
127
133
  | [`@tiptap/pm`](https://www.npmjs.com/package/@tiptap/pm) | ^3.31.3 | Pacotes ProseMirror usados pelo Tiptap |
128
134
  | [`@tiptap/starter-kit`](https://www.npmjs.com/package/@tiptap/starter-kit) | ^3.31.3 | Nós e marcas base (parágrafo, título, listas, negrito, link, sublinhado…) |
129
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.2 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
135
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.4.0 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
130
136
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
131
137
 
132
138
  ---
@@ -137,6 +143,24 @@ Contribuições são bem-vindas! Abra issues e pull requests no repositório [To
137
143
 
138
144
  ---
139
145
 
146
+ ## 🆘 Ajuda & Segurança
147
+
148
+ - ❓ **Dúvidas, bugs e ideias** — veja o [SUPPORT.md](https://github.com/Tooark/web-components/blob/main/SUPPORT.md) para escolher o canal certo
149
+ - 🔒 **Vulnerabilidades de segurança** — **não** abra issue pública; siga o [SECURITY.md](https://github.com/Tooark/web-components/blob/main/SECURITY.md)
150
+
151
+ ---
152
+
153
+ ## 💖 Apoie
154
+
155
+ Se este projeto ajuda no seu dia a dia, considere apoiar o desenvolvimento:
156
+
157
+ - 💙 [GitHub Sponsors](https://github.com/sponsors/paulosfjunior)
158
+ - ☕ [Ko-fi](https://ko-fi.com/paulosfjunior)
159
+
160
+ Cada contribuição ajuda a manter o projeto ativo e em evolução. Obrigado! 🙏
161
+
162
+ ---
163
+
140
164
  ## 📄 Licença
141
165
 
142
166
  Este projeto está licenciado sob a licença Apache 2.0. Veja o arquivo [LICENSE](https://github.com/Tooark/web-components/blob/main/LICENSE) para mais detalhes.
package/dist/index.cjs CHANGED
@@ -242,6 +242,8 @@ function createInstance(element, options) {
242
242
  extensions: createWysiwygExtensions({ editable: options.editable, placeholder: options.placeholder }),
243
243
  content: EMPTY_DOC,
244
244
  editorProps: {
245
+ // O Tiptap já põe role="textbox" no conteúdo editável; o nome acessível vai junto, só quando o app dá um.
246
+ ...(options.label ? { attributes: { "aria-label": options.label } } : {}),
245
247
  handlePaste: (_view, event) => {
246
248
  const files = filesOf(event.clipboardData?.files);
247
249
  // Planilhas e editores copiam o texto junto de arquivos que não são mídia: aí o texto vence e cola normal.
@@ -356,6 +358,7 @@ function createWysiwygEditor(element, options = {}) {
356
358
  content: options.content,
357
359
  theme: options.theme,
358
360
  placeholder: options.placeholder,
361
+ label: options.label,
359
362
  editable: options.editable ?? true,
360
363
  uploadFile: options.uploadFile,
361
364
  maxFileSize: options.maxFileSize,
@@ -843,6 +846,48 @@ const ARK_WYSIWYG_DEFAULT_TOOLBAR = [
843
846
  const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
844
847
  } : HTMLElement;
845
848
 
849
+ // Mesmos hooks de E2E de @tooark/web-components (este pacote não depende dele): `data-ark` estático em cada parte e,
850
+ // com `testid` no host, `data-testid` na parte principal e sufixado nas demais.
851
+ /** Marca `el` com `data-ark="<componente>[-parte]"` e, com `testid` no host, `data-testid="<testid>[-parte]"`. */
852
+ function applyTestHooks(host, component, el, part) {
853
+ const suffix = part ? `-${part}` : "";
854
+ el.setAttribute("data-ark", `${component}${suffix}`);
855
+ const testid = host.getAttribute("testid");
856
+ if (testid) {
857
+ el.setAttribute("data-testid", `${testid}${suffix}`);
858
+ }
859
+ else {
860
+ el.removeAttribute("data-testid");
861
+ }
862
+ }
863
+
864
+ // Um framework (ou o app) pode gravar uma propriedade no elemento antes de registerTooark*() defini-lo: sem a classe,
865
+ // `el.rows = x` vira uma propriedade própria do nó, que depois do upgrade esconde o setter da classe e o valor nunca
866
+ // chega ao componente. Ao conectar, toda propriedade própria que tem setter na classe é retirada e regravada por ele,
867
+ // na ordem em que foi gravada. Os campos da própria classe e o que os frameworks penduram no nó (chaves internas do
868
+ // React e do Vue) não têm setter e ficam como estão.
869
+ /** Reaplica pelo setter da classe as propriedades gravadas no nó antes de o elemento ser registrado. */
870
+ function upgradeProperties(element) {
871
+ const target = element;
872
+ for (const name of Object.keys(element)) {
873
+ if (!hasSetter(Object.getPrototypeOf(element), name))
874
+ continue;
875
+ const value = target[name];
876
+ delete target[name];
877
+ target[name] = value;
878
+ }
879
+ }
880
+ // Procura o acessor na cadeia de protótipos até o HTMLElement: as propriedades nativas nunca viram propriedade própria,
881
+ // porque o nó já é um HTMLElement antes do registro.
882
+ function hasSetter(prototype, name) {
883
+ for (let proto = prototype; proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
884
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
885
+ if (descriptor)
886
+ return typeof descriptor.set === "function";
887
+ }
888
+ return false;
889
+ }
890
+
846
891
  const headingAction = (level) => ({
847
892
  icon: "bold",
848
893
  label: "heading",
@@ -989,9 +1034,11 @@ let popoverSeq = 0;
989
1034
  * `locale-json` (rótulos), `toolbar` (grupos e/ou itens separados por vírgula,
990
1035
  * `all`, ou "none"/"false" para ocultar; padrão: style, marks, lists, link,
991
1036
  * blocks, clear, history), `colors` e `highlights` (JSON com a paleta),
992
- * `max-file-size` (bytes). Propriedade `uploadFile`: sem ela, imagem e vídeo
993
- * não aparecem na toolbar e arquivos colados ou arrastados são recusados
994
- * (`ark-wysiwyg-upload-error`), nunca embutidos em base64.
1037
+ * `max-file-size` (bytes), `aria-label` (vai para o conteúdo editável, o
1038
+ * `role="textbox"`) e `testid` (`data-ark="wysiwyg-editor"` na raiz, com as
1039
+ * partes `-toolbar` e `-content`). Propriedade `uploadFile`: sem ela, imagem
1040
+ * e vídeo não aparecem na toolbar e arquivos colados ou arrastados são
1041
+ * recusados (`ark-wysiwyg-upload-error`), nunca embutidos em base64.
995
1042
  */
996
1043
  class ArkWysiwygEditor extends HTMLElementBase {
997
1044
  constructor() {
@@ -1059,7 +1106,9 @@ class ArkWysiwygEditor extends HTMLElementBase {
1059
1106
  "locale-json",
1060
1107
  "colors",
1061
1108
  "highlights",
1062
- "max-file-size"
1109
+ "max-file-size",
1110
+ "aria-label",
1111
+ "testid"
1063
1112
  ];
1064
1113
  }
1065
1114
  /** Conteúdo do editor como JSON do Tiptap. Atribuir substitui (sanitizado) sem disparar `ark-wysiwyg-change`. */
@@ -1102,6 +1151,8 @@ class ArkWysiwygEditor extends HTMLElementBase {
1102
1151
  return this.instance?.editor ?? null;
1103
1152
  }
1104
1153
  connectedCallback() {
1154
+ // Gravadas antes do registro: o setter guarda e só a montagem abaixo constrói.
1155
+ upgradeProperties(this);
1105
1156
  ensureWysiwygStyles();
1106
1157
  this.build();
1107
1158
  }
@@ -1121,6 +1172,10 @@ class ArkWysiwygEditor extends HTMLElementBase {
1121
1172
  this.syncToolbar();
1122
1173
  return;
1123
1174
  }
1175
+ if (name === "testid") {
1176
+ this.applyHooks();
1177
+ return;
1178
+ }
1124
1179
  // placeholder, toolbar, rótulos, paletas e limite exigem reconstrução.
1125
1180
  this.build();
1126
1181
  }
@@ -1150,7 +1205,12 @@ class ArkWysiwygEditor extends HTMLElementBase {
1150
1205
  }
1151
1206
  }
1152
1207
  writePalette(name, value) {
1153
- if (Array.isArray(value)) {
1208
+ // Uma string é o JSON do atributo (React 19 e Vue gravam a prop como propriedade): vai como está, e a leitura
1209
+ // filtra as cores inválidas.
1210
+ if (typeof value === "string") {
1211
+ this.setAttribute(name, value);
1212
+ }
1213
+ else if (Array.isArray(value)) {
1154
1214
  this.setAttribute(name, JSON.stringify(value.filter(isSafeColor)));
1155
1215
  }
1156
1216
  else {
@@ -1224,6 +1284,7 @@ class ArkWysiwygEditor extends HTMLElementBase {
1224
1284
  content: this.pendingContent,
1225
1285
  theme: this.getTheme(),
1226
1286
  placeholder: this.getAttribute("placeholder") || undefined,
1287
+ label: this.getAttribute("aria-label") || undefined,
1227
1288
  editable: this.isEditable(),
1228
1289
  uploadFile: this.uploader ?? undefined,
1229
1290
  maxFileSize: this.getMaxFileSize(),
@@ -1248,8 +1309,18 @@ class ArkWysiwygEditor extends HTMLElementBase {
1248
1309
  this.instance.editor.on("transaction", this.syncToolbar);
1249
1310
  this.syncToolbar();
1250
1311
  this.root.setAttribute("data-ark-theme", this.instance.resolvedTheme());
1312
+ this.applyHooks();
1251
1313
  this.syncThemeObserver();
1252
1314
  }
1315
+ // Raiz, toolbar e conteúdo editável levam os hooks de E2E, como os componentes de @tooark/web-components.
1316
+ applyHooks() {
1317
+ if (!this.root || !this.instance)
1318
+ return;
1319
+ applyTestHooks(this, "wysiwyg-editor", this.root);
1320
+ if (this.toolbarEl)
1321
+ applyTestHooks(this, "wysiwyg-editor", this.toolbarEl, "toolbar");
1322
+ applyTestHooks(this, "wysiwyg-editor", this.instance.editor.view.dom, "content");
1323
+ }
1253
1324
  // Em `auto`, a troca de tema da página re-resolve o tema do editor; com tema fixo não há o que observar.
1254
1325
  syncThemeObserver() {
1255
1326
  this.disposeTheme?.();
@@ -1608,7 +1679,8 @@ ArkWysiwygEditor.tagName = "ark-wysiwyg-editor";
1608
1679
  * sanitizado ao entrar (`sanitizeWysiwygContent`), sem injetar HTML
1609
1680
  * arbitrário; links abrem em nova aba com `rel="noopener noreferrer nofollow"`.
1610
1681
  *
1611
- * Conteúdo via propriedade `content` (JSON do Tiptap). Atributo: `theme`.
1682
+ * Conteúdo via propriedade `content` (JSON do Tiptap). Atributos: `theme` e
1683
+ * `testid` (`data-ark="wysiwyg-viewer"` na raiz e `-content` no conteúdo).
1612
1684
  */
1613
1685
  class ArkWysiwygViewer extends HTMLElementBase {
1614
1686
  constructor() {
@@ -1620,7 +1692,7 @@ class ArkWysiwygViewer extends HTMLElementBase {
1620
1692
  this.disposeTheme = null;
1621
1693
  }
1622
1694
  static get observedAttributes() {
1623
- return ["theme"];
1695
+ return ["theme", "testid"];
1624
1696
  }
1625
1697
  /** Conteúdo a renderizar como JSON do Tiptap. */
1626
1698
  get content() {
@@ -1635,6 +1707,7 @@ class ArkWysiwygViewer extends HTMLElementBase {
1635
1707
  return this.instance?.resolvedTheme() ?? null;
1636
1708
  }
1637
1709
  connectedCallback() {
1710
+ upgradeProperties(this);
1638
1711
  ensureWysiwygStyles();
1639
1712
  this.build();
1640
1713
  }
@@ -1648,6 +1721,8 @@ class ArkWysiwygViewer extends HTMLElementBase {
1648
1721
  this.applyTheme(this.getTheme());
1649
1722
  this.syncThemeObserver();
1650
1723
  }
1724
+ if (name === "testid")
1725
+ this.applyHooks();
1651
1726
  }
1652
1727
  getTheme() {
1653
1728
  const value = (this.getAttribute("theme") || "auto").toLowerCase();
@@ -1672,8 +1747,16 @@ class ArkWysiwygViewer extends HTMLElementBase {
1672
1747
  theme: this.getTheme()
1673
1748
  });
1674
1749
  this.root.setAttribute("data-ark-theme", this.instance.resolvedTheme());
1750
+ this.applyHooks();
1675
1751
  this.syncThemeObserver();
1676
1752
  }
1753
+ // Raiz e conteúdo levam os hooks de E2E, como os componentes de @tooark/web-components.
1754
+ applyHooks() {
1755
+ if (!this.root || !this.instance)
1756
+ return;
1757
+ applyTestHooks(this, "wysiwyg-viewer", this.root);
1758
+ applyTestHooks(this, "wysiwyg-viewer", this.instance.editor.view.dom, "content");
1759
+ }
1677
1760
  // Em `auto`, a troca de tema da página re-resolve o tema do viewer; com tema fixo não há o que observar.
1678
1761
  syncThemeObserver() {
1679
1762
  this.disposeTheme?.();