@xleddyl/443-components-vue 0.16.11 → 0.16.12
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/CATALOG.md +3 -3
- package/dist/editor/RichTextEditor.vue +72 -4
- package/dist/editor/RichTextEditor.vue.d.ts +2 -0
- package/dist/editor/rich-text-editor.css +20 -0
- package/dist/editor/types.d.ts +1 -1
- package/dist/locale/de.mjs +2 -1
- package/dist/locale/en.mjs +2 -1
- package/dist/locale/it.mjs +2 -1
- package/dist/locale/types.d.ts +1 -0
- package/package.json +1 -1
package/CATALOG.md
CHANGED
|
@@ -292,9 +292,9 @@ Grid helpers: `registerGridModules`, `registerGridEditorModules`, `registerGridF
|
|
|
292
292
|
|
|
293
293
|
## Editor (group `editor`)
|
|
294
294
|
|
|
295
|
-
| Component | Purpose and when to use it | Main props, models, slots, events
|
|
296
|
-
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
297
|
-
| `RichTextEditor` | Rich text field (Tiptap): headings, bold, italic, lists, quote, code, links. Use `Textarea` for plain text. | Model: `v-model` (HTML string or JSON, per `format`). Props: `format` (html, json), `placeholder`, `readonly`, `disabled`, `invalid`, `required`, `maxLength`, `showCount`, `minHeight`, `maxHeight`, `toolbar` (items and `'\|'` separators), `headings`, `headingLabel`, `linkTypes` (url, email, phone), `extensions`, `messages`. Works inside `FormField`. | `editor/rich-text-editor.vue` |
|
|
295
|
+
| Component | Purpose and when to use it | Main props, models, slots, events | Playground |
|
|
296
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
297
|
+
| `RichTextEditor` | Rich text field (Tiptap): headings, bold, italic, lists, quote, code, links. Use `Textarea` for plain text. | Model: `v-model` (HTML string or JSON, per `format`). Props: `format` (html, json), `placeholder`, `readonly`, `disabled`, `invalid`, `required`, `maxLength`, `showCount`, `minHeight`, `maxHeight`, `toolbar` (items and `'\|'` separators, `'source'` for the raw value toggle), `source` (adds the raw value toggle to the default toolbar), `headings`, `headingLabel`, `linkTypes` (url, email, phone), `extensions`, `messages`. Works inside `FormField`. | `editor/rich-text-editor.vue` |
|
|
298
298
|
|
|
299
299
|
## Chart (group `chart`)
|
|
300
300
|
|
|
@@ -101,7 +101,20 @@
|
|
|
101
101
|
/>
|
|
102
102
|
</form>
|
|
103
103
|
|
|
104
|
-
<EditorContent class="k-editor-content" :editor="editor" />
|
|
104
|
+
<EditorContent v-show="!sourceMode" class="k-editor-content" :editor="editor" />
|
|
105
|
+
<textarea
|
|
106
|
+
v-if="sourceMode"
|
|
107
|
+
ref="sourceRef"
|
|
108
|
+
class="k-editor-source"
|
|
109
|
+
:class="{ 'is-invalid': sourceInvalid }"
|
|
110
|
+
:value="sourceText"
|
|
111
|
+
:readonly="!editable"
|
|
112
|
+
:aria-label="text.source"
|
|
113
|
+
:aria-invalid="sourceInvalid ? 'true' : void 0"
|
|
114
|
+
:style="{ minHeight, maxHeight }"
|
|
115
|
+
spellcheck="false"
|
|
116
|
+
@input="onSourceInput($event.target.value)"
|
|
117
|
+
/>
|
|
105
118
|
|
|
106
119
|
<div v-if="showCount" class="k-editor-footer">
|
|
107
120
|
<span
|
|
@@ -134,6 +147,7 @@ const icons = {
|
|
|
134
147
|
undo: "M9 15 3 9m0 0 6-6M3 9h12a6 6 0 0 1 0 12h-3",
|
|
135
148
|
redo: "m15 15 6-6m0 0-6-6m6 6H9a6 6 0 0 0 0 12h3",
|
|
136
149
|
bulletList: "M9 6h12M9 12h12M9 18h12M4 6h.01M4 12h.01M4 18h.01",
|
|
150
|
+
source: "M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5",
|
|
137
151
|
link: "M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"
|
|
138
152
|
};
|
|
139
153
|
const props = defineProps({
|
|
@@ -153,7 +167,8 @@ const props = defineProps({
|
|
|
153
167
|
toolbar: { type: Array, required: false },
|
|
154
168
|
extensions: { type: Array, required: false, default: () => [] },
|
|
155
169
|
linkTypes: { type: Array, required: false, default: () => ["url"] },
|
|
156
|
-
messages: { type: Object, required: false }
|
|
170
|
+
messages: { type: Object, required: false },
|
|
171
|
+
source: { type: Boolean, required: false }
|
|
157
172
|
});
|
|
158
173
|
const model = defineModel({ type: [String, Object, null], ...{ default: null } });
|
|
159
174
|
const control = useFieldControl({
|
|
@@ -171,6 +186,10 @@ const linkUrl = ref("");
|
|
|
171
186
|
const linkText = ref("");
|
|
172
187
|
const linkType = ref("url");
|
|
173
188
|
const linkNeedsText = ref(false);
|
|
189
|
+
const sourceRef = useTemplateRef("sourceRef");
|
|
190
|
+
const sourceMode = ref(false);
|
|
191
|
+
const sourceText = ref("");
|
|
192
|
+
const sourceInvalid = ref(false);
|
|
174
193
|
const linkPrefixes = { url: "", email: "mailto:", phone: "tel:" };
|
|
175
194
|
const linkTypeLabels = computed(() => ({
|
|
176
195
|
url: text.value.linkTypeUrl,
|
|
@@ -400,7 +419,15 @@ const defaultToolbar = computed(() => [
|
|
|
400
419
|
}
|
|
401
420
|
]
|
|
402
421
|
]);
|
|
422
|
+
const sourceItem = computed(() => ({
|
|
423
|
+
id: "source",
|
|
424
|
+
label: text.value.source,
|
|
425
|
+
icon: icons.source,
|
|
426
|
+
active: () => sourceMode.value,
|
|
427
|
+
run: toggleSource
|
|
428
|
+
}));
|
|
403
429
|
const optionalItems = computed(() => [
|
|
430
|
+
sourceItem.value,
|
|
404
431
|
mark(
|
|
405
432
|
"underline",
|
|
406
433
|
text.value.underline,
|
|
@@ -423,7 +450,10 @@ function splitToolbar(toolbar) {
|
|
|
423
450
|
return result;
|
|
424
451
|
}
|
|
425
452
|
const groups = computed(() => {
|
|
426
|
-
if (!props.toolbar)
|
|
453
|
+
if (!props.toolbar)
|
|
454
|
+
return [...defaultToolbar.value, props.source ? [sourceItem.value] : []].filter(
|
|
455
|
+
(group) => group.length
|
|
456
|
+
);
|
|
427
457
|
const byId = new Map(
|
|
428
458
|
[...defaultToolbar.value.flat(), ...optionalItems.value].map((item) => [item.id, item])
|
|
429
459
|
);
|
|
@@ -437,7 +467,8 @@ const groups = computed(() => {
|
|
|
437
467
|
).filter((group) => group.length);
|
|
438
468
|
});
|
|
439
469
|
function itemAttributes(item) {
|
|
440
|
-
const
|
|
470
|
+
const locked = sourceMode.value && item.id !== "source";
|
|
471
|
+
const disabled = locked || (item.enabled ? !item.enabled() : false);
|
|
441
472
|
return {
|
|
442
473
|
"aria-label": item.label,
|
|
443
474
|
title: item.label,
|
|
@@ -448,6 +479,43 @@ function itemAttributes(item) {
|
|
|
448
479
|
onClick: item.run
|
|
449
480
|
};
|
|
450
481
|
}
|
|
482
|
+
function sourceOf(value) {
|
|
483
|
+
if (value === null || value === "") return "";
|
|
484
|
+
return typeof value === "string" ? value : JSON.stringify(value, null, 2);
|
|
485
|
+
}
|
|
486
|
+
async function toggleSource() {
|
|
487
|
+
if (sourceMode.value) {
|
|
488
|
+
sourceMode.value = false;
|
|
489
|
+
sourceInvalid.value = false;
|
|
490
|
+
await nextTick();
|
|
491
|
+
editor.value?.commands.focus();
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
linkOpen.value = false;
|
|
495
|
+
sourceText.value = sourceOf(model.value);
|
|
496
|
+
sourceInvalid.value = false;
|
|
497
|
+
sourceMode.value = true;
|
|
498
|
+
await nextTick();
|
|
499
|
+
sourceRef.value?.focus();
|
|
500
|
+
}
|
|
501
|
+
function onSourceInput(value) {
|
|
502
|
+
sourceText.value = value;
|
|
503
|
+
if (!value.trim()) {
|
|
504
|
+
sourceInvalid.value = false;
|
|
505
|
+
model.value = null;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
if (props.format !== "json") {
|
|
509
|
+
model.value = value;
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
try {
|
|
513
|
+
model.value = JSON.parse(value);
|
|
514
|
+
sourceInvalid.value = false;
|
|
515
|
+
} catch {
|
|
516
|
+
sourceInvalid.value = true;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
451
519
|
function toggleLink() {
|
|
452
520
|
if (linkOpen.value) {
|
|
453
521
|
closeLink();
|
|
@@ -19,6 +19,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
19
19
|
extensions?: Extensions;
|
|
20
20
|
linkTypes?: EditorLinkType[];
|
|
21
21
|
messages?: Partial<EditorMessages>;
|
|
22
|
+
source?: boolean;
|
|
22
23
|
modelValue?: EditorValue;
|
|
23
24
|
key?: PropertyKey | undefined;
|
|
24
25
|
prefix?: string | undefined | undefined;
|
|
@@ -234,6 +235,7 @@ declare const __VLS_export: import("vue").DefineComponent<{
|
|
|
234
235
|
extensions?: Extensions;
|
|
235
236
|
linkTypes?: EditorLinkType[];
|
|
236
237
|
messages?: Partial<EditorMessages>;
|
|
238
|
+
source?: boolean;
|
|
237
239
|
modelValue?: EditorValue;
|
|
238
240
|
key?: PropertyKey | undefined;
|
|
239
241
|
prefix?: string | undefined | undefined;
|
|
@@ -291,3 +291,23 @@
|
|
|
291
291
|
.k-editor-count.is-over {
|
|
292
292
|
color: var(--k-danger-text);
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
.k-editor-source {
|
|
296
|
+
flex: 1;
|
|
297
|
+
width: 100%;
|
|
298
|
+
min-width: 0;
|
|
299
|
+
padding: 0.625rem 0.875rem;
|
|
300
|
+
overflow-y: auto;
|
|
301
|
+
font-family: var(--k-font-mono);
|
|
302
|
+
font-size: 0.8125rem;
|
|
303
|
+
line-height: 1.6;
|
|
304
|
+
color: var(--k-text-toned);
|
|
305
|
+
background: transparent;
|
|
306
|
+
border: 0;
|
|
307
|
+
outline: none;
|
|
308
|
+
resize: vertical;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.k-editor-source.is-invalid {
|
|
312
|
+
color: var(--k-danger-text);
|
|
313
|
+
}
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export type EditorMessages = KMessages['editor'];
|
|
|
6
6
|
export type EditorHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
7
|
export type EditorHeadingLabel = 'level' | 'relative';
|
|
8
8
|
export type EditorLinkType = 'url' | 'email' | 'phone';
|
|
9
|
-
export type EditorToolbarItem = 'undo' | 'redo' | 'headings' | `h${EditorHeadingLevel}` | 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'blockquote' | 'link' | '|';
|
|
9
|
+
export type EditorToolbarItem = 'undo' | 'redo' | 'headings' | `h${EditorHeadingLevel}` | 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'bulletList' | 'orderedList' | 'blockquote' | 'link' | 'source' | '|';
|
|
10
10
|
export type EditorToolbar = EditorToolbarItem[] | EditorToolbarItem[][];
|
package/dist/locale/de.mjs
CHANGED
|
@@ -73,7 +73,8 @@ export const de = {
|
|
|
73
73
|
linkText: "Linktext",
|
|
74
74
|
characters: "{count} Zeichen | {count} Zeichen",
|
|
75
75
|
limit: "{count} von {max} Zeichen",
|
|
76
|
-
limitReached: "Zeichenlimit erreicht"
|
|
76
|
+
limitReached: "Zeichenlimit erreicht",
|
|
77
|
+
source: "Quelltext"
|
|
77
78
|
},
|
|
78
79
|
grid: {
|
|
79
80
|
noRows: "Keine Zeilen vorhanden",
|
package/dist/locale/en.mjs
CHANGED
|
@@ -73,7 +73,8 @@ export const en = {
|
|
|
73
73
|
linkText: "Link text",
|
|
74
74
|
characters: "{count} character | {count} characters",
|
|
75
75
|
limit: "{count} of {max} characters",
|
|
76
|
-
limitReached: "Character limit reached"
|
|
76
|
+
limitReached: "Character limit reached",
|
|
77
|
+
source: "Source"
|
|
77
78
|
},
|
|
78
79
|
grid: {
|
|
79
80
|
noRows: "No rows to show",
|
package/dist/locale/it.mjs
CHANGED
|
@@ -73,7 +73,8 @@ export const it = {
|
|
|
73
73
|
linkText: "Testo del link",
|
|
74
74
|
characters: "{count} carattere | {count} caratteri",
|
|
75
75
|
limit: "{count} di {max} caratteri",
|
|
76
|
-
limitReached: "Limite di caratteri raggiunto"
|
|
76
|
+
limitReached: "Limite di caratteri raggiunto",
|
|
77
|
+
source: "Codice sorgente"
|
|
77
78
|
},
|
|
78
79
|
grid: {
|
|
79
80
|
noRows: "Nessuna riga da mostrare",
|
package/dist/locale/types.d.ts
CHANGED
package/package.json
CHANGED