OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
_backup
/
tinymce
/
tinymce
/
src
/
core
/
test
/
ts
/
module
/
test
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/20/2020 06:15:07 AM
rwxr-xr-x
📄
AnnotationAsserts.ts
1.96 KB
02/20/2020 06:15:10 AM
rw-r--r--
📄
CaretAsserts.ts
1.54 KB
02/20/2020 06:15:10 AM
rw-r--r--
📄
HtmlUtils.ts
1.17 KB
02/20/2020 06:15:11 AM
rw-r--r--
📄
KeyUtils.ts
3.66 KB
02/20/2020 06:15:11 AM
rw-r--r--
📄
TypeText.ts
1.59 KB
02/20/2020 06:15:12 AM
rw-r--r--
📄
ViewBlock.ts
733 bytes
02/20/2020 06:15:12 AM
rw-r--r--
Editing: AnnotationAsserts.ts
Close
import { ApproxStructure, Assertions, Step } from '@ephox/agar'; import { Element } from '@ephox/dom-globals'; import { Arr, Obj } from '@ephox/katamari'; import { Element as SugarElement } from '@ephox/sugar'; import Editor from 'tinymce/core/api/Editor'; const sAnnotate = (editor: Editor, name: string, uid: string, data: { }) => Step.sync(() => { editor.annotator.annotate(name, { uid, ...data }); }); // This will result in an attribute order-insensitive HTML assertion const sAssertHtmlContent = (tinyApis, children: string[]) => { return tinyApis.sAssertContentStructure( ApproxStructure.build((s, str, arr) => { return s.element('body', { children: Arr.map(children, ApproxStructure.fromHtml) }); }) ); }; const assertMarker = (editor: Editor, expected, nodes: Element[]) => { const { uid, name } = expected; Arr.each(nodes, (node) => { Assertions.assertEq('Wrapper must be in content', true, editor.getBody().contains(node)); Assertions.assertStructure( 'Checking wrapper has correct decoration', ApproxStructure.build((s, str, arr) => { return s.element('span', { attrs: { 'data-mce-annotation': str.is(name), 'data-mce-annotation-uid': str.is(uid) } }); }), SugarElement.fromDom(node) ); }); }; const sAssertGetAll = (editor: Editor, expected: Record<string, number>, name: string) => Step.sync(() => { const annotations = editor.annotator.getAll(name); const keys = Obj.keys(annotations); const sortedKeys = Arr.sort(keys); const expectedKeys = Arr.sort(Obj.keys(expected)); Assertions.assertEq('Checking keys of getAll response', expectedKeys, sortedKeys); Obj.each(annotations, (markers, uid) => { Assertions.assertEq('Checking number of markers for uid', expected[uid], markers.length); assertMarker(editor, { uid, name }, markers); }); }); export { sAnnotate, sAssertHtmlContent, sAssertGetAll, assertMarker };