Skip to content

Commit

Permalink
feat(uip-editor): add jsdoc for UIPEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed Jul 15, 2021
1 parent 5721ed6 commit a7fe18f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import {jsonAttr} from '@exadel/esl/modules/esl-base-element/core';

import {UIPPlugin} from '../core/plugin';

/**
* Config for customizing editor's behaviour
* @property {string} theme - editor's appearance theme
* @property {string} mode - text mode used
* @property {number} printMarginColumn - position of the vertical line for wrapping
* @property {number} warp - limit of characters before wrapping
*/
interface EditorConfig {
theme: string;
mode: string;
Expand All @@ -19,17 +26,20 @@ interface EditorConfig {

export class UIPEditor extends UIPPlugin {
public static is = 'uip-editor';
/** Default [config]{@link EditorConfig} used by editor */
public static defaultOptions = {
theme: 'ace/theme/chrome',
mode: 'ace/mode/html',
printMarginColumn: -1,
wrap: true,
};

/** Editor's [config]{@link EditorConfig} passed through attribute */
@jsonAttr()
public editorConfig: EditorConfig;
protected editor: Ace.Editor;

/** Merges [default config]{@link defaultOptions} with editor's [config]{@link editorConfig} */
protected get mergedEditorConfig(): EditorConfig {
const type = (this.constructor as typeof UIPEditor);
return Object.assign({}, type.defaultOptions, this.editorConfig || {});
Expand All @@ -40,6 +50,7 @@ export class UIPEditor extends UIPPlugin {
this.initEditor();
}

/** Initialization of Ace editor */
protected initEditor() {
this.innerHTML = '';
this.appendChild(this.$inner);
Expand All @@ -58,6 +69,8 @@ export class UIPEditor extends UIPPlugin {
this.model!.setHtml(this.editor.getValue(), this);
}, 1000);

/** Setting editor's value after markup changes
* @see [onRootStateChange]{@link UIPPlugin#_onRootStateChange} */
@bind
protected _onRootStateChange(): void {
if (this.model!.lastModifier === this) return;
Expand Down

0 comments on commit a7fe18f

Please sign in to comment.