@notectl/angular
v0.0.5
Published
Angular adapter for NotectlEditor
Downloads
14
Maintainers
Readme
@notectl/angular
Angular adapter for NotectlEditor - a framework-agnostic rich text editor built on Web Components.
Installation
npm install @notectl/angular @notectl/coreUsage
Import Module
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NotectlEditorModule } from '@notectl/angular';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
NotectlEditorModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }Component Usage
import { Component } from '@angular/core';
import type { EditorAPI } from '@notectl/core';
@Component({
selector: 'app-root',
template: `
<notectl-editor
[content]="content"
[placeholder]="'Start writing...'"
[readOnly]="false"
(contentChange)="onContentChange($event)"
(ready)="onReady($event)"
></notectl-editor>
`
})
export class AppComponent {
content = { type: 'doc', content: [] };
onContentChange(content: unknown): void {
console.log('Content changed:', content);
}
onReady(editor: EditorAPI): void {
console.log('Editor ready:', editor);
}
}Reactive Forms Integration
import { Component } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
@Component({
selector: 'app-editor-form',
template: `
<form [formGroup]="form">
<notectl-editor formControlName="content"></notectl-editor>
</form>
`
})
export class EditorFormComponent {
form = new FormGroup({
content: new FormControl(null)
});
}Directive Usage
import { Component } from '@angular/core';
@Component({
selector: 'app-editor',
template: `
<div
notectl-editor
[content]="content"
(contentChange)="onContentChange($event)"
></div>
`
})
export class EditorComponent {
content = { type: 'doc', content: [] };
onContentChange(content: unknown): void {
console.log('Content changed:', content);
}
}API
Component Props
debug?: boolean- Enable debug modecontent?: string | object- Initial editor contentplaceholder?: string- Placeholder textreadOnly?: boolean- Read-only modeaccessibility?: object- Accessibility configurationi18n?: object- Internationalization settingstheme?: object- Theme configuration
Component Events
contentChange: EventEmitter<unknown>- Emitted when content changesselectionChange: EventEmitter<unknown>- Emitted when selection changeseditorFocus: EventEmitter<void>- Emitted when editor gains focuseditorBlur: EventEmitter<void>- Emitted when editor loses focusready: EventEmitter<EditorAPI>- Emitted when editor is readyerror: EventEmitter<Error>- Emitted when an error occurs
Component Methods
getContent(): unknown- Get current contentsetContent(content: unknown): void- Set contentgetState(): unknown- Get editor stateexecuteCommand(command: string, ...args: unknown[]): void- Execute commandregisterPlugin(plugin: unknown): void- Register a pluginunregisterPlugin(pluginId: string): void- Unregister a plugin
License
MIT
