@tooark/react 1.6.1 → 1.7.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 +17 -10
- package/README.pt-BR.md +17 -10
- package/dist/ark-alert.d.ts +6 -6
- package/dist/ark-avatar.d.ts +2 -2
- package/dist/ark-button.d.ts +6 -2
- package/dist/ark-button.js +14 -3
- package/dist/ark-card.d.ts +2 -2
- package/dist/ark-card.js +4 -2
- package/dist/ark-checkbox.d.ts +8 -8
- package/dist/ark-clock.d.ts +2 -2
- package/dist/ark-color-swatches.d.ts +4 -4
- package/dist/ark-command-palette.d.ts +18 -18
- package/dist/ark-copy-button.d.ts +2 -2
- package/dist/ark-data-view.d.ts +79 -0
- package/dist/ark-data-view.js +195 -0
- package/dist/ark-dialog.d.ts +12 -12
- package/dist/ark-dialog.js +4 -3
- package/dist/ark-drawer.d.ts +12 -12
- package/dist/ark-drawer.js +4 -3
- package/dist/ark-empty.d.ts +4 -4
- package/dist/ark-empty.js +3 -2
- package/dist/ark-file-input.d.ts +8 -8
- package/dist/ark-input.d.ts +2 -2
- package/dist/ark-kv-editor.d.ts +11 -11
- package/dist/ark-kv-editor.js +2 -2
- package/dist/ark-mark.d.ts +2 -2
- package/dist/ark-menu.d.ts +23 -11
- package/dist/ark-menu.js +8 -0
- package/dist/ark-nav.d.ts +111 -0
- package/dist/ark-nav.js +79 -0
- package/dist/ark-pagination.d.ts +36 -0
- package/dist/ark-pagination.js +31 -0
- package/dist/ark-progress.d.ts +8 -8
- package/dist/ark-radio.d.ts +10 -10
- package/dist/ark-scheduler.d.ts +1 -1
- package/dist/ark-shape-picker.d.ts +6 -6
- package/dist/ark-skeleton.d.ts +2 -2
- package/dist/ark-spinner.d.ts +2 -2
- package/dist/ark-split-pane.d.ts +4 -4
- package/dist/ark-status-dot.d.ts +2 -2
- package/dist/ark-switch.d.ts +6 -3
- package/dist/ark-switch.js +3 -2
- package/dist/ark-tabs.d.ts +6 -6
- package/dist/ark-textarea.d.ts +9 -9
- package/dist/ark-time.d.ts +18 -0
- package/dist/ark-time.js +22 -0
- package/dist/ark-tooltip.d.ts +4 -4
- package/dist/ark-tree.d.ts +86 -0
- package/dist/ark-tree.js +54 -0
- package/dist/chart.d.ts +65 -0
- package/dist/chart.js +35 -0
- package/dist/code.d.ts +148 -0
- package/dist/code.js +77 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.js +7 -2
- package/dist/jsx-intrinsics.d.ts +126 -1
- package/dist/wysiwyg.d.ts +108 -0
- package/dist/wysiwyg.js +68 -0
- package/package.json +47 -3
package/dist/jsx-intrinsics.d.ts
CHANGED
|
@@ -10,23 +10,31 @@ import type {
|
|
|
10
10
|
ArkButtonVariant,
|
|
11
11
|
ArkCardPadding,
|
|
12
12
|
ArkCarouselSnap,
|
|
13
|
+
ArkDataViewMode,
|
|
14
|
+
ArkDataViewView,
|
|
13
15
|
ArkDatepickerLang,
|
|
14
16
|
ArkDialogSize,
|
|
15
17
|
ArkDrawerMode,
|
|
16
18
|
ArkDrawerSide,
|
|
19
|
+
ArkHeadingLevel,
|
|
17
20
|
ArkIntent,
|
|
18
21
|
ArkLang,
|
|
19
22
|
ArkMarkShape,
|
|
20
23
|
ArkMenuAlign,
|
|
21
24
|
ArkMenuDirection,
|
|
25
|
+
ArkNavCollapsible,
|
|
26
|
+
ArkNavSide,
|
|
27
|
+
ArkNavVariant,
|
|
22
28
|
ArkRounded,
|
|
23
29
|
ArkSize,
|
|
24
30
|
ArkTabsFill,
|
|
25
31
|
ArkTabsVariant,
|
|
26
32
|
ArkTextareaResize,
|
|
27
33
|
ArkTheme,
|
|
34
|
+
ArkTimeFormat,
|
|
28
35
|
ArkToastPosition,
|
|
29
|
-
ArkTooltipSide
|
|
36
|
+
ArkTooltipSide,
|
|
37
|
+
ArkTreeSelection
|
|
30
38
|
} from "@tooark/core";
|
|
31
39
|
import React from "react";
|
|
32
40
|
|
|
@@ -78,6 +86,7 @@ interface ArkIntrinsicElements {
|
|
|
78
86
|
"full-width"?: boolean;
|
|
79
87
|
href?: string;
|
|
80
88
|
target?: string;
|
|
89
|
+
download?: string;
|
|
81
90
|
color?: string;
|
|
82
91
|
"text-color"?: string;
|
|
83
92
|
};
|
|
@@ -278,6 +287,7 @@ interface ArkIntrinsicElements {
|
|
|
278
287
|
width?: string | number;
|
|
279
288
|
height?: string | number;
|
|
280
289
|
label?: string;
|
|
290
|
+
"heading-level"?: ArkHeadingLevel;
|
|
281
291
|
"no-close-button"?: boolean;
|
|
282
292
|
persistent?: boolean;
|
|
283
293
|
"no-scroll-lock"?: boolean;
|
|
@@ -307,6 +317,53 @@ interface ArkIntrinsicElements {
|
|
|
307
317
|
lang?: ArkLang;
|
|
308
318
|
"locale-json"?: string;
|
|
309
319
|
};
|
|
320
|
+
"ark-pagination": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
321
|
+
testid?: string;
|
|
322
|
+
page?: number | string;
|
|
323
|
+
"page-size"?: number | string;
|
|
324
|
+
total?: number | string;
|
|
325
|
+
/** Opções do seletor de itens por página, separadas por vírgula; sem ele o seletor não aparece. */
|
|
326
|
+
"page-sizes"?: string;
|
|
327
|
+
siblings?: number | string;
|
|
328
|
+
disabled?: boolean;
|
|
329
|
+
size?: ArkSize;
|
|
330
|
+
intent?: ArkIntent;
|
|
331
|
+
theme?: ArkTheme;
|
|
332
|
+
lang?: ArkLang;
|
|
333
|
+
"locale-json"?: string;
|
|
334
|
+
};
|
|
335
|
+
"ark-data-view": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
336
|
+
testid?: string;
|
|
337
|
+
/** JSON das colunas (sem `render`/`compare`, que só existem na propriedade JS). */
|
|
338
|
+
columns?: string;
|
|
339
|
+
rows?: string;
|
|
340
|
+
"row-key"?: string;
|
|
341
|
+
view?: ArkDataViewView;
|
|
342
|
+
/** Esconde o seletor de visualização; `view` continua valendo. */
|
|
343
|
+
"no-view-selector"?: boolean;
|
|
344
|
+
breakpoint?: number | string;
|
|
345
|
+
mode?: ArkDataViewMode;
|
|
346
|
+
page?: number | string;
|
|
347
|
+
"page-size"?: number | string;
|
|
348
|
+
"page-sizes"?: string;
|
|
349
|
+
total?: number | string;
|
|
350
|
+
/** "chave:asc" ou "chave:desc". */
|
|
351
|
+
sort?: string;
|
|
352
|
+
search?: string;
|
|
353
|
+
searchable?: boolean;
|
|
354
|
+
"search-placeholder"?: string;
|
|
355
|
+
"search-debounce"?: number | string;
|
|
356
|
+
selectable?: boolean;
|
|
357
|
+
reorderable?: boolean;
|
|
358
|
+
clickable?: boolean;
|
|
359
|
+
loading?: boolean;
|
|
360
|
+
"card-columns"?: number | string;
|
|
361
|
+
label?: string;
|
|
362
|
+
size?: ArkSize;
|
|
363
|
+
theme?: ArkTheme;
|
|
364
|
+
lang?: ArkLang;
|
|
365
|
+
"locale-json"?: string;
|
|
366
|
+
};
|
|
310
367
|
"ark-mark": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
311
368
|
testid?: string;
|
|
312
369
|
shape?: ArkMarkShape;
|
|
@@ -324,6 +381,12 @@ interface ArkIntrinsicElements {
|
|
|
324
381
|
size?: ArkSize;
|
|
325
382
|
theme?: ArkTheme;
|
|
326
383
|
};
|
|
384
|
+
"ark-menu-group": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
385
|
+
testid?: string;
|
|
386
|
+
label?: string;
|
|
387
|
+
size?: ArkSize;
|
|
388
|
+
theme?: ArkTheme;
|
|
389
|
+
};
|
|
327
390
|
"ark-menu-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
328
391
|
testid?: string;
|
|
329
392
|
value?: string;
|
|
@@ -333,6 +396,36 @@ interface ArkIntrinsicElements {
|
|
|
333
396
|
divider?: boolean;
|
|
334
397
|
static?: boolean;
|
|
335
398
|
};
|
|
399
|
+
"ark-nav": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
400
|
+
testid?: string;
|
|
401
|
+
variant?: ArkNavVariant;
|
|
402
|
+
side?: ArkNavSide;
|
|
403
|
+
value?: string;
|
|
404
|
+
collapsed?: boolean;
|
|
405
|
+
collapsible?: boolean | ArkNavCollapsible;
|
|
406
|
+
label?: string;
|
|
407
|
+
size?: ArkSize;
|
|
408
|
+
intent?: ArkIntent;
|
|
409
|
+
theme?: ArkTheme;
|
|
410
|
+
lang?: ArkLang;
|
|
411
|
+
"locale-json"?: string;
|
|
412
|
+
};
|
|
413
|
+
"ark-nav-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
414
|
+
testid?: string;
|
|
415
|
+
href?: string;
|
|
416
|
+
target?: string;
|
|
417
|
+
label?: string;
|
|
418
|
+
value?: string;
|
|
419
|
+
current?: boolean;
|
|
420
|
+
disabled?: boolean;
|
|
421
|
+
divider?: boolean;
|
|
422
|
+
};
|
|
423
|
+
"ark-nav-group": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
424
|
+
testid?: string;
|
|
425
|
+
label?: string;
|
|
426
|
+
expandable?: boolean;
|
|
427
|
+
open?: boolean;
|
|
428
|
+
};
|
|
336
429
|
"ark-tooltip": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
337
430
|
testid?: string;
|
|
338
431
|
content?: string;
|
|
@@ -341,12 +434,35 @@ interface ArkIntrinsicElements {
|
|
|
341
434
|
open?: boolean;
|
|
342
435
|
theme?: ArkTheme;
|
|
343
436
|
};
|
|
437
|
+
"ark-tree": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
438
|
+
testid?: string;
|
|
439
|
+
selection?: ArkTreeSelection;
|
|
440
|
+
checkboxes?: boolean;
|
|
441
|
+
propagate?: boolean;
|
|
442
|
+
value?: string;
|
|
443
|
+
label?: string;
|
|
444
|
+
size?: ArkSize;
|
|
445
|
+
theme?: ArkTheme;
|
|
446
|
+
};
|
|
447
|
+
"ark-tree-item": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
448
|
+
testid?: string;
|
|
449
|
+
value?: string;
|
|
450
|
+
label?: string;
|
|
451
|
+
expanded?: boolean;
|
|
452
|
+
lazy?: boolean;
|
|
453
|
+
loading?: boolean;
|
|
454
|
+
selected?: boolean;
|
|
455
|
+
checked?: boolean | "mixed" | "false";
|
|
456
|
+
disabled?: boolean;
|
|
457
|
+
};
|
|
344
458
|
"ark-card": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
345
459
|
testid?: string;
|
|
346
460
|
heading?: string;
|
|
461
|
+
"heading-level"?: ArkHeadingLevel;
|
|
347
462
|
padding?: ArkCardPadding;
|
|
348
463
|
rounded?: ArkRounded;
|
|
349
464
|
theme?: ArkTheme;
|
|
465
|
+
"wrap-actions"?: boolean;
|
|
350
466
|
};
|
|
351
467
|
"ark-drawer": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
352
468
|
testid?: string;
|
|
@@ -355,6 +471,7 @@ interface ArkIntrinsicElements {
|
|
|
355
471
|
mode?: ArkDrawerMode;
|
|
356
472
|
size?: string | number;
|
|
357
473
|
label?: string;
|
|
474
|
+
"heading-level"?: ArkHeadingLevel;
|
|
358
475
|
"no-close-button"?: boolean;
|
|
359
476
|
persistent?: boolean;
|
|
360
477
|
"no-scroll-lock"?: boolean;
|
|
@@ -365,6 +482,7 @@ interface ArkIntrinsicElements {
|
|
|
365
482
|
"ark-empty": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
366
483
|
testid?: string;
|
|
367
484
|
heading?: string;
|
|
485
|
+
"heading-level"?: ArkHeadingLevel;
|
|
368
486
|
description?: string;
|
|
369
487
|
theme?: ArkTheme;
|
|
370
488
|
};
|
|
@@ -520,6 +638,11 @@ interface ArkIntrinsicElements {
|
|
|
520
638
|
minlength?: number | string;
|
|
521
639
|
spellcheck?: boolean | "true" | "false";
|
|
522
640
|
};
|
|
641
|
+
"ark-time": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
642
|
+
testid?: string;
|
|
643
|
+
datetime?: string;
|
|
644
|
+
format?: ArkTimeFormat;
|
|
645
|
+
};
|
|
523
646
|
"ark-carousel": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
524
647
|
testid?: string;
|
|
525
648
|
theme?: ArkTheme;
|
|
@@ -549,6 +672,7 @@ interface ArkIntrinsicElements {
|
|
|
549
672
|
"ark-chart": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
550
673
|
testid?: string;
|
|
551
674
|
theme?: ArkTheme;
|
|
675
|
+
palette?: "default" | "tokens";
|
|
552
676
|
renderer?: "canvas" | "svg";
|
|
553
677
|
height?: string;
|
|
554
678
|
"auto-resize"?: boolean | "false";
|
|
@@ -576,6 +700,7 @@ interface ArkIntrinsicElements {
|
|
|
576
700
|
readonly?: boolean;
|
|
577
701
|
placeholder?: string;
|
|
578
702
|
"min-height"?: string;
|
|
703
|
+
"max-height"?: string;
|
|
579
704
|
"line-numbers"?: boolean | "false";
|
|
580
705
|
fold?: boolean | "false";
|
|
581
706
|
wrap?: boolean;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ArkLang } from "@tooark/core";
|
|
2
|
+
import { type ArkWysiwygContent, type ArkWysiwygEditor as ArkWysiwygEditorElement, type ArkWysiwygUploadError, type ArkWysiwygUploader, type ArkWysiwygViewer as ArkWysiwygViewerElement } from "@tooark/wysiwyg";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import type { ArkDomProps } from "./dom-props.js";
|
|
5
|
+
/** Atributos da tag `ark-wysiwyg-editor`, os mesmos da entrada principal, mais as propriedades JS. */
|
|
6
|
+
type ArkWysiwygEditorTagProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
7
|
+
testid?: string;
|
|
8
|
+
theme?: "auto" | "light" | "dark";
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
editable?: boolean | "false";
|
|
11
|
+
toolbar?: string;
|
|
12
|
+
lang?: ArkLang;
|
|
13
|
+
"locale-json"?: string;
|
|
14
|
+
colors?: string;
|
|
15
|
+
highlights?: string;
|
|
16
|
+
"max-file-size"?: number;
|
|
17
|
+
/** Gancho de upload de imagem e vídeo (propriedade JS). */
|
|
18
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
19
|
+
};
|
|
20
|
+
declare module "react" {
|
|
21
|
+
namespace JSX {
|
|
22
|
+
interface IntrinsicElements {
|
|
23
|
+
"ark-wysiwyg-editor": ArkWysiwygEditorTagProps;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
namespace JSX {
|
|
29
|
+
interface IntrinsicElements {
|
|
30
|
+
"ark-wysiwyg-editor": ArkWysiwygEditorTagProps;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export type ArkWysiwygEditorProps = ArkDomProps<{
|
|
35
|
+
/**
|
|
36
|
+
* Conteúdo como JSON do Tiptap. Atribuído só quando a referência muda e fora do histórico de desfazer: o objeto que
|
|
37
|
+
* o `onChange` devolve, repassado, não reescreve o editor.
|
|
38
|
+
*/
|
|
39
|
+
content?: ArkWysiwygContent | null;
|
|
40
|
+
/** Gancho de upload; sem ele não há botões de mídia e arquivos colados são recusados. */
|
|
41
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
42
|
+
/** Grupos e itens da toolbar (`style,marks,...`, `all`, `none`). */
|
|
43
|
+
toolbar?: string;
|
|
44
|
+
theme?: "auto" | "light" | "dark";
|
|
45
|
+
placeholder?: string;
|
|
46
|
+
/** false desabilita a edição. Padrão: true. */
|
|
47
|
+
editable?: boolean;
|
|
48
|
+
lang?: ArkLang;
|
|
49
|
+
/** Rótulos próprios (objeto ou JSON), por cima do idioma. */
|
|
50
|
+
localeJson?: string | Record<string, string>;
|
|
51
|
+
/** Paleta da cor do texto (cores CSS). */
|
|
52
|
+
colors?: string[];
|
|
53
|
+
/** Paleta do marca-texto (cores CSS). */
|
|
54
|
+
highlights?: string[];
|
|
55
|
+
/** Tamanho máximo de arquivo em bytes. Padrão: 10 MiB. */
|
|
56
|
+
maxFileSize?: number;
|
|
57
|
+
testid?: string;
|
|
58
|
+
className?: string;
|
|
59
|
+
/** Cada edição, com o JSON do Tiptap em `detail`. */
|
|
60
|
+
onChange?: (event: CustomEvent<ArkWysiwygContent>) => void;
|
|
61
|
+
/** Arquivo recusado ou upload que falhou, com o motivo em `detail`. */
|
|
62
|
+
onUploadError?: (event: CustomEvent<ArkWysiwygUploadError>) => void;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const ArkWysiwygEditor: React.ForwardRefExoticComponent<{
|
|
65
|
+
/**
|
|
66
|
+
* Conteúdo como JSON do Tiptap. Atribuído só quando a referência muda e fora do histórico de desfazer: o objeto que
|
|
67
|
+
* o `onChange` devolve, repassado, não reescreve o editor.
|
|
68
|
+
*/
|
|
69
|
+
content?: ArkWysiwygContent | null;
|
|
70
|
+
/** Gancho de upload; sem ele não há botões de mídia e arquivos colados são recusados. */
|
|
71
|
+
uploadFile?: ArkWysiwygUploader | null;
|
|
72
|
+
/** Grupos e itens da toolbar (`style,marks,...`, `all`, `none`). */
|
|
73
|
+
toolbar?: string;
|
|
74
|
+
theme?: "auto" | "light" | "dark";
|
|
75
|
+
placeholder?: string;
|
|
76
|
+
/** false desabilita a edição. Padrão: true. */
|
|
77
|
+
editable?: boolean;
|
|
78
|
+
lang?: ArkLang;
|
|
79
|
+
/** Rótulos próprios (objeto ou JSON), por cima do idioma. */
|
|
80
|
+
localeJson?: string | Record<string, string>;
|
|
81
|
+
/** Paleta da cor do texto (cores CSS). */
|
|
82
|
+
colors?: string[];
|
|
83
|
+
/** Paleta do marca-texto (cores CSS). */
|
|
84
|
+
highlights?: string[];
|
|
85
|
+
/** Tamanho máximo de arquivo em bytes. Padrão: 10 MiB. */
|
|
86
|
+
maxFileSize?: number;
|
|
87
|
+
testid?: string;
|
|
88
|
+
className?: string;
|
|
89
|
+
/** Cada edição, com o JSON do Tiptap em `detail`. */
|
|
90
|
+
onChange?: (event: CustomEvent<ArkWysiwygContent>) => void;
|
|
91
|
+
/** Arquivo recusado ou upload que falhou, com o motivo em `detail`. */
|
|
92
|
+
onUploadError?: (event: CustomEvent<ArkWysiwygUploadError>) => void;
|
|
93
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "lang" | "content" | "onChange" | "testid" | "theme" | "localeJson" | "toolbar" | "colors" | "placeholder" | "uploadFile" | "editable" | "highlights" | "maxFileSize" | "onUploadError"> & React.RefAttributes<ArkWysiwygEditorElement>>;
|
|
94
|
+
export type ArkWysiwygViewerProps = ArkDomProps<{
|
|
95
|
+
/** Conteúdo como JSON do Tiptap, sanitizado ao entrar. */
|
|
96
|
+
content?: ArkWysiwygContent | null;
|
|
97
|
+
theme?: "auto" | "light" | "dark";
|
|
98
|
+
testid?: string;
|
|
99
|
+
className?: string;
|
|
100
|
+
}>;
|
|
101
|
+
export declare const ArkWysiwygViewer: React.ForwardRefExoticComponent<{
|
|
102
|
+
/** Conteúdo como JSON do Tiptap, sanitizado ao entrar. */
|
|
103
|
+
content?: ArkWysiwygContent | null;
|
|
104
|
+
theme?: "auto" | "light" | "dark";
|
|
105
|
+
testid?: string;
|
|
106
|
+
className?: string;
|
|
107
|
+
} & Omit<React.HTMLAttributes<HTMLElement>, "children" | "className" | "content" | "testid" | "theme"> & React.RefAttributes<ArkWysiwygViewerElement>>;
|
|
108
|
+
export {};
|
package/dist/wysiwyg.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { registerTooarkWysiwyg } from "@tooark/wysiwyg";
|
|
2
|
+
import { createElement, forwardRef, useEffect, useRef } from "react";
|
|
3
|
+
import { useForwardedRef } from "./use-forwarded-ref.js";
|
|
4
|
+
import { useIsomorphicLayoutEffect } from "./use-isomorphic-layout-effect.js";
|
|
5
|
+
export const ArkWysiwygEditor = forwardRef(function ArkWysiwygEditor(props, forwardedRef) {
|
|
6
|
+
const { className, content, uploadFile, editable, localeJson, colors, highlights, maxFileSize, onChange, onUploadError, ...rest } = props;
|
|
7
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
8
|
+
// O último JSON que o editor emitiu e o último atribuído: o getter `content` monta um objeto novo a cada leitura,
|
|
9
|
+
// então a comparação é com o que passou por aqui.
|
|
10
|
+
const known = useRef(undefined);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
registerTooarkWysiwyg();
|
|
13
|
+
}, []);
|
|
14
|
+
// Conteúdo e gancho pela propriedade, só com referência nova: setContent troca o documento fora do histórico, e
|
|
15
|
+
// o objeto que o onChange acabou de entregar, repassado pelo app, não reescreve o editor nem move o cursor.
|
|
16
|
+
useIsomorphicLayoutEffect(() => {
|
|
17
|
+
const el = ref.current;
|
|
18
|
+
if (!el || content === undefined || content === known.current)
|
|
19
|
+
return;
|
|
20
|
+
known.current = content;
|
|
21
|
+
el.content = content;
|
|
22
|
+
}, [ref, content]);
|
|
23
|
+
useIsomorphicLayoutEffect(() => {
|
|
24
|
+
const el = ref.current;
|
|
25
|
+
if (el && uploadFile !== undefined && el.uploadFile !== uploadFile)
|
|
26
|
+
el.uploadFile = uploadFile;
|
|
27
|
+
}, [ref, uploadFile]);
|
|
28
|
+
useIsomorphicLayoutEffect(() => {
|
|
29
|
+
const el = ref.current;
|
|
30
|
+
if (!el)
|
|
31
|
+
return;
|
|
32
|
+
const handleChange = (event) => {
|
|
33
|
+
known.current = event.detail;
|
|
34
|
+
onChange?.(event);
|
|
35
|
+
};
|
|
36
|
+
const handleError = (event) => onUploadError?.(event);
|
|
37
|
+
el.addEventListener("ark-wysiwyg-change", handleChange);
|
|
38
|
+
el.addEventListener("ark-wysiwyg-upload-error", handleError);
|
|
39
|
+
return () => {
|
|
40
|
+
el.removeEventListener("ark-wysiwyg-change", handleChange);
|
|
41
|
+
el.removeEventListener("ark-wysiwyg-upload-error", handleError);
|
|
42
|
+
};
|
|
43
|
+
}, [ref, onChange, onUploadError]);
|
|
44
|
+
const attrs = {
|
|
45
|
+
...rest,
|
|
46
|
+
ref: setRef,
|
|
47
|
+
class: className,
|
|
48
|
+
editable: editable === false ? "false" : undefined,
|
|
49
|
+
"locale-json": localeJson === undefined || typeof localeJson === "string" ? localeJson : JSON.stringify(localeJson),
|
|
50
|
+
colors: colors ? JSON.stringify(colors) : undefined,
|
|
51
|
+
highlights: highlights ? JSON.stringify(highlights) : undefined,
|
|
52
|
+
"max-file-size": maxFileSize
|
|
53
|
+
};
|
|
54
|
+
return createElement("ark-wysiwyg-editor", attrs);
|
|
55
|
+
});
|
|
56
|
+
export const ArkWysiwygViewer = forwardRef(function ArkWysiwygViewer(props, forwardedRef) {
|
|
57
|
+
const { className, content, ...rest } = props;
|
|
58
|
+
const [ref, setRef] = useForwardedRef(forwardedRef);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
registerTooarkWysiwyg();
|
|
61
|
+
}, []);
|
|
62
|
+
useIsomorphicLayoutEffect(() => {
|
|
63
|
+
const el = ref.current;
|
|
64
|
+
if (el && content !== undefined && el.content !== content)
|
|
65
|
+
el.content = content;
|
|
66
|
+
}, [ref, content]);
|
|
67
|
+
return createElement("ark-wysiwyg-viewer", { ...rest, ref: setRef, class: className });
|
|
68
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tooark/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Tooark React — typed wrappers for ark-* components for React 18 and 19",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tooark",
|
|
@@ -45,8 +45,33 @@
|
|
|
45
45
|
"types": "./dist/index.d.ts",
|
|
46
46
|
"default": "./dist/index.js"
|
|
47
47
|
},
|
|
48
|
+
"./chart": {
|
|
49
|
+
"types": "./dist/chart.d.ts",
|
|
50
|
+
"default": "./dist/chart.js"
|
|
51
|
+
},
|
|
52
|
+
"./code": {
|
|
53
|
+
"types": "./dist/code.d.ts",
|
|
54
|
+
"default": "./dist/code.js"
|
|
55
|
+
},
|
|
56
|
+
"./wysiwyg": {
|
|
57
|
+
"types": "./dist/wysiwyg.d.ts",
|
|
58
|
+
"default": "./dist/wysiwyg.js"
|
|
59
|
+
},
|
|
48
60
|
"./package.json": "./package.json"
|
|
49
61
|
},
|
|
62
|
+
"typesVersions": {
|
|
63
|
+
"*": {
|
|
64
|
+
"chart": [
|
|
65
|
+
"./dist/chart.d.ts"
|
|
66
|
+
],
|
|
67
|
+
"code": [
|
|
68
|
+
"./dist/code.d.ts"
|
|
69
|
+
],
|
|
70
|
+
"wysiwyg": [
|
|
71
|
+
"./dist/wysiwyg.d.ts"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
50
75
|
"files": [
|
|
51
76
|
"NOTICE",
|
|
52
77
|
"README.pt-BR.md",
|
|
@@ -57,12 +82,31 @@
|
|
|
57
82
|
"registry": "https://registry.npmjs.org/"
|
|
58
83
|
},
|
|
59
84
|
"peerDependencies": {
|
|
85
|
+
"@tooark/chart": ">=1.0.0",
|
|
86
|
+
"@tooark/code": ">=1.6.0",
|
|
87
|
+
"@tooark/wysiwyg": ">=1.0.0",
|
|
60
88
|
"react": ">=18",
|
|
61
89
|
"react-dom": ">=18"
|
|
62
90
|
},
|
|
91
|
+
"peerDependenciesMeta": {
|
|
92
|
+
"@tooark/chart": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"@tooark/code": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"@tooark/wysiwyg": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
101
|
+
},
|
|
63
102
|
"dependencies": {
|
|
64
|
-
"@tooark/core": "^1.
|
|
65
|
-
"@tooark/web-components": "^1.
|
|
103
|
+
"@tooark/core": "^1.7.0",
|
|
104
|
+
"@tooark/web-components": "^1.7.0"
|
|
105
|
+
},
|
|
106
|
+
"devDependencies": {
|
|
107
|
+
"@tooark/chart": "^1.7.0",
|
|
108
|
+
"@tooark/code": "^1.7.0",
|
|
109
|
+
"@tooark/wysiwyg": "^1.7.0"
|
|
66
110
|
},
|
|
67
111
|
"scripts": {
|
|
68
112
|
"build": "tsc -p tsconfig.json && tsc -p tsconfig.typecheck.json && node postbuild.mjs",
|