refactor: 删除残留代码
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
import {environment} from '../../environments/environment';
|
|
||||||
|
|
||||||
export class EditorConfig {
|
|
||||||
public width = '100%';
|
|
||||||
public height = '400';
|
|
||||||
public path = 'assets/editor/lib/';
|
|
||||||
public codeFold: true;
|
|
||||||
public searchReplace = true;
|
|
||||||
public toolbar = true;
|
|
||||||
public placeholder = '欢迎来到小海的创作中心';
|
|
||||||
public emoji = true;
|
|
||||||
public taskList = true;
|
|
||||||
public tex = true;
|
|
||||||
public readOnly = false;
|
|
||||||
public tocm = true;
|
|
||||||
public watch = true;
|
|
||||||
public previewCodeHighlight = true;
|
|
||||||
public saveHTMLToTextarea = true;
|
|
||||||
public markdown = '';
|
|
||||||
public flowChart = true;
|
|
||||||
public syncScrolling = true;
|
|
||||||
public sequenceDiagram = false; // 时序图/序列图
|
|
||||||
public imageUpload = true;
|
|
||||||
public imageFormats = ['jpg', 'jpeg', 'gif', 'png', 'bmp', 'webp'];
|
|
||||||
public imageUploadURL = environment.host + '/imgUpload';
|
|
||||||
public useAjaxToUploadImg = true
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { EditorMdDirective } from './editor-md.directive';
|
|
||||||
|
|
||||||
describe('EditorMdDirective', () => {
|
|
||||||
it('should create an instance', () => {
|
|
||||||
const directive = new EditorMdDirective();
|
|
||||||
expect(directive).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import {AfterViewInit, Attribute, Directive, EventEmitter, Input, Output} from '@angular/core';
|
|
||||||
import {EditorConfig} from '../../../class/EditorConfig';
|
|
||||||
|
|
||||||
declare var editormd: any;
|
|
||||||
declare var $: any;
|
|
||||||
|
|
||||||
@Directive({
|
|
||||||
selector: '[appEditorMd]'
|
|
||||||
})
|
|
||||||
export class EditorMdDirective implements AfterViewInit {
|
|
||||||
|
|
||||||
@Input() editormdConfig: EditorConfig; // 配置选项
|
|
||||||
@Output() editorChange: EventEmitter<string> = new EventEmitter<string>(); // 发射器
|
|
||||||
editor: any; // editormd编辑器
|
|
||||||
|
|
||||||
constructor(@Attribute('id') private id: string) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
|
||||||
this.editor = editormd(this.id, this.editormdConfig); // 创建编辑器
|
|
||||||
|
|
||||||
const out = this.editorChange;
|
|
||||||
const textarea = $('#' + this.id + ' :first'); // 获取textarea元素
|
|
||||||
|
|
||||||
// 当编辑器内容改变时,触发textarea的change事件
|
|
||||||
// tslint:disable-next-line:only-arrow-functions
|
|
||||||
this.editor.on('change', function() {
|
|
||||||
out.emit(textarea.val());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user