editor.js/test/cypress/support/utils/nestedEditorInstance.ts
Ilya Gorenburg b6ba44d610
fix: prevent inline toolbar from closing in nested instance of editor (#2780)
* 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>
2024-09-14 01:12:46 +03:00

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;
}
}