import {test, expect} from '../../fixtures/test' // contenteditable="false" creates non-editable islands inside TinyMCE. // Canvas uses this pattern for inline media embeds, equation widgets, and // placeholder elements that the user cannot directly edit. The surrounding // editable content must still be preserved across round-trips. test.describe('contenteditable="false" non-editable island elements', () => { test.beforeEach(async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() }) async function setAndGet(page: any, html: string): Promise { return page.evaluate((content: string) => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent(content) // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent() }, html) } test('contenteditable="false" span — surrounding text preserved', async ({page}) => { const content = await setAndGet( page, '

Before Non-editable widget after.

', ) expect(content).toContain('Before') expect(content).toContain('after') }) test('contenteditable="false" div — surrounding paragraphs preserved', async ({page}) => { const content = await setAndGet( page, '

Intro paragraph.

Locked content block

Continued text here.

', ) expect(content).toContain('Intro paragraph') expect(content).toContain('Continued text here') }) test('canvas equation placeholder with contenteditable=false — text preserved', async ({ page, }) => { const content = await setAndGet( page, '

The formula x²+y²=r² describes a circle.

', ) expect(content).toContain('describes a circle') }) test('contenteditable="true" nested inside false — text preserved', async ({page}) => { const content = await setAndGet( page, '

Nested editable inside non-editable

', ) expect(typeof content).toBe('string') }) test('multiple contenteditable=false spans in paragraph — text around preserved', async ({ page, }) => { const content = await setAndGet( page, '

Start [Widget A] middle [Widget B] end.

', ) expect(content).toContain('Start') expect(content).toContain('middle') expect(content).toContain('end') }) })