pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

`insert-text` brick: insert into iframe-based editors from the parent (CKEditor 4, TinyMCE 6)

Open fregante opened this issue 1 year ago • 0 comments

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:

  1. Go to https://pbx.vercel.app/advanced-fields/
  2. In the sidebar, add the Insert Text at Cursor brick
  3. Set "Run in all frames" as it's the current solution to support iframed editors
  4. Focus CKEditor 5
  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:

  1. is CKE5 element? use pageScript.insertCKEditorData()
  2. is iframe? try iframe.contentDocument.execCommand()
  3. 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

fregante avatar Mar 14 '24 07:03 fregante