Skip to content

Commit 704fd48

Browse files
author
pipeline
committed
v30.1.41 is released
1 parent f9cba66 commit 704fd48

File tree

196 files changed

+22224
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+22224
-695
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h1>
22
<a href="https://www.syncfusion.com/javascript-ui-controls">
33
<img src="https://ej2.syncfusion.com/github/images/syncfusion.svg" alt="Syncfusion Inc." title="Syncfusion Inc." align="top" height="40px" />
4-
<span>Syncfusion JavaScript UI Controls Library</span>
4+
<span>Syncfusion JavaScript UI Controls Library</span>
55
</a>
66
</h1>
77

controls/blockeditor/spec/actions/clipboard.spec.ts

Lines changed: 1296 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
import { createElement, remove } from '@syncfusion/ej2-base';
2+
import { ClickEventArgs } from '@syncfusion/ej2-navigations';
3+
import { BlockModel, UserModel } from '../../src/blockeditor/models';
4+
import { BlockEditor, BlockType, ContentType, setCursorPosition, setSelectionRange, getBlockContentElement } from '../../src/index';
5+
import { createEditor } from '../common/util.spec';
6+
7+
describe('Content types', () => {
8+
beforeAll(() => {
9+
const isDef: any = (o: any) => o !== undefined && o !== null;
10+
if (!isDef(window.performance)) {
11+
console.log('Unsupported environment, window.performance.memory is unavailable');
12+
pending(); // skips test (in Chai)
13+
return;
14+
}
15+
});
16+
17+
describe('Ensuring basic rendering of content types', () => {
18+
let editor: BlockEditor;
19+
let editorElement: HTMLElement;
20+
21+
beforeEach(() => {
22+
editorElement = createElement('div', { id: 'editor' });
23+
document.body.appendChild(editorElement);
24+
const blocks: BlockModel[] = [
25+
{
26+
id: 'text-block',
27+
type: BlockType.Paragraph,
28+
content: [{ type: ContentType.Text, content: 'helloworld' }]
29+
},
30+
{
31+
id: 'link-block',
32+
type: BlockType.Paragraph,
33+
content: [{ type: ContentType.Link, content: 'syncfusion', linkSettings: { url: 'www.syncfusion.com', openInNewWindow: true } }]
34+
},
35+
{
36+
id: 'code-block',
37+
type: BlockType.Paragraph,
38+
content: [{ type: ContentType.Code, content: 'console.log("hello world")' }]
39+
},
40+
{
41+
id: 'mention-block',
42+
type: BlockType.Paragraph,
43+
content: [{ type: ContentType.Mention, id: 'user1' }]
44+
},
45+
{
46+
id: 'label-block',
47+
type: BlockType.Paragraph,
48+
content: [{ type: ContentType.Label, id: 'progress' }]
49+
},
50+
{
51+
id: 'combined-block',
52+
type: BlockType.Paragraph,
53+
content: [
54+
{ type: ContentType.Text, content: 'To navigate to syncfusion site, ' },
55+
{ type: ContentType.Link, content: 'click here ', linkSettings: { url: 'www.syncfusion.com', openInNewWindow: true } },
56+
{ type: ContentType.Code, content: 'console.log("hello world"), ' },
57+
{ type: ContentType.Mention, id: 'user2' },
58+
{ type: ContentType.Label, id: 'progress' }
59+
]
60+
},
61+
];
62+
const users: UserModel[] = [
63+
{ id: 'user1', user: 'John Paul' },
64+
{ id: 'user2', user: 'John Snow' }
65+
];
66+
editor = createEditor({ blocks: blocks, users: users });
67+
editor.appendTo('#editor');
68+
});
69+
70+
afterEach(() => {
71+
if (editor) {
72+
editor.destroy();
73+
editor = undefined;
74+
}
75+
remove(editorElement);
76+
});
77+
78+
it('ensure content type text rendering', () => {
79+
const blockElement = editorElement.querySelector('#text-block') as HTMLElement;
80+
expect(blockElement).not.toBeNull();
81+
const contentElement = getBlockContentElement(blockElement);
82+
expect(contentElement).not.toBeNull();
83+
expect(contentElement.textContent).toBe('helloworld');
84+
});
85+
86+
it('ensure content type link rendering', () => {
87+
const blockElement = editorElement.querySelector('#link-block') as HTMLElement;
88+
expect(blockElement).not.toBeNull();
89+
const contentElement = getBlockContentElement(blockElement);
90+
expect(contentElement).not.toBeNull();
91+
const anchorEle = (contentElement.firstChild as HTMLElement);
92+
expect(anchorEle.tagName).toBe('A');
93+
expect(anchorEle.textContent).toBe('syncfusion');
94+
expect(anchorEle.getAttribute('href')).toBe('https://www.syncfusion.com');
95+
expect(anchorEle.getAttribute('target')).toBe('_blank');
96+
expect(editor.blocks[1].content[0].id).toBe(anchorEle.id);
97+
});
98+
99+
it('ensure content type code rendering', () => {
100+
const blockElement = editorElement.querySelector('#code-block') as HTMLElement;
101+
expect(blockElement).not.toBeNull();
102+
const contentElement = getBlockContentElement(blockElement);
103+
expect(contentElement).not.toBeNull();
104+
const codeEle = (contentElement.firstChild as HTMLElement);
105+
expect(codeEle.tagName).toBe('CODE');
106+
expect(codeEle.textContent).toBe('console.log("hello world")');
107+
expect(editor.blocks[2].content[0].id).toBe(codeEle.id);
108+
});
109+
110+
it('ensure content type mention rendering', () => {
111+
const blockElement = editorElement.querySelector('#mention-block') as HTMLElement;
112+
expect(blockElement).not.toBeNull();
113+
const contentElement = getBlockContentElement(blockElement);
114+
expect(contentElement).not.toBeNull();
115+
const mentionChipEle = (contentElement.firstChild as HTMLElement);
116+
expect(mentionChipEle.tagName).toBe('DIV');
117+
expect((mentionChipEle.querySelector('.em-content') as HTMLElement).textContent).toBe('John Paul');
118+
expect(editor.blocks[3].content[0].dataId).toBe(mentionChipEle.id);
119+
expect(editor.blocks[3].content[0].id).toBe(mentionChipEle.getAttribute('data-user-id'));
120+
});
121+
122+
it('ensure content type label rendering', () => {
123+
const blockElement = editorElement.querySelector('#label-block') as HTMLElement;
124+
expect(blockElement).not.toBeNull();
125+
const contentElement = getBlockContentElement(blockElement);
126+
expect(contentElement).not.toBeNull();
127+
const labelChipEle = (contentElement.firstChild as HTMLElement);
128+
expect(labelChipEle.tagName).toBe('SPAN');
129+
expect(labelChipEle.textContent).toBe('Progress: In-progress');
130+
expect(editor.blocks[4].content[0].dataId).toBe(labelChipEle.id);
131+
expect(editor.blocks[4].content[0].id).toBe(labelChipEle.getAttribute('data-label-id'));
132+
});
133+
134+
it('ensure all content types combined rendering', () => {
135+
const blockElement = editorElement.querySelector('#combined-block') as HTMLElement;
136+
expect(blockElement).not.toBeNull();
137+
const contentElement = getBlockContentElement(blockElement);
138+
expect(contentElement).not.toBeNull();
139+
expect(contentElement.textContent).toBe('To navigate to syncfusion site, click here console.log("hello world"), JSJohn SnowProgress: In-progress');
140+
const textEle = contentElement.firstChild as HTMLElement;
141+
expect(textEle.tagName).toBe('SPAN');
142+
expect(textEle.textContent).toBe('To navigate to syncfusion site, ');
143+
expect(editor.blocks[5].content[0].id).toBe(textEle.id);
144+
145+
const anchorEle = contentElement.childNodes[1] as HTMLElement;
146+
expect(anchorEle.tagName).toBe('A');
147+
expect(anchorEle.textContent).toBe('click here ');
148+
expect(anchorEle.getAttribute('href')).toBe('https://www.syncfusion.com');
149+
expect(anchorEle.getAttribute('target')).toBe('_blank');
150+
expect(editor.blocks[5].content[1].id).toBe(anchorEle.id);
151+
152+
const codeEle = contentElement.childNodes[2] as HTMLElement;
153+
expect(codeEle.tagName).toBe('CODE');
154+
expect(codeEle.textContent).toBe('console.log("hello world"), ');
155+
expect(editor.blocks[5].content[2].id).toBe(codeEle.id);
156+
157+
const mentionEle = contentElement.childNodes[3] as HTMLElement;
158+
expect(mentionEle.tagName).toBe('DIV');
159+
expect((mentionEle.querySelector('.em-content') as HTMLElement).textContent).toBe('John Snow');
160+
161+
const labelEle = contentElement.lastChild as HTMLElement;
162+
expect(labelEle.tagName).toBe('SPAN');
163+
expect(labelEle.textContent).toBe('Progress: In-progress');
164+
});
165+
});
166+
});

0 commit comments

Comments
 (0)