@tooark/wysiwyg 1.0.1 → 1.2.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
@@ -26,10 +26,10 @@
26
26
 
27
27
  The `@tooark/wysiwyg` package provides:
28
28
 
29
- - content as Tiptap JSON (never raw HTML), sanitized on the way in by `sanitizeWysiwygContent`: unknown nodes and marks dropped, `href`/`src`/`poster` restricted to http(s), mailto, tel or relative paths, colors validated;
29
+ - content as Tiptap JSON (never raw HTML), sanitized on the way in by `sanitizeWysiwygContent`: unknown nodes and marks dropped, `href`/`src`/`poster` restricted to http(s), mailto, tel or a relative path starting with `/`, `#`, `?`, `./` or `../` (`uploads/x.png` is refused), colors validated (hex, a CSS color name or `rgb()`/`hsl()`);
30
30
  - toolbar built from opt-in groups (`style`, `marks`, `color`, `align`, `lists`, `link`, `media`, `blocks`, `clear`, `history`; `all`, `none`), `role="toolbar"` with one tab stop, labels in `en`/`pt`/`es`;
31
31
  - links with a URL popover (unsafe schemes refused), text color and highlight palettes, alignment, list indentation, clear formatting;
32
- - images and videos only through the `uploadFile(file, kind)` hook — your storage, the JSON keeps the URL, never base64; without the hook the `media` group does not render and pasted/dropped files are refused;
32
+ - images and videos only through the `uploadFile(file, kind)` hook — your storage, the JSON keeps the URL, never base64; without the hook the `media` group does not render, pasted/dropped files are refused and `<img>`/`<video>` are stripped from pasted HTML; with it, pasted `<img>`/`<video>` only enter with an allowed `src`; pasted/dropped files that are not images or videos are refused with `unsupported-type`;
33
33
  - the same schema in the viewer, which renders links with `target="_blank"` and `rel="noopener noreferrer nofollow"`;
34
34
  - `createWysiwygEditor`/`createWysiwygViewer` engine for use without the elements; theme follows the page (`theme="auto"`).
35
35
 
@@ -38,7 +38,7 @@ The `@tooark/wysiwyg` package provides:
38
38
  ## 🔧 Installation
39
39
 
40
40
  ```bash
41
- pnpm add @tooark/wysiwyg # Tiptap is bundled as a dependency
41
+ pnpm add @tooark/wysiwyg # Tiptap is installed as a dependency
42
42
  ```
43
43
 
44
44
  ---
@@ -61,8 +61,9 @@ Pick the toolbar groups per instance with `toolbar` and, to enable images and vi
61
61
 
62
62
  ### `ark-wysiwyg-editor`
63
63
 
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`) and `locale-json`, `colors`/`highlights` (JSON arrays of CSS colors), `max-file-size` (bytes, default 10 MiB).
65
- - Properties: `content` (Tiptap JSON, sanitized; setting it does not emit `change` and stays out of the undo history), `uploadFile`, `colors`, `highlights`, `resolvedTheme`, `editor` (the Tiptap instance); `insertFile(file)`.
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).
65
+ - 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)`.
66
67
  - Events: `ark-wysiwyg-change` (`detail` = JSON), `ark-wysiwyg-upload-error` (`detail: { reason, file, error? }`, reasons `no-uploader`, `unsupported-type`, `too-large`, `invalid-src`, `failed`).
67
68
 
68
69
  ### `ark-wysiwyg-viewer`
@@ -72,7 +73,9 @@ Pick the toolbar groups per instance with `toolbar` and, to enable images and vi
72
73
  ### Engine and helpers
73
74
 
74
75
  - `createWysiwygEditor(element, options)`, `createWysiwygViewer(element, options)` → `{ editor, getJSON, setContent, isActive, setEditable, setTheme, resolvedTheme, insertFile, uploading, setLink, unsetLink, destroy }`.
