@wrrdev/fenix-ui 1.1.14 → 1.1.15
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 +5 -4
- package/dist/components/editor/commands.d.ts +27 -0
- package/dist/components/editor/commands.d.ts.map +1 -0
- package/dist/components/editor/commands.js +235 -0
- package/dist/components/editor/commands.js.map +1 -0
- package/dist/components/editor/editor.d.ts +83 -0
- package/dist/components/editor/editor.d.ts.map +1 -0
- package/dist/components/editor/editor.js +1951 -0
- package/dist/components/editor/editor.js.map +1 -0
- package/dist/components/editor/index.d.ts +12 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/editor/index.js.map +1 -0
- package/dist/components/editor/normalize-html.d.ts +33 -0
- package/dist/components/editor/normalize-html.d.ts.map +1 -0
- package/dist/components/editor/normalize-html.js +316 -0
- package/dist/components/editor/normalize-html.js.map +1 -0
- package/dist/components/editor/sanitize-html.d.ts +37 -0
- package/dist/components/editor/sanitize-html.d.ts.map +1 -0
- package/dist/components/editor/sanitize-html.js +247 -0
- package/dist/components/editor/sanitize-html.js.map +1 -0
- package/dist/components/editor/schema.d.ts +36 -0
- package/dist/components/editor/schema.d.ts.map +1 -0
- package/dist/components/editor/schema.js +232 -0
- package/dist/components/editor/schema.js.map +1 -0
- package/dist/components/editor/selection.d.ts +22 -0
- package/dist/components/editor/selection.d.ts.map +1 -0
- package/dist/components/editor/selection.js +97 -0
- package/dist/components/editor/selection.js.map +1 -0
- package/dist/components/editor/styles.d.ts +10 -0
- package/dist/components/editor/styles.d.ts.map +1 -0
- package/dist/components/editor/styles.js +446 -0
- package/dist/components/editor/styles.js.map +1 -0
- package/dist/components/editor/table-utils.d.ts +33 -0
- package/dist/components/editor/table-utils.d.ts.map +1 -0
- package/dist/components/editor/table-utils.js +150 -0
- package/dist/components/editor/table-utils.js.map +1 -0
- package/dist/components/input/input.d.ts +5 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/input.js +15 -1
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/toast/toast.d.ts +10 -10
- package/dist/components/toast/toast.d.ts.map +1 -1
- package/dist/components/toast/toast.js +46 -13
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/core/jsx.d.ts +25 -1
- package/dist/core/jsx.d.ts.map +1 -1
- package/dist/core/jsx.js.map +1 -1
- package/dist/core/vue.d.ts +3 -1
- package/dist/core/vue.d.ts.map +1 -1
- package/dist/core/vue.js.map +1 -1
- package/dist/docs/componentes/editor.doc.d.ts +6 -0
- package/dist/docs/componentes/editor.doc.d.ts.map +1 -0
- package/dist/docs/componentes/index.d.ts.map +1 -1
- package/dist/docs/componentes/input.doc.d.ts.map +1 -1
- package/dist/fenix-ui.umd.min.js +748 -254
- package/dist/fenix-ui2.esm.js.map +1 -1
- package/dist/fenix-ui4.esm.js +3817 -183
- package/dist/fenix-ui4.esm.js.map +1 -1
- package/dist/fenix-ui5.esm.js +1 -0
- package/dist/fenix-ui5.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/auto-import.d.ts.map +1 -1
- package/dist/plugins/auto-import.js +1 -0
- package/dist/plugins/auto-import.js.map +1 -1
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ import { FenixUI } from '@wrrdev/fenix-ui'; // API de tema/tokens (índice)
|
|
|
18
18
|
FenixUI.theme('dark');
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
> 📦 npm: [`@wrrdev/fenix-ui`](https://www.npmjs.com/package/@wrrdev/fenix-ui) — **v1.1.
|
|
22
|
-
> Subpaths disponíveis: `./theme`, `./tokens`, `./jsx`, `./vue`, `./react`, `./button`, `./badge`, `./spinner`, `./select`, `./input`, `./switch`, `./textarea`, `./checkbox`, `./radio`, `./calendar`, `./datepicker`, `./multiselect`, `./table`, `./floatlabel`, `./dialog`, `./toast`, `./tooltip`, `./tabs`, `./progress`, `./skeleton`, `./alert`, `./drawer`, `./dropdown`, `./icon`, `./icons`, `./pagination`, `./autocomplete`, `./knob`, `./orderlist`, `./picklist`, `./auto-import` e o curinga `./components/*`.
|
|
21
|
+
> 📦 npm: [`@wrrdev/fenix-ui`](https://www.npmjs.com/package/@wrrdev/fenix-ui) — **v1.1.15**, acesso público.
|
|
22
|
+
> Subpaths disponíveis: `./theme`, `./tokens`, `./jsx`, `./vue`, `./react`, `./button`, `./badge`, `./spinner`, `./select`, `./input`, `./switch`, `./textarea`, `./editor`, `./checkbox`, `./radio`, `./calendar`, `./datepicker`, `./multiselect`, `./table`, `./floatlabel`, `./dialog`, `./toast`, `./tooltip`, `./tabs`, `./progress`, `./skeleton`, `./alert`, `./drawer`, `./dropdown`, `./icon`, `./icons`, `./pagination`, `./autocomplete`, `./knob`, `./orderlist`, `./picklist`, `./auto-import` e o curinga `./components/*`.
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
## Consumo
|
|
@@ -65,7 +65,7 @@ Carregue o bundle **UMD** único: ele registra todos os componentes e expõe os
|
|
|
65
65
|
<fx-toast></fx-toast>
|
|
66
66
|
|
|
67
67
|
<!--
|
|
68
|
-
🔗 Links diretos para CDN (versão 1.1.
|
|
68
|
+
🔗 Links diretos para CDN (versão 1.1.15):
|
|
69
69
|
• https://cdn.jsdelivr.net/npm/@wrrdev/fenix-ui@latest/dist/fenix-ui.umd.min.js
|
|
70
70
|
• https://unpkg.com/@wrrdev/fenix-ui@latest/dist/fenix-ui.umd.min.js
|
|
71
71
|
-->
|
|
@@ -140,6 +140,7 @@ export default defineConfig({
|
|
|
140
140
|
| `fx-table` | `@wrrdev/fenix-ui/table` |
|
|
141
141
|
| `fx-floatlabel` | `@wrrdev/fenix-ui/floatlabel` |
|
|
142
142
|
| `fx-textarea` | `@wrrdev/fenix-ui/textarea` |
|
|
143
|
+
| `fx-editor` | `@wrrdev/fenix-ui/editor` |
|
|
143
144
|
| `fx-dialog` | `@wrrdev/fenix-ui/dialog` |
|
|
144
145
|
| `fx-drawer` | `@wrrdev/fenix-ui/drawer` |
|
|
145
146
|
| `fx-toast` | `@wrrdev/fenix-ui/toast` |
|
|
@@ -392,7 +393,7 @@ ative o modo estrito do Volar no `tsconfig.json`:
|
|
|
392
393
|
|--------------|-----------------------------------------------|--------------|
|
|
393
394
|
| `fx-button` | `variant` (primary/secondary/success/warning/danger/ghost/outline), `size`, `disabled`, `loading`, `type`, `full` | default, `icon` |
|
|
394
395
|
| `fx-badge` | `variant` (default/primary/success/warning/danger/info), `round` | default |
|
|
395
|
-
| `fx-input` | `type` (text/number/
|
|
396
|
+
| `fx-input` | `type` (text/number/password), `value`, `size`, `placeholder`, `disabled`, `readonly`, `min/max/step` | — |
|
|
396
397
|
| `fx-select` | `value`, `size` (sm/md/lg), `disabled`, `placeholder` — filhos `<option>` nativos | `(padrão)` |
|
|
397
398
|
| `fx-switch` | `checked`, `disabled`, `size` (sm/md/lg) | `(padrão)` |
|
|
398
399
|
| `fx-spinner` | `size` (sm/md/lg) | — |
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camada de comandos do <fx-editor>.
|
|
3
|
+
*
|
|
4
|
+
* `document.execCommand` é deprecated, mas ainda é o único caminho que
|
|
5
|
+
* preserva o undo nativo sem um modelo de documento. Ele fica isolado aqui;
|
|
6
|
+
* quando não existe (jsdom, navegador futuro), caímos para Selection/Range.
|
|
7
|
+
*/
|
|
8
|
+
export declare function nativeExec(command: string, value?: string): boolean;
|
|
9
|
+
export declare function queryState(command: string): boolean | null;
|
|
10
|
+
/** Insere HTML na seleção. Usa `insertHTML` nativo quando disponível. */
|
|
11
|
+
export declare function insertHtml(editor: HTMLElement, html: string): boolean;
|
|
12
|
+
/** Alterna uma marca inline (strong/em/u/s/code/sub/sup/mark). */
|
|
13
|
+
export declare function toggleInline(editor: HTMLElement, tag: string): boolean;
|
|
14
|
+
/** Formata o bloco atual/selecionado para p, h1..h6, blockquote ou pre. */
|
|
15
|
+
export declare function formatBlock(editor: HTMLElement, tag: string): boolean;
|
|
16
|
+
/** Alinhamento de bloco. */
|
|
17
|
+
export declare function align(editor: HTMLElement, value: 'left' | 'center' | 'right' | 'justify'): boolean;
|
|
18
|
+
/** Lista com/sem ordem. */
|
|
19
|
+
export declare function toggleList(editor: HTMLElement, ordered: boolean): boolean;
|
|
20
|
+
/** Limpa formatação inline mantendo o texto. */
|
|
21
|
+
export declare function removeFormat(editor: HTMLElement): boolean;
|
|
22
|
+
export declare function applyLink(editor: HTMLElement, href: string, text?: string, target?: string): boolean;
|
|
23
|
+
export declare function unlink(editor: HTMLElement): boolean;
|
|
24
|
+
export declare function indent(editor: HTMLElement, delta: number): boolean;
|
|
25
|
+
export declare function escapeAttr(value: string): string;
|
|
26
|
+
export declare function escapeText(value: string): string;
|
|
27
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/components/editor/commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAQnE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAQ1D;AAED,yEAAyE;AACzE,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAsBrE;AAiCD,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CA4BtE;AAED,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAkBrE;AAED,4BAA4B;AAC5B,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAalG;AAED,2BAA2B;AAC3B,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAsBzE;AAED,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAczD;AAMD,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,SAAW,GAAG,OAAO,CA2CtG;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAanD;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAWlE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { getSelectedBlocks, getBlock, getRange, placeCaretAtEnd } from "./selection.js";
|
|
2
|
+
function setSelection(range) {
|
|
3
|
+
const selection = document.getSelection();
|
|
4
|
+
if (!selection) return;
|
|
5
|
+
selection.removeAllRanges();
|
|
6
|
+
selection.addRange(range);
|
|
7
|
+
}
|
|
8
|
+
function nativeExec(command, value) {
|
|
9
|
+
const exec = document.execCommand;
|
|
10
|
+
if (typeof exec !== "function") return false;
|
|
11
|
+
try {
|
|
12
|
+
return exec.call(document, command, false, value);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function insertHtml(editor, html) {
|
|
18
|
+
if (nativeExec("insertHTML", html)) return true;
|
|
19
|
+
const range = getRange(editor);
|
|
20
|
+
if (!range) {
|
|
21
|
+
editor.insertAdjacentHTML("beforeend", html);
|
|
22
|
+
placeCaretAtEnd(editor);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
range.deleteContents();
|
|
26
|
+
const fragment = range.createContextualFragment(html);
|
|
27
|
+
const last = fragment.lastChild;
|
|
28
|
+
range.insertNode(fragment);
|
|
29
|
+
if (last) {
|
|
30
|
+
const next = document.createRange();
|
|
31
|
+
next.setStartAfter(last);
|
|
32
|
+
next.collapse(true);
|
|
33
|
+
setSelection(next);
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
function unwrap(el) {
|
|
38
|
+
const parent = el.parentNode;
|
|
39
|
+
if (!parent) return;
|
|
40
|
+
while (el.firstChild) parent.insertBefore(el.firstChild, el);
|
|
41
|
+
el.remove();
|
|
42
|
+
}
|
|
43
|
+
function wrapSelection(editor, tag) {
|
|
44
|
+
const range = getRange(editor);
|
|
45
|
+
if (!range) return false;
|
|
46
|
+
const el = document.createElement(tag);
|
|
47
|
+
if (range.collapsed) {
|
|
48
|
+
el.appendChild(document.createTextNode(""));
|
|
49
|
+
range.insertNode(el);
|
|
50
|
+
const caret = document.createRange();
|
|
51
|
+
caret.setStart(el.firstChild ?? el, 1);
|
|
52
|
+
caret.collapse(true);
|
|
53
|
+
setSelection(caret);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
range.surroundContents(el);
|
|
58
|
+
} catch {
|
|
59
|
+
el.appendChild(range.extractContents());
|
|
60
|
+
range.insertNode(el);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
function toggleInline(editor, tag) {
|
|
65
|
+
const nativeMap = {
|
|
66
|
+
strong: "bold",
|
|
67
|
+
b: "bold",
|
|
68
|
+
em: "italic",
|
|
69
|
+
i: "italic",
|
|
70
|
+
u: "underline",
|
|
71
|
+
s: "strikeThrough",
|
|
72
|
+
strike: "strikeThrough"
|
|
73
|
+
};
|
|
74
|
+
const nativeCommand = nativeMap[tag];
|
|
75
|
+
if (nativeCommand && nativeExec(nativeCommand)) return true;
|
|
76
|
+
const range = getRange(editor);
|
|
77
|
+
if (!range) return false;
|
|
78
|
+
const current = (range.startContainer.nodeType === Node.ELEMENT_NODE ? range.startContainer : range.startContainer.parentElement)?.closest(tag);
|
|
79
|
+
if (current && editor.contains(current)) {
|
|
80
|
+
unwrap(current);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
return wrapSelection(editor, tag);
|
|
84
|
+
}
|
|
85
|
+
function formatBlock(editor, tag) {
|
|
86
|
+
const normalized = tag.toLowerCase().replace(/[<>]/g, "");
|
|
87
|
+
if (nativeExec("formatBlock", normalized)) return true;
|
|
88
|
+
const blocks = getSelectedBlocks(editor);
|
|
89
|
+
if (!blocks.length) {
|
|
90
|
+
const block = getBlock(editor);
|
|
91
|
+
if (block) blocks.push(block);
|
|
92
|
+
}
|
|
93
|
+
for (const block of blocks) {
|
|
94
|
+
if (!editor.contains(block)) continue;
|
|
95
|
+
const next = document.createElement(normalized);
|
|
96
|
+
for (const attr of Array.from(block.attributes)) next.setAttribute(attr.name, attr.value);
|
|
97
|
+
while (block.firstChild) next.appendChild(block.firstChild);
|
|
98
|
+
block.replaceWith(next);
|
|
99
|
+
}
|
|
100
|
+
return blocks.length > 0;
|
|
101
|
+
}
|
|
102
|
+
function align(editor, value) {
|
|
103
|
+
const nativeMap = {
|
|
104
|
+
left: "justifyLeft",
|
|
105
|
+
center: "justifyCenter",
|
|
106
|
+
right: "justifyRight",
|
|
107
|
+
justify: "justifyFull"
|
|
108
|
+
};
|
|
109
|
+
if (nativeExec(nativeMap[value])) return true;
|
|
110
|
+
const blocks = getSelectedBlocks(editor);
|
|
111
|
+
for (const block of blocks) block.style.textAlign = value;
|
|
112
|
+
return blocks.length > 0;
|
|
113
|
+
}
|
|
114
|
+
function toggleList(editor, ordered) {
|
|
115
|
+
if (nativeExec(ordered ? "insertOrderedList" : "insertUnorderedList")) return true;
|
|
116
|
+
const blocks = getSelectedBlocks(editor);
|
|
117
|
+
if (!blocks.length) return false;
|
|
118
|
+
const list = document.createElement(ordered ? "ol" : "ul");
|
|
119
|
+
const first = blocks[0];
|
|
120
|
+
first.parentNode?.insertBefore(list, first);
|
|
121
|
+
for (const block of blocks) {
|
|
122
|
+
const li = document.createElement("li");
|
|
123
|
+
while (block.firstChild) li.appendChild(block.firstChild);
|
|
124
|
+
list.appendChild(li);
|
|
125
|
+
block.remove();
|
|
126
|
+
}
|
|
127
|
+
const range = document.createRange();
|
|
128
|
+
range.selectNodeContents(list.lastElementChild ?? list);
|
|
129
|
+
range.collapse(false);
|
|
130
|
+
setSelection(range);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function removeFormat(editor) {
|
|
134
|
+
if (nativeExec("removeFormat")) return true;
|
|
135
|
+
const range = getRange(editor);
|
|
136
|
+
if (!range) return false;
|
|
137
|
+
const root = range.commonAncestorContainer;
|
|
138
|
+
const container = root.nodeType === Node.ELEMENT_NODE ? root : root.parentElement;
|
|
139
|
+
if (!container) return false;
|
|
140
|
+
const tags = ["strong", "b", "em", "i", "u", "s", "strike", "span", "mark", "code", "sub", "sup"];
|
|
141
|
+
for (const el of Array.from(container.querySelectorAll(tags.join(",")))) {
|
|
142
|
+
if (range.intersectsNode(el)) unwrap(el);
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const linkHtml = (href, label, target) => `<a href="${escapeAttr(href)}" target="${target}" rel="noopener noreferrer">${escapeText(label)}</a>`;
|
|
147
|
+
function applyLink(editor, href, text, target = "_blank") {
|
|
148
|
+
const label = text?.trim() || href;
|
|
149
|
+
const range = getRange(editor);
|
|
150
|
+
if (!range) return insertHtml(editor, linkHtml(href, label, target));
|
|
151
|
+
const anchor = (range.startContainer.nodeType === Node.ELEMENT_NODE ? range.startContainer : range.startContainer.parentElement)?.closest("a");
|
|
152
|
+
if (anchor && editor.contains(anchor)) {
|
|
153
|
+
anchor.setAttribute("href", href);
|
|
154
|
+
anchor.setAttribute("target", target);
|
|
155
|
+
anchor.setAttribute("rel", "noopener noreferrer");
|
|
156
|
+
if (text && text !== anchor.textContent) anchor.textContent = text;
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (!range.collapsed) {
|
|
160
|
+
if (nativeExec("createLink", href)) {
|
|
161
|
+
const created = (range.startContainer.nodeType === Node.ELEMENT_NODE ? range.startContainer : range.startContainer.parentElement)?.closest("a");
|
|
162
|
+
created?.setAttribute("target", target);
|
|
163
|
+
created?.setAttribute("rel", "noopener noreferrer");
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
const el = document.createElement("a");
|
|
167
|
+
el.setAttribute("href", href);
|
|
168
|
+
el.setAttribute("target", target);
|
|
169
|
+
el.setAttribute("rel", "noopener noreferrer");
|
|
170
|
+
try {
|
|
171
|
+
range.surroundContents(el);
|
|
172
|
+
} catch {
|
|
173
|
+
el.appendChild(range.extractContents());
|
|
174
|
+
range.insertNode(el);
|
|
175
|
+
}
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
return insertHtml(editor, linkHtml(href, label, target));
|
|
179
|
+
}
|
|
180
|
+
function unlink(editor) {
|
|
181
|
+
if (nativeExec("unlink")) return true;
|
|
182
|
+
const range = getRange(editor);
|
|
183
|
+
if (!range) return false;
|
|
184
|
+
const anchor = (range.startContainer.nodeType === Node.ELEMENT_NODE ? range.startContainer : range.startContainer.parentElement)?.closest("a");
|
|
185
|
+
if (anchor && editor.contains(anchor)) {
|
|
186
|
+
unwrap(anchor);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
function indent(editor, delta) {
|
|
192
|
+
if (delta > 0 && nativeExec("indent")) return true;
|
|
193
|
+
if (delta < 0 && nativeExec("outdent")) return true;
|
|
194
|
+
const blocks = getSelectedBlocks(editor);
|
|
195
|
+
for (const block of blocks) {
|
|
196
|
+
const current = Number.parseInt(block.style.marginLeft || "0", 10) || 0;
|
|
197
|
+
const next = Math.max(0, current + delta);
|
|
198
|
+
block.style.marginLeft = next ? `${next}px` : "";
|
|
199
|
+
}
|
|
200
|
+
return blocks.length > 0;
|
|
201
|
+
}
|
|
202
|
+
function escapeAttr(value) {
|
|
203
|
+
return value.replace(/[&<>"']/g, (ch) => {
|
|
204
|
+
switch (ch) {
|
|
205
|
+
case "&":
|
|
206
|
+
return "&";
|
|
207
|
+
case "<":
|
|
208
|
+
return "<";
|
|
209
|
+
case ">":
|
|
210
|
+
return ">";
|
|
211
|
+
case '"':
|
|
212
|
+
return """;
|
|
213
|
+
default:
|
|
214
|
+
return "'";
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
function escapeText(value) {
|
|
219
|
+
return value.replace(/[&<>]/g, (ch) => ch === "&" ? "&" : ch === "<" ? "<" : ">");
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
align,
|
|
223
|
+
applyLink,
|
|
224
|
+
escapeAttr,
|
|
225
|
+
escapeText,
|
|
226
|
+
formatBlock,
|
|
227
|
+
indent,
|
|
228
|
+
insertHtml,
|
|
229
|
+
nativeExec,
|
|
230
|
+
removeFormat,
|
|
231
|
+
toggleInline,
|
|
232
|
+
toggleList,
|
|
233
|
+
unlink
|
|
234
|
+
};
|
|
235
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sources":["../../../src/components/editor/commands.ts"],"sourcesContent":["/**\n * Camada de comandos do <fx-editor>.\n *\n * `document.execCommand` é deprecated, mas ainda é o único caminho que\n * preserva o undo nativo sem um modelo de documento. Ele fica isolado aqui;\n * quando não existe (jsdom, navegador futuro), caímos para Selection/Range.\n */\n\nimport { getBlock, getRange, getSelectedBlocks, placeCaretAtEnd } from './selection';\n\ntype ExecDocument = Document & {\n execCommand?: (commandId: string, showUI?: boolean, value?: string) => boolean;\n};\n\nfunction setSelection(range: Range): void {\n const selection = document.getSelection();\n if (!selection) return;\n selection.removeAllRanges();\n selection.addRange(range);\n}\n\nexport function nativeExec(command: string, value?: string): boolean {\n const exec = (document as ExecDocument).execCommand;\n if (typeof exec !== 'function') return false;\n try {\n return exec.call(document, command, false, value);\n } catch {\n return false;\n }\n}\n\nexport function queryState(command: string): boolean | null {\n try {\n return typeof document.queryCommandState === 'function'\n ? document.queryCommandState(command)\n : null;\n } catch {\n return null;\n }\n}\n\n/** Insere HTML na seleção. Usa `insertHTML` nativo quando disponível. */\nexport function insertHtml(editor: HTMLElement, html: string): boolean {\n if (nativeExec('insertHTML', html)) return true;\n\n const range = getRange(editor);\n if (!range) {\n editor.insertAdjacentHTML('beforeend', html);\n placeCaretAtEnd(editor);\n return true;\n }\n\n range.deleteContents();\n const fragment = range.createContextualFragment(html);\n const last = fragment.lastChild;\n range.insertNode(fragment);\n\n if (last) {\n const next = document.createRange();\n next.setStartAfter(last);\n next.collapse(true);\n setSelection(next);\n }\n return true;\n}\n\nfunction unwrap(el: Element): void {\n const parent = el.parentNode;\n if (!parent) return;\n while (el.firstChild) parent.insertBefore(el.firstChild, el);\n el.remove();\n}\n\nfunction wrapSelection(editor: HTMLElement, tag: string): boolean {\n const range = getRange(editor);\n if (!range) return false;\n\n const el = document.createElement(tag);\n if (range.collapsed) {\n el.appendChild(document.createTextNode('\\u200B'));\n range.insertNode(el);\n const caret = document.createRange();\n caret.setStart(el.firstChild ?? el, 1);\n caret.collapse(true);\n setSelection(caret);\n return true;\n }\n\n try {\n range.surroundContents(el);\n } catch {\n el.appendChild(range.extractContents());\n range.insertNode(el);\n }\n return true;\n}\n\n/** Alterna uma marca inline (strong/em/u/s/code/sub/sup/mark). */\nexport function toggleInline(editor: HTMLElement, tag: string): boolean {\n const nativeMap: Record<string, string> = {\n strong: 'bold',\n b: 'bold',\n em: 'italic',\n i: 'italic',\n u: 'underline',\n s: 'strikeThrough',\n strike: 'strikeThrough',\n };\n\n const nativeCommand = nativeMap[tag];\n if (nativeCommand && nativeExec(nativeCommand)) return true;\n\n const range = getRange(editor);\n if (!range) return false;\n\n const current = (range.startContainer.nodeType === Node.ELEMENT_NODE\n ? (range.startContainer as Element)\n : range.startContainer.parentElement\n )?.closest(tag);\n\n if (current && editor.contains(current)) {\n unwrap(current);\n return true;\n }\n\n return wrapSelection(editor, tag);\n}\n\n/** Formata o bloco atual/selecionado para p, h1..h6, blockquote ou pre. */\nexport function formatBlock(editor: HTMLElement, tag: string): boolean {\n const normalized = tag.toLowerCase().replace(/[<>]/g, '');\n if (nativeExec('formatBlock', normalized)) return true;\n\n const blocks = getSelectedBlocks(editor);\n if (!blocks.length) {\n const block = getBlock(editor);\n if (block) blocks.push(block);\n }\n\n for (const block of blocks) {\n if (!editor.contains(block)) continue;\n const next = document.createElement(normalized);\n for (const attr of Array.from(block.attributes)) next.setAttribute(attr.name, attr.value);\n while (block.firstChild) next.appendChild(block.firstChild);\n block.replaceWith(next);\n }\n return blocks.length > 0;\n}\n\n/** Alinhamento de bloco. */\nexport function align(editor: HTMLElement, value: 'left' | 'center' | 'right' | 'justify'): boolean {\n const nativeMap = {\n left: 'justifyLeft',\n center: 'justifyCenter',\n right: 'justifyRight',\n justify: 'justifyFull',\n } as const;\n\n if (nativeExec(nativeMap[value])) return true;\n\n const blocks = getSelectedBlocks(editor);\n for (const block of blocks) block.style.textAlign = value;\n return blocks.length > 0;\n}\n\n/** Lista com/sem ordem. */\nexport function toggleList(editor: HTMLElement, ordered: boolean): boolean {\n if (nativeExec(ordered ? 'insertOrderedList' : 'insertUnorderedList')) return true;\n\n const blocks = getSelectedBlocks(editor);\n if (!blocks.length) return false;\n\n const list = document.createElement(ordered ? 'ol' : 'ul');\n const first = blocks[0];\n first.parentNode?.insertBefore(list, first);\n\n for (const block of blocks) {\n const li = document.createElement('li');\n while (block.firstChild) li.appendChild(block.firstChild);\n list.appendChild(li);\n block.remove();\n }\n\n const range = document.createRange();\n range.selectNodeContents(list.lastElementChild ?? list);\n range.collapse(false);\n setSelection(range);\n return true;\n}\n\n/** Limpa formatação inline mantendo o texto. */\nexport function removeFormat(editor: HTMLElement): boolean {\n if (nativeExec('removeFormat')) return true;\n\n const range = getRange(editor);\n if (!range) return false;\n const root = range.commonAncestorContainer;\n const container = root.nodeType === Node.ELEMENT_NODE ? (root as Element) : root.parentElement;\n if (!container) return false;\n\n const tags = ['strong', 'b', 'em', 'i', 'u', 's', 'strike', 'span', 'mark', 'code', 'sub', 'sup'];\n for (const el of Array.from(container.querySelectorAll(tags.join(',')))) {\n if (range.intersectsNode(el)) unwrap(el);\n }\n return true;\n}\n\n/** Cria/edita link na seleção. */\nconst linkHtml = (href: string, label: string, target: string): string =>\n `<a href=\"${escapeAttr(href)}\" target=\"${target}\" rel=\"noopener noreferrer\">${escapeText(label)}</a>`;\n\nexport function applyLink(editor: HTMLElement, href: string, text?: string, target = '_blank'): boolean {\n const label = text?.trim() || href;\n const range = getRange(editor);\n if (!range) return insertHtml(editor, linkHtml(href, label, target));\n\n const anchor = (range.startContainer.nodeType === Node.ELEMENT_NODE\n ? (range.startContainer as Element)\n : range.startContainer.parentElement\n )?.closest('a');\n\n if (anchor && editor.contains(anchor)) {\n anchor.setAttribute('href', href);\n anchor.setAttribute('target', target);\n anchor.setAttribute('rel', 'noopener noreferrer');\n if (text && text !== anchor.textContent) anchor.textContent = text;\n return true;\n }\n\n if (!range.collapsed) {\n if (nativeExec('createLink', href)) {\n const created = (range.startContainer.nodeType === Node.ELEMENT_NODE\n ? (range.startContainer as Element)\n : range.startContainer.parentElement\n )?.closest('a');\n created?.setAttribute('target', target);\n created?.setAttribute('rel', 'noopener noreferrer');\n return true;\n }\n\n const el = document.createElement('a');\n el.setAttribute('href', href);\n el.setAttribute('target', target);\n el.setAttribute('rel', 'noopener noreferrer');\n try {\n range.surroundContents(el);\n } catch {\n el.appendChild(range.extractContents());\n range.insertNode(el);\n }\n return true;\n }\n\n return insertHtml(editor, linkHtml(href, label, target));\n}\n\nexport function unlink(editor: HTMLElement): boolean {\n if (nativeExec('unlink')) return true;\n const range = getRange(editor);\n if (!range) return false;\n const anchor = (range.startContainer.nodeType === Node.ELEMENT_NODE\n ? (range.startContainer as Element)\n : range.startContainer.parentElement\n )?.closest('a');\n if (anchor && editor.contains(anchor)) {\n unwrap(anchor);\n return true;\n }\n return false;\n}\n\nexport function indent(editor: HTMLElement, delta: number): boolean {\n if (delta > 0 && nativeExec('indent')) return true;\n if (delta < 0 && nativeExec('outdent')) return true;\n\n const blocks = getSelectedBlocks(editor);\n for (const block of blocks) {\n const current = Number.parseInt(block.style.marginLeft || '0', 10) || 0;\n const next = Math.max(0, current + delta);\n block.style.marginLeft = next ? `${next}px` : '';\n }\n return blocks.length > 0;\n}\n\nexport function escapeAttr(value: string): string {\n return value.replace(/[&<>\"']/g, (ch) => {\n switch (ch) {\n case '&': return '&';\n case '<': return '<';\n case '>': return '>';\n case '\"': return '"';\n default: return ''';\n }\n });\n}\n\nexport function escapeText(value: string): string {\n return value.replace(/[&<>]/g, (ch) => (ch === '&' ? '&' : ch === '<' ? '<' : '>'));\n}\n\n"],"names":[],"mappings":";AAcA,SAAS,aAAa,OAAoB;AACxC,QAAM,YAAY,SAAS,aAAA;AAC3B,MAAI,CAAC,UAAW;AAChB,YAAU,gBAAA;AACV,YAAU,SAAS,KAAK;AAC1B;AAEO,SAAS,WAAW,SAAiB,OAAyB;AACnE,QAAM,OAAQ,SAA0B;AACxC,MAAI,OAAO,SAAS,WAAY,QAAO;AACvC,MAAI;AACF,WAAO,KAAK,KAAK,UAAU,SAAS,OAAO,KAAK;AAAA,EAClD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAaO,SAAS,WAAW,QAAqB,MAAuB;AACrE,MAAI,WAAW,cAAc,IAAI,EAAG,QAAO;AAE3C,QAAM,QAAQ,SAAS,MAAM;AAC7B,MAAI,CAAC,OAAO;AACV,WAAO,mBAAmB,aAAa,IAAI;AAC3C,oBAAgB,MAAM;AACtB,WAAO;AA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,KAAK,WAAW,QAAQ,EAAG,QAAO;AAC9C,MAAI,QAAQ,KAAK,WAAW,SAAS,EAAG,QAAO;AAE/C,QAAM,SAAS,kBAAkB,MAAM;AACvC,aAAW,SAAS,QAAQ;AAC1B,UAAM,UAAU,OAAO,SAAS,MAAM,MAAM,cAAc,KAAK,EAAE,KAAK;AACtE,UAAM,OAAO,KAAK,IAAI,GAAG,UAAU,KAAK;AACxC,UAAM,MAAM,aAAa,OAAO,GAAG,IAAI,OAAO;AAAA,EAChD;AACA,SAAO,OAAO,SAAS;AACzB;AAEO,SAAS,WAAW,OAAuB;AAChD,SAAO,MAAM,QAAQ,YAAY,CAAC,OAAO;AACvC,YAAQ,IAAA;AAAA,MACN,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB,KAAK;AAAK,eAAO;AAAA,MACjB;AAAS,eAAO;AAAA,IAAA;AAAA,EAEpB,CAAC;AACH;AAEO,SAAS,WAAW,OAAuB;AAChD,SAAO,MAAM,QAAQ,UAAU,CAAC,OAAQ,OAAO,MAAM,UAAU,OAAO,MAAM,SAAS,MAAO;AAC9F;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FxFormElement } from '../../core/form-element';
|
|
2
|
+
export type FxEditorToolbar = 'minimal' | 'basic' | 'standard' | 'full' | 'none';
|
|
3
|
+
export type FxEditorPasteMode = 'clean' | 'plain';
|
|
4
|
+
export interface FxEditorChangeDetail {
|
|
5
|
+
value: string;
|
|
6
|
+
html: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export type FxEditorUploadResult = string | {
|
|
10
|
+
url: string;
|
|
11
|
+
alt?: string;
|
|
12
|
+
width?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* <fx-editor> — editor de texto rico nativo.
|
|
16
|
+
*
|
|
17
|
+
* Form-associated: com `name` entra no FormData com o HTML sanitizado.
|
|
18
|
+
* O atributo `value` é o conteúdo inicial (como o texto de um <textarea>);
|
|
19
|
+
* a propriedade `value` é o conteúdo atual.
|
|
20
|
+
*/
|
|
21
|
+
export declare class FxEditor extends FxFormElement {
|
|
22
|
+
#private;
|
|
23
|
+
static styles: string;
|
|
24
|
+
static get observedAttributes(): string[];
|
|
25
|
+
/** Callback opcional de upload de imagem. */
|
|
26
|
+
uploadImage?: (file: File) => Promise<FxEditorUploadResult>;
|
|
27
|
+
/** Hook opcional de sanitização extra (roda depois do sanitizador interno). */
|
|
28
|
+
sanitizeHtml?: (html: string) => string;
|
|
29
|
+
get editor(): HTMLElement | null;
|
|
30
|
+
get source(): HTMLTextAreaElement | null;
|
|
31
|
+
get toolbarEl(): HTMLElement | null;
|
|
32
|
+
get value(): string;
|
|
33
|
+
set value(next: string);
|
|
34
|
+
get html(): string;
|
|
35
|
+
set html(next: string);
|
|
36
|
+
get text(): string;
|
|
37
|
+
get defaultValue(): string;
|
|
38
|
+
set defaultValue(next: string);
|
|
39
|
+
get disabled(): boolean;
|
|
40
|
+
set disabled(value: boolean);
|
|
41
|
+
get readonly(): boolean;
|
|
42
|
+
set readonly(value: boolean);
|
|
43
|
+
get required(): boolean;
|
|
44
|
+
set required(value: boolean);
|
|
45
|
+
get placeholder(): string;
|
|
46
|
+
set placeholder(value: string);
|
|
47
|
+
get toolbar(): FxEditorToolbar;
|
|
48
|
+
set toolbar(value: FxEditorToolbar);
|
|
49
|
+
get pasteMode(): FxEditorPasteMode;
|
|
50
|
+
set pasteMode(value: FxEditorPasteMode);
|
|
51
|
+
get fullscreen(): boolean;
|
|
52
|
+
set fullscreen(value: boolean);
|
|
53
|
+
/** Limite de caracteres de texto (0 desativa). Padrão: 30.000. */
|
|
54
|
+
get maxlength(): number;
|
|
55
|
+
set maxlength(value: number);
|
|
56
|
+
protected connectedCallback(): void;
|
|
57
|
+
protected disconnectedCallback(): void;
|
|
58
|
+
protected attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
59
|
+
formResetCallback(): void;
|
|
60
|
+
protected getFormValue(): string | FormData | null;
|
|
61
|
+
protected render(): void;
|
|
62
|
+
focus(options?: FocusOptions): void;
|
|
63
|
+
blur(): void;
|
|
64
|
+
execute(command: string, value?: string): void;
|
|
65
|
+
insertHTML(html: string): void;
|
|
66
|
+
/** Mescla as células tocadas pela seleção. */
|
|
67
|
+
mergeCells(): boolean;
|
|
68
|
+
/** Divide a célula mesclada atual. */
|
|
69
|
+
splitCell(): boolean;
|
|
70
|
+
getHtml(): string;
|
|
71
|
+
setHtml(html: string): void;
|
|
72
|
+
getText(): string;
|
|
73
|
+
clear(): void;
|
|
74
|
+
undo(): void;
|
|
75
|
+
redo(): void;
|
|
76
|
+
saveSelection(): void;
|
|
77
|
+
restoreSelection(): void;
|
|
78
|
+
openDialog(kind: 'link' | 'image' | 'video'): void;
|
|
79
|
+
toggleSource(): void;
|
|
80
|
+
toggleFullscreen(): void;
|
|
81
|
+
}
|
|
82
|
+
export declare function defineFxEditor(): typeof FxEditor;
|
|
83
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgCxD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AACjF,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,M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