@skyux/text-editor 12.0.0-alpha.2 → 12.0.0-alpha.4
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/documentation.json +244 -241
- package/fesm2022/skyux-text-editor.mjs +100 -70
- package/fesm2022/skyux-text-editor.mjs.map +1 -1
- package/package.json +13 -13
|
@@ -459,6 +459,9 @@ class SkyTextEditorAdapterService {
|
|
|
459
459
|
initEditor(id, iframeElement, styleState, placeholder) {
|
|
460
460
|
this.#textEditorService.editor = this.#createObservers(iframeElement);
|
|
461
461
|
const documentEl = this.#getIframeDocumentEl();
|
|
462
|
+
if (!documentEl) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
462
465
|
const styleEl = documentEl.createElement('style');
|
|
463
466
|
styleEl.innerHTML = `.editor:empty:before {
|
|
464
467
|
content: attr(data-placeholder);
|
|
@@ -510,7 +513,7 @@ class SkyTextEditorAdapterService {
|
|
|
510
513
|
await navigator.clipboard.readText().then((clipText) => {
|
|
511
514
|
/* istanbul ignore else */
|
|
512
515
|
if (this.editorSelected()) {
|
|
513
|
-
documentEl
|
|
516
|
+
documentEl?.execCommand('insertHTML', false, clipText);
|
|
514
517
|
this.focusEditor();
|
|
515
518
|
this.#textEditorService.editor.commandChangeObservable.next();
|
|
516
519
|
}
|
|
@@ -520,7 +523,7 @@ class SkyTextEditorAdapterService {
|
|
|
520
523
|
else {
|
|
521
524
|
/* istanbul ignore else */
|
|
522
525
|
if (this.editorSelected()) {
|
|
523
|
-
documentEl
|
|
526
|
+
documentEl?.execCommand(editorCommand.command, false, editorCommand.value);
|
|
524
527
|
this.focusEditor();
|
|
525
528
|
this.#textEditorService.editor.commandChangeObservable.next();
|
|
526
529
|
}
|
|
@@ -528,7 +531,11 @@ class SkyTextEditorAdapterService {
|
|
|
528
531
|
}
|
|
529
532
|
}
|
|
530
533
|
getCurrentSelection() {
|
|
531
|
-
|
|
534
|
+
const documentEl = this.#getIframeDocumentEl();
|
|
535
|
+
if (documentEl) {
|
|
536
|
+
return this.#selectionService.getCurrentSelection(documentEl);
|
|
537
|
+
}
|
|
538
|
+
return null;
|
|
532
539
|
}
|
|
533
540
|
/**
|
|
534
541
|
* Returns a data URI using the provided text string.
|
|
@@ -563,7 +570,7 @@ class SkyTextEditorAdapterService {
|
|
|
563
570
|
getStyleState() {
|
|
564
571
|
const documentEl = this.#getIframeDocumentEl();
|
|
565
572
|
/* istanbul ignore else */
|
|
566
|
-
if (this.editorSelected()) {
|
|
573
|
+
if (documentEl && this.editorSelected()) {
|
|
567
574
|
return {
|
|
568
575
|
backColor: this.#getColor(documentEl, 'BackColor'),
|
|
569
576
|
fontColor: this.#getColor(documentEl, 'ForeColor'),
|
|
@@ -587,9 +594,9 @@ class SkyTextEditorAdapterService {
|
|
|
587
594
|
}
|
|
588
595
|
setEditorInnerHtml(value) {
|
|
589
596
|
const documentEl = this.#getIframeDocumentEl();
|
|
590
|
-
const editorContent = documentEl
|
|
597
|
+
const editorContent = documentEl?.body;
|
|
591
598
|
/* istanbul ignore else */
|
|
592
|
-
if (editorContent.innerHTML !== value) {
|
|
599
|
+
if (editorContent && editorContent.innerHTML !== value) {
|
|
593
600
|
editorContent.innerHTML = value;
|
|
594
601
|
}
|
|
595
602
|
}
|
|
@@ -598,29 +605,31 @@ class SkyTextEditorAdapterService {
|
|
|
598
605
|
if (this.#textEditorService.editor) {
|
|
599
606
|
const windowEl = this.#getContentWindowEl();
|
|
600
607
|
const iframeDocumentEl = this.#getIframeDocumentEl();
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
608
|
+
if (windowEl && iframeDocumentEl) {
|
|
609
|
+
const currentSelection = this.#selectionService.getCurrentSelectionRange(iframeDocumentEl, windowEl);
|
|
610
|
+
const cursorIsNotActiveAndHasReset = currentSelection &&
|
|
611
|
+
currentSelection.startOffset === 0 &&
|
|
612
|
+
currentSelection.endOffset === 0;
|
|
613
|
+
if (!this.editorSelected() || cursorIsNotActiveAndHasReset) {
|
|
614
|
+
// focus the end of the editor
|
|
615
|
+
const documentEl = this.#windowRef.nativeWindow.document;
|
|
616
|
+
const editor = iframeDocumentEl.body;
|
|
617
|
+
const range = documentEl.createRange();
|
|
618
|
+
this.#textEditorService.editor.iframeElementRef.focus();
|
|
619
|
+
editor.focus();
|
|
620
|
+
if (windowEl.getSelection && documentEl.createRange) {
|
|
621
|
+
range.selectNodeContents(editor);
|
|
622
|
+
range.collapse(false);
|
|
623
|
+
const sel = windowEl.getSelection();
|
|
624
|
+
sel?.removeAllRanges();
|
|
625
|
+
sel?.addRange(range);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
// Cursor may not be active, restore it
|
|
630
|
+
this.#textEditorService.editor.iframeElementRef.focus();
|
|
631
|
+
iframeDocumentEl.body.focus();
|
|
618
632
|
}
|
|
619
|
-
}
|
|
620
|
-
else {
|
|
621
|
-
// Cursor may not be active, restore it
|
|
622
|
-
this.#textEditorService.editor.iframeElementRef.focus();
|
|
623
|
-
iframeDocumentEl.body.focus();
|
|
624
633
|
}
|
|
625
634
|
}
|
|
626
635
|
}
|
|
@@ -642,48 +651,58 @@ class SkyTextEditorAdapterService {
|
|
|
642
651
|
if (selectedEl) {
|
|
643
652
|
return this.#getParent(selectedEl, 'a');
|
|
644
653
|
}
|
|
645
|
-
/* istanbul ignore next */
|
|
646
654
|
return undefined;
|
|
647
655
|
}
|
|
648
656
|
saveSelection() {
|
|
649
|
-
|
|
657
|
+
const documentEl = this.#getIframeDocumentEl();
|
|
658
|
+
const windowEl = this.#getContentWindowEl();
|
|
659
|
+
if (documentEl && windowEl) {
|
|
660
|
+
return this.#selectionService.getCurrentSelectionRange(documentEl, windowEl);
|
|
661
|
+
}
|
|
662
|
+
return undefined;
|
|
650
663
|
}
|
|
651
664
|
selectElement(element) {
|
|
652
|
-
this.#
|
|
665
|
+
const documentEl = this.#getIframeDocumentEl();
|
|
666
|
+
const windowEl = this.#getContentWindowEl();
|
|
667
|
+
if (documentEl && windowEl) {
|
|
668
|
+
this.#selectionService.selectElement(documentEl, windowEl, element);
|
|
669
|
+
}
|
|
653
670
|
}
|
|
654
671
|
setErrorAttributes(errorId, errors) {
|
|
655
672
|
const documentEl = this.#getIframeDocumentEl();
|
|
656
|
-
documentEl
|
|
673
|
+
documentEl?.body.setAttribute('aria-invalid', (!!errors).toString());
|
|
657
674
|
if (errors && errorId) {
|
|
658
|
-
documentEl
|
|
675
|
+
documentEl?.body.setAttribute('aria-errormessage', errorId);
|
|
659
676
|
}
|
|
660
677
|
else {
|
|
661
|
-
documentEl
|
|
678
|
+
documentEl?.body.removeAttribute('aria-errormessage');
|
|
662
679
|
}
|
|
663
680
|
}
|
|
664
681
|
setLabelAttribute(label) {
|
|
665
682
|
if (label) {
|
|
666
683
|
const documentEl = this.#getIframeDocumentEl();
|
|
667
|
-
documentEl
|
|
684
|
+
documentEl?.body.setAttribute('aria-label', label);
|
|
668
685
|
}
|
|
669
686
|
}
|
|
670
687
|
setPlaceholder(placeholder) {
|
|
671
688
|
const documentEl = this.#getIframeDocumentEl();
|
|
672
|
-
documentEl
|
|
689
|
+
documentEl?.body.setAttribute('data-placeholder', placeholder || '');
|
|
673
690
|
}
|
|
674
691
|
setRequiredAttribute(required) {
|
|
675
692
|
const documentEl = this.#getIframeDocumentEl();
|
|
676
|
-
documentEl
|
|
693
|
+
documentEl?.body.setAttribute('aria-required', required.toString());
|
|
677
694
|
}
|
|
678
695
|
async setFontSize(fontSize) {
|
|
679
696
|
const doc = this.#getIframeDocumentEl();
|
|
680
697
|
await this.execCommand({ command: 'fontSize', value: '1' });
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
element
|
|
684
|
-
|
|
698
|
+
if (doc) {
|
|
699
|
+
const fontElements = Array.from(doc.querySelectorAll('font[size="1"]'));
|
|
700
|
+
for (const element of fontElements) {
|
|
701
|
+
element.removeAttribute('size');
|
|
702
|
+
element.style.fontSize = fontSize + 'px';
|
|
703
|
+
}
|
|
704
|
+
this.#cleanUpBlankStyleTags(doc);
|
|
685
705
|
}
|
|
686
|
-
this.#cleanUpBlankStyleTags(doc);
|
|
687
706
|
this.focusEditor();
|
|
688
707
|
this.#textEditorService.editor.commandChangeObservable.next();
|
|
689
708
|
}
|
|
@@ -772,8 +791,8 @@ class SkyTextEditorAdapterService {
|
|
|
772
791
|
? element.contentWindow.document
|
|
773
792
|
: element.contentDocument;
|
|
774
793
|
// Firefox bug where we need to open/close to cancel load so it doesn't overwrite attrs
|
|
775
|
-
documentEl
|
|
776
|
-
documentEl
|
|
794
|
+
documentEl?.open();
|
|
795
|
+
documentEl?.close();
|
|
777
796
|
const selectionObservable = new Subject();
|
|
778
797
|
const selectionListener = () => selectionObservable.next();
|
|
779
798
|
const clickObservable = new Subject();
|
|
@@ -785,12 +804,12 @@ class SkyTextEditorAdapterService {
|
|
|
785
804
|
const focusListener = () => focusObservable.next();
|
|
786
805
|
const inputObservable = new Subject();
|
|
787
806
|
const inputListener = () => inputObservable.next();
|
|
788
|
-
documentEl
|
|
789
|
-
documentEl
|
|
790
|
-
documentEl
|
|
791
|
-
documentEl
|
|
792
|
-
documentEl
|
|
793
|
-
documentEl
|
|
807
|
+
documentEl?.addEventListener('selectionchange', selectionListener);
|
|
808
|
+
documentEl?.addEventListener('input', inputListener);
|
|
809
|
+
documentEl?.addEventListener('mousedown', clickListener);
|
|
810
|
+
documentEl?.body.addEventListener('paste', pasteListener);
|
|
811
|
+
documentEl?.body.addEventListener('blur', blurListener);
|
|
812
|
+
documentEl?.body.addEventListener('focusin', focusListener);
|
|
794
813
|
return {
|
|
795
814
|
blurObservable,
|
|
796
815
|
clickObservable,
|
|
@@ -821,7 +840,11 @@ class SkyTextEditorAdapterService {
|
|
|
821
840
|
};
|
|
822
841
|
}
|
|
823
842
|
#getCurrentSelectionParentElement() {
|
|
824
|
-
|
|
843
|
+
const documentEl = this.#getIframeDocumentEl();
|
|
844
|
+
if (documentEl) {
|
|
845
|
+
return this.#selectionService.getCurrentSelectionParentElement(documentEl);
|
|
846
|
+
}
|
|
847
|
+
return undefined;
|
|
825
848
|
}
|
|
826
849
|
#getColor(documentEl, selector) {
|
|
827
850
|
const commandValue = documentEl.queryCommandValue(selector);
|
|
@@ -862,7 +885,10 @@ class SkyTextEditorAdapterService {
|
|
|
862
885
|
}
|
|
863
886
|
editorSelected() {
|
|
864
887
|
const documentEl = this.#getIframeDocumentEl();
|
|
865
|
-
|
|
888
|
+
if (documentEl) {
|
|
889
|
+
return this.#selectionService.isElementSelected(documentEl, documentEl.body);
|
|
890
|
+
}
|
|
891
|
+
return false;
|
|
866
892
|
}
|
|
867
893
|
#cleanUpBlankStyleTags(doc) {
|
|
868
894
|
const orphanElements = Array.from(doc.querySelectorAll('font,span,*[style=""]'));
|
|
@@ -904,7 +930,7 @@ class SkyTextEditorAdapterService {
|
|
|
904
930
|
aFocusableChild.tabIndex = disabled ? -1 : 0;
|
|
905
931
|
});
|
|
906
932
|
}
|
|
907
|
-
this.#getIframeDocumentEl()
|
|
933
|
+
this.#getIframeDocumentEl()?.body.setAttribute('contenteditable', disabled ? 'false' : 'true');
|
|
908
934
|
}
|
|
909
935
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SkyTextEditorAdapterService, deps: [{ token: SkyTextEditorSelectionService }, { token: SkyTextEditorService }, { token: i3.SkyAppWindowRef }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
910
936
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SkyTextEditorAdapterService }); }
|
|
@@ -1394,7 +1420,7 @@ class SkyTextEditorToolbarComponent {
|
|
|
1394
1420
|
return undefined;
|
|
1395
1421
|
}
|
|
1396
1422
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SkyTextEditorToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1397
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: SkyTextEditorToolbarComponent, isStandalone: true, selector: "sky-text-editor-toolbar", inputs: { editorFocusStream: "editorFocusStream", fontList: "fontList", fontSizeList: "fontSizeList", toolbarActions: "toolbarActions", linkWindowOptions: "linkWindowOptions", styleState: "styleState", disabled: ["disabled", "disabled", booleanAttribute] }, ngImport: i0, template: "@for (action of toolbarActions; track action) {\n <sky-toolbar-item\n class=\"sky-text-editor-toolbar-action\"\n [ngClass]=\"'sky-text-editor-toolbar-action-' + action\"\n >\n @switch (action) {\n @case ('font-family') {\n <sky-dropdown\n class=\"sky-text-editor-font-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font: ' + styleStateFontName\"\n [messageStream]=\"fontPickerStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.font\n }\"\n >\n {{ styleStateFontName }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n @for (fontModel of fontList; track fontModel) {\n <sky-dropdown-item>\n <button\n type=\"button\"\n [ngStyle]=\"{\n 'font-family': fontModel.value\n }\"\n (click)=\"execCommand('fontname', fontModel.name)\"\n >\n {{ fontModel.name }}\n </button>\n </sky-dropdown-item>\n }\n </sky-dropdown-menu>\n </sky-dropdown>\n }\n @case ('font-size') {\n <sky-dropdown\n class=\"sky-text-editor-font-size-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font size: ' + styleState.fontSize + 'px'\"\n [messageStream]=\"fontSizeStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.fontSize\n }\"\n >\n {{ styleState.fontSize + 'px' }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n @for (size of fontSizeList; track size) {\n <sky-dropdown-item>\n <button type=\"button\" (click)=\"changeFontSize(size)\">\n {{ size + 'px' }}\n </button>\n </sky-dropdown-item>\n }\n </sky-dropdown-menu>\n </sky-dropdown>\n }\n @case ('font-style') {\n <div class=\"sky-switch-icon-group sky-text-editor-font-style-picker\">\n <sky-checkbox\n icon=\"bold\"\n label=\"Bold\"\n title=\"Bold\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.boldState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.boldState, $event, 'bold')\n \"\n />\n <sky-checkbox\n icon=\"italic\"\n label=\"Italicized\"\n title=\"Italicized\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.italicState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.italicState, $event, 'italic')\n \"\n />\n <sky-checkbox\n icon=\"underline\"\n label=\"Underline\"\n title=\"Underline\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.underlineState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.underlineState, $event, 'underline')\n \"\n />\n </div>\n }\n @case ('color') {\n <div class=\"sky-text-editor-colorpicker-group\">\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n #colorPicker\n class=\"sky-text-editor-font-color-picker\"\n label=\"Font color\"\n pickerButtonIcon=\"highlighter\"\n pickerButtonIconType=\"skyux\"\n [messageStream]=\"colorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event)\"\n >\n <input\n outputFormat=\"hex\"\n type=\"text\"\n [allowTransparency]=\"false\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.fontColor\"\n [skyColorpickerInput]=\"colorPicker\"\n />\n </sky-colorpicker>\n </div>\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n #backColorPicker\n class=\"sky-text-editor-background-color-picker\"\n label=\"Background color\"\n pickerButtonIcon=\"text-color\"\n pickerButtonIconType=\"skyux\"\n [messageStream]=\"backColorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event, true)\"\n >\n <input\n outputFormat=\"rgba\"\n type=\"text\"\n [allowTransparency]=\"true\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.backColor\"\n [skyColorpickerInput]=\"backColorPicker\"\n />\n </sky-colorpicker>\n </div>\n </div>\n }\n @case ('list') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Bulleted list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Bulleted list\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertUnorderedList')\"\n >\n <sky-icon icon=\"bullet-list\" />\n </button>\n <button\n aria-label=\"Numbered list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Numbered list\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertOrderedList')\"\n >\n <sky-icon icon=\"number-list\" />\n </button>\n </div>\n }\n @case ('alignment') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Align left\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align left\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyLeft')\"\n >\n <sky-icon icon=\"align-left-text\" />\n </button>\n <button\n aria-label=\"Align center\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align center\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyCenter')\"\n >\n <sky-icon icon=\"center-text\" />\n </button>\n <button\n aria-label=\"Align right\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align right\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyRight')\"\n >\n <sky-icon icon=\"align-right-text\" />\n </button>\n </div>\n }\n @case ('indentation') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Outdent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Outdent\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('outdent')\"\n >\n <sky-icon icon=\"outdent\" />\n </button>\n <button\n aria-label=\"Indent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Indent\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('indent')\"\n >\n <sky-icon icon=\"indent\" />\n </button>\n </div>\n }\n @case ('undo-redo') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Undo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Undo\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('undo')\"\n >\n <sky-icon icon=\"undo\" />\n </button>\n <button\n aria-label=\"Redo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Redo\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('redo')\"\n >\n <sky-icon icon=\"redo\" />\n </button>\n </div>\n }\n @case ('link') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Link\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Link\"\n type=\"button\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'icon-btn-active': styleState.linkState\n }\"\n (click)=\"link()\"\n >\n <sky-icon icon=\"link\" />\n </button>\n <button\n aria-label=\"Unlink\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Unlink\"\n type=\"button\"\n [disabled]=\"!styleState.linkState || disabled\"\n (click)=\"unlink()\"\n >\n <sky-icon icon=\"unlink\" />\n </button>\n </div>\n }\n }\n </sky-toolbar-item>\n}\n", styles: [".sky-text-editor-toolbar-action:not(.sky-theme-modern *){--sky-override-text-editor-border-radius: 0;--sky-override-text-editor-button-border-outer-radius: 3px;--sky-override-text-editor-button-border: 1px solid #cdcfd2;--sky-override-text-editor-colorpicker-spacing: 10px;--sky-override-text-editor-colorpicker-top: 3px}.sky-text-editor-toolbar-action .sky-text-editor-font-picker ::ng-deep .sky-dropdown-button-content-container{width:140px;height:20px;text-align:left}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group{display:flex}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{position:relative;top:var(--sky-override-text-editor-colorpicker-top, -2px);margin-right:var(--sky-override-text-editor-colorpicker-spacing, var(--sky-space-gap-action_group-m))}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child{margin-right:0}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn{margin-left:0;margin-right:0;border-radius:var(--sky-override-text-editor-border-radius, var(--sky-border-radius-s));border-right:none}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:first-of-type{border-top-left-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-bottom-left-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s))}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border-top-right-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-bottom-right-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-right:var(--sky-override-text-editor-button-border, none)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: SkyCheckboxModule }, { kind: "component", type: i1$3.λ3, selector: "sky-checkbox", inputs: ["label", "labelledBy", "id", "disabled", "tabindex", "name", "helpPopoverContent", "helpPopoverTitle", "icon", "checkboxType", "checked", "indeterminate", "required", "labelText", "labelHidden", "hintText", "stacked", "helpKey"], outputs: ["change", "checkedChange", "disabledChange", "indeterminateChange"] }, { kind: "ngmodule", type: SkyColorpickerModule }, { kind: "component", type: i4$1.λ1, selector: "sky-colorpicker", inputs: ["pickerButtonIcon", "pickerButtonIconType", "label", "labelledBy", "labelText", "labelHidden", "helpKey", "helpPopoverContent", "helpPopoverTitle", "hintText", "stacked", "messageStream", "showResetButton"], outputs: ["selectedColorChanged", "selectedColorApplied"] }, { kind: "directive", type: i4$1.λ2, selector: "[skyColorpickerInput]", inputs: ["skyColorpickerInput", "initialColor", "id", "returnFormat", "outputFormat", "presetColors", "alphaChannel", "allowTransparency"] }, { kind: "ngmodule", type: SkyDropdownModule }, { kind: "component", type: i2.λ2, selector: "sky-dropdown-button" }, { kind: "component", type: i2.λ3, selector: "sky-dropdown", inputs: ["buttonStyle", "buttonType", "disabled", "label", "horizontalAlignment", "messageStream", "title", "trigger"] }, { kind: "component", type: i2.λ1, selector: "sky-dropdown-item", inputs: ["ariaRole"] }, { kind: "component", type: i2.λ4, selector: "sky-dropdown-menu", inputs: ["ariaLabelledBy", "ariaRole", "useNativeFocus"], outputs: ["menuChanges"] }, { kind: "ngmodule", type: SkyIconModule }, { kind: "component", type: i6$1.λ1, selector: "sky-icon", inputs: ["icon", "iconName", "iconType", "size", "fixedWidth", "variant"] }, { kind: "ngmodule", type: SkyThemeModule }, { kind: "ngmodule", type: SkyToolbarModule }, { kind: "component", type: i6.λ39, selector: "sky-toolbar-item" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1423
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.5", type: SkyTextEditorToolbarComponent, isStandalone: true, selector: "sky-text-editor-toolbar", inputs: { editorFocusStream: "editorFocusStream", fontList: "fontList", fontSizeList: "fontSizeList", toolbarActions: "toolbarActions", linkWindowOptions: "linkWindowOptions", styleState: "styleState", disabled: ["disabled", "disabled", booleanAttribute] }, ngImport: i0, template: "@for (action of toolbarActions; track action) {\n <sky-toolbar-item\n class=\"sky-text-editor-toolbar-action\"\n [ngClass]=\"'sky-text-editor-toolbar-action-' + action\"\n >\n @switch (action) {\n @case ('font-family') {\n <sky-dropdown\n class=\"sky-text-editor-font-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font: ' + styleStateFontName\"\n [messageStream]=\"fontPickerStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.font\n }\"\n >\n {{ styleStateFontName }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n @for (fontModel of fontList; track fontModel) {\n <sky-dropdown-item>\n <button\n type=\"button\"\n [ngStyle]=\"{\n 'font-family': fontModel.value\n }\"\n (click)=\"execCommand('fontname', fontModel.name)\"\n >\n {{ fontModel.name }}\n </button>\n </sky-dropdown-item>\n }\n </sky-dropdown-menu>\n </sky-dropdown>\n }\n @case ('font-size') {\n <sky-dropdown\n class=\"sky-text-editor-font-size-picker\"\n [disabled]=\"disabled\"\n [label]=\"'Font size: ' + styleState.fontSize + 'px'\"\n [messageStream]=\"fontSizeStream\"\n >\n <sky-dropdown-button\n [ngStyle]=\"{\n 'font-family': styleState.fontSize\n }\"\n >\n {{ styleState.fontSize + 'px' }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n @for (size of fontSizeList; track size) {\n <sky-dropdown-item>\n <button type=\"button\" (click)=\"changeFontSize(size)\">\n {{ size + 'px' }}\n </button>\n </sky-dropdown-item>\n }\n </sky-dropdown-menu>\n </sky-dropdown>\n }\n @case ('font-style') {\n <div class=\"sky-switch-icon-group sky-text-editor-font-style-picker\">\n <sky-checkbox\n icon=\"bold\"\n label=\"Bold\"\n title=\"Bold\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.boldState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.boldState, $event, 'bold')\n \"\n />\n <sky-checkbox\n icon=\"italic\"\n label=\"Italicized\"\n title=\"Italicized\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.italicState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.italicState, $event, 'italic')\n \"\n />\n <sky-checkbox\n icon=\"underline\"\n label=\"Underline\"\n title=\"Underline\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.underlineState\"\n (ngModelChange)=\"\n toggleFontStyle(styleState.underlineState, $event, 'underline')\n \"\n />\n </div>\n }\n @case ('color') {\n <div class=\"sky-text-editor-colorpicker-group\">\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n #colorPicker\n class=\"sky-text-editor-font-color-picker\"\n label=\"Font color\"\n pickerButtonIcon=\"highlighter\"\n pickerButtonIconType=\"skyux\"\n [messageStream]=\"colorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event)\"\n >\n <input\n outputFormat=\"hex\"\n type=\"text\"\n [allowTransparency]=\"false\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.fontColor\"\n [skyColorpickerInput]=\"colorPicker\"\n />\n </sky-colorpicker>\n </div>\n <div class=\"sky-text-editor-colorpicker-container\">\n <sky-colorpicker\n #backColorPicker\n class=\"sky-text-editor-background-color-picker\"\n label=\"Background color\"\n pickerButtonIcon=\"text-color\"\n pickerButtonIconType=\"skyux\"\n [messageStream]=\"backColorpickerStream\"\n [showResetButton]=\"false\"\n (selectedColorChanged)=\"onColorpickerColorChanged($event, true)\"\n >\n <input\n outputFormat=\"rgba\"\n type=\"text\"\n [allowTransparency]=\"true\"\n [disabled]=\"disabled\"\n [ngModel]=\"styleState.backColor\"\n [skyColorpickerInput]=\"backColorPicker\"\n />\n </sky-colorpicker>\n </div>\n </div>\n }\n @case ('list') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Bulleted list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Bulleted list\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertUnorderedList')\"\n >\n <sky-icon icon=\"bullet-list\" />\n </button>\n <button\n aria-label=\"Numbered list\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Numbered list\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('insertOrderedList')\"\n >\n <sky-icon icon=\"number-list\" />\n </button>\n </div>\n }\n @case ('alignment') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Align left\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align left\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyLeft')\"\n >\n <sky-icon icon=\"align-left-text\" />\n </button>\n <button\n aria-label=\"Align center\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align center\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyCenter')\"\n >\n <sky-icon icon=\"center-text\" />\n </button>\n <button\n aria-label=\"Align right\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Align right\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('justifyRight')\"\n >\n <sky-icon icon=\"align-right-text\" />\n </button>\n </div>\n }\n @case ('indentation') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Outdent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Outdent\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('outdent')\"\n >\n <sky-icon icon=\"outdent\" />\n </button>\n <button\n aria-label=\"Indent\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Indent\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('indent')\"\n >\n <sky-icon icon=\"indent\" />\n </button>\n </div>\n }\n @case ('undo-redo') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Undo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Undo\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('undo')\"\n >\n <sky-icon icon=\"undo\" />\n </button>\n <button\n aria-label=\"Redo\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Redo\"\n type=\"button\"\n [disabled]=\"disabled\"\n (click)=\"execCommand('redo')\"\n >\n <sky-icon icon=\"redo\" />\n </button>\n </div>\n }\n @case ('link') {\n <div class=\"sky-switch-icon-group\">\n <button\n aria-label=\"Link\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Link\"\n type=\"button\"\n [disabled]=\"disabled\"\n [ngClass]=\"{\n 'icon-btn-active': styleState.linkState\n }\"\n (click)=\"link()\"\n >\n <sky-icon icon=\"link\" />\n </button>\n <button\n aria-label=\"Unlink\"\n class=\"sky-btn sky-btn-default sky-btn-icon\"\n title=\"Unlink\"\n type=\"button\"\n [disabled]=\"!styleState.linkState || disabled\"\n (click)=\"unlink()\"\n >\n <sky-icon icon=\"unlink\" />\n </button>\n </div>\n }\n }\n </sky-toolbar-item>\n}\n", styles: [".sky-text-editor-toolbar-action:not(.sky-theme-modern *){--sky-override-text-editor-border-radius: 0;--sky-override-text-editor-button-border-outer-radius: 3px;--sky-override-text-editor-button-border: 1px solid #cdcfd2;--sky-override-text-editor-colorpicker-spacing: 10px;--sky-override-text-editor-colorpicker-top: 3px}.sky-text-editor-toolbar-action .sky-text-editor-font-picker ::ng-deep .sky-dropdown-button-content-container{width:140px;height:20px;text-align:left}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group{display:flex}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container{position:relative;top:var(--sky-override-text-editor-colorpicker-top, -2px);margin-right:var(--sky-override-text-editor-colorpicker-spacing, var(--sky-space-gap-action_group-m))}.sky-text-editor-toolbar-action .sky-text-editor-colorpicker-group .sky-text-editor-colorpicker-container:last-child{margin-right:0}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn{margin-left:0;margin-right:0;border-radius:var(--sky-override-text-editor-border-radius, var(--sky-border-radius-s));border-right:none}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:first-of-type{border-top-left-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-bottom-left-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s))}.sky-text-editor-toolbar-action .sky-switch-icon-group .sky-btn:last-of-type{border-top-right-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-bottom-right-radius:var(--sky-override-text-editor-button-border-outer-radius, var(--sky-border-radius-s));border-right:var(--sky-override-text-editor-button-border, none)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1$1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: SkyCheckboxModule }, { kind: "component", type: i1$3.λ3, selector: "sky-checkbox", inputs: ["label", "labelledBy", "id", "disabled", "tabindex", "name", "helpPopoverContent", "helpPopoverTitle", "icon", "iconName", "checkboxType", "checked", "indeterminate", "required", "labelText", "labelHidden", "hintText", "stacked", "helpKey"], outputs: ["change", "checkedChange", "disabledChange", "indeterminateChange"] }, { kind: "ngmodule", type: SkyColorpickerModule }, { kind: "component", type: i4$1.λ1, selector: "sky-colorpicker", inputs: ["pickerButtonIcon", "pickerButtonIconType", "label", "labelledBy", "labelText", "labelHidden", "helpKey", "helpPopoverContent", "helpPopoverTitle", "hintText", "stacked", "messageStream", "showResetButton"], outputs: ["selectedColorChanged", "selectedColorApplied"] }, { kind: "directive", type: i4$1.λ2, selector: "[skyColorpickerInput]", inputs: ["skyColorpickerInput", "initialColor", "id", "returnFormat", "outputFormat", "presetColors", "alphaChannel", "allowTransparency"] }, { kind: "ngmodule", type: SkyDropdownModule }, { kind: "component", type: i2.λ2, selector: "sky-dropdown-button" }, { kind: "component", type: i2.λ3, selector: "sky-dropdown", inputs: ["buttonStyle", "buttonType", "disabled", "label", "horizontalAlignment", "messageStream", "title", "trigger"] }, { kind: "component", type: i2.λ1, selector: "sky-dropdown-item", inputs: ["ariaRole"] }, { kind: "component", type: i2.λ4, selector: "sky-dropdown-menu", inputs: ["ariaLabelledBy", "ariaRole", "useNativeFocus"], outputs: ["menuChanges"] }, { kind: "ngmodule", type: SkyIconModule }, { kind: "component", type: i6$1.λ1, selector: "sky-icon", inputs: ["icon", "iconName", "iconType", "size", "fixedWidth", "variant"] }, { kind: "ngmodule", type: SkyThemeModule }, { kind: "ngmodule", type: SkyToolbarModule }, { kind: "component", type: i6.λ39, selector: "sky-toolbar-item" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1398
1424
|
}
|
|
1399
1425
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.5", ngImport: i0, type: SkyTextEditorToolbarComponent, decorators: [{
|
|
1400
1426
|
type: Component,
|
|
@@ -1437,22 +1463,7 @@ class SkyTextEditorComponent {
|
|
|
1437
1463
|
set disabled(value) {
|
|
1438
1464
|
if (value !== this.disabled) {
|
|
1439
1465
|
this.#_disabled = value;
|
|
1440
|
-
|
|
1441
|
-
let focusableChildren;
|
|
1442
|
-
/* istanbul ignore else */
|
|
1443
|
-
if (this.iframeRef) {
|
|
1444
|
-
focusableChildren = this.#coreAdapterService.getFocusableChildren(this.iframeRef.nativeElement.contentDocument.body, {
|
|
1445
|
-
ignoreVisibility: true,
|
|
1446
|
-
ignoreTabIndex: true,
|
|
1447
|
-
});
|
|
1448
|
-
if (this.#_disabled) {
|
|
1449
|
-
this.#adapterService.disableEditor(focusableChildren, this.iframeRef.nativeElement);
|
|
1450
|
-
}
|
|
1451
|
-
else {
|
|
1452
|
-
this.#adapterService.enableEditor(focusableChildren, this.iframeRef.nativeElement);
|
|
1453
|
-
}
|
|
1454
|
-
this.#changeDetector.markForCheck();
|
|
1455
|
-
}
|
|
1466
|
+
this.#applyDisabledState();
|
|
1456
1467
|
}
|
|
1457
1468
|
}
|
|
1458
1469
|
get disabled() {
|
|
@@ -1802,6 +1813,7 @@ class SkyTextEditorComponent {
|
|
|
1802
1813
|
if (this.autofocus) {
|
|
1803
1814
|
this.#adapterService.focusEditor();
|
|
1804
1815
|
}
|
|
1816
|
+
this.#applyDisabledState();
|
|
1805
1817
|
this.#initialized = true;
|
|
1806
1818
|
this.#focusInitialized = false;
|
|
1807
1819
|
this.#checkAutofocusAndFocus();
|
|
@@ -1820,6 +1832,24 @@ class SkyTextEditorComponent {
|
|
|
1820
1832
|
this.#_onChange(this.#_value);
|
|
1821
1833
|
}
|
|
1822
1834
|
}
|
|
1835
|
+
#applyDisabledState() {
|
|
1836
|
+
// Update focusableChildren inside the iframe.
|
|
1837
|
+
let focusableChildren;
|
|
1838
|
+
/* istanbul ignore else */
|
|
1839
|
+
if (this.iframeRef?.nativeElement.contentDocument?.body) {
|
|
1840
|
+
focusableChildren = this.#coreAdapterService.getFocusableChildren(this.iframeRef.nativeElement.contentDocument.body, {
|
|
1841
|
+
ignoreVisibility: true,
|
|
1842
|
+
ignoreTabIndex: true,
|
|
1843
|
+
});
|
|
1844
|
+
if (this.#_disabled) {
|
|
1845
|
+
this.#adapterService.disableEditor(focusableChildren, this.iframeRef.nativeElement);
|
|
1846
|
+
}
|
|
1847
|
+
else {
|
|
1848
|
+
this.#adapterService.enableEditor(focusableChildren, this.iframeRef.nativeElement);
|
|
1849
|
+
}
|
|
1850
|
+
this.#changeDetector.markForCheck();
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1823
1853
|
/* istanbul ignore next */
|
|
1824
1854
|
#_onTouched;
|
|
1825
1855
|
/* istanbul ignore next */
|