editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

When Editor is on readonly' mode editor throw warning "EventDispatcher .off(): there is no subscribers for event"

Open seemaPatelTest opened this issue 2 years ago • 4 comments

If Editor.js has 'readonly' mode true, then console tab display warning EventDispatcher .off(): there is no subscribers for event "editor mobile layout toggled". Probably, .off() called before .on()

Expected behavior: No warning will display for read only mode

Screenshots: image

I tested this on vue3 project. Below is code snippet

import { onMounted, ref } from 'vue'
import EditorJS from '@editorjs/editorjs'
import Header from '@editorjs/header'

const editorInstance = ref()

onMounted(() => {
  const editorEl = document.getElementById('editorJs')
  if (!editorEl) return
  editorInstance.value = new EditorJS({
    holder: editorEl,
    readOnly: true,
    tools: {
      header: {
        class: Header,
        inlineToolbar: ['link'],
        config: {
          levels: [1, 2, 3, 4, 5, 6],
          defaultLevel: 1,
        },
      },
    },
  })
})
</script>
<template>
  <div id="editorJs">
  </div>
</template>

seemaPatelTest avatar Jul 10 '24 13:07 seemaPatelTest

I have the same problem

dxvgef avatar Jan 07 '25 09:01 dxvgef

I guess temporary fix. Try this :

{
    // ... config
    readOnly: false, // optional because default value is false
    onReady: async () => {
        await editor.readOnly.toggle(true); // toggle readonly mode only when editor is up !
    }
}

FactorSpeed avatar Jan 23 '25 16:01 FactorSpeed

Will this issue be addressed in the future? Still having the same problem in React dev mode:/

leonnicklas avatar Dec 16 '25 13:12 leonnicklas

The issue was caused by incorrect toolbar initialization when the editor was instantiated with read-only mode enabled. Resolved since v2.31.1.

akulistus avatar Jan 08 '26 22:01 akulistus