vobi_document 1.0.2 → 1.1.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 +23 -6
- package/dist/blocks.cjs +100 -0
- package/dist/blocks.cjs.map +1 -0
- package/dist/blocks.d.cts +201 -0
- package/dist/blocks.d.ts +201 -0
- package/dist/blocks.js +7 -0
- package/dist/blocks.js.map +1 -0
- package/dist/catalogContext-DenbX-OW.d.cts +15 -0
- package/dist/catalogContext-HGMU-w_4.d.ts +15 -0
- package/dist/chunk-2EBYURIX.js +90 -0
- package/dist/chunk-2EBYURIX.js.map +1 -0
- package/dist/chunk-6GRYRVU5.js +824 -0
- package/dist/chunk-6GRYRVU5.js.map +1 -0
- package/dist/chunk-ABIEQHS2.js +159 -0
- package/dist/chunk-ABIEQHS2.js.map +1 -0
- package/dist/chunk-AQ5FAAP6.cjs +168 -0
- package/dist/chunk-AQ5FAAP6.cjs.map +1 -0
- package/dist/chunk-ERKU5FDV.cjs +407 -0
- package/dist/chunk-ERKU5FDV.cjs.map +1 -0
- package/dist/chunk-FKX46GKE.cjs +36 -0
- package/dist/chunk-FKX46GKE.cjs.map +1 -0
- package/dist/chunk-HMTCQOEV.js +1319 -0
- package/dist/chunk-HMTCQOEV.js.map +1 -0
- package/dist/chunk-IRFFN74K.cjs +89 -0
- package/dist/chunk-IRFFN74K.cjs.map +1 -0
- package/dist/chunk-IUDN2CGP.js +863 -0
- package/dist/chunk-IUDN2CGP.js.map +1 -0
- package/dist/chunk-JEVWEGSE.js +95 -0
- package/dist/chunk-JEVWEGSE.js.map +1 -0
- package/dist/chunk-KCZKC3OG.js +61 -0
- package/dist/chunk-KCZKC3OG.js.map +1 -0
- package/dist/chunk-KUB3TYG2.cjs +102 -0
- package/dist/chunk-KUB3TYG2.cjs.map +1 -0
- package/dist/chunk-L5FXGEKX.cjs +114 -0
- package/dist/chunk-L5FXGEKX.cjs.map +1 -0
- package/dist/chunk-LNBAFOVK.cjs +14 -0
- package/dist/chunk-LNBAFOVK.cjs.map +1 -0
- package/dist/chunk-M2TPAU2F.js +79 -0
- package/dist/chunk-M2TPAU2F.js.map +1 -0
- package/dist/chunk-MHTTFNK2.cjs +890 -0
- package/dist/chunk-MHTTFNK2.cjs.map +1 -0
- package/dist/chunk-NDHTMYPA.cjs +844 -0
- package/dist/chunk-NDHTMYPA.cjs.map +1 -0
- package/dist/chunk-PLQNNXS2.js +382 -0
- package/dist/chunk-PLQNNXS2.js.map +1 -0
- package/dist/chunk-QYBWIJXZ.js +98 -0
- package/dist/chunk-QYBWIJXZ.js.map +1 -0
- package/dist/chunk-U56KVTK5.cjs +68 -0
- package/dist/chunk-U56KVTK5.cjs.map +1 -0
- package/dist/chunk-X2BLERM5.cjs +1346 -0
- package/dist/chunk-X2BLERM5.cjs.map +1 -0
- package/dist/chunk-ZOJBDFKU.js +12 -0
- package/dist/chunk-ZOJBDFKU.js.map +1 -0
- package/dist/chunk-ZXWOZZXO.cjs +94 -0
- package/dist/chunk-ZXWOZZXO.cjs.map +1 -0
- package/dist/editor.cjs +60 -0
- package/dist/editor.cjs.map +1 -0
- package/dist/editor.d.cts +190 -0
- package/dist/editor.d.ts +190 -0
- package/dist/editor.js +7 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.cjs +412 -3753
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -7892
- package/dist/index.d.ts +72 -7892
- package/dist/index.js +22 -3662
- package/dist/index.js.map +1 -1
- package/dist/messages-Bi0JxNIH.d.cts +23 -0
- package/dist/messages-Bi0JxNIH.d.ts +23 -0
- package/dist/print.cjs +354 -0
- package/dist/print.cjs.map +1 -0
- package/dist/print.d.cts +43 -0
- package/dist/print.d.ts +43 -0
- package/dist/print.js +336 -0
- package/dist/print.js.map +1 -0
- package/dist/puck.cjs +8 -8
- package/dist/puck.cjs.map +1 -1
- package/dist/render.cjs +72 -0
- package/dist/render.cjs.map +1 -0
- package/dist/render.d.cts +93 -0
- package/dist/render.d.ts +93 -0
- package/dist/render.js +7 -0
- package/dist/render.js.map +1 -0
- package/dist/theme-BuEFpQeZ.d.cts +112 -0
- package/dist/theme-BuEFpQeZ.d.ts +112 -0
- package/dist/types-BgIugNWW.d.cts +25 -0
- package/dist/types-BgIugNWW.d.ts +25 -0
- package/dist/types-CvKSS1Sy.d.cts +38 -0
- package/dist/types-CvKSS1Sy.d.ts +38 -0
- package/dist/variables.cjs +95 -0
- package/dist/variables.cjs.map +1 -0
- package/dist/variables.d.cts +74 -0
- package/dist/variables.d.ts +74 -0
- package/dist/variables.js +6 -0
- package/dist/variables.js.map +1 -0
- package/package.json +39 -8
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { MutableRefObject, ReactNode } from 'react';
|
|
3
|
+
import { Data, IframeConfig, ComponentData, Metadata, Dictionary, PuckApi, Config } from '@puckeditor/core';
|
|
4
|
+
import { R as Registry } from './types-CvKSS1Sy.cjs';
|
|
5
|
+
import { T as Theme } from './theme-BuEFpQeZ.cjs';
|
|
6
|
+
import { T as Translator } from './catalogContext-DenbX-OW.cjs';
|
|
7
|
+
import { V as VariableDef, c as VariableResolver, b as VariableContext, U as UnresolvedDisplay } from './types-BgIugNWW.cjs';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import 'styled-components';
|
|
10
|
+
|
|
11
|
+
type DataUpdater = Data | ((previous: Data) => Data);
|
|
12
|
+
/** Handle imperativo que a lib preenche para o host mutar o documento sem remontar o editor. */
|
|
13
|
+
type DocumentEditorApi = {
|
|
14
|
+
/**
|
|
15
|
+
* Substitui o `data` do editor no lugar (sem remount). Dispara o `onChange` do host uma vez
|
|
16
|
+
* com o novo `data` (a menos que ele seja deep-equal ao anterior — ver docs/theme.md).
|
|
17
|
+
*/
|
|
18
|
+
setData: (data: DataUpdater) => void;
|
|
19
|
+
};
|
|
20
|
+
type DocumentEditorApiRef = MutableRefObject<DocumentEditorApi | null> | ((api: DocumentEditorApi | null) => void);
|
|
21
|
+
|
|
22
|
+
type DocumentHeaderApi = {
|
|
23
|
+
undo: () => void;
|
|
24
|
+
redo: () => void;
|
|
25
|
+
canUndo: boolean;
|
|
26
|
+
canRedo: boolean;
|
|
27
|
+
openSettings: () => void;
|
|
28
|
+
openPreview: () => void;
|
|
29
|
+
theme: Theme;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type DisabledBlock = {
|
|
33
|
+
key: string;
|
|
34
|
+
reason?: string;
|
|
35
|
+
};
|
|
36
|
+
type SettingsRenderProps = {
|
|
37
|
+
open: boolean;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
theme: Theme;
|
|
40
|
+
onThemeChange: (theme: Theme) => void;
|
|
41
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
42
|
+
key?: string;
|
|
43
|
+
url?: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
type DocumentEditorProps = {
|
|
47
|
+
registry: Registry;
|
|
48
|
+
data?: Partial<Data>;
|
|
49
|
+
onChange?: (data: Data) => void;
|
|
50
|
+
onPublish?: (data: Data) => void;
|
|
51
|
+
iframe?: IframeConfig;
|
|
52
|
+
disabledBlocks?: DisabledBlock[];
|
|
53
|
+
theme?: Theme;
|
|
54
|
+
onThemeChange?: (theme: Theme) => void;
|
|
55
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
56
|
+
key?: string;
|
|
57
|
+
url?: string;
|
|
58
|
+
}>;
|
|
59
|
+
renderSettings?: (settings: SettingsRenderProps) => ReactNode;
|
|
60
|
+
renderHeader?: (api: DocumentHeaderApi) => ReactNode;
|
|
61
|
+
/** Ações extras na action bar do bloco selecionado. Recebe o item; devolva `ActionBar.Action`s. */
|
|
62
|
+
renderBlockActions?: (item: ComponentData | null) => ReactNode;
|
|
63
|
+
/** A lib preenche com `{ setData }` para o host mutar o documento sem remontar o editor. */
|
|
64
|
+
apiRef?: DocumentEditorApiRef;
|
|
65
|
+
catalog?: VariableDef[];
|
|
66
|
+
translator?: Translator;
|
|
67
|
+
resolver?: VariableResolver;
|
|
68
|
+
ctx?: VariableContext;
|
|
69
|
+
unresolvedDisplay?: UnresolvedDisplay;
|
|
70
|
+
/** Dados do host visíveis a todo bloco como `puck.metadata` (ex.: `{ isTemplate: true }`). */
|
|
71
|
+
metadata?: Metadata;
|
|
72
|
+
/** Strings da UI do Puck. Default: PT-BR (`ptBrDictionary`). */
|
|
73
|
+
dictionary?: Dictionary;
|
|
74
|
+
patchModifierState?: boolean;
|
|
75
|
+
};
|
|
76
|
+
declare function DocumentEditor({ registry, data, onChange, onPublish, iframe, theme, onThemeChange, onLogoUpload, renderSettings, renderHeader, renderBlockActions, catalog, translator, resolver, ctx, unresolvedDisplay, metadata, dictionary, patchModifierState, disabledBlocks, apiRef }: DocumentEditorProps): react.JSX.Element;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* UI do Puck em PT-BR (chaves de `defaultDictionary` do 0.23+).
|
|
80
|
+
* As interpolações (`{title}`, `{count}`, `{index}`, `{type}`, `{zoom}`, `{label}`) precisam ser preservadas.
|
|
81
|
+
* Chaves em minúscula no original são rótulos internos — mantidas em minúscula.
|
|
82
|
+
*/
|
|
83
|
+
declare const ptBrDictionary: Dictionary;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* O Puck escuta keydown/keyup no `document` (monitorHotkeys) e chama
|
|
87
|
+
* `e.getModifierState('AltGraph')` sem checar o tipo do evento. Extensão de navegador, gerenciador
|
|
88
|
+
* de senha ou IME que dispara `new Event('keydown')` em vez de `KeyboardEvent` — comum no Linux —
|
|
89
|
+
* derruba a árvore com `e.getModifierState is not a function`.
|
|
90
|
+
*
|
|
91
|
+
* O fallback vive em `Event.prototype`: `KeyboardEvent`/`MouseEvent` têm implementação própria e
|
|
92
|
+
* seguem intactos; evento sem informação de modificador passa a responder `false`, que é a resposta
|
|
93
|
+
* correta. Fica no protótipo (e não num listener de captura) porque evento disparado direto no
|
|
94
|
+
* `document` chega em AT_TARGET, onde a ordem de registro decidiria quem roda primeiro.
|
|
95
|
+
*/
|
|
96
|
+
declare function installModifierStateShim(): void;
|
|
97
|
+
|
|
98
|
+
type SaveStatus = 'saving' | 'saved' | 'error';
|
|
99
|
+
type UseDocumentAutosaveOptions<T> = {
|
|
100
|
+
doc: T;
|
|
101
|
+
save: (doc: T) => Promise<void>;
|
|
102
|
+
delay?: number;
|
|
103
|
+
initialSavedAt?: Date | null;
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
};
|
|
106
|
+
type UseDocumentAutosaveResult = {
|
|
107
|
+
status: SaveStatus;
|
|
108
|
+
lastSavedAt: Date | null;
|
|
109
|
+
/** Salva o snapshot mais recente AGORA, aguardando qualquer save feito antes. */
|
|
110
|
+
flushNow: () => Promise<void>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Autosave com debounce por conteúdo e fila de saves — `flushNow()` só resolve
|
|
114
|
+
* com o snapshot mais recente persistido. Semântica completa: docs/autosave.md.
|
|
115
|
+
*/
|
|
116
|
+
declare function useDocumentAutosave<T>({ doc, save, delay, initialSavedAt, enabled }: UseDocumentAutosaveOptions<T>): UseDocumentAutosaveResult;
|
|
117
|
+
|
|
118
|
+
type DocumentSettingsModalProps = {
|
|
119
|
+
open: boolean;
|
|
120
|
+
onClose: () => void;
|
|
121
|
+
theme: Theme;
|
|
122
|
+
onThemeChange: (theme: Theme) => void;
|
|
123
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
124
|
+
key?: string;
|
|
125
|
+
url?: string;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Modal padrão de configurações do documento (aba Visual: cores, fonte, logo).
|
|
130
|
+
* Hosts que precisam de mais abas ou do próprio design system substituem via
|
|
131
|
+
* `renderSettings` no DocumentEditor.
|
|
132
|
+
*/
|
|
133
|
+
declare function DocumentSettingsModal({ open, onClose, theme, onThemeChange, onLogoUpload }: DocumentSettingsModalProps): react.JSX.Element | null;
|
|
134
|
+
|
|
135
|
+
declare const DEFAULT_COLOR_PRESETS: string[];
|
|
136
|
+
type ColorPickerProps = {
|
|
137
|
+
/** Cor escolhida (#rrggbb). `undefined` = herdando (mostra `fallback`). */
|
|
138
|
+
value?: string;
|
|
139
|
+
/** Cor efetiva exibida quando não há `value` (ex: brand do tema). */
|
|
140
|
+
fallback?: string;
|
|
141
|
+
presets?: string[];
|
|
142
|
+
/** `undefined` no argumento = herdar/limpar. */
|
|
143
|
+
onChange: (hex?: string) => void;
|
|
144
|
+
/** Quando presente, exibe a ação de herdar (ex: "Herdar do tema"). */
|
|
145
|
+
inheritLabel?: string;
|
|
146
|
+
ariaLabel?: string;
|
|
147
|
+
/** Lado do swatch em px. */
|
|
148
|
+
size?: number;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Seletor de cor unificado do gerador: swatch → popover com paleta, cor atual +
|
|
152
|
+
* hex e picker avançado (react-colorful) embutido. Usado nos blocos e no modal
|
|
153
|
+
* de configurações do documento.
|
|
154
|
+
*/
|
|
155
|
+
declare function ColorPicker({ value, fallback, presets, onChange, inheritLabel, ariaLabel, size }: ColorPickerProps): react.JSX.Element;
|
|
156
|
+
|
|
157
|
+
type ColorPickerPanelProps = {
|
|
158
|
+
/** Cor inicial (#rrggbb). */
|
|
159
|
+
value: string;
|
|
160
|
+
/** Chamado com debounce a cada ajuste (arraste, hex, RGB). */
|
|
161
|
+
onChange: (hex: string) => void;
|
|
162
|
+
debounceMs?: number;
|
|
163
|
+
};
|
|
164
|
+
/** Picker avançado (react-colorful): saturação + matiz e campos Hex/RGB, aplicação ao vivo. */
|
|
165
|
+
declare function ColorPickerPanel({ value, onChange, debounceMs }: ColorPickerPanelProps): react.JSX.Element;
|
|
166
|
+
|
|
167
|
+
declare function normalizeHex(input: string): string | null;
|
|
168
|
+
declare function hexToRgb(hex: string): {
|
|
169
|
+
r: number;
|
|
170
|
+
g: number;
|
|
171
|
+
b: number;
|
|
172
|
+
};
|
|
173
|
+
declare function rgbToHex(r: number, g: number, b: number): string;
|
|
174
|
+
|
|
175
|
+
/** Estado exposto pelo `usePuckState` / `useGetPuck`. */
|
|
176
|
+
type PuckState = PuckApi<Config>;
|
|
177
|
+
/**
|
|
178
|
+
* Hook do Puck **com seletor**. Use sempre este, nunca `usePuck()` avulso: sem seletor
|
|
179
|
+
* o componente assina o app state inteiro e re-renderiza a cada tecla digitada no canvas
|
|
180
|
+
* (o próprio Puck emite um warning nesse caso).
|
|
181
|
+
*
|
|
182
|
+
* Duas regras:
|
|
183
|
+
* - A comparação é `Object.is` — selecione primitivos ou referências estáveis
|
|
184
|
+
* (`selectedItem`, `appState.data.content`), nunca um objeto montado no seletor.
|
|
185
|
+
* - Getters (`getSelectorForId`, `getItemById`, `dispatch`…) são recriados a cada mudança
|
|
186
|
+
* de estado. O que só é lido dentro de callback vai por `useGetPuck()`, que não assina nada.
|
|
187
|
+
*/
|
|
188
|
+
declare const usePuckState: <T>(selector: (state: PuckState) => T) => T;
|
|
189
|
+
|
|
190
|
+
export { ColorPicker, ColorPickerPanel, type ColorPickerPanelProps, type ColorPickerProps, DEFAULT_COLOR_PRESETS, type DataUpdater, type DisabledBlock, DocumentEditor, type DocumentEditorApi, type DocumentEditorApiRef, type DocumentEditorProps, type DocumentHeaderApi, DocumentSettingsModal, type DocumentSettingsModalProps, type PuckState, type SaveStatus, type SettingsRenderProps, type UseDocumentAutosaveOptions, type UseDocumentAutosaveResult, hexToRgb, installModifierStateShim, normalizeHex, ptBrDictionary, rgbToHex, useDocumentAutosave, usePuckState };
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { MutableRefObject, ReactNode } from 'react';
|
|
3
|
+
import { Data, IframeConfig, ComponentData, Metadata, Dictionary, PuckApi, Config } from '@puckeditor/core';
|
|
4
|
+
import { R as Registry } from './types-CvKSS1Sy.js';
|
|
5
|
+
import { T as Theme } from './theme-BuEFpQeZ.js';
|
|
6
|
+
import { T as Translator } from './catalogContext-HGMU-w_4.js';
|
|
7
|
+
import { V as VariableDef, c as VariableResolver, b as VariableContext, U as UnresolvedDisplay } from './types-BgIugNWW.js';
|
|
8
|
+
import 'zod';
|
|
9
|
+
import 'styled-components';
|
|
10
|
+
|
|
11
|
+
type DataUpdater = Data | ((previous: Data) => Data);
|
|
12
|
+
/** Handle imperativo que a lib preenche para o host mutar o documento sem remontar o editor. */
|
|
13
|
+
type DocumentEditorApi = {
|
|
14
|
+
/**
|
|
15
|
+
* Substitui o `data` do editor no lugar (sem remount). Dispara o `onChange` do host uma vez
|
|
16
|
+
* com o novo `data` (a menos que ele seja deep-equal ao anterior — ver docs/theme.md).
|
|
17
|
+
*/
|
|
18
|
+
setData: (data: DataUpdater) => void;
|
|
19
|
+
};
|
|
20
|
+
type DocumentEditorApiRef = MutableRefObject<DocumentEditorApi | null> | ((api: DocumentEditorApi | null) => void);
|
|
21
|
+
|
|
22
|
+
type DocumentHeaderApi = {
|
|
23
|
+
undo: () => void;
|
|
24
|
+
redo: () => void;
|
|
25
|
+
canUndo: boolean;
|
|
26
|
+
canRedo: boolean;
|
|
27
|
+
openSettings: () => void;
|
|
28
|
+
openPreview: () => void;
|
|
29
|
+
theme: Theme;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type DisabledBlock = {
|
|
33
|
+
key: string;
|
|
34
|
+
reason?: string;
|
|
35
|
+
};
|
|
36
|
+
type SettingsRenderProps = {
|
|
37
|
+
open: boolean;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
theme: Theme;
|
|
40
|
+
onThemeChange: (theme: Theme) => void;
|
|
41
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
42
|
+
key?: string;
|
|
43
|
+
url?: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
type DocumentEditorProps = {
|
|
47
|
+
registry: Registry;
|
|
48
|
+
data?: Partial<Data>;
|
|
49
|
+
onChange?: (data: Data) => void;
|
|
50
|
+
onPublish?: (data: Data) => void;
|
|
51
|
+
iframe?: IframeConfig;
|
|
52
|
+
disabledBlocks?: DisabledBlock[];
|
|
53
|
+
theme?: Theme;
|
|
54
|
+
onThemeChange?: (theme: Theme) => void;
|
|
55
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
56
|
+
key?: string;
|
|
57
|
+
url?: string;
|
|
58
|
+
}>;
|
|
59
|
+
renderSettings?: (settings: SettingsRenderProps) => ReactNode;
|
|
60
|
+
renderHeader?: (api: DocumentHeaderApi) => ReactNode;
|
|
61
|
+
/** Ações extras na action bar do bloco selecionado. Recebe o item; devolva `ActionBar.Action`s. */
|
|
62
|
+
renderBlockActions?: (item: ComponentData | null) => ReactNode;
|
|
63
|
+
/** A lib preenche com `{ setData }` para o host mutar o documento sem remontar o editor. */
|
|
64
|
+
apiRef?: DocumentEditorApiRef;
|
|
65
|
+
catalog?: VariableDef[];
|
|
66
|
+
translator?: Translator;
|
|
67
|
+
resolver?: VariableResolver;
|
|
68
|
+
ctx?: VariableContext;
|
|
69
|
+
unresolvedDisplay?: UnresolvedDisplay;
|
|
70
|
+
/** Dados do host visíveis a todo bloco como `puck.metadata` (ex.: `{ isTemplate: true }`). */
|
|
71
|
+
metadata?: Metadata;
|
|
72
|
+
/** Strings da UI do Puck. Default: PT-BR (`ptBrDictionary`). */
|
|
73
|
+
dictionary?: Dictionary;
|
|
74
|
+
patchModifierState?: boolean;
|
|
75
|
+
};
|
|
76
|
+
declare function DocumentEditor({ registry, data, onChange, onPublish, iframe, theme, onThemeChange, onLogoUpload, renderSettings, renderHeader, renderBlockActions, catalog, translator, resolver, ctx, unresolvedDisplay, metadata, dictionary, patchModifierState, disabledBlocks, apiRef }: DocumentEditorProps): react.JSX.Element;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* UI do Puck em PT-BR (chaves de `defaultDictionary` do 0.23+).
|
|
80
|
+
* As interpolações (`{title}`, `{count}`, `{index}`, `{type}`, `{zoom}`, `{label}`) precisam ser preservadas.
|
|
81
|
+
* Chaves em minúscula no original são rótulos internos — mantidas em minúscula.
|
|
82
|
+
*/
|
|
83
|
+
declare const ptBrDictionary: Dictionary;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* O Puck escuta keydown/keyup no `document` (monitorHotkeys) e chama
|
|
87
|
+
* `e.getModifierState('AltGraph')` sem checar o tipo do evento. Extensão de navegador, gerenciador
|
|
88
|
+
* de senha ou IME que dispara `new Event('keydown')` em vez de `KeyboardEvent` — comum no Linux —
|
|
89
|
+
* derruba a árvore com `e.getModifierState is not a function`.
|
|
90
|
+
*
|
|
91
|
+
* O fallback vive em `Event.prototype`: `KeyboardEvent`/`MouseEvent` têm implementação própria e
|
|
92
|
+
* seguem intactos; evento sem informação de modificador passa a responder `false`, que é a resposta
|
|
93
|
+
* correta. Fica no protótipo (e não num listener de captura) porque evento disparado direto no
|
|
94
|
+
* `document` chega em AT_TARGET, onde a ordem de registro decidiria quem roda primeiro.
|
|
95
|
+
*/
|
|
96
|
+
declare function installModifierStateShim(): void;
|
|
97
|
+
|
|
98
|
+
type SaveStatus = 'saving' | 'saved' | 'error';
|
|
99
|
+
type UseDocumentAutosaveOptions<T> = {
|
|
100
|
+
doc: T;
|
|
101
|
+
save: (doc: T) => Promise<void>;
|
|
102
|
+
delay?: number;
|
|
103
|
+
initialSavedAt?: Date | null;
|
|
104
|
+
enabled?: boolean;
|
|
105
|
+
};
|
|
106
|
+
type UseDocumentAutosaveResult = {
|
|
107
|
+
status: SaveStatus;
|
|
108
|
+
lastSavedAt: Date | null;
|
|
109
|
+
/** Salva o snapshot mais recente AGORA, aguardando qualquer save feito antes. */
|
|
110
|
+
flushNow: () => Promise<void>;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Autosave com debounce por conteúdo e fila de saves — `flushNow()` só resolve
|
|
114
|
+
* com o snapshot mais recente persistido. Semântica completa: docs/autosave.md.
|
|
115
|
+
*/
|
|
116
|
+
declare function useDocumentAutosave<T>({ doc, save, delay, initialSavedAt, enabled }: UseDocumentAutosaveOptions<T>): UseDocumentAutosaveResult;
|
|
117
|
+
|
|
118
|
+
type DocumentSettingsModalProps = {
|
|
119
|
+
open: boolean;
|
|
120
|
+
onClose: () => void;
|
|
121
|
+
theme: Theme;
|
|
122
|
+
onThemeChange: (theme: Theme) => void;
|
|
123
|
+
onLogoUpload?: (file: File) => Promise<{
|
|
124
|
+
key?: string;
|
|
125
|
+
url?: string;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Modal padrão de configurações do documento (aba Visual: cores, fonte, logo).
|
|
130
|
+
* Hosts que precisam de mais abas ou do próprio design system substituem via
|
|
131
|
+
* `renderSettings` no DocumentEditor.
|
|
132
|
+
*/
|
|
133
|
+
declare function DocumentSettingsModal({ open, onClose, theme, onThemeChange, onLogoUpload }: DocumentSettingsModalProps): react.JSX.Element | null;
|
|
134
|
+
|
|
135
|
+
declare const DEFAULT_COLOR_PRESETS: string[];
|
|
136
|
+
type ColorPickerProps = {
|
|
137
|
+
/** Cor escolhida (#rrggbb). `undefined` = herdando (mostra `fallback`). */
|
|
138
|
+
value?: string;
|
|
139
|
+
/** Cor efetiva exibida quando não há `value` (ex: brand do tema). */
|
|
140
|
+
fallback?: string;
|
|
141
|
+
presets?: string[];
|
|
142
|
+
/** `undefined` no argumento = herdar/limpar. */
|
|
143
|
+
onChange: (hex?: string) => void;
|
|
144
|
+
/** Quando presente, exibe a ação de herdar (ex: "Herdar do tema"). */
|
|
145
|
+
inheritLabel?: string;
|
|
146
|
+
ariaLabel?: string;
|
|
147
|
+
/** Lado do swatch em px. */
|
|
148
|
+
size?: number;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Seletor de cor unificado do gerador: swatch → popover com paleta, cor atual +
|
|
152
|
+
* hex e picker avançado (react-colorful) embutido. Usado nos blocos e no modal
|
|
153
|
+
* de configurações do documento.
|
|
154
|
+
*/
|
|
155
|
+
declare function ColorPicker({ value, fallback, presets, onChange, inheritLabel, ariaLabel, size }: ColorPickerProps): react.JSX.Element;
|
|
156
|
+
|
|
157
|
+
type ColorPickerPanelProps = {
|
|
158
|
+
/** Cor inicial (#rrggbb). */
|
|
159
|
+
value: string;
|
|
160
|
+
/** Chamado com debounce a cada ajuste (arraste, hex, RGB). */
|
|
161
|
+
onChange: (hex: string) => void;
|
|
162
|
+
debounceMs?: number;
|
|
163
|
+
};
|
|
164
|
+
/** Picker avançado (react-colorful): saturação + matiz e campos Hex/RGB, aplicação ao vivo. */
|
|
165
|
+
declare function ColorPickerPanel({ value, onChange, debounceMs }: ColorPickerPanelProps): react.JSX.Element;
|
|
166
|
+
|
|
167
|
+
declare function normalizeHex(input: string): string | null;
|
|
168
|
+
declare function hexToRgb(hex: string): {
|
|
169
|
+
r: number;
|
|
170
|
+
g: number;
|
|
171
|
+
b: number;
|
|
172
|
+
};
|
|
173
|
+
declare function rgbToHex(r: number, g: number, b: number): string;
|
|
174
|
+
|
|
175
|
+
/** Estado exposto pelo `usePuckState` / `useGetPuck`. */
|
|
176
|
+
type PuckState = PuckApi<Config>;
|
|
177
|
+
/**
|
|
178
|
+
* Hook do Puck **com seletor**. Use sempre este, nunca `usePuck()` avulso: sem seletor
|
|
179
|
+
* o componente assina o app state inteiro e re-renderiza a cada tecla digitada no canvas
|
|
180
|
+
* (o próprio Puck emite um warning nesse caso).
|
|
181
|
+
*
|
|
182
|
+
* Duas regras:
|
|
183
|
+
* - A comparação é `Object.is` — selecione primitivos ou referências estáveis
|
|
184
|
+
* (`selectedItem`, `appState.data.content`), nunca um objeto montado no seletor.
|
|
185
|
+
* - Getters (`getSelectorForId`, `getItemById`, `dispatch`…) são recriados a cada mudança
|
|
186
|
+
* de estado. O que só é lido dentro de callback vai por `useGetPuck()`, que não assina nada.
|
|
187
|
+
*/
|
|
188
|
+
declare const usePuckState: <T>(selector: (state: PuckState) => T) => T;
|
|
189
|
+
|
|
190
|
+
export { ColorPicker, ColorPickerPanel, type ColorPickerPanelProps, type ColorPickerProps, DEFAULT_COLOR_PRESETS, type DataUpdater, type DisabledBlock, DocumentEditor, type DocumentEditorApi, type DocumentEditorApiRef, type DocumentEditorProps, type DocumentHeaderApi, DocumentSettingsModal, type DocumentSettingsModalProps, type PuckState, type SaveStatus, type SettingsRenderProps, type UseDocumentAutosaveOptions, type UseDocumentAutosaveResult, hexToRgb, installModifierStateShim, normalizeHex, ptBrDictionary, rgbToHex, useDocumentAutosave, usePuckState };
|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ColorPicker, ColorPickerPanel, DEFAULT_COLOR_PRESETS, DocumentEditor, DocumentSettingsModal, hexToRgb, installModifierStateShim, normalizeHex, ptBrDictionary, rgbToHex, useDocumentAutosave, usePuckState } from './chunk-HMTCQOEV.js';
|
|
2
|
+
import './chunk-QYBWIJXZ.js';
|
|
3
|
+
import './chunk-PLQNNXS2.js';
|
|
4
|
+
import './chunk-2EBYURIX.js';
|
|
5
|
+
import './chunk-M2TPAU2F.js';
|
|
6
|
+
//# sourceMappingURL=editor.js.map
|
|
7
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"editor.js"}
|