-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
245 lines (233 loc) · 5.65 KB
/
index.js
File metadata and controls
245 lines (233 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
var storedImages = [];
var emailData = [
{
Name: 'Selma Rose',
Eimg: '3',
EmailId: 'selma@gmail.com',
},
{
Name: 'Russo Kay',
Eimg: '8',
EmailId: 'russo@gmail.com',
},
{
Name: 'Camden Kate',
Eimg: '9',
EmailId: 'camden@gmail.com',
},
{
Name: 'Mary Kate',
Eimg: '4',
EmailId: 'marry@gmail.com',
},
{
Name: 'Ursula Ann',
Eimg: '2',
EmailId: 'ursula@gmail.com',
},
{
Name: 'Margaret',
Eimg: '5',
EmailId: 'margaret@gmail.com',
},
{
Name: 'Laura Grace',
Eimg: '6',
EmailId: 'laura@gmail.com',
},
{
Name: 'Robert',
Eimg: '8',
EmailId: 'robert@gmail.com',
},
{
Name: 'Albert',
Eimg: '9',
EmailId: 'albert@gmail.com',
},
{
Name: 'Michale',
Eimg: '10',
EmailId: 'michale@gmail.com',
},
{
Name: 'Andrew James',
Eimg: '7',
EmailId: 'james@gmail.com',
},
{
Name: 'Rosalie',
Eimg: '4',
EmailId: 'rosalie@gmail.com',
},
{
Name: 'Stella Ruth',
Eimg: '2',
EmailId: 'stella@gmail.com',
},
{
Name: 'Richard Rose',
Eimg: '10',
EmailId: 'richard@gmail.com',
},
{
Name: 'Gabrielle',
Eimg: '3',
EmailId: 'gabrielle@gmail.com',
},
{
Name: 'Thomas',
Eimg: '7',
EmailId: 'thomas@gmail.com',
},
{
Name: 'Charles Danny',
Eimg: '8',
EmailId: 'charles@gmail.com',
},
{
Name: 'Daniel',
Eimg: '10',
EmailId: 'daniel@gmail.com',
},
{
Name: 'Matthew',
Eimg: '7',
EmailId: 'matthew@gmail.com',
},
{
Name: 'Donald Krish',
Eimg: '9',
EmailId: 'donald@gmail.com',
},
{
Name: 'Yohana',
Eimg: '1',
EmailId: 'yohana@gmail.com',
},
{
Name: 'Kevin Paul',
Eimg: '10',
EmailId: 'kevin@gmail.com',
},
];
/**
* Rich Text Editor overview sample
*/
var defaultRTE;
var hostUrl = 'https://ej2-aspcore-service.azurewebsites.net/';
var defaultRTE = new ej.richtexteditor.RichTextEditor({
toolbarSettings: {
items: [
'Bold',
'Italic',
'Underline',
'StrikeThrough',
'FontName',
'FontSize',
'FontColor',
'BackgroundColor',
'LowerCase',
'UpperCase',
'SuperScript',
'SubScript',
'|',
'Formats',
'Alignments',
'NumberFormatList',
'BulletFormatList',
'Outdent',
'Indent',
'|',
'CreateTable',
'CreateLink',
'Image',
'FileManager',
'|',
'ClearFormat',
'Print',
'SourceCode',
'FullScreen',
'|',
'Undo',
'Redo',
],
},
quickToolbarSettings: {
table: [
'TableHeader',
'TableRows',
'TableColumns',
'TableCell',
'-',
'BackgroundColor',
'TableRemove',
'TableCellVerticalAlign',
'Styles',
],
},
actionComplete: onActionSuccess,
afterImageDelete: onImageDelete,
insertImageSettings: {
allowedTypes: ['.jpeg', '.jpg', '.png'],
display: 'inline',
width: 'auto',
height: 'auto',
saveFormat: 'Base64',
},
});
defaultRTE.appendTo('#defaultRTE');
// Initialize Mention control.
var emailObj = new ej.dropdowns.Mention({
dataSource: emailData,
fields: { text: 'Name' },
suggestionCount: 8,
displayTemplate: '<a title=${EmailId}>@${Name}</a>',
itemTemplate: '<table><tr><td><div id="mention-TemplateList"><img class="mentionEmpImage" src="../../../images/${EmployeeImage}" alt="employee" /><span class="e-badge e-badge-success e-badge-overlap e-badge-dot e-badge-bottom ${Status}"></span></div></td><td><span class="person">${Name}</span><span class="email">${EmailId}</span></td</tr></table>',
popupWidth: '250px',
popupHeight: '200px',
target: '#mention_integration_rte-edit-view',
allowSpaces: true
});
emailObj.appendTo('#mentionEditor');
function generateUUID() {
// Public Domain/MIT
var d = new Date().getTime(); //Timestamp
var d2 =
(typeof performance !== 'undefined' &&
performance.now &&
performance.now() * 1000) ||
0; //Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16; //random number between 0 and 16
if (d > 0) {
//Use timestamp until depleted
r = (d + r) % 16 | 0;
d = Math.floor(d / 16);
} else {
//Use microseconds since page-load if supported
r = (d2 + r) % 16 | 0;
d2 = Math.floor(d2 / 16);
}
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
});
}
function onActionSuccess(args) {
//NARROW THE SUCCESS TO ONLY REPORT ON IMAGES BEING INSERTED/DROPPED
if (args.requestType == 'Images') {
//SRC OF THE ELEMENT WILL BE ALREADY AS BASE64 AS DETERMINED BY THE saveFormat: 'Base64'
console.log(args);
console.log(args.elements[0].src);
args.elements[0].id = generateUUID(); //USE THE BUILT IN JARVIS ONE :)
storedImages.push(args.elements[0].id);
//AT THIS STAGE THE ORIGINAL SAVE TO BLOB CAN BE HOOKED IN - IMAGE WILL NEED AN IDENTIFIER THATS RETURNED BACK TO THE EDITOR SO THAT WHEN DELETED FROM THE EDITOR THE IMAGE IN THE BLOB IS ALSO DELETED
console.log('Whats stored in the blob?');
console.log(storedImages);
}
}
function onImageDelete(args) {
var imageID = args.element.getAttribute('id');
var index = storedImages.findIndex((num) => num === imageID);
console.log('Going to delete ' + imageID + ' from the blob @ index ' + index);
storedImages.splice(index, 1);
}