3 Star 16 Fork 4

imlxp/ngx-editor.md-markdown

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
editor-md.directive.ts 918 Bytes
一键复制 编辑 原始数据 按行查看 历史
imlxp 提交于 2018-01-22 13:38 +08:00 . 删除多余方法
import {AfterViewInit, Attribute, Directive, EventEmitter, Input, Output} from '@angular/core';
import {EditorConfig} from './model/editor-config';
declare var editormd: any;
declare var $: any;
@Directive({
selector: '[appEditorMd]'
})
export class EditorMdDirective implements AfterViewInit {
@Input() editormdConfig: EditorConfig; // 配置选项
@Output() onEditorChange: 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.onEditorChange;
const textarea = $('#' + this.id + ' :first'); // 获取textarea元素
// 当编辑器内容改变时,触发textarea的change事件
this.editor.on('change', function () {
out.emit(textarea.val());
});
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/imlxp/ngx-editor.md-markdown.git
git@gitee.com:imlxp/ngx-editor.md-markdown.git
imlxp
ngx-editor.md-markdown
ngx-editor.md-markdown
master

搜索帮助