Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4833

CKEditor fails to initialized if added to a closed detail component

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 9.6.0
    • 8.0.5, 9.5.1.1
    • Components
    • Security Level: Jimmy

      Steps to Reproduce

      Run fiddle

      https://zkfiddle.org/sample/1r0q5hl/2-ckeditor-in-detail

      Open detail

      Current Result

       Editor cannot be used, text zone fails to initialize.

      Clicking editor controls will throw:

       

      Uncaught TypeError: Cannot read property 'getSelection' of undefined
          at CKEDITOR.dom.selection.getNative (ckez.wpd:475)
          at new CKEDITOR.dom.selection (ckez.wpd:473)
          at a.CKEDITOR.editor.getSelection (ckez.wpd:471)
          at new CKEDITOR.plugins.undo.Image (ckez.wpd:1264)
          at CKEDITOR.plugins.undo.UndoManager.save (ckez.wpd:1258)
          at a.b (ckez.wpd:1253)
          at a.l (ckez.wpd:13)
          at a.<anonymous> (ckez.wpd:15)
          at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckez.wpd:16)
          at a.execCommand (ckez.wpd:295)
      getNative @ ckez.wpd:475
      CKEDITOR.dom.selection @ ckez.wpd:473
      CKEDITOR.editor.getSelection @ ckez.wpd:471
      CKEDITOR.plugins.undo.Image @ ckez.wpd:1264
      save @ ckez.wpd:1258
      b @ ckez.wpd:1253
      l @ ckez.wpd:13
      (anonymous) @ ckez.wpd:15
      CKEDITOR.editor.CKEDITOR.editor.fire @ ckez.wpd:16
      execCommand @ ckez.wpd:295
      CKEDITOR.tools.extend.click @ ckez.wpd:703
      execute @ ckez.wpd:704
      (anonymous) @ ckez.wpd:705
      (anonymous) @ ckez.wpd:36
      callFunction @ ckez.wpd:36
      onclick @ ckeditor95-2.zul:1
      

       

      Expected Result

       Editor initialized properly when added to the page / when detail is opened

      Debug Information

      The node of detail will be moved if open/close.
      CKeditor uses an iframe as an editable area.
      If an iframe was moved, the content will be unloaded: https://stackoverflow.com/q/28613526

      Workaround

      Call restore on the detail content to force the editor to check its initialization status.

       

      <script><![CDATA[ 
      	zk.afterLoad("zkex.grid", function () {
      	    var _xDetail = {};
      	    zk.override(zkex.grid.Detail.prototype, _xDetail, {
      	        open: function() {
      				var result = _xDetail.open.apply(this, arguments);
      				zWatch.fireDown('onRestore', this);
      				return result;
      	        }
      	     });
      	});
      ]]></script>
      

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Time Spent - 2 hours, 30 minutes Remaining Estimate - 1 hour, 30 minutes
                1h 30m
                Logged:
                Time Spent - 2 hours, 30 minutes Remaining Estimate - 1 hour, 30 minutes
                2h 30m