CoreFiles by mySites.guru
admin-article-readmore.js30 lines, 1,098 bytes, from Joomla_5.3.0-Stable-Full_Package.zip
Raw History Compare with 5.2.6
md5
0cf3b5365ccc8aa5555dbb6b17bac81d
sha1
da621ea20523073d2e64560471e77e94ccfe92dc
sha256
ac7321f3027b223a1bc877e79ac10265df641d862542cabb9fe4ba9af7154ab7
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 18 releases, Joomla 5.3.0-rc1 to 6.0.0-alpha3. See them all, or every version of this file.