OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
test
/
ts
/
browser
/
delete
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:14:55 AM
rwxr-xr-x
📄
BlockBoundaryDeleteTest.ts
10.57 KB
02/20/2020 06:13:13 AM
rw-r--r--
📄
BlockMergeBoundaryTest.ts
5.49 KB
02/20/2020 06:13:13 AM
rw-r--r--
📄
BlockRangeDeleteTest.ts
7.06 KB
02/20/2020 06:13:14 AM
rw-r--r--
📄
CefBoundaryDeleteTest.ts
4.17 KB
02/20/2020 06:13:14 AM
rw-r--r--
📄
CefDeleteActionTest.ts
14.63 KB
02/20/2020 06:13:15 AM
rw-r--r--
📄
CefDeleteTest.ts
5.55 KB
02/20/2020 06:13:15 AM
rw-r--r--
📄
DeleteCommandsTest.ts
1.75 KB
02/20/2020 06:13:16 AM
rw-r--r--
📄
DeleteElementTest.ts
10.08 KB
02/20/2020 06:13:16 AM
rw-r--r--
📄
DeleteUtilsTest.ts
5.22 KB
02/20/2020 06:13:17 AM
rw-r--r--
📄
ImageBlockDeleteTest.ts
3.23 KB
02/20/2020 06:13:17 AM
rw-r--r--
📄
InlineBoundaryDeleteTest.ts
6.21 KB
02/20/2020 06:13:19 AM
rw-r--r--
📄
InlineFormatDeleteTest.ts
11.09 KB
02/20/2020 06:13:19 AM
rw-r--r--
📄
MergeBlocksTest.ts
9.54 KB
02/20/2020 06:13:20 AM
rw-r--r--
📄
TableDeleteActionTest.ts
5.29 KB
02/20/2020 06:13:20 AM
rw-r--r--
📄
TableDeleteTest.ts
15.75 KB
02/20/2020 06:13:21 AM
rw-r--r--
Editing: DeleteElementTest.ts
Close
import { Assertions, GeneralSteps, Logger, Pipeline, Step } from '@ephox/agar'; import { TinyApis, TinyLoader } from '@ephox/mcagar'; import { Hierarchy, Element } from '@ephox/sugar'; import DeleteElement from 'tinymce/core/delete/DeleteElement'; import Theme from 'tinymce/themes/silver/Theme'; import { UnitTest } from '@ephox/bedrock'; UnitTest.asynctest('browser.tinymce.core.delete.DeleteElementTest', function () { const success = arguments[arguments.length - 2]; const failure = arguments[arguments.length - 1]; Theme(); const sDeleteElementPath = function (editor, forward, path) { return Step.sync(function () { const element = Hierarchy.follow(Element.fromDom(editor.getBody()), path).getOrDie(); DeleteElement.deleteElement(editor, forward, element); }); }; const sAssertCaretDirection = function (editor, expectedCaretData) { return Step.sync(function () { Assertions.assertEq('Should have the right caret data', expectedCaretData, editor.selection.getNode().getAttribute('data-mce-caret')); }); }; TinyLoader.setup(function (editor, onSuccess, onFailure) { const tinyApis = TinyApis(editor); Pipeline.async({}, [ tinyApis.sFocus, Logger.t('Delete image forwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"></p>'), tinyApis.sSetCursor([0], 0), sDeleteElementPath(editor, true, [0, 0]), tinyApis.sAssertContent(''), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete image backwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"></p>'), tinyApis.sSetCursor([0], 1), sDeleteElementPath(editor, false, [0, 0]), tinyApis.sAssertContent(''), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete first image forwards caret before', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 0), sDeleteElementPath(editor, true, [0, 0]), tinyApis.sAssertContent('<p><img src="#2" /></p>'), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete first image forwards caret after', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 1), sDeleteElementPath(editor, true, [0, 0]), tinyApis.sAssertContent('<p><img src="#2" /></p>'), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete first image backwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 2), sDeleteElementPath(editor, false, [0, 0]), tinyApis.sAssertContent('<p><img src="#2" /></p>'), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete second image forwards caret before', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 1), sDeleteElementPath(editor, true, [0, 1]), tinyApis.sAssertContent('<p><img src="#1" /></p>'), tinyApis.sAssertSelection([0], 1, [0], 1) ])), Logger.t('Delete second image forwards caret after', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 2), sDeleteElementPath(editor, true, [0, 1]), tinyApis.sAssertContent('<p><img src="#1" /></p>'), tinyApis.sAssertSelection([0], 1, [0], 1) ])), Logger.t('Delete second image backwards caret before', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 1), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p><img src="#1" /></p>'), tinyApis.sAssertSelection([0], 1, [0], 1) ])), Logger.t('Delete second image backwards caret after', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1"><img src="#2"></p>'), tinyApis.sSetCursor([0], 2), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p><img src="#1" /></p>'), tinyApis.sAssertSelection([0], 1, [0], 1) ])), Logger.t('Delete forwards on paragraph to next paragraph with caret position (text)', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p><p>b</p>'), tinyApis.sSetCursor([0, 0], 1), sDeleteElementPath(editor, true, [0]), tinyApis.sAssertContent('<p>b</p>'), tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0) ])), Logger.t('Delete backwards on paragraph to previous paragraph with caret position (text)', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p><p>b</p>'), tinyApis.sSetCursor([1, 0], 0), sDeleteElementPath(editor, false, [1]), tinyApis.sAssertContent('<p>a</p>'), tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1) ])), Logger.t('Delete forwards on paragraph to previous paragraph with caret position (text)', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p><p>b</p>'), tinyApis.sSetCursor([1, 0], 1), sDeleteElementPath(editor, true, [1]), tinyApis.sAssertContent('<p>a</p>'), tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1) ])), Logger.t('Delete backwards on paragraph to next paragraph with caret position (text)', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a</p><p>b</p>'), tinyApis.sSetCursor([0, 0], 0), sDeleteElementPath(editor, false, [0]), tinyApis.sAssertContent('<p>b</p>'), tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0) ])), Logger.t('Delete forwards paragraph before paragraph with caret position (element)', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1" /></p><p><img src="#2" /></p>'), tinyApis.sSetCursor([0], 1), sDeleteElementPath(editor, true, [0]), tinyApis.sAssertContent('<p><img src="#2" /></p>'), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete backwards paragraph after paragraph with caret position (element)', GeneralSteps.sequence([ tinyApis.sSetContent('<p><img src="#1" /></p><p><img src="#2" /></p>'), tinyApis.sSetCursor([1], 0), sDeleteElementPath(editor, false, [0]), tinyApis.sAssertContent('<p><img src="#2" /></p>'), tinyApis.sAssertSelection([0], 0, [0], 0) ])), Logger.t('Delete backwards on cef block between cef blocks', GeneralSteps.sequence([ tinyApis.sSetContent('<p contenteditable="false">a</p><p contenteditable="false">b</p><p contenteditable="false">c</p>'), tinyApis.sSetSelection([], 1, [], 2), sDeleteElementPath(editor, false, [1]), tinyApis.sAssertContent('<p contenteditable="false">a</p><p contenteditable="false">c</p>'), tinyApis.sAssertSelection([1], 0, [1], 0), sAssertCaretDirection(editor, 'after') ])), Logger.t('Delete forwards on cef block between cef blocks', GeneralSteps.sequence([ tinyApis.sSetContent('<p contenteditable="false">a</p><p contenteditable="false">b</p><p contenteditable="false">c</p>'), tinyApis.sSetSelection([], 1, [], 2), sDeleteElementPath(editor, true, [1]), tinyApis.sAssertContent('<p contenteditable="false">a</p><p contenteditable="false">c</p>'), tinyApis.sAssertSelection([1], 0, [1], 0), sAssertCaretDirection(editor, 'before') ])), Logger.t('Delete element adjacent text nodes forward', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a<br>b</p>'), tinyApis.sSetCursor([0, 0], 1), sDeleteElementPath(editor, true, [0, 1]), tinyApis.sAssertContent('<p>ab</p>'), tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1) ])), Logger.t('Delete element adjacent text nodes backwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a<br>b</p>'), tinyApis.sSetCursor([0, 2], 0), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p>ab</p>'), tinyApis.sAssertSelection([0, 0], 1, [0, 0], 1) ])), Logger.t('Delete inline element adjacent text nodes forwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a <strong>b</strong> c</p>'), tinyApis.sSetCursor([0, 0], 2), sDeleteElementPath(editor, true, [0, 1]), tinyApis.sAssertContent('<p>a c</p>'), tinyApis.sAssertSelection([0, 0], 2, [0, 0], 2) ])), Logger.t('Delete inline element adjacent text nodes backwards', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a <strong>b</strong> c</p>'), tinyApis.sSetCursor([0, 2], 0), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p>a c</p>'), tinyApis.sAssertSelection([0, 0], 3, [0, 0], 3) ])), Logger.t('Delete inline element adjacent text nodes, single space', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a <strong>b</strong>c</p>'), tinyApis.sSetCursor([0, 1], 0), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p>a c</p>'), tinyApis.sAssertSelection([0, 0], 2, [0, 0], 2) ])), Logger.t('Delete inline element leading only text nodes', GeneralSteps.sequence([ tinyApis.sSetContent('<p>a <strong>b</strong></p>'), tinyApis.sSetCursor([0, 1], 0), sDeleteElementPath(editor, false, [0, 1]), tinyApis.sAssertContent('<p>a </p>'), tinyApis.sAssertSelection([0, 0], 2, [0, 0], 2) ])), Logger.t('Delete inline element trailing only text nodes', GeneralSteps.sequence([ tinyApis.sSetContent('<p><strong>a</strong> b</p>'), tinyApis.sSetCursor([0, 1], 0), sDeleteElementPath(editor, false, [0, 0]), tinyApis.sAssertContent('<p> b</p>'), tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0) ])) ], onSuccess, onFailure); }, { add_unload_trigger: false, indent: false, base_url: '/project/tinymce/js/tinymce' }, success, failure); });