pixiebrix-extension
pixiebrix-extension copied to clipboard
`insert-text` brick: insert into iframe-based editors from the parent (CKEditor 4, TinyMCE 6)
As reported in https://github.com/pixiebrix/pixiebrix-extension/issues/7779, using the "insert text" into all frames means that all frames receive the "insert text" message, so they all insert it regardless of the field the user actually selected.
To Reproduce
Steps to reproduce the behavior:
- Go to https://pbx.vercel.app/advanced-fields/
- In the sidebar, add the
Insert Text at Cursorbrick - Set "Run in all frames" as it's the current solution to support iframed editors
- Focus CKEditor 5
- Notice how the text is inserted into CKE4 too
Technically this isn't a bug, we should not ask users to use "Run in all frames". We should support iframe-based editors from their parent frame.
For example:
- is CKE5 element? use
pageScript.insertCKEditorData() - is iframe? try
iframe.contentDocument.execCommand() - otherwise use
document.execCommand()
Also mentioned in https://github.com/pixiebrix/pixiebrix-extension/issues/7774#issuecomment-1978679850
Desktop
- Extension Version: 1.8.10
Follows
- https://github.com/pixiebrix/pixiebrix-extension/pull/7918