PHP Classes

File: public/js/tinymce/src/core/src/main/js/delete/InlineFormatDelete.js

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

Contents

Class file image Download
/** * InlineFormatDelete.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.delete.InlineFormatDelete', [ 'ephox.katamari.api.Arr', 'ephox.katamari.api.Fun', 'ephox.sugar.api.node.Element', 'ephox.sugar.api.search.Traverse', 'tinymce.core.caret.CaretPosition', 'tinymce.core.delete.DeleteElement', 'tinymce.core.delete.DeleteUtils', 'tinymce.core.dom.ElementType', 'tinymce.core.dom.Parents', 'tinymce.core.fmt.CaretFormat' ], function (Arr, Fun, Element, Traverse, CaretPosition, DeleteElement, DeleteUtils, ElementType, Parents, CaretFormat) { var getParentInlines = function (rootElm, startElm) { var parents = Parents.parentsAndSelf(startElm, rootElm); return Arr.findIndex(parents, ElementType.isBlock).fold( Fun.constant(parents), function (index) { return parents.slice(0, index); } ); }; var hasOnlyOneChild = function (elm) { return Traverse.children(elm).length === 1; }; var deleteLastPosition = function (forward, editor, target, parentInlines) { var isFormatElement = Fun.curry(CaretFormat.isFormatElement, editor); var formatNodes = Arr.map(Arr.filter(parentInlines, isFormatElement), function (elm) { return elm.dom(); }); if (formatNodes.length === 0) { DeleteElement.deleteElement(editor, forward, target); } else { var pos = CaretFormat.replaceWithCaretFormat(target.dom(), formatNodes); editor.selection.setRng(pos.toRange()); } }; var deleteCaret = function (editor, forward) { var rootElm = Element.fromDom(editor.getBody()); var startElm = Element.fromDom(editor.selection.getStart()); var parentInlines = Arr.filter(getParentInlines(rootElm, startElm), hasOnlyOneChild); return Arr.last(parentInlines).map(function (target) { var fromPos = CaretPosition.fromRangeStart(editor.selection.getRng()); if (DeleteUtils.willDeleteLastPositionInElement(forward, fromPos, target.dom())) { deleteLastPosition(forward, editor, target, parentInlines); return true; } else { return false; } }).getOr(false); }; var backspaceDelete = function (editor, forward) { return editor.selection.isCollapsed() ? deleteCaret(editor, forward) : false; }; return { backspaceDelete: backspaceDelete }; } );