75
- - `createWysiwygExtensions`, `sanitizeWysiwygContent(json, schema)`, `isSafeUrl`, `isSafeColor`, `resolveWysiwygLabels`, `ARK_WYSIWYG_TOOLBAR_GROUPS`, `ARK_WYSIWYG_DEFAULT_TOOLBAR`, `EMPTY_DOC`.
76
+ - `createWysiwygExtensions`, `Video` (the video node), `sanitizeWysiwygContent(json, schema)`, `isSafeUrl`, `isSafeColor`, `resolveWysiwygLabels`, `resolveWysiwygTheme(theme, element)`, `ARK_WYSIWYG_TOOLBAR_GROUPS`, `ARK_WYSIWYG_DEFAULT_TOOLBAR`, `EMPTY_DOC`, `DEFAULT_MAX_FILE_SIZE`, `HEADING_LEVELS`.
77
+ - Styles: `ensureWysiwygStyles()` injects `wysiwygCss` into `<head>` once (a `<style>` whose id is `WYSIWYG_STYLE_ID`); the elements call it on connect, the engine does not.
78
+ - Types: `ArkWysiwygInstance`, `ArkWysiwygContent`, `ArkWysiwygEditorOptions`, `ArkWysiwygViewerOptions`, `ArkWysiwygTheme`, `ArkWysiwygLang`, `ArkWysiwygLabels`, `ArkWysiwygToolbarGroup`, `ArkWysiwygToolbarItem`, `ArkWysiwygUploader`, `ArkWysiwygUploadKind`, `ArkWysiwygUploadResult`, `ArkWysiwygUploadError`, `ArkWysiwygUploadErrorReason`, `JSONContent` (re-exported).
76
79
 
77
80
  ---
78
81
 
