@aquera/nile-elements 1.9.5 → 1.9.6
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 +6 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +470 -298
- package/dist/nile-chip/nile-chip.css.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.css.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.css.esm.js +8 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.esm.js +3 -3
- package/dist/nile-hero/nile-hero.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.cjs.js.map +1 -1
- package/dist/nile-hero/nile-hero.css.cjs.js +1 -1
- package/dist/nile-hero/nile-hero.css.cjs.js.map +1 -1
- package/dist/nile-hero/nile-hero.css.esm.js +14 -14
- package/dist/nile-hero/nile-hero.esm.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.cjs.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.cjs.js.map +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.cjs.js +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.cjs.js.map +1 -1
- package/dist/nile-hero-header/nile-hero-header.css.esm.js +11 -11
- package/dist/nile-hero-header/nile-hero-header.esm.js +3 -3
- package/dist/nile-rich-text-editor/index.cjs.js +1 -1
- package/dist/nile-rich-text-editor/index.esm.js +1 -1
- 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 +70 -0
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-image.cjs.js +3 -0
- package/dist/nile-rich-text-editor/nile-rte-image.cjs.js.map +1 -0
- package/dist/nile-rich-text-editor/nile-rte-image.esm.js +96 -0
- package/dist/src/nile-chip/nile-chip.css.js +8 -1
- package/dist/src/nile-chip/nile-chip.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.js +3 -3
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-hero/nile-hero.css.js +12 -12
- package/dist/src/nile-hero/nile-hero.css.js.map +1 -1
- package/dist/src/nile-hero/nile-hero.js +1 -1
- package/dist/src/nile-hero/nile-hero.js.map +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.css.js +9 -9
- package/dist/src/nile-hero-header/nile-hero-header.css.js.map +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.js +1 -1
- package/dist/src/nile-hero-header/nile-hero-header.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +70 -0
- 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 +3 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +81 -3
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-image.d.ts +87 -0
- package/dist/src/nile-rich-text-editor/nile-rte-image.js +1073 -0
- package/dist/src/nile-rich-text-editor/nile-rte-image.js.map +1 -0
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-chip/nile-chip.css.ts +8 -1
- package/src/nile-code-editor/nile-code-editor.ts +3 -3
- package/src/nile-hero/nile-hero.css.ts +12 -12
- package/src/nile-hero/nile-hero.ts +1 -1
- package/src/nile-hero-header/nile-hero-header.css.ts +9 -9
- package/src/nile-hero-header/nile-hero-header.ts +1 -1
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +70 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +89 -3
- package/src/nile-rich-text-editor/nile-rte-image.ts +1132 -0
- package/vscode-html-custom-data.json +41 -1
package/package.json
CHANGED
|
@@ -89,11 +89,13 @@ export const styles = css`
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
.nile-chip {
|
|
92
|
-
padding: var(--nile-spacing-5px,var(
|
|
92
|
+
padding: var(--nile-spacing-5px,var(--ng-spacing-xs)) var(--nile-spacing-10px,var(--ng-spacing-lg));
|
|
93
|
+
min-height: var(--ng-height-40px);
|
|
93
94
|
background-color: var(--nile-colors-white-base,var( --ng-colors-bg-primary));
|
|
94
95
|
border-radius: var(--nile-radius-radius-xs,var(--ng-radius-md));
|
|
95
96
|
border: solid 1px var(--nile-colors-neutral-500,var(--ng-colors-border-primary));
|
|
96
97
|
display: flex;
|
|
98
|
+
align-items: center;
|
|
97
99
|
flex-wrap: wrap;
|
|
98
100
|
width: 100%;
|
|
99
101
|
overflow-x: hidden;
|
|
@@ -102,6 +104,7 @@ export const styles = css`
|
|
|
102
104
|
|
|
103
105
|
nile-input::part(base) {
|
|
104
106
|
padding: 0px !important;
|
|
107
|
+
height: auto;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
.nile-chip--no-wrap {
|
|
@@ -171,6 +174,10 @@ export const styles = css`
|
|
|
171
174
|
nile-auto-complete::part(input) {
|
|
172
175
|
padding: var(--nile-spacing-lg, var(--ng-spacing-none));
|
|
173
176
|
}
|
|
177
|
+
|
|
178
|
+
nile-auto-complete::part(base) {
|
|
179
|
+
height: auto;
|
|
180
|
+
}
|
|
174
181
|
|
|
175
182
|
.nile-chip:hover:not(.nile-chip--disabled) {
|
|
176
183
|
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-neutral));
|
|
@@ -298,12 +298,12 @@ export class NileCodeEditor extends NileElement {
|
|
|
298
298
|
${this.expandable && !this.disabled
|
|
299
299
|
? html`
|
|
300
300
|
<div @click="${(e: CustomEvent) => this.emit('nile-expand')}" class="expand__icon__container">
|
|
301
|
-
<nile-
|
|
301
|
+
<nile-glyph
|
|
302
302
|
name="${this.expandIcon}"
|
|
303
|
-
method="var(--nile-svg-method-fill, var(--ng-svg-method-
|
|
303
|
+
method="var(--nile-svg-method-fill, var(--ng-svg-method-fill))"
|
|
304
304
|
size="16"
|
|
305
305
|
color="black"
|
|
306
|
-
></nile-
|
|
306
|
+
></nile-glyph>
|
|
307
307
|
</div>`
|
|
308
308
|
: ''}
|
|
309
309
|
</div>
|
|
@@ -37,12 +37,12 @@ export const styles = css`
|
|
|
37
37
|
|
|
38
38
|
.hero__container--collapsed{
|
|
39
39
|
height: 67px;
|
|
40
|
-
background-color: var(--nile-hero-collapsed-background);
|
|
40
|
+
background-color: var(--nile-hero-collapsed-background, var(--ng-colors-bg-primary));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
.hero__container--expanded{
|
|
44
|
-
height:var(--nile-hero-height);
|
|
45
|
-
background:linear-gradient(180deg, var( --nile-hero-color-bg-from-gradient) 0%, var( --nile-hero-color-bg-to-gradient) 100%);
|
|
44
|
+
height:var(--nile-hero-height, var(--ng-height-200px));
|
|
45
|
+
background:linear-gradient(180deg, var( --nile-hero-color-bg-from-gradient, var(--ng-color-bluelight-50)) 0%, var( --nile-hero-color-bg-to-gradient, var(--ng-componentcolors-utility-gray-200)) 100%);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
.icon__container {
|
|
@@ -50,17 +50,17 @@ export const styles = css`
|
|
|
50
50
|
aspect-ratio: 1 / 1;
|
|
51
51
|
place-items: center;
|
|
52
52
|
display: grid;
|
|
53
|
-
border-radius: var(--nile-radius-radius-xl);
|
|
54
|
-
border: 1px solid var(--nile-colors-neutral-400);
|
|
55
|
-
background: linear-gradient(180deg, var(--nile-hero-color-icon-bg-from-gradient) 0%, var(--nile-hero-color-icon-bg-to-gradient) 100%);
|
|
53
|
+
border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
54
|
+
border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
55
|
+
background: linear-gradient(180deg, var(--nile-hero-color-icon-bg-from-gradient, var(--ng-colors-bg-primary)) 0%, var(--nile-hero-color-icon-bg-to-gradient, var(--ng-colors-bg-secondary)) 100%);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
.hero__slot__container {
|
|
59
|
-
height:var(--nile-hero-height);
|
|
60
|
-
padding-left: var(--nile-spacing-5xl);
|
|
59
|
+
height:var(--nile-hero-height, var(--ng-height-200px));
|
|
60
|
+
padding-left: var(--nile-spacing-5xl, var(--ng-spacing-5xl));
|
|
61
61
|
display: flex;
|
|
62
62
|
align-items: center;
|
|
63
|
-
gap:var(--nile-spacing-spacing-xl);
|
|
63
|
+
gap:var(--nile-spacing-spacing-xl, var(--ng-spacing-xl));
|
|
64
64
|
position: absolute;
|
|
65
65
|
left: 0;
|
|
66
66
|
bottom:0;
|
|
@@ -69,11 +69,11 @@ export const styles = css`
|
|
|
69
69
|
|
|
70
70
|
.hero__slot {
|
|
71
71
|
display: flex;
|
|
72
|
-
gap:var(--nile-spacing-spacing-xl);
|
|
72
|
+
gap:var(--nile-spacing-spacing-xl, var(--ng-spacing-xl));
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
.hero__img__container {
|
|
76
|
-
height:var(--nile-hero-height);
|
|
76
|
+
height:var(--nile-hero-height, var(--ng-height-200px));
|
|
77
77
|
overflow:hidden;
|
|
78
78
|
width:max-content;
|
|
79
79
|
position: absolute;
|
|
@@ -84,7 +84,7 @@ export const styles = css`
|
|
|
84
84
|
|
|
85
85
|
.hero__img {
|
|
86
86
|
object-fit:cover;
|
|
87
|
-
height:var(--nile-hero-height);
|
|
87
|
+
height:var(--nile-hero-height, var(--ng-height-200px));
|
|
88
88
|
width:auto;
|
|
89
89
|
}
|
|
90
90
|
`;
|
|
@@ -52,7 +52,7 @@ export class NileHero extends NileElement {
|
|
|
52
52
|
<div class="hero__slot__container" style="opacity:${this.collapse?0:1}">
|
|
53
53
|
<div class="hero__slot">
|
|
54
54
|
<span class="icon__container">
|
|
55
|
-
<nile-icon size="16" method="var(--nile-svg-method-stroke, var(--ng-svg-method-
|
|
55
|
+
<nile-icon size="16" method="var(--nile-svg-method-stroke, var(--ng-svg-method-fill))" name="${this.icon}"></nile-icon>
|
|
56
56
|
</span>
|
|
57
57
|
<slot></slot>
|
|
58
58
|
</div>
|
|
@@ -16,8 +16,8 @@ export const styles = css`
|
|
|
16
16
|
width:100%;
|
|
17
17
|
display: flex;
|
|
18
18
|
align-items: center;
|
|
19
|
-
padding:var(--nile-spacing-xl) var(--nile-spacing-5xl);
|
|
20
|
-
gap: var(--nile-spacing-xl);
|
|
19
|
+
padding:var(--nile-spacing-xl, var(--ng-spacing-xl)) var(--nile-spacing-5xl, var(--ng-spacing-5xl));
|
|
20
|
+
gap: var(--nile-spacing-xl, var(--ng-spacing-xl));
|
|
21
21
|
border-bottom: 1px solid rgb(234, 236, 240);
|
|
22
22
|
-webkit-font-smoothing: var(--nile-webkit-font-smoothing, var(--ng-webkit-font-smoothing));
|
|
23
23
|
-moz-osx-font-smoothing: var(--nile-moz-osx-font-smoothing, var(--ng-moz-osx-font-smoothing));
|
|
@@ -29,17 +29,17 @@ export const styles = css`
|
|
|
29
29
|
aspect-ratio: 1 / 1;
|
|
30
30
|
place-items: center;
|
|
31
31
|
display: grid;
|
|
32
|
-
border-radius: var(--nile-radius-radius-xl);
|
|
33
|
-
border: 1px solid var(--nile-colors-neutral-400);
|
|
34
|
-
background: linear-gradient(180deg, var(--nile-hero-color-icon-bg-from-gradient) 0%, var(--nile-hero-color-icon-bg-to-gradient) 100%);
|
|
32
|
+
border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
33
|
+
border: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
|
|
34
|
+
background: linear-gradient(180deg, var(--nile-hero-color-icon-bg-from-gradient, var(--ng-colors-bg-primary)) 0%, var(--nile-hero-color-icon-bg-to-gradient, var(--ng-colors-bg-secondary)) 100%);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.hero__text {
|
|
38
|
-
color: var(--nile-hero-text-color);
|
|
39
|
-
font-size: var(--nile-hero-text-font-size);
|
|
40
|
-
line-height: var(--nile-hero-text-line-height);
|
|
38
|
+
color: var(--nile-hero-text-color, var(--ng-colors-text-primary-900));
|
|
39
|
+
font-size: var(--nile-hero-text-font-size, var(--ng-font-size-text-md));
|
|
40
|
+
line-height: var(--nile-hero-text-line-height, var(--ng-line-height-text-md));
|
|
41
41
|
font-style: normal;
|
|
42
|
-
font-weight: var(--nile-hero-text-font-weight);
|
|
42
|
+
font-weight: var(--nile-hero-text-font-weight, var(--ng-font-weight-bold));
|
|
43
43
|
}
|
|
44
44
|
`;
|
|
45
45
|
|
|
@@ -41,7 +41,7 @@ export class NileHeroHeader extends NileElement {
|
|
|
41
41
|
public render(): TemplateResult {
|
|
42
42
|
return html`
|
|
43
43
|
<span class="icon__container">
|
|
44
|
-
<nile-icon method="var(--nile-svg-method-stroke, var(--ng-svg-method-
|
|
44
|
+
<nile-icon method="var(--nile-svg-method-stroke, var(--ng-svg-method-fill))" size="16" name="${this.icon}"></nile-icon>
|
|
45
45
|
</span>
|
|
46
46
|
<span class="hero__text">${this.heroText}</span>
|
|
47
47
|
`;
|
|
@@ -201,6 +201,76 @@ nile-rich-text-editor[disabled] .editor a {
|
|
|
201
201
|
pointer-events: none;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
.editor figure.rte-image,
|
|
205
|
+
nile-rte-preview figure.rte-image {
|
|
206
|
+
margin: 1em 0;
|
|
207
|
+
width: fit-content;
|
|
208
|
+
max-width: 100%;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.editor > figure.rte-image:first-child,
|
|
212
|
+
nile-rte-preview > figure.rte-image:first-child {
|
|
213
|
+
margin-top: 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.editor figure.rte-image[data-align='center'],
|
|
217
|
+
nile-rte-preview figure.rte-image[data-align='center'] {
|
|
218
|
+
margin-left: auto;
|
|
219
|
+
margin-right: auto;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.editor figure.rte-image[data-align='right'],
|
|
223
|
+
nile-rte-preview figure.rte-image[data-align='right'] {
|
|
224
|
+
margin-left: auto;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.editor figure.rte-image[data-align='justify'],
|
|
228
|
+
nile-rte-preview figure.rte-image[data-align='justify'] {
|
|
229
|
+
width: 100%;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.editor figure.rte-image[data-align='justify'] img,
|
|
233
|
+
nile-rte-preview figure.rte-image[data-align='justify'] img {
|
|
234
|
+
width: 100%;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.editor figure.rte-image img,
|
|
238
|
+
nile-rte-preview figure.rte-image img {
|
|
239
|
+
max-width: 100%;
|
|
240
|
+
height: auto;
|
|
241
|
+
display: block;
|
|
242
|
+
border-radius: var(--nile-radius-radius-lg, var(--ng-radius-md));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.editor figure.rte-image figcaption,
|
|
246
|
+
nile-rte-preview figure.rte-image figcaption {
|
|
247
|
+
margin-top: 6px;
|
|
248
|
+
font-size: 0.875em;
|
|
249
|
+
color: var(--nile-colors-neutral-600, var(--ng-colors-text-secondary));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.editor figure.rte-image {
|
|
253
|
+
cursor: pointer;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.editor figure.rte-image:hover img {
|
|
257
|
+
outline: 2px solid var(--nile-colors-primary-400, var(--ng-componentcolors-utility-blue-400));
|
|
258
|
+
outline-offset: 2px;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
nile-rte-image nile-button.rte-image-button[data-active]::part(base) {
|
|
262
|
+
background-color: var(--nile-colors-primary-400, var(--ng-componentcolors-utility-blue-400));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
nile-rte-image nile-button.rte-image-button[data-active]::part(base):hover {
|
|
266
|
+
background-color: var(--nile-colors-primary-500, var(--ng-componentcolors-utility-blue-500));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
nile-rich-text-editor[disabled] .editor figure.rte-image {
|
|
270
|
+
cursor: not-allowed;
|
|
271
|
+
pointer-events: none;
|
|
272
|
+
}
|
|
273
|
+
|
|
204
274
|
.editor.empty::before {
|
|
205
275
|
content: attr(data-placeholder);
|
|
206
276
|
color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));
|
|
@@ -9,6 +9,7 @@ import './nile-rte-divider';
|
|
|
9
9
|
import './nile-rte-preview';
|
|
10
10
|
import './nile-rte-mentions';
|
|
11
11
|
import './nile-rte-link';
|
|
12
|
+
import './nile-rte-image';
|
|
12
13
|
|
|
13
14
|
import {
|
|
14
15
|
closestBlock,
|
|
@@ -135,6 +136,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
135
136
|
private bgSwatchEl: HTMLElement | null = null;
|
|
136
137
|
private containerEl: HTMLElement | null = null;
|
|
137
138
|
private linkEl: HTMLElement | null = null;
|
|
139
|
+
private imageEl: HTMLElement | null = null;
|
|
138
140
|
|
|
139
141
|
private mentionsEl: HTMLElement | null = null;
|
|
140
142
|
|
|
@@ -265,6 +267,9 @@ export class NileRichTextEditor extends LitElement {
|
|
|
265
267
|
if (this.linkEl) {
|
|
266
268
|
(this.linkEl as any).disabled = this.disabled;
|
|
267
269
|
}
|
|
270
|
+
if (this.imageEl) {
|
|
271
|
+
(this.imageEl as any).disabled = this.disabled;
|
|
272
|
+
}
|
|
268
273
|
}
|
|
269
274
|
if (changed.has('placeholder') && this.editorEl) {
|
|
270
275
|
if (this.placeholder) {
|
|
@@ -418,6 +423,13 @@ export class NileRichTextEditor extends LitElement {
|
|
|
418
423
|
this.updateToolbarState();
|
|
419
424
|
}
|
|
420
425
|
|
|
426
|
+
if (
|
|
427
|
+
(e.key === 'Backspace' || e.key === 'Delete') &&
|
|
428
|
+
this.handleFigureDeletion(e)
|
|
429
|
+
) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
|
|
421
433
|
if (this.singleLineEditor && e.key === 'Enter') {
|
|
422
434
|
e.preventDefault();
|
|
423
435
|
return;
|
|
@@ -465,6 +477,61 @@ export class NileRichTextEditor extends LitElement {
|
|
|
465
477
|
this.updateContent();
|
|
466
478
|
this.updateToolbarState();
|
|
467
479
|
};
|
|
480
|
+
private handleFigureDeletion(e: KeyboardEvent): boolean {
|
|
481
|
+
const sel = window.getSelection();
|
|
482
|
+
if (!sel || sel.rangeCount === 0) return false;
|
|
483
|
+
const range = sel.getRangeAt(0);
|
|
484
|
+
if (!this.editorEl.contains(range.commonAncestorContainer)) return false;
|
|
485
|
+
|
|
486
|
+
if (!range.collapsed) {
|
|
487
|
+
const figures = Array.from(
|
|
488
|
+
this.editorEl.querySelectorAll('figure.rte-image')
|
|
489
|
+
);
|
|
490
|
+
const touched = figures.filter(f => range.intersectsNode(f));
|
|
491
|
+
if (!touched.length) return false;
|
|
492
|
+
|
|
493
|
+
e.preventDefault();
|
|
494
|
+
range.deleteContents();
|
|
495
|
+
touched.forEach(f => f.isConnected && f.remove());
|
|
496
|
+
this.ensureAtLeastOneParagraph();
|
|
497
|
+
this.updateContent();
|
|
498
|
+
this.updateToolbarState();
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const block =
|
|
503
|
+
closestBlock(range.startContainer, this.editorEl) || this.editorEl;
|
|
504
|
+
|
|
505
|
+
if (e.key === 'Backspace') {
|
|
506
|
+
const before = document.createRange();
|
|
507
|
+
before.setStart(block, 0);
|
|
508
|
+
before.setEnd(range.startContainer, range.startOffset);
|
|
509
|
+
const atStart = before.toString().replace(/\u200B/g, '') === '';
|
|
510
|
+
const prev = block.previousElementSibling;
|
|
511
|
+
if (atStart && prev?.matches?.('figure.rte-image')) {
|
|
512
|
+
e.preventDefault();
|
|
513
|
+
prev.remove();
|
|
514
|
+
this.updateContent();
|
|
515
|
+
this.updateToolbarState();
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
const after = document.createRange();
|
|
520
|
+
after.setStart(range.endContainer, range.endOffset);
|
|
521
|
+
after.setEnd(block, block.childNodes.length);
|
|
522
|
+
const atEnd = after.toString().replace(/\u200B/g, '') === '';
|
|
523
|
+
const next = block.nextElementSibling;
|
|
524
|
+
if (atEnd && next?.matches?.('figure.rte-image')) {
|
|
525
|
+
e.preventDefault();
|
|
526
|
+
next.remove();
|
|
527
|
+
this.updateContent();
|
|
528
|
+
this.updateToolbarState();
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
468
535
|
|
|
469
536
|
private wireAuthoredToolbar(tb: HTMLElement) {
|
|
470
537
|
this.buttonMap.clear();
|
|
@@ -496,6 +563,16 @@ export class NileRichTextEditor extends LitElement {
|
|
|
496
563
|
});
|
|
497
564
|
return;
|
|
498
565
|
}
|
|
566
|
+
if (tag === 'nile-rte-image') {
|
|
567
|
+
(child as any).editorEl = this.editorEl;
|
|
568
|
+
(child as any).disabled = this.disabled;
|
|
569
|
+
this.imageEl = child as HTMLElement;
|
|
570
|
+
child.addEventListener('nile-image-changed', () => {
|
|
571
|
+
this.updateContent();
|
|
572
|
+
this.updateToolbarState();
|
|
573
|
+
});
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
499
576
|
|
|
500
577
|
if (tag === 'nile-rte-toolbar-item') {
|
|
501
578
|
let btn = child.querySelector(
|
|
@@ -666,7 +743,8 @@ export class NileRichTextEditor extends LitElement {
|
|
|
666
743
|
if (!el) return;
|
|
667
744
|
|
|
668
745
|
const onlyWhitespace =
|
|
669
|
-
(el.textContent ?? '').replace(/\u200B/g, '').trim() === ''
|
|
746
|
+
(el.textContent ?? '').replace(/\u200B/g, '').trim() === '' &&
|
|
747
|
+
!el.querySelector('img');
|
|
670
748
|
if (el.childNodes.length === 0 || onlyWhitespace) {
|
|
671
749
|
el.innerHTML = '<p><br></p>';
|
|
672
750
|
const p = el.querySelector('p');
|
|
@@ -684,7 +762,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
684
762
|
}
|
|
685
763
|
|
|
686
764
|
const hasBlock = el.querySelector(
|
|
687
|
-
'p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre'
|
|
765
|
+
'p,h1,h2,h3,h4,h5,h6,ul,ol,table,blockquote,pre,figure'
|
|
688
766
|
);
|
|
689
767
|
if (!hasBlock) {
|
|
690
768
|
const p = document.createElement('p');
|
|
@@ -849,6 +927,12 @@ export class NileRichTextEditor extends LitElement {
|
|
|
849
927
|
if (linkBtn) linkBtn.toggleAttribute('data-active', inLink);
|
|
850
928
|
}
|
|
851
929
|
|
|
930
|
+
if (this.imageEl) {
|
|
931
|
+
const inImage = !!startElm.closest('figure.rte-image');
|
|
932
|
+
const imageBtn = this.imageEl.querySelector('nile-button');
|
|
933
|
+
if (imageBtn) imageBtn.toggleAttribute('data-active', inImage);
|
|
934
|
+
}
|
|
935
|
+
|
|
852
936
|
this.setBtnActive(
|
|
853
937
|
'left',
|
|
854
938
|
alignNorm === 'left' &&
|
|
@@ -928,7 +1012,9 @@ export class NileRichTextEditor extends LitElement {
|
|
|
928
1012
|
private updateContent() {
|
|
929
1013
|
if (!this.editorEl) return;
|
|
930
1014
|
this.ensureAtLeastOneParagraph();
|
|
931
|
-
const isEmpty =
|
|
1015
|
+
const isEmpty =
|
|
1016
|
+
(this.editorEl.textContent ?? '').trim() === '' &&
|
|
1017
|
+
!this.editorEl.querySelector('img');
|
|
932
1018
|
this.editorEl.classList.toggle('empty', isEmpty);
|
|
933
1019
|
|
|
934
1020
|
const sel = window.getSelection();
|