Wysiwyg-editor: `codeView.update` event doesn't fire

Created on 3 Sep 2019  路  5Comments  路  Source: froala/wysiwyg-editor

Expected behavior.

Event callback should fire when switching to html view.

Actual behavior.

Event does not fire when switching to html view.

Steps to reproduce the problem.

codeView.update documentation

import FroalaEditor from "froala-editor"
import "froala-editor/js/plugins/code_view.min.js"

const editor = new FroalaEditor(node, {
  events: {
    "codeView.update": () => {
      debugger
    }
  }
})

CodeMirror is not used.

Editor version.

[email protected] (via NPM)

OS.

All OSes

Browser.

All Browsers

bug version 3

All 5 comments

Just an observation -> the event fires when you switch to fullscreen mode.

I just recently figured that out as well. It seems that event name is used to indicate the desired side-effect which is an anti-pattern. Event names should indicate what is happening, not what their intended effect should be.

Had the same issue. Workaround: Listen to the 'commands.after' event, it will fire when clicking the code view button (cmd === 'html') and the fullscreen button (cmd === 'fullscreen').

Any update on this?

..as mentioned above, we end up forcing fullscreen on code view:

events: {
  'commands.after': function (cmd) {
    if (cmd == 'html' && this.codeView.isActive() && !this.fullscreen.isActive()) {
      this.fullscreen.toggle();
    }
  }
}

I have updated code to fire event when you switch from code view to html view. It will be available in 3.0.7 release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adilsonb picture adilsonb  路  3Comments

homoky picture homoky  路  3Comments

bbugh picture bbugh  路  3Comments

lohiaad picture lohiaad  路  4Comments

bnjmnfnk picture bnjmnfnk  路  4Comments