/
plugin.js
63 lines (58 loc) · 2.05 KB
/
plugin.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
/*
* Copyright (c) 2004-2018 OIC Group, Inc.
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*/
CKEDITOR.plugins.add('fieldinsert' ,
{
requires : ['richcombo'] ,
init : function (editor) {
// array of fields to choose from that'll be inserted into the editor
var fields = editor.config.fieldinsert_list;
// add the menu to the editor
editor.ui.addRichCombo('fieldinsert' ,
{
label : 'Fields' ,
title : 'Fields' ,
// voiceLabel : 'Fields' ,
// className : 'cke_format' ,
multiSelect : false ,
panel : {
css : [ editor.config.contentsCss, CKEDITOR.skin.getPath('editor') ] ,
// voiceLabel : editor.lang.panelVoiceLabel
} ,
init : function () {
this.startGroup("Fields");
//this.add('value', 'drop_text', 'drop_label');
for (var i in fields) {
this.add(escape(fields[i][0]) , fields[i][1] , fields[i][2]);
}
} ,
onClick : function (value) {
editor.focus();
editor.fire('saveSnapshot');
editor.insertHtml(unescape(value));
editor.fire('saveSnapshot');
}
});
}
});
/**
* List of fields available to insert.
*
* fieldinsert_list = array of fields; 'value', 'drop_text', 'drop_label'
*
* @member CKEDITOR.config
*/
CKEDITOR.config.fieldinsert_list = [
['', 'No Fields', 'There are no fields']
];