@aquera/nile-elements 1.5.9 → 1.6.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 +3 -0
- package/dist/index.js +84 -45
- 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 +24 -0
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-link.esm.js +59 -44
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/utils/inline-utils.esm.js +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +24 -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 +6 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +62 -24
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.d.ts +12 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.js +239 -130
- package/dist/src/nile-rich-text-editor/nile-rte-link.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js +469 -0
- package/dist/src/nile-rich-text-editor/nile-rte-link.test.js.map +1 -0
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js +13 -4
- package/dist/src/nile-rich-text-editor/utils/inline-utils.js.map +1 -1
- 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-rich-text-editor/nile-rich-text-editor.css.ts +24 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +66 -26
- package/src/nile-rich-text-editor/nile-rte-link.test.ts +682 -0
- package/src/nile-rich-text-editor/nile-rte-link.ts +195 -100
- package/src/nile-rich-text-editor/utils/inline-utils.ts +11 -4
- package/vscode-html-custom-data.json +16 -2
package/package.json
CHANGED
|
@@ -172,6 +172,30 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
|
|
172
172
|
background-color: var(--nile-colors-primary-500, var(--ng-componentcolors-utility-blue-500));
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
nile-rte-link nile-button[data-active]::part(base) {
|
|
176
|
+
background-color: var(--nile-colors-primary-400, var(--ng-componentcolors-utility-blue-400));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
nile-rte-link nile-button[data-active]::part(base):hover {
|
|
180
|
+
background-color: var(--nile-colors-primary-500, var(--ng-componentcolors-utility-blue-500));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.editor a {
|
|
184
|
+
color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-tertiary-600));
|
|
185
|
+
cursor: pointer;
|
|
186
|
+
text-decoration: none;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.editor a:hover {
|
|
190
|
+
text-decoration: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
nile-rich-text-editor[disabled] .editor a {
|
|
194
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
195
|
+
cursor: not-allowed;
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
175
199
|
.editor.empty::before {
|
|
176
200
|
content: attr(data-placeholder);
|
|
177
201
|
color: var(--nile-colors-neutral-500, var(--ng-colors-text-secondary));
|
|
@@ -134,6 +134,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
134
134
|
private colorSwatchEl: HTMLElement | null = null;
|
|
135
135
|
private bgSwatchEl: HTMLElement | null = null;
|
|
136
136
|
private containerEl: HTMLElement | null = null;
|
|
137
|
+
private linkEl: HTMLElement | null = null;
|
|
137
138
|
|
|
138
139
|
private mentionsEl: HTMLElement | null = null;
|
|
139
140
|
|
|
@@ -223,6 +224,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
disconnectedCallback(): void {
|
|
227
|
+
this.unwireEditor();
|
|
226
228
|
document.removeEventListener('selectionchange', this.onSelectionChange);
|
|
227
229
|
|
|
228
230
|
if (this.mentionsEl && (this.mentionsEl as any).detach) {
|
|
@@ -249,6 +251,16 @@ export class NileRichTextEditor extends LitElement {
|
|
|
249
251
|
if (changed.has('disabled') && this.editorEl) {
|
|
250
252
|
this.editorEl.setAttribute('contenteditable', this.disabled ? 'false' : 'true');
|
|
251
253
|
this.editorEl.tabIndex = this.disabled ? -1 : 0;
|
|
254
|
+
if (this.linkEl) {
|
|
255
|
+
(this.linkEl as any).disabled = this.disabled;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (changed.has('placeholder') && this.editorEl) {
|
|
259
|
+
if (this.placeholder) {
|
|
260
|
+
this.editorEl.dataset.placeholder = this.placeholder;
|
|
261
|
+
} else {
|
|
262
|
+
delete this.editorEl.dataset.placeholder;
|
|
263
|
+
}
|
|
252
264
|
}
|
|
253
265
|
|
|
254
266
|
}
|
|
@@ -314,36 +326,57 @@ export class NileRichTextEditor extends LitElement {
|
|
|
314
326
|
});
|
|
315
327
|
}
|
|
316
328
|
|
|
317
|
-
private
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
this.
|
|
325
|
-
|
|
329
|
+
private onEditorClick = (e: MouseEvent) => {
|
|
330
|
+
const anchor = (e.target as HTMLElement).closest?.('a');
|
|
331
|
+
if (anchor) e.preventDefault();
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
private onEditorInput = () => {
|
|
335
|
+
this.ensureAtLeastOneParagraph();
|
|
336
|
+
this.scrubBrokenMentions();
|
|
337
|
+
this.updateContent();
|
|
338
|
+
this.updateToolbarState();
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
private onEditorMouseup = () => {
|
|
342
|
+
this.saveSelection();
|
|
343
|
+
this.updateToolbarState();
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
private onEditorKeyup = (e: KeyboardEvent) => {
|
|
347
|
+
this.saveSelection();
|
|
348
|
+
|
|
349
|
+
if (
|
|
350
|
+
[
|
|
351
|
+
'ArrowLeft',
|
|
352
|
+
'ArrowRight',
|
|
353
|
+
'ArrowUp',
|
|
354
|
+
'ArrowDown',
|
|
355
|
+
'Home',
|
|
356
|
+
'End',
|
|
357
|
+
].includes(e.key)
|
|
358
|
+
) {
|
|
326
359
|
this.updateToolbarState();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
this.saveSelection();
|
|
360
|
+
}
|
|
361
|
+
};
|
|
330
362
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
'ArrowDown',
|
|
337
|
-
'Home',
|
|
338
|
-
'End',
|
|
339
|
-
].includes(e.key)
|
|
340
|
-
) {
|
|
341
|
-
this.updateToolbarState();
|
|
342
|
-
}
|
|
343
|
-
});
|
|
363
|
+
private wireEditor() {
|
|
364
|
+
this.editorEl.addEventListener('click', this.onEditorClick);
|
|
365
|
+
this.editorEl.addEventListener('input', this.onEditorInput);
|
|
366
|
+
this.editorEl.addEventListener('mouseup', this.onEditorMouseup);
|
|
367
|
+
this.editorEl.addEventListener('keyup', this.onEditorKeyup);
|
|
344
368
|
this.editorEl.addEventListener('keydown', this.onEditorKeydown);
|
|
345
369
|
}
|
|
346
370
|
|
|
371
|
+
private unwireEditor() {
|
|
372
|
+
if (!this.editorEl) return;
|
|
373
|
+
this.editorEl.removeEventListener('click', this.onEditorClick);
|
|
374
|
+
this.editorEl.removeEventListener('input', this.onEditorInput);
|
|
375
|
+
this.editorEl.removeEventListener('mouseup', this.onEditorMouseup);
|
|
376
|
+
this.editorEl.removeEventListener('keyup', this.onEditorKeyup);
|
|
377
|
+
this.editorEl.removeEventListener('keydown', this.onEditorKeydown);
|
|
378
|
+
}
|
|
379
|
+
|
|
347
380
|
private onEditorKeydown = (e: KeyboardEvent) => {
|
|
348
381
|
if (this.singleLineEditor && e.key === 'Enter' && e.shiftKey) {
|
|
349
382
|
e.preventDefault();
|
|
@@ -426,7 +459,9 @@ export class NileRichTextEditor extends LitElement {
|
|
|
426
459
|
}
|
|
427
460
|
if (tag === 'nile-rte-link') {
|
|
428
461
|
(child as any).editorEl = this.editorEl;
|
|
429
|
-
child
|
|
462
|
+
(child as any).disabled = this.disabled;
|
|
463
|
+
this.linkEl = child as HTMLElement;
|
|
464
|
+
child.addEventListener('nile-link-changed', () => {
|
|
430
465
|
this.updateContent();
|
|
431
466
|
this.updateToolbarState();
|
|
432
467
|
});
|
|
@@ -768,6 +803,11 @@ export class NileRichTextEditor extends LitElement {
|
|
|
768
803
|
this.setBtnActive('underline', isUnderline);
|
|
769
804
|
this.setBtnActive('link', inLink);
|
|
770
805
|
|
|
806
|
+
if (this.linkEl) {
|
|
807
|
+
const linkBtn = this.linkEl.querySelector('nile-button');
|
|
808
|
+
if (linkBtn) linkBtn.toggleAttribute('data-active', inLink);
|
|
809
|
+
}
|
|
810
|
+
|
|
771
811
|
this.setBtnActive(
|
|
772
812
|
'left',
|
|
773
813
|
alignNorm === 'left' &&
|