@kolkov/angular-editor 3.0.0-beta.2 → 3.0.1
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/CHANGELOG.md +69 -1
- package/README.md +15 -10
- package/assets/icons/icons.svg +2 -2
- package/fesm2022/kolkov-angular-editor.mjs +1360 -0
- package/fesm2022/kolkov-angular-editor.mjs.map +1 -0
- package/index.d.ts +412 -0
- package/package.json +10 -16
- package/themes/default.scss +22 -22
- package/esm2020/kolkov-angular-editor.mjs +0 -5
- package/esm2020/lib/ae-button/ae-button.component.mjs +0 -21
- package/esm2020/lib/ae-select/ae-select.component.mjs +0 -185
- package/esm2020/lib/ae-toolbar/ae-toolbar.component.mjs +0 -365
- package/esm2020/lib/ae-toolbar-set/ae-toolbar-set.component.mjs +0 -15
- package/esm2020/lib/angular-editor.module.mjs +0 -27
- package/esm2020/lib/angular-editor.service.mjs +0 -275
- package/esm2020/lib/config.mjs +0 -36
- package/esm2020/lib/editor/angular-editor.component.mjs +0 -415
- package/esm2020/lib/utils.mjs +0 -4
- package/esm2020/public-api.mjs +0 -11
- package/fesm2015/kolkov-angular-editor.mjs +0 -1325
- package/fesm2015/kolkov-angular-editor.mjs.map +0 -1
- package/fesm2020/kolkov-angular-editor.mjs +0 -1319
- package/fesm2020/kolkov-angular-editor.mjs.map +0 -1
- package/kolkov-angular-editor.d.ts +0 -5
- package/lib/ae-button/ae-button.component.d.ts +0 -7
- package/lib/ae-select/ae-select.component.d.ts +0 -46
- package/lib/ae-toolbar/ae-toolbar.component.d.ts +0 -97
- package/lib/ae-toolbar-set/ae-toolbar-set.component.d.ts +0 -6
- package/lib/angular-editor.module.d.ts +0 -13
- package/lib/angular-editor.service.d.ts +0 -87
- package/lib/config.d.ts +0 -39
- package/lib/editor/angular-editor.component.d.ts +0 -133
- package/lib/utils.d.ts +0 -1
- package/public-api.d.ts +0 -8
|
@@ -1,1319 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Inject, Component, Input, EventEmitter, forwardRef, HostBinding, Output, ViewChild, HostListener, SecurityContext, Attribute, ContentChild, NgModule } from '@angular/core';
|
|
3
|
-
import * as i1$1 from '@angular/common';
|
|
4
|
-
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
5
|
-
import * as i1 from '@angular/common/http';
|
|
6
|
-
import * as i6 from '@angular/forms';
|
|
7
|
-
import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
-
import * as i2 from '@angular/platform-browser';
|
|
9
|
-
|
|
10
|
-
class AngularEditorService {
|
|
11
|
-
constructor(http, doc) {
|
|
12
|
-
this.http = http;
|
|
13
|
-
this.doc = doc;
|
|
14
|
-
/**
|
|
15
|
-
* save selection when the editor is focussed out
|
|
16
|
-
*/
|
|
17
|
-
this.saveSelection = () => {
|
|
18
|
-
if (this.doc.getSelection) {
|
|
19
|
-
const sel = this.doc.getSelection();
|
|
20
|
-
if (sel.getRangeAt && sel.rangeCount) {
|
|
21
|
-
this.savedSelection = sel.getRangeAt(0);
|
|
22
|
-
this.selectedText = sel.toString();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else if (this.doc.getSelection && this.doc.createRange) {
|
|
26
|
-
this.savedSelection = document.createRange();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.savedSelection = null;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Executed command from editor header buttons exclude toggleEditorMode
|
|
35
|
-
* @param command string from triggerCommand
|
|
36
|
-
* @param value
|
|
37
|
-
*/
|
|
38
|
-
executeCommand(command, value) {
|
|
39
|
-
const commands = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'pre'];
|
|
40
|
-
if (commands.includes(command)) {
|
|
41
|
-
this.doc.execCommand('formatBlock', false, command);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.doc.execCommand(command, false, value);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Create URL link
|
|
48
|
-
* @param url string from UI prompt
|
|
49
|
-
*/
|
|
50
|
-
createLink(url) {
|
|
51
|
-
if (!url.includes('http')) {
|
|
52
|
-
this.doc.execCommand('createlink', false, url);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const newUrl = '<a href="' + url + '" target="_blank">' + this.selectedText + '</a>';
|
|
56
|
-
this.insertHtml(newUrl);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* insert color either font or background
|
|
61
|
-
*
|
|
62
|
-
* @param color color to be inserted
|
|
63
|
-
* @param where where the color has to be inserted either text/background
|
|
64
|
-
*/
|
|
65
|
-
insertColor(color, where) {
|
|
66
|
-
const restored = this.restoreSelection();
|
|
67
|
-
if (restored) {
|
|
68
|
-
if (where === 'textColor') {
|
|
69
|
-
this.doc.execCommand('foreColor', false, color);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
this.doc.execCommand('hiliteColor', false, color);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Set font name
|
|
78
|
-
* @param fontName string
|
|
79
|
-
*/
|
|
80
|
-
setFontName(fontName) {
|
|
81
|
-
this.doc.execCommand('fontName', false, fontName);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Set font size
|
|
85
|
-
* @param fontSize string
|
|
86
|
-
*/
|
|
87
|
-
setFontSize(fontSize) {
|
|
88
|
-
this.doc.execCommand('fontSize', false, fontSize);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Create raw HTML
|
|
92
|
-
* @param html HTML string
|
|
93
|
-
*/
|
|
94
|
-
insertHtml(html) {
|
|
95
|
-
const isHTMLInserted = this.doc.execCommand('insertHTML', false, html);
|
|
96
|
-
if (!isHTMLInserted) {
|
|
97
|
-
throw new Error('Unable to perform the operation');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* restore selection when the editor is focused in
|
|
102
|
-
*
|
|
103
|
-
* saved selection when the editor is focused out
|
|
104
|
-
*/
|
|
105
|
-
restoreSelection() {
|
|
106
|
-
if (this.savedSelection) {
|
|
107
|
-
if (this.doc.getSelection) {
|
|
108
|
-
const sel = this.doc.getSelection();
|
|
109
|
-
sel.removeAllRanges();
|
|
110
|
-
sel.addRange(this.savedSelection);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
else if (this.doc.getSelection /*&& this.savedSelection.select*/) {
|
|
114
|
-
// this.savedSelection.select();
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* setTimeout used for execute 'saveSelection' method in next event loop iteration
|
|
124
|
-
*/
|
|
125
|
-
executeInNextQueueIteration(callbackFn, timeout = 1e2) {
|
|
126
|
-
setTimeout(callbackFn, timeout);
|
|
127
|
-
}
|
|
128
|
-
/** check any selection is made or not */
|
|
129
|
-
checkSelection() {
|
|
130
|
-
const selectedText = this.savedSelection.toString();
|
|
131
|
-
if (selectedText.length === 0) {
|
|
132
|
-
throw new Error('No Selection Made');
|
|
133
|
-
}
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Upload file to uploadUrl
|
|
138
|
-
* @param file The file
|
|
139
|
-
*/
|
|
140
|
-
uploadImage(file) {
|
|
141
|
-
const uploadData = new FormData();
|
|
142
|
-
uploadData.append('file', file, file.name);
|
|
143
|
-
return this.http.post(this.uploadUrl, uploadData, {
|
|
144
|
-
reportProgress: true,
|
|
145
|
-
observe: 'events',
|
|
146
|
-
withCredentials: this.uploadWithCredentials,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Insert image with Url
|
|
151
|
-
* @param imageUrl The imageUrl.
|
|
152
|
-
*/
|
|
153
|
-
insertImage(imageUrl) {
|
|
154
|
-
this.doc.execCommand('insertImage', false, imageUrl);
|
|
155
|
-
}
|
|
156
|
-
setDefaultParagraphSeparator(separator) {
|
|
157
|
-
this.doc.execCommand('defaultParagraphSeparator', false, separator);
|
|
158
|
-
}
|
|
159
|
-
createCustomClass(customClass) {
|
|
160
|
-
let newTag = this.selectedText;
|
|
161
|
-
if (customClass) {
|
|
162
|
-
const tagName = customClass.tag ? customClass.tag : 'span';
|
|
163
|
-
newTag = '<' + tagName + ' class="' + customClass.class + '">' + this.selectedText + '</' + tagName + '>';
|
|
164
|
-
}
|
|
165
|
-
this.insertHtml(newTag);
|
|
166
|
-
}
|
|
167
|
-
insertVideo(videoUrl) {
|
|
168
|
-
if (videoUrl.match('www.youtube.com')) {
|
|
169
|
-
this.insertYouTubeVideoTag(videoUrl);
|
|
170
|
-
}
|
|
171
|
-
if (videoUrl.match('vimeo.com')) {
|
|
172
|
-
this.insertVimeoVideoTag(videoUrl);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
insertYouTubeVideoTag(videoUrl) {
|
|
176
|
-
const id = videoUrl.split('v=')[1];
|
|
177
|
-
const imageUrl = `https://img.youtube.com/vi/${id}/0.jpg`;
|
|
178
|
-
const thumbnail = `
|
|
179
|
-
<div style='position: relative'>
|
|
180
|
-
<a href='${videoUrl}' target='_blank'>
|
|
181
|
-
<img src="${imageUrl}" alt="click to watch"/>
|
|
182
|
-
<img style='position: absolute; left:200px; top:140px'
|
|
183
|
-
src="https://img.icons8.com/color/96/000000/youtube-play.png"/>
|
|
184
|
-
</a>
|
|
185
|
-
</div>`;
|
|
186
|
-
this.insertHtml(thumbnail);
|
|
187
|
-
}
|
|
188
|
-
insertVimeoVideoTag(videoUrl) {
|
|
189
|
-
const sub = this.http.get(`https://vimeo.com/api/oembed.json?url=${videoUrl}`).subscribe(data => {
|
|
190
|
-
const imageUrl = data.thumbnail_url_with_play_button;
|
|
191
|
-
const thumbnail = `<div>
|
|
192
|
-
<a href='${videoUrl}' target='_blank'>
|
|
193
|
-
<img src="${imageUrl}" alt="${data.title}"/>
|
|
194
|
-
</a>
|
|
195
|
-
</div>`;
|
|
196
|
-
this.insertHtml(thumbnail);
|
|
197
|
-
sub.unsubscribe();
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
nextNode(node) {
|
|
201
|
-
if (node.hasChildNodes()) {
|
|
202
|
-
return node.firstChild;
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
while (node && !node.nextSibling) {
|
|
206
|
-
node = node.parentNode;
|
|
207
|
-
}
|
|
208
|
-
if (!node) {
|
|
209
|
-
return null;
|
|
210
|
-
}
|
|
211
|
-
return node.nextSibling;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
getRangeSelectedNodes(range, includePartiallySelectedContainers) {
|
|
215
|
-
let node = range.startContainer;
|
|
216
|
-
const endNode = range.endContainer;
|
|
217
|
-
let rangeNodes = [];
|
|
218
|
-
// Special case for a range that is contained within a single node
|
|
219
|
-
if (node === endNode) {
|
|
220
|
-
rangeNodes = [node];
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
// Iterate nodes until we hit the end container
|
|
224
|
-
while (node && node !== endNode) {
|
|
225
|
-
rangeNodes.push(node = this.nextNode(node));
|
|
226
|
-
}
|
|
227
|
-
// Add partially selected nodes at the start of the range
|
|
228
|
-
node = range.startContainer;
|
|
229
|
-
while (node && node !== range.commonAncestorContainer) {
|
|
230
|
-
rangeNodes.unshift(node);
|
|
231
|
-
node = node.parentNode;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// Add ancestors of the range container, if required
|
|
235
|
-
if (includePartiallySelectedContainers) {
|
|
236
|
-
node = range.commonAncestorContainer;
|
|
237
|
-
while (node) {
|
|
238
|
-
rangeNodes.push(node);
|
|
239
|
-
node = node.parentNode;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
return rangeNodes;
|
|
243
|
-
}
|
|
244
|
-
getSelectedNodes() {
|
|
245
|
-
const nodes = [];
|
|
246
|
-
if (this.doc.getSelection) {
|
|
247
|
-
const sel = this.doc.getSelection();
|
|
248
|
-
for (let i = 0, len = sel.rangeCount; i < len; ++i) {
|
|
249
|
-
nodes.push.apply(nodes, this.getRangeSelectedNodes(sel.getRangeAt(i), true));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return nodes;
|
|
253
|
-
}
|
|
254
|
-
replaceWithOwnChildren(el) {
|
|
255
|
-
const parent = el.parentNode;
|
|
256
|
-
while (el.hasChildNodes()) {
|
|
257
|
-
parent.insertBefore(el.firstChild, el);
|
|
258
|
-
}
|
|
259
|
-
parent.removeChild(el);
|
|
260
|
-
}
|
|
261
|
-
removeSelectedElements(tagNames) {
|
|
262
|
-
const tagNamesArray = tagNames.toLowerCase().split(',');
|
|
263
|
-
this.getSelectedNodes().forEach((node) => {
|
|
264
|
-
if (node.nodeType === 1 &&
|
|
265
|
-
tagNamesArray.indexOf(node.tagName.toLowerCase()) > -1) {
|
|
266
|
-
// Remove the node and replace it with its children
|
|
267
|
-
this.replaceWithOwnChildren(node);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
AngularEditorService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorService, deps: [{ token: i1.HttpClient }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
273
|
-
AngularEditorService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorService });
|
|
274
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorService, decorators: [{
|
|
275
|
-
type: Injectable
|
|
276
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: undefined, decorators: [{
|
|
277
|
-
type: Inject,
|
|
278
|
-
args: [DOCUMENT]
|
|
279
|
-
}] }]; } });
|
|
280
|
-
|
|
281
|
-
const angularEditorConfig = {
|
|
282
|
-
editable: true,
|
|
283
|
-
spellcheck: true,
|
|
284
|
-
height: 'auto',
|
|
285
|
-
minHeight: '0',
|
|
286
|
-
maxHeight: 'auto',
|
|
287
|
-
width: 'auto',
|
|
288
|
-
minWidth: '0',
|
|
289
|
-
translate: 'yes',
|
|
290
|
-
enableToolbar: true,
|
|
291
|
-
showToolbar: true,
|
|
292
|
-
placeholder: 'Enter text here...',
|
|
293
|
-
defaultParagraphSeparator: '',
|
|
294
|
-
defaultFontName: '',
|
|
295
|
-
defaultFontSize: '',
|
|
296
|
-
fonts: [
|
|
297
|
-
{ class: 'arial', name: 'Arial' },
|
|
298
|
-
{ class: 'times-new-roman', name: 'Times New Roman' },
|
|
299
|
-
{ class: 'calibri', name: 'Calibri' },
|
|
300
|
-
{ class: 'comic-sans-ms', name: 'Comic Sans MS' }
|
|
301
|
-
],
|
|
302
|
-
uploadUrl: 'v1/image',
|
|
303
|
-
uploadWithCredentials: false,
|
|
304
|
-
sanitize: true,
|
|
305
|
-
toolbarPosition: 'top',
|
|
306
|
-
outline: true,
|
|
307
|
-
/*toolbarHiddenButtons: [
|
|
308
|
-
['bold', 'italic', 'underline', 'strikeThrough', 'superscript', 'subscript'],
|
|
309
|
-
['heading', 'fontName', 'fontSize', 'color'],
|
|
310
|
-
['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'indent', 'outdent'],
|
|
311
|
-
['cut', 'copy', 'delete', 'removeFormat', 'undo', 'redo'],
|
|
312
|
-
['paragraph', 'blockquote', 'removeBlockquote', 'horizontalLine', 'orderedList', 'unorderedList'],
|
|
313
|
-
['link', 'unlink', 'image', 'video']
|
|
314
|
-
]*/
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
function isDefined(value) {
|
|
318
|
-
return value !== undefined && value !== null;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
class AeToolbarSetComponent {
|
|
322
|
-
constructor() {
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
AeToolbarSetComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeToolbarSetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
326
|
-
AeToolbarSetComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: AeToolbarSetComponent, selector: "ae-toolbar-set, [aeToolbarSet]", host: { classAttribute: "angular-editor-toolbar-set" }, ngImport: i0, template: "<ng-content></ng-content>\n", styles: ["a{cursor:pointer}:host.angular-editor-toolbar-set{display:flex;gap:1px;width:fit-content;vertical-align:baseline}\n"] });
|
|
327
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeToolbarSetComponent, decorators: [{
|
|
328
|
-
type: Component,
|
|
329
|
-
args: [{ selector: 'ae-toolbar-set, [aeToolbarSet]', host: {
|
|
330
|
-
'class': 'angular-editor-toolbar-set'
|
|
331
|
-
}, template: "<ng-content></ng-content>\n", styles: ["a{cursor:pointer}:host.angular-editor-toolbar-set{display:flex;gap:1px;width:fit-content;vertical-align:baseline}\n"] }]
|
|
332
|
-
}], ctorParameters: function () { return []; } });
|
|
333
|
-
|
|
334
|
-
class AeButtonComponent {
|
|
335
|
-
constructor() {
|
|
336
|
-
this.iconName = '';
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
AeButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
340
|
-
AeButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: AeButtonComponent, selector: "ae-button, button[aeButton]", inputs: { iconName: "iconName" }, host: { properties: { "tabIndex": "-1", "type": "\"button\"" }, classAttribute: "angular-editor-button" }, ngImport: i0, template: "<ng-container *ngIf=\"iconName; else contentTemplate\">\n <svg>\n <use [attr.href]=\"'assets/ae-icons/icons.svg#' + iconName\" [attr.xlink:href]=\"'assets/ae-icons/icons.svg#' + iconName\"></use>\n </svg>\n</ng-container>\n<ng-template #contentTemplate>\n <ng-content></ng-content>\n</ng-template>\n", styles: ["a{cursor:pointer}:host.angular-editor-button{background-color:var(--ae-button-bg-color, white);vertical-align:middle;border:var(--ae-button-border, 1px solid #ddd);border-radius:var(--ae-button-radius, 4px);padding:.4rem;float:left;width:2rem;height:2rem}:host.angular-editor-button svg{width:100%;height:100%}:host.angular-editor-button:hover{cursor:pointer;background-color:var(--ae-button-hover-bg-color, #f1f1f1);transition:.2s ease}:host.angular-editor-button:focus,:host.angular-editor-button.focus{outline:0}:host.angular-editor-button:disabled{background-color:var(--ae-button-disabled-bg-color, #f5f5f5);pointer-events:none;cursor:not-allowed}:host.angular-editor-button:disabled>.color-label{pointer-events:none;cursor:not-allowed}:host.angular-editor-button:disabled>.color-label.foreground :after{background:#555555}:host.angular-editor-button:disabled>.color-label.background{background:#555555}:host.angular-editor-button.active{background:var(--ae-button-active-bg-color, #fffbd3)}:host.angular-editor-button.active:hover{background-color:var(--ae-button-active-hover-bg-color, #fffaad)}\n"], directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
341
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeButtonComponent, decorators: [{
|
|
342
|
-
type: Component,
|
|
343
|
-
args: [{ selector: 'ae-button, button[aeButton]', host: {
|
|
344
|
-
'class': 'angular-editor-button',
|
|
345
|
-
'[tabIndex]': '-1',
|
|
346
|
-
'[type]': '"button"',
|
|
347
|
-
}, template: "<ng-container *ngIf=\"iconName; else contentTemplate\">\n <svg>\n <use [attr.href]=\"'assets/ae-icons/icons.svg#' + iconName\" [attr.xlink:href]=\"'assets/ae-icons/icons.svg#' + iconName\"></use>\n </svg>\n</ng-container>\n<ng-template #contentTemplate>\n <ng-content></ng-content>\n</ng-template>\n", styles: ["a{cursor:pointer}:host.angular-editor-button{background-color:var(--ae-button-bg-color, white);vertical-align:middle;border:var(--ae-button-border, 1px solid #ddd);border-radius:var(--ae-button-radius, 4px);padding:.4rem;float:left;width:2rem;height:2rem}:host.angular-editor-button svg{width:100%;height:100%}:host.angular-editor-button:hover{cursor:pointer;background-color:var(--ae-button-hover-bg-color, #f1f1f1);transition:.2s ease}:host.angular-editor-button:focus,:host.angular-editor-button.focus{outline:0}:host.angular-editor-button:disabled{background-color:var(--ae-button-disabled-bg-color, #f5f5f5);pointer-events:none;cursor:not-allowed}:host.angular-editor-button:disabled>.color-label{pointer-events:none;cursor:not-allowed}:host.angular-editor-button:disabled>.color-label.foreground :after{background:#555555}:host.angular-editor-button:disabled>.color-label.background{background:#555555}:host.angular-editor-button.active{background:var(--ae-button-active-bg-color, #fffbd3)}:host.angular-editor-button.active:hover{background-color:var(--ae-button-active-hover-bg-color, #fffaad)}\n"] }]
|
|
348
|
-
}], ctorParameters: function () { return []; }, propDecorators: { iconName: [{
|
|
349
|
-
type: Input
|
|
350
|
-
}] } });
|
|
351
|
-
|
|
352
|
-
class AeSelectComponent {
|
|
353
|
-
constructor(elRef, r) {
|
|
354
|
-
this.elRef = elRef;
|
|
355
|
-
this.r = r;
|
|
356
|
-
this.options = [];
|
|
357
|
-
this.disabled = false;
|
|
358
|
-
this.optionId = 0;
|
|
359
|
-
this.opened = false;
|
|
360
|
-
this.hidden = 'inline-block';
|
|
361
|
-
// eslint-disable-next-line @angular-eslint/no-output-native, @angular-eslint/no-output-rename
|
|
362
|
-
this.changeEvent = new EventEmitter();
|
|
363
|
-
this.onChange = () => {
|
|
364
|
-
};
|
|
365
|
-
this.onTouched = () => {
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
get label() {
|
|
369
|
-
return this.selectedOption && this.selectedOption.hasOwnProperty('label') ? this.selectedOption.label : 'Select';
|
|
370
|
-
}
|
|
371
|
-
get value() {
|
|
372
|
-
return this.selectedOption.value;
|
|
373
|
-
}
|
|
374
|
-
ngOnInit() {
|
|
375
|
-
this.selectedOption = this.options[0];
|
|
376
|
-
if (isDefined(this.isHidden) && this.isHidden) {
|
|
377
|
-
this.hide();
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
hide() {
|
|
381
|
-
this.hidden = 'none';
|
|
382
|
-
}
|
|
383
|
-
optionSelect(option, event) {
|
|
384
|
-
event.stopPropagation();
|
|
385
|
-
this.setValue(option.value);
|
|
386
|
-
this.onChange(this.selectedOption.value);
|
|
387
|
-
this.changeEvent.emit(this.selectedOption.value);
|
|
388
|
-
this.onTouched();
|
|
389
|
-
this.opened = false;
|
|
390
|
-
}
|
|
391
|
-
toggleOpen(event) {
|
|
392
|
-
// event.stopPropagation();
|
|
393
|
-
if (this.disabled) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
this.opened = !this.opened;
|
|
397
|
-
}
|
|
398
|
-
onClick($event) {
|
|
399
|
-
if (!this.elRef.nativeElement.contains($event.target)) {
|
|
400
|
-
this.close();
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
close() {
|
|
404
|
-
this.opened = false;
|
|
405
|
-
}
|
|
406
|
-
get isOpen() {
|
|
407
|
-
return this.opened;
|
|
408
|
-
}
|
|
409
|
-
writeValue(value) {
|
|
410
|
-
if (!value || typeof value !== 'string') {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
this.setValue(value);
|
|
414
|
-
}
|
|
415
|
-
setValue(value) {
|
|
416
|
-
let index = 0;
|
|
417
|
-
const selectedEl = this.options.find((el, i) => {
|
|
418
|
-
index = i;
|
|
419
|
-
return el.value === value;
|
|
420
|
-
});
|
|
421
|
-
if (selectedEl) {
|
|
422
|
-
this.selectedOption = selectedEl;
|
|
423
|
-
this.optionId = index;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
registerOnChange(fn) {
|
|
427
|
-
this.onChange = fn;
|
|
428
|
-
}
|
|
429
|
-
registerOnTouched(fn) {
|
|
430
|
-
this.onTouched = fn;
|
|
431
|
-
}
|
|
432
|
-
setDisabledState(isDisabled) {
|
|
433
|
-
this.labelButton.nativeElement.disabled = isDisabled;
|
|
434
|
-
const div = this.labelButton.nativeElement;
|
|
435
|
-
const action = isDisabled ? 'addClass' : 'removeClass';
|
|
436
|
-
this.r[action](div, 'disabled');
|
|
437
|
-
this.disabled = isDisabled;
|
|
438
|
-
}
|
|
439
|
-
handleKeyDown($event) {
|
|
440
|
-
if (!this.opened) {
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
// console.log($event.key);
|
|
444
|
-
// if (KeyCode[$event.key]) {
|
|
445
|
-
switch ($event.key) {
|
|
446
|
-
case 'ArrowDown':
|
|
447
|
-
this._handleArrowDown($event);
|
|
448
|
-
break;
|
|
449
|
-
case 'ArrowUp':
|
|
450
|
-
this._handleArrowUp($event);
|
|
451
|
-
break;
|
|
452
|
-
case 'Space':
|
|
453
|
-
this._handleSpace($event);
|
|
454
|
-
break;
|
|
455
|
-
case 'Enter':
|
|
456
|
-
this._handleEnter($event);
|
|
457
|
-
break;
|
|
458
|
-
case 'Tab':
|
|
459
|
-
this._handleTab($event);
|
|
460
|
-
break;
|
|
461
|
-
case 'Escape':
|
|
462
|
-
this.close();
|
|
463
|
-
$event.preventDefault();
|
|
464
|
-
break;
|
|
465
|
-
case 'Backspace':
|
|
466
|
-
this._handleBackspace();
|
|
467
|
-
break;
|
|
468
|
-
}
|
|
469
|
-
// } else if ($event.key && $event.key.length === 1) {
|
|
470
|
-
// this._keyPress$.next($event.key.toLocaleLowerCase());
|
|
471
|
-
// }
|
|
472
|
-
}
|
|
473
|
-
_handleArrowDown($event) {
|
|
474
|
-
if (this.optionId < this.options.length - 1) {
|
|
475
|
-
this.optionId++;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
_handleArrowUp($event) {
|
|
479
|
-
if (this.optionId >= 1) {
|
|
480
|
-
this.optionId--;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
_handleSpace($event) {
|
|
484
|
-
}
|
|
485
|
-
_handleEnter($event) {
|
|
486
|
-
this.optionSelect(this.options[this.optionId], $event);
|
|
487
|
-
}
|
|
488
|
-
_handleTab($event) {
|
|
489
|
-
}
|
|
490
|
-
_handleBackspace() {
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
AeSelectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeSelectComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
|
|
494
|
-
AeSelectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: AeSelectComponent, selector: "ae-select", inputs: { options: "options", isHidden: ["hidden", "isHidden"] }, outputs: { changeEvent: "change" }, host: { listeners: { "document:click": "onClick($event)", "keydown": "handleKeyDown($event)" }, properties: { "style.display": "this.hidden" } }, providers: [
|
|
495
|
-
{
|
|
496
|
-
provide: NG_VALUE_ACCESSOR,
|
|
497
|
-
useExisting: forwardRef(() => AeSelectComponent),
|
|
498
|
-
multi: true,
|
|
499
|
-
}
|
|
500
|
-
], viewQueries: [{ propertyName: "labelButton", first: true, predicate: ["labelButton"], descendants: true, static: true }], ngImport: i0, template: "<span class=\"ae-picker\" [ngClass]=\"{'ae-expanded':isOpen}\">\n <button [tabIndex]=\"-1\" #labelButton tabindex=\"-1\" type=\"button\" role=\"button\" class=\"ae-picker-label\" (click)=\"toggleOpen($event);\">{{label}}\n <svg>\n <use [attr.href]=\"'assets/ae-icons/icons.svg#sort'\" [attr.xlink:href]=\"'assets/ae-icons/icons.svg#sort'\"></use>\n </svg>\n </button>\n <span class=\"ae-picker-options\">\n <button tabindex=\"-1\" type=\"button\" role=\"button\" class=\"ae-picker-item\"\n *ngFor=\"let item of options; let i = index\"\n [ngClass]=\"{'selected': item.value === value, 'focused': i === optionId}\"\n (click)=\"optionSelect(item, $event)\">\n {{item.label}}\n </button>\n <span class=\"dropdown-item\" *ngIf=\"!options.length\">No items for select</span>\n </span>\n</span>\n", styles: ["a{cursor:pointer}svg{width:100%;height:100%}.ae-picker{color:var(--ae-picker-color, #444);display:inline-block;float:left;width:100%;position:relative;vertical-align:middle}.ae-picker-label{cursor:pointer;display:inline-block;padding-left:8px;padding-right:10px;position:relative;width:100%;line-height:1.8rem;vertical-align:middle;font-size:85%;text-align:left;background-color:var(--ae-picker-label-color, white);min-width:2rem;float:left;border:1px solid #ddd;border-radius:var(--ae-button-radius, 4px);text-overflow:clip;overflow:hidden;white-space:nowrap;height:2rem}.ae-picker-label:before{content:\"\";position:absolute;right:0;top:0;width:20px;height:100%;background:linear-gradient(to right,var(--ae-picker-label-color, white),var(--ae-picker-label-color, white) 100%)}.ae-picker-label:focus{outline:none}.ae-picker-label:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.ae-picker-label:hover:before{background:linear-gradient(to right,#f5f5f5 100%,#ffffff 100%)}.ae-picker-label:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.ae-picker-label:disabled:before{background:linear-gradient(to right,#f5f5f5 100%,#ffffff 100%)}.ae-picker-label svg{position:absolute;right:0;width:1rem}.ae-picker-label svg:not(:root){overflow:hidden}.ae-picker-label svg .ae-stroke{fill:none;stroke:#444;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.ae-picker-options{background-color:var(--ae-picker-option-bg-color, #fff);display:none;min-width:100%;position:absolute;white-space:nowrap;z-index:3;border:1px solid transparent;box-shadow:#0003 0 2px 8px}.ae-picker-options .ae-picker-item{cursor:pointer;display:block;padding-bottom:5px;padding-top:5px;padding-left:5px;z-index:3;text-align:left;background-color:transparent;min-width:2rem;width:100%;border:0 solid #ddd}.ae-picker-options .ae-picker-item.selected{color:#06c;background-color:var(--ae-picker-option-active-bg-color, #fff4c2)}.ae-picker-options .ae-picker-item.focused{background-color:var(--ae-picker-option-focused-bg-color, #fbf9b0)}.ae-picker-options .ae-picker-item:hover{background-color:var(--ae-picker-option-hover-bg-color, #fffa98)}.ae-expanded{display:block;margin-top:-1px;z-index:1}.ae-expanded .ae-picker-label{color:#ccc;z-index:2}.ae-expanded .ae-picker-label svg{color:#ccc;z-index:2}.ae-expanded .ae-picker-label svg .ae-stroke{stroke:#ccc}.ae-expanded .ae-picker-options{display:flex;flex-direction:column;margin-top:-1px;top:100%;z-index:3;border-color:#ccc}\n"], directives: [{ type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
501
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeSelectComponent, decorators: [{
|
|
502
|
-
type: Component,
|
|
503
|
-
args: [{ selector: 'ae-select', providers: [
|
|
504
|
-
{
|
|
505
|
-
provide: NG_VALUE_ACCESSOR,
|
|
506
|
-
useExisting: forwardRef(() => AeSelectComponent),
|
|
507
|
-
multi: true,
|
|
508
|
-
}
|
|
509
|
-
], template: "<span class=\"ae-picker\" [ngClass]=\"{'ae-expanded':isOpen}\">\n <button [tabIndex]=\"-1\" #labelButton tabindex=\"-1\" type=\"button\" role=\"button\" class=\"ae-picker-label\" (click)=\"toggleOpen($event);\">{{label}}\n <svg>\n <use [attr.href]=\"'assets/ae-icons/icons.svg#sort'\" [attr.xlink:href]=\"'assets/ae-icons/icons.svg#sort'\"></use>\n </svg>\n </button>\n <span class=\"ae-picker-options\">\n <button tabindex=\"-1\" type=\"button\" role=\"button\" class=\"ae-picker-item\"\n *ngFor=\"let item of options; let i = index\"\n [ngClass]=\"{'selected': item.value === value, 'focused': i === optionId}\"\n (click)=\"optionSelect(item, $event)\">\n {{item.label}}\n </button>\n <span class=\"dropdown-item\" *ngIf=\"!options.length\">No items for select</span>\n </span>\n</span>\n", styles: ["a{cursor:pointer}svg{width:100%;height:100%}.ae-picker{color:var(--ae-picker-color, #444);display:inline-block;float:left;width:100%;position:relative;vertical-align:middle}.ae-picker-label{cursor:pointer;display:inline-block;padding-left:8px;padding-right:10px;position:relative;width:100%;line-height:1.8rem;vertical-align:middle;font-size:85%;text-align:left;background-color:var(--ae-picker-label-color, white);min-width:2rem;float:left;border:1px solid #ddd;border-radius:var(--ae-button-radius, 4px);text-overflow:clip;overflow:hidden;white-space:nowrap;height:2rem}.ae-picker-label:before{content:\"\";position:absolute;right:0;top:0;width:20px;height:100%;background:linear-gradient(to right,var(--ae-picker-label-color, white),var(--ae-picker-label-color, white) 100%)}.ae-picker-label:focus{outline:none}.ae-picker-label:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.ae-picker-label:hover:before{background:linear-gradient(to right,#f5f5f5 100%,#ffffff 100%)}.ae-picker-label:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.ae-picker-label:disabled:before{background:linear-gradient(to right,#f5f5f5 100%,#ffffff 100%)}.ae-picker-label svg{position:absolute;right:0;width:1rem}.ae-picker-label svg:not(:root){overflow:hidden}.ae-picker-label svg .ae-stroke{fill:none;stroke:#444;stroke-linecap:round;stroke-linejoin:round;stroke-width:2}.ae-picker-options{background-color:var(--ae-picker-option-bg-color, #fff);display:none;min-width:100%;position:absolute;white-space:nowrap;z-index:3;border:1px solid transparent;box-shadow:#0003 0 2px 8px}.ae-picker-options .ae-picker-item{cursor:pointer;display:block;padding-bottom:5px;padding-top:5px;padding-left:5px;z-index:3;text-align:left;background-color:transparent;min-width:2rem;width:100%;border:0 solid #ddd}.ae-picker-options .ae-picker-item.selected{color:#06c;background-color:var(--ae-picker-option-active-bg-color, #fff4c2)}.ae-picker-options .ae-picker-item.focused{background-color:var(--ae-picker-option-focused-bg-color, #fbf9b0)}.ae-picker-options .ae-picker-item:hover{background-color:var(--ae-picker-option-hover-bg-color, #fffa98)}.ae-expanded{display:block;margin-top:-1px;z-index:1}.ae-expanded .ae-picker-label{color:#ccc;z-index:2}.ae-expanded .ae-picker-label svg{color:#ccc;z-index:2}.ae-expanded .ae-picker-label svg .ae-stroke{stroke:#ccc}.ae-expanded .ae-picker-options{display:flex;flex-direction:column;margin-top:-1px;top:100%;z-index:3;border-color:#ccc}\n"] }]
|
|
510
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.Renderer2 }]; }, propDecorators: { options: [{
|
|
511
|
-
type: Input
|
|
512
|
-
}], isHidden: [{
|
|
513
|
-
type: Input,
|
|
514
|
-
args: ['hidden']
|
|
515
|
-
}], hidden: [{
|
|
516
|
-
type: HostBinding,
|
|
517
|
-
args: ['style.display']
|
|
518
|
-
}], changeEvent: [{
|
|
519
|
-
type: Output,
|
|
520
|
-
args: ['change']
|
|
521
|
-
}], labelButton: [{
|
|
522
|
-
type: ViewChild,
|
|
523
|
-
args: ['labelButton', { static: true }]
|
|
524
|
-
}], onClick: [{
|
|
525
|
-
type: HostListener,
|
|
526
|
-
args: ['document:click', ['$event']]
|
|
527
|
-
}], handleKeyDown: [{
|
|
528
|
-
type: HostListener,
|
|
529
|
-
args: ['keydown', ['$event']]
|
|
530
|
-
}] } });
|
|
531
|
-
|
|
532
|
-
class AeToolbarComponent {
|
|
533
|
-
constructor(r, editorService, er, doc) {
|
|
534
|
-
this.r = r;
|
|
535
|
-
this.editorService = editorService;
|
|
536
|
-
this.er = er;
|
|
537
|
-
this.doc = doc;
|
|
538
|
-
this.htmlMode = false;
|
|
539
|
-
this.linkSelected = false;
|
|
540
|
-
this.block = 'default';
|
|
541
|
-
this.fontName = 'Times New Roman';
|
|
542
|
-
this.fontSize = '3';
|
|
543
|
-
this.headings = [
|
|
544
|
-
{
|
|
545
|
-
label: 'Heading 1',
|
|
546
|
-
value: 'h1',
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
label: 'Heading 2',
|
|
550
|
-
value: 'h2',
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
label: 'Heading 3',
|
|
554
|
-
value: 'h3',
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
label: 'Heading 4',
|
|
558
|
-
value: 'h4',
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
label: 'Heading 5',
|
|
562
|
-
value: 'h5',
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
label: 'Heading 6',
|
|
566
|
-
value: 'h6',
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
label: 'Heading 7',
|
|
570
|
-
value: 'h7',
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
label: 'Paragraph',
|
|
574
|
-
value: 'p',
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
label: 'Predefined',
|
|
578
|
-
value: 'pre'
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
label: 'Standard',
|
|
582
|
-
value: 'div'
|
|
583
|
-
},
|
|
584
|
-
{
|
|
585
|
-
label: 'default',
|
|
586
|
-
value: 'default'
|
|
587
|
-
}
|
|
588
|
-
];
|
|
589
|
-
this.fontSizes = [
|
|
590
|
-
{
|
|
591
|
-
label: '1',
|
|
592
|
-
value: '1',
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
label: '2',
|
|
596
|
-
value: '2',
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
label: '3',
|
|
600
|
-
value: '3',
|
|
601
|
-
},
|
|
602
|
-
{
|
|
603
|
-
label: '4',
|
|
604
|
-
value: '4',
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
label: '5',
|
|
608
|
-
value: '5',
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
label: '6',
|
|
612
|
-
value: '6',
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
label: '7',
|
|
616
|
-
value: '7',
|
|
617
|
-
}
|
|
618
|
-
];
|
|
619
|
-
this.customClassId = '-1';
|
|
620
|
-
this.customClassList = [{ label: '', value: '' }];
|
|
621
|
-
// uploadUrl: string;
|
|
622
|
-
this.tagMap = {
|
|
623
|
-
BLOCKQUOTE: 'indent',
|
|
624
|
-
A: 'link'
|
|
625
|
-
};
|
|
626
|
-
this.select = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'P', 'PRE', 'DIV'];
|
|
627
|
-
this.buttons = ['bold', 'italic', 'underline', 'strikeThrough', 'subscript', 'superscript', 'justifyLeft', 'justifyCenter',
|
|
628
|
-
'justifyRight', 'justifyFull', 'indent', 'outdent', 'insertUnorderedList', 'insertOrderedList', 'link'];
|
|
629
|
-
this.fonts = [{ label: '', value: '' }];
|
|
630
|
-
this.execute = new EventEmitter();
|
|
631
|
-
}
|
|
632
|
-
set customClasses(classes) {
|
|
633
|
-
if (classes) {
|
|
634
|
-
this._customClasses = classes;
|
|
635
|
-
this.customClassList = this._customClasses.map((x, i) => ({ label: x.name, value: i.toString() }));
|
|
636
|
-
this.customClassList.unshift({ label: 'Clear Class', value: '-1' });
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
set defaultFontName(value) {
|
|
640
|
-
if (value) {
|
|
641
|
-
this.fontName = value;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
set defaultFontSize(value) {
|
|
645
|
-
if (value) {
|
|
646
|
-
this.fontSize = value;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
get isLinkButtonDisabled() {
|
|
650
|
-
return this.htmlMode || !Boolean(this.editorService.selectedText);
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Trigger command from editor header buttons
|
|
654
|
-
* @param command string from toolbar buttons
|
|
655
|
-
*/
|
|
656
|
-
triggerCommand(command) {
|
|
657
|
-
this.execute.emit(command);
|
|
658
|
-
}
|
|
659
|
-
/**
|
|
660
|
-
* highlight editor buttons when cursor moved or positioning
|
|
661
|
-
*/
|
|
662
|
-
triggerButtons() {
|
|
663
|
-
if (!this.showToolbar) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
this.buttons.forEach(e => {
|
|
667
|
-
const result = this.doc.queryCommandState(e);
|
|
668
|
-
const elementById = this.doc.getElementById(e + '-' + this.id);
|
|
669
|
-
if (result) {
|
|
670
|
-
this.r.addClass(elementById, 'active');
|
|
671
|
-
}
|
|
672
|
-
else {
|
|
673
|
-
this.r.removeClass(elementById, 'active');
|
|
674
|
-
}
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* trigger highlight editor buttons when cursor moved or positioning in block
|
|
679
|
-
*/
|
|
680
|
-
triggerBlocks(nodes) {
|
|
681
|
-
if (!this.showToolbar) {
|
|
682
|
-
return;
|
|
683
|
-
}
|
|
684
|
-
this.linkSelected = nodes.findIndex(x => x.nodeName === 'A') > -1;
|
|
685
|
-
let found = false;
|
|
686
|
-
this.select.forEach(y => {
|
|
687
|
-
const node = nodes.find(x => x.nodeName === y);
|
|
688
|
-
if (node !== undefined && y === node.nodeName) {
|
|
689
|
-
if (found === false) {
|
|
690
|
-
this.block = node.nodeName.toLowerCase();
|
|
691
|
-
found = true;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
else if (found === false) {
|
|
695
|
-
this.block = 'default';
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
found = false;
|
|
699
|
-
if (this._customClasses) {
|
|
700
|
-
this._customClasses.forEach((y, index) => {
|
|
701
|
-
const node = nodes.find(x => {
|
|
702
|
-
if (x instanceof Element) {
|
|
703
|
-
return x.className === y.class;
|
|
704
|
-
}
|
|
705
|
-
});
|
|
706
|
-
if (node !== undefined) {
|
|
707
|
-
if (found === false) {
|
|
708
|
-
this.customClassId = index.toString();
|
|
709
|
-
found = true;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
else if (found === false) {
|
|
713
|
-
this.customClassId = '-1';
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
Object.keys(this.tagMap).map(e => {
|
|
718
|
-
const elementById = this.doc.getElementById(this.tagMap[e] + '-' + this.id);
|
|
719
|
-
const node = nodes.find(x => x.nodeName === e);
|
|
720
|
-
if (node !== undefined && e === node.nodeName) {
|
|
721
|
-
this.r.addClass(elementById, 'active');
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
this.r.removeClass(elementById, 'active');
|
|
725
|
-
}
|
|
726
|
-
});
|
|
727
|
-
this.foreColour = this.doc.queryCommandValue('ForeColor');
|
|
728
|
-
this.fontSize = this.doc.queryCommandValue('FontSize');
|
|
729
|
-
this.fontName = this.doc.queryCommandValue('FontName').replace(/"/g, '');
|
|
730
|
-
this.backColor = this.doc.queryCommandValue('backColor');
|
|
731
|
-
}
|
|
732
|
-
/**
|
|
733
|
-
* insert URL link
|
|
734
|
-
*/
|
|
735
|
-
insertUrl() {
|
|
736
|
-
let url = 'https:\/\/';
|
|
737
|
-
const selection = this.editorService.savedSelection;
|
|
738
|
-
if (selection && selection.commonAncestorContainer.parentElement.nodeName === 'A') {
|
|
739
|
-
const parent = selection.commonAncestorContainer.parentElement;
|
|
740
|
-
if (parent.href !== '') {
|
|
741
|
-
url = parent.href;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
url = prompt('Insert URL link', url);
|
|
745
|
-
if (url && url !== '' && url !== 'https://') {
|
|
746
|
-
this.editorService.createLink(url);
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* insert Video link
|
|
751
|
-
*/
|
|
752
|
-
insertVideo() {
|
|
753
|
-
this.execute.emit('');
|
|
754
|
-
const url = prompt('Insert Video link', `https://`);
|
|
755
|
-
if (url && url !== '' && url !== `https://`) {
|
|
756
|
-
this.editorService.insertVideo(url);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
/** insert color */
|
|
760
|
-
insertColor(color, where) {
|
|
761
|
-
this.editorService.insertColor(color, where);
|
|
762
|
-
this.execute.emit('');
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* set font Name/family
|
|
766
|
-
* @param foreColor string
|
|
767
|
-
*/
|
|
768
|
-
setFontName(foreColor) {
|
|
769
|
-
this.editorService.setFontName(foreColor);
|
|
770
|
-
this.execute.emit('');
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* set font Size
|
|
774
|
-
* @param fontSize string
|
|
775
|
-
*/
|
|
776
|
-
setFontSize(fontSize) {
|
|
777
|
-
this.editorService.setFontSize(fontSize);
|
|
778
|
-
this.execute.emit('');
|
|
779
|
-
}
|
|
780
|
-
/**
|
|
781
|
-
* toggle editor mode (WYSIWYG or SOURCE)
|
|
782
|
-
* @param m boolean
|
|
783
|
-
*/
|
|
784
|
-
setEditorMode(m) {
|
|
785
|
-
const toggleEditorModeButton = this.doc.getElementById('toggleEditorMode' + '-' + this.id);
|
|
786
|
-
if (m) {
|
|
787
|
-
this.r.addClass(toggleEditorModeButton, 'active');
|
|
788
|
-
}
|
|
789
|
-
else {
|
|
790
|
-
this.r.removeClass(toggleEditorModeButton, 'active');
|
|
791
|
-
}
|
|
792
|
-
this.htmlMode = m;
|
|
793
|
-
}
|
|
794
|
-
/**
|
|
795
|
-
* Upload image when file is selected.
|
|
796
|
-
*/
|
|
797
|
-
onFileChanged(event) {
|
|
798
|
-
const file = event.target.files[0];
|
|
799
|
-
if (file.type.includes('image/')) {
|
|
800
|
-
if (this.upload) {
|
|
801
|
-
this.upload(file).subscribe((response) => this.watchUploadImage(response, event));
|
|
802
|
-
}
|
|
803
|
-
else if (this.uploadUrl) {
|
|
804
|
-
this.editorService.uploadImage(file).subscribe((response) => this.watchUploadImage(response, event));
|
|
805
|
-
}
|
|
806
|
-
else {
|
|
807
|
-
const reader = new FileReader();
|
|
808
|
-
reader.onload = (e) => {
|
|
809
|
-
const fr = e.currentTarget;
|
|
810
|
-
this.editorService.insertImage(fr.result.toString());
|
|
811
|
-
};
|
|
812
|
-
reader.readAsDataURL(file);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
watchUploadImage(response, event) {
|
|
817
|
-
const { imageUrl } = response.body;
|
|
818
|
-
this.editorService.insertImage(imageUrl);
|
|
819
|
-
event.srcElement.value = null;
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Set custom class
|
|
823
|
-
*/
|
|
824
|
-
setCustomClass(classId) {
|
|
825
|
-
if (classId === '-1') {
|
|
826
|
-
this.execute.emit('clear');
|
|
827
|
-
}
|
|
828
|
-
else {
|
|
829
|
-
this.editorService.createCustomClass(this._customClasses[+classId]);
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
isButtonHidden(name) {
|
|
833
|
-
if (!name) {
|
|
834
|
-
return false;
|
|
835
|
-
}
|
|
836
|
-
if (!(this.hiddenButtons instanceof Array)) {
|
|
837
|
-
return false;
|
|
838
|
-
}
|
|
839
|
-
let result;
|
|
840
|
-
for (const arr of this.hiddenButtons) {
|
|
841
|
-
if (arr instanceof Array) {
|
|
842
|
-
result = arr.find(item => item === name);
|
|
843
|
-
}
|
|
844
|
-
if (result) {
|
|
845
|
-
break;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
return result !== undefined;
|
|
849
|
-
}
|
|
850
|
-
focus() {
|
|
851
|
-
this.execute.emit('focus');
|
|
852
|
-
console.log('focused');
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
AeToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeToolbarComponent, deps: [{ token: i0.Renderer2 }, { token: AngularEditorService }, { token: i0.ElementRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
|
|
856
|
-
AeToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: AeToolbarComponent, selector: "angular-editor-toolbar, ae-toolbar, div[aeToolbar]", inputs: { id: "id", uploadUrl: "uploadUrl", upload: "upload", showToolbar: "showToolbar", fonts: "fonts", customClasses: "customClasses", defaultFontName: "defaultFontName", defaultFontSize: "defaultFontSize", hiddenButtons: "hiddenButtons" }, outputs: { execute: "execute" }, viewQueries: [{ propertyName: "myInputFile", first: true, predicate: ["fileInput"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"angular-editor-toolbar\" *ngIf=\"showToolbar\">\n <div aeToolbarSet>\n <button aeButton title=\"Undo\" iconName=\"undo\" (click)=\"triggerCommand('undo')\" [hidden]=\"isButtonHidden('undo')\">\n </button>\n <button aeButton title=\"Redo\" iconName=\"redo\" (click)=\"triggerCommand('redo')\"\n [hidden]=\"isButtonHidden('redo')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'bold-'+id\" aeButton title=\"Bold\" iconName=\"bold\" (click)=\"triggerCommand('bold')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('bold')\">\n </button>\n <button [id]=\"'italic-'+id\" aeButton iconName=\"italic\" title=\"Italic\" (click)=\"triggerCommand('italic')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('italic')\">\n </button>\n <button [id]=\"'underline-'+id\" aeButton title=\"Underline\" iconName=\"underline\"\n (click)=\"triggerCommand('underline')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('underline')\">\n </button>\n <button [id]=\"'strikeThrough-'+id\" aeButton iconName=\"strikeThrough\" title=\"Strikethrough\"\n (click)=\"triggerCommand('strikeThrough')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('strikeThrough')\">\n </button>\n <button [id]=\"'subscript-'+id\" aeButton title=\"Subscript\" iconName=\"subscript\"\n (click)=\"triggerCommand('subscript')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('subscript')\">\n </button>\n <button [id]=\"'superscript-'+id\" aeButton iconName=\"superscript\" title=\"Superscript\"\n (click)=\"triggerCommand('superscript')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('superscript')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'justifyLeft-'+id\" aeButton iconName=\"justifyLeft\" title=\"Justify Left\"\n (click)=\"triggerCommand('justifyLeft')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyLeft')\">\n </button>\n <button [id]=\"'justifyCenter-'+id\" aeButton iconName=\"justifyCenter\" title=\"Justify Center\"\n (click)=\"triggerCommand('justifyCenter')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyCenter')\">\n </button>\n <button [id]=\"'justifyRight-'+id\" aeButton iconName=\"justifyRight\" title=\"Justify Right\"\n (click)=\"triggerCommand('justifyRight')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyRight')\">\n </button>\n <button [id]=\"'justifyFull-'+id\" aeButton iconName=\"justifyFull\" title=\"Justify Full\"\n (click)=\"triggerCommand('justifyFull')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyFull')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'indent-'+id\" aeButton iconName=\"indent\" title=\"Indent\"\n (click)=\"triggerCommand('indent')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('indent')\">\n </button>\n <button [id]=\"'outdent-'+id\" aeButton iconName=\"outdent\" title=\"Outdent\"\n (click)=\"triggerCommand('outdent')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('outdent')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'insertUnorderedList-'+id\" aeButton iconName=\"unorderedList\" title=\"Unordered List\"\n (click)=\"triggerCommand('insertUnorderedList')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertUnorderedList')\">\n </button>\n <button [id]=\"'insertOrderedList-'+id\" aeButton iconName=\"orderedList\" title=\"Ordered List\"\n (click)=\"triggerCommand('insertOrderedList')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertOrderedList')\">\n </button>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-heading\" [options]=\"headings\"\n [(ngModel)]=\"block\"\n (change)=\"triggerCommand(block)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('heading')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-font\" [options]=\"fonts\"\n [(ngModel)]=\"fontName\"\n (change)=\"setFontName(fontName)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('fontName')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-font-size\" [options]=\"fontSizes\"\n [(ngModel)]=\"fontSize\"\n (change)=\"setFontSize(fontSize)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('fontSize')\"\n tabindex=\"-1\">\n </ae-select>\n </div>\n <div aeToolbarSet>\n <input\n style=\"display: none\"\n type=\"color\" (change)=\"insertColor(fgInput.value, 'textColor')\"\n #fgInput>\n <button [id]=\"'foregroundColorPicker-'+id\" aeButton iconName=\"textColor\"\n (click)=\"focus(); ; fgInput.click()\"\n title=\"Text Color\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('textColor')\">\n </button>\n <input\n style=\"display: none\"\n type=\"color\" (change)=\"insertColor(bgInput.value, 'backgroundColor')\"\n #bgInput>\n <button [id]=\"'backgroundColorPicker-'+id\" aeButton iconName=\"backgroundColor\"\n (click)=\"focus(); ; bgInput.click()\"\n title=\"Background Color\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('backgroundColor')\">\n </button>\n </div>\n <div *ngIf=\"_customClasses\" aeToolbarSet>\n <ae-select class=\"select-custom-style\" [options]=\"customClassList\"\n [(ngModel)]=\"customClassId\"\n (change)=\"setCustomClass(customClassId)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('customClasses')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'link-'+id\" aeButton iconName=\"link\" (click)=\"insertUrl()\"\n title=\"Insert Link\" [disabled]=\"isLinkButtonDisabled\" [hidden]=\"isButtonHidden('link')\">\n </button>\n <button [id]=\"'unlink-'+id\" aeButton iconName=\"unlink\" (click)=\"triggerCommand('unlink')\"\n title=\"Unlink\" [disabled]=\"htmlMode || !linkSelected\" [hidden]=\"isButtonHidden('unlink')\">\n </button>\n <input\n style=\"display: none\"\n accept=\"image/*\"\n type=\"file\" (change)=\"onFileChanged($event)\"\n #fileInput>\n <button [id]=\"'insertImage-'+id\" aeButton iconName=\"image\" (click)=\"focus(); fileInput.click()\"\n title=\"Insert Image\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('insertImage')\">\n </button>\n <button [id]=\"'insertVideo-'+id\" aeButton iconName=\"video\"\n (click)=\"insertVideo()\" title=\"Insert Video\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertVideo')\">\n </button>\n <button [id]=\"'insertHorizontalRule-'+id\" aeButton iconName=\"horizontalLine\" title=\"Horizontal Line\"\n (click)=\"triggerCommand('insertHorizontalRule')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertHorizontalRule')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'clearFormatting-'+id\" aeButton iconName=\"removeFormat\" title=\"Clear Formatting\"\n class=\"angular-editor-button\"\n (click)=\"triggerCommand('removeFormat')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('removeFormat')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'toggleEditorMode-'+id\" aeButton iconName=\"htmlCode\" title=\"HTML Code\"\n (click)=\"triggerCommand('toggleEditorMode')\" [hidden]=\"isButtonHidden('toggleEditorMode')\">\n </button>\n </div>\n <ng-content></ng-content>\n</div>\n", styles: ["a{cursor:pointer}.angular-editor-toolbar{font:100 14px/15px Roboto,Arial,sans-serif;background-color:var(--ae-toolbar-bg-color, #f5f5f5);font-size:.8rem;padding:var(--ae-toolbar-padding, .2rem);border:var(--ae-toolbar-border-radius, 1px solid #ddd);display:flex;flex-wrap:wrap;gap:4px}.select-heading{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-heading optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-heading option{border:1px solid;background-color:#fff}.select-heading .default{font-size:16px}.select-heading .h1{font-size:24px}.select-heading .h2{font-size:20px}.select-heading .h3{font-size:16px}.select-heading .h4{font-size:15px}.select-heading .h5{font-size:14px}.select-heading .h6{font-size:13px}.select-heading .div,.select-heading .pre{font-size:12px}}.select-heading:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-heading:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-font{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-font optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-font option{border:1px solid;background-color:#fff}}.select-font:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-font:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-font-size{display:inline-block;width:50px}@supports not (-moz-appearance: none){.select-font-size optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-font-size option{border:1px solid;background-color:#fff}.select-font-size .size1{font-size:10px}.select-font-size .size2{font-size:12px}.select-font-size .size3{font-size:14px}.select-font-size .size4{font-size:16px}.select-font-size .size5{font-size:18px}.select-font-size .size6{font-size:20px}.select-font-size .size7{font-size:22px}}.select-font-size:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-font-size:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-custom-style{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-custom-style optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-custom-style option{border:1px solid;background-color:#fff}}.select-custom-style:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-custom-style:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.color-label{position:relative;cursor:pointer}.background{font-size:smaller;background:#1b1b1b;color:#fff;padding:3px}.foreground :after{position:absolute;content:\"\";inset:auto auto -3px -1px;width:15px;height:2px;z-index:0;background:#1b1b1b}\n"], components: [{ type: AeToolbarSetComponent, selector: "ae-toolbar-set, [aeToolbarSet]" }, { type: AeButtonComponent, selector: "ae-button, button[aeButton]", inputs: ["iconName"] }, { type: AeSelectComponent, selector: "ae-select", inputs: ["options", "hidden"], outputs: ["change"] }], directives: [{ type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
|
|
857
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AeToolbarComponent, decorators: [{
|
|
858
|
-
type: Component,
|
|
859
|
-
args: [{ selector: 'angular-editor-toolbar, ae-toolbar, div[aeToolbar]', template: "<div class=\"angular-editor-toolbar\" *ngIf=\"showToolbar\">\n <div aeToolbarSet>\n <button aeButton title=\"Undo\" iconName=\"undo\" (click)=\"triggerCommand('undo')\" [hidden]=\"isButtonHidden('undo')\">\n </button>\n <button aeButton title=\"Redo\" iconName=\"redo\" (click)=\"triggerCommand('redo')\"\n [hidden]=\"isButtonHidden('redo')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'bold-'+id\" aeButton title=\"Bold\" iconName=\"bold\" (click)=\"triggerCommand('bold')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('bold')\">\n </button>\n <button [id]=\"'italic-'+id\" aeButton iconName=\"italic\" title=\"Italic\" (click)=\"triggerCommand('italic')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('italic')\">\n </button>\n <button [id]=\"'underline-'+id\" aeButton title=\"Underline\" iconName=\"underline\"\n (click)=\"triggerCommand('underline')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('underline')\">\n </button>\n <button [id]=\"'strikeThrough-'+id\" aeButton iconName=\"strikeThrough\" title=\"Strikethrough\"\n (click)=\"triggerCommand('strikeThrough')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('strikeThrough')\">\n </button>\n <button [id]=\"'subscript-'+id\" aeButton title=\"Subscript\" iconName=\"subscript\"\n (click)=\"triggerCommand('subscript')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('subscript')\">\n </button>\n <button [id]=\"'superscript-'+id\" aeButton iconName=\"superscript\" title=\"Superscript\"\n (click)=\"triggerCommand('superscript')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('superscript')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'justifyLeft-'+id\" aeButton iconName=\"justifyLeft\" title=\"Justify Left\"\n (click)=\"triggerCommand('justifyLeft')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyLeft')\">\n </button>\n <button [id]=\"'justifyCenter-'+id\" aeButton iconName=\"justifyCenter\" title=\"Justify Center\"\n (click)=\"triggerCommand('justifyCenter')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyCenter')\">\n </button>\n <button [id]=\"'justifyRight-'+id\" aeButton iconName=\"justifyRight\" title=\"Justify Right\"\n (click)=\"triggerCommand('justifyRight')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyRight')\">\n </button>\n <button [id]=\"'justifyFull-'+id\" aeButton iconName=\"justifyFull\" title=\"Justify Full\"\n (click)=\"triggerCommand('justifyFull')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('justifyFull')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'indent-'+id\" aeButton iconName=\"indent\" title=\"Indent\"\n (click)=\"triggerCommand('indent')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('indent')\">\n </button>\n <button [id]=\"'outdent-'+id\" aeButton iconName=\"outdent\" title=\"Outdent\"\n (click)=\"triggerCommand('outdent')\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('outdent')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'insertUnorderedList-'+id\" aeButton iconName=\"unorderedList\" title=\"Unordered List\"\n (click)=\"triggerCommand('insertUnorderedList')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertUnorderedList')\">\n </button>\n <button [id]=\"'insertOrderedList-'+id\" aeButton iconName=\"orderedList\" title=\"Ordered List\"\n (click)=\"triggerCommand('insertOrderedList')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertOrderedList')\">\n </button>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-heading\" [options]=\"headings\"\n [(ngModel)]=\"block\"\n (change)=\"triggerCommand(block)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('heading')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-font\" [options]=\"fonts\"\n [(ngModel)]=\"fontName\"\n (change)=\"setFontName(fontName)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('fontName')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <ae-select class=\"select-font-size\" [options]=\"fontSizes\"\n [(ngModel)]=\"fontSize\"\n (change)=\"setFontSize(fontSize)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('fontSize')\"\n tabindex=\"-1\">\n </ae-select>\n </div>\n <div aeToolbarSet>\n <input\n style=\"display: none\"\n type=\"color\" (change)=\"insertColor(fgInput.value, 'textColor')\"\n #fgInput>\n <button [id]=\"'foregroundColorPicker-'+id\" aeButton iconName=\"textColor\"\n (click)=\"focus(); ; fgInput.click()\"\n title=\"Text Color\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('textColor')\">\n </button>\n <input\n style=\"display: none\"\n type=\"color\" (change)=\"insertColor(bgInput.value, 'backgroundColor')\"\n #bgInput>\n <button [id]=\"'backgroundColorPicker-'+id\" aeButton iconName=\"backgroundColor\"\n (click)=\"focus(); ; bgInput.click()\"\n title=\"Background Color\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('backgroundColor')\">\n </button>\n </div>\n <div *ngIf=\"_customClasses\" aeToolbarSet>\n <ae-select class=\"select-custom-style\" [options]=\"customClassList\"\n [(ngModel)]=\"customClassId\"\n (change)=\"setCustomClass(customClassId)\"\n [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('customClasses')\"\n tabindex=\"-1\"></ae-select>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'link-'+id\" aeButton iconName=\"link\" (click)=\"insertUrl()\"\n title=\"Insert Link\" [disabled]=\"isLinkButtonDisabled\" [hidden]=\"isButtonHidden('link')\">\n </button>\n <button [id]=\"'unlink-'+id\" aeButton iconName=\"unlink\" (click)=\"triggerCommand('unlink')\"\n title=\"Unlink\" [disabled]=\"htmlMode || !linkSelected\" [hidden]=\"isButtonHidden('unlink')\">\n </button>\n <input\n style=\"display: none\"\n accept=\"image/*\"\n type=\"file\" (change)=\"onFileChanged($event)\"\n #fileInput>\n <button [id]=\"'insertImage-'+id\" aeButton iconName=\"image\" (click)=\"focus(); fileInput.click()\"\n title=\"Insert Image\"\n [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('insertImage')\">\n </button>\n <button [id]=\"'insertVideo-'+id\" aeButton iconName=\"video\"\n (click)=\"insertVideo()\" title=\"Insert Video\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertVideo')\">\n </button>\n <button [id]=\"'insertHorizontalRule-'+id\" aeButton iconName=\"horizontalLine\" title=\"Horizontal Line\"\n (click)=\"triggerCommand('insertHorizontalRule')\" [disabled]=\"htmlMode\"\n [hidden]=\"isButtonHidden('insertHorizontalRule')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'clearFormatting-'+id\" aeButton iconName=\"removeFormat\" title=\"Clear Formatting\"\n class=\"angular-editor-button\"\n (click)=\"triggerCommand('removeFormat')\" [disabled]=\"htmlMode\" [hidden]=\"isButtonHidden('removeFormat')\">\n </button>\n </div>\n <div aeToolbarSet>\n <button [id]=\"'toggleEditorMode-'+id\" aeButton iconName=\"htmlCode\" title=\"HTML Code\"\n (click)=\"triggerCommand('toggleEditorMode')\" [hidden]=\"isButtonHidden('toggleEditorMode')\">\n </button>\n </div>\n <ng-content></ng-content>\n</div>\n", styles: ["a{cursor:pointer}.angular-editor-toolbar{font:100 14px/15px Roboto,Arial,sans-serif;background-color:var(--ae-toolbar-bg-color, #f5f5f5);font-size:.8rem;padding:var(--ae-toolbar-padding, .2rem);border:var(--ae-toolbar-border-radius, 1px solid #ddd);display:flex;flex-wrap:wrap;gap:4px}.select-heading{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-heading optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-heading option{border:1px solid;background-color:#fff}.select-heading .default{font-size:16px}.select-heading .h1{font-size:24px}.select-heading .h2{font-size:20px}.select-heading .h3{font-size:16px}.select-heading .h4{font-size:15px}.select-heading .h5{font-size:14px}.select-heading .h6{font-size:13px}.select-heading .div,.select-heading .pre{font-size:12px}}.select-heading:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-heading:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-font{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-font optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-font option{border:1px solid;background-color:#fff}}.select-font:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-font:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-font-size{display:inline-block;width:50px}@supports not (-moz-appearance: none){.select-font-size optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-font-size option{border:1px solid;background-color:#fff}.select-font-size .size1{font-size:10px}.select-font-size .size2{font-size:12px}.select-font-size .size3{font-size:14px}.select-font-size .size4{font-size:16px}.select-font-size .size5{font-size:18px}.select-font-size .size6{font-size:20px}.select-font-size .size7{font-size:22px}}.select-font-size:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-font-size:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.select-custom-style{display:inline-block;width:90px}@supports not (-moz-appearance: none){.select-custom-style optgroup{font-size:12px;background-color:#f4f4f4;padding:5px}.select-custom-style option{border:1px solid;background-color:#fff}}.select-custom-style:disabled{background-color:#f5f5f5;pointer-events:none;cursor:not-allowed}.select-custom-style:hover{cursor:pointer;background-color:#f1f1f1;transition:.2s ease}.color-label{position:relative;cursor:pointer}.background{font-size:smaller;background:#1b1b1b;color:#fff;padding:3px}.foreground :after{position:absolute;content:\"\";inset:auto auto -3px -1px;width:15px;height:2px;z-index:0;background:#1b1b1b}\n"] }]
|
|
860
|
-
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: AngularEditorService }, { type: i0.ElementRef }, { type: undefined, decorators: [{
|
|
861
|
-
type: Inject,
|
|
862
|
-
args: [DOCUMENT]
|
|
863
|
-
}] }]; }, propDecorators: { id: [{
|
|
864
|
-
type: Input
|
|
865
|
-
}], uploadUrl: [{
|
|
866
|
-
type: Input
|
|
867
|
-
}], upload: [{
|
|
868
|
-
type: Input
|
|
869
|
-
}], showToolbar: [{
|
|
870
|
-
type: Input
|
|
871
|
-
}], fonts: [{
|
|
872
|
-
type: Input
|
|
873
|
-
}], customClasses: [{
|
|
874
|
-
type: Input
|
|
875
|
-
}], defaultFontName: [{
|
|
876
|
-
type: Input
|
|
877
|
-
}], defaultFontSize: [{
|
|
878
|
-
type: Input
|
|
879
|
-
}], hiddenButtons: [{
|
|
880
|
-
type: Input
|
|
881
|
-
}], execute: [{
|
|
882
|
-
type: Output
|
|
883
|
-
}], myInputFile: [{
|
|
884
|
-
type: ViewChild,
|
|
885
|
-
args: ['fileInput', { static: true }]
|
|
886
|
-
}] } });
|
|
887
|
-
|
|
888
|
-
class AngularEditorComponent {
|
|
889
|
-
constructor(r, editorService, doc, sanitizer, cdRef, defaultTabIndex, autoFocus) {
|
|
890
|
-
this.r = r;
|
|
891
|
-
this.editorService = editorService;
|
|
892
|
-
this.doc = doc;
|
|
893
|
-
this.sanitizer = sanitizer;
|
|
894
|
-
this.cdRef = cdRef;
|
|
895
|
-
this.autoFocus = autoFocus;
|
|
896
|
-
this.modeVisual = true;
|
|
897
|
-
this.showPlaceholder = false;
|
|
898
|
-
this.disabled = false;
|
|
899
|
-
this.focused = false;
|
|
900
|
-
this.touched = false;
|
|
901
|
-
this.changed = false;
|
|
902
|
-
this.id = '';
|
|
903
|
-
this.config = angularEditorConfig;
|
|
904
|
-
this.placeholder = '';
|
|
905
|
-
this.executeCommandFn = this.executeCommand.bind(this);
|
|
906
|
-
this.viewMode = new EventEmitter();
|
|
907
|
-
/** emits `blur` event when focused out from the textarea */
|
|
908
|
-
// eslint-disable-next-line @angular-eslint/no-output-native, @angular-eslint/no-output-rename
|
|
909
|
-
this.blurEvent = new EventEmitter();
|
|
910
|
-
/** emits `focus` event when focused in to the textarea */
|
|
911
|
-
// eslint-disable-next-line @angular-eslint/no-output-rename, @angular-eslint/no-output-native
|
|
912
|
-
this.focusEvent = new EventEmitter();
|
|
913
|
-
this.tabindex = -1;
|
|
914
|
-
const parsedTabIndex = Number(defaultTabIndex);
|
|
915
|
-
this.tabIndex = (parsedTabIndex || parsedTabIndex === 0) ? parsedTabIndex : null;
|
|
916
|
-
}
|
|
917
|
-
onFocus() {
|
|
918
|
-
this.focus();
|
|
919
|
-
}
|
|
920
|
-
ngOnInit() {
|
|
921
|
-
this.config.toolbarPosition = this.config.toolbarPosition ? this.config.toolbarPosition : angularEditorConfig.toolbarPosition;
|
|
922
|
-
}
|
|
923
|
-
ngAfterViewInit() {
|
|
924
|
-
if (isDefined(this.autoFocus)) {
|
|
925
|
-
this.focus();
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
onPaste(event) {
|
|
929
|
-
if (this.config.rawPaste) {
|
|
930
|
-
event.preventDefault();
|
|
931
|
-
const text = event.clipboardData.getData('text/plain');
|
|
932
|
-
document.execCommand('insertHTML', false, text);
|
|
933
|
-
return text;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* Executed command from editor header buttons
|
|
938
|
-
* @param command string from triggerCommand
|
|
939
|
-
* @param value
|
|
940
|
-
*/
|
|
941
|
-
executeCommand(command, value) {
|
|
942
|
-
this.focus();
|
|
943
|
-
if (command === 'focus') {
|
|
944
|
-
return;
|
|
945
|
-
}
|
|
946
|
-
if (command === 'toggleEditorMode') {
|
|
947
|
-
this.toggleEditorMode(this.modeVisual);
|
|
948
|
-
}
|
|
949
|
-
else if (command !== '') {
|
|
950
|
-
if (command === 'clear') {
|
|
951
|
-
this.editorService.removeSelectedElements(this.getCustomTags());
|
|
952
|
-
this.onContentChange(this.textArea.nativeElement);
|
|
953
|
-
}
|
|
954
|
-
else if (command === 'default') {
|
|
955
|
-
this.editorService.removeSelectedElements('h1,h2,h3,h4,h5,h6,p,pre');
|
|
956
|
-
this.onContentChange(this.textArea.nativeElement);
|
|
957
|
-
}
|
|
958
|
-
else {
|
|
959
|
-
this.editorService.executeCommand(command, value);
|
|
960
|
-
}
|
|
961
|
-
this.exec();
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* focus event
|
|
966
|
-
*/
|
|
967
|
-
onTextAreaFocus(event) {
|
|
968
|
-
if (this.focused) {
|
|
969
|
-
event.stopPropagation();
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
this.focused = true;
|
|
973
|
-
this.focusEvent.emit(event);
|
|
974
|
-
if (!this.touched || !this.changed) {
|
|
975
|
-
this.editorService.executeInNextQueueIteration(() => {
|
|
976
|
-
this.configure();
|
|
977
|
-
this.touched = true;
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* @description fires when cursor leaves textarea
|
|
983
|
-
*/
|
|
984
|
-
onTextAreaMouseOut(event) {
|
|
985
|
-
this.editorService.saveSelection();
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
* blur event
|
|
989
|
-
*/
|
|
990
|
-
onTextAreaBlur(event) {
|
|
991
|
-
/**
|
|
992
|
-
* save selection if focussed out
|
|
993
|
-
*/
|
|
994
|
-
this.editorService.executeInNextQueueIteration(this.editorService.saveSelection);
|
|
995
|
-
if (typeof this.onTouched === 'function') {
|
|
996
|
-
this.onTouched();
|
|
997
|
-
}
|
|
998
|
-
if (event.relatedTarget !== null) {
|
|
999
|
-
const parent = event.relatedTarget.parentElement;
|
|
1000
|
-
if (!parent.classList.contains('angular-editor-toolbar-set') && !parent.classList.contains('ae-picker')) {
|
|
1001
|
-
this.blurEvent.emit(event);
|
|
1002
|
-
this.focused = false;
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* focus the text area when the editor is focused
|
|
1008
|
-
*/
|
|
1009
|
-
focus() {
|
|
1010
|
-
if (this.modeVisual) {
|
|
1011
|
-
this.textArea.nativeElement.focus();
|
|
1012
|
-
}
|
|
1013
|
-
else {
|
|
1014
|
-
const sourceText = this.doc.getElementById('sourceText' + this.id);
|
|
1015
|
-
sourceText.focus();
|
|
1016
|
-
this.focused = true;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Executed from the contenteditable section while the input property changes
|
|
1021
|
-
* @param element html element from contenteditable
|
|
1022
|
-
*/
|
|
1023
|
-
onContentChange(element) {
|
|
1024
|
-
let html = '';
|
|
1025
|
-
if (this.modeVisual) {
|
|
1026
|
-
html = element.innerHTML;
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
html = element.innerText;
|
|
1030
|
-
}
|
|
1031
|
-
if ((!html || html === '<br>')) {
|
|
1032
|
-
html = '';
|
|
1033
|
-
}
|
|
1034
|
-
if (typeof this.onChange === 'function') {
|
|
1035
|
-
this.onChange(this.config.sanitize || this.config.sanitize === undefined ?
|
|
1036
|
-
this.sanitizer.sanitize(SecurityContext.HTML, html) : html);
|
|
1037
|
-
if ((!html) !== this.showPlaceholder) {
|
|
1038
|
-
this.togglePlaceholder(this.showPlaceholder);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
this.changed = true;
|
|
1042
|
-
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Set the function to be called
|
|
1045
|
-
* when the control receives a change event.
|
|
1046
|
-
*
|
|
1047
|
-
* @param fn a function
|
|
1048
|
-
*/
|
|
1049
|
-
registerOnChange(fn) {
|
|
1050
|
-
this.onChange = e => (e === '<br>' ? fn('') : fn(e));
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* Set the function to be called
|
|
1054
|
-
* when the control receives a touch event.
|
|
1055
|
-
*
|
|
1056
|
-
* @param fn a function
|
|
1057
|
-
*/
|
|
1058
|
-
registerOnTouched(fn) {
|
|
1059
|
-
this.onTouched = fn;
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* Write a new value to the element.
|
|
1063
|
-
*
|
|
1064
|
-
* @param value value to be executed when there is a change in contenteditable
|
|
1065
|
-
*/
|
|
1066
|
-
writeValue(value) {
|
|
1067
|
-
if ((!value || value === '<br>' || value === '') !== this.showPlaceholder) {
|
|
1068
|
-
this.togglePlaceholder(this.showPlaceholder);
|
|
1069
|
-
}
|
|
1070
|
-
if (value === undefined || value === '' || value === '<br>') {
|
|
1071
|
-
value = null;
|
|
1072
|
-
}
|
|
1073
|
-
this.refreshView(value);
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
* refresh view/HTML of the editor
|
|
1077
|
-
*
|
|
1078
|
-
* @param value html string from the editor
|
|
1079
|
-
*/
|
|
1080
|
-
refreshView(value) {
|
|
1081
|
-
const normalizedValue = value === null ? '' : value;
|
|
1082
|
-
this.r.setProperty(this.textArea.nativeElement, 'innerHTML', normalizedValue);
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* toggles placeholder based on input string
|
|
1087
|
-
*
|
|
1088
|
-
* @param value A HTML string from the editor
|
|
1089
|
-
*/
|
|
1090
|
-
togglePlaceholder(value) {
|
|
1091
|
-
if (!value) {
|
|
1092
|
-
this.r.addClass(this.editorWrapper.nativeElement, 'show-placeholder');
|
|
1093
|
-
this.showPlaceholder = true;
|
|
1094
|
-
}
|
|
1095
|
-
else {
|
|
1096
|
-
this.r.removeClass(this.editorWrapper.nativeElement, 'show-placeholder');
|
|
1097
|
-
this.showPlaceholder = false;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Implements disabled state for this element
|
|
1102
|
-
*
|
|
1103
|
-
* @param isDisabled Disabled flag
|
|
1104
|
-
*/
|
|
1105
|
-
setDisabledState(isDisabled) {
|
|
1106
|
-
const div = this.textArea.nativeElement;
|
|
1107
|
-
const action = isDisabled ? 'addClass' : 'removeClass';
|
|
1108
|
-
this.r[action](div, 'disabled');
|
|
1109
|
-
this.disabled = isDisabled;
|
|
1110
|
-
}
|
|
1111
|
-
/**
|
|
1112
|
-
* toggles editor mode based on bToSource bool
|
|
1113
|
-
*
|
|
1114
|
-
* @param bToSource A boolean value from the editor
|
|
1115
|
-
*/
|
|
1116
|
-
toggleEditorMode(bToSource) {
|
|
1117
|
-
let oContent;
|
|
1118
|
-
const editableElement = this.textArea.nativeElement;
|
|
1119
|
-
if (bToSource) {
|
|
1120
|
-
oContent = this.r.createText(editableElement.innerHTML);
|
|
1121
|
-
this.r.setProperty(editableElement, 'innerHTML', '');
|
|
1122
|
-
this.r.setProperty(editableElement, 'contentEditable', false);
|
|
1123
|
-
const oPre = this.r.createElement('pre');
|
|
1124
|
-
this.r.setStyle(oPre, 'margin', '0');
|
|
1125
|
-
this.r.setStyle(oPre, 'outline', 'none');
|
|
1126
|
-
const oCode = this.r.createElement('code');
|
|
1127
|
-
this.r.setProperty(oCode, 'id', 'sourceText' + this.id);
|
|
1128
|
-
this.r.setStyle(oCode, 'display', 'block');
|
|
1129
|
-
this.r.setStyle(oCode, 'white-space', 'pre-wrap');
|
|
1130
|
-
this.r.setStyle(oCode, 'word-break', 'keep-all');
|
|
1131
|
-
this.r.setStyle(oCode, 'outline', 'none');
|
|
1132
|
-
this.r.setStyle(oCode, 'margin', '0');
|
|
1133
|
-
this.r.setStyle(oCode, 'background-color', '#fff5b9');
|
|
1134
|
-
this.r.setProperty(oCode, 'contentEditable', true);
|
|
1135
|
-
this.r.appendChild(oCode, oContent);
|
|
1136
|
-
this.focusInstance = this.r.listen(oCode, 'focus', (event) => this.onTextAreaFocus(event));
|
|
1137
|
-
this.blurInstance = this.r.listen(oCode, 'blur', (event) => this.onTextAreaBlur(event));
|
|
1138
|
-
this.r.appendChild(oPre, oCode);
|
|
1139
|
-
this.r.appendChild(editableElement, oPre);
|
|
1140
|
-
// ToDo move to service
|
|
1141
|
-
this.doc.execCommand('defaultParagraphSeparator', false, 'div');
|
|
1142
|
-
this.modeVisual = false;
|
|
1143
|
-
this.viewMode.emit(false);
|
|
1144
|
-
oCode.focus();
|
|
1145
|
-
}
|
|
1146
|
-
else {
|
|
1147
|
-
if (this.doc.querySelectorAll) {
|
|
1148
|
-
this.r.setProperty(editableElement, 'innerHTML', editableElement.innerText);
|
|
1149
|
-
}
|
|
1150
|
-
else {
|
|
1151
|
-
oContent = this.doc.createRange();
|
|
1152
|
-
oContent.selectNodeContents(editableElement.firstChild);
|
|
1153
|
-
this.r.setProperty(editableElement, 'innerHTML', oContent.toString());
|
|
1154
|
-
}
|
|
1155
|
-
this.r.setProperty(editableElement, 'contentEditable', true);
|
|
1156
|
-
this.modeVisual = true;
|
|
1157
|
-
this.viewMode.emit(true);
|
|
1158
|
-
this.onContentChange(editableElement);
|
|
1159
|
-
editableElement.focus();
|
|
1160
|
-
}
|
|
1161
|
-
this.editorToolbar.setEditorMode(!this.modeVisual);
|
|
1162
|
-
}
|
|
1163
|
-
/**
|
|
1164
|
-
* toggles editor buttons when cursor moved or positioning
|
|
1165
|
-
*
|
|
1166
|
-
* Send a node array from the contentEditable of the editor
|
|
1167
|
-
*/
|
|
1168
|
-
exec() {
|
|
1169
|
-
this.editorToolbar.triggerButtons();
|
|
1170
|
-
let userSelection;
|
|
1171
|
-
if (this.doc.getSelection) {
|
|
1172
|
-
userSelection = this.doc.getSelection();
|
|
1173
|
-
this.editorService.executeInNextQueueIteration(this.editorService.saveSelection);
|
|
1174
|
-
}
|
|
1175
|
-
let a = userSelection.focusNode;
|
|
1176
|
-
const els = [];
|
|
1177
|
-
while (a && a.id !== 'editor') {
|
|
1178
|
-
els.unshift(a);
|
|
1179
|
-
a = a.parentNode;
|
|
1180
|
-
}
|
|
1181
|
-
this.editorToolbar.triggerBlocks(els);
|
|
1182
|
-
}
|
|
1183
|
-
configure() {
|
|
1184
|
-
this.editorService.uploadUrl = this.config.uploadUrl;
|
|
1185
|
-
this.editorService.uploadWithCredentials = this.config.uploadWithCredentials;
|
|
1186
|
-
if (this.config.defaultParagraphSeparator) {
|
|
1187
|
-
this.editorService.setDefaultParagraphSeparator(this.config.defaultParagraphSeparator);
|
|
1188
|
-
}
|
|
1189
|
-
if (this.config.defaultFontName) {
|
|
1190
|
-
this.editorService.setFontName(this.config.defaultFontName);
|
|
1191
|
-
}
|
|
1192
|
-
if (this.config.defaultFontSize) {
|
|
1193
|
-
this.editorService.setFontSize(this.config.defaultFontSize);
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
getFonts() {
|
|
1197
|
-
const fonts = this.config.fonts ? this.config.fonts : angularEditorConfig.fonts;
|
|
1198
|
-
return fonts.map(x => {
|
|
1199
|
-
return { label: x.name, value: x.name };
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
getCustomTags() {
|
|
1203
|
-
const tags = ['span'];
|
|
1204
|
-
this.config.customClasses.forEach(x => {
|
|
1205
|
-
if (x.tag !== undefined) {
|
|
1206
|
-
if (!tags.includes(x.tag)) {
|
|
1207
|
-
tags.push(x.tag);
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
});
|
|
1211
|
-
return tags.join(',');
|
|
1212
|
-
}
|
|
1213
|
-
ngOnDestroy() {
|
|
1214
|
-
if (this.blurInstance) {
|
|
1215
|
-
this.blurInstance();
|
|
1216
|
-
}
|
|
1217
|
-
if (this.focusInstance) {
|
|
1218
|
-
this.focusInstance();
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
filterStyles(html) {
|
|
1222
|
-
html = html.replace('position: fixed;', '');
|
|
1223
|
-
return html;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
AngularEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorComponent, deps: [{ token: i0.Renderer2 }, { token: AngularEditorService }, { token: DOCUMENT }, { token: i2.DomSanitizer }, { token: i0.ChangeDetectorRef }, { token: 'tabindex', attribute: true }, { token: 'autofocus', attribute: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1227
|
-
AngularEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: AngularEditorComponent, selector: "angular-editor", inputs: { id: "id", config: "config", placeholder: "placeholder", tabIndex: "tabIndex" }, outputs: { html: "html", viewMode: "viewMode", blurEvent: "blur", focusEvent: "focus" }, host: { listeners: { "focus": "onFocus()" }, properties: { "attr.tabindex": "this.tabindex" } }, providers: [
|
|
1228
|
-
{
|
|
1229
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1230
|
-
useExisting: forwardRef(() => AngularEditorComponent),
|
|
1231
|
-
multi: true
|
|
1232
|
-
},
|
|
1233
|
-
AngularEditorService
|
|
1234
|
-
], queries: [{ propertyName: "customButtonsTemplateRef", first: true, predicate: ["customButtons"], descendants: true }], viewQueries: [{ propertyName: "textArea", first: true, predicate: ["editor"], descendants: true, static: true }, { propertyName: "editorWrapper", first: true, predicate: ["editorWrapper"], descendants: true, static: true }, { propertyName: "editorToolbar", first: true, predicate: ["editorToolbar"], descendants: true }], ngImport: i0, template: "<div\n class=\"angular-editor\"\n #angularEditor\n [style.width]=\"config.width\"\n [style.minWidth]=\"config.minWidth\"\n [ngClass]=\"{\n 'bottom': config.toolbarPosition === 'bottom'\n }\"\n>\n <angular-editor-toolbar\n #editorToolbar\n [id]=\"id\"\n [uploadUrl]=\"config.uploadUrl\"\n [upload]=\"config.upload\"\n [showToolbar]=\"config.showToolbar !== undefined ? config.showToolbar : true\"\n [fonts]=\"getFonts()\"\n [customClasses]=\"config.customClasses\"\n [defaultFontName]=\"config.defaultFontName\"\n [defaultFontSize]=\"config.defaultFontSize\"\n [hiddenButtons]=\"config.toolbarHiddenButtons\"\n (execute)=\"executeCommand($event)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"customButtonsTemplateRef\"\n [ngTemplateOutletContext]=\"{ executeCommandFn: this.executeCommandFn}\"\n >\n </ng-container>\n </angular-editor-toolbar>\n\n <div\n class=\"angular-editor-wrapper\"\n #editorWrapper\n >\n <div\n #editor\n class=\"angular-editor-textarea\"\n [attr.contenteditable]=\"config.editable\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [attr.translate]=\"config.translate\"\n [attr.spellcheck]=\"config.spellcheck\"\n [style.height]=\"config.height\"\n [style.minHeight]=\"config.minHeight\"\n [style.maxHeight]=\"config.maxHeight\"\n [style.outline]=\"config.outline === false ? 'none': undefined\"\n (input)=\"onContentChange($event.target)\"\n (focus)=\"onTextAreaFocus($event)\"\n (blur)=\"onTextAreaBlur($event)\"\n (click)=\"exec()\"\n (keyup)=\"exec()\"\n (mouseout)=\"onTextAreaMouseOut($event)\"\n (paste)=\"onPaste($event)\"\n >\n </div>\n <span class=\"angular-editor-placeholder\">{{ placeholder || config['placeholder'] }}</span>\n </div>\n</div>\n", styles: ["a{cursor:pointer}.angular-editor{display:flex;flex-direction:column;gap:var(--ae-gap, 5px)}.angular-editor.bottom{flex-direction:column-reverse}.angular-editor ::ng-deep [contenteditable=true]:empty:before{content:attr(placeholder);color:#868e96;opacity:1}.angular-editor .angular-editor-wrapper{position:relative}.angular-editor .angular-editor-wrapper .angular-editor-textarea{min-height:150px;overflow:auto;resize:vertical}.angular-editor .angular-editor-wrapper .angular-editor-textarea:after{content:\"\";position:absolute;bottom:0;right:0;display:block;width:8px;height:8px;cursor:nwse-resize;background-color:#ffffff80}.angular-editor .angular-editor-wrapper .angular-editor-textarea{min-height:5rem;padding:.5rem .8rem 1rem;border-radius:var(--ae-text-area-border-radius, .3rem);border:var(--ae-text-area-border, 1px solid #ddd);background-color:transparent;overflow-x:hidden;overflow-y:auto;position:relative}.angular-editor .angular-editor-wrapper .angular-editor-textarea:focus,.angular-editor .angular-editor-wrapper .angular-editor-textarea.focus{outline:var(--ae-focus-outline-color, -webkit-focus-ring-color auto 1px)}.angular-editor .angular-editor-wrapper .angular-editor-textarea ::ng-deep blockquote{margin-left:1rem;border-left:.2em solid #dfe2e5;padding-left:.5rem}.angular-editor .angular-editor-wrapper ::ng-deep p{margin-bottom:0}.angular-editor .angular-editor-wrapper .angular-editor-placeholder{display:none;position:absolute;top:0;padding:.6rem .8rem 1rem .9rem;color:#6c757d;opacity:.75}.angular-editor .angular-editor-wrapper.show-placeholder .angular-editor-placeholder{display:block}.angular-editor .angular-editor-wrapper.disabled{cursor:not-allowed;opacity:.5;pointer-events:none}\n"], components: [{ type: AeToolbarComponent, selector: "angular-editor-toolbar, ae-toolbar, div[aeToolbar]", inputs: ["id", "uploadUrl", "upload", "showToolbar", "fonts", "customClasses", "defaultFontName", "defaultFontSize", "hiddenButtons"], outputs: ["execute"] }], directives: [{ type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
1235
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorComponent, decorators: [{
|
|
1236
|
-
type: Component,
|
|
1237
|
-
args: [{ selector: 'angular-editor', providers: [
|
|
1238
|
-
{
|
|
1239
|
-
provide: NG_VALUE_ACCESSOR,
|
|
1240
|
-
useExisting: forwardRef(() => AngularEditorComponent),
|
|
1241
|
-
multi: true
|
|
1242
|
-
},
|
|
1243
|
-
AngularEditorService
|
|
1244
|
-
], template: "<div\n class=\"angular-editor\"\n #angularEditor\n [style.width]=\"config.width\"\n [style.minWidth]=\"config.minWidth\"\n [ngClass]=\"{\n 'bottom': config.toolbarPosition === 'bottom'\n }\"\n>\n <angular-editor-toolbar\n #editorToolbar\n [id]=\"id\"\n [uploadUrl]=\"config.uploadUrl\"\n [upload]=\"config.upload\"\n [showToolbar]=\"config.showToolbar !== undefined ? config.showToolbar : true\"\n [fonts]=\"getFonts()\"\n [customClasses]=\"config.customClasses\"\n [defaultFontName]=\"config.defaultFontName\"\n [defaultFontSize]=\"config.defaultFontSize\"\n [hiddenButtons]=\"config.toolbarHiddenButtons\"\n (execute)=\"executeCommand($event)\"\n >\n <ng-container\n [ngTemplateOutlet]=\"customButtonsTemplateRef\"\n [ngTemplateOutletContext]=\"{ executeCommandFn: this.executeCommandFn}\"\n >\n </ng-container>\n </angular-editor-toolbar>\n\n <div\n class=\"angular-editor-wrapper\"\n #editorWrapper\n >\n <div\n #editor\n class=\"angular-editor-textarea\"\n [attr.contenteditable]=\"config.editable\"\n [attr.tabindex]=\"disabled ? -1 : tabIndex\"\n [attr.translate]=\"config.translate\"\n [attr.spellcheck]=\"config.spellcheck\"\n [style.height]=\"config.height\"\n [style.minHeight]=\"config.minHeight\"\n [style.maxHeight]=\"config.maxHeight\"\n [style.outline]=\"config.outline === false ? 'none': undefined\"\n (input)=\"onContentChange($event.target)\"\n (focus)=\"onTextAreaFocus($event)\"\n (blur)=\"onTextAreaBlur($event)\"\n (click)=\"exec()\"\n (keyup)=\"exec()\"\n (mouseout)=\"onTextAreaMouseOut($event)\"\n (paste)=\"onPaste($event)\"\n >\n </div>\n <span class=\"angular-editor-placeholder\">{{ placeholder || config['placeholder'] }}</span>\n </div>\n</div>\n", styles: ["a{cursor:pointer}.angular-editor{display:flex;flex-direction:column;gap:var(--ae-gap, 5px)}.angular-editor.bottom{flex-direction:column-reverse}.angular-editor ::ng-deep [contenteditable=true]:empty:before{content:attr(placeholder);color:#868e96;opacity:1}.angular-editor .angular-editor-wrapper{position:relative}.angular-editor .angular-editor-wrapper .angular-editor-textarea{min-height:150px;overflow:auto;resize:vertical}.angular-editor .angular-editor-wrapper .angular-editor-textarea:after{content:\"\";position:absolute;bottom:0;right:0;display:block;width:8px;height:8px;cursor:nwse-resize;background-color:#ffffff80}.angular-editor .angular-editor-wrapper .angular-editor-textarea{min-height:5rem;padding:.5rem .8rem 1rem;border-radius:var(--ae-text-area-border-radius, .3rem);border:var(--ae-text-area-border, 1px solid #ddd);background-color:transparent;overflow-x:hidden;overflow-y:auto;position:relative}.angular-editor .angular-editor-wrapper .angular-editor-textarea:focus,.angular-editor .angular-editor-wrapper .angular-editor-textarea.focus{outline:var(--ae-focus-outline-color, -webkit-focus-ring-color auto 1px)}.angular-editor .angular-editor-wrapper .angular-editor-textarea ::ng-deep blockquote{margin-left:1rem;border-left:.2em solid #dfe2e5;padding-left:.5rem}.angular-editor .angular-editor-wrapper ::ng-deep p{margin-bottom:0}.angular-editor .angular-editor-wrapper .angular-editor-placeholder{display:none;position:absolute;top:0;padding:.6rem .8rem 1rem .9rem;color:#6c757d;opacity:.75}.angular-editor .angular-editor-wrapper.show-placeholder .angular-editor-placeholder{display:block}.angular-editor .angular-editor-wrapper.disabled{cursor:not-allowed;opacity:.5;pointer-events:none}\n"] }]
|
|
1245
|
-
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: AngularEditorService }, { type: undefined, decorators: [{
|
|
1246
|
-
type: Inject,
|
|
1247
|
-
args: [DOCUMENT]
|
|
1248
|
-
}] }, { type: i2.DomSanitizer }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
|
|
1249
|
-
type: Attribute,
|
|
1250
|
-
args: ['tabindex']
|
|
1251
|
-
}] }, { type: undefined, decorators: [{
|
|
1252
|
-
type: Attribute,
|
|
1253
|
-
args: ['autofocus']
|
|
1254
|
-
}] }]; }, propDecorators: { id: [{
|
|
1255
|
-
type: Input
|
|
1256
|
-
}], config: [{
|
|
1257
|
-
type: Input
|
|
1258
|
-
}], placeholder: [{
|
|
1259
|
-
type: Input
|
|
1260
|
-
}], tabIndex: [{
|
|
1261
|
-
type: Input
|
|
1262
|
-
}], html: [{
|
|
1263
|
-
type: Output
|
|
1264
|
-
}], textArea: [{
|
|
1265
|
-
type: ViewChild,
|
|
1266
|
-
args: ['editor', { static: true }]
|
|
1267
|
-
}], editorWrapper: [{
|
|
1268
|
-
type: ViewChild,
|
|
1269
|
-
args: ['editorWrapper', { static: true }]
|
|
1270
|
-
}], editorToolbar: [{
|
|
1271
|
-
type: ViewChild,
|
|
1272
|
-
args: ['editorToolbar']
|
|
1273
|
-
}], customButtonsTemplateRef: [{
|
|
1274
|
-
type: ContentChild,
|
|
1275
|
-
args: ["customButtons"]
|
|
1276
|
-
}], viewMode: [{
|
|
1277
|
-
type: Output
|
|
1278
|
-
}], blurEvent: [{
|
|
1279
|
-
type: Output,
|
|
1280
|
-
args: ['blur']
|
|
1281
|
-
}], focusEvent: [{
|
|
1282
|
-
type: Output,
|
|
1283
|
-
args: ['focus']
|
|
1284
|
-
}], tabindex: [{
|
|
1285
|
-
type: HostBinding,
|
|
1286
|
-
args: ['attr.tabindex']
|
|
1287
|
-
}], onFocus: [{
|
|
1288
|
-
type: HostListener,
|
|
1289
|
-
args: ['focus']
|
|
1290
|
-
}] } });
|
|
1291
|
-
|
|
1292
|
-
class AngularEditorModule {
|
|
1293
|
-
}
|
|
1294
|
-
AngularEditorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1295
|
-
AngularEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorModule, declarations: [AngularEditorComponent, AeToolbarComponent, AeSelectComponent, AeButtonComponent, AeToolbarSetComponent], imports: [CommonModule, FormsModule, ReactiveFormsModule], exports: [AngularEditorComponent, AeToolbarComponent, AeButtonComponent, AeToolbarSetComponent] });
|
|
1296
|
-
AngularEditorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorModule, imports: [[
|
|
1297
|
-
CommonModule, FormsModule, ReactiveFormsModule
|
|
1298
|
-
]] });
|
|
1299
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AngularEditorModule, decorators: [{
|
|
1300
|
-
type: NgModule,
|
|
1301
|
-
args: [{
|
|
1302
|
-
imports: [
|
|
1303
|
-
CommonModule, FormsModule, ReactiveFormsModule
|
|
1304
|
-
],
|
|
1305
|
-
declarations: [AngularEditorComponent, AeToolbarComponent, AeSelectComponent, AeButtonComponent, AeToolbarSetComponent],
|
|
1306
|
-
exports: [AngularEditorComponent, AeToolbarComponent, AeButtonComponent, AeToolbarSetComponent]
|
|
1307
|
-
}]
|
|
1308
|
-
}] });
|
|
1309
|
-
|
|
1310
|
-
/*
|
|
1311
|
-
* Public API Surface of angular-editor
|
|
1312
|
-
*/
|
|
1313
|
-
|
|
1314
|
-
/**
|
|
1315
|
-
* Generated bundle index. Do not edit.
|
|
1316
|
-
*/
|
|
1317
|
-
|
|
1318
|
-
export { AeButtonComponent, AeSelectComponent, AeToolbarComponent, AeToolbarSetComponent, AngularEditorComponent, AngularEditorModule, AngularEditorService };
|
|
1319
|
-
//# sourceMappingURL=kolkov-angular-editor.mjs.map
|