Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Cannot add read more in editor of default install #20477

Closed
PhilETaylor opened this issue May 19, 2018 · 19 comments
Closed

[4.0] Cannot add read more in editor of default install #20477

PhilETaylor opened this issue May 19, 2018 · 19 comments

Comments

@PhilETaylor
Copy link
Contributor

PhilETaylor commented May 19, 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

@PhilETaylor PhilETaylor changed the title [4.0] Cannot add page break in editor of default install [4.0] Cannot add read more in editor of default install May 19, 2018
@brianteeman
Copy link
Contributor

Could not replicate

readmore

@PhilETaylor

This comment was marked as abuse.

@carlitorweb
Copy link
Member

I can not replicate it either
readmore

@PhilETaylor

This comment was marked as abuse.

@infograf768
Copy link
Member

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

@infograf768
Copy link
Member

Setting to confirmed


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

@dgrammatiko
Copy link
Contributor

dgrammatiko commented May 20, 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 🙏

@carlitorweb
Copy link
Member

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

@infograf768
Copy link
Member

infograf768 commented May 20, 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

@dgrammatiko
Copy link
Contributor

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

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

@infograf768
Copy link
Member

@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.

@dgrammatiko
Copy link
Contributor

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

@infograf768
Copy link
Member

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

@dgrammatiko
Copy link
Contributor

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

@ghazal
Copy link
Contributor

ghazal commented Jun 2, 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 ?

@laoneo
Copy link
Member

laoneo commented Jun 2, 2018

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

@ghazal
Copy link
Contributor

ghazal commented Jun 2, 2018

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

@laoneo
Copy link
Member

laoneo commented Jun 2, 2018

Thank your for stepping up to help.

brianteeman added a commit to brianteeman/joomla-cms that referenced this issue Jul 21, 2018
PR for joomla#20477

When editing an article on the front end it ws not possible to insert a readmore link

This pr fixes that. Also test that it doesnt let you insert more than one readmore and that it still works in the admin
@brianteeman
Copy link
Contributor

closed see #21207

laoneo pushed a commit that referenced this issue Jul 31, 2018
* [4.0] Article readmore in frontend

PR for #20477

When editing an article on the front end it ws not possible to insert a readmore link

This pr fixes that. Also test that it doesnt let you insert more than one readmore and that it still works in the admin

* hound fixes

* consistenct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants