PHP Classes

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

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra  >  GoLavaCMS  >  public/js/tinymce/src/core/src/main/js/selection/TableCellSelection.js  >  Download  
File: public/js/tinymce/src/core/src/main/js/selection/TableCellSelection.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: 4 years ago
Size: 1,543 bytes
 

Contents

Class file image Download
/**
 * TableCellSelection.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.TableCellSelection',
  [
    'ephox.katamari.api.Arr',
    'ephox.sugar.api.node.Element',
    'ephox.sugar.api.search.SelectorFilter',
    'tinymce.core.dom.ElementType',
    'tinymce.core.selection.MultiRange'
  ],
  function (Arr, Element, SelectorFilter, ElementType, MultiRange) {
    var getCellsFromRanges = function (ranges) {
      return Arr.filter(MultiRange.getSelectedNodes(ranges), ElementType.isTableCell);
    };

    var getCellsFromElement = function (elm) {
      var selectedCells = SelectorFilter.descendants(elm, 'td[data-mce-selected],th[data-mce-selected]');
      return selectedCells;
    };

    var getCellsFromElementOrRanges = function (ranges, element) {
      var selectedCells = getCellsFromElement(element);
      var rangeCells = getCellsFromRanges(ranges);
      return selectedCells.length > 0 ? selectedCells : rangeCells;
    };

    var getCellsFromEditor = function (editor) {
      return getCellsFromElementOrRanges(MultiRange.getRanges(editor.selection.getSel()), Element.fromDom(editor.getBody()));
    };

    return {
      getCellsFromRanges: getCellsFromRanges,
      getCellsFromElement: getCellsFromElement,
      getCellsFromElementOrRanges: getCellsFromElementOrRanges,
      getCellsFromEditor: getCellsFromEditor
    };
  }
);
For more information send a message to info at phpclasses dot org.