
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
ngx-highlight-js
Advanced tools
Angular for syntax highlighting with highlight.js
npm install ngx-highlight-js --save
把 UeditorModule
模块导入到你项目中。
import { UeditorModule } from 'ngx-highlight-js';
@NgModule({
imports: [BrowserModule, UeditorModule ],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
<ueditor [(ngModel)]="full_source"
[config]="{...}"
[path]="'./assets/ueditor/'"
[loadingTip]="'加载中……'"
(onReady)=""
(onDestroy)=""
(onContentChange)=""></ueditor>
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
config | Object | 前端配置项说明,见官网 | |
path | string | ./assets/ueditor/ | ueditor代码根目录路径,以 / 结尾。 |
loadingTip | string | 加载中... | 初始化提示文本。 |
onReady | Function | 编辑器准备就绪后会触发该事件 | |
onDestroy | Function | 编辑器组件销毁后会触发该事件 | |
onContentChange | Function | 编辑器内容发生改变时会触发该事件 |
懒加载在未到 wdinow.UE
时会启动,如果你在 index.html
已经使用 <script src="ueditor.all.js"></script>
加载过,懒加载流程将会失效。
加载语言注意点
懒加载会自动识别并引用,否则,需要自行在 <head>
加入语言版本脚本。
首先,需要给组件定义一下模板变量:
<ueditor [(ngModel)]="full_source" #full></ueditor>
使用 @ViewChild
访问组件,并使用 this.full.Instance
访问ueditor实例对象。
export class DemoComponent {
@ViewChild('full') full: UeditorComponent;
constructor(private el: ElementRef) {}
getAllHtml() {
// 通过 `this.full.Instance` 访问ueditor实例对象
alert(this.full.Instance.getAllHtml())
}
}
虽说上节也可以直接注册ueditor事件,但当组件被销毁时可能会引发内存泄露。所以不建议直接在ueditor实例中这么做。组件本身提供 addListener
和 removeListener
来帮你处理。
// 事件监听
this.full.addListener('focus', () => {
this.focus = `fire focus in ${new Date().getTime()}`;
});
// 事件移除
this.full.removeListener('focus');
组件加入 required
当编辑器为空时会处于 ng-invalid
状态,具体体验见Live Demo。
interface UeditorComponent {
/**
* 获取UE实例
*
* @readonly
*/
get Instance(): any;
/**
* 设置编辑器语言
*
* @param {('zh-cn' | 'en')} lang
*/
setLanguage(lang: 'zh-cn' | 'en') {}
/**
* 添加编辑器事件
*/
addListener(eventName: 'destroy' | 'reset' | 'focus' | 'langReady' | 'beforeExecCommand' | 'afterExecCommand' | 'firstBeforeExecCommand' | 'beforeGetContent' | 'afterGetContent' | 'getAllHtml' | 'beforeSetContent' | 'afterSetContent' | 'selectionchange' | 'beforeSelectionChange' | 'afterSelectionChange',
fn: Function): void {}
/**
* 移除编辑器事件
*
* @param {('destroy' | 'reset' | 'focus' | 'langReady' | 'beforeExecCommand' | 'afterExecCommand' | 'firstBeforeExecCommand' | 'beforeGetContent' | 'afterGetContent' | 'getAllHtml' | 'beforeSetContent' | 'afterSetContent' | 'selectionchange' | 'beforeSelectionChange' | 'afterSelectionChange')} eventName
*/
removeListener(eventName: 'destroy' | 'reset' | 'focus' | 'langReady' | 'beforeExecCommand' | 'afterExecCommand' | 'firstBeforeExecCommand' | 'beforeGetContent' | 'afterGetContent' | 'getAllHtml' | 'beforeSetContent' | 'afterSetContent' | 'selectionchange' | 'beforeSelectionChange' | 'afterSelectionChange'): void {}
}
Please follow this guidelines when reporting bugs and feature requests:
Thanks for understanding!
The MIT License (see the LICENSE file for the full text)
FAQs
Angular for syntax highlighting with highlight.js
The npm package ngx-highlight-js receives a total of 2,212 weekly downloads. As such, ngx-highlight-js popularity was classified as popular.
We found that ngx-highlight-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.