@kolkov/angular-editor 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,38 @@
1
- import { HttpEvent, HttpClient, HttpResponse } from '@angular/common/http';
1
+ import { HttpEvent, HttpResponse } from '@angular/common/http';
2
2
  import { Observable } from 'rxjs';
3
3
  import * as i0 from '@angular/core';
4
- import { OnInit, EventEmitter, ElementRef, Renderer2, AfterViewInit, OnDestroy, TemplateRef, ChangeDetectorRef } from '@angular/core';
4
+ import { OnInit, EventEmitter, ElementRef, AfterViewInit, OnDestroy, TemplateRef } from '@angular/core';
5
5
  import * as i7 from '@angular/forms';
6
6
  import { ControlValueAccessor } from '@angular/forms';
7
- import { DomSanitizer } from '@angular/platform-browser';
8
7
  import * as i6 from '@angular/common';
9
8
 
9
+ /**
10
+ * Custom class configuration for applying styles to selected content.
11
+ *
12
+ * @example
13
+ * // Basic usage (inline span)
14
+ * { name: 'Red Text', class: 'text-red' }
15
+ *
16
+ * // Block-level class (applies to each paragraph)
17
+ * { name: 'Highlight', class: 'highlight', mode: 'block' }
18
+ *
19
+ * // Auto mode (smart detection)
20
+ * { name: 'Quote', class: 'quote', mode: 'auto', tag: 'div' }
21
+ */
10
22
  interface CustomClass {
23
+ /** Display name shown in dropdown */
11
24
  name: string;
25
+ /** CSS class to apply */
12
26
  class: string;
27
+ /** HTML tag to use for wrapping (default: 'span') */
13
28
  tag?: string;
29
+ /**
30
+ * Application mode:
31
+ * - 'inline': Always wrap selection in a single element (legacy behavior)
32
+ * - 'block': Apply class to each block element in selection
33
+ * - 'auto': Smart detection - inline for single block, block for multiple (default)
34
+ */
35
+ mode?: 'inline' | 'block' | 'auto';
14
36
  }
