Uncaught TypeError: Cannot read property 'wysiwyg' of undefined

I’m attempting to do some customization to CKEDITOR as outlined here:

https://pimcore.com/docs/6.x/Development_Documentation/Documents/Editables/WYSIWYG.html

I have the following in my services.yml:

AppBundle\EventListener\PimcoreAdminListener:
tags:
- { name: kernel.event_listener, event: pimcore.bundle_manager.paths.js, method: addJsFiles }

I have the following in AppBundle\EventListener\PimcoreAdminListener:

public function addJsFiles(PathsEvent $event)
{
    $event->setPaths(array_merge($event->getPaths(), [
        '/bundles/app/js/pimcore/editmode.js',
    ]));
}

And following in /bundles/app/js/pimcore/editmode.js:

pimcore.document.tags.wysiwyg.defaultEditorConfig = pimcore.document.tags.wysiwyg.defaultEditorConfig || {};
pimcore.document.tags.wysiwyg.defaultEditorConfig.disableNativeSpellChecker = false;
pimcore.document.tags.wysiwyg.defaultEditorConfig.removePlugins = 'liststyle,tableselection,tabletools,tableresize,contextmenu';

I get the error message:

Uncaught TypeError: Cannot read property 'wysiwyg' of undefined

It seems to be an issue going back awhile (it does it in 6.5.2 as well as 6.2.3).

Try with ‘pimcore.bundle_manager.paths.editmode_js’ event

Thank you for the reply! The error message went away, but it does not seem to ever actually fire that event. Does it inject editmode.js into the page when the admin page loads? Or at what point is it supposed to fire?

EDIT: I tried modifying the approach to more closely match the documentation. I pulled the editmode code to its own class and registered it separately:

<?php

namespace AppBundle\EventSubscriber;

use Pimcore\Event\BundleManager\PathsEvent;
use Pimcore\Event\BundleManagerEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class AdminEditSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            BundleManagerEvents::EDITMODE_JS_PATHS => 'onEditmodeJsPaths',
            BundleManagerEvents::EDITMODE_CSS_PATHS => 'onEditmodeCssPaths',
        ];
    }

    public function onEditmodeJsPaths(PathsEvent $event)
    {
        $event->setPaths(array_merge($event->getPaths(), [
            '/bundles/app/js/pimcore/editmode.js'
        ]));
    }

    public function onEditmodeCssPaths(PathsEvent $event)
    {
    }    
}

I can confirm it’s at least getting to the getSubscribedEvents(), but it never seems to fire onEditmodeJsPaths. Am I doing something wrong?