mirror of
https://github.com/codex-team/editor.js
synced 2026-03-17 08:05:47 +01:00
41 lines
927 B
TypeScript
41 lines
927 B
TypeScript
import type { BlockTool, BlockToolConstructorOptions } from '../../../../types';
|
|
import { createEditorWithTextBlocks } from './createEditorWithTextBlocks';
|
|
|
|
export const NESTED_EDITOR_ID = 'nested-editor';
|
|
|
|
/**
|
|
* Creates nested Editor instance with paragraph block
|
|
*/
|
|
export default class NestedEditor implements BlockTool {
|
|
private data: { text: string };
|
|
|
|
/**
|
|
*
|
|
* @param value - The constructor options for the block tool
|
|
*/
|
|
constructor(value: BlockToolConstructorOptions) {
|
|
this.data = value.data;
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public render(): HTMLDivElement {
|
|
const editorEl = Object.assign(document.createElement('div'), {
|
|
id: NESTED_EDITOR_ID,
|
|
});
|
|
|
|
editorEl.setAttribute('data-cy', NESTED_EDITOR_ID);
|
|
|
|
createEditorWithTextBlocks([ this.data.text ], { holder: NESTED_EDITOR_ID });
|
|
|
|
return editorEl;
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public save(): string {
|
|
return this.data.text;
|
|
}
|
|
}
|