15
37
  interface Font {
16
38
  name: string;
@@ -41,19 +63,19 @@ interface AngularEditorConfig {
41
63
  outline?: boolean;
42
64
  toolbarHiddenButtons?: string[][];
43
65
  rawPaste?: boolean;
66
+ textDirection?: 'ltr' | 'rtl' | 'auto';
44
67
  }
45
68
 
46
69
  interface UploadResponse {
47
70
  imageUrl: string;
48
71
  }
49
72
  declare class AngularEditorService {
50
- private http;
51
- private doc;
52
73
  savedSelection: Range | null;
53
74
  selectedText: string;
54
75
  uploadUrl: string;
55
76
  uploadWithCredentials: boolean;
56
- constructor(http: HttpClient, doc: any);
77
+ private http;
78
+ private doc;
57
79
  /**
58
80
  * Executed command from editor header buttons exclude toggleEditorMode
59
81
  * @param command string from triggerCommand
@@ -100,7 +122,7 @@ declare class AngularEditorService {
100
122
  /**
101
123
  * setTimeout used for execute 'saveSelection' method in next event loop iteration
102
124
  */
103
- executeInNextQueueIteration(callbackFn: (...args: any[]) => any, timeout?: number): void;
125
+ executeInNextQueueIteration(callbackFn: (...args: unknown[]) => unknown, timeout?: number): void;
104
126
  /** check any selection is made or not */
105
127
  private checkSelection;
106
128
  /**
@@ -114,12 +136,48 @@ declare class AngularEditorService {
114
136
  */
115
137
  insertImage(imageUrl: string): void;
116
138
  setDefaultParagraphSeparator(separator: string): void;
139
+ /**
140
+ * Apply custom class to selection with enterprise-level HTML structure preservation.
141
+ * Supports three modes:
142
+ * - 'inline': Wrap selection in a single element (legacy behavior)
143
+ * - 'block': Apply class to each block element in selection
144
+ * - 'auto': Smart detection based on selection span (default)
145
+ *
146
+ * @param customClass The custom class configuration
147
+ */
117
148
  createCustomClass(customClass: CustomClass): void;
149
+ /**
150
+ * Apply class inline by wrapping selection in a single element.
151
+ * Uses extractContents + insertNode pattern for safety.
152
+ */
153
+ private applyClassInline;
154
+ /**
155
+ * Fallback method for inline class application (legacy behavior).
156
+ */
157
+ private applyClassInlineFallback;
158
+ /**
159
+ * Apply class to each block element in selection.
160
+ * Preserves HTML structure by adding class to existing elements.
161
+ */
162
+ private applyClassToBlocks;
163
+ /**
164
+ * Get all block-level elements within a range.
165
+ * Returns elements that are fully or partially selected.
166
+ */
167
+ private getBlockElementsInRange;
168
+ /**
169
+ * Check if a node is fully contained within a range.
170
+ */
171
+ private isNodeFullyInRange;
172
+ /**
173
+ * Check if element has an ancestor in the given set.
174
+ */
175
+ private hasAncestorInSet;
118
176
  insertVideo(videoUrl: string): void;
119
177
  private insertYouTubeVideoTag;
120
178
  private insertVimeoVideoTag;
121
179
  nextNode(node: any): any;
122
- getRangeSelectedNodes(range: any, includePartiallySelectedContainers: any): any[];
180
+ getRangeSelectedNodes(range: any, includePartiallySelectedContainers: boolean): any[];
123
181
  getSelectedNodes(): any[];
124
182
  replaceWithOwnChildren(el: any): void;
125
183
  removeSelectedElements(tagNames: any): void;
@@ -132,8 +190,6 @@ interface SelectOption {
132
190
  value: string;
133
191
  }
134
192
  declare class AeSelectComponent implements OnInit, ControlValueAccessor {
135
- private elRef;
136
- private r;
137
193
  options: SelectOption[];
138
194
  isHidden: boolean;
139
195
  selectedOption: SelectOption;
@@ -145,7 +201,8 @@ declare class AeSelectComponent implements OnInit, ControlValueAccessor {
145
201
  hidden: string;
146
202
  changeEvent: EventEmitter<any>;
147
203
  labelButton: ElementRef;
148
- constructor(elRef: ElementRef, r: Renderer2);
204
+ private elRef;
205
+ private r;
149
206
  ngOnInit(): void;
150
207
  hide(): void;
151
208
  optionSelect(option: SelectOption, event: MouseEvent): void;
@@ -172,26 +229,19 @@ declare class AeSelectComponent implements OnInit, ControlValueAccessor {
172
229
  }
173
230
 
174
231
  declare class AeToolbarComponent {
175
- private r;
176
- private editorService;
177
- private er;
178
- private doc;
179
232
  htmlMode: boolean;
180
233
  linkSelected: boolean;
181
234
  block: string;
182
235
  fontName: string;
183
236
  fontSize: string;
184
- foreColour: any;
185
- backColor: any;
237
+ foreColour: string;
238
+ backColor: string;
186
239
  headings: SelectOption[];
187
240
  fontSizes: SelectOption[];
188
241
  customClassId: string;
189
242
  _customClasses: CustomClass[];
190
243
  customClassList: SelectOption[];
191
- tagMap: {
192
- BLOCKQUOTE: string;
193
- A: string;
194
- };
244
+ tagMap: Record<string, string>;
195
245
  select: string[];
196
246
  buttons: string[];
197
247
  id: string;
@@ -206,7 +256,10 @@ declare class AeToolbarComponent {
206
256
  execute: EventEmitter<string>;
207
257
  myInputFile: ElementRef;
208
258
  get isLinkButtonDisabled(): boolean;
209
- constructor(r: Renderer2, editorService: AngularEditorService, er: ElementRef, doc: any);
259
+ private r;
260
+ private editorService;
261
+ private er;
262
+ private doc;
210
263
  /**
211
264
  * Trigger command from editor header buttons
212
265
  * @param command string from toolbar buttons
@@ -263,11 +316,6 @@ declare class AeToolbarComponent {
263
316
  }
264
317
 
265
318
  declare class AngularEditorComponent implements OnInit, ControlValueAccessor, AfterViewInit, OnDestroy {
266
- private r;
267
- private editorService;
268
- private doc;
269
- private sanitizer;
270
- private cdRef;
271
319
  private autoFocus;
272
320
  private onChange;
273
321
  private onTouched;
@@ -283,12 +331,12 @@ declare class AngularEditorComponent implements OnInit, ControlValueAccessor, Af
283
331
  config: AngularEditorConfig;
284
332
  placeholder: string;
285
333
  tabIndex: number | null;
286
- html: any;
334
+ html: EventEmitter<any>;
287
335
  textArea: ElementRef;
288
336
  editorWrapper: ElementRef;
289
337
  editorToolbar: AeToolbarComponent;
290
338
  customButtonsTemplateRef?: TemplateRef<any>;
291
- executeCommandFn: any;
339
+ executeCommandFn: (command: string, value?: string) => void;
292
340
  viewMode: EventEmitter<boolean>;
293
341
  /** emits `blur` event when focused out from the textarea */
294
342
  blurEvent: EventEmitter<FocusEvent>;
@@ -296,10 +344,15 @@ declare class AngularEditorComponent implements OnInit, ControlValueAccessor, Af
296
344
  focusEvent: EventEmitter<FocusEvent>;
297
345
  tabindex: number;
298
346
  onFocus(): void;
299
- constructor(r: Renderer2, editorService: AngularEditorService, doc: any, sanitizer: DomSanitizer, cdRef: ChangeDetectorRef, defaultTabIndex: string, autoFocus: any);
347
+ private r;
348
+ private editorService;
349
+ private doc;
350
+ private sanitizer;
351
+ private cdRef;
352
+ constructor(defaultTabIndex: string, autoFocus: any);
300
353
  ngOnInit(): void;
301
354
  ngAfterViewInit(): void;
302
- onPaste(event: ClipboardEvent): string;
355
+ onPaste(event: ClipboardEvent): string | undefined;
303
356
  /**
304
357
  * Executed command from editor header buttons
305
358
  * @param command string from triggerCommand
@@ -385,13 +438,12 @@ declare class AngularEditorComponent implements OnInit, ControlValueAccessor, Af
385
438
  getCustomTags(): string;
386
439
  ngOnDestroy(): void;
387
440
  filterStyles(html: string): string;
388
- static ɵfac: i0.ɵɵFactoryDeclaration<AngularEditorComponent, [null, null, null, null, null, { attribute: "tabindex"; }, { attribute: "autofocus"; }]>;
441
+ static ɵfac: i0.ɵɵFactoryDeclaration<AngularEditorComponent, [{ attribute: "tabindex"; }, { attribute: "autofocus"; }]>;
389
442
  static ɵcmp: i0.ɵɵComponentDeclaration<AngularEditorComponent, "angular-editor", never, { "id": { "alias": "id"; "required": false; }; "config": { "alias": "config"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "tabIndex": { "alias": "tabIndex"; "required": false; }; }, { "html": "html"; "viewMode": "viewMode"; "blurEvent": "blur"; "focusEvent": "focus"; }, ["customButtonsTemplateRef"], never, false, never>;
390
443
  }
391
444
 
392
445
  declare class AeButtonComponent {
393
446
  iconName: string;
394
- constructor();
395
447
  static ɵfac: i0.ɵɵFactoryDeclaration<AeButtonComponent, never>;
396
448
  static ɵcmp: i0.ɵɵComponentDeclaration<AeButtonComponent, "ae-button, button[aeButton]", never, { "iconName": { "alias": "iconName"; "required": false; }; }, {}, never, ["*"], false, never>;
397
449
  }