CoreFiles by mySites.guru
admin-article-readmore.js29 lines, 1,057 bytes, from Joomla_6.0.2-Stable-Full_Package.zip
Raw History Compare with 6.0.1
md5
373f351537f2c3ee28d68fedfe88e7a4
sha1
4b778ebf892d86ac8a1fa2f77f8eac56dde08191
sha256
45dc2e6b106ddec06d76cb08e883b96be7cafa5ea46f031a10166deaae8e68a7
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 = () => {
  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 76 releases, Joomla 5.4.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.