PHP Classes

File: public/js/tinymce/src/plugins/anchor/src/main/js/core/Anchor.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/plugins/anchor/src/main/js/core/Anchor.js   Download  
File: public/js/tinymce/src/plugins/anchor/src/main/js/core/Anchor.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: GoLavaCMS
Publish content on Web pages with SEO support
Author: By
Last change:
Date: 6 years ago
Size: 1,335 bytes
 

Contents

Class file image Download
/** * Anchor.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ define( 'tinymce.plugins.anchor.core.Anchor', [ ], function () { var isValidId = function (id) { // Follows HTML4 rules: https://www.w3.org/TR/html401/types.html#type-id return /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id); }; var getId = function (editor) { var selectedNode = editor.selection.getNode(); var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === ''; return isAnchor ? (selectedNode.id || selectedNode.name) : ''; }; var insert = function (editor, id) { var selectedNode = editor.selection.getNode(); var isAnchor = selectedNode.tagName === 'A' && editor.dom.getAttrib(selectedNode, 'href') === ''; if (isAnchor) { selectedNode.removeAttribute('name'); selectedNode.id = id; } else { editor.focus(); editor.selection.collapse(true); editor.execCommand('mceInsertContent', false, editor.dom.createHTML('a', { id: id })); } }; return { isValidId: isValidId, getId: getId, insert: insert }; } );