-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
100 lines (95 loc) · 3.18 KB
/
index.js
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
/*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii [email protected].
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
var tinymceOption = {
theme: 'silver',
width: 800,
height: 400,
plugins: ['advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table directionality emoticons template paste'],
// content_css: 'css/content.css',
// toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify ' +
// '| bullist numlist outdent indent | link image | print preview media fullpage ' +
// '| forecolor backcolor emoticons',
// style_formats: [
// {title: 'Bold text', inline: 'b'},
// {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
// {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
// {title: 'Example 1', inline: 'span', classes: 'example1'},
// {title: 'Example 2', inline: 'span', classes: 'example2'},
// {title: 'Table styles'},
// {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
// ]
};
IMParts_Catalog['tinymce'] = {
instantiate: function (parentNode) {
let newId = parentNode.getAttribute('id') + '-e';
this.ids.push(newId);
let newNode = document.createElement('TEXTAREA');
newNode.setAttribute('id', newId);
newNode.setAttribute('class', '_im_tinymce');
parentNode.appendChild(newNode);
this.ids.push(newId);
parentNode._im_getComponentId = (function () {
let theId = newId;
return function () {
return theId;
};
})();
parentNode._im_setValue = (function () {
let aNode = newNode;
return function (str) {
aNode.innerHTML = str;
};
})();
},
ids: [],
finish: function (update) {
update = (update === undefined) ? true : update;
if (!tinymceOption) {
tinymceOption = {};
}
if (update) {
tinymceOption.setup = function (ed) {
ed.on('change', (function () {
let updateRquired = update;
return function (ev) {
if (updateRquired) {
IMLibUI.valueChange(ed.id);
}
};
})());
ed.on('keydown', function (ev) {
//IMLibUI.keyDown(ev);
});
ed.on('keyup', function (ev) {
//IMLibUI.keyUp(ev);
});
};
} else {
tinymceOption.setup = null;
}
for (let i = 0; i < this.ids.length; i++) {
let targetNode = document.getElementById(this.ids[i]);
let targetId = this.ids[i];
tinymceOption.selector = '#' + targetId;
tinyMCE.init(tinymceOption);
if (targetNode) {
targetNode._im_getValue = (function () {
let thisId = targetId;
return function () {
return tinymce.EditorManager.get(thisId).getContent();
};
})();
}
}
this.ids = [];
}
};