NewsPublisher Issues with RTE

I’m attempting to configure NP to load TinyMCE for both the content field and a richtext TV and am experiencing a couple issues.

Firstly, some of the time, the resource containing the NP snippet loads with the following css inserted into the textarea (within the div of class np-*-container) that contains the fields shown by the snippet:

style="visibility: hidden;"

There is a console error for the theme.min.js file that seems related to the above:

theme.min.js:formatted:6614 Uncaught TypeError: Cannot read properties of undefined (reading 'add')
    at Object.<anonymous> (theme.min.js:formatted:6614)
    at Object.each$2 [as each] (tinymce.js?v=5.0.16:2300)
    at theme.min.js:formatted:6613
    at theme.min.js:formatted:6621
(anonymous) @ theme.min.js:formatted:6614
each$2 @ tinymce.js?v=5.0.16:2300
(anonymous) @ theme.min.js:formatted:6613
(anonymous) @ theme.min.js:formatted:6621

Secondly, sometimes these fields do show when the NP resource loads, and in these instances, the RTE is not available and I get this console error, referencing the TinyMCE init code injected into the page by the snippet:

index.php?id=30:114 Uncaught ReferenceError: tinymce is not defined
    at index.php?id=30:114
(anonymous) @ index.php?id=30:114

Finally, submissions of the NP form do not create new resources. I’m sure this is related to the JS erro, but worth mentioning. Here again, no errors are produced in the MODX log.

Here’s the snippet call in my NP resource. I added the tinysource reference after making this post, but get the same uncaught reference error as above:

[[NewsPublisher?
 &initrte=`1`
 &rtcontent=`1`
 &show=`longtitle,content,journalEntry`
 &initfilebrowser=`1`
 &published=`1`
 &parentid=`30`
 &template=`11`
 &hidemenu=`1`
 &presets=`pagetitle:[[!+nowdate:default=`now`:strtotime:date=`%d %B %Y`]],menutitle:[[!+nowdate:default=`now`:strtotime:date=`%d %B %Y`]],longtitle:[[!+nowdate:default=`now`:strtotime:date=`%d %B %Y`]]`
 &published_default=`1`
 &hidemenu_default=`1`
 &cacheable_default=`1`
 &searchable_default=`1`
 &tinysource=`assets/components/newspublisher/js/tinymce.min.js`
]]

I don’t think this is germane, but this occurs on a site served locally using MAMP. There are no errors in either the MAMP or MODX logs.

This forum s/w won’t let me edit my original post, so replying to it with the following update:

After encountering the above issues, I force removed NP and re-installed it.

There are no editable rte fields available, despite having the parameters in the snippet call. Also, I removed the &tinysource parameter so that the cdn js file is used.

With this file in use, I now receive the following console error:

Uncaught TypeError: Cannot read properties of undefined (reading 'add')
   at Object.<anonymous> (theme.min.js:formatted:6614)
   at Object.each$2 [as each] (tinymce.js?v=5.0.16:2300)
   at theme.min.js:formatted:6613
   at theme.min.js:formatted:6621

I found similar issues reported here, with the resolution being to ensure that the theme files and core tinymcs js are all updated to the same version.

The code referenced by the error above (see below) looks like it’s trying to access a theme called ‘modern’. Again, I assume this should reference cdn files.

    w.each(yr(), function(e, t) {
        v.add(t, e)
    }),
    xr(window.tinymce ? window.tinymce : {}),
    r.add("modern", function(e) {
        return Ji.setup(e),
        $t(e)
    })

Any thoughts on this are appreciated. The solution I’m trying to put in place could really benefit from the use of NP.

Finally sorted this out - there was a conflict between NP and tinyMCE5, which was loaded by another extra on this site.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.