mirador_rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +97 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mirador_rails.rb +16 -0
- data/lib/mirador_rails/version.rb +3 -0
- data/lib/mirador_rails/view_helpers.rb +30 -0
- data/mirador_rails.gemspec +30 -0
- data/vendor/assets/images/border_type_1.png +0 -0
- data/vendor/assets/images/border_type_2.png +0 -0
- data/vendor/assets/images/border_type_3.png +0 -0
- data/vendor/assets/images/debut_dark.png +0 -0
- data/vendor/assets/javascripts/mirador.js +1 -0
- data/vendor/assets/javascripts/mirador.min.js +88 -0
- data/vendor/assets/javascripts/mirador.min.js.map +1 -0
- data/vendor/assets/locales/ar/translation.json +42 -0
- data/vendor/assets/locales/de/translation.json +77 -0
- data/vendor/assets/locales/en/translation.json +82 -0
- data/vendor/assets/locales/es/translation.json +35 -0
- data/vendor/assets/locales/fr/translation.json +77 -0
- data/vendor/assets/locales/ga/translation.json +39 -0
- data/vendor/assets/locales/ja/translation.json +82 -0
- data/vendor/assets/locales/ko/translation.json +74 -0
- data/vendor/assets/locales/nl/translation.json +39 -0
- data/vendor/assets/locales/zh-CN/translation.json +74 -0
- data/vendor/assets/locales/zh-TW/translation.json +74 -0
- data/vendor/assets/locales/zh/translation.json +74 -0
- data/vendor/assets/plugins/plugins/advlist/plugin.js +97 -0
- data/vendor/assets/plugins/plugins/advlist/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/anchor/plugin.js +45 -0
- data/vendor/assets/plugins/plugins/anchor/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autolink/plugin.js +194 -0
- data/vendor/assets/plugins/plugins/autolink/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autoresize/plugin.js +152 -0
- data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/autosave/plugin.js +165 -0
- data/vendor/assets/plugins/plugins/autosave/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/bbcode/plugin.js +123 -0
- data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/charmap/plugin.js +370 -0
- data/vendor/assets/plugins/plugins/charmap/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/code/plugin.js +60 -0
- data/vendor/assets/plugins/plugins/code/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/colorpicker/plugin.js +112 -0
- data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +118 -0
- data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
- data/vendor/assets/plugins/plugins/compat3x/plugin.js +297 -0
- data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +542 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +70 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +210 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +164 -0
- data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +252 -0
- data/vendor/assets/plugins/plugins/contextmenu/plugin.js +87 -0
- data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/directionality/plugin.js +64 -0
- data/vendor/assets/plugins/plugins/directionality/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
- data/vendor/assets/plugins/plugins/emoticons/plugin.js +65 -0
- data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/example/dialog.html +8 -0
- data/vendor/assets/plugins/plugins/example/plugin.js +68 -0
- data/vendor/assets/plugins/plugins/example/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/example_dependency/plugin.js +22 -0
- data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/fullpage/plugin.js +490 -0
- data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/fullscreen/plugin.js +136 -0
- data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/hr/plugin.js +30 -0
- data/vendor/assets/plugins/plugins/hr/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/image/plugin.js +439 -0
- data/vendor/assets/plugins/plugins/image/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/importcss/plugin.js +195 -0
- data/vendor/assets/plugins/plugins/importcss/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +121 -0
- data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/layer/plugin.js +225 -0
- data/vendor/assets/plugins/plugins/layer/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +211 -0
- data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/link/plugin.js +400 -0
- data/vendor/assets/plugins/plugins/link/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/lists/plugin.js +791 -0
- data/vendor/assets/plugins/plugins/lists/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
- data/vendor/assets/plugins/plugins/media/plugin.js +774 -0
- data/vendor/assets/plugins/plugins/media/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +53 -0
- data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/noneditable/plugin.js +540 -0
- data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/pagebreak/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +634 -0
- data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +110 -0
- data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +159 -0
- data/vendor/assets/plugins/plugins/paste/classes/Utils.js +130 -0
- data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +493 -0
- data/vendor/assets/plugins/plugins/paste/plugin.dev.js +120 -0
- data/vendor/assets/plugins/plugins/paste/plugin.js +1625 -0
- data/vendor/assets/plugins/plugins/paste/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/preview/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/preview/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/print/plugin.js +32 -0
- data/vendor/assets/plugins/plugins/print/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/save/plugin.js +94 -0
- data/vendor/assets/plugins/plugins/save/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/searchreplace/plugin.js +594 -0
- data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +470 -0
- data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +436 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +117 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.js +996 -0
- data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/tabfocus/plugin.js +120 -0
- data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +176 -0
- data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +749 -0
- data/vendor/assets/plugins/plugins/table/classes/Plugin.js +422 -0
- data/vendor/assets/plugins/plugins/table/classes/Quirks.js +372 -0
- data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +864 -0
- data/vendor/assets/plugins/plugins/table/plugin.dev.js +118 -0
- data/vendor/assets/plugins/plugins/table/plugin.js +2680 -0
- data/vendor/assets/plugins/plugins/table/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/template/plugin.js +262 -0
- data/vendor/assets/plugins/plugins/template/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/textcolor/plugin.js +272 -0
- data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/textpattern/plugin.js +268 -0
- data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +135 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
- data/vendor/assets/plugins/plugins/visualblocks/plugin.js +86 -0
- data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/visualchars/plugin.js +88 -0
- data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +1 -0
- data/vendor/assets/plugins/plugins/wordcount/plugin.js +69 -0
- data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +1 -0
- data/vendor/assets/skins/skins/lightgray/content.inline.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/content.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +62 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +63 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
- data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
- data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
- data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +1 -0
- data/vendor/assets/skins/skins/lightgray/skin.min.css +1 -0
- data/vendor/assets/stylesheets/mirador-combined.css +3969 -0
- data/vendor/assets/stylesheets/mirador.css +11 -0
- data/vendor/assets/themes/themes/modern/theme.js +617 -0
- data/vendor/assets/themes/themes/modern/theme.min.js +1 -0
- metadata +318 -0
@@ -0,0 +1 @@
|
|
1
|
+
tinymce.PluginManager.add("textcolor",function(a){function b(b){var c;return a.dom.getParents(a.selection.getStart(),function(a){var d;(d=a.style["forecolor"==b?"color":"background-color"])&&(c=d)}),c}function c(){var b,c,d=[];for(c=a.settings.textcolor_map||["000000","Black","993300","Burnt orange","333300","Dark olive","003300","Dark green","003366","Dark azure","000080","Navy Blue","333399","Indigo","333333","Very dark gray","800000","Maroon","FF6600","Orange","808000","Olive","008000","Green","008080","Teal","0000FF","Blue","666699","Grayish blue","808080","Gray","FF0000","Red","FF9900","Amber","99CC00","Yellow green","339966","Sea green","33CCCC","Turquoise","3366FF","Royal blue","800080","Purple","999999","Medium gray","FF00FF","Magenta","FFCC00","Gold","FFFF00","Yellow","00FF00","Lime","00FFFF","Aqua","00CCFF","Sky blue","993366","Red violet","FFFFFF","White","FF99CC","Pink","FFCC99","Peach","FFFF99","Light yellow","CCFFCC","Pale green","CCFFFF","Pale cyan","99CCFF","Light sky blue","CC99FF","Plum"],b=0;b<c.length;b+=2)d.push({text:c[b+1],color:"#"+c[b]});return d}function d(){function b(a,b){var c="transparent"==a;return'<td class="mce-grid-cell'+(c?" mce-colorbtn-trans":"")+'"><div id="'+n+"-"+o++ +'" data-mce-color="'+(a?a:"")+'" role="option" tabIndex="-1" style="'+(a?"background-color: "+a:"")+'" title="'+tinymce.translate(b)+'">'+(c?"×":"")+"</div></td>"}var d,e,f,g,h,k,l,m=this,n=m._id,o=0;for(d=c(),d.push({text:tinymce.translate("No color"),color:"transparent"}),f='<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>',g=d.length-1,k=0;j>k;k++){for(f+="<tr>",h=0;i>h;h++)l=k*i+h,l>g?f+="<td></td>":(e=d[l],f+=b(e.color,e.text));f+="</tr>"}if(a.settings.color_picker_callback){for(f+='<tr><td colspan="'+i+'" class="mce-custom-color-btn"><div id="'+n+'-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" role="button" tabindex="-1" aria-labelledby="'+n+'-c" style="width: 100%"><button type="button" role="presentation" tabindex="-1">'+tinymce.translate("Custom...")+"</button></div></td></tr>",f+="<tr>",h=0;i>h;h++)f+=b("","Custom color");f+="</tr>"}return f+="</tbody></table>"}function e(b,c){a.focus(),a.formatter.apply(b,{value:c}),a.nodeChanged()}function f(b){a.focus(),a.formatter.remove(b,{value:null},null,!0),a.nodeChanged()}function g(c){function d(a){j.hidePanel(),j.color(a),e(j.settings.format,a)}function g(a,b){a.style.background=b,a.setAttribute("data-mce-color",b)}var h,j=this.parent();if(tinymce.DOM.getParent(c.target,".mce-custom-color-btn")&&(j.hidePanel(),a.settings.color_picker_callback.call(a,function(a){var b,c,e,f=j.panel.getEl().getElementsByTagName("table")[0];for(b=tinymce.map(f.rows[f.rows.length-1].childNodes,function(a){return a.firstChild}),e=0;e<b.length&&(c=b[e],c.getAttribute("data-mce-color"));e++);if(e==i)for(e=0;i-1>e;e++)g(b[e],b[e+1].getAttribute("data-mce-color"));g(c,a),d(a)},b(j.settings.format))),h=c.target.getAttribute("data-mce-color")){if(this.lastId&&document.getElementById(this.lastId).setAttribute("aria-selected",!1),c.target.setAttribute("aria-selected",!0),this.lastId=c.target.id,"transparent"==h)return f(j.settings.format),void j.hidePanel();d(h)}else null!==h&&j.hidePanel()}function h(){var a=this;a._color&&e(a.settings.format,a._color)}var i,j;j=a.settings.textcolor_rows||5,i=a.settings.textcolor_cols||8,a.addButton("forecolor",{type:"colorbutton",tooltip:"Text color",format:"forecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h}),a.addButton("backcolor",{type:"colorbutton",tooltip:"Background color",format:"hilitecolor",panel:{role:"application",ariaRemember:!0,html:d,onclick:g},onclick:h})});
|
@@ -0,0 +1,268 @@
|
|
1
|
+
/**
|
2
|
+
* plugin.js
|
3
|
+
*
|
4
|
+
* Copyright, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*global tinymce:true */
|
12
|
+
|
13
|
+
tinymce.PluginManager.add('textpattern', function(editor) {
|
14
|
+
var isPatternsDirty = true, patterns;
|
15
|
+
|
16
|
+
patterns = editor.settings.textpattern_patterns || [
|
17
|
+
{start: '*', end: '*', format: 'italic'},
|
18
|
+
{start: '**', end: '**', format: 'bold'},
|
19
|
+
{start: '#', format: 'h1'},
|
20
|
+
{start: '##', format: 'h2'},
|
21
|
+
{start: '###', format: 'h3'},
|
22
|
+
{start: '####', format: 'h4'},
|
23
|
+
{start: '#####', format: 'h5'},
|
24
|
+
{start: '######', format: 'h6'},
|
25
|
+
{start: '1. ', cmd: 'InsertOrderedList'},
|
26
|
+
{start: '* ', cmd: 'InsertUnorderedList'},
|
27
|
+
{start: '- ', cmd: 'InsertUnorderedList'}
|
28
|
+
];
|
29
|
+
|
30
|
+
// Returns a sorted patterns list, ordered descending by start length
|
31
|
+
function getPatterns() {
|
32
|
+
if (isPatternsDirty) {
|
33
|
+
patterns.sort(function(a, b) {
|
34
|
+
if (a.start.length > b.start.length) {
|
35
|
+
return -1;
|
36
|
+
}
|
37
|
+
|
38
|
+
if (a.start.length < b.start.length) {
|
39
|
+
return 1;
|
40
|
+
}
|
41
|
+
|
42
|
+
return 0;
|
43
|
+
});
|
44
|
+
|
45
|
+
isPatternsDirty = false;
|
46
|
+
}
|
47
|
+
|
48
|
+
return patterns;
|
49
|
+
}
|
50
|
+
|
51
|
+
// Finds a matching pattern to the specified text
|
52
|
+
function findPattern(text) {
|
53
|
+
var patterns = getPatterns();
|
54
|
+
|
55
|
+
for (var i = 0; i < patterns.length; i++) {
|
56
|
+
if (text.indexOf(patterns[i].start) !== 0) {
|
57
|
+
continue;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (patterns[i].end && text.lastIndexOf(patterns[i].end) != text.length - patterns[i].end.length) {
|
61
|
+
continue;
|
62
|
+
}
|
63
|
+
|
64
|
+
return patterns[i];
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
// Finds the best matching end pattern
|
69
|
+
function findEndPattern(text, offset, delta) {
|
70
|
+
var patterns, pattern, i;
|
71
|
+
|
72
|
+
// Find best matching end
|
73
|
+
patterns = getPatterns();
|
74
|
+
for (i = 0; i < patterns.length; i++) {
|
75
|
+
pattern = patterns[i];
|
76
|
+
if (pattern.end && text.substr(offset - pattern.end.length - delta, pattern.end.length) == pattern.end) {
|
77
|
+
return pattern;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
// Handles inline formats like *abc* and **abc**
|
83
|
+
function applyInlineFormat(space) {
|
84
|
+
var selection, dom, rng, container, offset, startOffset, text, patternRng, pattern, delta, format;
|
85
|
+
|
86
|
+
function splitContainer() {
|
87
|
+
// Split text node and remove start/end from text node
|
88
|
+
container = container.splitText(startOffset);
|
89
|
+
container.splitText(offset - startOffset - delta);
|
90
|
+
container.deleteData(0, pattern.start.length);
|
91
|
+
container.deleteData(container.data.length - pattern.end.length, pattern.end.length);
|
92
|
+
}
|
93
|
+
|
94
|
+
selection = editor.selection;
|
95
|
+
dom = editor.dom;
|
96
|
+
|
97
|
+
if (!selection.isCollapsed()) {
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
|
101
|
+
rng = selection.getRng(true);
|
102
|
+
container = rng.startContainer;
|
103
|
+
offset = rng.startOffset;
|
104
|
+
text = container.data;
|
105
|
+
delta = space ? 1 : 0;
|
106
|
+
|
107
|
+
if (container.nodeType != 3) {
|
108
|
+
return;
|
109
|
+
}
|
110
|
+
|
111
|
+
// Find best matching end
|
112
|
+
pattern = findEndPattern(text, offset, delta);
|
113
|
+
if (!pattern) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
|
117
|
+
// Find start of matched pattern
|
118
|
+
// TODO: Might need to improve this if there is nested formats
|
119
|
+
startOffset = Math.max(0, offset - delta);
|
120
|
+
startOffset = text.lastIndexOf(pattern.start, startOffset - pattern.end.length - 1);
|
121
|
+
|
122
|
+
if (startOffset === -1) {
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
|
126
|
+
// Setup a range for the matching word
|
127
|
+
patternRng = dom.createRng();
|
128
|
+
patternRng.setStart(container, startOffset);
|
129
|
+
patternRng.setEnd(container, offset - delta);
|
130
|
+
pattern = findPattern(patternRng.toString());
|
131
|
+
|
132
|
+
if (!pattern || !pattern.end) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
// If container match doesn't have anything between start/end then do nothing
|
137
|
+
if (container.data.length <= pattern.start.length + pattern.end.length) {
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
141
|
+
format = editor.formatter.get(pattern.format);
|
142
|
+
if (format && format[0].inline) {
|
143
|
+
splitContainer();
|
144
|
+
editor.formatter.apply(pattern.format, {}, container);
|
145
|
+
return container;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
// Handles block formats like ##abc or 1. abc
|
150
|
+
function applyBlockFormat() {
|
151
|
+
var selection, dom, container, firstTextNode, node, format, textBlockElm, pattern, walker, rng, offset;
|
152
|
+
|
153
|
+
selection = editor.selection;
|
154
|
+
dom = editor.dom;
|
155
|
+
|
156
|
+
if (!selection.isCollapsed()) {
|
157
|
+
return;
|
158
|
+
}
|
159
|
+
|
160
|
+
textBlockElm = dom.getParent(selection.getStart(), 'p');
|
161
|
+
if (textBlockElm) {
|
162
|
+
walker = new tinymce.dom.TreeWalker(textBlockElm, textBlockElm);
|
163
|
+
while ((node = walker.next())) {
|
164
|
+
if (node.nodeType == 3) {
|
165
|
+
firstTextNode = node;
|
166
|
+
break;
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
if (firstTextNode) {
|
171
|
+
pattern = findPattern(firstTextNode.data);
|
172
|
+
if (!pattern) {
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
176
|
+
rng = selection.getRng(true);
|
177
|
+
container = rng.startContainer;
|
178
|
+
offset = rng.startOffset;
|
179
|
+
|
180
|
+
if (firstTextNode == container) {
|
181
|
+
offset = Math.max(0, offset - pattern.start.length);
|
182
|
+
}
|
183
|
+
|
184
|
+
if (tinymce.trim(firstTextNode.data).length == pattern.start.length) {
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
if (pattern.format) {
|
189
|
+
format = editor.formatter.get(pattern.format);
|
190
|
+
if (format && format[0].block) {
|
191
|
+
firstTextNode.deleteData(0, pattern.start.length);
|
192
|
+
editor.formatter.apply(pattern.format, {}, firstTextNode);
|
193
|
+
|
194
|
+
rng.setStart(container, offset);
|
195
|
+
rng.collapse(true);
|
196
|
+
selection.setRng(rng);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
if (pattern.cmd) {
|
201
|
+
editor.undoManager.transact(function() {
|
202
|
+
firstTextNode.deleteData(0, pattern.start.length);
|
203
|
+
editor.execCommand(pattern.cmd);
|
204
|
+
});
|
205
|
+
}
|
206
|
+
}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
function handleEnter() {
|
211
|
+
var rng, wrappedTextNode;
|
212
|
+
|
213
|
+
wrappedTextNode = applyInlineFormat();
|
214
|
+
if (wrappedTextNode) {
|
215
|
+
rng = editor.dom.createRng();
|
216
|
+
rng.setStart(wrappedTextNode, wrappedTextNode.data.length);
|
217
|
+
rng.setEnd(wrappedTextNode, wrappedTextNode.data.length);
|
218
|
+
editor.selection.setRng(rng);
|
219
|
+
}
|
220
|
+
|
221
|
+
applyBlockFormat();
|
222
|
+
}
|
223
|
+
|
224
|
+
function handleSpace() {
|
225
|
+
var wrappedTextNode, lastChar, lastCharNode, rng, dom;
|
226
|
+
|
227
|
+
wrappedTextNode = applyInlineFormat(true);
|
228
|
+
if (wrappedTextNode) {
|
229
|
+
dom = editor.dom;
|
230
|
+
lastChar = wrappedTextNode.data.slice(-1);
|
231
|
+
|
232
|
+
// Move space after the newly formatted node
|
233
|
+
if (/[\u00a0 ]/.test(lastChar)) {
|
234
|
+
wrappedTextNode.deleteData(wrappedTextNode.data.length - 1, 1);
|
235
|
+
lastCharNode = dom.doc.createTextNode(lastChar);
|
236
|
+
|
237
|
+
if (wrappedTextNode.nextSibling) {
|
238
|
+
dom.insertAfter(lastCharNode, wrappedTextNode.nextSibling);
|
239
|
+
} else {
|
240
|
+
wrappedTextNode.parentNode.appendChild(lastCharNode);
|
241
|
+
}
|
242
|
+
|
243
|
+
rng = dom.createRng();
|
244
|
+
rng.setStart(lastCharNode, 1);
|
245
|
+
rng.setEnd(lastCharNode, 1);
|
246
|
+
editor.selection.setRng(rng);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
editor.on('keydown', function(e) {
|
252
|
+
if (e.keyCode == 13 && !tinymce.util.VK.modifierPressed(e)) {
|
253
|
+
handleEnter();
|
254
|
+
}
|
255
|
+
}, true);
|
256
|
+
|
257
|
+
editor.on('keyup', function(e) {
|
258
|
+
if (e.keyCode == 32 && !tinymce.util.VK.modifierPressed(e)) {
|
259
|
+
handleSpace();
|
260
|
+
}
|
261
|
+
});
|
262
|
+
|
263
|
+
this.getPatterns = getPatterns;
|
264
|
+
this.setPatterns = function(newPatterns) {
|
265
|
+
patterns = newPatterns;
|
266
|
+
isPatternsDirty = true;
|
267
|
+
};
|
268
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
tinymce.PluginManager.add("textpattern",function(a){function b(){return j&&(i.sort(function(a,b){return a.start.length>b.start.length?-1:a.start.length<b.start.length?1:0}),j=!1),i}function c(a){for(var c=b(),d=0;d<c.length;d++)if(0===a.indexOf(c[d].start)&&(!c[d].end||a.lastIndexOf(c[d].end)==a.length-c[d].end.length))return c[d]}function d(a,c,d){var e,f,g;for(e=b(),g=0;g<e.length;g++)if(f=e[g],f.end&&a.substr(c-f.end.length-d,f.end.length)==f.end)return f}function e(b){function e(){i=i.splitText(k),i.splitText(j-k-o),i.deleteData(0,n.start.length),i.deleteData(i.data.length-n.end.length,n.end.length)}var f,g,h,i,j,k,l,m,n,o,p;return f=a.selection,g=a.dom,f.isCollapsed()&&(h=f.getRng(!0),i=h.startContainer,j=h.startOffset,l=i.data,o=b?1:0,3==i.nodeType&&(n=d(l,j,o),n&&(k=Math.max(0,j-o),k=l.lastIndexOf(n.start,k-n.end.length-1),-1!==k&&(m=g.createRng(),m.setStart(i,k),m.setEnd(i,j-o),n=c(m.toString()),n&&n.end&&!(i.data.length<=n.start.length+n.end.length)))))?(p=a.formatter.get(n.format),p&&p[0].inline?(e(),a.formatter.apply(n.format,{},i),i):void 0):void 0}function f(){var b,d,e,f,g,h,i,j,k,l,m;if(b=a.selection,d=a.dom,b.isCollapsed()&&(i=d.getParent(b.getStart(),"p"))){for(k=new tinymce.dom.TreeWalker(i,i);g=k.next();)if(3==g.nodeType){f=g;break}if(f){if(j=c(f.data),!j)return;if(l=b.getRng(!0),e=l.startContainer,m=l.startOffset,f==e&&(m=Math.max(0,m-j.start.length)),tinymce.trim(f.data).length==j.start.length)return;j.format&&(h=a.formatter.get(j.format),h&&h[0].block&&(f.deleteData(0,j.start.length),a.formatter.apply(j.format,{},f),l.setStart(e,m),l.collapse(!0),b.setRng(l))),j.cmd&&a.undoManager.transact(function(){f.deleteData(0,j.start.length),a.execCommand(j.cmd)})}}}function g(){var b,c;c=e(),c&&(b=a.dom.createRng(),b.setStart(c,c.data.length),b.setEnd(c,c.data.length),a.selection.setRng(b)),f()}function h(){var b,c,d,f,g;b=e(!0),b&&(g=a.dom,c=b.data.slice(-1),/[\u00a0 ]/.test(c)&&(b.deleteData(b.data.length-1,1),d=g.doc.createTextNode(c),b.nextSibling?g.insertAfter(d,b.nextSibling):b.parentNode.appendChild(d),f=g.createRng(),f.setStart(d,1),f.setEnd(d,1),a.selection.setRng(f)))}var i,j=!0;i=a.settings.textpattern_patterns||[{start:"*",end:"*",format:"italic"},{start:"**",end:"**",format:"bold"},{start:"#",format:"h1"},{start:"##",format:"h2"},{start:"###",format:"h3"},{start:"####",format:"h4"},{start:"#####",format:"h5"},{start:"######",format:"h6"},{start:"1. ",cmd:"InsertOrderedList"},{start:"* ",cmd:"InsertUnorderedList"},{start:"- ",cmd:"InsertUnorderedList"}],a.on("keydown",function(a){13!=a.keyCode||tinymce.util.VK.modifierPressed(a)||g()},!0),a.on("keyup",function(a){32!=a.keyCode||tinymce.util.VK.modifierPressed(a)||h()}),this.getPatterns=b,this.setPatterns=function(a){i=a,j=!0}});
|
@@ -0,0 +1,135 @@
|
|
1
|
+
.mce-visualblocks p {
|
2
|
+
padding-top: 10px;
|
3
|
+
border: 1px dashed #BBB;
|
4
|
+
margin-left: 3px;
|
5
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhCQAJAJEAAAAAAP///7u7u////yH5BAEAAAMALAAAAAAJAAkAAAIQnG+CqCN/mlyvsRUpThG6AgA7);
|
6
|
+
}
|
7
|
+
|
8
|
+
.mce-visualblocks h1 {
|
9
|
+
padding-top: 10px;
|
10
|
+
border: 1px dashed #BBB;
|
11
|
+
margin-left: 3px;
|
12
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybGu1JuxHoAfRNRW3TWXyF2YiRUAOw==);
|
13
|
+
}
|
14
|
+
|
15
|
+
.mce-visualblocks h2 {
|
16
|
+
padding-top: 10px;
|
17
|
+
border: 1px dashed #BBB;
|
18
|
+
margin-left: 3px;
|
19
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8Hybbx4oOuqgTynJd6bGlWg3DkJzoaUAAAOw==);
|
20
|
+
}
|
21
|
+
|
22
|
+
.mce-visualblocks h3 {
|
23
|
+
padding-top: 10px;
|
24
|
+
border: 1px dashed #BBB;
|
25
|
+
margin-left: 3px;
|
26
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIZjI8Hybbx4oOuqgTynJf2Ln2NOHpQpmhAAQA7);
|
27
|
+
}
|
28
|
+
|
29
|
+
.mce-visualblocks h4 {
|
30
|
+
padding-top: 10px;
|
31
|
+
border: 1px dashed #BBB;
|
32
|
+
margin-left: 3px;
|
33
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxInR0zqeAdhtJlXwV1oCll2HaWgAAOw==);
|
34
|
+
}
|
35
|
+
|
36
|
+
.mce-visualblocks h5 {
|
37
|
+
padding-top: 10px;
|
38
|
+
border: 1px dashed #BBB;
|
39
|
+
margin-left: 3px;
|
40
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjane4iq5GlW05GgIkIZUAAAOw==);
|
41
|
+
}
|
42
|
+
|
43
|
+
.mce-visualblocks h6 {
|
44
|
+
padding-top: 10px;
|
45
|
+
border: 1px dashed #BBB;
|
46
|
+
margin-left: 3px;
|
47
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDgAKAIABALu7u////yH5BAEAAAEALAAAAAAOAAoAAAIajI8HybbxIoiuwjan04jep1iZ1XRlAo5bVgAAOw==);
|
48
|
+
}
|
49
|
+
|
50
|
+
.mce-visualblocks div {
|
51
|
+
padding-top: 10px;
|
52
|
+
border: 1px dashed #BBB;
|
53
|
+
margin-left: 3px;
|
54
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhEgAKAIABALu7u////yH5BAEAAAEALAAAAAASAAoAAAIfjI9poI0cgDywrhuxfbrzDEbQM2Ei5aRjmoySW4pAAQA7);
|
55
|
+
}
|
56
|
+
|
57
|
+
.mce-visualblocks section {
|
58
|
+
padding-top: 10px;
|
59
|
+
border: 1px dashed #BBB;
|
60
|
+
margin: 0 0 1em 3px;
|
61
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhKAAKAIABALu7u////yH5BAEAAAEALAAAAAAoAAoAAAI5jI+pywcNY3sBWHdNrplytD2ellDeSVbp+GmWqaDqDMepc8t17Y4vBsK5hDyJMcI6KkuYU+jpjLoKADs=);
|
62
|
+
}
|
63
|
+
|
64
|
+
.mce-visualblocks article {
|
65
|
+
padding-top: 10px;
|
66
|
+
border: 1px dashed #BBB;
|
67
|
+
margin: 0 0 1em 3px;
|
68
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhKgAKAIABALu7u////yH5BAEAAAEALAAAAAAqAAoAAAI6jI+pywkNY3wG0GBvrsd2tXGYSGnfiF7ikpXemTpOiJScasYoDJJrjsG9gkCJ0ag6KhmaIe3pjDYBBQA7);
|
69
|
+
}
|
70
|
+
|
71
|
+
.mce-visualblocks blockquote {
|
72
|
+
padding-top: 10px;
|
73
|
+
border: 1px dashed #BBB;
|
74
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhPgAKAIABALu7u////yH5BAEAAAEALAAAAAA+AAoAAAJPjI+py+0Knpz0xQDyuUhvfoGgIX5iSKZYgq5uNL5q69asZ8s5rrf0yZmpNkJZzFesBTu8TOlDVAabUyatguVhWduud3EyiUk45xhTTgMBBQA7);
|
75
|
+
}
|
76
|
+
|
77
|
+
.mce-visualblocks address {
|
78
|
+
padding-top: 10px;
|
79
|
+
border: 1px dashed #BBB;
|
80
|
+
margin: 0 0 1em 3px;
|
81
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhLQAKAIABALu7u////yH5BAEAAAEALAAAAAAtAAoAAAI/jI+pywwNozSP1gDyyZcjb3UaRpXkWaXmZW4OqKLhBmLs+K263DkJK7OJeifh7FicKD9A1/IpGdKkyFpNmCkAADs=);
|
82
|
+
}
|
83
|
+
|
84
|
+
.mce-visualblocks pre {
|
85
|
+
padding-top: 10px;
|
86
|
+
border: 1px dashed #BBB;
|
87
|
+
margin-left: 3px;
|
88
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhFQAKAIABALu7uwAAACH5BAEAAAEALAAAAAAVAAoAAAIjjI+ZoN0cgDwSmnpz1NCueYERhnibZVKLNnbOq8IvKpJtVQAAOw==);
|
89
|
+
}
|
90
|
+
|
91
|
+
.mce-visualblocks figure {
|
92
|
+
padding-top: 10px;
|
93
|
+
border: 1px dashed #BBB;
|
94
|
+
margin: 0 0 1em 3px;
|
95
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhJAAKAIAAALu7u////yH5BAEAAAEALAAAAAAkAAoAAAI0jI+py+2fwAHUSFvD3RlvG4HIp4nX5JFSpnZUJ6LlrM52OE7uSWosBHScgkSZj7dDKnWAAgA7);
|
96
|
+
}
|
97
|
+
|
98
|
+
.mce-visualblocks hgroup {
|
99
|
+
padding-top: 10px;
|
100
|
+
border: 1px dashed #BBB;
|
101
|
+
margin: 0 0 1em 3px;
|
102
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhJwAKAIABALu7uwAAACH5BAEAAAEALAAAAAAnAAoAAAI3jI+pywYNI3uB0gpsRtt5fFnfNZaVSYJil4Wo03Hv6Z62uOCgiXH1kZIIJ8NiIxRrAZNMZAtQAAA7);
|
103
|
+
}
|
104
|
+
|
105
|
+
.mce-visualblocks aside {
|
106
|
+
padding-top: 10px;
|
107
|
+
border: 1px dashed #BBB;
|
108
|
+
margin: 0 0 1em 3px;
|
109
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhHgAKAIABAKqqqv///yH5BAEAAAEALAAAAAAeAAoAAAItjI+pG8APjZOTzgtqy7I3f1yehmQcFY4WKZbqByutmW4aHUd6vfcVbgudgpYCADs=);
|
110
|
+
}
|
111
|
+
|
112
|
+
.mce-visualblocks figcaption {
|
113
|
+
border: 1px dashed #BBB;
|
114
|
+
}
|
115
|
+
|
116
|
+
.mce-visualblocks ul {
|
117
|
+
padding-top: 10px;
|
118
|
+
border: 1px dashed #BBB;
|
119
|
+
margin: 0 0 1em 3px;
|
120
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIAAALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybGuYnqUVSjvw26DzzXiqIDlVwAAOw==)
|
121
|
+
}
|
122
|
+
|
123
|
+
.mce-visualblocks ol {
|
124
|
+
padding-top: 10px;
|
125
|
+
border: 1px dashed #BBB;
|
126
|
+
margin: 0 0 1em 3px;
|
127
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybH6HHt0qourxC6CvzXieHyeWQAAOw==);
|
128
|
+
}
|
129
|
+
|
130
|
+
.mce-visualblocks dl {
|
131
|
+
padding-top: 10px;
|
132
|
+
border: 1px dashed #BBB;
|
133
|
+
margin: 0 0 1em 3px;
|
134
|
+
background: transparent no-repeat url(data:image/gif;base64,R0lGODlhDQAKAIABALu7u////yH5BAEAAAEALAAAAAANAAoAAAIXjI8GybEOnmOvUoWznTqeuEjNSCqeGRUAOw==);
|
135
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,86 @@
|
|
1
|
+
/**
|
2
|
+
* plugin.js
|
3
|
+
*
|
4
|
+
* Copyright 2012, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://www.tinymce.com/license
|
8
|
+
* Contributing: http://www.tinymce.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*global tinymce:true */
|
12
|
+
|
13
|
+
tinymce.PluginManager.add('visualblocks', function(editor, url) {
|
14
|
+
var cssId, visualBlocksMenuItem, enabled;
|
15
|
+
|
16
|
+
// We don't support older browsers like IE6/7 and they don't provide prototypes for DOM objects
|
17
|
+
if (!window.NodeList) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
|
21
|
+
function toggleActiveState() {
|
22
|
+
var self = this;
|
23
|
+
|
24
|
+
self.active(enabled);
|
25
|
+
|
26
|
+
editor.on('VisualBlocks', function() {
|
27
|
+
self.active(editor.dom.hasClass(editor.getBody(), 'mce-visualblocks'));
|
28
|
+
});
|
29
|
+
}
|
30
|
+
|
31
|
+
editor.addCommand('mceVisualBlocks', function() {
|
32
|
+
var dom = editor.dom, linkElm;
|
33
|
+
|
34
|
+
if (!cssId) {
|
35
|
+
cssId = dom.uniqueId();
|
36
|
+
linkElm = dom.create('link', {
|
37
|
+
id: cssId,
|
38
|
+
rel: 'stylesheet',
|
39
|
+
href: url + '/css/visualblocks.css'
|
40
|
+
});
|
41
|
+
|
42
|
+
editor.getDoc().getElementsByTagName('head')[0].appendChild(linkElm);
|
43
|
+
}
|
44
|
+
|
45
|
+
// Toggle on/off visual blocks while computing previews
|
46
|
+
editor.on("PreviewFormats AfterPreviewFormats", function(e) {
|
47
|
+
if (enabled) {
|
48
|
+
dom.toggleClass(editor.getBody(), 'mce-visualblocks', e.type == "afterpreviewformats");
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
dom.toggleClass(editor.getBody(), 'mce-visualblocks');
|
53
|
+
enabled = editor.dom.hasClass(editor.getBody(), 'mce-visualblocks');
|
54
|
+
|
55
|
+
if (visualBlocksMenuItem) {
|
56
|
+
visualBlocksMenuItem.active(dom.hasClass(editor.getBody(), 'mce-visualblocks'));
|
57
|
+
}
|
58
|
+
|
59
|
+
editor.fire('VisualBlocks');
|
60
|
+
});
|
61
|
+
|
62
|
+
editor.addButton('visualblocks', {
|
63
|
+
title: 'Show blocks',
|
64
|
+
cmd: 'mceVisualBlocks',
|
65
|
+
onPostRender: toggleActiveState
|
66
|
+
});
|
67
|
+
|
68
|
+
editor.addMenuItem('visualblocks', {
|
69
|
+
text: 'Show blocks',
|
70
|
+
cmd: 'mceVisualBlocks',
|
71
|
+
onPostRender: toggleActiveState,
|
72
|
+
selectable: true,
|
73
|
+
context: 'view',
|
74
|
+
prependToContext: true
|
75
|
+
});
|
76
|
+
|
77
|
+
editor.on('init', function() {
|
78
|
+
if (editor.settings.visualblocks_default_state) {
|
79
|
+
editor.execCommand('mceVisualBlocks', false, null, {skip_focus: true});
|
80
|
+
}
|
81
|
+
});
|
82
|
+
|
83
|
+
editor.on('remove', function() {
|
84
|
+
editor.dom.removeClass(editor.getBody(), 'mce-visualblocks');
|
85
|
+
});
|
86
|
+
});
|