@aquera/nile-elements 0.1.67-beta-2.2 → 0.1.67-beta-2.3
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/dist/index.js +63 -51
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +22 -12
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.esm.js +4 -2
- package/dist/nile-rich-text-editor/nile-rte-toolbar.cjs.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +22 -12
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +2 -2
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +41 -12
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-select.js +5 -3
- package/dist/src/nile-rich-text-editor/nile-rte-select.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-toolbar.js +2 -2
- package/dist/src/nile-rich-text-editor/nile-rte-toolbar.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +22 -12
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +53 -15
- package/src/nile-rich-text-editor/nile-rte-select.ts +5 -3
- package/src/nile-rich-text-editor/nile-rte-toolbar.ts +2 -2
- package/vscode-html-custom-data.json +8 -3
package/package.json
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
"description": "Webcomponent nile-elements following open-wc recommendations",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "nile-elements",
|
6
|
-
"version": "0.1.67-beta-2.
|
6
|
+
"version": "0.1.67-beta-2.3",
|
7
7
|
"main": "dist/src/index.js",
|
8
8
|
"type": "module",
|
9
9
|
"module": "dist/src/index.js",
|
@@ -9,7 +9,7 @@ export const styles = css`
|
|
9
9
|
nile-rich-text-editor { position: relative; display: block; font-family: inherit; }
|
10
10
|
|
11
11
|
|
12
|
-
nile-rte-toolbar-item
|
12
|
+
nile-rte-toolbar-item nile-button::part(base) {
|
13
13
|
|
14
14
|
width:32px; height:32px; padding:0px 6px;
|
15
15
|
border: none;
|
@@ -21,9 +21,20 @@ nile-rte-preview {
|
|
21
21
|
}
|
22
22
|
|
23
23
|
|
24
|
+
.editor.single-line {
|
25
|
+
width: 478px;
|
26
|
+
min-height: 50px;
|
27
|
+
overflow-x: auto;
|
28
|
+
white-space: nowrap;
|
29
|
+
border-radius: 8px;
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
24
36
|
|
25
37
|
.toolbar, nile-rte-toolbar {
|
26
|
-
|
27
38
|
width:486px;
|
28
39
|
display:flex; align-items:center; gap:6px; padding:8px;
|
29
40
|
border:1px solid #e5e7eb; border-bottom:none; border-radius:8px 8px 0 0; background:#fff;
|
@@ -70,6 +81,13 @@ font-weight: bold;}
|
|
70
81
|
}
|
71
82
|
nile-rte-preview { display:block; margin-top:10px; padding:10px; border:1px dashed #cbd5e1; border-radius:8px; background:#fafafa; max-width:478px; }
|
72
83
|
|
84
|
+
nile-rte-preview.single-line {
|
85
|
+
width: 478px;
|
86
|
+
min-height: 50px;
|
87
|
+
overflow-x: auto;
|
88
|
+
white-space: nowrap;
|
89
|
+
}
|
90
|
+
|
73
91
|
.rte-color-trigger {
|
74
92
|
display: inline-flex;
|
75
93
|
align-items: center;
|
@@ -105,7 +123,6 @@ nile-button.rte-color-trigger::part(base){
|
|
105
123
|
border-radius: 2px;
|
106
124
|
background: currentColor;
|
107
125
|
}
|
108
|
-
|
109
126
|
|
110
127
|
.rte-color-trigger .swatch-box {
|
111
128
|
width: 18px;
|
@@ -114,20 +131,13 @@ nile-button.rte-color-trigger::part(base){
|
|
114
131
|
border: 1px solid rgba(0,0,0,0.35);
|
115
132
|
background: currentColor; /* overridden via JS */
|
116
133
|
}
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
nile-rte-toolbar-item > nile-button[data-active]::part(base) {
|
134
|
+
nile-rte-toolbar-item nile-button[data-active]::part(base) {
|
122
135
|
background-color: var(--nile-colors-primary-400);
|
123
136
|
}
|
124
137
|
|
125
|
-
nile-rte-toolbar-item
|
138
|
+
nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
126
139
|
background-color: var(--nile-colors-primary-500);
|
127
140
|
}
|
128
|
-
|
129
|
-
|
130
|
-
|
131
141
|
`;
|
132
142
|
|
133
143
|
export default [styles];
|
@@ -21,10 +21,11 @@ import {styles} from './nile-rich-text-editor.css';
|
|
21
21
|
|
22
22
|
type MentionsConfig = Record<string, { key: string; label: string }[]>;
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
28
29
|
const DEFAULT_ICONS: Record<string, string> = {
|
29
30
|
bold: 'format_bold',
|
30
31
|
italic: 'format_italic',
|
@@ -44,10 +45,11 @@ export class NileRichTextEditor extends LitElement {
|
|
44
45
|
protected createRenderRoot() { return this; }
|
45
46
|
protected shouldUpdate() { return false; }
|
46
47
|
|
47
|
-
|
48
|
+
|
48
49
|
@property({ type: String }) value = '';
|
50
|
+
@property({ type: Boolean, attribute: 'singlelineeditor' })singleLineEditor = false;
|
49
51
|
|
50
|
-
|
52
|
+
|
51
53
|
@property({
|
52
54
|
attribute: 'mentions',
|
53
55
|
converter: {
|
@@ -71,7 +73,7 @@ export class NileRichTextEditor extends LitElement {
|
|
71
73
|
})
|
72
74
|
mentions: MentionsConfig = {};
|
73
75
|
|
74
|
-
|
76
|
+
|
75
77
|
@state() private content = '';
|
76
78
|
private editorEl!: HTMLElement;
|
77
79
|
private previewEl: HTMLElement | null = null;
|
@@ -79,7 +81,7 @@ export class NileRichTextEditor extends LitElement {
|
|
79
81
|
|
80
82
|
private lastRange: Range | null = null;
|
81
83
|
|
82
|
-
|
84
|
+
|
83
85
|
private buttonMap = new Map<string, HTMLElement[]>();
|
84
86
|
private headingSelect: HTMLSelectElement | null = null;
|
85
87
|
private fontSelect: HTMLSelectElement | null = null;
|
@@ -89,7 +91,7 @@ private colorSwatchEl: HTMLElement | null = null;
|
|
89
91
|
private bgSwatchEl: HTMLElement | null = null;
|
90
92
|
|
91
93
|
|
92
|
-
|
94
|
+
|
93
95
|
private mentionsEl: HTMLElement | null = null;
|
94
96
|
|
95
97
|
|
@@ -112,7 +114,10 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
112
114
|
|
113
115
|
this.toolbarEl = this.querySelector('nile-rte-toolbar');
|
114
116
|
this.previewEl = this.querySelector('nile-rte-preview');
|
115
|
-
|
117
|
+
if (this.singleLineEditor) {
|
118
|
+
this.editorEl?.classList.add('single-line');
|
119
|
+
this.previewEl?.classList.add('single-line');
|
120
|
+
}
|
116
121
|
|
117
122
|
this.ensureEditor();
|
118
123
|
|
@@ -172,9 +177,17 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
172
177
|
}
|
173
178
|
super.disconnectedCallback();
|
174
179
|
}
|
175
|
-
|
176
|
-
|
177
|
-
|
180
|
+
protected updated(changed: Map<string, any>) {
|
181
|
+
if (changed.has('singleLineEditor')) {
|
182
|
+
if (this.editorEl) {
|
183
|
+
this.editorEl.classList.toggle('single-line', this.singleLineEditor);
|
184
|
+
}
|
185
|
+
if (this.previewEl) {
|
186
|
+
this.previewEl.classList.toggle('single-line', this.singleLineEditor);
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
178
191
|
|
179
192
|
private ensureEditor() {
|
180
193
|
this.editorEl = this.querySelector('.editor') as HTMLElement;
|
@@ -182,6 +195,8 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
182
195
|
const editor = document.createElement('article');
|
183
196
|
editor.className = 'editor';
|
184
197
|
editor.setAttribute('contenteditable','true');
|
198
|
+
if (this.singleLineEditor) editor.classList.add('single-line');
|
199
|
+
|
185
200
|
if (this.toolbarEl?.nextSibling) {
|
186
201
|
this.insertBefore(editor, this.toolbarEl.nextSibling);
|
187
202
|
} else if (this.previewEl) {
|
@@ -196,6 +211,7 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
196
211
|
}
|
197
212
|
this.ensureAtLeastOneParagraph();
|
198
213
|
}
|
214
|
+
|
199
215
|
|
200
216
|
|
201
217
|
private unwrapMention(span: HTMLElement, preserveText = true) {
|
@@ -251,6 +267,22 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
251
267
|
|
252
268
|
|
253
269
|
private onEditorKeydown = (e: KeyboardEvent) => {
|
270
|
+
if (this.singleLineEditor && e.key === 'Enter' && e.shiftKey) {
|
271
|
+
e.preventDefault();
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
if (e.ctrlKey && e.key.toLowerCase() === 'i') {
|
275
|
+
e.preventDefault();
|
276
|
+
toggleInlineTag(this.editorEl, 'em');
|
277
|
+
this.updateContent();
|
278
|
+
this.updateToolbarState();
|
279
|
+
}
|
280
|
+
|
281
|
+
|
282
|
+
if (this.singleLineEditor && e.key === 'Enter' ) {
|
283
|
+
e.preventDefault();
|
284
|
+
return;
|
285
|
+
}
|
254
286
|
if (e.key !== 'Tab') return;
|
255
287
|
|
256
288
|
e.preventDefault();
|
@@ -365,8 +397,14 @@ private bgSwatchEl: HTMLElement | null = null;
|
|
365
397
|
child.innerHTML = '';
|
366
398
|
}
|
367
399
|
|
368
|
-
|
369
|
-
|
400
|
+
// Mount button inside tooltip
|
401
|
+
if (!btn.isConnected) {
|
402
|
+
const tooltip = document.createElement('nile-tooltip');
|
403
|
+
tooltip.setAttribute('content', label);
|
404
|
+
tooltip.appendChild(btn);
|
405
|
+
child.appendChild(tooltip);
|
406
|
+
}
|
407
|
+
|
370
408
|
|
371
409
|
// Interactions
|
372
410
|
btn.setAttribute('aria-label', label);
|
@@ -129,10 +129,11 @@ export class NileRteSelect extends LitElement {
|
|
129
129
|
box-shadow: none;
|
130
130
|
}
|
131
131
|
nile-button.rte-align-trigger::part(base) {
|
132
|
-
|
133
132
|
|
134
133
|
border: none;
|
135
134
|
}
|
135
|
+
|
136
|
+
|
136
137
|
`;
|
137
138
|
this.insertBefore(style, this.firstChild);
|
138
139
|
}
|
@@ -159,7 +160,9 @@ export class NileRteSelect extends LitElement {
|
|
159
160
|
class="rte-align-item"
|
160
161
|
?active=${o.value === this.selectedValue}
|
161
162
|
@click=${() => this.onSelect(o.value)}>
|
162
|
-
<nile-
|
163
|
+
<nile-tooltip hoist content="${o.label}">
|
164
|
+
<nile-icon name="${o.icon}"></nile-icon>
|
165
|
+
</nile-tooltip>
|
163
166
|
</nile-menu-item>
|
164
167
|
`)}
|
165
168
|
</nile-menu>
|
@@ -167,7 +170,6 @@ export class NileRteSelect extends LitElement {
|
|
167
170
|
`;
|
168
171
|
}
|
169
172
|
|
170
|
-
// ► Font: show labels, preview fonts in items and trigger
|
171
173
|
if (this.type === 'font') {
|
172
174
|
const triggerText = current?.label || this.label || 'Font';
|
173
175
|
return html`
|
@@ -3,7 +3,7 @@ import { customElement } from 'lit/decorators.js';
|
|
3
3
|
|
4
4
|
@customElement('nile-rte-toolbar')
|
5
5
|
export class NileRteToolbar extends LitElement {
|
6
|
-
protected createRenderRoot() { return this; }
|
7
|
-
protected shouldUpdate() { return false; }
|
6
|
+
protected createRenderRoot() { return this; }
|
7
|
+
protected shouldUpdate() { return false; }
|
8
8
|
}
|
9
9
|
declare global { interface HTMLElementTagNameMap { 'nile-rte-toolbar': NileRteToolbar; } }
|
@@ -2953,15 +2953,20 @@
|
|
2953
2953
|
},
|
2954
2954
|
{
|
2955
2955
|
"name": "nile-rich-text-editor",
|
2956
|
-
"description": "Events:\n\n * `content-changed` {`CustomEvent<{ content: string; mention: any; }>`} - \n\nAttributes:\n\n * `value` {`string`} -
|
2956
|
+
"description": "Events:\n\n * `content-changed` {`CustomEvent<{ content: string; mention: any; }>`} - \n\nAttributes:\n\n * `value` {`string`} - \n\n * `singlelineeditor` {`boolean`} - \n\n * `mentions` - \n\nProperties:\n\n * `value` {`string`} - \n\n * `singleLineEditor` {`boolean`} - \n\n * `mentions` - \n\n * `content` {`string`} - \n\n * `editorEl` {`HTMLElement`} - \n\n * `previewEl` {`HTMLElement | null`} - \n\n * `toolbarEl` {`HTMLElement | null`} - \n\n * `lastRange` {`Range | null`} - \n\n * `buttonMap` {`Map<string, HTMLElement[]>`} - \n\n * `headingSelect` {`HTMLSelectElement | null`} - \n\n * `fontSelect` {`HTMLSelectElement | null`} - \n\n * `colorInput` {`HTMLInputElement | null`} - \n\n * `bgColorInput` {`HTMLInputElement | null`} - \n\n * `colorSwatchEl` {`HTMLElement | null`} - \n\n * `bgSwatchEl` {`HTMLElement | null`} - \n\n * `mentionsEl` {`HTMLElement | null`} - \n\n * `onEditorKeydown` - \n\n * `onSelectionChange` - ",
|
2957
2957
|
"attributes": [
|
2958
2958
|
{
|
2959
2959
|
"name": "value",
|
2960
|
-
"description": "`value` {`string`} -
|
2960
|
+
"description": "`value` {`string`} - \n\nProperty: value\n\nDefault: "
|
2961
|
+
},
|
2962
|
+
{
|
2963
|
+
"name": "singlelineeditor",
|
2964
|
+
"description": "`singlelineeditor` {`boolean`} - \n\nProperty: singleLineEditor\n\nDefault: false",
|
2965
|
+
"valueSet": "v"
|
2961
2966
|
},
|
2962
2967
|
{
|
2963
2968
|
"name": "mentions",
|
2964
|
-
"description": "`mentions` -
|
2969
|
+
"description": "`mentions` - \n\nProperty: mentions\n\nDefault: [object Object]"
|
2965
2970
|
},
|
2966
2971
|
{
|
2967
2972
|
"name": "oncontent-changed",
|