PHP Classes

File: public/js/tinymce/src/core/src/main/js/selection/GetSelectionContent.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/core/src/main/js/selection/GetSelectionContent.js   Download  
File: public/js/tinymce/src/core/src/main/js/selection/GetSelectionContent.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: 2,404 bytes
 

Contents

Class file image Download
/** * GetSelectionContent.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.core.selection.GetSelectionContent', [ 'ephox.sugar.api.node.Element', 'tinymce.core.selection.EventProcessRanges', 'tinymce.core.selection.FragmentReader', 'tinymce.core.selection.MultiRange', 'tinymce.core.text.Zwsp' ], function (Element, EventProcessRanges, FragmentReader, MultiRange, Zwsp) { var getContent = function (editor, args) { var rng = editor.selection.getRng(), tmpElm = editor.dom.create("body"); var sel = editor.selection.getSel(), fragment; var ranges = EventProcessRanges.processRanges(editor, MultiRange.getRanges(sel)); args = args || {}; args.get = true; args.format = args.format || 'html'; args.selection = true; args = editor.fire('BeforeGetContent', args); if (args.isDefaultPrevented()) { editor.fire('GetContent', args); return args.content; } if (args.format === 'text') { return editor.selection.isCollapsed() ? '' : Zwsp.trim(rng.text || (sel.toString ? sel.toString() : '')); } if (rng.cloneContents) { fragment = args.contextual ? FragmentReader.read(Element.fromDom(editor.getBody()), ranges).dom() : rng.cloneContents(); if (fragment) { tmpElm.appendChild(fragment); } } else if (rng.item !== undefined || rng.htmlText !== undefined) { // IE will produce invalid markup if elements are present that // it doesn't understand like custom elements or HTML5 elements. // Adding a BR in front of the contents and then remoiving it seems to fix it though. tmpElm.innerHTML = '<br>' + (rng.item ? rng.item(0).outerHTML : rng.htmlText); tmpElm.removeChild(tmpElm.firstChild); } else { tmpElm.innerHTML = rng.toString(); } args.getInner = true; var content = editor.selection.serializer.serialize(tmpElm, args); if (args.format === 'tree') { return content; } args.content = editor.selection.isCollapsed() ? '' : content; editor.fire('GetContent', args); return args.content; }; return { getContent: getContent }; } );