J4 Issue ?
avatar PhilETaylor
PhilETaylor
19 May 2018

Steps to reproduce the issue

Edit article, select CMS Content dropdown, select read more.

Expected result

read more added to WYSIWYG

Actual result

JS Error

Uncaught TypeError: (intermediate value)(intermediate value)(intermediate value).match is not a function

screen recording 2018-05-19 at 09 04 pm

System information (as much as possible)

79fd949
Google chrome

avatar PhilETaylor PhilETaylor - open - 19 May 2018
avatar joomla-cms-bot joomla-cms-bot - change - 19 May 2018
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 19 May 2018
avatar PhilETaylor PhilETaylor - change - 19 May 2018
Title
[4.0] Cannot add page break in editor of default install
[4.0] Cannot add read more in editor of default install
avatar PhilETaylor PhilETaylor - edited - 19 May 2018
avatar PhilETaylor PhilETaylor - change - 19 May 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 19 May 2018
avatar PhilETaylor PhilETaylor - change - 19 May 2018
The description was changed
avatar PhilETaylor PhilETaylor - edited - 19 May 2018
avatar brianteeman
brianteeman - comment - 19 May 2018

Could not replicate

readmore

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar carlitorweb
carlitorweb - comment - 19 May 2018

I can not replicate it either
readmore

avatar PhilETaylor PhilETaylor - comment - 19 May 2018
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 May 2018
Status New Discussion
avatar franz-wohlkoenig franz-wohlkoenig - change - 20 May 2018
Category com_content JavaScript
avatar infograf768
infograf768 - comment - 20 May 2018

I CAN replicate on Firefox and Safari.
Those that can't should test from last staging.

Exactly the same error pointed by @PhilETaylor

TypeError: (intermediate value).match is not a function[Learn More]
admin-article-readmore.min.js:1:161
window.insertReadmore
http://localhost:8888/newfolder/joomla40/media/com_content/js/admin-article-readmore.min.js:1:161
anonymous
http://localhost:8888/newfolder/joomla40/media/editors/tinymce/js/tinymce.min.js:3:1
setupEditor/</n.onclick
http://localhost:8888/newfolder/joomla40/media/editors/tinymce/js/tinymce.min.js:1:871
vm/r.fire
http://localhost:8888/newfolder/joomla40/media/vendor/tinymce/tinymce.min.js:1:187603
fire
http://localhost:8888/newfolder/joomla40/media/vendor/tinymce/themes/modern/theme.min.js:1:30800
a
http://localhost:8888/newfolder/joomla40/media/vendor/tinymce/themes/modern/theme.min.js:1:35026
u
http://localhost:8888/newfolder/joomla40/media/vendor/tinymce/tinymce.min.js:1:11719
C
http://localhost:8888/newfolder/joomla40/media/vendor/tinymce/tinymce.min.js:1:11870
l
http://localhost:8888/newfolder/joomla40/media/vendor/webcomponentsjs/js/webcomponents-hi-sd-ce.min.js:1:25807
avatar infograf768 infograf768 - change - 20 May 2018
Status Discussion Confirmed
avatar infograf768
infograf768 - comment - 20 May 2018

Setting to confirmed


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/20477.

avatar dgrammatiko
dgrammatiko - comment - 20 May 2018

Here is the code for admin-article-readmore.es6.js:

(() => {
  'use strict';
  const options = window.Joomla.getOptions('xtd-readmore');

  window.insertReadmore = (editor) => {
    if (!options) {
      // Something went wrong!
      throw new Error(`XTD Button 'read more' not properly initialized`)
    }

    const content = window.Joomla.editors.instances[editor].getValue();

    if (content && !content.match(/<hr\s+id=("|')system-readmore("|')\s*\/*>/i)) {
      Joomla.editors.instances[editor].replaceSelection('<hr id="system-readmore">');
    } else {
      // TODO replace with joomla-alert
      alert(options.exists);
      return false;
    }
    return true;
  };
})();

If someone can make a pr I would really appreciate it ?

avatar carlitorweb
carlitorweb - comment - 20 May 2018

Thank @infograf768, now yes. I can replicate it. I thought I had the last staging.

avatar infograf768
infograf768 - comment - 20 May 2018

@dgrammatiko
Looks like we have to modify
content.match to editor.match

Files concerned
/media/com_content/js/admin-article-readmore.es6.js
/media/com_content/js/admin-article-readmore.js

And then correct the minified files.

If I do that, no more errors.
Want me to do the PR?

NOTE: What we have in core is different from what you pasted above

avatar dgrammatiko
dgrammatiko - comment - 20 May 2018

Looks like we have to modify content.match to editor.match

Nope, I've already provided the code (it's also tested)

avatar infograf768
infograf768 - comment - 20 May 2018

@dgrammatiko
I just wanted to help. The issue is NOT here in the e6 but in the admin-article-readmore.js and minified
Please do as you wish.

avatar dgrammatiko
dgrammatiko - comment - 20 May 2018

the admin-article-readmore.js is generated from the es6 file, that's the source

avatar infograf768
infograf768 - comment - 20 May 2018

OK, then do it as I don't know how to.

avatar dgrammatiko
dgrammatiko - comment - 20 May 2018

BTW, with your proposal I guess you don't have an error but also you can insert as many read more (hr) as you like

avatar brianteeman brianteeman - change - 20 May 2018
Labels Added: J4 Issue
avatar brianteeman brianteeman - labeled - 20 May 2018
avatar ghazal
ghazal - comment - 2 Jun 2018

@dgrammatiko
Looks like nobody made a PR with your code,
that works alright BTW.

I can do it but I need some details:
if I understand properly, the modified code should be applied to:
admin-article-readmore.es6.js
??
what I don't get is how to minify it. Can I use a minifying tool online ?
Or else ?

avatar laoneo
laoneo - comment - 2 Jun 2018

Yes in the es6 file. How to transpile to es5 and then minify can be found in #20396. You need npm installed.

avatar ghazal
ghazal - comment - 2 Jun 2018

I postponed until now my digging into npm. Guess this is the opportunity.
Tks for your tuto.

avatar laoneo
laoneo - comment - 2 Jun 2018

Thank your for stepping up to help.

avatar brianteeman brianteeman - change - 21 Jul 2018
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2018-07-21 12:48:32
Closed_By brianteeman
avatar brianteeman brianteeman - close - 21 Jul 2018
avatar brianteeman
brianteeman - comment - 21 Jul 2018

closed see #21207

Add a Comment

Login with GitHub to post a comment