@skyux/text-editor 5.0.3 → 5.5.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 +7 -1
- package/bundles/skyux-text-editor.umd.js +39 -39
- package/documentation.json +61 -14
- package/esm2015/index.js +15 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js +39 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.component.js.map +1 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js +18 -0
- package/esm2015/lib/modules/rich-text-display/rich-text-display.module.js.map +1 -0
- package/esm2015/lib/modules/shared/forms-utility.js +10 -0
- package/esm2015/lib/modules/shared/forms-utility.js.map +1 -0
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js +106 -0
- package/esm2015/lib/modules/shared/sky-text-editor-resources.module.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js +42 -0
- package/esm2015/lib/modules/text-editor/defaults/font-list-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js +7 -0
- package/esm2015/lib/modules/text-editor/defaults/font-size-list-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js +5 -0
- package/esm2015/lib/modules/text-editor/defaults/menu-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js +15 -0
- package/esm2015/lib/modules/text-editor/defaults/style-state-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js +12 -0
- package/esm2015/lib/modules/text-editor/defaults/toolbar-action-defaults.js.map +1 -0
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js +196 -0
- package/esm2015/lib/modules/text-editor/menubar/text-editor-menubar.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js +473 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-adapter.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js +80 -0
- package/esm2015/lib/modules/text-editor/services/text-editor-selection.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js +61 -0
- package/esm2015/lib/modules/text-editor/services/text-editor.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js +38 -0
- package/esm2015/lib/modules/text-editor/services/text-sanitization.service.js.map +1 -0
- package/esm2015/lib/modules/text-editor/text-editor.component.js +322 -0
- package/esm2015/lib/modules/text-editor/text-editor.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/text-editor.module.js +99 -0
- package/esm2015/lib/modules/text-editor/text-editor.module.js.map +1 -0
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js +175 -0
- package/esm2015/lib/modules/text-editor/toolbar/text-editor-toolbar.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/editor-command.js +2 -0
- package/esm2015/lib/modules/text-editor/types/editor-command.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/editor-setting.js +2 -0
- package/esm2015/lib/modules/text-editor/types/editor-setting.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/font-state.js +2 -0
- package/esm2015/lib/modules/text-editor/types/font-state.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/menu-type.js +2 -0
- package/esm2015/lib/modules/text-editor/types/menu-type.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/style-state.js +2 -0
- package/esm2015/lib/modules/text-editor/types/style-state.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js +2 -0
- package/esm2015/lib/modules/text-editor/types/text-editor-merge-field.js.map +1 -0
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js +2 -0
- package/esm2015/lib/modules/text-editor/types/toolbar-action-type.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js +6 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-context.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js +2 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal-result.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js +121 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-modal.component.js.map +1 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js +9 -0
- package/esm2015/lib/modules/text-editor/url-modal/text-editor-url-target.js.map +1 -0
- package/esm2015/skyux-text-editor.js +2 -2
- package/esm2015/skyux-text-editor.js.map +1 -0
- package/fesm2015/skyux-text-editor.js +105 -105
- package/fesm2015/skyux-text-editor.js.map +1 -1
- package/index.d.ts +12 -0
- package/{modules → lib/modules}/rich-text-display/rich-text-display.component.d.ts +0 -0
- package/{modules → lib/modules}/rich-text-display/rich-text-display.module.d.ts +0 -0
- package/{modules → lib/modules}/shared/forms-utility.d.ts +0 -0
- package/{modules → lib/modules}/shared/sky-text-editor-resources.module.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/font-list-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/font-size-list-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/menu-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/style-state-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/defaults/toolbar-action-defaults.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/menubar/text-editor-menubar.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor-adapter.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor-selection.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-editor.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/services/text-sanitization.service.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/text-editor.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/text-editor.module.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/toolbar/text-editor-toolbar.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/editor-command.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/editor-setting.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/font-state.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/menu-type.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/style-state.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/text-editor-merge-field.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/types/toolbar-action-type.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal-context.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal-result.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-modal.component.d.ts +0 -0
- package/{modules → lib/modules}/text-editor/url-modal/text-editor-url-target.d.ts +0 -0
- package/package.json +27 -13
- package/skyux-text-editor.d.ts +1 -1
- package/LICENSE +0 -21
- package/bundles/skyux-text-editor.umd.js.map +0 -1
- package/esm2015/modules/rich-text-display/rich-text-display.component.js +0 -37
- package/esm2015/modules/rich-text-display/rich-text-display.module.js +0 -18
- package/esm2015/modules/shared/forms-utility.js +0 -10
- package/esm2015/modules/shared/sky-text-editor-resources.module.js +0 -106
- package/esm2015/modules/text-editor/defaults/font-list-defaults.js +0 -42
- package/esm2015/modules/text-editor/defaults/font-size-list-defaults.js +0 -7
- package/esm2015/modules/text-editor/defaults/menu-defaults.js +0 -5
- package/esm2015/modules/text-editor/defaults/style-state-defaults.js +0 -15
- package/esm2015/modules/text-editor/defaults/toolbar-action-defaults.js +0 -12
- package/esm2015/modules/text-editor/menubar/text-editor-menubar.component.js +0 -194
- package/esm2015/modules/text-editor/services/text-editor-adapter.service.js +0 -470
- package/esm2015/modules/text-editor/services/text-editor-selection.service.js +0 -80
- package/esm2015/modules/text-editor/services/text-editor.service.js +0 -61
- package/esm2015/modules/text-editor/services/text-sanitization.service.js +0 -38
- package/esm2015/modules/text-editor/text-editor.component.js +0 -317
- package/esm2015/modules/text-editor/text-editor.module.js +0 -99
- package/esm2015/modules/text-editor/toolbar/text-editor-toolbar.component.js +0 -173
- package/esm2015/modules/text-editor/types/editor-command.js +0 -2
- package/esm2015/modules/text-editor/types/editor-setting.js +0 -2
- package/esm2015/modules/text-editor/types/font-state.js +0 -2
- package/esm2015/modules/text-editor/types/menu-type.js +0 -2
- package/esm2015/modules/text-editor/types/style-state.js +0 -2
- package/esm2015/modules/text-editor/types/text-editor-merge-field.js +0 -2
- package/esm2015/modules/text-editor/types/toolbar-action-type.js +0 -2
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal-context.js +0 -6
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal-result.js +0 -2
- package/esm2015/modules/text-editor/url-modal/text-editor-url-modal.component.js +0 -119
- package/esm2015/modules/text-editor/url-modal/text-editor-url-target.js +0 -9
- package/esm2015/public-api.js +0 -15
- package/public-api.d.ts +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar-action-defaults.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/defaults/toolbar-action-defaults.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,aAAa;IACb,WAAW;IACX,YAAY;IACZ,OAAO;IACP,MAAM;IACN,MAAM;CACP,CAAC","sourcesContent":["import { SkyTextEditorToolbarActionType } from '../types/toolbar-action-type';\n\n/**\n * @internal\n */\nexport const TOOLBAR_ACTION_DEFAULTS: SkyTextEditorToolbarActionType[] = [\n 'font-family',\n 'font-size',\n 'font-style',\n 'color',\n 'list',\n 'link',\n];\n"]}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ChangeDetectorRef, ChangeDetectionStrategy, Component, Input, } from '@angular/core';
|
|
2
|
+
import { SkyLibResourcesService } from '@skyux/i18n';
|
|
3
|
+
import { SkyDropdownMessageType } from '@skyux/popovers';
|
|
4
|
+
import { forkJoin, Subject } from 'rxjs';
|
|
5
|
+
import { take, takeUntil } from 'rxjs/operators';
|
|
6
|
+
import { SkyTextEditorAdapterService } from '../services/text-editor-adapter.service';
|
|
7
|
+
import { SkyFormsUtility } from '../../shared/forms-utility';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
import * as i1 from "../services/text-editor-adapter.service";
|
|
10
|
+
import * as i2 from "@skyux/i18n";
|
|
11
|
+
import * as i3 from "@skyux/layout";
|
|
12
|
+
import * as i4 from "@skyux/popovers";
|
|
13
|
+
import * as i5 from "@angular/common";
|
|
14
|
+
import * as i6 from "@skyux/theme";
|
|
15
|
+
/**
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export class SkyTextEditorMenubarComponent {
|
|
19
|
+
constructor(adapterService, changeDetector, resources) {
|
|
20
|
+
this.adapterService = adapterService;
|
|
21
|
+
this.changeDetector = changeDetector;
|
|
22
|
+
this.resources = resources;
|
|
23
|
+
this.editorFocusStream = new Subject();
|
|
24
|
+
this.menus = [];
|
|
25
|
+
this.mergeFields = [];
|
|
26
|
+
this._disabled = false;
|
|
27
|
+
this.editDropdownStream = new Subject();
|
|
28
|
+
this.formatDropdownStream = new Subject();
|
|
29
|
+
this.mergeFieldDropdownStream = new Subject();
|
|
30
|
+
this.ngUnsubscribe = new Subject();
|
|
31
|
+
}
|
|
32
|
+
set disabled(value) {
|
|
33
|
+
const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);
|
|
34
|
+
if (coercedValue !== this.disabled) {
|
|
35
|
+
this._disabled = coercedValue;
|
|
36
|
+
this.changeDetector.markForCheck();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get disabled() {
|
|
40
|
+
return this._disabled;
|
|
41
|
+
}
|
|
42
|
+
ngOnInit() {
|
|
43
|
+
this.editorFocusStream.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {
|
|
44
|
+
this.closeDropdowns();
|
|
45
|
+
});
|
|
46
|
+
forkJoin([
|
|
47
|
+
// Format menu strings.
|
|
48
|
+
this.resources.getString('skyux_text_editor_format_menu_action_bold_label'),
|
|
49
|
+
this.resources.getString('skyux_text_editor_format_menu_action_bold_key_shortcut'),
|
|
50
|
+
this.resources.getString('skyux_text_editor_format_menu_action_italic_label'),
|
|
51
|
+
this.resources.getString('skyux_text_editor_format_menu_action_italic_key_shortcut'),
|
|
52
|
+
this.resources.getString('skyux_text_editor_format_menu_action_underline_label'),
|
|
53
|
+
this.resources.getString('skyux_text_editor_format_menu_action_underline_key_shortcut'),
|
|
54
|
+
this.resources.getString('skyux_text_editor_format_menu_action_strikethrough_label'),
|
|
55
|
+
this.resources.getString('skyux_text_editor_format_menu_action_clear_formatting_label'),
|
|
56
|
+
// Edit menu string - start at index 8.
|
|
57
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_undo_label'),
|
|
58
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_undo_key_shortcut'),
|
|
59
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_redo_label'),
|
|
60
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_redo_key_shortcut'),
|
|
61
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_cut_label'),
|
|
62
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_cut_key_shortcut'),
|
|
63
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_copy_label'),
|
|
64
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_copy_key_shortcut'),
|
|
65
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_paste_label'),
|
|
66
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_paste_key_shortcut'),
|
|
67
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_select_all_label'),
|
|
68
|
+
this.resources.getString('skyux_text_editor_edit_menu_action_select_all_key_shortcut'),
|
|
69
|
+
])
|
|
70
|
+
.pipe(take(1))
|
|
71
|
+
.subscribe((resources) => {
|
|
72
|
+
this.formatItems = [
|
|
73
|
+
{
|
|
74
|
+
function: () => this.execCommand('bold'),
|
|
75
|
+
label: resources[0],
|
|
76
|
+
keyShortcut: resources[1],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
function: () => this.execCommand('italic'),
|
|
80
|
+
label: resources[2],
|
|
81
|
+
keyShortcut: resources[3],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
function: () => this.execCommand('underline'),
|
|
85
|
+
label: resources[4],
|
|
86
|
+
keyShortcut: resources[5],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
function: () => this.execCommand('strikethrough'),
|
|
90
|
+
label: resources[6],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
isDivider: true,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
function: () => this.clearFormat(),
|
|
97
|
+
label: resources[7],
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
this.editItems = [
|
|
101
|
+
{
|
|
102
|
+
function: () => this.execCommand('undo'),
|
|
103
|
+
label: resources[8],
|
|
104
|
+
keyShortcut: resources[9],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
function: () => this.execCommand('redo'),
|
|
108
|
+
label: resources[10],
|
|
109
|
+
keyShortcut: resources[11],
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
isDivider: true,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
function: () => this.execCommand('cut'),
|
|
116
|
+
label: resources[12],
|
|
117
|
+
keyShortcut: resources[13],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
function: () => this.execCommand('copy'),
|
|
121
|
+
label: resources[14],
|
|
122
|
+
keyShortcut: resources[15],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
function: () => this.execCommand('paste'),
|
|
126
|
+
label: resources[16],
|
|
127
|
+
keyShortcut: resources[17],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
isDivider: true,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
function: () => this.execCommand('selectAll'),
|
|
134
|
+
label: resources[18],
|
|
135
|
+
keyShortcut: resources[19],
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
ngOnDestroy() {
|
|
141
|
+
this.ngUnsubscribe.next();
|
|
142
|
+
this.ngUnsubscribe.complete();
|
|
143
|
+
}
|
|
144
|
+
execCommand(command, value = '') {
|
|
145
|
+
this.adapterService.execCommand(this.editorId, {
|
|
146
|
+
command: command,
|
|
147
|
+
value: value,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
insertMergeField(field) {
|
|
151
|
+
this.execCommand('insertHTML', '<img style="display: inline; cursor: grab;" data-fieldid="' +
|
|
152
|
+
field.id +
|
|
153
|
+
'" data-fielddisplay="' +
|
|
154
|
+
field.name +
|
|
155
|
+
'" src="' +
|
|
156
|
+
(field.previewImageUrl ||
|
|
157
|
+
this.adapterService.getMergeFieldDataURI(field.name)) +
|
|
158
|
+
'">');
|
|
159
|
+
}
|
|
160
|
+
closeDropdowns() {
|
|
161
|
+
this.editDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
162
|
+
this.formatDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
163
|
+
this.mergeFieldDropdownStream.next({ type: SkyDropdownMessageType.Close });
|
|
164
|
+
}
|
|
165
|
+
clearFormat() {
|
|
166
|
+
let currentSelection = this.adapterService.getCurrentSelection(this.editorId);
|
|
167
|
+
/* istanbul ignore else */
|
|
168
|
+
if (currentSelection.rangeCount > 0 &&
|
|
169
|
+
currentSelection.getRangeAt(0).toString().length <= 0) {
|
|
170
|
+
this.execCommand('selectAll');
|
|
171
|
+
}
|
|
172
|
+
this.execCommand('removeFormat');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
SkyTextEditorMenubarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorMenubarComponent, deps: [{ token: i1.SkyTextEditorAdapterService }, { token: i0.ChangeDetectorRef }, { token: i2.SkyLibResourcesService }], target: i0.ɵɵFactoryTarget.Component });
|
|
176
|
+
SkyTextEditorMenubarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: SkyTextEditorMenubarComponent, selector: "sky-text-editor-menubar", inputs: { editorFocusStream: "editorFocusStream", editorId: "editorId", menus: "menus", mergeFields: "mergeFields", disabled: "disabled" }, ngImport: i0, template: "<sky-toolbar-item\n *ngFor=\"let menu of menus\"\n class=\"sky-text-editor-menu\"\n [ngClass]=\"'sky-text-editor-menu-' + menu\"\n>\n <ng-container [ngSwitch]=\"menu\">\n <ng-container *ngSwitchCase=\"'edit'\">\n <sky-dropdown\n label=\"Edit menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"editDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_edit_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let editItem of editItems\">\n <button\n *ngIf=\"!editItem.isDivider\"\n type=\"button\"\n (click)=\"editItem.function()\"\n >\n {{ editItem.label }}\n <div\n *ngIf=\"editItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ editItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"editItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'format'\">\n <sky-dropdown\n label=\"Format menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"formatDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_format_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let formatItem of formatItems\">\n <button\n *ngIf=\"!formatItem.isDivider\"\n type=\"button\"\n (click)=\"formatItem.function()\"\n >\n {{ formatItem.label }}\n <div\n *ngIf=\"formatItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ formatItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"formatItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'merge-field'\">\n <sky-dropdown\n *ngIf=\"mergeFields && mergeFields.length > 0\"\n label=\"Insert merge field\"\n [disabled]=\"disabled\"\n [messageStream]=\"mergeFieldDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_insert_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let mergeField of mergeFields\">\n <button type=\"button\" (click)=\"insertMergeField(mergeField)\">\n {{ mergeField.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n", styles: [".sky-text-editor-dropdown-item-divider{border:0;padding:0;height:1px;margin:9px 1px;overflow:hidden;background:transparent;border-bottom:1px solid rgba(0,0,0,.1);cursor:default;filter:none}.sky-text-editor-menu-key-shortcut{float:right;margin-left:15px}\n"], components: [{ type: i3.λ39, selector: "sky-toolbar-item" }, { type: i4.λ3, selector: "sky-dropdown", inputs: ["buttonStyle", "buttonType", "disabled", "dismissOnBlur", "label", "horizontalAlignment", "messageStream", "title", "trigger"] }, { type: i4.λ2, selector: "sky-dropdown-button" }, { type: i4.λ4, selector: "sky-dropdown-menu", inputs: ["ariaLabelledBy", "ariaRole", "useNativeFocus"], outputs: ["menuChanges"] }, { type: i4.λ1, selector: "sky-dropdown-item", inputs: ["ariaRole"] }], directives: [{ type: i5.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i5.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i5.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.λ2, selector: "[skyThemeClass]", inputs: ["class", "skyThemeClass"] }], pipes: { "skyLibResources": i2.SkyLibResourcesPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
177
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyTextEditorMenubarComponent, decorators: [{
|
|
178
|
+
type: Component,
|
|
179
|
+
args: [{
|
|
180
|
+
selector: 'sky-text-editor-menubar',
|
|
181
|
+
templateUrl: './text-editor-menubar.component.html',
|
|
182
|
+
styleUrls: ['./text-editor-menubar.component.scss'],
|
|
183
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
184
|
+
}]
|
|
185
|
+
}], ctorParameters: function () { return [{ type: i1.SkyTextEditorAdapterService }, { type: i0.ChangeDetectorRef }, { type: i2.SkyLibResourcesService }]; }, propDecorators: { editorFocusStream: [{
|
|
186
|
+
type: Input
|
|
187
|
+
}], editorId: [{
|
|
188
|
+
type: Input
|
|
189
|
+
}], menus: [{
|
|
190
|
+
type: Input
|
|
191
|
+
}], mergeFields: [{
|
|
192
|
+
type: Input
|
|
193
|
+
}], disabled: [{
|
|
194
|
+
type: Input
|
|
195
|
+
}] } });
|
|
196
|
+
//# sourceMappingURL=text-editor-menubar.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-editor-menubar.component.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/menubar/text-editor-menubar.component.ts","../../../../../../../../../libs/components/text-editor/src/lib/modules/text-editor/menubar/text-editor-menubar.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,SAAS,EACT,KAAK,GAGN,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAErD,OAAO,EAAsB,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAMtF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;;;;;;;;AAE7D;;GAEG;AAOH,MAAM,OAAO,6BAA6B;IAkDxC,YACU,cAA2C,EAC3C,cAAiC,EACjC,SAAiC;QAFjC,mBAAc,GAAd,cAAc,CAA6B;QAC3C,mBAAc,GAAd,cAAc,CAAmB;QACjC,cAAS,GAAT,SAAS,CAAwB;QAnDpC,sBAAiB,GAAG,IAAI,OAAO,EAAE,CAAC;QAMlC,UAAK,GAA4B,EAAE,CAAC;QAGpC,gBAAW,GAA8B,EAAE,CAAC;QAe3C,cAAS,GAAY,KAAK,CAAC;QAE5B,uBAAkB,GAAG,IAAI,OAAO,EAAsB,CAAC;QASvD,yBAAoB,GAAG,IAAI,OAAO,EAAsB,CAAC;QASzD,6BAAwB,GAAG,IAAI,OAAO,EAAsB,CAAC;QAE5D,kBAAa,GAAG,IAAI,OAAO,EAAQ,CAAC;IAMzC,CAAC;IAzCJ,IACW,QAAQ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AAU,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,EACrD;YACA,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SAC/B;QACD,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;;2HAzOU,6BAA6B;+GAA7B,6BAA6B,2MClC1C,8pHA8GA;4FD5Ea,6BAA6B;kBANzC,SAAS;mBAAC;oBACT,QAAQ,EAAE,yBAAyB;oBACnC,WAAW,EAAE,sCAAsC;oBACnD,SAAS,EAAE,CAAC,sCAAsC,CAAC;oBACnD,eAAe,EAAE,uBAAuB,CAAC,MAAM;iBAChD;uLAGQ,iBAAiB;sBADvB,KAAK;gBAIC,QAAQ;sBADd,KAAK;gBAIC,KAAK;sBADX,KAAK;gBAIC,WAAW;sBADjB,KAAK;gBAIK,QAAQ;sBADlB,KAAK","sourcesContent":["import {\n ChangeDetectorRef,\n ChangeDetectionStrategy,\n Component,\n Input,\n OnDestroy,\n OnInit,\n} from '@angular/core';\n\nimport { SkyLibResourcesService } from '@skyux/i18n';\n\nimport { SkyDropdownMessage, SkyDropdownMessageType } from '@skyux/popovers';\n\nimport { forkJoin, Subject } from 'rxjs';\n\nimport { take, takeUntil } from 'rxjs/operators';\n\nimport { SkyTextEditorAdapterService } from '../services/text-editor-adapter.service';\n\nimport { SkyTextEditorMenuType } from '../types/menu-type';\n\nimport { SkyTextEditorMergeField } from '../types/text-editor-merge-field';\n\nimport { SkyFormsUtility } from '../../shared/forms-utility';\n\n/**\n * @internal\n */\n@Component({\n selector: 'sky-text-editor-menubar',\n templateUrl: './text-editor-menubar.component.html',\n styleUrls: ['./text-editor-menubar.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SkyTextEditorMenubarComponent implements OnDestroy, OnInit {\n @Input()\n public editorFocusStream = new Subject();\n\n @Input()\n public editorId: string;\n\n @Input()\n public menus: SkyTextEditorMenuType[] = [];\n\n @Input()\n public mergeFields: SkyTextEditorMergeField[] = [];\n\n @Input()\n public set disabled(value: boolean) {\n const coercedValue = SkyFormsUtility.coerceBooleanProperty(value);\n if (coercedValue !== this.disabled) {\n this._disabled = coercedValue;\n this.changeDetector.markForCheck();\n }\n }\n\n public get disabled(): boolean {\n return this._disabled;\n }\n\n private _disabled: boolean = false;\n\n public editDropdownStream = new Subject<SkyDropdownMessage>();\n\n public editItems: {\n function?: () => void;\n isDivider?: boolean;\n label?: string;\n keyShortcut?: string;\n }[];\n\n public formatDropdownStream = new Subject<SkyDropdownMessage>();\n\n public formatItems: {\n function?: () => void;\n isDivider?: boolean;\n label?: string;\n keyShortcut?: string;\n }[];\n\n public mergeFieldDropdownStream = new Subject<SkyDropdownMessage>();\n\n private ngUnsubscribe = new Subject<void>();\n\n constructor(\n private adapterService: SkyTextEditorAdapterService,\n private changeDetector: ChangeDetectorRef,\n private resources: SkyLibResourcesService\n ) {}\n\n public ngOnInit(): void {\n this.editorFocusStream.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n this.closeDropdowns();\n });\n\n forkJoin([\n // Format menu strings.\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_bold_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_bold_key_shortcut'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_italic_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_italic_key_shortcut'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_underline_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_underline_key_shortcut'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_strikethrough_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_format_menu_action_clear_formatting_label'\n ),\n\n // Edit menu string - start at index 8.\n this.resources.getString('skyux_text_editor_edit_menu_action_undo_label'),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_undo_key_shortcut'\n ),\n this.resources.getString('skyux_text_editor_edit_menu_action_redo_label'),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_redo_key_shortcut'\n ),\n this.resources.getString('skyux_text_editor_edit_menu_action_cut_label'),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_cut_key_shortcut'\n ),\n this.resources.getString('skyux_text_editor_edit_menu_action_copy_label'),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_copy_key_shortcut'\n ),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_paste_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_paste_key_shortcut'\n ),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_select_all_label'\n ),\n this.resources.getString(\n 'skyux_text_editor_edit_menu_action_select_all_key_shortcut'\n ),\n ])\n .pipe(take(1))\n .subscribe((resources) => {\n this.formatItems = [\n {\n function: () => this.execCommand('bold'),\n label: resources[0],\n keyShortcut: resources[1],\n },\n {\n function: () => this.execCommand('italic'),\n label: resources[2],\n keyShortcut: resources[3],\n },\n {\n function: () => this.execCommand('underline'),\n label: resources[4],\n keyShortcut: resources[5],\n },\n {\n function: () => this.execCommand('strikethrough'),\n label: resources[6],\n },\n {\n isDivider: true,\n },\n {\n function: () => this.clearFormat(),\n label: resources[7],\n },\n ];\n this.editItems = [\n {\n function: () => this.execCommand('undo'),\n label: resources[8],\n keyShortcut: resources[9],\n },\n {\n function: () => this.execCommand('redo'),\n label: resources[10],\n keyShortcut: resources[11],\n },\n {\n isDivider: true,\n },\n {\n function: () => this.execCommand('cut'),\n label: resources[12],\n keyShortcut: resources[13],\n },\n {\n function: () => this.execCommand('copy'),\n label: resources[14],\n keyShortcut: resources[15],\n },\n {\n function: () => this.execCommand('paste'),\n label: resources[16],\n keyShortcut: resources[17],\n },\n {\n isDivider: true,\n },\n {\n function: () => this.execCommand('selectAll'),\n label: resources[18],\n keyShortcut: resources[19],\n },\n ];\n });\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n\n public execCommand(command: string, value: any = ''): void {\n this.adapterService.execCommand(this.editorId, {\n command: command,\n value: value,\n });\n }\n\n public insertMergeField(field: SkyTextEditorMergeField): void {\n this.execCommand(\n 'insertHTML',\n '<img style=\"display: inline; cursor: grab;\" data-fieldid=\"' +\n field.id +\n '\" data-fielddisplay=\"' +\n field.name +\n '\" src=\"' +\n (field.previewImageUrl ||\n this.adapterService.getMergeFieldDataURI(field.name)) +\n '\">'\n );\n }\n\n private closeDropdowns(): void {\n this.editDropdownStream.next({ type: SkyDropdownMessageType.Close });\n this.formatDropdownStream.next({ type: SkyDropdownMessageType.Close });\n this.mergeFieldDropdownStream.next({ type: SkyDropdownMessageType.Close });\n }\n\n private clearFormat(): void {\n let currentSelection = this.adapterService.getCurrentSelection(\n this.editorId\n );\n /* istanbul ignore else */\n if (\n currentSelection.rangeCount > 0 &&\n currentSelection.getRangeAt(0).toString().length <= 0\n ) {\n this.execCommand('selectAll');\n }\n this.execCommand('removeFormat');\n }\n}\n","<sky-toolbar-item\n *ngFor=\"let menu of menus\"\n class=\"sky-text-editor-menu\"\n [ngClass]=\"'sky-text-editor-menu-' + menu\"\n>\n <ng-container [ngSwitch]=\"menu\">\n <ng-container *ngSwitchCase=\"'edit'\">\n <sky-dropdown\n label=\"Edit menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"editDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_edit_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let editItem of editItems\">\n <button\n *ngIf=\"!editItem.isDivider\"\n type=\"button\"\n (click)=\"editItem.function()\"\n >\n {{ editItem.label }}\n <div\n *ngIf=\"editItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ editItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"editItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'format'\">\n <sky-dropdown\n label=\"Format menu\"\n [disabled]=\"disabled\"\n [messageStream]=\"formatDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_format_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let formatItem of formatItems\">\n <button\n *ngIf=\"!formatItem.isDivider\"\n type=\"button\"\n (click)=\"formatItem.function()\"\n >\n {{ formatItem.label }}\n <div\n *ngIf=\"formatItem.keyShortcut\"\n class=\"sky-text-editor-menu-key-shortcut\"\n [skyThemeClass]=\"{\n 'sky-font-deemphasized': 'modern',\n 'sky-deemphasized': 'default'\n }\"\n >\n {{ formatItem.keyShortcut }}\n </div>\n </button>\n <div\n *ngIf=\"formatItem.isDivider\"\n class=\"sky-text-editor-dropdown-item-divider\"\n role=\"divider\"\n ></div>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n <ng-container *ngSwitchCase=\"'merge-field'\">\n <sky-dropdown\n *ngIf=\"mergeFields && mergeFields.length > 0\"\n label=\"Insert merge field\"\n [disabled]=\"disabled\"\n [messageStream]=\"mergeFieldDropdownStream\"\n >\n <sky-dropdown-button>\n {{\n 'skyux_text_editor_menubar_dropdown_button_insert_label'\n | skyLibResources\n }}\n </sky-dropdown-button>\n <sky-dropdown-menu>\n <sky-dropdown-item *ngFor=\"let mergeField of mergeFields\">\n <button type=\"button\" (click)=\"insertMergeField(mergeField)\">\n {{ mergeField.name }}\n </button>\n </sky-dropdown-item>\n </sky-dropdown-menu>\n </sky-dropdown>\n </ng-container>\n </ng-container>\n</sky-toolbar-item>\n"]}
|