PHP Classes

File: public/js/tinymce/src/core/src/test/js/browser/selection/GetSelectionContentTest.js

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

Contents

Class file image Download
asynctest( 'browser.tinymce.selection.GetSelectionContentTest', [ 'ephox.agar.api.Assertions', 'ephox.agar.api.Chain', 'ephox.agar.api.GeneralSteps', 'ephox.agar.api.Logger', 'ephox.agar.api.Pipeline', 'ephox.agar.api.Step', 'ephox.mcagar.api.TinyApis', 'ephox.mcagar.api.TinyLoader', 'tinymce.core.selection.GetSelectionContent', 'tinymce.themes.modern.Theme' ], function (Assertions, Chain, GeneralSteps, Logger, Pipeline, Step, TinyApis, TinyLoader, GetSelectionContent, Theme) { var success = arguments[arguments.length - 2]; var failure = arguments[arguments.length - 1]; Theme(); var cGetContent = function (args) { return Chain.mapper(function (editor) { return GetSelectionContent.getContent(editor, args); }); }; var sAssertGetContent = function (label, editor, expectedContents) { return Chain.asStep(editor, [ cGetContent({}), Assertions.cAssertEq('Should be expected contents', expectedContents) ]); }; var sAssertGetContentOverrideBeforeGetContent = function (label, editor, expectedContents) { var handler = function (e) { if (e.selection === true) { e.preventDefault(); e.content = expectedContents; } }; return GeneralSteps.sequence([ Step.sync(function () { editor.on('BeforeGetContent', handler); }), Chain.asStep(editor, [ cGetContent({}), Assertions.cAssertEq('Should be expected contents', expectedContents) ]), Step.sync(function () { editor.off('BeforeGetContent', handler); }) ]); }; TinyLoader.setup(function (editor, onSuccess, onFailure) { var tinyApis = TinyApis(editor); Pipeline.async({}, [ Logger.t('Should be empty contents on a caret selection', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p>'), tinyApis.sSetSelection([0, 0], 0, [0, 0], 0), sAssertGetContent('Should be empty selection on caret', editor, '') ])), Logger.t('Should be text contents on a range selection', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p>'), tinyApis.sSetSelection([0, 0], 0, [0, 0], 1), sAssertGetContent('Should be some content', editor, 'a') ])), Logger.t('Should be text contents provided by override handler', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p>'), tinyApis.sSetSelection([0, 0], 0, [0, 0], 1), sAssertGetContentOverrideBeforeGetContent('Should be overridden content', editor, 'X') ])) ], onSuccess, onFailure); }, { selector: 'textarea', indent: false, skin_url: '/project/src/skins/lightgray/dist/lightgray' }, success, failure); } );