Update
This commit is contained in:
47
public/admin/plugins/tmce/codemagic/codemagic.htm
Normal file
47
public/admin/plugins/tmce/codemagic/codemagic.htm
Normal file
@@ -0,0 +1,47 @@
|
||||
<!--
|
||||
*
|
||||
*
|
||||
* @author Josh Lobe
|
||||
* http://ultimatetinymcepro.com
|
||||
*/
|
||||
-->
|
||||
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
|
||||
<script type="text/javascript" src="includes/codemirror/codemirror.js"></script>
|
||||
<script type="text/javascript" src="includes/batched_scripts.js"></script>
|
||||
<script type="text/javascript" src="includes/codemagic.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="includes/codemagic.css" />
|
||||
<link rel="stylesheet" href="includes/codemirror/codemirror.css" />
|
||||
|
||||
<div id="body">
|
||||
|
||||
<div id="wrapline">
|
||||
<input type="checkbox" name="wraptext" id="wraptext" checked="checked" /> Wrap text
|
||||
<input type="checkbox" name="autocompletion" id="autocompletion" checked="checked" /> Auto completion
|
||||
<input type="checkbox" name="highlighting" id="highlighting" checked="checked" /> Highlight Code
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
|
||||
<div class="editor-buttons">
|
||||
<a id="undo" class="disabled" title="Undo"><img src="images/icons/undo.png" alt="Undo" /> Undo</a>
|
||||
<a id="redo" class="disabled" title="Redo"><img src="images/icons/redo.png" alt="Redo" /> Redo</a>
|
||||
<a id="search_replace" title="Search and Replace"><img src="images/icons/lens.png" alt="Search and Replace" /> Search/Replace</a>
|
||||
<a id="re_beautify" title="Format HTML Code"><img src="images/icons/file.png" alt="Format HTML Code" /> Reformat</a>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
<div id="search_panel">
|
||||
<span id="search_query"><label for="query">Search</label>: <input id="query" type="text" class="form-control" /></span>
|
||||
<span id="replace_query"><label for="replace">Replace</label>: <input id="replace" type="text" class="form-control" /></span>
|
||||
<span id="search_button"><input id="search_code" type="submit" value="Search" class="btn-default" /></span>
|
||||
<span id="replace_button"><input id="replace_code" type="submit" value="Replace" class="btn-default" /></span>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
||||
<textarea name="htmlSource" id="htmlSource" rows="25" cols="100" class="htmlSource"></textarea>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<button id="codemagic_cancel" class="btn-default">Cancel</button> <button id="codemagic_insert" class="btn-primary">Insert and Close</button>
|
||||
</div>
|
||||
</div>
|
||||
BIN
public/admin/plugins/tmce/codemagic/images/codemagic.png
Normal file
BIN
public/admin/plugins/tmce/codemagic/images/codemagic.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
public/admin/plugins/tmce/codemagic/images/icons/file.png
Normal file
BIN
public/admin/plugins/tmce/codemagic/images/icons/file.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 192 B |
BIN
public/admin/plugins/tmce/codemagic/images/icons/lens.png
Normal file
BIN
public/admin/plugins/tmce/codemagic/images/icons/lens.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 384 B |
BIN
public/admin/plugins/tmce/codemagic/images/icons/redo.png
Normal file
BIN
public/admin/plugins/tmce/codemagic/images/icons/redo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 305 B |
BIN
public/admin/plugins/tmce/codemagic/images/icons/undo.png
Normal file
BIN
public/admin/plugins/tmce/codemagic/images/icons/undo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 327 B |
File diff suppressed because one or more lines are too long
158
public/admin/plugins/tmce/codemagic/includes/codemagic.css
Normal file
158
public/admin/plugins/tmce/codemagic/includes/codemagic.css
Normal file
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Josh Lobe
|
||||
* http://ultimatetinymcepro.com
|
||||
*/
|
||||
|
||||
|
||||
.btn-primary, .btn-default {
|
||||
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 1px 1px rgba(0, 0, 0, 0.075);
|
||||
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
|
||||
font-weight: bold;
|
||||
}
|
||||
.btn-primary {
|
||||
background-image: linear-gradient(to bottom, #428BCA 0px, #3071A9 100%);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #2D6CA2;
|
||||
color: #FFF;
|
||||
padding: 5px 20px;
|
||||
}
|
||||
.btn-default {
|
||||
background-image: linear-gradient(to bottom, #FFFFFF 0px, #E6E6E6 100%);
|
||||
background-repeat: repeat-x;
|
||||
border-color: #CCCCCC;
|
||||
text-shadow: 0 1px 0 #FFFFFF;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
.form-control {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #CCCCCC;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
|
||||
color: #555555;
|
||||
font-size: 14px;
|
||||
height: 34px;
|
||||
line-height: 1.42857;
|
||||
padding: 6px 12px;
|
||||
transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
|
||||
}
|
||||
.form-control:focus {
|
||||
border-color: #66AFE9;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);
|
||||
outline: 0 none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#codemagic_insert {
|
||||
float:right;
|
||||
margin-right:20px;
|
||||
cursor:pointer;
|
||||
}
|
||||
#codemagic_cancel {
|
||||
float:right;
|
||||
margin-right:20px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.mceActionPanel {
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
#htmlSource {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.editor-buttons {
|
||||
margin:20px 0px;
|
||||
display:block;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.editor-buttons a {
|
||||
width: 16px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #CCC;
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.editor-buttons a:hover,
|
||||
.editor-buttons a.selected {
|
||||
background-color: #C2CBE0;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
|
||||
.editor-buttons a.disabled,
|
||||
.editor-buttons a.disabled:hover {
|
||||
background-color: transparent;
|
||||
border: 1px solid #F0F0EE;
|
||||
cursor: default;
|
||||
opacity: .35;
|
||||
filter: alpha(opacity=35);
|
||||
-ms-filter: "alpha(opacity=35)";
|
||||
}
|
||||
|
||||
.editor-buttons a.disabled img {
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
border: 1px solid #666;
|
||||
margin-top:10px;
|
||||
height:450px !important;
|
||||
}
|
||||
.CodeMirror-selectedtext {
|
||||
background-color: #ccc !important;
|
||||
}
|
||||
.cm-matchhighlight {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
#wrapline {
|
||||
display:block;
|
||||
text-align:center;
|
||||
}
|
||||
#autocompletion, #highlighting {
|
||||
margin-left:30px;
|
||||
}
|
||||
|
||||
#search_panel {
|
||||
display:none;
|
||||
margin-left:60px;
|
||||
}
|
||||
#search_query {
|
||||
float:left;
|
||||
}
|
||||
#replace_query {
|
||||
float:left;
|
||||
margin-left:20px;
|
||||
}
|
||||
#search_button {
|
||||
float:left;
|
||||
margin-left:40px;
|
||||
}
|
||||
#replace_button {
|
||||
float:left;
|
||||
margin-left:20px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.completions {
|
||||
position: absolute;
|
||||
border: 1px solid #000000;
|
||||
background-color: #F0F0EE;
|
||||
padding: 3px;
|
||||
z-index:99;
|
||||
}
|
||||
|
||||
.completions select {
|
||||
background-color: #FFFFFF;
|
||||
border: 1px solid #B5A69C;
|
||||
width: 200px;
|
||||
}
|
||||
528
public/admin/plugins/tmce/codemagic/includes/codemagic.js
Normal file
528
public/admin/plugins/tmce/codemagic/includes/codemagic.js
Normal file
@@ -0,0 +1,528 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Josh Lobe
|
||||
* http://ultimatetinymcepro.com
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// Declare global variables
|
||||
var editor = top.tinymce.activeEditor;
|
||||
var lastQuery = null;
|
||||
var lastPos = null;
|
||||
var marked = [];
|
||||
var autocompletion_active = true;
|
||||
|
||||
// Instantiate CodeMirror on textarea
|
||||
var myCodeMirror = CodeMirror.fromTextArea($("#htmlSource")[0], {
|
||||
|
||||
mode: "text/html",
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
styleActiveLine: true,
|
||||
styleSelectedText: true,
|
||||
highlightSelectionMatches: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
|
||||
// Beautify source HTML and populate CodeMirror textarea
|
||||
myCodeMirror.doc.setValue( style_html(editor.getContent({format : 'html'}), 4) );
|
||||
|
||||
// Set focus to codemirror window
|
||||
myCodeMirror.focus();
|
||||
|
||||
// Add change event to capture undo;redo events
|
||||
myCodeMirror.on('change', function(i, e) {
|
||||
|
||||
// Set undo and redo levels
|
||||
var undo = myCodeMirror.doc.historySize().undo;
|
||||
var redo = myCodeMirror.doc.historySize().redo;
|
||||
|
||||
// Toggle class name for action buttons
|
||||
if(undo > 1) $("#undo").attr('class', '');
|
||||
else $("#undo").attr('class', 'disabled');
|
||||
|
||||
if(redo > 0) $("#redo").attr('class', '');
|
||||
else $("#redo").attr('class', 'disabled');
|
||||
});
|
||||
|
||||
// Initialize autocomplete
|
||||
myCodeMirror.on('keypress', function(i, e) {
|
||||
|
||||
if(autocompletion_active) {
|
||||
|
||||
/* Hook into charcode '<' */
|
||||
if(String.fromCharCode(e.which == null ? e.keyCode : e.which) == "<") {
|
||||
|
||||
// Prevent keypress of '<'
|
||||
e.preventDefault();
|
||||
|
||||
var cur = myCodeMirror.getCursor(false), token = myCodeMirror.getTokenAt(cur);
|
||||
myCodeMirror.replaceRange("<", cur); // Replace '<' back into range
|
||||
|
||||
setTimeout(startComplete, 50);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Cancel button
|
||||
$('#codemagic_cancel').click(function() {
|
||||
|
||||
editor.windowManager.close();
|
||||
});
|
||||
// Insert button
|
||||
$('#codemagic_insert').click(function() {
|
||||
|
||||
window_content = myCodeMirror.doc.getValue(); // Get codemirror html
|
||||
editor.setContent(window_content); // Set editor content to codermirror content
|
||||
editor.windowManager.close(); // Close window
|
||||
});
|
||||
|
||||
// Codemagic action buttons
|
||||
// Undo
|
||||
$('#undo').click(function() {
|
||||
|
||||
if($(this).attr('class') != 'disabled') {
|
||||
|
||||
// Check if undo button is disabled
|
||||
className = $('#undo').attr('class');
|
||||
if(className == 'disabled') return;
|
||||
|
||||
// Undo step
|
||||
myCodeMirror.doc.undo();
|
||||
}
|
||||
});
|
||||
// Redo
|
||||
$('#redo').click(function() {
|
||||
|
||||
if($(this).attr('class') != 'disabled') {
|
||||
|
||||
// Redo step
|
||||
myCodeMirror.doc.redo();
|
||||
}
|
||||
});
|
||||
// Search and Replace
|
||||
$( "#search_replace" ).click(function() {
|
||||
|
||||
if($(this).attr('class') != 'disabled') {
|
||||
|
||||
$( "#search_replace" ).toggleClass( 'selected' );
|
||||
$( "#search_panel" ).slideToggle( "slow", function() {
|
||||
// Animation complete.
|
||||
});
|
||||
}
|
||||
});
|
||||
// Re-format html window code
|
||||
$('#re_beautify').click(function() {
|
||||
|
||||
if($(this).attr('class') != 'disabled') {
|
||||
|
||||
// Re-beautify html in window manager
|
||||
window_html = myCodeMirror.doc.getValue();
|
||||
myCodeMirror.doc.setValue(
|
||||
|
||||
style_html(window_html, 4)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle Line Wrapping
|
||||
$("#wraptext").click( function() {
|
||||
|
||||
if ($(this).is(':checked')){ myCodeMirror.setOption('lineWrapping', true); }
|
||||
else { myCodeMirror.setOption('lineWrapping', false); }
|
||||
});
|
||||
|
||||
// Toggle Auto Completion
|
||||
$("#autocompletion").click( function() {
|
||||
|
||||
if ($(this).is(':checked')){ autocompletion_active = true; }
|
||||
else { autocompletion_active = false; }
|
||||
});
|
||||
|
||||
// Toggle Code Highlighting
|
||||
$("#highlighting").click( function() {
|
||||
|
||||
if ($(this).is(':checked')){ activateCodeColoring('htmlSource'); }
|
||||
else { deactivateCodeColoring(); }
|
||||
});
|
||||
|
||||
// Activate code highlighting
|
||||
function activateCodeColoring(id) {
|
||||
|
||||
// Enable buttons
|
||||
$("#search_replace").attr('class', '');
|
||||
$("#re_beautify").attr('class', '');
|
||||
$("#autocompletion").attr("disabled", false);
|
||||
|
||||
// Redraw codemirror textarea
|
||||
myCodeMirror = CodeMirror.fromTextArea($("#htmlSource")[0], {
|
||||
|
||||
mode: "text/html",
|
||||
lineNumbers: true,
|
||||
styleActiveLine: true,
|
||||
styleSelectedText: true,
|
||||
highlightSelectionMatches: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
|
||||
// Set focus to window
|
||||
myCodeMirror.focus();
|
||||
|
||||
// Add change event to capture undo;redo events
|
||||
myCodeMirror.on('change', function(e) {
|
||||
|
||||
// Set undo and redo levels
|
||||
var undo = myCodeMirror.doc.historySize().undo;
|
||||
var redo = myCodeMirror.doc.historySize().redo;
|
||||
|
||||
// Toggle class name for action buttons
|
||||
if(undo > 0) $("#undo").attr('class', '');
|
||||
else $("#undo").attr('class', 'disabled');
|
||||
|
||||
if(redo > 0) $("#redo").attr('class', '');
|
||||
else $("#redo").attr('class', 'disabled');
|
||||
});
|
||||
|
||||
// Initialize autocomplete
|
||||
myCodeMirror.on('keypress', function(i, e) {
|
||||
|
||||
if(autocompletion_active) {
|
||||
|
||||
/* Hook into charcode '<' */
|
||||
if(String.fromCharCode(e.which == null ? e.keyCode : e.which) == "<") {
|
||||
|
||||
// Prevent keypress of '<'
|
||||
e.preventDefault();
|
||||
|
||||
var cur = myCodeMirror.getCursor(false), token = myCodeMirror.getTokenAt(cur);
|
||||
myCodeMirror.replaceRange("<", cur); // Replace '<' back into range
|
||||
|
||||
setTimeout(startComplete, 50);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Match linewrap option
|
||||
if ($("#wraptext").is(':checked')) { myCodeMirror.setOption('lineWrapping', true); }
|
||||
else { myCodeMirror.setOption('lineWrapping', false); }
|
||||
}
|
||||
|
||||
|
||||
// Deactivate code highlighting
|
||||
function deactivateCodeColoring() {
|
||||
|
||||
// Clear undo history
|
||||
myCodeMirror.doc.clearHistory();
|
||||
|
||||
// Disable buttons
|
||||
$("#undo").attr('class', 'disabled');
|
||||
$("#redo").attr('class', 'disabled');
|
||||
$("#search_replace").attr('class', 'disabled');
|
||||
$("#re_beautify").attr('class', 'disabled');
|
||||
$("#autocompletion").attr("disabled", true);
|
||||
|
||||
// Send codemirror back to original textarea
|
||||
myCodeMirror.toTextArea();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***************************************
|
||||
****************************************
|
||||
Search and Replace
|
||||
*/
|
||||
|
||||
|
||||
// Search code button
|
||||
$('#search_code').click(function() { searchCode(); });
|
||||
// Replace code button
|
||||
$('#replace_code').click(function() { replaceCode(); });
|
||||
|
||||
// Unmark all highlighted words
|
||||
function unmark() { marked.length = 0; }
|
||||
|
||||
// Search code function
|
||||
function searchCode() {
|
||||
|
||||
unmark();
|
||||
|
||||
var text = $("#query").val();
|
||||
|
||||
if (!text) return false;
|
||||
|
||||
if(!myCodeMirror.getSearchCursor(text).findNext()) {
|
||||
|
||||
alert('Nothing Found.');
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var cursor = myCodeMirror.getSearchCursor(text); cursor.findNext();)
|
||||
marked.push(myCodeMirror.markText(cursor.from(), cursor.to(), "searched"));
|
||||
|
||||
if (lastQuery != text) lastPos = null;
|
||||
|
||||
var cursor = myCodeMirror.getSearchCursor(text, lastPos || myCodeMirror.getCursor());
|
||||
|
||||
if (!cursor.findNext()) {
|
||||
|
||||
cursor = myCodeMirror.getSearchCursor(text);
|
||||
if (!cursor.findNext()) return;
|
||||
}
|
||||
myCodeMirror.setSelection(cursor.from(), cursor.to());
|
||||
lastQuery = text; lastPos = cursor.to();
|
||||
}
|
||||
|
||||
// Replace code function
|
||||
function replaceCode() {
|
||||
|
||||
unmark();
|
||||
|
||||
var s_text = $("#query").val();
|
||||
var replace = $("#replace").val();
|
||||
|
||||
if (!s_text) return false;
|
||||
|
||||
if(!myCodeMirror.getSearchCursor(s_text).findNext()) {
|
||||
|
||||
alert('Nothing to Replace.');
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var cursor = myCodeMirror.getSearchCursor(s_text); cursor.findNext();)
|
||||
myCodeMirror.replaceRange(replace, cursor.from(), cursor.to());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************
|
||||
****************************************
|
||||
Autocompletion
|
||||
*/
|
||||
var tagNames = ("a abbr acronym address applet area b base basefont bdo big blockquote body br button" +
|
||||
" caption center cite code col colgroup dd del dfn dir div dl dt em fieldset font form frame" +
|
||||
" frameset h1 h2 h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map" +
|
||||
" menu meta noframes noscript object ol optgroup option p param pre q s samp script select small" +
|
||||
" span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var").split(" ");
|
||||
|
||||
var pairedTags = ("a abbr acronym address applet b bdo big blockquote body button" +
|
||||
" caption center cite code colgroup del dfn dir div dl em fieldset font form" +
|
||||
" frameset h1 h2 h3 h4 h5 h6 head html i iframe ins kbd label legend li map" +
|
||||
" menu noframes noscript object ol optgroup option p pre q s samp script select small" +
|
||||
" span strike strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var").split(" ");
|
||||
|
||||
var unPairedTags = ("area base basefont br col dd dt frame hr img input isindex link meta param").split(" ");
|
||||
|
||||
var specialTags = {
|
||||
|
||||
"applet" : { tag: 'applet width="" height=""></applet>', cusror: 8 },
|
||||
"area" : { tag: 'area alt="" />', cusror: 6 },
|
||||
"base" : { tag: 'base href="" />', cusror: 7 },
|
||||
"form" : { tag: 'form action=""></form>', cusror: 9 },
|
||||
"img" : { tag: 'img src="" alt="" />', cusror: 6 },
|
||||
"map" : { tag: 'map name=""></map>', cusror: 7 },
|
||||
"meta" : { tag: 'meta content="" />', cusror: 10 },
|
||||
"optgroup" : { tag: 'optgroup label=""></optgroup>', cusror: 8 },
|
||||
"param" : { tag: 'param name="" />', cusror: 7 },
|
||||
"script" : { tag: 'script type=""></script>', cusror: 7 },
|
||||
"style" : { tag: 'style type=""></style>', cusror: 7 },
|
||||
"textarea" : { tag: 'textarea cols="" rows=""></textarea>', cusror: 7 }
|
||||
}
|
||||
|
||||
function forEach(arr, f) { for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]); }
|
||||
|
||||
Array.prototype.inArray = function(value){
|
||||
|
||||
for (var key in this)
|
||||
if (this[key] === value) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Autocompletion Start
|
||||
function startComplete() {
|
||||
|
||||
var startingTag, unPaired;
|
||||
|
||||
// We want a single cursor position.
|
||||
if (myCodeMirror.somethingSelected()) return;
|
||||
|
||||
// Find the token at the cursor
|
||||
var cur = myCodeMirror.getCursor(false),
|
||||
token = myCodeMirror.getTokenAt(cur),
|
||||
tprop = token;
|
||||
|
||||
if(token.string.indexOf("<") == 0 && token.string.indexOf("</") != 0) {
|
||||
|
||||
token.string = token.string.replace("<", "");
|
||||
token.start++;
|
||||
startingTag = true;
|
||||
}
|
||||
else if(token.string.indexOf("</") == 0) {
|
||||
|
||||
token.string = token.string.replace("</", "");
|
||||
token.start += 2;
|
||||
startingTag = false;
|
||||
}
|
||||
else {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the tags
|
||||
var completions = getCompletions(token, startingTag);
|
||||
if (!completions.length) return;
|
||||
|
||||
// Insert tag into codemirror window
|
||||
function insert(str) {
|
||||
|
||||
if(str == "") return;
|
||||
|
||||
// Trim
|
||||
str = str.replace(/^\s+|\s+$/g,"");
|
||||
|
||||
// Is this an unpaired tag?
|
||||
unPaired = unPairedTags.inArray(str) ? true : false;
|
||||
|
||||
if(specialTags[str] != null && startingTag) {
|
||||
|
||||
var insertTag = specialTags[str].tag;
|
||||
var jumpTo = (token.start + str.length + specialTags[str].cusror);
|
||||
}
|
||||
else if(startingTag && unPaired) {
|
||||
|
||||
var insertTag = str + " />";
|
||||
var jumpTo = (token.start + str.length + 3);
|
||||
}
|
||||
else if (startingTag) {
|
||||
|
||||
var insertTag = str + "></" + str + ">";
|
||||
var jumpTo = (token.start + str.length + 1);
|
||||
}
|
||||
else {
|
||||
|
||||
var insertTag = str + ">";
|
||||
var jumpTo = (token.start + str.length + 1);
|
||||
}
|
||||
|
||||
// Insert tag
|
||||
myCodeMirror.replaceRange(insertTag, {line: cur.line, ch: token.start}, {line: cur.line, ch: token.end});
|
||||
myCodeMirror.setCursor({line: cur.line, ch: jumpTo});
|
||||
|
||||
// Unbind events so additional uses of window don't populate all binded history events
|
||||
$('body').off('dblclick', 'option');
|
||||
$('body').off('keydown', 'select');
|
||||
}
|
||||
|
||||
|
||||
// Build the select widget
|
||||
var complete = $( "<div class='completions'>" );
|
||||
var option_tag = [];
|
||||
|
||||
for (var i = 0; i < completions.length; ++i) {
|
||||
|
||||
option_tag += "<option>" + completions[i] + "</option>";
|
||||
}
|
||||
var sel = complete.append('<select id="completions_options">'+option_tag+'</select>');
|
||||
|
||||
// Select first option
|
||||
$('select option:first-child').attr("selected", "selected");
|
||||
|
||||
// Show six options in select box
|
||||
complete.children().attr('size', '10');
|
||||
|
||||
// Left position
|
||||
var pos = myCodeMirror.cursorCoords();
|
||||
complete.css('margin-left', pos.left+'px');
|
||||
|
||||
// Top position
|
||||
if(pos.top > 0) pos.top = pos.top - 550;
|
||||
complete.css('margin-top', pos.top+'px');
|
||||
|
||||
|
||||
// Append populated div and select box to body
|
||||
$('body').append(complete);
|
||||
|
||||
// Apply focus to select box
|
||||
$('select').focus();
|
||||
|
||||
|
||||
|
||||
// Close autocompletion window
|
||||
function close_autocomplete() { complete.remove(); }
|
||||
|
||||
// Grab select option (tag) and run insert() function.
|
||||
function pick() {
|
||||
|
||||
html_tag = $('#completions_options').find(":selected").text();
|
||||
|
||||
insert(html_tag);
|
||||
close_autocomplete();
|
||||
|
||||
// Re-focus codemirror window after a brief delay
|
||||
setTimeout(function(){ myCodeMirror.focus(); }, 50);
|
||||
}
|
||||
|
||||
// Bind dblclick to autocomplete option box
|
||||
$('body').on('dblclick', 'option', function() { pick(); });
|
||||
|
||||
// Bind keydown event to select box
|
||||
$('body').on('keydown', 'select', function(e) {
|
||||
|
||||
var code = e.keyCode;
|
||||
|
||||
// Enter, space, tab
|
||||
if (code == 13 || code == 32 || code == 9) {
|
||||
|
||||
e.preventDefault();
|
||||
pick();
|
||||
}
|
||||
// Escape
|
||||
else if (code == 27) {
|
||||
|
||||
e.preventDefault();
|
||||
close_autocomplete();
|
||||
myCodeMirror.focus();
|
||||
}
|
||||
// Other than arrow up/down
|
||||
else if (code != 38 && code != 40 && code != 16 && code != 17 && code != 18 && code != 91 && code != 92) {
|
||||
|
||||
close_autocomplete();
|
||||
myCodeMirror.focus();
|
||||
|
||||
if(code != 39 && code != 37) {
|
||||
|
||||
// Unbind event handlers
|
||||
$('body').off('dblclick', 'option');
|
||||
$('body').off('keydown', 'select');
|
||||
|
||||
setTimeout(startComplete, 50);
|
||||
}
|
||||
else {
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getCompletions(token, startingTag) {
|
||||
|
||||
var found = [], start = token.string;
|
||||
|
||||
function maybeAdd(str) { if (str.indexOf(start) == 0) found.push(str); }
|
||||
|
||||
// Check if this is a starting tag
|
||||
if(startingTag) { forEach(tagNames, maybeAdd) }
|
||||
else { forEach(pairedTags, maybeAdd) }
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,268 @@
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: 300px;
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
/* Set scrolling behaviour here */
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
background-color: white; /* The little square between H and V scrollbars */
|
||||
}
|
||||
|
||||
/* GUTTER */
|
||||
|
||||
.CodeMirror-gutters {
|
||||
border-right: 1px solid #ddd;
|
||||
background-color: #f7f7f7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.CodeMirror-linenumbers {}
|
||||
.CodeMirror-linenumber {
|
||||
padding: 0 3px 0 5px;
|
||||
min-width: 20px;
|
||||
text-align: right;
|
||||
color: #999;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
z-index: 3;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
z-index: 1;
|
||||
}
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||
|
||||
.cm-tab { display: inline-block; }
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
.cm-s-default .cm-def {color: #00f;}
|
||||
.cm-s-default .cm-variable {color: black;}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3 {color: #085;}
|
||||
.cm-s-default .cm-property {color: black;}
|
||||
.cm-s-default .cm-operator {color: black;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
.cm-s-default .cm-meta {color: #555;}
|
||||
.cm-s-default .cm-qualifier {color: #555;}
|
||||
.cm-s-default .cm-builtin {color: #30a;}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
|
||||
/* STOP */
|
||||
|
||||
/* The rest of this file contains styles related to the mechanics of
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px; padding-right: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
}
|
||||
.CodeMirror-gutter-filler {
|
||||
left: 0; bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
padding-bottom: 30px;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: -32px;
|
||||
display: inline-block;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
}
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
.CodeMirror-code pre {
|
||||
border-right: 30px solid transparent;
|
||||
width: -webkit-fit-content;
|
||||
width: -moz-fit-content;
|
||||
width: fit-content;
|
||||
}
|
||||
.CodeMirror-wrap .CodeMirror-code pre {
|
||||
border-right: none;
|
||||
width: auto;
|
||||
}
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-widget {}
|
||||
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.CodeMirror-focused div.CodeMirror-cursor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
.searched {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
33
public/admin/plugins/tmce/codemagic/plugin.js
Normal file
33
public/admin/plugins/tmce/codemagic/plugin.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Josh Lobe
|
||||
* http://ultimatetinymcepro.com
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
|
||||
tinymce.PluginManager.add('codemagic', function(editor, url) {
|
||||
|
||||
|
||||
editor.addButton('codemagic', {
|
||||
|
||||
image: url + '/images/codemagic.png',
|
||||
tooltip: 'Code Magic',
|
||||
onclick: open_codemagic
|
||||
});
|
||||
|
||||
function open_codemagic() {
|
||||
|
||||
editor.windowManager.open({
|
||||
|
||||
title: 'Code Magic',
|
||||
width: 900,
|
||||
height: 700,
|
||||
url: url+'/codemagic.htm'
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
33
public/admin/plugins/tmce/codemagic/plugin.min.js
vendored
Normal file
33
public/admin/plugins/tmce/codemagic/plugin.min.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Josh Lobe
|
||||
* http://ultimatetinymcepro.com
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
|
||||
tinymce.PluginManager.add('codemagic', function(editor, url) {
|
||||
|
||||
|
||||
editor.addButton('codemagic', {
|
||||
|
||||
image: url + '/images/codemagic.png',
|
||||
tooltip: 'Code Magic',
|
||||
onclick: open_codemagic
|
||||
});
|
||||
|
||||
function open_codemagic() {
|
||||
|
||||
editor.windowManager.open({
|
||||
|
||||
title: 'Code Magic',
|
||||
width: 900,
|
||||
height: 700,
|
||||
url: url+'/codemagic.htm'
|
||||
})
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user