mirror of
https://github.com/codex-team/editor.js
synced 2026-03-15 15:15:47 +01:00
* fix: prevent inline toolbar from closing in nested instance of editor * docs: updated changelog.md with fix description * fix: fix import to use `type` --------- Co-authored-by: Peter <specc.dev@gmail.com>
31 lines
813 B
TypeScript
31 lines
813 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 };
|
|
|
|
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;
|
|
}
|
|
}
|