devkit.js
13.1 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
var devkit = parent.tinyMCE.plugins['devkit'], logEnabled = true, flip = false, book = null;
function init() {
var log, i, f = document.forms[0];
devkit._winLoaded = true;
log = tinyMCE.log;
for (i=0; i<log.length; i++)
debug(log[i]);
f.logfilter.value = devkit._logFilter;
}
function changeFilter(f) {
devkit._logFilter = f;
}
function toggleLog(s) {
logEnabled = s;
}
function toggleFlip() {
document.getElementById('flipbtn').src = flip ? 'images/flip_down.gif' : 'images/flip_up.gif';
if (flip)
parent.document.getElementById('devkit').className = 'devkitup';
else
parent.document.getElementById('devkit').className = 'devkitdown';
flip = !flip;
}
function debug(s) {
var d, l, n;
if (!logEnabled || !new RegExp(devkit._logFilter, 'gi').test(s))
return;
d = document;
l = d.getElementById('log');
n = d.createElement('span');
n.innerHTML = tinyMCE.xmlEncode(s);
l.appendChild(n);
l.scrollTop = l.scrollHeight;
}
function renderInfo() {
var se = document.getElementById('info'), n, sn, inst, h = '', sel, rng, instCount = 0, rc;
h += '<h2>Browser info:</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
h += addRenderInfo('navigator.userAgent', navigator.userAgent);
h += addRenderInfo('navigator.appName', navigator.appName);
h += addRenderInfo('navigator.platform', navigator.platform);
h += addRenderInfo('navigator.language', navigator.language, 'bspec');
h += addRenderInfo('navigator.browserLanguage', navigator.browserLanguage, 'bspec');
h += addRenderInfo('navigator.systemLanguage', navigator.systemLanguage, 'bspec');
h += addRenderInfo('navigator.userLanguage', navigator.userLanguage, 'bspec');
h += addRenderInfo('opera.buildNumber("inconspicuous")', typeof(opera) != 'undefined' && opera.buildNumber ? opera.buildNumber('inconspicuous') : null, 'bspec');
h += addRenderInfo('window.innerWidth', parent.window.innerWidth, 'bspec');
h += addRenderInfo('window.innerHeight', parent.window.innerHeight, 'bspec');
h += addRenderInfo('document.body.offsetWidth', parent.document.body.offsetWidth);
h += addRenderInfo('document.body.offsetHeight', parent.document.body.offsetHeight);
h += addRenderInfo('screen.width', screen.width);
h += addRenderInfo('screen.height', screen.height);
h += addRenderInfo('screen.availWidth', screen.availWidth);
h += addRenderInfo('screen.availHeight', screen.availHeight);
h += addRenderInfo('screen.colorDepth', screen.colorDepth);
h += addRenderInfo('screen.pixelDepth', screen.pixelDepth, 'bspec');
h += addRenderInfo('document.contentType', document.contentType, 'bspec');
h += '</table>';
h += '<h2>TinyMCE_Engine info:</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
h += addRenderInfo('baseURL', tinyMCE.baseURL);
h += addRenderInfo('selectedInstance.editorId', tinyMCE.selectedInstance ? tinyMCE.selectedInstance.editorId : null);
h += addRenderInfo('selectedElement.nodeName', tinyMCE.selectedElement ? tinyMCE.selectedElement.nodeName : null, 'dep');
h += addRenderInfo('loadedFiles',tinyMCE.loadedFiles.join(','));
h += addRenderInfo('isMSIE', tinyMCE.isMSIE);
h += addRenderInfo('isMSIE5', tinyMCE.isMSIE5);
h += addRenderInfo('isMSIE5_0', tinyMCE.isMSIE5_0);
h += addRenderInfo('isMSIE7', tinyMCE.isMSIE7);
h += addRenderInfo('isGecko', tinyMCE.isGecko);
h += addRenderInfo('isSafari', tinyMCE.isSafari);
h += addRenderInfo('isOpera', tinyMCE.isOpera);
h += addRenderInfo('isMac', tinyMCE.isMac);
h += addRenderInfo('isNS7', tinyMCE.isNS7);
h += addRenderInfo('isNS71', tinyMCE.isNS71);
h += addRenderInfo('idCounter', tinyMCE.idCounter);
h += addRenderInfo('currentConfig', tinyMCE.currentConfig);
h += addRenderInfo('majorVersion', tinyMCE.majorVersion);
h += addRenderInfo('minorVersion', tinyMCE.minorVersion);
h += addRenderInfo('releaseDate', tinyMCE.releaseDate);
h += addRenderInfo('documentBasePath', tinyMCE.documentBasePath);
h += addRenderInfo('documentURL', tinyMCE.documentURL);
h += '</table>';
for (n in tinyMCE.instances) {
inst = tinyMCE.instances[n];
if (!tinyMCE.isInstance(inst))
continue;
sel = inst.selection.getSel();
rng = inst.selection.getRng();
h += '<h2>TinyMCE_Control(' + (instCount++) + ') id: ' + inst.editorId + '</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
h += addRenderInfo('editorId', inst.editorId);
h += addRenderInfo('visualAid', inst.visualAid);
h += addRenderInfo('foreColor', inst.foreColor);
h += addRenderInfo('backColor', inst.backColor);
h += addRenderInfo('formTargetElementId', inst.formTargetElementId);
h += addRenderInfo('linkElement', inst.linkElement ? inst.linkElement.nodeName : null, 'dep');
h += addRenderInfo('imgElement', inst.imgElement ? inst.imgElement.nodeName : null, 'dep');
h += addRenderInfo('selectedNode', inst.selectedNode ? inst.selectedNode.nodeName : null, 'dep');
h += addRenderInfo('targetElement', inst.targetElement ? inst.targetElement.nodeName : null);
h += addRenderInfo('getBody().nodeName', inst.getBody() ? inst.getBody().nodeName : null);
h += addRenderInfo('getBody().getAttribute("id")', inst.getBody() ? inst.getBody().getAttribute("id") : null);
h += addRenderInfo('getDoc().location', inst.getDoc() ? inst.getDoc().location : null);
h += addRenderInfo('startContent', inst.startContent);
h += addRenderInfo('isHidden()', inst.isHidden());
h += addRenderInfo('isDirty()', inst.isDirty());
h += addRenderInfo('undoRedo.undoLevels.length', inst.undoRedo.undoLevels.length);
h += addRenderInfo('undoRedo.undoIndex', inst.undoRedo.undoIndex);
h += addRenderInfo('selection.getSelectedHTML()', inst.selection.getSelectedHTML());
h += addRenderInfo('selection.getSelectedText()', inst.selection.getSelectedText());
h += addRenderInfo('selection.getFocusElement().nodeName', inst.selection.getFocusElement().nodeName);
h += addRenderInfo('selection.getFocusElement().outerHTML', tinyMCE.getOuterHTML(inst.selection.getFocusElement()));
if ((tinyMCE.isGecko || tinyMCE.isOpera) && sel && rng) {
h += addRenderInfo('selection.getSel().anchorNode.nodeName', sel.anchorNode ? sel.anchorNode.nodeName : null, 'bspec');
h += addRenderInfo('selection.getSel().anchorOffset', sel.anchorOffset, 'bspec');
h += addRenderInfo('selection.getSel().focusNode.nodeName', sel.focusNode ? sel.focusNode.nodeName : null, 'bspec');
h += addRenderInfo('selection.getSel().focusOffset', sel.focusOffset, 'bspec');
h += addRenderInfo('selection.getRng().startContainer.nodeName', rng.startContainer ? rng.startContainer.nodeName : null, 'bspec');
h += addRenderInfo('selection.getRng().startOffset', rng.startOffset, 'bspec');
h += addRenderInfo('selection.getRng().endContainer.nodeName', rng.endContainer ? rng.endContainer.nodeName : null, 'bspec');
h += addRenderInfo('selection.getRng().endOffset', rng.endOffset, 'bspec');
}
if (typeof(rng.item) != 'undefined' || typeof(rng.htmlText) != 'undefined') {
if (!rng.item) {
h += addRenderInfo('selection.getSel().type', sel.type, 'bspec');
h += addRenderInfo('selection.getRng().htmlText', rng.htmlText, 'bspec');
h += addRenderInfo('selection.getRng().text', rng.text, 'bspec');
} else
h += addRenderInfo('selection.getRng().item(0).nodeName', rng.item(0).nodeName, 'bspec');
}
h += '</table>';
}
h += '<p>Fields marked in <strong class="bspec">gray</strong> is not cross browser and should be used with care.</p>';
h += '<p>Fields marked <strong class="dep">red</strong> are marked deprecated and will be removed in the future.</p><br />';
se.innerHTML = h;
}
function addRenderInfo(n, v, c) {
return '<tr><td' + (c ? ' class="' + c + '"' : '')+ '>' + n + '</td><td><input type="text" value="' + tinyMCE.xmlEncode(v != null ? ('' + v).replace(/[\r\n]/g, '') : 'null') + '" /></td></tr>';
}
function renderSettings() {
var se = document.getElementById('settings'), n, sn, inst, h = '', v;
for (n in tinyMCE.instances) {
inst = tinyMCE.instances[n];
if (!tinyMCE.isInstance(inst))
continue;
h += '<h2>Instance id: ' + inst.editorId + '</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
for (sn in inst.settings) {
v = inst.settings[sn];
h += '<tr><td class="col1">' + tinyMCE.xmlEncode(sn) + '</td><td><input type="text" value="' + tinyMCE.xmlEncode(v) + '" /></td></tr>';
}
h += '</table>';
}
se.innerHTML = h;
}
function renderContent() {
var se = document.getElementById('content'), n, inst, h = '';
for (n in tinyMCE.instances) {
inst = tinyMCE.instances[n];
if (!tinyMCE.isInstance(inst))
continue;
h += '<h2>Instance id: ' + inst.editorId + '</h2>';
h += '<h3>Start content - inst.startContent:</h3>';
h += '<div>' + tinyMCE.xmlEncode(inst.startContent) + '</div>';
h += '<h3>Raw content - inst.getBody().innerHTML or inst.getHTML(true):</h3>';
h += '<div>' + tinyMCE.xmlEncode(inst.getHTML(true)) + '</div>';
h += '<h3>Cleaned content - inst.getHTML():</h3>';
h += '<div>' + tinyMCE.xmlEncode(inst.getHTML()) + '</div>';
if (inst.serializedHTML) {
h += '<h3>Serialized HTML content - inst.serializedHTML:</h3>';
h += '<div>' + tinyMCE.xmlEncode(inst.serializedHTML) + '</div>';
}
}
se.innerHTML = h;
}
function renderCommandStates() {
var se = document.getElementById('command_states'), n, inst, h = '', v, ex;
var cmds = new Array('2D-Position','AbsolutePosition','BackColor','BlockDirLTR','BlockDirRTL','Bold','BrowseMode','Copy','CreateBookmark','CreateLink','Cut','Delete','DirLTR','DirRTL','EditMode','enableInlineTableEditing','enableObjectResizing','FontName','FontSize','ForeColor','FormatBlock','Indent','InsertButton','InsertFieldset','InsertHorizontalRule','InsertIFrame','InsertImage','InsertInputButton','InsertInputCheckbox','InsertInputFileUpload','InsertInputHidden','InsertInputImage','InsertInputPassword','InsertInputRadio','InsertInputReset','InsertInputSubmit','InsertInputText','InsertMarquee','InsertOrderedList','InsertParagraph','InsertSelectDropdown','InsertSelectListbox','InsertTextArea','InsertUnorderedList','Italic','JustifyCenter','JustifyFull','JustifyLeft','JustifyNone','JustifyRight','LiveResize','MultipleSelection','Open','Outdent','OverWrite','Paste','PlayImage','Redo','Refresh','RemoveFormat','SaveAs','SelectAll','SizeToControl','SizeToControlHeight','SizeToControlWidth','Stop','StopImage','StrikeThrough','styleWithCSS','Subscript','Superscript','UnBookmark','Underline','Undo','Unlink','Unselect'), i;
for (n in tinyMCE.instances) {
inst = tinyMCE.instances[n];
if (!tinyMCE.isInstance(inst))
continue;
h += '<h2>Instance id: ' + inst.editorId + '</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
for (i=0; i<cmds.length; i++) {
v = null;
try {
v = tinyMCE.isGecko || inst.getDoc().queryCommandSupported(cmds[i]);
v = v ? inst.queryCommandState(cmds[i]) : 'Not supported';
} catch (ex) {
v = 'Not supported';
}
h += '<tr><td><input type="text" value="' + tinyMCE.xmlEncode(cmds[i]) + '" /></td><td><input type="text" value="' + tinyMCE.xmlEncode(v) + '" /></td></tr>';
}
h += '</table>';
}
se.innerHTML = h;
}
function renderUndoRedo() {
var se = document.getElementById('undo_redo'), inst, n, h = '', i, le, id, d, ur;
var f = document.forms[0];
if (tinyMCE.undoLevels) {
le = tinyMCE.undoLevels;
h += '<h2>Global undo/redo</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" width="50%" class="data">';
h += '<tr><td>undoLevels.length</td><td>' + le.length + '</td></tr>';
h += '<tr><td>undoIndex</td><td>' + tinyMCE.undoIndex + '</td></tr>';
h += '</table>';
for (i=0; i<le.length; i++)
h += '<h3>Level: ' + i + ', Instance: ' + (le[i] ? le[i].editorId : 'null') + '</h3>';
}
for (n in tinyMCE.instances) {
inst = tinyMCE.instances[n];
if (!tinyMCE.isInstance(inst))
continue;
ur = inst.undoRedo;
le = ur.undoLevels;
h += '<hr /><h2>Instance id: ' + inst.editorId + '</h2>';
h += '<table border="0" cellpadding="0" cellspacing="0" width="50%" class="data">';
h += '<tr><td>undoLevels.length</td><td>' + le.length + '</td></tr>';
h += '<tr><td>undoIndex</td><td>' + ur.undoIndex + '</td></tr>';
h += '<tr><td>typingUndoIndex</td><td>' + ur.typingUndoIndex + '</td></tr>';
h += '<tr><td>undoRedo</td><td>' + ur.undoRedo + '</td></tr>';
h += '</table>';
for (i=0; i<le.length; i++) {
h += '<h3>Level: ' + i + (!le[i].bookmark ? "" : " [bookmark]") + '</h3>';
h += '<div class="undodata">' + tinyMCE.xmlEncode(le[i].content) + '</div>';
if (i > 0 && f.undo_diff.checked) {
d = diff_main(i > 0 ? le[i-1].content.replace(/[\r\n]+/g, '') : null, le[i].content.replace(/[\r\n]+/g, ''), false);
diff_cleanup_semantic(d);
h += '<h3>Diff ' + (i-1) + ',' + i + '</h3><div class="undodata">' + diff_prettyhtml(d) + '</div>';
}
}
}
se.innerHTML = h;
}
function clearLog() {
document.getElementById('log').innerHTML = '';
devkit._startTime = null;
}
function cancelAction() {
parent.document.getElementById('devkit').style.display = 'none';
}
function toggleDebugEvents(s) {
devkit._debugEvents(s);
}
function storeSelection() {
book = tinyMCE.selectedInstance.selection.getBookmark();
return false;
}
function restoreSelection() {
tinyMCE.selectedInstance.selection.moveToBookmark(book);
return false;
}