Complete reference for all ArmorEditor methods, properties, and events.
Creates a new ArmorEditor instance.
const editor = new ArmorEditor({
container: '#editor',
height: '400px',
// ... other options
});Parameters:
options(Object) - Configuration options
Returns: ArmorEditor instance
Get the HTML content of the editor.
const content = editor.getContent();Returns: String - HTML content
Set the HTML content of the editor.
editor.setContent('<p>Hello world!</p>');Parameters:
html(String) - HTML content to set
Get the plain text content (without HTML tags).
const text = editor.getText();Returns: String - Plain text content
Insert HTML at the current cursor position.
editor.insertHTML('<strong>Bold text</strong>');Parameters:
html(String) - HTML to insert
Clear all content from the editor.
editor.clear();Focus the editor.
editor.focus();Remove focus from the editor.
editor.blur();Set the editor to read-only mode.
editor.setReadOnly(true); // Enable read-only
editor.setReadOnly(false); // Enable editingParameters:
readOnly(Boolean) - Read-only state
Check if the editor is in read-only mode.
const readOnly = editor.isReadOnly();Returns: Boolean - Read-only state
Destroy the editor instance and clean up resources.
editor.destroy();Generate content using AI.
const content = await editor.generateContent('Write a blog post about AI');Parameters:
prompt(String) - AI prompt
Returns: Promise - Generated content
Improve existing content with AI.
const improved = await editor.improveContent('This is some text');Parameters:
text(String) - Text to improve
Returns: Promise - Improved text
Fix grammar and spelling errors.
const corrected = await editor.fixGrammar('This are wrong');Parameters:
text(String) - Text to correct
Returns: Promise - Corrected text
Adjust the tone of text.
const professional = await editor.adjustTone(text, 'professional');Parameters:
text(String) - Text to adjusttone(String) - Target tone ('professional', 'casual', 'friendly')
Returns: Promise - Adjusted text
Join a collaboration session.
editor.joinCollaboration('doc-123', 'user-456', 'John Doe');Parameters:
channelId(String) - Document channel IDuserId(String) - User IDuserName(String) - Display name
Leave the current collaboration session.
editor.leaveCollaboration();Get list of active collaborators.
const users = editor.getActiveUsers();Returns: Array - List of active users
Set current user information.
editor.setUserInfo({
userId: 'user-123',
userName: 'Jane Smith',
userColor: '#ff6b6b',
avatar: 'https://example.com/avatar.jpg'
});Parameters:
userInfo(Object) - User information
Encrypt content using configured encryption.
const encrypted = await editor.encryptContent(sensitiveText);Parameters:
content(String) - Content to encrypt
Returns: Promise - Encrypted content
Decrypt encrypted content.
const decrypted = await editor.decryptContent(encrypted);Parameters:
encryptedContent(String) - Encrypted content
Returns: Promise - Decrypted content
Get current authenticated user.
const user = editor.getCurrentUser();Returns: Object - User information
Check if current user has permission.
const canEdit = editor.hasPermission('write', 'document');Parameters:
action(String) - Action to checkresource(String) - Resource to check
Returns: Boolean - Permission status
Start recording voice comment.
editor.startVoiceRecording();Stop recording voice comment.
editor.stopVoiceRecording();Start a video call session.
await editor.startVideoCall();Returns: Promise - Video call session
End the current video call.
editor.endVideoCall();Open image editor for the specified image.
await editor.editImage('path/to/image.jpg');Parameters:
imageUrl(String) - URL of image to edit
Returns: Promise - Edited image data
Start a workflow process.
const id = editor.startWorkflow('approval-process', 'doc-123', 'user-456');Parameters:
workflowId(String) - Workflow template IDdocumentId(String) - Document IDinitiatedBy(String) - User who started workflow
Returns: String - Workflow instance ID
Submit document for approval at specified stage.
await editor.submitForApproval('review');Parameters:
stage(String) - Approval stage
Returns: Promise - Submission result
Create a new document version.
const version = editor.createVersion('Added new section', {
author: 'john@example.com',
timestamp: new Date()
});Parameters:
message(String) - Version messageauthor(Object) - Author information
Returns: Object - Version information
Restore a previous version.
const success = editor.restoreVersion('version-abc123');Parameters:
versionId(String) - Version ID to restore
Returns: Boolean - Success status
Use a document template.
editor.useTemplate('project-proposal', {
project_name: 'AI Integration',
budget: 150000
});Parameters:
templateId(String) - Template IDvariables(Object) - Template variables
Create a new template.
editor.createTemplate({
id: 'my-template',
name: 'My Template',
content: '<h1>{{title}}</h1><p>{{content}}</p>',
variables: ['title', 'content']
});Parameters:
template(Object) - Template definition
Get current performance metrics.
const metrics = editor.getPerformanceMetrics();
console.log('FPS:', metrics.fps);
console.log('Memory:', metrics.memory);Returns: Object - Performance metrics
Manually trigger cleanup of unused resources.
editor.cleanup();Enable performance debugging mode.
editor.enablePerformanceDebugging();Add event listener.
editor.on('contentChanged', (content) => {
console.log('Content changed:', content);
});Parameters:
event(String) - Event namecallback(Function) - Event handler
Remove event listener.
editor.off('contentChanged', handler);Parameters:
event(String) - Event namecallback(Function) - Event handler to remove
Emit custom event.
editor.emit('customEvent', { data: 'value' });Parameters:
event(String) - Event namedata(Any) - Event data
Fired when content changes.
editor.on('contentChanged', (content) => {
console.log('New content:', content);
});Callback Parameters:
content(String) - New content
Fired when text selection changes.
editor.on('selectionChanged', (selection) => {
console.log('Selection:', selection);
});Callback Parameters:
selection(Object) - Selection information
Fired when a user joins collaboration.
editor.on('userJoined', (user) => {
console.log(`${user.name} joined`);
});Callback Parameters:
user(Object) - User information
Fired when a user leaves collaboration.
editor.on('userLeft', (user) => {
console.log(`${user.name} left`);
});Callback Parameters:
user(Object) - User information
Fired when remote user makes changes.
editor.on('remoteChange', (change) => {
console.log('Remote change:', change);
});Callback Parameters:
change(Object) - Change information
Fired when AI request starts.
editor.on('aiRequestStarted', (request) => {
console.log('AI request started:', request);
});Fired when AI request completes.
editor.on('aiRequestCompleted', (result) => {
console.log('AI result:', result);
});Fired when AI request fails.
editor.on('aiError', (error) => {
console.error('AI error:', error);
});Fired when performance metrics are updated.
editor.on('performanceMetric', (metric) => {
console.log(`${metric.name}: ${metric.value}`);
});Fired when performance alert is triggered.
editor.on('performanceAlert', (alert) => {
console.warn('Performance alert:', alert);
});| Option | Type | Default | Description |
|---|---|---|---|
container |
String/Element | - | Container selector or element |
height |
String | '300px' | Editor height |
width |
String | '100%' | Editor width |
theme |
String | 'light' | Editor theme |
placeholder |
String | '' | Placeholder text |
readOnly |
Boolean | false | Read-only mode |
toolbar |
Boolean/Array | true | Toolbar configuration |
| Option | Type | Default | Description |
|---|---|---|---|
ai.enabled |
Boolean | false | Enable AI features |
ai.provider |
String | 'openai' | AI provider |
ai.apiKey |
String | - | API key |
ai.model |
String | 'gpt-3.5-turbo' | AI model |
ai.features |
Object | {} | AI feature settings |
| Option | Type | Default | Description |
|---|---|---|---|
collaboration.enabled |
Boolean | false | Enable collaboration |
collaboration.channelId |
String | - | Document channel ID |
collaboration.userId |
String | - | User ID |
collaboration.userName |
String | - | Display name |
collaboration.maxUsers |
Number | 10 | Max concurrent users |
| Option | Type | Default | Description |
|---|---|---|---|
encryption.enabled |
Boolean | false | Enable encryption |
encryption.algorithm |
String | 'AES-GCM' | Encryption algorithm |
encryption.keySize |
Number | 256 | Key size in bits |
sso.enabled |
Boolean | false | Enable SSO |
sso.provider |
String | 'saml' | SSO provider |
| Option | Type | Default | Description |
|---|---|---|---|
performance.virtualScrolling |
Boolean | false | Virtual scrolling |
performance.lazyLoading |
Boolean | false | Lazy loading |
performance.webWorkers |
Boolean | false | Web workers |
performance.memoryLimit |
String | '100MB' | Memory limit |
interface EditorOptions {
container: HTMLElement | string;
height?: string;
width?: string;
theme?: 'light' | 'dark';
placeholder?: string;
readOnly?: boolean;
toolbar?: boolean | string[];
ai?: AIConfig;
collaboration?: CollaborationConfig;
encryption?: EncryptionConfig;
// ... other options
}interface AIConfig {
enabled: boolean;
provider?: string;
apiKey?: string;
model?: string;
features?: {
smartSuggestions?: boolean;
contentGeneration?: boolean;
grammarCheck?: boolean;
};
}interface User {
id: string;
name: string;
email?: string;
avatar?: string;
role?: string;
permissions?: string[];
}Thrown when trying to use editor before initialization.
try {
editor.getContent();
} catch (error) {
if (error instanceof EditorNotInitializedError) {
console.error('Editor not initialized');
}
}Thrown when AI provider fails.
editor.on('aiError', (error) => {
if (error.code === 'INVALID_API_KEY') {
console.error('Invalid API key');
}
});Thrown when collaboration fails.
editor.on('collaborationError', (error) => {
if (error.code === 'CONNECTION_LOST') {
console.error('Connection lost');
}
});