|
|
@@ -1,9 +1,11 @@
|
|
|
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges, SecurityContext, ViewChild, inject, output } from '@angular/core';
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
+import { Bold, Heading2, Images, Italic, List, ListOrdered, LucideAngularModule, Quote, Redo2, RemoveFormatting, Type, Underline, Undo2 } from 'lucide-angular';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-training-body-editor',
|
|
|
standalone: true,
|
|
|
+ imports: [LucideAngularModule],
|
|
|
templateUrl: './training-body-editor.component.html',
|
|
|
styleUrl: './training-body-editor.component.scss',
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
|
@@ -17,18 +19,19 @@ export class TrainingBodyEditorComponent implements AfterViewInit, OnChanges {
|
|
|
private readonly sanitizer = inject(DomSanitizer);
|
|
|
private selection: Range | null = null;
|
|
|
private emittedValue: string | null = null;
|
|
|
+ readonly imagesIcon = Images;
|
|
|
readonly tools = [
|
|
|
- { label: '加粗', command: 'bold', value: '' },
|
|
|
- { label: '斜体', command: 'italic', value: '' },
|
|
|
- { label: '下划线', command: 'underline', value: '' },
|
|
|
- { label: '小标题', command: 'formatBlock', value: 'h2' },
|
|
|
- { label: '正文', command: 'formatBlock', value: 'p' },
|
|
|
- { label: '无序列表', command: 'insertUnorderedList', value: '' },
|
|
|
- { label: '有序列表', command: 'insertOrderedList', value: '' },
|
|
|
- { label: '引用', command: 'formatBlock', value: 'blockquote' },
|
|
|
- { label: '清除格式', command: 'removeFormat', value: '' },
|
|
|
- { label: '撤销', command: 'undo', value: '' },
|
|
|
- { label: '重做', command: 'redo', value: '' },
|
|
|
+ { label: '加粗', icon: Bold, command: 'bold', value: '' },
|
|
|
+ { label: '斜体', icon: Italic, command: 'italic', value: '' },
|
|
|
+ { label: '下划线', icon: Underline, command: 'underline', value: '' },
|
|
|
+ { label: '小标题', icon: Heading2, command: 'formatBlock', value: 'h2' },
|
|
|
+ { label: '正文', icon: Type, command: 'formatBlock', value: 'p' },
|
|
|
+ { label: '无序列表', icon: List, command: 'insertUnorderedList', value: '' },
|
|
|
+ { label: '有序列表', icon: ListOrdered, command: 'insertOrderedList', value: '' },
|
|
|
+ { label: '引用', icon: Quote, command: 'formatBlock', value: 'blockquote' },
|
|
|
+ { label: '清除格式', icon: RemoveFormatting, command: 'removeFormat', value: '' },
|
|
|
+ { label: '撤销', icon: Undo2, command: 'undo', value: '' },
|
|
|
+ { label: '重做', icon: Redo2, command: 'redo', value: '' },
|
|
|
];
|
|
|
|
|
|
ngAfterViewInit(): void { this.renderValue(); }
|