Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The ImageResize plugin crashes if HtmlEmbed plugin has enabled showPreviews option #8433

Closed
psmyrek opened this issue Nov 9, 2020 · 1 comment · Fixed by #8444
Closed
Assignees
Labels
package:image squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@psmyrek
Copy link
Contributor

psmyrek commented Nov 9, 2020

📝 Provide detailed reproduction steps (if any)

The following code is sufficient to crash the editor:

import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import HtmlEmbed from '@ckeditor/ckeditor5-html-embed/src/htmlembed';
import Image from '@ckeditor/ckeditor5-image/src/image';
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize';

ClassicEditor
    .create( document.querySelector( '#editor' ), {
        plugins: [
            HtmlEmbed, Image, ImageResize
        ],
        htmlEmbed: {
            showPreviews: true
        }
    } )
    .then( editor => {
        window.editor = editor;
    } )
    .catch( err => {
        console.error( err.stack );
    } );
<div id="editor">
    <div class="raw-html-embed">
        <img src="sample.jpg">
    </div>
</div>

✔️ Expected result

Editor should not crash.

❌ Actual result

There is an Uncaught TypeError:

Uncaught TypeError: Cannot read property 'is' of null
    at Function._createAt (position.js:349)
    at DowncastWriter.createPositionAt (downcastwriter.js:1015)
    at resizer.js:138
    at View.change (view.js:477)
    at Resizer.attach (resizer.js:117)
    at WidgetResize.attachTo (widgetresize.js:129)
    at Document.<anonymous> (imageresizehandles.js:76)
    at Document.fire (emittermixin.js:209)
    at ImageLoadObserver._fireEvents (imageloadobserver.js:52)
    at ProxyEmitter.listenTo.useCapture (imageloadobserver.js:35)

📃 Other details

  • Browser: Firefox 82, Chrome 86
  • OS: Windows 10 x64
  • CKEditor version: 23.1.0
  • Installed CKEditor plugins:
    • HtmlEmbed
    • Image
    • ImageResize

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@psmyrek psmyrek added type:bug This issue reports a buggy (incorrect) behavior. package:image labels Nov 9, 2020
@Reinmar Reinmar added the squad:core Issue to be handled by the Core team. label Nov 9, 2020
@Reinmar Reinmar added this to the iteration 38 milestone Nov 9, 2020
@oleq
Copy link
Member

oleq commented Nov 9, 2020

ImageResizeHandles listens to imageLoaded event which fires for every img in the document. And this includes imgs in HTML embed previews. Narrowing this down should help.

jodator added a commit that referenced this issue Nov 20, 2020
Fix (image): Don't attach the image resizer to images inside the HTML embed preview. Closes #8433.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:image squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants