Browse Source

Move CustomRTE interface

pull/5649/head
Artur Arseniev 3 years ago
parent
commit
c088107a5d
  1. 3
      src/editor/index.ts
  2. 29
      src/rich_text_editor/config/config.ts
  3. 31
      src/rich_text_editor/index.ts

3
src/editor/index.ts

@ -78,7 +78,8 @@ import PageManager from '../pages';
import PanelManager from '../panels';
import ParserModule from '../parser';
import { CustomParserCss } from '../parser/config/config';
import RichTextEditorModule, { CustomRTE, RichTextEditorEvent } from '../rich_text_editor';
import RichTextEditorModule, { RichTextEditorEvent } from '../rich_text_editor';
import { CustomRTE } from '../rich_text_editor/config/config';
import SelectorManager, { SelectorEvent } from '../selector_manager';
import StorageManager, { StorageEvent } from '../storage_manager';
import { ProjectData } from '../storage_manager/model/IStorage';

29
src/rich_text_editor/config/config.ts

@ -1,3 +1,32 @@
export interface CustomRTE<T = any> {
/**
* If true, the returned HTML content will be parsed into Components, allowing
* the custom RTE to behave in the same way as the native one.
* If false, the HTML content will be used as it is in the canvas and the export code.
*/
parseContent?: boolean;
/**
* Create or enable the custom RTE.
*/
enable: (el: HTMLElement, rte: T | undefined) => T | Promise<T>;
/**
* Disable the custom RTE.
*/
disable: (el: HTMLElement, rte: T) => any | Promise<any>;
/**
* Get HTML content from the custom RTE.
* If not specified, it will use the innerHTML of the element (passed also as `content` in options).
*/
getContent?: (el: HTMLElement, rte: T | undefined) => string | Promise<string>;
/**
* Destroy the custom RTE.
* Will be triggered on editor destroy.
*/
destroy?: () => void;
[key: string]: unknown;
}
export interface RichTextEditorConfig {
/**
* Class name prefix for styles

31
src/rich_text_editor/index.ts

@ -44,7 +44,7 @@ import ComponentView from '../dom_components/view/ComponentView';
import EditorModel from '../editor/model/Editor';
import { createEl, cx, removeEl } from '../utils/dom';
import { hasWin, isDef, on } from '../utils/mixins';
import defaults, { RichTextEditorConfig } from './config/config';
import defaults, { CustomRTE, RichTextEditorConfig } from './config/config';
import RichTextEditor, { RichTextEditorAction } from './model/RichTextEditor';
export type RichTextEditorEvent = 'rte:enable' | 'rte:disable' | 'rte:custom';
@ -61,35 +61,6 @@ const events = {
custom: evCustom,
};
export interface CustomRTE<T = any> {
/**
* If true, the returned HTML content will be parsed into Components, allowing
* the custom RTE to behave in the same way as the native one.
* If false, the HTML content will be used as it is in the canvas and the export code.
*/
parseContent?: boolean;
/**
* Create or enable the custom RTE.
*/
enable: (el: HTMLElement, rte: T | undefined) => T | Promise<T>;
/**
* Disable the custom RTE.
*/
disable: (el: HTMLElement, rte: T) => any | Promise<any>;
/**
* Get HTML content from the custom RTE.
* If not specified, it will use the innerHTML of the element (passed also as `content` in options).
*/
getContent?: (el: HTMLElement, rte: T | undefined) => string | Promise<string>;
/**
* Destroy the custom RTE.
* Will be triggered on editor destroy.
*/
destroy?: () => void;
[key: string]: unknown;
}
interface ModelRTE {
currentView?: ComponentView;
}

Loading…
Cancel
Save