CoreFiles by mySites.guru
admin-article-readmore.js29 lines, 1,097 bytes, from Joomla_5.2.3-Stable-Full_Package.zip
Raw History Compare with 5.2.2
md5
654e3b96c62cfeba76a261d333d43812
sha1
2084710b73bdb020ca6bda97df4fe11623b23f82
sha256
550ebee8595d1ec976abccd3413f93456a5aede8d8faa480945ea0ad27a7df22
import { JoomlaEditor, JoomlaEditorButton } from 'editor-api';
import JoomlaDialog from 'joomla.dialog';

/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
const insertReadmoreHandler = editor => {
  const content = editor.getValue();
  if (!content) {
    editor.replaceSelection('<hr id="system-readmore">');
  } else if (content && !content.match(/<hr\s+id=("|')system-readmore("|')\s*\/*>/i)) {
    editor.replaceSelection('<hr id="system-readmore">');
  } else {
    JoomlaDialog.alert(Joomla.Text._('PLG_READMORE_ALREADY_EXISTS'));
  }
};

// @TODO: Remove in Joomla 6
window.insertReadmore = () => {
  // eslint-disable-next-line no-console
  console.warn('Method window.insertReadmore() is deprecated, use button action "insert-readmore."');
  const editor = JoomlaEditor.getActive();
  if (!editor) {
    throw new Error('An active editor are not available');
  }
  insertReadmoreHandler(editor);
};
JoomlaEditorButton.registerAction('insert-readmore', insertReadmoreHandler);

The same content is in 60 releases, Joomla 5.0.0-beta1 to 5.3.0-beta3. See them all, or every version of this file.