@@ -96,7 +99,7 @@ editor.addEventListener("ark-wysiwyg-upload-error", (event) => {
96
99
  document.querySelector("ark-wysiwyg-viewer")!.content = savedJson;
97
100
  ```
98
101
 
99
- ### Sanitizing content on the server side too
102
+ ### Sanitizing content outside the editor too
100
103
 
101
104
  ```ts
102
105
  import { createWysiwygViewer, sanitizeWysiwygContent } from "@tooark/wysiwyg";
@@ -123,7 +126,7 @@ Installed automatically unless marked as peer; peer dependencies are yours to in
123
126
  | [`@tiptap/extension-text-style`](https://www.npmjs.com/package/@tiptap/extension-text-style) | ^3.31.3 | Text style mark with color |
124
127
  | [`@tiptap/pm`](https://www.npmjs.com/package/@tiptap/pm) | ^3.31.3 | ProseMirror packages used by Tiptap |
125
128
  | [`@tiptap/starter-kit`](https://www.npmjs.com/package/@tiptap/starter-kit) | ^3.31.3 | Base nodes and marks (paragraph, heading, lists, bold, link, underline…) |
126
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.0.0 | Design tokens (colors, sizes, radii, motion) and primitive types |
129
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.0 | Design tokens (colors, sizes, motion) and primitive types |
127
130
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | TypeScript runtime helpers |
128
131
 
129
132
  ---
package/README.pt-BR.md CHANGED
@@ -26,10 +26,10 @@
26
26
 
27
27
  O pacote `@tooark/wysiwyg` fornece:
28
28
 
29
- - conteúdo como JSON do Tiptap (nunca HTML cru), sanitizado ao entrar por `sanitizeWysiwygContent`: nós e marcas desconhecidos caem, `href`/`src`/`poster` restritos a http(s), mailto, tel ou caminho relativo, cores validadas;
29
+ - conteúdo como JSON do Tiptap (nunca HTML cru), sanitizado ao entrar por `sanitizeWysiwygContent`: nós e marcas desconhecidos caem, `href`/`src`/`poster` restritos a http(s), mailto, tel ou caminho relativo iniciado por `/`, `#`, `?`, `./` ou `../` (`uploads/x.png` é recusado), cores validadas (hex, nome de cor CSS ou `rgb()`/`hsl()`);
30
30
  - toolbar montada por grupos opt-in (`style`, `marks`, `color`, `align`, `lists`, `link`, `media`, `blocks`, `clear`, `history`; `all`, `none`), `role="toolbar"` com um tab stop, rótulos em `en`/`pt`/`es`;
31
31
  - links com popover de URL (esquemas inseguros recusados), paletas de cor do texto e marca-texto, alinhamento, recuo de listas, limpar formatação;
32
- - imagens e vídeos só pelo gancho `uploadFile(file, kind)` — seu storage, o JSON guarda a URL, nunca base64; sem o gancho o grupo `media` não é renderizado e arquivos colados/arrastados são recusados;
32
+ - imagens e vídeos só pelo gancho `uploadFile(file, kind)` — seu storage, o JSON guarda a URL, nunca base64; sem o gancho o grupo `media` não é renderizado, arquivos colados/arrastados são recusados e `<img>`/`<video>` saem do HTML colado; com ele, `<img>`/`<video>` colados só entram com `src` permitido; arquivos colados/arrastados que não são imagem nem vídeo são recusados com `unsupported-type`;
33
33
  - o mesmo schema no viewer, que renderiza links com `target="_blank"` e `rel="noopener noreferrer nofollow"`;
34
34
  - engine `createWysiwygEditor`/`createWysiwygViewer` para uso sem os elementos; tema segue a página (`theme="auto"`).
35
35
 
@@ -38,7 +38,7 @@ O pacote `@tooark/wysiwyg` fornece:
38
38
  ## 🔧 Instalação
39
39
 
40
40
  ```bash
41
- pnpm add @tooark/wysiwyg # o Tiptap vem junto como dependência
41
+ pnpm add @tooark/wysiwyg # o Tiptap é instalado como dependência
42
42
  ```
43
43
 
44
44
  ---
@@ -61,8 +61,9 @@ Escolha os grupos da toolbar por instância com `toolbar` e, para ligar imagens
61
61
 
62
62
  ### `ark-wysiwyg-editor`
63
63
 
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`) e `locale-json`, `colors`/`highlights` (arrays JSON de cores CSS), `max-file-size` (bytes, padrão 10 MiB).
65
- - Propriedades: `content` (JSON do Tiptap, sanitizado; atribuir não emite `change` e fica fora do histórico), `uploadFile`, `colors`, `highlights`, `resolvedTheme`, `editor` (a instância do Tiptap); `insertFile(file)`.
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).
65
+ - 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)`.
66
67
  - Eventos: `ark-wysiwyg-change` (`detail` = JSON), `ark-wysiwyg-upload-error` (`detail: { reason, file, error? }`, motivos `no-uploader`, `unsupported-type`, `too-large`, `invalid-src`, `failed`).
67
68
 
68
69
  ### `ark-wysiwyg-viewer`
@@ -72,7 +73,9 @@ Escolha os grupos da toolbar por instância com `toolbar` e, para ligar imagens
72
73
  ### Engine e helpers
73
74
 
74
75
  - `createWysiwygEditor(element, options)`, `createWysiwygViewer(element, options)` → `{ editor, getJSON, setContent, isActive, setEditable, setTheme, resolvedTheme, insertFile, uploading, setLink, unsetLink, destroy }`.
75
- - `createWysiwygExtensions`, `sanitizeWysiwygContent(json, schema)`, `isSafeUrl`, `isSafeColor`, `resolveWysiwygLabels`, `ARK_WYSIWYG_TOOLBAR_GROUPS`, `ARK_WYSIWYG_DEFAULT_TOOLBAR`, `EMPTY_DOC`.
76
+ - `createWysiwygExtensions`, `Video` (o nó de vídeo), `sanitizeWysiwygContent(json, schema)`, `isSafeUrl`, `isSafeColor`, `resolveWysiwygLabels`, `resolveWysiwygTheme(theme, element)`, `ARK_WYSIWYG_TOOLBAR_GROUPS`, `ARK_WYSIWYG_DEFAULT_TOOLBAR`, `EMPTY_DOC`, `DEFAULT_MAX_FILE_SIZE`, `HEADING_LEVELS`.
77
+ - Estilos: `ensureWysiwygStyles()` injeta o `wysiwygCss` no `<head>` uma única vez (um `<style>` cujo id é `WYSIWYG_STYLE_ID`); os elementos a chamam ao conectar, o engine não.
78
+ - Tipos: `ArkWysiwygInstance`, `ArkWysiwygContent`, `ArkWysiwygEditorOptions`, `ArkWysiwygViewerOptions`, `ArkWysiwygTheme`, `ArkWysiwygLang`, `ArkWysiwygLabels`, `ArkWysiwygToolbarGroup`, `ArkWysiwygToolbarItem`, `ArkWysiwygUploader`, `ArkWysiwygUploadKind`, `ArkWysiwygUploadResult`, `ArkWysiwygUploadError`, `ArkWysiwygUploadErrorReason`, `JSONContent` (reexportado).
76
79
 
77
80
  ---
78
81
 
@@ -123,7 +126,7 @@ Instaladas automaticamente, salvo as marcadas como peer, que ficam por sua conta
123
126
  | [`@tiptap/extension-text-style`](https://www.npmjs.com/package/@tiptap/extension-text-style) | ^3.31.3 | Marca de estilo de texto com cor |
124
127
  | [`@tiptap/pm`](https://www.npmjs.com/package/@tiptap/pm) | ^3.31.3 | Pacotes ProseMirror usados pelo Tiptap |
125
128
  | [`@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…) |
126
- | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.0.0 | Design tokens (cores, tamanhos, raios, motion) e tipos primitivos |
129
+ | [`@tooark/tokens`](https://www.npmjs.com/package/@tooark/tokens) | ^1.2.0 | Design tokens (cores, tamanhos, motion) e tipos primitivos |
127
130
  | [`tslib`](https://www.npmjs.com/package/tslib) | ^2.8.1 | Helpers de runtime do TypeScript |
128
131
 
129
132
  ---
package/dist/index.cjs CHANGED
@@ -146,12 +146,20 @@ const Video = core.Node.create({
146
146
  addAttributes() {
147
147
  return {
148
148
  src: { default: null },
149
- poster: { default: null },
149
+ // HTML colado: um poster fora da lista de permissão cai, o vídeo fica.
150
+ poster: {
151
+ default: null,
152
+ parseHTML: (element) => {
153
+ const poster = element.getAttribute("poster");
154
+ return isSafeUrl(poster) ? poster : null;
155
+ }
156
+ },
150
157
  title: { default: null }
151
158
  };
152
159
  },
153
160
  parseHTML() {
154
- return [{ tag: "video[src]" }];
161
+ // HTML colado: só vira nó com src permitido (nada de data:/blob:, que a sanitização do JSON também barra).
162
+ return [{ tag: "video[src]", getAttrs: (element) => (isSafeUrl(element.getAttribute("src")) ? null : false) }];
155
163
  },
156
164
  renderHTML({ HTMLAttributes }) {
157
165
  return ["video", core.mergeAttributes({ controls: "true", preload: "metadata" }, HTMLAttributes)];
@@ -162,6 +170,12 @@ const Video = core.Node.create({
162
170
  };
163
171
  }
164
172
  });
173
+ /** Imagem do Tiptap que, no HTML colado, só vira nó com src permitido (o padrão só barra data:, não blob:). */
174
+ const SafeImage = extensionImage.Image.extend({
175
+ parseHTML() {
176
+ return [{ tag: "img[src]", getAttrs: (element) => (isSafeUrl(element.getAttribute("src")) ? null : false) }];
177
+ }
178
+ });
165
179
  // --- Extensões compartilhadas ---
166
180
  /**
167
181
  * Extensões do editor e do viewer (o mesmo schema nos dois, senão o conteúdo salvo não renderiza): StarterKit
@@ -186,7 +200,7 @@ function createWysiwygExtensions(options) {
186
200
  extensionTextStyle.Color,
187
201
  extensionHighlight.Highlight.configure({ multicolor: true }),
188
202
  extensionTextAlign.TextAlign.configure({ types: ["heading", "paragraph"], alignments: ["left", "center", "right", "justify"] }),
189
- extensionImage.Image.configure({ allowBase64: false, inline: false }),
203
+ SafeImage.configure({ allowBase64: false, inline: false }),
190
204
  Video
191
205
  ];
192
206
  if (options.placeholder) {
@@ -201,8 +215,8 @@ function kindOf(file) {
201
215
  return "video";
202
216
  return null;
203
217
  }
204
- function mediaFiles(list) {
205
- return Array.from(list ?? []).filter((file) => kindOf(file) !== null);
218
+ function filesOf(list) {
219
+ return Array.from(list ?? []);
206
220
  }
207
221
  function createInstance(element, options) {
208
222
  let resolved = resolveWysiwygTheme(options.theme, element);
@@ -213,7 +227,8 @@ function createInstance(element, options) {
213
227
  options.onUploadError?.({ reason, file, error });
214
228
  return false;
215
229
  };
216
- // Arquivos colados ou arrastados só entram pelo gancho; sem ele são consumidos (nada de base64 no JSON).
230
+ // Arquivos colados ou arrastados só entram pelo gancho; sem ele são consumidos (nada de base64 no JSON). Os que
231
+ // não são imagem nem vídeo são recusados com o motivo (insertFile emite unsupported-type), em vez de sumir.
217
232
  const handleFiles = (files, position) => {
218
233
  if (files.length === 0)
219
234
  return false;
@@ -227,12 +242,19 @@ function createInstance(element, options) {
227
242
  extensions: createWysiwygExtensions({ editable: options.editable, placeholder: options.placeholder }),
228
243
  content: EMPTY_DOC,
229
244
  editorProps: {
230
- handlePaste: (_view, event) => handleFiles(mediaFiles(event.clipboardData?.files)),
245
+ handlePaste: (_view, event) => {
246
+ const files = filesOf(event.clipboardData?.files);
247
+ // Planilhas e editores copiam o texto junto de arquivos que não são mídia: aí o texto vence e cola normal.
248
+ const hasText = Array.from(event.clipboardData?.types ?? []).some((type) => type.startsWith("text/"));
249
+ if (hasText && !files.some((file) => kindOf(file)))
250
+ return false;
251
+ return handleFiles(files);
252
+ },
231
253
  handleDrop: (view, event, _slice, moved) => {
232
254
  if (moved)
233
255
  return false;
234
256
  const at = view.posAtCoords({ left: event.clientX, top: event.clientY });
235
- return handleFiles(mediaFiles(event.dataTransfer?.files), at?.pos);
257
+ return handleFiles(filesOf(event.dataTransfer?.files), at?.pos);
236
258
  },
237
259
  // HTML colado com <img>/<video> só vira nó quando há gancho: sem ele, seria um hotlink que o app não controla.
238
260
  transformPastedHTML: (html) => (options.uploadFile ? html : html.replace(/<(img|video|source)\b[^>]*>/gi, ""))
@@ -814,6 +836,13 @@ const ARK_WYSIWYG_DEFAULT_TOOLBAR = [
814
836
  "history"
815
837
  ];
816
838
 
839
+ // Base dos Custom Elements que também carrega fora do navegador. No SSR (Node, Angular SSR, Next, Nuxt) não existe
840
+ // HTMLElement, e um `extends HTMLElement` no topo do módulo derrubaria o import de quem só renderiza o HTML; lá a
841
+ // base é uma classe vazia, e os elementos só passam a existir no cliente, quando registerTooark*() os define.
842
+ /** `HTMLElement` no navegador; fora dele, uma classe vazia para o módulo poder ser importado no servidor. */
843
+ const HTMLElementBase = typeof HTMLElement === "undefined" ? class {
844
+ } : HTMLElement;
845
+
817
846
  const headingAction = (level) => ({
818
847
  icon: "bold",
819
848
  label: "heading",
@@ -964,7 +993,7 @@ let popoverSeq = 0;
964
993
  * não aparecem na toolbar e arquivos colados ou arrastados são recusados
965
994
  * (`ark-wysiwyg-upload-error`), nunca embutidos em base64.
966
995
  */
967
- class ArkWysiwygEditor extends HTMLElement {
996
+ class ArkWysiwygEditor extends HTMLElementBase {
968
997
  constructor() {
969
998
  super(...arguments);
970
999
  this.instance = null;
@@ -1178,9 +1207,6 @@ class ArkWysiwygEditor extends HTMLElement {
1178
1207
  }
1179
1208
  build() {
1180
1209
  this.teardown();
1181
- if (this.pendingContent === null) {
1182
- this.pendingContent = this.content;
1183
- }
1184
1210
  this.labels = resolveWysiwygLabels(this.getAttribute("lang"), this.getAttribute("locale-json"));
1185
1211
  const root = document.createElement("div");
1186
1212
  root.className = "ark-wysiwyg";
@@ -1556,6 +1582,8 @@ class ArkWysiwygEditor extends HTMLElement {
1556
1582
  this.disposeTheme?.();
1557
1583
  this.disposeTheme = null;
1558
1584
  if (this.instance) {
1585
+ // Reconstruir (toolbar, rótulos, paletas, gancho) ou mover o nó no DOM não pode perder o que foi digitado.
1586
+ this.pendingContent = this.instance.getJSON();
1559
1587
  this.instance.editor.off("selectionUpdate", this.syncToolbar);
1560
1588
  this.instance.editor.off("transaction", this.syncToolbar);
1561
1589
  this.instance.destroy();
@@ -1582,7 +1610,7 @@ ArkWysiwygEditor.tagName = "ark-wysiwyg-editor";
1582
1610
  *
1583
1611
  * Conteúdo via propriedade `content` (JSON do Tiptap). Atributo: `theme`.
1584
1612
  */
1585
- class ArkWysiwygViewer extends HTMLElement {
1613
+ class ArkWysiwygViewer extends HTMLElementBase {
1586
1614
  constructor() {
1587
1615
  super(...arguments);
1588
1616
  this.instance = null;
@@ -1679,6 +1707,9 @@ ArkWysiwygViewer.tagName = "ark-wysiwyg-viewer";
1679
1707
  * Chame antes de usar em qualquer ambiente (puro, React, Angular, Vue).
1680
1708
  */
1681
1709
  function registerTooarkWysiwyg() {
1710
+ // Fora do navegador (SSR) não há registro de elementos: no-op, e o cliente registra na hidratação.
1711
+ if (typeof customElements === "undefined")
1712
+ return;
1682
1713
  if (!customElements.get(ArkWysiwygEditor.tagName)) {
1683
1714
  customElements.define(ArkWysiwygEditor.tagName, ArkWysiwygEditor);
1684
1715
  }