tinymce / tinymce-webcomponent

MIT License
15 stars 7 forks source link

tinymce.get() function doesn't appear to work in version 6.0.2 for the Web Component API #32

Open bob2517-whiteline opened 1 year ago

bob2517-whiteline commented 1 year ago

What is the current behavior? Describe the bug The tinymce.get() function doesn't appear to work for the Web Component API.

Please provide the steps to reproduce and if possible a minimal demo of the problem via fiddle.tiny.cloud or similar.

// Several editors are on the page at this point.
// The specific one mentioned below is displayed correctly on the page when the code below runs.
// The editor that is being retrieved is not the active instance.

// This ID is set on the tinymce-editor tag. On the <tinymce-editor> tag itself.
let thisTinyMCEEditor = 'oneOfSeveralEditors_1';

let el = document.getElementById(thisTinyMCEEditor);
// Correctly displays a tinymce-editor element:
console.log('el:', el);

let activeEditor = tinymce.get(thisTinyMCEEditor);
// Incorrectly displays "null":
console.log('activeEditor:', activeEditor);

What is the expected behavior? The editor specified by the ID should be retrieved by the get() function.

Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE? At least version 6.0.2. I didn't see any mentioned fix for this in later versions. Affects Chromium/Firefox.

Suggestion: is it trying to look in the shadow DOM for the tag?

lnewson commented 1 year ago

This doesn't appear to be related to TinyMCE and is instead related to the TinyMCE web component integration. The problem is that the integration isn't passing through the id specified and as such TinyMCE is generating one randomly for the target provided by the integration here: https://github.com/tinymce/tinymce-webcomponent/blob/main/src/main/ts/component/Editor.ts#L212-L218

As such I'm going to transfer this to the integration repo so it can be looked at by our integrations team.

exalate-issue-sync[bot] commented 1 year ago

Ref: INT-2957